#include "sys.h"
#include "can.h"
#include "adc.h"
#include "dma.h"
#include "rtc.h"
#include "iic.h"
#include "gpio.h"
#include "oled.h"
#include "wwdg.h"
#include "gprs.h"
//#include "adxl.h"
#include "uart1.h"
#include "uart2.h"
#include "uart3.h"
#include "timer.h"
#include "myiic.h"
#include "dht11.h"
#include "delay.h"
#include "malloc.h"
#include "ds18b20.h"
#include "mpu6050.h"
#include "adxl345.h"
#include "inv_mpu.h"
#include "rc522_hw.h"
#include "stmflash.h"
#include "lora_app.h"
#include "user_config.h"
#include "softwaretimer.h"
#include "esp8266_sta_at.h"
#include "esp8266_sdk_mqtt.h"
#include "lis3dh_driver_spi.h"
#include "rc522_application.h"
#include "inv_mpu_dmp_motion_driver.h"
void Usart_Test(void);
typedef u8 (init_fnc_t) (void);
init_fnc_t *init_sequence[] = {
mem_init, //内存管理初始化
LED_Init, //LED 初始化
Adc_Init, //ADC 初始化
DHT11_Init,
ESP8266_MQTT_Init,
NULL,
};
init_fnc_t **init_fnc_ptr;
typedef void (test_fnc_t) (void);
test_fnc_t *test_sequence[] = {
Usart_Test,
//GPIO_Test,
DHT11_Test,
ADC_Test,
ESP8266_MQTT_Test,
NULL,
};
test_fnc_t **test_fnc_ptr;
u8 initcall_run_list(init_fnc_t*);
u8 do_loop(void);
int main(void)
{
u8 init_flag = 0;
u32 count = 0;
u32 num = 0;
HAL_Init(); //初始化HAL库
Stm32_Clock_Init(RCC_PLL_MUL9); //设置时钟,72M
delay_init(72); //初始化延时函数
uart1_init(9600); //初始化串口一 115200
uart2_init(115200); //初始化串口二 115200
uart3_init(115200); //初始化串口二 115200
LogLevel_3("Init OK--");
while(0 == init_flag)
{
init_flag = 1;
for (init_fnc_ptr = init_sequence; *init_fnc_ptr; ++init_fnc_ptr)
{
if ((*init_fnc_ptr)() != 0) {
init_flag = 0;
LogLevel_3("Init ERROR\r\n");
delay_ms(300);
}
}
}
DisplayPosition();
LogLevel_3("Init OK");
// WWDG_Init(0X7F,0X5F,WWDG_PRESCALER_8); //计数器值为7F,窗口寄存器为5F,分频数为8
while(1)
{
count++;
if(count == 100)//周期进行
{
count = 0;
for (test_fnc_ptr = test_sequence; *test_fnc_ptr; ++test_fnc_ptr)
{
(*test_fnc_ptr)();
}
// LogLevel_1("count:%d",count++);
}
delay_ms(10);
}
}
u8 k1=0,k2=0,k3=0;
void Usart_Test(void)
{
u32 UART1_length = 0;
u32 UART2_length = 0;
u32 UART3_length = 0;
if(UART1_RX_STA&0X8000) //接收到一次数据了
{
UART1_length=UART1_RX_STA&0X7FFF; //得到本次接收到的数据长度
UART1_RX_BUF[UART1_length]=0; //添加结束符
LogLevel_3("UART1_length:%d\r\n",UART1_length);
LogLevel_3("%s\r\n",UART1_RX_BUF);
UART1_RX_STA=0;
}
/* if(UART2_RX_STA&0X8000) //接收到一次数据了
{
UART2_length=UART2_RX_STA&0X7FFF; //得到本次接收到的数据长度
UART2_RX_BUF[UART2_length]=0; //添加结束符
u2_printf("UART2_length:%d\r\n",UART2_length);
u2_printf("%s\r\n",UART2_RX_BUF);
UART2_RX_STA=0;
}*/
if(UART3_RX_STA&0X8000) //接收到一次数据了
{
UART3_length=UART3_RX_STA&0X7FFF; //得到本次接收到的数据长度
UART3_RX_BUF[UART3_length]=0; //添加结束符
u3_printf("UART3_length:%d\r\n",UART3_length);
u3_printf("%s\r\n",UART3_RX_BUF);
UART3_RX_STA=0;
}
}