User_Main.c 1.5 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869
  1. #include "DSP2803x_Device.h" // DSP2803x Headerfile Include File
  2. #include "DSP2803x_Examples.h" // DSP2803x Examples Include File
  3. #include "Flash2803x_API_Library.h"
  4. //0x3F 7FF6 and 0x3F 7FF7ÊdzÌÐòµÄÈë¿Ú
  5. #define BOOT_ENTRY_POINT 0x3F3FF6
  6. struct BOOTSTATUS BootStatus;
  7. void (*program)() = (void (*)())(BOOT_ENTRY_POINT);
  8. void InitVar(void);
  9. void SystemTimer(void);
  10. Uint32 SystemTime = 0;
  11. //#pragma CODE_SECTION(main,"ramfuncs");
  12. main()
  13. {
  14. InitSysCtrl();
  15. InitGpio();
  16. InitECan();
  17. InitVar();
  18. DisableDog();
  19. MemCopy(&RamfuncsLoadStart, &RamfuncsLoadEnd, &RamfuncsRunStart);
  20. MemCopy(&Flash28_API_LoadStart, &Flash28_API_LoadEnd, &Flash28_API_RunStart);
  21. InitFlash();
  22. DINT;
  23. IER = 0x0000;
  24. IFR = 0x0000;
  25. while(BootStatus.Reboot)
  26. {
  27. RunLedControl();
  28. CanMaster();
  29. SystemTimer();
  30. }
  31. program();
  32. }
  33. //---------------------------------------------------------------
  34. void InitVar()
  35. {
  36. BootStatus.Reboot = 1;
  37. BootStatus.WorkStatus = 1;
  38. BootStatus.HexRow = 0;
  39. BootStatus.FrameId = 0;
  40. BootStatus.LineDataLen = 0;
  41. BootStatus.LineId = 0;
  42. BootStatus.SendNum = SHAKE_FIR_ACK;
  43. }
  44. //---------------------------------------------------------------
  45. void SystemTimer()
  46. {
  47. SystemTime++;
  48. if(SystemTime > 1000000)
  49. {
  50. if(BootStatus.Reboot == BOOT_SHAKE_SUCCESS)
  51. {
  52. SystemTime = 0;
  53. }else
  54. {
  55. BootStatus.Reboot = FALSE;
  56. }
  57. }
  58. }
  59. //===========================================================================
  60. // End of file.
  61. //===========================================================================