#include "usr.h" #include "system.h" #include "bsp_time.h" #include "nrf_delay.h" //用户初始化头文件 //Add your code here... #include "twi_master.h" #include "hal_imu.h" #include "hal_ble_client.h" #include "hal_ble_host.h" #include "hal_mt.h" #include "hal_battery.h" #include "hal_mempress.h" #include "hal_led.h" #include "app_overturn.h" #include "app_charge.h" #include "app_power.h" #include "app_client.h" #include "app_host.h" #include "hal_flash.h" #include "app_step.h" #include "app_game.h" #include "hal_ble_uart0.h" #include "app_config.h" #include "app_ota.h" #include "app_connect_manage.h" #include "ble_comm.h" #include "ble_gap.h" #include "app_err.h" #include "bsp_pwm.h" #include "bsp_wdt.h" #include "bsp_adc.h" #include "tool.h" #include "hal_soft_time.h" #include "lsm6ds3tr_c.h" ////host //char sn1[] = "SH_P0"; //char hn1[] = "SH_L0"; ////client //char sn2[] = "SH_L0"; //char hn2[] = "SH_N0"; //char* HOST_NAME; //char* DEVICE_NAME; void USR_SetName(void) { char buf[16]; memset(buf,0,16); if(mFlash.isHost){ //主机 //slave_set_adv_name((char *) LEFT_NAME,sizeof(LEFT_NAME)); if(mFlash.mClient.isConfig=='C'){ //已配置 sprintf(buf,"%02X%02X%02X%02X%02X%02X",mFlash.macHost[0],mFlash.macHost[1],mFlash.macHost[2],mFlash.mClient.macAddr[3],mFlash.mClient.macAddr[4],mFlash.mClient.macAddr[5]); SEGGER_RTT_printf(0,"scanName(%d):%s\n",strlen(buf),buf); host_set_scan_name(buf,strlen(buf)); }else{SEGGER_RTT_printf(0,"scanName(%d):%s\n",sizeof(RIGHT_NAME),RIGHT_NAME); host_set_scan_name((char *)RIGHT_NAME,sizeof(RIGHT_NAME)); } }else{ //从机 if(mFlash.mClient.isConfig=='C'){ //已配置 sprintf(buf,"%02X%02X%02X%02X%02X%02X",mFlash.macHost[0],mFlash.macHost[1],mFlash.macHost[2],mFlash.mClient.macAddr[3],mFlash.mClient.macAddr[4],mFlash.mClient.macAddr[5]); SEGGER_RTT_printf(0,"advName(%d):%s\n",strlen(buf),buf); slave_set_adv_name(buf,strlen(buf)); }else{ //无配置 #if DEBUG slave_set_adv_name((char *)RIGHT_NAME,sizeof(RIGHT_NAME)); SEGGER_RTT_printf(0,"AdvName(%d):%s\n",sizeof(RIGHT_NAME),RIGHT_NAME); #endif } host_set_scan_name((char *) LAST_NAME,sizeof(LAST_NAME)); } } __weak void usr1_Init(void) { USR_SetName(); slave_init(BLE_Client_Push); host_init(BLE_Host_Push); } void PRE_Init(void) { nrf_gpio_cfg_input(21,NRF_GPIO_PIN_PULLUP);//充电引脚上拉 PWR_Init(); LED_Init(); MT_Init(); Flash_Initialize(); JS_RTT_Init(); usr1_Init(); } void USR_Init(void) { //用户初始化 //Add your code here... TIME_Init(); #if WATCHDOG_ENANBLE watchdog_init(); #endif Battery_Initialize(); IMU_Initialize(); ADC_Initialize(); Battery_Enable(true); BLE_Client_Initialize(); BLE_Host_Initialize(); //APP app_client_Initialize(); app_host_Initialize(); app_overturn_Init(); app_charge_Init(); app_step_Init(); app_game_Init(); app_config_Init(); app_ota_Init(); app_connect_manage_Init(); app_err_Init(); }