/** **************************************************************************************** * @brief Restore from low power mode * @param[in] callback callback before XTAL clock ready * @description * This function is used to set MCU restoring from low power mode, switch system clock to XTAL. ***************************************************************************************** */ void restore_from_low_power_mode(void (*callback)(void)) { syscon_SetPGCR2WithMask(QN_SYSCON, SYSCON_MASK_PD_STATE|SYSCON_MASK_DVDD12_PMU_SET, MASK_DISABLE); if (callback != NULL) { callback(); } // 16MHz/32MHz XTAL is ready while (!(syscon_GetBLESR(QN_SYSCON) & SYSCON_MASK_CLK_RDY)) { // XTAL shall be ready before BLE wakeup if (check_ble_wakeup()) { // In this case XTAL wakeup duration is larger than setting. // The parameter 'Oscillator wake-up time' in the NVDS should be revised. #if (QN_DBG_INFO) set_dbg_info(QN_DBG_INFO_XTAL_WAKEUP_DURATION); #endif } } //syscon_SetCMDCRWithMask(QN_SYSCON, SYSCON_MASK_CLK_MUX, CLK_XTAL<<SYSCON_POS_CLK_MUX); syscon_set_sysclk_src(CLK_XTAL, __XTAL); syscon_set_ahb_clk(__AHB_CLK); syscon_set_apb_clk(__APB_CLK); }
/** **************************************************************************************** * @brief Setup the microcontroller system. * * Initialize the system clock and pins. ***************************************************************************************** */ void SystemInit(void) { /* ************************** * Sub module clock setting ************************** */ // DC-DC dc_dc_enable(true); // QN platform initialization plf_init(NORMAL_MODE, __XTAL, QN_32K_RCO, NULL, 0); // Disable all peripheral clock, will be enabled in the driver initilization. timer_clock_off(QN_TIMER0); timer_clock_off(QN_TIMER1); timer_clock_off(QN_TIMER2); timer_clock_off(QN_TIMER3); uart_clock_off(QN_UART0); uart_clock_off(QN_UART1); spi_clock_off(QN_SPI0); usart_reset((uint32_t) QN_SPI1); spi_clock_off(QN_SPI1); flash_clock_off(); gpio_clock_off(); adc_clock_off(); dma_clock_off(); pwm_clock_off(); // calibration will change system clock setting // Configure sytem clock. syscon_set_sysclk_src(CLK_XTAL, __XTAL); syscon_set_ahb_clk(__AHB_CLK); syscon_set_apb_clk(__APB_CLK); syscon_set_ble_clk(__BLE_CLK); syscon_set_timer_clk(__TIMER_CLK); syscon_set_usart_clk((uint32_t)QN_UART0, __USART_CLK); syscon_set_usart_clk((uint32_t)QN_UART1, __USART_CLK); /* ************************** * IO configuration ************************** */ SystemIOCfg(); /* ************************** * Peripheral setting ************************** */ }
/** **************************************************************************************** * @brief Setup the microcontroller system. * * Initialize the system clock and pins. ***************************************************************************************** */ void SystemInit(void) { /* ************************** * Sub module clock setting ************************** */ // Disable all peripheral clock, will be enabled in the driver initilization. timer_clock_off(QN_TIMER0); timer_clock_off(QN_TIMER1); timer_clock_off(QN_TIMER2); timer_clock_off(QN_TIMER3); uart_clock_off(QN_UART0); uart_clock_off(QN_UART1); spi_clock_off(QN_SPI0); usart_reset((uint32_t) QN_SPI1); spi_clock_off(QN_SPI1); flash_clock_off(); gpio_clock_off(); adc_clock_off(); dma_clock_off(); pwm_clock_off(); // Configure sytem clock. syscon_set_sysclk_src(CLK_XTAL, __XTAL); syscon_set_ahb_clk(__AHB_CLK); syscon_set_ble_clk(__BLE_CLK); syscon_set_apb_clk(__APB_CLK); syscon_set_timer_clk(__TIMER_CLK); syscon_set_usart_clk((uint32_t)QN_UART0, __USART_CLK); syscon_set_usart_clk((uint32_t)QN_UART1, __USART_CLK); clk32k_enable(__32K_TYPE); /* ************************** * IO configuration ************************** */ SystemIOCfg(); /* ************************** * Peripheral setting ************************** */ // GPIO initialization for led, button & test control pin. gpio_init(gpio_interrupt_callback); // LED led_init(); #if (FB_OLED && FB_SPI_OLED) spi_init(QN_SPI1, SPI_BITRATE(10000), SPI_8BIT, SPI_MASTER_MOD); #endif /// Firefly add #if (FB_OLED) OLED_Init(); //初始化 OLED OLED_Clear(); //清屏 OLED OLED_ShowString(0,0," Firefly Team "); OLED_ShowString(0,2," Wait ... "); // OLED_ShowString(4,4,"Please wait..."); #endif //#if (FB_OLED) // OLED_Init(); //初始化OLED // delay(10000); // OLED_Clear(); //清屏 OLED // delay(10000); // OLED_ShowCHinese(9,0,0); // OLED_ShowCHinese(27,0,1); // OLED_ShowCHinese(45,0,2); // OLED_ShowCHinese(63,0,3); // OLED_ShowCHinese(81,0,4); // OLED_ShowCHinese(99,0,5); //#endif #if (defined(CFG_PRO_TEST)) gpio_pull_set(BUTTON1_PIN,GPIO_PULL_UP); gpio_set_direction(BUTTON1_PIN,GPIO_INPUT); if (gpio_read_pin(BUTTON1_PIN) == GPIO_LOW) app_env.pro_test_flag = TRUE; else app_env.pro_test_flag = FALSE; #endif // Test controll pin is input to check work mode #if (defined(QN_TEST_CTRL_PIN)) gpio_pull_set(QN_TEST_CTRL_PIN, GPIO_PULL_UP); gpio_set_direction_field(QN_TEST_CTRL_PIN, (uint32_t)GPIO_INPUT); #if (defined(CFG_HCI_UART)) // Initialize HCI UART port uart_init(QN_HCI_PORT, USARTx_CLK(0), UART_9600); uart_tx_enable(QN_HCI_PORT, MASK_ENABLE); uart_rx_enable(QN_HCI_PORT, MASK_ENABLE); #elif (defined(CFG_HCI_SPI)) // Initialize HCI SPI port spi_init(QN_HCI_PORT, SPI_BITRATE(1000000), SPI_8BIT, SPI_SLAVE_MOD); gpio_set_direction_field(CFG_HCI_SPI_WR_CTRL_PIN, (uint32_t)GPIO_OUTPUT); gpio_write_pin(CFG_HCI_SPI_WR_CTRL_PIN, GPIO_HIGH); #endif #endif // Button button_init(); #if (QN_DBG_PRINT) uart_init(QN_DEBUG_UART, USARTx_CLK(0), UART_9600); uart_tx_enable(QN_DEBUG_UART, MASK_ENABLE); uart_rx_enable(QN_DEBUG_UART, MASK_ENABLE); #endif }
/** **************************************************************************************** * @brief Setup the microcontroller system. * * Initialize the system clock and pins. ***************************************************************************************** */ void SystemInit(void) { /* ************************** * Sub module clock setting ************************** */ syscon_SetIvrefX32WithMask(QN_SYSCON, SYSCON_MASK_DVDD12_SW_EN, MASK_ENABLE); syscon_set_sysclk_src(CLK_XTAL, __XTAL); #if __XTAL == XTAL_32MHz calibration_init(XTAL_32M); #else calibration_init(XTAL_16M); #endif ref_pll_calibration(); clk32k_enable(__32K_TYPE); #if QN_32K_RCO rco_calibration(); #endif // Reset SPI1 module(since the default register value was changed in bootloader) syscon_SetCRSS(QN_SYSCON, SYSCON_MASK_USART1_RST); syscon_SetCRSC(QN_SYSCON, SYSCON_MASK_USART1_RST); /* Disable all peripheral clock, will be enabled in the driver initilization. The next function performs the equivalent effect of a collection of these functions. timer_clock_off(QN_TIMER0); timer_clock_off(QN_TIMER1); timer_clock_off(QN_TIMER2); timer_clock_off(QN_TIMER3); uart_clock_off(QN_UART0); uart_clock_off(QN_UART1); spi_clock_off(QN_SPI0); spi_clock_off(QN_SPI1); flash_clock_off(); gpio_clock_off(); adc_clock_off(); dma_clock_off(); pwm_clock_off(); */ syscon_SetCRSS(QN_SYSCON, SYSCON_MASK_GATING_TIMER0 | SYSCON_MASK_GATING_TIMER1 | SYSCON_MASK_GATING_TIMER2 | SYSCON_MASK_GATING_TIMER3 | SYSCON_MASK_GATING_UART0 | SYSCON_MASK_GATING_UART1 | SYSCON_MASK_GATING_SPI0 | SYSCON_MASK_GATING_SPI1 | SYSCON_MASK_GATING_SPI_AHB | SYSCON_MASK_GATING_GPIO | SYSCON_MASK_GATING_ADC | SYSCON_MASK_GATING_DMA | SYSCON_MASK_GATING_PWM); // calibration changed system clock setting // Configure sytem clock. syscon_set_sysclk_src(CLK_XTAL, __XTAL); syscon_set_ahb_clk(__AHB_CLK); syscon_set_apb_clk(__APB_CLK); syscon_set_ble_clk(__BLE_CLK); syscon_set_timer_clk(__TIMER_CLK); syscon_set_usart_clk((uint32_t)QN_UART0, __USART_CLK); syscon_set_usart_clk((uint32_t)QN_UART1, __USART_CLK); /* ************************** * IO configuration ************************** */ SystemIOCfg(); /* ************************** * Peripheral setting ************************** */ }
/** **************************************************************************************** * @brief Setup the microcontroller system. * * Initialize the system clock and pins. ***************************************************************************************** */ void SystemInit(void) { /* ************************** * Sub module clock setting ************************** */ // Reset SPI1 module(since the default register value was changed in bootloader) syscon_SetCRSS(QN_SYSCON, SYSCON_MASK_USART1_RST); syscon_SetCRSC(QN_SYSCON, SYSCON_MASK_USART1_RST); /* Disable all peripheral clock, will be enabled in the driver initilization. The next function performs the equivalent effect of a collection of these functions. timer_clock_off(QN_TIMER0); timer_clock_off(QN_TIMER1); timer_clock_off(QN_TIMER2); timer_clock_off(QN_TIMER3); uart_clock_off(QN_UART0); uart_clock_off(QN_UART1); spi_clock_off(QN_SPI0); spi_clock_off(QN_SPI1); flash_clock_off(); gpio_clock_off(); adc_clock_off(); dma_clock_off(); pwm_clock_off(); */ syscon_SetCRSS(QN_SYSCON, SYSCON_MASK_GATING_TIMER0 | SYSCON_MASK_GATING_TIMER1 | SYSCON_MASK_GATING_TIMER2 | SYSCON_MASK_GATING_TIMER3 | SYSCON_MASK_GATING_UART0 | SYSCON_MASK_GATING_UART1 | SYSCON_MASK_GATING_SPI0 | SYSCON_MASK_GATING_SPI1 | SYSCON_MASK_GATING_SPI_AHB | SYSCON_MASK_GATING_GPIO | SYSCON_MASK_GATING_ADC | SYSCON_MASK_GATING_DMA | SYSCON_MASK_GATING_PWM); // Configure sytem clock. syscon_set_sysclk_src(CLK_XTAL, __XTAL); syscon_set_ahb_clk(__AHB_CLK); syscon_set_ble_clk(__BLE_CLK); syscon_set_apb_clk(__APB_CLK); syscon_set_timer_clk(__TIMER_CLK); syscon_set_usart_clk((uint32_t)QN_UART0, __USART_CLK); syscon_set_usart_clk((uint32_t)QN_UART1, __USART_CLK); clk32k_enable(__32K_TYPE); /* ************************** * IO configuration ************************** */ SystemIOCfg(); /* ************************** * Peripheral setting ************************** */ // GPIO initialization for led, button & test control pin. gpio_init(gpio_interrupt_callback); // LED led_init(); // Test controll pin is input to check work mode #if (defined(QN_TEST_CTRL_PIN)) gpio_pull_set(QN_TEST_CTRL_PIN, GPIO_PULL_UP); gpio_set_direction_field(QN_TEST_CTRL_PIN, (uint32_t)GPIO_INPUT); #if (defined(CFG_HCI_UART)) // Initialize HCI UART port uart_init(QN_HCI_PORT, USARTx_CLK(0), UART_9600); uart_tx_enable(QN_HCI_PORT, MASK_ENABLE); uart_rx_enable(QN_HCI_PORT, MASK_ENABLE); #elif (defined(CFG_HCI_SPI)) // Initialize HCI SPI port spi_init(QN_HCI_PORT, SPI_BITRATE(1000000), SPI_8BIT, SPI_SLAVE_MOD); gpio_set_direction_field(CFG_HCI_SPI_WR_CTRL_PIN, (uint32_t)GPIO_OUTPUT); gpio_write_pin(CFG_HCI_SPI_WR_CTRL_PIN, GPIO_HIGH); #endif #endif // Button button_init(); #if (QN_DBG_PRINT) uart_init(QN_DEBUG_UART, USARTx_CLK(0), UART_9600); uart_tx_enable(QN_DEBUG_UART, MASK_ENABLE); uart_rx_enable(QN_DEBUG_UART, MASK_ENABLE); #endif }
/** **************************************************************************************** * @brief Enter low power mode * @param[in] en enabled peripheral at low power mode * @description * This function is used to set MCU entering into low power mode. ***************************************************************************************** */ void enter_low_power_mode(uint32_t en) { PGCR1_restore = syscon_GetPGCR1(QN_SYSCON); syscon_SetPGCR2WithMask(QN_SYSCON, SYSCON_MASK_PD_STATE|SYSCON_MASK_PMUENABLE, MASK_DISABLE); low_power_mode_en = 1; // set system clock to 32K syscon_set_sysclk_src(CLK_LOW_32K, __32K_TYPE); syscon_SetCMDCRWithMask(QN_SYSCON, SYSCON_MASK_AHB_DIV_BYPASS|SYSCON_MASK_APB_DIV_BYPASS, MASK_ENABLE); uint32_t mask; // power off all not needed modules mask = SYSCON_MASK_DIS_OSC | SYSCON_MASK_DIS_BG | SYSCON_MASK_DIS_V2I | SYSCON_MASK_DIS_BUCK | SYSCON_MASK_DIS_VREG_A | SYSCON_MASK_DIS_VREG_D | SYSCON_MASK_DIS_XTAL #if QN_32K_RCO == TRUE | SYSCON_MASK_DIS_XTAL32 #endif | SYSCON_MASK_DIS_REF_PLL | SYSCON_MASK_DIS_LO_VCO | SYSCON_MASK_DIS_LO_PLL | SYSCON_MASK_DIS_PA | SYSCON_MASK_DIS_LNA | SYSCON_MASK_DIS_LNA_PKDET | SYSCON_MASK_DIS_MIXER | SYSCON_MASK_DIS_PPF_PKDET | SYSCON_MASK_DIS_PPF | SYSCON_MASK_DIS_RX_PKDET | SYSCON_MASK_DIS_RX_ADC | SYSCON_MASK_DIS_SAR_ADC #if (QN_32K_RCO == FALSE) | SYSCON_MASK_DIS_RCO #endif | SYSCON_MASK_DIS_MEM7 | SYSCON_MASK_DIS_MEM6 | SYSCON_MASK_DIS_MEM5 | SYSCON_MASK_DIS_MEM4 | SYSCON_MASK_DIS_MEM3 | SYSCON_MASK_DIS_MEM2 | SYSCON_MASK_DIS_MEM1 | SYSCON_MASK_DIS_SAR_BUF ; syscon_SetPGCR1WithMask(QN_SYSCON, mask&(~QN_MEM_RETENTION), MASK_ENABLE); #if 0 // gating all not needed modules mask = SYSCON_MASK_GATING_TIMER3 | SYSCON_MASK_GATING_TIMER2 #if QN_32K_RCO == FALSE | SYSCON_MASK_GATING_TIMER1 #endif | SYSCON_MASK_GATING_TIMER0 | SYSCON_MASK_GATING_UART1 | SYSCON_MASK_GATING_UART0 | SYSCON_MASK_GATING_SPI1 | SYSCON_MASK_GATING_SPI0 //| SYSCON_MASK_GATING_32K_CLK | SYSCON_MASK_GATING_SPI_AHB //| SYSCON_MASK_GATING_GPIO | SYSCON_MASK_GATING_ADC | SYSCON_MASK_GATING_DMA //| SYSCON_MASK_GATING_BLE_AHB | SYSCON_MASK_GATING_PWM ; syscon_SetCRSS(QN_SYSCON, mask&(~en)); #endif // set PMU to 0.8V, b1 should set PMU after OSC disabled syscon_SetPGCR2WithMask(QN_SYSCON, SYSCON_MASK_DVDD12_PMU_SET, MASK_ENABLE); }
/** **************************************************************************************** * @brief Setup the microcontroller system. * * Initialize the system clock and pins. ***************************************************************************************** */ void SystemInit(void) { /* ************************** * Sub module clock setting ************************** */ // Disable all peripheral clock, will be enabled in the driver initilization. timer_clock_off(QN_TIMER0); timer_clock_off(QN_TIMER1); timer_clock_off(QN_TIMER2); timer_clock_off(QN_TIMER3); uart_clock_off(QN_UART0); uart_clock_off(QN_UART1); spi_clock_off(QN_SPI0); usart_reset((uint32_t) QN_SPI1); spi_clock_off(QN_SPI1); flash_clock_off(); gpio_clock_off(); adc_clock_off(); dma_clock_off(); pwm_clock_off(); // Configure sytem clock. syscon_set_sysclk_src(CLK_XTAL, __XTAL); syscon_set_ahb_clk(__AHB_CLK); syscon_set_ble_clk(__BLE_CLK); syscon_set_apb_clk(__APB_CLK); syscon_set_timer_clk(__TIMER_CLK); syscon_set_usart_clk((uint32_t)QN_UART0, __USART_CLK); syscon_set_usart_clk((uint32_t)QN_UART1, __USART_CLK); clk32k_enable(__32K_TYPE); // if pull down GPIO_P12 when power on,it will enter the test mode #if defined(CFG_ALL_GPIO_TEST) //set GPIO_P12 direction to GPIO_INPUT syscon_SetPMCR0(QN_SYSCON,P12_GPIO_10_PIN_CTRL); gpio_init(gpio_interrupt_callback); gpio_pull_set(GPIO_P12, GPIO_PULL_UP); gpio_set_direction_field(GPIO_P12, (uint32_t)GPIO_INPUT); //check if it's pull down if (gpio_read_pin(GPIO_P12) == GPIO_LOW) { //set a flag to enter test mode until device reset app_env.test_flag = TRUE; } else app_env.test_flag = FALSE; #endif /* ************************** * IO configuration ************************** */ SystemIOCfg(); /* ************************** * Peripheral setting ************************** */ // GPIO initialization for led, button & test control pin. gpio_init(gpio_interrupt_callback); // LED led_init(); // Test controll pin is input to check work mode #if (defined(QN_TEST_CTRL_PIN)) gpio_pull_set(QN_TEST_CTRL_PIN, GPIO_PULL_UP); gpio_set_direction_field(QN_TEST_CTRL_PIN, (uint32_t)GPIO_INPUT); #if (defined(CFG_HCI_UART)) // Initialize HCI UART port uart_init(QN_HCI_PORT, USARTx_CLK(0), UART_9600); uart_tx_enable(QN_HCI_PORT, MASK_ENABLE); uart_rx_enable(QN_HCI_PORT, MASK_ENABLE); #elif (defined(CFG_HCI_SPI)) // Initialize HCI SPI port spi_init(QN_HCI_PORT, SPI_BITRATE(1000000), SPI_8BIT, SPI_SLAVE_MOD); gpio_set_direction_field(CFG_HCI_SPI_WR_CTRL_PIN, (uint32_t)GPIO_OUTPUT); gpio_write_pin(CFG_HCI_SPI_WR_CTRL_PIN, GPIO_HIGH); #endif #endif #if defined(QN_COM_UART) // Initialize User UART port uart_init(QN_COM_UART, USARTx_CLK(0), UART_9600); uart_tx_enable(QN_COM_UART, MASK_ENABLE); uart_rx_enable(QN_COM_UART, MASK_ENABLE); #endif #if (QN_DBG_PRINT) // Initialize Debug UART port uart_init(QN_DEBUG_UART, USARTx_CLK(0), UART_9600); uart_tx_enable(QN_DEBUG_UART, MASK_ENABLE); uart_rx_enable(QN_DEBUG_UART, MASK_ENABLE); #endif // if enter test mode flag had been seted,enter a loop to test all GPIO. #if (defined(CFG_ALL_GPIO_TEST)) if (app_env.test_flag == TRUE) { //get a warnning to user QPRINTF("\r\n@@@You pull down the GPIO_level of GPIO_P12 when power on,so it will enter the test mode!"); while(1) { all_gpio_test(); } } #endif }
/** **************************************************************************************** * @brief Setup the microcontroller system. * * Initialize the system clock and pins. ***************************************************************************************** */ void SystemInit(void) { /* ************************** * Sub module clock setting ************************** */ // Disable all peripheral clock, will be enabled in the driver initilization. timer_clock_off(QN_TIMER0); timer_clock_off(QN_TIMER1); timer_clock_off(QN_TIMER2); timer_clock_off(QN_TIMER3); uart_clock_off(QN_UART0); uart_clock_off(QN_UART1); spi_clock_off(QN_SPI0); usart_reset((uint32_t) QN_SPI1); spi_clock_off(QN_SPI1); flash_clock_off(); gpio_clock_off(); adc_clock_off(); dma_clock_off(); pwm_clock_off(); // Configure sytem clock. syscon_set_sysclk_src(CLK_XTAL, __XTAL); syscon_set_ahb_clk(__AHB_CLK); syscon_set_ble_clk(__BLE_CLK); syscon_set_apb_clk(__APB_CLK); syscon_set_timer_clk(__TIMER_CLK); syscon_set_usart_clk((uint32_t)QN_UART0, __USART_CLK); syscon_set_usart_clk((uint32_t)QN_UART1, __USART_CLK); clk32k_enable(__32K_TYPE); /* ************************** * IO configuration ************************** */ SystemIOCfg(); /* ************************** * Peripheral setting ************************** */ // GPIO initialization for led, button & test control pin. gpio_init(gpio_interrupt_callback); // LED led_init(); // Test controll pin is input to check work mode #if (defined(QN_TEST_CTRL_PIN)) gpio_pull_set(QN_TEST_CTRL_PIN, GPIO_PULL_UP); gpio_set_direction_field(QN_TEST_CTRL_PIN, (uint32_t)GPIO_INPUT); #if (defined(CFG_HCI_UART)) // Initialize HCI UART port uart_init(QN_HCI_PORT, USARTx_CLK(0), UART_9600); uart_tx_enable(QN_HCI_PORT, MASK_ENABLE); uart_rx_enable(QN_HCI_PORT, MASK_ENABLE); #elif (defined(CFG_HCI_SPI)) // Initialize HCI SPI port spi_init(QN_HCI_PORT, SPI_BITRATE(1000000), SPI_8BIT, SPI_SLAVE_MOD); gpio_set_direction_field(CFG_HCI_SPI_WR_CTRL_PIN, (uint32_t)GPIO_OUTPUT); gpio_write_pin(CFG_HCI_SPI_WR_CTRL_PIN, GPIO_HIGH); #endif #endif // Button button_init(); #if (QN_DBG_PRINT) uart_init(QN_DEBUG_UART, USARTx_CLK(0), UART_9600); uart_tx_enable(QN_DEBUG_UART, MASK_ENABLE); uart_rx_enable(QN_DEBUG_UART, MASK_ENABLE); #endif }
/** **************************************************************************************** * @brief Setup the microcontroller system. * * Initialize the system clock and pins. ***************************************************************************************** */ void SystemInit(void) { /* ************************** * Sub module clock setting ************************** */ syscon_SetIvrefX32WithMask(QN_SYSCON, SYSCON_MASK_DVDD12_SW_EN, MASK_ENABLE); syscon_set_sysclk_src(CLK_XTAL, __XTAL); #if __XTAL == XTAL_32MHz calibration_init(XTAL_32M); #else calibration_init(XTAL_16M); #endif ref_pll_calibration(); clk32k_enable(__32K_TYPE); #if QN_32K_RCO rco_calibration(); #endif // Disable all peripheral clock, will be enabled in the driver initilization. timer_clock_off(QN_TIMER0); timer_clock_off(QN_TIMER1); timer_clock_off(QN_TIMER2); timer_clock_off(QN_TIMER3); uart_clock_off(QN_UART0); uart_clock_off(QN_UART1); spi_clock_off(QN_SPI0); usart_reset((uint32_t) QN_SPI1); spi_clock_off(QN_SPI1); flash_clock_off(); gpio_clock_off(); adc_clock_off(); dma_clock_off(); pwm_clock_off(); // calibration will change system clock setting // Configure sytem clock. syscon_set_sysclk_src(CLK_XTAL, __XTAL); syscon_set_ahb_clk(__AHB_CLK); syscon_set_apb_clk(__APB_CLK); syscon_set_ble_clk(__BLE_CLK); syscon_set_timer_clk(__TIMER_CLK); syscon_set_usart_clk((uint32_t)QN_UART0, __USART_CLK); syscon_set_usart_clk((uint32_t)QN_UART1, __USART_CLK); /* ************************** * IO configuration ************************** */ SystemIOCfg(); /* ************************** * Peripheral setting ************************** */ }