1.蓝牙SOC芯片主函数流程
int main()
{
sys_init_app();
ble_init();
dev_manager_init(dev_manager_callback);
gap_manager_init(gap_manager_callback);
gatt_manager_init(gatt_manager_callback);
rtos_init();
ble_task_init();
app_task_init();
vTaskStartScheduler();
/*if all well,never to run here */
for( ;; );
return 0;
}
void sys_init_app()
{
analog_init();
var_init();
main_task_app_init();
module_init();
}
static void analog_init()
{
dcdc_on();
if(clk_check()==false)
{
clk_switch();
}
lse_init();
lsi_calib();
REG_FIELD_WR(SYSCFG->PMU_TRIM, SYSCFG_XTAL_STBTIME, XTAL_STB_VAL);
arm_cm_set_int_isr(LVD33_IRQn,LVD33_Handler);
}
static void var_init()
{
stack_data_bss_init();
bb_mem_clr();
stack_var_ptr_init();
hal_flash_drv_var_init(true,false);
}
void main_task_app_init()
{
main_task = 3;
app_init_fn = app_init;
eif_read = (void (*)(uint8_t *, uint32_t, void (*)(void *, uint8_t), void *))dummy;
eif_write = (void (*)(uint8_t *, uint32_t, void (*)(void *, uint8_t), void *))dummy;
eif_flow_on = (void (*)(void))dummy;
eif_flow_off = (bool (*)(void))dummy;
}
static void module_init()
{
io_init();
LOG_INIT();
LOG_I("sys init");
INIT_BUILTIN_TIMER_ENV();
rco_freq_counting_init();
lsi_counting_timer_create();
HAL_PIS_Init();
srand(get_trng_value());
calc_acc_init();
cpu_sleep_recover_init();
mac_init();
modem_rf_init();
irq_init();
systick_start();
rco_freq_counting_start();
uint32_t base_offset = flash_data_storage_base_offset();
tinyfs_init(base_offset);
tinyfs_print_dir_tree();
}