/** ****************************************************************************** * File Name : main.c * Description : Main program body ****************************************************************************** ** This notice applies to any and all portions of this file * that are not between comment pairs USER CODE BEGIN and * USER CODE END. Other portions of this file, whether * inserted by the user or by software development tools * are owned by their respective copyright owners. * * COPYRIGHT(c) 2019 STMicroelectronics * * Redistribution and use in source and binary forms, with or without modification, * are permitted provided that the following conditions are met: * 1. Redistributions of source code must retain the above copyright notice, * this list of conditions and the following disclaimer. * 2. Redistributions in binary form must reproduce the above copyright notice, * this list of conditions and the following disclaimer in the documentation * and/or other materials provided with the distribution. * 3. Neither the name of STMicroelectronics nor the names of its contributors * may be used to endorse or promote products derived from this software * without specific prior written permission. * * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ****************************************************************************** */ /* Includes ------------------------------------------------------------------*/ #include "main.h" #include "stm32f1xx_hal.h" #include "delay.h" #include "sys.h" #include "usart.h" #include "led.h" #include "usmart.h" #include "24cxx.h" #include "task.h" #include "sim7600.h" #include "iwdg.h" #include "gpio.h" const u8 TEXT_Buffer[]={"4G_SIM7600C STM32F103 IIC TEST"}; BOOL posted = false; #define SIZE sizeof(TEXT_Buffer) void http_post_callback(char *buffer) { PRINTF(buffer); posted = true; } int main(void) { u8 datatemp[SIZE]; task *task; // u8 time; HAL_Init(); Stm32_Clock_Init(RCC_PLL_MUL9); //设置时钟,72M delay_init(72); //初始化延时函数 uart2_init(115200); //初始化串口2 uart3_init(115200); //初始化串口3 usmart_dev.init(36); //初始化USMART LED_Init(); //初始化LED sim7600_rst(); AT24CXX_Init(); //初始化IIC // time=RTC_Init(); //初始化RTC // sim7600_Init(); //4G模块初始化 while(AT24CXX_Check())//检测不到24c02 { // SIM7600_led=0; delay_ms(50); SIM7600_led=1; delay_ms(50); } // AT24CXX_Write(0,(u8*)TEXT_Buffer,SIZE); // delay_us(50); AT24CXX_Read(0,datatemp,SIZE); SIM7600_led=1; while (1) { if(MODULE_OFF_LINE == get_module_status()) { module_system_start(); } else if(MODULE_SYNC == get_module_status()) { module_system_init(); } else if(MODULE_GET_IP == get_module_status()) { set_module_status(MODULE_INIT_DONE); PRINTF("Init Getway\r\n"); SIM7600_led=0; if(!posted){ module_http_post("http://118.190.199.225:8099/test", "", http_post_callback); posted = true; } } while((task = pop_task()) != NULL) { if(task->handler != NULL) { task->handler(task->pdata); //delete_task(task); } if(task != NULL) { delete_task(task); } } } } /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/