main.c 1.7 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687
  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. DS18B20_Get_Temp();
  28. DS18B20_Get_Temp();
  29. DAC_AD5675((1<<(16+5))|( unsigned short)(0x7FFF),1);
  30. DAC_AD5675((1<<(16+5))|( unsigned short)(0x7FFF),2);
  31. u8 setData1= 0x1f;
  32. u8 setData2= 0x00;
  33. for(int i=0; i<MAX_CHANNEL_NUM; i++)
  34. {
  35. DSA_PE43711(LMH6401_ADDR_TEMPCORRECT_GAIN,setData1,1+i);
  36. DSA_PE43711(LMH6401_ADDR_TEMPCORRECT_FREQ,setData2,1+i);
  37. }
  38. //启动后通知APP,需要重新发送通道等信息,是一个Mcu意外重新启动后的补救措施
  39. Command_SendbackAppStartTime();
  40. int delay50usTimes=0;
  41. while(delay50usTimes<1000)
  42. {
  43. if(i%100==0)
  44. {
  45. IWDG_Feed();//喂狗
  46. }
  47. i++;
  48. delay_us(50);
  49. delay50usTimes++;
  50. }
  51. i=0;
  52. Command_SendbackAppStartTime();//间隔500ms发两次
  53. #else
  54. iap_WriteBootVersionInfo();
  55. #endif
  56. while(1)
  57. {
  58. delay_us(50);
  59. #ifndef RUNNING_WHERE_AT_BOOT
  60. if(i%100==0)
  61. {
  62. IWDG_Feed();//喂狗
  63. }
  64. AnalogChCtrl_ProtectProcess();
  65. Command_ProcessRequestCmds();
  66. if(IsChannelSetting==1)
  67. {
  68. continue;
  69. }
  70. if(i>=1000)
  71. {
  72. Timer_ReadBack_ProbeStatus(1,1);
  73. DS18B20_Get_Temp();
  74. i=0;
  75. }
  76. i++;
  77. #else
  78. Command_ProcessRequestCmds();
  79. #endif
  80. }
  81. }