void app_init_func(void) { #if (BLE_SPOTA_RECEIVER) app_spotar_init(); #endif app_dis_init(); app_set_adv_data(); }
/** **************************************************************************************** * @brief Enable pad's and peripheral clocks assuming that peripherals' power domain is down. * * The Uart and SPi clocks are set. **************************************************************************************** */ void periph_init(void) // set i2c, spi, uart, uart2 serial clks { // Power up peripherals' power domain SetBits16(PMU_CTRL_REG, PERIPH_SLEEP, 0); while (!(GetWord16(SYS_STAT_REG) & PER_IS_UP)) ; #if ES4_CODE SetBits16(CLK_16M_REG,XTAL16_BIAS_SH_DISABLE, 1); #endif // TODO: Application specific - Modify accordingly! // Example: Activate UART and SPI. // Initialize UART component #ifdef PROGRAM_ENABLE_UART SetBits16(CLK_PER_REG, UART1_ENABLE, 1); // enable clock - always @16MHz // baudr=9-> 115k2 // mode=3-> no parity, 1 stop bit 8 data length #ifdef UART_MEGABIT uart_init(UART_BAUDRATE_1M, 3); #else uart_init(UART_BAUDRATE_115K2, 3); #endif // UART_MEGABIT //NVIC_SetPriority(UART_IRQn, 1); // remove if the bug in uart.c is fixed in ES4(b)! #endif // PROGRAM_ENABLE_UART //FPGA #ifdef FPGA_USED SetBits16(CLK_PER_REG, SPI_ENABLE, 1); // enable clock SetBits16(CLK_PER_REG, SPI_DIV, 1); // set divider to 1 #endif #if BLE_ACCEL SetBits16(CLK_PER_REG, SPI_ENABLE, 1); // enable clock SetBits16(CLK_PER_REG, SPI_DIV, 1); // set divider to 1 SetBits16(CLK_PER_REG, WAKEUPCT_ENABLE, 1); // enable clock of Wakeup Controller #endif #if 0 //Example: Do something with the timer if need be... SetWord16(TIMER0_CTRL_REG, 0); SetWord16(TIMER0_RELOAD_M_REG, 0); SetWord16(TIMER0_RELOAD_N_REG, 0); SetWord16(TIMER0_ON_REG, 0); #endif //rom patch patch_func(); //Init pads set_pad_functions(); #ifndef FPGA_USED #if (BLE_APP_PRESENT) #if BLE_HID_DEVICE SetBits16(CLK_PER_REG, WAKEUPCT_ENABLE, 1); // enable clock of Wakeup Controller // if (app_env.app_flags & KBD_START_SCAN) // reinit kbd only if needed if ( !(app_env.app_flags & KBD_START_SCAN) && !(app_env.app_flags & KBD_SCANNING) ) app_kbd_reinit_matrix(); #endif // BLE_HID_DEVICE #if BLE_PROX_REPORTER app_proxr_port_reinit(); #elif BLE_FINDME_LOCATOR app_button_enable(); #endif //BLE_PROX_REPORTER #if BLE_SPOTA_RECEIVER app_spotar_init(); #endif // BLE_SPOTA_RECEIVER #if BLE_STREAMDATA_DEVICE stream_start_button_init(); #endif //BLE_STREAMDATA_DEVICE #if BLE_BATTERY_SERVER app_batt_port_reinit(); #endif //BLE_BATTERY_SERVER #endif #endif // Enable the pads SetBits16(SYS_CTRL_REG, PAD_LATCH_EN, 1); }