int board_app_initialize(uintptr_t arg) { #ifdef HAVE_RTC_DRIVER FAR struct rtc_lowerhalf_s *rtclower; #endif #ifdef CONFIG_QENCODER int index; char buf[9]; #endif int ret; (void)ret; #ifdef CONFIG_SCHED_INSTRUMENTATION /* Configure CPU load estimation */ cpuload_initialize_once(); #endif #ifdef HAVE_PROC /* Mount the proc filesystem */ syslog(LOG_INFO, "Mounting procfs to /proc\n"); ret = mount(NULL, CONFIG_NSH_PROC_MOUNTPOINT, "procfs", 0, NULL); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to mount the PROC filesystem: %d (%d)\n", ret, errno); return ret; } #endif #ifdef HAVE_RTC_DRIVER /* Instantiate the STM32L4 lower-half RTC driver */ rtclower = stm32l4_rtc_lowerhalf(); if (!rtclower) { serr("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, rtclower); if (ret < 0) { serr("ERROR: Failed to bind/register the RTC driver: %d\n", ret); return ret; } } #endif #ifdef HAVE_MMCSD /* First, get an instance of the SDIO interface */ g_sdio = sdio_initialize(CONFIG_NSH_MMCSDSLOTNO); if (!g_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, g_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. There is no * card detect GPIO. */ sdio_mediachange(g_sdio, true); syslog(LOG_INFO, "[boot] Initialized SDIO\n"); #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_AJOYSTICK /* Initialize and register the joystick driver */ ret = board_ajoy_initialize(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to register the joystick driver: %d\n", ret); return ret; } #endif #ifdef CONFIG_TIMER /* Initialize and register the timer driver */ ret = board_timer_driver_initialize("/dev/timer0", 2); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to register the timer driver: %d\n", ret); return ret; } #endif #ifdef CONFIG_QENCODER /* Initialize and register the qencoder driver */ index = 0; #ifdef CONFIG_STM32L4_TIM1_QE sprintf(buf, "/dev/qe%d", index++); ret = stm32l4_qencoder_initialize(buf, 1); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to register the qencoder: %d\n", ret); return ret; } #endif #ifdef CONFIG_STM32L4_TIM2_QE sprintf(buf, "/dev/qe%d", index++); ret = stm32l4_qencoder_initialize(buf, 2); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to register the qencoder: %d\n", ret); return ret; } #endif #ifdef CONFIG_STM32L4_TIM3_QE sprintf(buf, "/dev/qe%d", index++); ret = stm32l4_qencoder_initialize(buf, 3); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to register the qencoder: %d\n", ret); return ret; } #endif #ifdef CONFIG_STM32L4_TIM4_QE sprintf(buf, "/dev/qe%d", index++); ret = stm32l4_qencoder_initialize(buf, 4); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to register the qencoder: %d\n", ret); return ret; } #endif #ifdef CONFIG_STM32L4_TIM5_QE sprintf(buf, "/dev/qe%d", index++); ret = stm32l4_qencoder_initialize(buf, 5); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to register the qencoder: %d\n", ret); return ret; } #endif #ifdef CONFIG_STM32L4_TIM8_QE sprintf(buf, "/dev/qe%d", index++); ret = stm32l4_qencoder_initialize(buf, 8); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to register the qencoder: %d\n", ret); return ret; } #endif #endif UNUSED(ret); return OK; }
int board_app_initialize(uintptr_t arg) { #ifdef HAVE_RTC_DRIVER FAR struct rtc_lowerhalf_s *rtclower; #endif int ret; (void)ret; /* Configure CPU load estimation */ #ifdef CONFIG_SCHED_INSTRUMENTATION cpuload_initialize_once(); #endif #ifdef HAVE_PROC /* Mount the proc filesystem */ syslog(LOG_INFO, "Mounting procfs to /proc\n"); ret = mount(NULL, CONFIG_NSH_PROC_MOUNTPOINT, "procfs", 0, NULL); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to mount the PROC filesystem: %d (%d)\n", ret, errno); return ret; } #endif #ifdef HAVE_RTC_DRIVER /* Instantiate the STM32L4 lower-half RTC driver */ rtclower = stm32l4_rtc_lowerhalf(); if (!rtclower) { serr("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, rtclower); if (ret < 0) { serr("ERROR: Failed to bind/register the RTC driver: %d\n", ret); return ret; } } #endif #ifdef HAVE_MMCSD /* First, get an instance of the SDIO interface */ g_sdio = sdio_initialize(CONFIG_NSH_MMCSDSLOTNO); if (!g_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, g_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. There is no * card detect GPIO. */ sdio_mediachange(g_sdio, true); syslog(LOG_INFO, "[boot] Initialized SDIO\n"); #endif #ifdef CONFIG_AJOYSTICK /* Initialize and register the joystick driver */ ret = board_ajoy_initialize(); if (ret != OK) { syslog(LOG_ERR, "ERROR: Failed to register the joystick driver: %d\n", ret); return ret; } #endif return OK; }
int board_app_initialize(uintptr_t arg) { #ifdef HAVE_RTC_DRIVER FAR struct rtc_lowerhalf_s *rtclower; #endif #if defined(HAVE_N25QXXX) FAR struct mtd_dev_s *mtd_temp; #endif #if defined(HAVE_N25QXXX_CHARDEV) char blockdev[18]; char chardev[12]; #endif int ret; (void)ret; #ifdef HAVE_PROC /* mount the proc filesystem */ syslog(LOG_INFO, "Mounting procfs to /proc\n"); ret = mount(NULL, CONFIG_NSH_PROC_MOUNTPOINT, "procfs", 0, NULL); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to mount the PROC filesystem: %d (%d)\n", ret, errno); return ret; } #endif #ifdef HAVE_RTC_DRIVER /* Instantiate the STM32 lower-half RTC driver */ rtclower = stm32l4_rtc_lowerhalf(); if (!rtclower) { serr("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, rtclower); if (ret < 0) { serr("ERROR: Failed to bind/register the RTC driver: %d\n", ret); return ret; } } #endif #ifdef HAVE_N25QXXX /* Create an instance of the STM32L4 QSPI device driver */ g_qspi = stm32l4_qspi_initialize(0); if (!g_qspi) { _err("ERROR: stm32l4_qspi_initialize failed\n"); return ret; } else { /* Use the QSPI device instance to initialize the * N25QXXX device. */ mtd_temp = n25qxxx_initialize(g_qspi, true); if (!mtd_temp) { _err("ERROR: n25qxxx_initialize failed\n"); return ret; } g_mtd_fs = mtd_temp; #ifdef CONFIG_MTD_PARTITION { FAR struct mtd_geometry_s geo; off_t nblocks; /* Setup a partition of 256KiB for our file system. */ ret = MTD_IOCTL(g_mtd_fs, MTDIOC_GEOMETRY, (unsigned long)(uintptr_t)&geo); if (ret < 0) { _err("ERROR: MTDIOC_GEOMETRY failed\n"); return ret; } nblocks = (256*1024) / geo.blocksize; mtd_temp = mtd_partition(g_mtd_fs, 0, nblocks); if (!mtd_temp) { _err("ERROR: mtd_partition failed\n"); return ret; } g_mtd_fs = mtd_temp; } #endif #ifdef HAVE_N25QXXX_SMARTFS /* Configure the device with no partition support */ ret = smart_initialize(N25QXXX_SMART_MINOR, g_mtd_fs, NULL); if (ret != OK) { _err("ERROR: Failed to initialize SmartFS: %d\n", ret); } #elif defined(HAVE_N25QXXX_NXFFS) /* Initialize to provide NXFFS on the N25QXXX MTD interface */ ret = nxffs_initialize(g_mtd_fs); if (ret < 0) { _err("ERROR: NXFFS initialization failed: %d\n", ret); } /* Mount the file system at /mnt/nxffs */ ret = mount(NULL, "/mnt/nxffs", "nxffs", 0, NULL); if (ret < 0) { _err("ERROR: Failed to mount the NXFFS volume: %d\n", errno); return ret; } #else /* if defined(HAVE_N25QXXX_CHARDEV) */ /* Use the FTL layer to wrap the MTD driver as a block driver */ ret = ftl_initialize(N25QXXX_MTD_MINOR, g_mtd_fs); if (ret < 0) { _err("ERROR: Failed to initialize the FTL layer: %d\n", ret); return ret; } /* Use the minor number to create device paths */ snprintf(blockdev, 18, "/dev/mtdblock%d", N25QXXX_MTD_MINOR); snprintf(chardev, 12, "/dev/mtd%d", N25QXXX_MTD_MINOR); /* Now create a character device on the block device */ /* NOTE: for this to work, you will need to make sure that * CONFIG_FS_WRITABLE is set in the config. It's not a user- * visible setting, but you can make it set by selecting an * arbitrary writable file system (you don't have to actually * use it, just select it so that the block device created via * ftl_initialize() will be writable). */ ret = bchdev_register(blockdev, chardev, false); if (ret < 0) { _err("ERROR: bchdev_register %s failed: %d\n", chardev, ret); return ret; } #endif } #endif #ifdef HAVE_USBHOST /* Initialize USB host operation. stm32l4_usbhost_initialize() starts a thread * will monitor for USB connection and disconnection events. */ ret = stm32l4_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 return OK; }
int board_app_initialize(uintptr_t arg) { #ifdef HAVE_RTC_DRIVER FAR struct rtc_lowerhalf_s *rtclower; #endif int ret; #ifdef HAVE_PROC /* mount the proc filesystem */ syslog(LOG_INFO, "Mounting procfs to /proc\n"); ret = mount(NULL, CONFIG_NSH_PROC_MOUNTPOINT, "procfs", 0, NULL); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to mount the PROC filesystem: %d (%d)\n", ret, errno); return ret; } #endif #ifdef HAVE_RTC_DRIVER /* Instantiate the STM32 lower-half RTC driver */ rtclower = stm32l4_rtc_lowerhalf(); if (!rtclower) { 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, rtclower); if (ret < 0) { syslog(LOG_ERR, "ERROR: Failed to bind/register the RTC driver: %d\n", ret); return ret; } } #endif #ifdef HAVE_USERLED_DRIVER /* Register the LED driver */ ret = userled_lower_initialize("/dev/userleds"); if (ret != OK) { syslog(LOG_ERR, "ERROR: userled_lower_initialize() failed: %d\n", ret); return ret; } #endif UNUSED(ret); return OK; }