main.c 20 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144
  1. #include "main.h"
  2. #include "sram.h"
  3. #include "nandflash.h"
  4. #include "usart.h"
  5. #include "malloc.h"
  6. #include "demo_nand_fatfs.h"
  7. #include "cjson.h"
  8. #include "delay.h"
  9. #include "string.h"
  10. #include "led.h"
  11. #include "log.h"
  12. #include "task.h"
  13. #include "myfile.h"
  14. //设置任务优先级
  15. #define START_TASK_PRIO 10 //开始任务的优先级设置为最低
  16. //设置任务堆栈大小
  17. #define START_STK_SIZE 128
  18. //任务堆栈
  19. OS_STK START_TASK_STK[START_STK_SIZE];
  20. //任务函数
  21. void start_task(void *pdata);
  22. //LED任务
  23. //设置任务优先级
  24. #define LED_TASK_PRIO 9
  25. //设置任务堆栈大小
  26. #define LED_STK_SIZE 64
  27. //任务堆栈
  28. OS_STK LED_TASK_STK[LED_STK_SIZE];
  29. //任务函数
  30. void led_task(void *pdata);
  31. //网络状态灯任务
  32. #define NET_STATUS_LED_TASK_PRIO 8
  33. //设置任务堆栈大小
  34. #define NET_STATUS_LED_STK_SIZE 64
  35. //任务堆栈
  36. OS_STK NET_STATUS_LED_TASK_STK[NET_STATUS_LED_STK_SIZE];
  37. //任务函数
  38. void net_status_led_task(void *pdata);
  39. OS_STK DATA_TASK_STK[DATA_STK_SIZE];
  40. void NVIC_Configuration(void);
  41. int main(void)
  42. {
  43. delay_init();
  44. NVIC_Configuration();
  45. NAND_Init();
  46. USART_232_config();
  47. LED_GPIO_Config();
  48. NET_STATUS_LED_Config();
  49. /*
  50. char *lora_test_json=malloc(15*1024);
  51. lora_test_json="{\"deviceId\":\"D4AD20641630\",\"nodeList\":[\"00122B9D\",\"00122BAF\"],\"codeRate\":4700,\"pollTime\":2000,\"inboundTime\":6000,\"bandwidth\":250,\"dataRate\":7,\"power\":22,\"preambleLen\":0,\"messageTopic\":\"/device/D4AD20641630\",\"port\":1883,\"host\":\"36.134.23.11\",\"commandTopic\":\"/device/D4AD20641630/command\",\"read_00122BAF\":[{\"registerByteNum\":0,\"identifier\":\"electric_fr\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":2,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"pActiveEnergy\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":2,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"rActiveEnergy\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"activePower\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"electric_fra\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"electric_frb\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"electric_frc\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"Ua\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":1,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"Ub\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":1,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"Uc\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":1,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"Ia\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"Ib\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"Ic\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"reactivePower\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"electric_pqa\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"electric_pqb\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"electric_pqc\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"powerFactor\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"electric_pfa\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"electric_pfb\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"electric_pfc\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"innerTemp\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":1,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"lastMonthEnergy\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":2,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"lastTwoMonthEnergy\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":2,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"totalPostMaximum\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"lastPostMaximum\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":0,\"deviceId\":\"209220000004\"},{\"registerByteNum\":0,\"identifier\":\"electric_fr\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":2,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"pActiveEnergy\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":2,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"rActiveEnergy\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"activePower\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"electric_fra\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"electric_frb\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"electric_frc\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"Ua\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":1,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"Ub\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":1,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"Uc\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":1,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"Ia\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"Ib\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"Ic\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"reactivePower\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"electric_pqa\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"electric_pqb\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"electric_pqc\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"powerFactor\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"electric_pfa\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"electric_pfb\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"electric_pfc\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"innerTemp\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":1,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"lastMonthEnergy\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":2,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"lastTwoMonthEnergy\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":2,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"totalPostMaximum\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000003\"},{\"registerByteNum\":0,\"identifier\":\"lastPostMaximum\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":0,\"deviceId\":\"209220000003\"}],\"read_00122B9D\":[{\"registerByteNum\":0,\"identifier\":\"electric_fr\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":2,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"pActiveEnergy\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":2,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"rActiveEnergy\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"activePower\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"electric_fra\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"electric_frb\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"electric_frc\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"Ua\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":1,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"Ub\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":1,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"Uc\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":1,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"Ia\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"Ib\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"Ic\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"reactivePower\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"electric_pqa\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"electric_pqb\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"electric_pqc\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"powerFactor\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"electric_pfa\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"electric_pfb\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"electric_pfc\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"innerTemp\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":1,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"lastMonthEnergy\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":2,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"lastTwoMonthEnergy\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":2,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"totalPostMaximum\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"lastPostMaximum\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":0,\"deviceId\":\"209320056717\"},{\"registerByteNum\":0,\"identifier\":\"electric_fr\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":2,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"pActiveEnergy\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":2,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"rActiveEnergy\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"activePower\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"electric_fra\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"electric_frb\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"electric_frc\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"Ua\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":1,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"Ub\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":1,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"Uc\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":1,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"Ia\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"Ib\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"Ic\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"reactivePower\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"electric_pqa\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"electric_pqb\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"electric_pqc\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"powerFactor\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"electric_pfa\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"electric_pfb\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"electric_pfc\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":3,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"innerTemp\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":1,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"lastMonthEnergy\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":2,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"lastTwoMonthEnergy\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":2,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"totalPostMaximum\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":4,\"deviceId\":\"209220000002\"},{\"registerByteNum\":0,\"identifier\":\"lastPostMaximum\",\"rFunctionCode\":0,\"registerAddress\":0,\"bigLittleFormat\":1,\"precise\":0,\"deviceId\":\"209220000002\"}]}\r\n\0";
  52. write_file("lora_json.txt",lora_test_json,strlen(lora_test_json));
  53. free(lora_test_json);
  54. */
  55. //ucos初始化
  56. OSInit();
  57. OSTaskCreate(start_task,(void*)0,(OS_STK*)&START_TASK_STK[START_STK_SIZE-1],START_TASK_PRIO);
  58. OSStart();
  59. /* Infinite loop */
  60. while (1)
  61. {
  62. }
  63. }
  64. void start_task(void *pdata)
  65. {
  66. OS_CPU_SR cpu_sr;
  67. pdata = pdata ;
  68. OSStatInit(); //初始化统计任务
  69. OS_ENTER_CRITICAL(); //关中断
  70. #if LWIP_DHCP
  71. lwip_comm_dhcp_creat(); //创建DHCP任务
  72. OSTimeDlyHMSM(0,0,2,500);
  73. #endif
  74. OSTaskCreate(led_task,(void*)0,(OS_STK*)&LED_TASK_STK[LED_STK_SIZE-1],LED_TASK_PRIO);//创建LED任务
  75. OSTaskCreate(net_status_led_task,(void*)0,(OS_STK*)&NET_STATUS_LED_TASK_STK[NET_STATUS_LED_STK_SIZE-1],NET_STATUS_LED_TASK_PRIO);//创建LED任务
  76. OSTaskCreate(data_task,(void*)0,(OS_STK*)&DATA_TASK_STK[DATA_STK_SIZE-1],DATA_TASK_PRIO);
  77. OSTaskSuspend(OS_PRIO_SELF); //挂起start_task任务
  78. OS_EXIT_CRITICAL(); //开中断
  79. }
  80. //测试任务
  81. void led_task(void *pdata)
  82. {
  83. OS_CPU_SR cpu_sr;
  84. pdata = pdata ;
  85. while(1)
  86. {
  87. LED(ON);
  88. OSTimeDlyHMSM(0,0,0,500);
  89. LED(OFF);
  90. OSTimeDlyHMSM(0,0,0,500);
  91. }
  92. }
  93. void net_status_led_task(void *pdata)
  94. {
  95. OS_CPU_SR cpu_sr;
  96. pdata = pdata ;
  97. while(1)
  98. {
  99. NET_STATUS_LED(ON);
  100. OSTimeDlyHMSM(0,0,0,500);
  101. NET_STATUS_LED(OFF);
  102. OSTimeDlyHMSM(0,0,0,500);
  103. }
  104. }
  105. void bsp_Idle(void)
  106. {
  107. /* --- 喂狗 */
  108. /* --- 让CPU进入休眠,由Systick定时中断唤醒或者其他中断唤醒 */
  109. }
  110. /**
  111. * @brief 配置嵌套向量中断控制器NVIC分组
  112. * @param 无
  113. * @retval 无
  114. */
  115. void NVIC_Configuration(void)
  116. {
  117. NVIC_InitTypeDef NVIC_InitStructure;
  118. /* 嵌套向量中断控制器组选择 */
  119. NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
  120. }