P100脱机下载器
You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

82 lines
1.9 KiB

4 years ago
  1. #include "sys.h"
  2. #include "delay.h"
  3. #include "led.h"
  4. #include "UID_Encryption.h"
  5. /* ʵ��Ŀ�ģ�
  6. ʾνѻUIDԶܹӵûĴ
  7. */
  8. /* ʵ��������
  9. ֤ͨLED1LED21000msƵʽ˸
  10. ֤ͨLED1LED2100msƵʽ˸
  11. */
  12. /******************* UID�Զ������ܲ������� *******************/
  13. /*
  14. * ǰоƬUIDڵַעݲͬоƬĵַһ,ûð޸ģ
  15. * оƬUIDĻûUIDƴյһڴʹUID_Encryption_Key_Check()ӿ
  16. */
  17. #define UID_BASE 0x1FFF7A10
  18. /*
  19. * ԿڵǰоƬеĴַ
  20. *עûʹʱ޸ĸֵռûλüоƬflashķΧλԿַһ£
  21. */
  22. #define KEY_BASE 0x08020000
  23. /* �û��ԵĶ���ID */
  24. const uint8_t custom_id[12] = {0x1, 0x2, 0x3, 0x4, 0x5, 0x6, 0x7, 0x8, 0x9, 0xA, 0xB, 0xC};
  25. int main(void)
  26. {
  27. Stm32_Clock_Init(336,8,2,7);//����ʱ��,168Mhz
  28. delay_init(168); //��ʼ����ʱ����
  29. LED_Init(); //��ʼ��LEDʱ��
  30. /* ��֤UID�Զ������ܵ���Կ�Ƿ���ȷ */
  31. if(UID_Encryption_Key_Check((void*)KEY_BASE,
  32. (void*)UID_BASE,
  33. (void*)custom_id,
  34. LENGTH_12,
  35. LITTLE_ENDIA,
  36. ALGORITHM_4))
  37. {/* ��֤��ͨ�� */
  38. while(1) //LED����
  39. {
  40. LED0=0; //DS0��
  41. LED1=1; //DS1��
  42. delay_ms(100);
  43. LED0=1; //DS0��
  44. LED1=0; //DS1��
  45. delay_ms(100);
  46. }
  47. }
  48. else
  49. {/* ��֤ͨ�� */
  50. }
  51. while(1)//LED����
  52. {
  53. LED0=0; //DS0��
  54. LED1=1; //DS1��
  55. delay_ms(1000);
  56. LED0=1; //DS0��
  57. LED1=0; //DS1��
  58. delay_ms(1000);
  59. }
  60. }