void hal_bsp_init(void) { int rc; (void)rc; #if MYNEWT_VAL(SPI_0_MASTER) rc = hal_spi_init(0, &spi0_cfg, HAL_SPI_TYPE_MASTER); assert(rc == 0); #endif #if MYNEWT_VAL(SPI_0_SLAVE) rc = hal_spi_init(0, &spi0_cfg, HAL_SPI_TYPE_SLAVE); assert(rc == 0); #endif #if MYNEWT_VAL(UART_0) rc = os_dev_create((struct os_dev *) &hal_uart0, "uart0", OS_DEV_INIT_PRIMARY, 0, uart_hal_init, (void *)&uart_cfg0); assert(rc == 0); #endif #if MYNEWT_VAL(ADC_1) rc = os_dev_create((struct os_dev *) &my_dev_adc1, "adc1", OS_DEV_INIT_KERNEL, OS_DEV_INIT_PRIO_DEFAULT, stm32f4_adc_dev_init, &adc1_config); assert(rc == 0); #endif #if MYNEWT_VAL(ADC_2) rc = os_dev_create((struct os_dev *) &my_dev_adc2, "adc2", OS_DEV_INIT_KERNEL, OS_DEV_INIT_PRIO_DEFAULT, stm32f4_adc_dev_init, &adc2_config); assert(rc == 0); #endif #if MYNEWT_VAL(ADC_3) rc = os_dev_create((struct os_dev *) &my_dev_adc3, "adc3", OS_DEV_INIT_KERNEL, OS_DEV_INIT_PRIO_DEFAULT, stm32f4_adc_dev_init, &adc3_config); assert(rc == 0); #endif #if MYNEWT_VAL(I2C_0) rc = hal_i2c_init(0, &i2c_cfg0); assert(rc == 0); #endif #if MYNEWT_VAL(TIMER_0) hal_timer_init(0, TIM9); #endif #if MYNEWT_VAL(ETH_0) rc = stm32_eth_init(ð_cfg); assert(rc == 0); #endif }
/* * STM32 plaform initialization. */ static void __init stm32_init(void) { /* * Configure the IOMUXes of STM32 */ stm32_iomux_init(); #if defined(CONFIG_STM32_DMA) /* * Configure DMA controller and its driver's API */ stm32_dma_init(); #endif #if defined(CONFIG_SERIAL_STM32) /* * Configure the USART devices */ stm32_uart_init(); #endif #if defined(CONFIG_STM32_MAC) /* * Configure the STM32 MAC */ stm32_eth_init(); #endif #if defined(CONFIG_SPI_STM32) /* * Configure the STM32 SPI devices */ stm32_spi_init(); #endif #if defined(CONFIG_I2C_STM32) /* * Configure the STM32 I2C devices */ stm32_i2c_init(); #endif #if defined(CONFIG_MTD_PHYSMAP) /* * Configure external Flash */ stm32_flash_init(); #endif #if defined(CONFIG_MMC_ARMMMCI) /* * Configure SD card controller */ stm32_sdcard_init(); #endif #if defined(CONFIG_RTC_DRV_STM32F2) /* * Initialize the on-chip real-time clock */ stm32_rtc_init(); #endif #if defined(CONFIG_GPIOLIB) /* * Register the MCU GPIO chip */ stm32_gpio_init(); #endif }
/* * STM32 plaform initialization. */ static void __init stm32_init(void) { /* * Configure the IOMUXes of STM32 */ stm32_iomux_init(); #if defined(CONFIG_STM32_DMA) /* * Configure DMA controller and its driver's API */ stm32_dma_init(); #endif #if defined(CONFIG_SERIAL_STM32) /* * Configure the USART devices */ stm32_uart_init(); #endif #if defined(CONFIG_STM32_MAC) /* * Configure the STM32 MAC */ stm32_eth_init(); #endif #if defined(CONFIG_SPI_STM32) /* * Configure the STM32 SPI devices */ stm32_spi_init(); #endif #if defined(CONFIG_I2C_STM32) || defined(CONFIG_I2C_STM32F7) /* * Configure the STM32 I2C devices */ stm32_i2c_init(); #endif #if defined(CONFIG_MTD_PHYSMAP) || defined(CONFIG_MTD_STM32F4_MAP) /* * Configure external Flash */ stm32_flash_init(); #endif #if defined(CONFIG_MMC_ARMMMCI) /* * Configure SD card controller */ stm32_sdcard_init(); #endif #if defined(CONFIG_RTC_DRV_STM32F2) /* * Initialize the on-chip real-time clock */ stm32_rtc_init(); #endif #if defined(CONFIG_STM32_USB_OTG_FS) /* * Initialize the USB OTG FS controller */ stm32_usb_otg_fs_init(); #endif #if defined(CONFIG_STM32_USB_OTG_HS) /* * Initialize the USB OTG HS controller */ stm32_usb_otg_hs_init(); #endif #if defined(CONFIG_GPIOLIB) /* * Register the MCU GPIO chip */ stm32_gpio_init(); #endif #if defined(CONFIG_I2C_GPIO) /* * Bit-bang GPIO I2C implementation */ stm32_i2c_gpio_init(); #endif #if defined(CONFIG_STM32_FB) /* * Register LCD controller with the framebuffer driver */ stm32f4x9_fb_init(); #endif }
/* * Register ethernet driver */ int board_eth_init(bd_t *bis) { return stm32_eth_init(bis); }
void hal_bsp_init(void) { int rc; (void)rc; hal_system_clock_start(); #if MYNEWT_VAL(TRNG) rc = os_dev_create(&os_bsp_trng.dev, "trng", OS_DEV_INIT_KERNEL, OS_DEV_INIT_PRIO_DEFAULT, stm32_trng_dev_init, NULL); assert(rc == 0); #endif #if MYNEWT_VAL(UART_0) rc = os_dev_create((struct os_dev *) &hal_uart0, "uart0", OS_DEV_INIT_PRIMARY, 0, uart_hal_init, (void *)&uart_cfg[0]); assert(rc == 0); #endif #if MYNEWT_VAL(SPI_0_MASTER) rc = hal_spi_init(0, &spi0_cfg, HAL_SPI_TYPE_MASTER); assert(rc == 0); #endif #if MYNEWT_VAL(SPI_0_SLAVE) rc = hal_spi_init(0, &spi0_cfg, HAL_SPI_TYPE_SLAVE); assert(rc == 0); #endif #if MYNEWT_VAL(I2C_0) rc = hal_i2c_init(0, &i2c_cfg0); assert(rc == 0); #endif #if MYNEWT_VAL(TIMER_0) hal_timer_init(0, TIM9); #endif #if MYNEWT_VAL(TIMER_1) hal_timer_init(1, TIM10); #endif #if MYNEWT_VAL(TIMER_2) hal_timer_init(2, TIM11); #endif #if (MYNEWT_VAL(OS_CPUTIME_TIMER_NUM) >= 0) rc = os_cputime_init(MYNEWT_VAL(OS_CPUTIME_FREQ)); assert(rc == 0); #endif #if MYNEWT_VAL(ETH_0) stm32_eth_init(ð_cfg); #endif #if MYNEWT_VAL(PWM_0) rc = os_dev_create((struct os_dev *) &stm32_pwm_dev_driver[PWM_0_DEV_ID], (char*)stm32_pwm_dev_name[PWM_0_DEV_ID], OS_DEV_INIT_KERNEL, OS_DEV_INIT_PRIO_DEFAULT, stm32_pwm_dev_init, &stm32_pwm_config[PWM_0_DEV_ID]); assert(rc == 0); #endif #if MYNEWT_VAL(PWM_1) rc = os_dev_create((struct os_dev *) &stm32_pwm_dev_driver[PWM_1_DEV_ID], (char*)stm32_pwm_dev_name[PWM_1_DEV_ID], OS_DEV_INIT_KERNEL, OS_DEV_INIT_PRIO_DEFAULT, stm32_pwm_dev_init, &stm32_pwm_config[PWM_1_DEV_ID]); assert(rc == 0); #endif #if MYNEWT_VAL(PWM_2) rc = os_dev_create((struct os_dev *) &stm32_pwm_dev_driver[PWM_2_DEV_ID], (char*)stm32_pwm_dev_name[PWM_2_DEV_ID], OS_DEV_INIT_KERNEL, OS_DEV_INIT_PRIO_DEFAULT, stm32_pwm_dev_init, &stm32_pwm_config[PWM_2_DEV_ID]); assert(rc == 0); #endif }