main.c 1.7 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485
  1. #include "CommandsDefine.h"
  2. #include "ProjectConfig.h"
  3. #include "AnalogChannelCtrl.h"
  4. #include "AnalogChannelCtrl_2d5g_base.h"
  5. #include "sys.h"
  6. #include "timer.h"
  7. #include "delay.h"
  8. #include "iwdg.h"
  9. #include "DS18B20.h"
  10. #include "iap.h"
  11. #include "Helper.h"
  12. //#include "OuterPanel_LED.h"
  13. //#include "Probe.h"
  14. int flag = 0;
  15. int port1 = 4;
  16. //int port2 = 7;
  17. int dacid = 1;
  18. //u8 testLed =0;
  19. //u8 ledTestEnable =0;
  20. int main(void)
  21. {
  22. MainInit();
  23. Helper_CRC32_Init();
  24. //LED_ALL(0xFF);
  25. #ifndef RUNNING_WHERE_AT_BOOT
  26. int i=0;
  27. DAC_AD5675((1<<(16+5))|( unsigned short)(0x7FFF),1);
  28. DAC_AD5675((1<<(16+5))|( unsigned short)(0x7FFF),2);
  29. u8 setData1= 0x1f;
  30. u8 setData2= 0x00;
  31. for(int i=0; i<MAX_CHANNEL_NUM; i++)
  32. {
  33. DSA_PE43711(LMH6401_ADDR_TEMPCORRECT_GAIN,setData1,1+i);
  34. DSA_PE43711(LMH6401_ADDR_TEMPCORRECT_FREQ,setData2,1+i);
  35. }
  36. //启动后通知APP,需要重新发送通道等信息,是一个Mcu意外重新启动后的补救措施
  37. Command_SendbackAppStartTime();
  38. int delay50usTimes=0;
  39. while(delay50usTimes<1000)
  40. {
  41. if(i%100==0)
  42. {
  43. IWDG_Feed();//喂狗
  44. }
  45. i++;
  46. delay_us(50);
  47. delay50usTimes++;
  48. }
  49. i=0;
  50. Command_SendbackAppStartTime();//间隔500ms发两次
  51. #else
  52. iap_WriteBootVersionInfo();
  53. #endif
  54. while(1)
  55. {
  56. delay_us(50);
  57. #ifndef RUNNING_WHERE_AT_BOOT
  58. if(i%100==0)
  59. {
  60. IWDG_Feed();//喂狗
  61. }
  62. AnalogChCtrl_ProtectProcess();
  63. Command_ProcessRequestCmds();
  64. if(IsChannelSetting==1)
  65. {
  66. continue;
  67. }
  68. if(i>=1000)
  69. {
  70. Timer_ReadBack_ProbeStatus(1,1);
  71. i=0;
  72. }
  73. i++;
  74. #else
  75. Command_ProcessRequestCmds();
  76. #endif
  77. }
  78. }