2024-04-15 09:23:32 +08:00
|
|
|
#include "b6x.h"
|
|
|
|
#include "drvs.h"
|
|
|
|
#include "dbg.h"
|
|
|
|
#include "app_uart.h"
|
|
|
|
#include "sftmr.h"
|
|
|
|
#include "app_speed_governor.h"
|
|
|
|
#include "app_control_out.h"
|
|
|
|
#include "app_ws2812.h"
|
|
|
|
|
|
|
|
#include "bledef.h"
|
|
|
|
#include "app.h"
|
|
|
|
|
|
|
|
|
|
|
|
GRB_Data_t WS2812_GRBs;
|
|
|
|
BLE_GRB_Data_t BLE_WS2812_GRBs;
|
|
|
|
|
|
|
|
extern void app_ble_procedure(void);
|
|
|
|
|
|
|
|
static void sysInit(void)
|
|
|
|
{
|
|
|
|
// Todo config, if need
|
|
|
|
iwdt_disable();
|
|
|
|
|
2024-04-19 15:13:25 +08:00
|
|
|
// rcc_ble_en();
|
|
|
|
// rcc_adc_en();
|
2024-04-15 09:23:32 +08:00
|
|
|
|
|
|
|
rcc_fshclk_set(FSH_CLK_DPSC42);
|
|
|
|
APBMISC->XOSC16M_CTRL.XOSC16M_CAP_TR = 0x22;
|
|
|
|
}
|
|
|
|
|
|
|
|
static void devInit(void)
|
|
|
|
{
|
2024-04-19 15:13:25 +08:00
|
|
|
// uint16_t rsn = rstrsn();
|
2024-04-15 09:23:32 +08:00
|
|
|
|
|
|
|
// dbgInit();
|
|
|
|
// debug("Start(rsn:0x%X)...\r\n", rsn);
|
|
|
|
|
|
|
|
// Init BLE App
|
2024-04-19 15:13:25 +08:00
|
|
|
// app_init(rsn);
|
2024-04-15 09:23:32 +08:00
|
|
|
|
2024-04-19 15:13:25 +08:00
|
|
|
// rf_pa_set(0x0C);
|
2024-04-15 09:23:32 +08:00
|
|
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
static tmr_tk_t test_timer_handler(tmr_id_t id){
|
|
|
|
|
|
|
|
(void)(id);
|
|
|
|
|
2024-04-19 15:13:25 +08:00
|
|
|
GRB_WS2812_Write_GRBs(WS2812_GRBs.len ,WS2812_GRBs.GRBs);
|
|
|
|
// GRB_WS2812_Write_color(BLE_WS2812_GRBs.len,BLE_WS2812_GRBs.GRBs);
|
|
|
|
return 10;
|
2024-04-15 09:23:32 +08:00
|
|
|
}
|
|
|
|
|
|
|
|
int main(void)
|
|
|
|
{
|
|
|
|
|
|
|
|
sysInit();
|
|
|
|
devInit();
|
|
|
|
|
|
|
|
// Global Interrupt Enable
|
|
|
|
GLOBAL_INT_START();
|
|
|
|
|
|
|
|
app_control_init();
|
|
|
|
app_speed_governing_init(0);
|
2024-04-19 15:13:25 +08:00
|
|
|
app_uart_Init(UART1_PORT,115200,PA06,PA07);//上位机
|
|
|
|
app_uart_Init(UART2_PORT,9600,20,PA04);//倒车雷达
|
2024-04-15 09:23:32 +08:00
|
|
|
|
2024-04-19 15:13:25 +08:00
|
|
|
// app_uart_Init(UART1_PORT,115200,PA03,PA04);//上位机
|
|
|
|
// app_uart_Init(UART2_PORT,9600,PA06,PA07);//倒车雷达
|
2024-04-15 09:23:32 +08:00
|
|
|
|
|
|
|
bootDelayMs(1000);
|
|
|
|
GRB_WS2812_Init();
|
|
|
|
sftmr_start(20, test_timer_handler);
|
|
|
|
while(1){
|
|
|
|
// SoftTimer Polling
|
|
|
|
sftmr_schedule();
|
|
|
|
// Schedule Messages & Events
|
2024-04-19 15:13:25 +08:00
|
|
|
// ble_schedule();
|
2024-04-15 09:23:32 +08:00
|
|
|
|
|
|
|
|
|
|
|
// User's Procedure
|
2024-04-19 15:13:25 +08:00
|
|
|
// app_ble_procedure();
|
2024-04-15 09:23:32 +08:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|