123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167 |
- #include "main.h"
- #include "sram.h"
- #include "nandflash.h"
- #include "usart.h"
- #include "malloc.h"
- #include "demo_nand_fatfs.h"
- #include "cjson.h"
- #include "delay.h"
- #include "string.h"
- #include "includes.h"
- #include "lwip/timers.h"
- #include "led.h"
- #include "sys_tcpdemo.h"
- #include "sys_mqtt.h"
- #include "sys_http.h"
- #include "task.h"
- #include "sys_sx1278.h"
- /*关于任务优先级分配(上限为12个、需要增加请修改上限)
- * 0: 保留
- * 1: 用于ucos的软件定时器
- * 2: 保留
- * 3: 用于 以太网的网卡数据包读取 ETHERNETIF_THREAD_PRO
- * 4: LWIP 核心线程 TCPIP_THREAD_PRIO
- * 5: 用于 ota升级
- * 6: 用于 MQTT数据发送线程 APP_TASK_MQTTMAIN_PRIO
- * 7: 用于 MQTT数据接收线程 APP_TASK_MQTTRECEIVE_PRIO
- * 8: 用于 sx1278发送/接收处理数据
- * 9: 用于 本机状态led显示
- * 10:用于网络状态led显示
- * 11:用于轮询读出本机保存信息发送到sx1278发送接收线程
- * 12:用于管理所有线程
- */
- ///////////////////////////////////////
- #define PERIOD_TASK_PRIO 2
- #define PERIOD_STK_SIZE 256
- OS_STK PERIOD_TASK_STK[PERIOD_STK_SIZE];
- void period_taskFuntcion(void *arg);
- //////////////////////////////////////////////
- //LED
- //LED优先级
- #define LED_TASK_PRIO 28
- //LED栈空间大小
- #define LED_STK_SIZE 128
- //任务堆栈
- OS_STK LED_TASK_STK[LED_STK_SIZE];
- //led运行任务
- void led_taskFuntcion(void *pdata);
- ////////////////////////////////////////////////////////
- /*---------------------------本地数据线程堆栈----------------------------------------------------------------*/
- __align(8) OS_STK DATA_TASK_STK[DATA_STK_SIZE];
- /*---------------------------lora通信线程堆栈----------------------------------------------------------------*/
- __align(8) OS_STK SX1278_TASK_STK[SX1278_STK_SIZE];
- void NVIC_Configuration(void);
- int main(void)
- {
- NVIC_Configuration();
- my_mem_init(SRAMEX);
- my_mem_init(SRAMIN);
- delay_init();
-
- //nandflash并不用初始化,调用fafts时会初始化
- NET_STATUS_LED_Config();
- USART_485_config();
- USART_232_config();
- NAND_Init();
- OSInit();
- //OSTaskCreate(start_task,(void*)0,(OS_STK*)&START_TASK_STK[START_STK_SIZE-1],START_TASK_PRIO);
- OSTaskCreate(period_taskFuntcion,(void*)0,(OS_STK*)&PERIOD_TASK_STK[PERIOD_STK_SIZE-1],PERIOD_TASK_PRIO);
- OSTaskCreate(led_taskFuntcion,(void*)0,(OS_STK*)&LED_TASK_STK[LED_STK_SIZE-1],LED_TASK_PRIO);
- OSTaskCreate(data_task,(void*)0,(OS_STK*)&DATA_TASK_STK[DATA_STK_SIZE-1],DATA_TASK_PRIO);
- OSTaskCreate(sx1278_send_task,(void *)0,(OS_STK*)&SX1278_TASK_STK[SX1278_STK_SIZE-1],SX1278_TASK_PRIO);
- printf("system start \r\n");
- OSStart(); //ucos启动
- /* Infinite loop */
- while (1)
- {
-
- }
-
- }
- void period_taskFuntcion(void *arg)
- {
-
-
- #if OS_TASK_STAT_EN > 0u
- OSStatInit();
- #endif
-
- lwIP_Init();
-
- http_getDemo();
- http_postDemo();
-
- mqtt_threadCreate();
-
- OSTaskSuspend(OS_PRIO_SELF);
- }
- //测试任务
- void led_taskFuntcion(void *pdata)
- {
- int tms;
-
- while(1)
- {
- tms = hd_netledOpen();
- OSTimeDly(tms);
-
- tms = hd_netledClose();
- OSTimeDly(tms);
- }
- }
- void bsp_Idle(void)
- {
- /* --- 喂狗 */
- /* --- 让CPU进入休眠,由Systick定时中断唤醒或者其他中断唤醒 */
- }
- /**
- * @brief 配置嵌套向量中断控制器NVIC分组
- * @param 无
- * @retval 无
- */
- void NVIC_Configuration(void)
- {
- // NVIC_InitTypeDef NVIC_InitStructure;
-
- /* 嵌套向量中断控制器组选择 */
- NVIC_PriorityGroupConfig(NVIC_PriorityGroup_2);
-
- }
- #ifdef USE_FULL_ASSERT
- /**
- * @brief Reports the name of the source file and the source line number
- * where the assert_param error has occurred.
- * @param file: pointer to the source file name
- * @param line: assert_param error line source number
- * @retval None
- */
- void assert_failed(uint8_t* file, uint32_t line)
- {
- /* User can add his own implementation to report the file name and line number,
- ex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */
- /* Infinite loop */
- while (1)
- {}
- }
- #endif
|