int stm32_bringup(void) { #ifdef HAVE_RTC_DRIVER FAR struct rtc_lowerhalf_s *lower; #endif int ret = OK; #ifdef CONFIG_ZEROCROSS /* Configure the zero-crossing driver */ stm32_zerocross_initialize(); #endif #ifdef CONFIG_RGBLED /* Configure the RGB LED driver */ stm32_rgbled_setup(); #endif #if defined(CONFIG_PCA9635PW) /* Initialize the PCA9635 chip */ ret = stm32_pca9635_initialize(); if (ret < 0) { sdbg("ERROR: stm32_pca9635_initialize failed: %d\n", ret); } #endif #ifdef HAVE_SDIO /* Initialize the SDIO block driver */ ret = stm32_sdio_initialize(); if (ret != OK) { fdbg("ERROR: Failed to initialize MMC/SD driver: %d\n", ret); return ret; } #endif #ifdef HAVE_USBHOST /* Initialize USB host operation. stm32_usbhost_initialize() starts a thread * will monitor for USB connection and disconnection events. */ ret = stm32_usbhost_initialize(); if (ret != OK) { udbg("ERROR: Failed to initialize USB host: %d\n", ret); return ret; } #endif #ifdef HAVE_USBMONITOR /* Start the USB Monitor */ ret = usbmonitor_start(0, NULL); if (ret != OK) { udbg("ERROR: Failed to start USB monitor: %d\n", ret); return ret; } #endif #ifdef HAVE_RTC_DRIVER /* Instantiate the STM32 lower-half RTC driver */ lower = stm32_rtc_lowerhalf(); if (!lower) { sdbg("ERROR: Failed to instantiate the RTC lower-half driver\n"); return -ENOMEM; } else { /* Bind the lower half driver and register the combined RTC driver * as /dev/rtc0 */ ret = rtc_initialize(0, lower); if (ret < 0) { sdbg("ERROR: Failed to bind/register the RTC driver: %d\n", ret); return ret; } } #endif #ifdef HAVE_ELF /* Initialize the ELF binary loader */ ret = elf_initialize(); if (ret < 0) { sdbg("ERROR: Initialization of the ELF loader failed: %d\n", ret); } #endif #ifdef CONFIG_MAX31855 ret = stm32_max31855initialize("/dev/temp0"); #endif #ifdef CONFIG_MAX6675 ret = stm32_max6675initialize("/dev/temp0"); #endif #ifdef CONFIG_FS_PROCFS /* Mount the procfs file system */ ret = mount(NULL, STM32_PROCFS_MOUNTPOINT, "procfs", 0, NULL); if (ret < 0) { sdbg("ERROR: Failed to mount procfs at %s: %d\n", STM32_PROCFS_MOUNTPOINT, ret); } #endif return ret; }
int board_app_initialize(uintptr_t arg) { #ifdef HAVE_RTC_DRIVER FAR struct rtc_lowerhalf_s *lower; #endif #ifdef CONFIG_STM32_SPI1 FAR struct spi_dev_s *spi; FAR struct mtd_dev_s *mtd; #endif #ifdef HAVE_MMCSD FAR struct sdio_dev_s *sdio; #endif int ret; /* Register I2C drivers on behalf of the I2C tool */ stm32_i2ctool(); #ifdef HAVE_RTC_DRIVER /* Instantiate the STM32 lower-half RTC driver */ lower = stm32_rtc_lowerhalf(); if (!lower) { syslog(LOG_ERR, "ERROR: Failed to instantiate the RTC lower-half driver\n"); return -ENOMEM; } else { /* Bind the lower half driver and register the combined RTC driver * as /dev/rtc0 */ ret = rtc_initialize(0, lower); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to bind/register the RTC driver: %d\n", ret); return ret; } } #endif /* Configure SPI-based devices */ #ifdef CONFIG_STM32_SPI1 /* Get the SPI port */ spi = stm32_spibus_initialize(1); if (!spi) { syslog(LOG_ERR, "ERROR: Failed to initialize SPI port 0\n"); return -ENODEV; } /* Now bind the SPI interface to the M25P64/128 SPI FLASH driver */ mtd = m25p_initialize(spi); if (!mtd) { syslog(LOG_ERR, "ERROR: Failed to bind SPI port 0 to the SPI FLASH driver\n"); return -ENODEV; } #warning "Now what are we going to do with this SPI FLASH driver?" #endif /* Mount the SDIO-based MMC/SD block driver */ #ifdef HAVE_MMCSD /* First, get an instance of the SDIO interface */ sdio = sdio_initialize(CONFIG_NSH_MMCSDSLOTNO); if (!sdio) { syslog(LOG_ERR, "ERROR: Failed to initialize SDIO slot %d\n", CONFIG_NSH_MMCSDSLOTNO); return -ENODEV; } /* Now bind the SDIO interface to the MMC/SD driver */ ret = mmcsd_slotinitialize(CONFIG_NSH_MMCSDMINOR, sdio); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to bind SDIO to the MMC/SD driver: %d\n", ret); return ret; } /* Then let's guess and say that there is a card in the slot. I need to check to * see if the STM3240G-EVAL board supports a GPIO to detect if there is a card in * the slot. */ sdio_mediachange(sdio, true); #endif #ifdef HAVE_USBHOST /* Initialize USB host operation. stm32_usbhost_initialize() starts a thread * will monitor for USB connection and disconnection events. */ ret = stm32_usbhost_initialize(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to initialize USB host: %d\n", ret); return ret; } #endif #ifdef CONFIG_PWM /* Initialize PWM and register the PWM device. */ ret = stm32_pwm_setup(); if (ret < 0) { syslog(LOG_ERR, "ERROR: stm32_pwm_setup() failed: %d\n", ret); } #endif #ifdef CONFIG_ADC /* Initialize ADC and register the ADC driver. */ ret = stm32_adc_setup(); if (ret < 0) { syslog(LOG_ERR, "ERROR: stm32_adc_setup failed: %d\n", ret); } #endif #ifdef CONFIG_CAN /* Initialize CAN and register the CAN driver. */ ret = stm32_can_setup(); if (ret < 0) { syslog(LOG_ERR, "ERROR: stm32_can_setup failed: %d\n", ret); } #endif UNUSED(ret); return OK; }