| | |
| | | #include "mk_uart.h" |
| | | #include "mk_spi.h" |
| | | #include "mk_flash.h" |
| | | #include "Usart.h" |
| | | #include <serial_at_cmd_app.h> |
| | | #include <global_param.h> |
| | | |
| | | #include "board.h" |
| | | |
| | |
| | | //***************************************************************************** |
| | | #define WSF_BUF_POOLS 5 |
| | | void Fira_Change_Task(void); |
| | | extern uint8_t normal_flag,log_4g_enable_flag; |
| | | extern uint16_t ip0,ip1,ip2,ip3,port; |
| | | uint8_t group_id,enable_sleep_count; |
| | | uint32_t dev_id; |
| | | uint16_t disoffset; |
| | | // Default pool descriptor. |
| | | static wsfBufPoolDesc_t poolDescriptors[WSF_BUF_POOLS] = { |
| | | {32, 26}, {64, 24}, {128, 4}, {256 + 32, 4}, {1024 + 32, 2}, |
| | |
| | | { |
| | | // LOG_INFO(TRACE_MODULE_APP, "Wake up by sleep timer %d\r\n", time); |
| | | } |
| | | |
| | | void Program_Init(void) |
| | | { |
| | | Usart1ParseDataCallback = UsartParseDataHandler;//需改为默认为gps处理,UsartParseDataHandler为升级处理当调试时候改为 |
| | | parameter_init_anchor();//g_com_map表初始化角色默认为基站 |
| | | dev_id=g_com_map[DEV_ID];//这里不太对 |
| | | group_id=(uint8_t)g_com_map[GROUP_ID];//组ID |
| | | // tag_frequency = 1000/g_com_map[COM_INTERVAL];//测距频率这个存的是测距时间 |
| | | memcpy(&disoffset,&g_com_map[DIST_OFFSET],2); |
| | | // g_com_map[ALARM_DISTANCE1] = 40; |
| | | // g_com_map[ALARM_DISTANCE2] = 40; |
| | | // warning_distance=g_com_map[ALARM_DISTANCE1]; |
| | | // prewarning_distance=g_com_map[ALARM_DISTANCE2]; |
| | | //g_com_map[SEND_4G_SECOND] |
| | | // if(g_com_map[SEND_4G_SECOND]<30) |
| | | // { |
| | | // gps_open_flag=0; |
| | | // }else{ |
| | | // gps_open_flag=1; |
| | | // } |
| | | g_com_map[MODBUS_MODE] = 0; |
| | | log_4g_enable_flag=g_com_map[LOG_4G_ENABLE]; |
| | | ip0 = (g_com_map[TCP_IP_0]>>12&0xf)*1000+(g_com_map[TCP_IP_0]>>8&0xf)*100+(g_com_map[TCP_IP_0]>>4&0xf)*10+(g_com_map[TCP_IP_0]&0xf); |
| | | ip1 = (g_com_map[TCP_IP_1]>>12&0xf)*1000+(g_com_map[TCP_IP_1]>>8&0xf)*100+(g_com_map[TCP_IP_1]>>4&0xf)*10+(g_com_map[TCP_IP_1]&0xf); |
| | | ip2 = (g_com_map[TCP_IP_2]>>12&0xf)*1000+(g_com_map[TCP_IP_2]>>8&0xf)*100+(g_com_map[TCP_IP_2]>>4&0xf)*10+(g_com_map[TCP_IP_2]&0xf); |
| | | ip3 = (g_com_map[TCP_IP_3]>>12&0xf)*1000+(g_com_map[TCP_IP_3]>>8&0xf)*100+(g_com_map[TCP_IP_3]>>4&0xf)*10+(g_com_map[TCP_IP_3]&0xf); |
| | | port = g_com_map[TCP_PORT]; |
| | | g_com_map[VERSION] = (1<<8)|0; |
| | | LOG_INFO(TRACE_MODULE_APP,"设备ID: %x .\r\n",dev_id); |
| | | LOG_INFO(TRACE_MODULE_APP,"固件版本:4G-GPS定位手环 V%d.%d. \r\n",g_com_map[VERSION]>>8,g_com_map[VERSION]&0xff); |
| | | LOG_INFO(TRACE_MODULE_APP,"服务器地址: %d.%d.%d.%d:%d.\r\n",ip0,ip1,ip2,ip3,port); |
| | | } |
| | | static void board_init(void) |
| | | { |
| | | uint32_t internal_flash = (REG_READ(0x40000018) >> 17) & 0x1; |
| | |
| | | // Configure IO_04 for RF Switch |
| | | gpio_pin_set_dir(IO_PIN_4, GPIO_DIR_OUT, 0); |
| | | #else |
| | | Program_Init(); |
| | | // led |
| | | board_led_init(); |
| | | // board_led_init(); |
| | | // board_led_on(BOARD_LED_1); |
| | | #endif |
| | | board_configure(); |
| | |
| | | void Fira_Change_Task(void) |
| | | { |
| | | } |
| | | extern uint8_t normal_flag; |
| | | |
| | | static void uart_receive_callback(void *dev, uint32_t err_code) |
| | | { |
| | | uart_receive(UART_ID1,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart_receive_callback); |
| | | } |
| | | |
| | | int main(void) |
| | | { |
| | | // Initialize MCU system |
| | |
| | | |
| | | // Enable sleep timer |
| | | sleep_timer_open(true, SLEEP_TIMER_MODE_ONESHOT, sleep_timer_callback); |
| | | |
| | | uart_receive(UART_ID1,m_EUART_DMA_RXBuf,EUART_RX_BUF_SIZE,uart_receive_callback); |
| | | while (1) |
| | | { |
| | | wsfOsDispatcher(); |