/** * This function will initial STM32 board. */ void rt_hw_board_init() { RCC_Configuration(); GPIO_Configuration(); exti_config(); /* mark by David */ Exti_Pvd_Init(); NVIC_Configuration(); /* Configure the SysTick */ SysTick_Config( SystemCoreClock / RT_TICK_PER_SECOND ); #if STM32_EXT_SRAM EXT_SRAM_Configuration(); #endif rt_hw_usart_init(); rt_console_set_device(CONSOLE_DEVICE); spi_config(); #if 1==USE_TO_7INCH_LCD FSMC_LCD_Init(); #elif 1==STM32_USE_FSMC_NOR_MUX //sys_fsmc_nor_mux_config(); #elif 1==STM32_USE_FSMC_NOR_MUX2LCD lcd_fsmc_nor_mux_config(); #endif #if USE_STM32_IWDG iwdg_init(); #endif // led_on(LED_PORTX, LED3_PIN); }
/** * This function will initial STM32 board. */ void rt_hw_board_init() { RCC_Configuration(); GPIO_Configuration(); #if STM32_EXT_SRAM EXT_SRAM_Configuration(); #endif NVIC_Configuration(); /* Configure the SysTick */ SysTick_Config( SystemCoreClock / RT_TICK_PER_SECOND ); /* rand */ #if ENABLE_RAND ADC_Configration(); ADC_Channel_Config(); #endif rt_hw_usart_init(); rt_console_set_device(CONSOLE_DEVICE); board_debug(("func:%s(), line:%d\n", __FUNCTION__, __LINE__)); exti_config(); /* mark by David */ spi_config(); board_debug(("func:%s(), line:%d\n", __FUNCTION__, __LINE__)); #if RT_USING_ADE7880 #if ADE7880_USE_SPI ade7880_spi_cfg(); #else ade7880_i2c_cfg(); start_7880_i2c(); ade7880_spi_withdma_hsdccfg(); dma_configuration_spi1_rx(); #endif #endif board_debug(("func:%s(), line:%d\n", __FUNCTION__, __LINE__)); #if USE_STM32_IWDG iwdg_init(); #endif board_debug(("func:%s(), line:%d\n", __FUNCTION__, __LINE__)); return; }
void button_init(void){ GPIO_InitTypeDef gpio_init_s; NVIC_InitTypeDef nvic_init_s; TIM_TimeBaseInitTypeDef timebase_s; RCC_ClocksTypeDef rcc_clocks; RCC_GetClocksFreq(&rcc_clocks); RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM2, ENABLE); // Initialize GPIO BUTTON_GPIO_CLK_CMD(BUTTON_GPIO_CLK, ENABLE); RCC_APB2PeriphClockCmd(RCC_APB2Periph_AFIO, ENABLE); GPIO_StructInit(&gpio_init_s); gpio_init_s.GPIO_Mode = GPIO_Mode_IN_FLOATING; gpio_init_s.GPIO_Pin = BUTTON_PIN; GPIO_Init(BUTTON_GPIO, &gpio_init_s); exti_config(BUTTON_GPIO, BUTTON_PIN_SRC, EXTI_Trigger_Falling); exti_register_handler(BUTTON_PIN_SRC, button_isr, NULL); timebase_s.TIM_Period = 65535; timebase_s.TIM_Prescaler = 0; timebase_s.TIM_ClockDivision = 0; timebase_s.TIM_CounterMode = TIM_CounterMode_Up; TIM_TimeBaseInit(TIM2, &timebase_s); button_tmr_prescaler = 65536 * (rcc_clocks.PCLK1_Frequency / 50) - 1; // Configure NVIC nvic_init_s.NVIC_IRQChannel = TIM2_IRQn; nvic_init_s.NVIC_IRQChannelPreemptionPriority = 0; nvic_init_s.NVIC_IRQChannelSubPriority = 1; nvic_init_s.NVIC_IRQChannelCmd = ENABLE; NVIC_Init(&nvic_init_s); if(BUTTON_GPIO->IDR & BUTTON_PIN){ button_set_off(); } else { button_set_on(); } }
//初始化24L01的IO口 void NRF24L01_Init(uint8_t mode) { gpio_out_pp_up_init(GPIOB, GPIO_Pin_7); //NRF24L01_CE初始化 spi_config(); //初始化SPI1 exti_config(GPIOB, 5); NRF24L01_CE=0; //使能24L01 NRF24L01_CS=1; //SPI片选取消 while(NRF24L01_Check()){ printf("not found NRF24L01\r\n"); delay_ms(500); } printf("NRF24L01 init ok\r\n"); if(mode == NRF_RX_MODE){ nrf_state = RX_OK; NRF24L01_RX_Mode(); } else{ nrf_state = TX_OK; NRF24L01_TX_Mode(); } }
void light_senser_init(void) { gpio_in_up_init(GPIOE, 0XFF81); exti_config(GPIOD, 11); }