104 lines
1.6 KiB
C
104 lines
1.6 KiB
C
|
#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();
|
||
|
|
||
|
rcc_ble_en();
|
||
|
rcc_adc_en();
|
||
|
|
||
|
rcc_fshclk_set(FSH_CLK_DPSC42);
|
||
|
APBMISC->XOSC16M_CTRL.XOSC16M_CAP_TR = 0x22;
|
||
|
}
|
||
|
|
||
|
static void devInit(void)
|
||
|
{
|
||
|
uint16_t rsn = rstrsn();
|
||
|
|
||
|
// dbgInit();
|
||
|
// debug("Start(rsn:0x%X)...\r\n", rsn);
|
||
|
|
||
|
// Init BLE App
|
||
|
app_init(rsn);
|
||
|
|
||
|
rf_pa_set(0x0C);
|
||
|
|
||
|
}
|
||
|
|
||
|
|
||
|
static tmr_tk_t test_timer_handler(tmr_id_t id){
|
||
|
|
||
|
(void)(id);
|
||
|
|
||
|
// GRB_WS2812_Write_GRBs(WS2812_GRBs.len ,WS2812_GRBs.GRBs);
|
||
|
GRB_WS2812_Write_color(BLE_WS2812_GRBs.len,BLE_WS2812_GRBs.GRBs);
|
||
|
return 100;
|
||
|
}
|
||
|
|
||
|
int main(void)
|
||
|
{
|
||
|
|
||
|
sysInit();
|
||
|
devInit();
|
||
|
|
||
|
// Global Interrupt Enable
|
||
|
GLOBAL_INT_START();
|
||
|
|
||
|
app_control_init();
|
||
|
app_speed_governing_init(0);
|
||
|
// app_uart_Init(UART1_PORT,115200,PA06,PA07);//上位机
|
||
|
// app_uart_Init(UART2_PORT,9600,PA03,PA04);//倒车雷达
|
||
|
|
||
|
app_uart_Init(UART1_PORT,115200,PA03,PA04);//上位机
|
||
|
app_uart_Init(UART2_PORT,9600,PA06,PA07);//倒车雷达
|
||
|
|
||
|
bootDelayMs(1000);
|
||
|
GRB_WS2812_Init();
|
||
|
sftmr_start(20, test_timer_handler);
|
||
|
while(1){
|
||
|
// SoftTimer Polling
|
||
|
sftmr_schedule();
|
||
|
// Schedule Messages & Events
|
||
|
ble_schedule();
|
||
|
|
||
|
|
||
|
// User's Procedure
|
||
|
app_ble_procedure();
|
||
|
}
|
||
|
}
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|
||
|
|