int sam_sdinitialize(int port, int minor) { FAR struct spi_dev_s *spi; int ret; /* Get the SPI driver instance for the SD chip select */ fvdbg("Initializing SERCOM SPI%d\n", port); spi = sam_spibus_initialize(port); if (!spi) { fdbg("Failed to initialize SPI%d\n", port); return -ENODEV; } fvdbg("Successfully initialized SPI%d\n", port); /* Bind the SPI device for the chip select to the slot */ fvdbg("Binding SPI%d to MMC/SD slot %d\n", port, SAMDL_MMCSDSLOTNO); ret = mmcsd_spislotinitialize(minor, SAMDL_MMCSDSLOTNO, spi); if (ret < 0) { fdbg("Failed to bind SPI%d to MMC/SD slot %d: %d\n", port, SAMDL_MMCSDSLOTNO, ret); return ret; } fvdbg("Successfuly bound SPI%d to MMC/SD slot %d\n", port, SAMDL_MMCSDSLOTNO); return OK; }
FAR struct lcd_dev_s *sam_graphics_setup(unsigned int devno) { FAR struct spi_dev_s *spi; FAR struct lcd_dev_s *dev; /* Configure the OLED GPIOs. This initial configuration is RESET low, * putting the OLED into reset state. */ sam_configgpio(GPIO_SSD1306_RST); /* Wait a bit then release the OLED from the reset state */ up_mdelay(20); sam_gpiowrite(GPIO_SSD1306_RST, true); /* Get the SPI1 port interface */ spi = sam_spibus_initialize(GPIO_SSD1306_CS); if (!spi) { lcderr("ERROR: Failed to initialize SPI port 1\n"); } else { /* Bind the SPI port to the OLED */ dev = ssd1306_initialize(spi, NULL, devno); if (!dev) { lcderr("ERROR: Failed to bind SPI port 1 to OLED %d: %d\n", devno); } else { lcdinfo("Bound SPI port 1 to OLED %d\n", devno); /* And turn the OLED on */ (void)dev->setpower(dev, CONFIG_LCD_MAXPOWER); #if defined(CONFIG_VIDEO_FB) && defined(CONFIG_LCD_FRAMEBUFFER) /* Initialize and register the simulated framebuffer driver */ ret = fb_register(0, 0); if (ret < 0) { syslog(LOG_ERR, "ERROR: fb_register() failed: %d\n", ret); } #endif return dev; } } return NULL; }
FAR struct lcd_dev_s *board_graphics_setup(unsigned int devno) { FAR struct spi_dev_s *spi; FAR struct lcd_dev_s *dev; /* Configure the OLED PORTs. This initial configuration is RESET low, * putting the OLED into reset state. */ (void)sam_configport(PORT_OLED_RST); /* Wait a bit then release the OLED from the reset state */ up_mdelay(20); sam_portwrite(PORT_OLED_RST, true); /* Get the SPI1 port interface */ spi = sam_spibus_initialize(OLED_CSNO); if (!spi) { lcderr("ERROR: Failed to initialize SPI port 1\n"); } else { /* Bind the SPI port to the OLED */ dev = ssd1306_initialize(spi, devno); if (!dev) { lcderr("ERROR: Failed to bind SPI port 1 to OLED %d: %d\n", devno); } else { lcdinfo("Bound SPI port 1 to OLED %d\n", devno); /* And turn the OLED on */ (void)dev->setpower(dev, CONFIG_LCD_MAXPOWER); return dev; } } return NULL; }
int sam_tsc_setup(int minor) { FAR struct spi_dev_s *dev; int ret; iinfo("minor %d\n", minor); DEBUGASSERT(minor == 0); /* Configure and enable the ADS7843E interrupt pin as an input */ (void)sam_configgpio(GPIO_TCS_BUSY); (void)sam_configgpio(GPIO_TCS_IRQ); /* Configure the PIO interrupt */ sam_gpioirq(GPIO_TCS_IRQ); /* Get an instance of the SPI interface for the touchscreen chip select */ dev = sam_spibus_initialize(TSC_CSNUM); if (!dev) { ierr("ERROR: Failed to initialize SPI chip select %d\n", TSC_CSNUM); return -ENODEV; } /* Initialize and register the SPI touschscreen device */ ret = ads7843e_register(dev, &g_tscinfo, CONFIG_ADS7843E_DEVMINOR); if (ret < 0) { ierr("ERROR: Failed to initialize SPI chip select %d\n", TSC_CSNUM); /* sam_spibus_uninitialize(dev); */ return -ENODEV; } return OK; }
int sam_at25_automount(int minor) { FAR struct spi_dev_s *spi; FAR struct mtd_dev_s *mtd; static bool initialized = false; int ret; /* Have we already initialized? */ if (!initialized) { /* No.. Get the SPI port driver */ spi = sam_spibus_initialize(AT25_PORT); if (!spi) { ferr("ERROR: Failed to initialize SPI port %d\n", AT25_PORT); return -ENODEV; } /* Now bind the SPI interface to the AT25 SPI FLASH driver */ mtd = at25_initialize(spi); if (!mtd) { ferr("ERROR: Failed to bind SPI port %d to the AT25 FLASH driver\n"); return -ENODEV; } #if defined(CONFIG_SAMA5D3XPLAINED_AT25_FTL) /* And finally, use the FTL layer to wrap the MTD driver as a block driver */ ret = ftl_initialize(AT25_MINOR, mtd); if (ret < 0) { ferr("ERROR: Failed to initialize the FTL layer: %d\n", ret); return ret; } #elif defined(CONFIG_SAMA5D3XPLAINED_AT25_NXFFS) /* Initialize to provide NXFFS on the MTD interface */ ret = nxffs_initialize(mtd); if (ret < 0) { ferr("ERROR: NXFFS initialization failed: %d\n", ret); return ret; } /* Mount the file system at /mnt/at25 */ ret = mount(NULL, "/mnt/at25", "nxffs", 0, NULL); if (ret < 0) { ferr("ERROR: Failed to mount the NXFFS volume: %d\n", errno); return ret; } #endif /* Now we are initializeed */ initialized = true; } return OK; }