implement SSP hooks

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3144 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2010-11-28 14:57:31 +00:00
parent 5ff45ea1e0
commit f24db4423e
2 changed files with 61 additions and 17 deletions

View File

@ -158,20 +158,30 @@
#define LPC1766STK_LEFT (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT2 | GPIO_PIN7)
#define LPC1766STK_RIGHT (GPIO_INPUT | GPIO_PULLUP | GPIO_PORT2 | GPIO_PIN8)
/* LCD GPIO PIN SIGNAL NAME
/* Nokia LCD GPIO PIN SIGNAL NAME
* -------------------------------- ---- --------------
* P1[21]/MCABORT/PWM1[3]/SSEL0 35 SSEL0
* P1[20]/MCFB0/PWM1[2]/SCK0 34 SCK0
* P1[23]/MCFB1/PWM1[4]/MISO0 37 MISO0
* P1[24]/MCFB2/PWM1[5]/MOSI0 38 MOSI0
* P3[25]/MAT0[0]/PWM1[2] 27 LCD_RST
* P3[26]/STCLK/MAT0[1]/PWM1[3] 26 LCD_BL
*/
#define LPC1766STK_LED1 (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT1 | GPIO_PIN25)
#define LPC1766STK_LED2 (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT0 | GPIO_PIN4)
#define LPC1766STK_LCD_CS (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT3 | GPIO_PIN25)
#define LPC1766STK_LCD_RST (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT3 | GPIO_PIN25)
#define LPC1766STK_LCD_BL (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT3 | GPIO_PIN26)
/* MMC GPIO PIN SIGNAL NAME
/* SD/MMC GPIO PIN SIGNAL NAME
* -------------------------------- ---- --------------
* P0[6]/I2SRX_SDA/SSEL1/MAT2[0] 79 SSEL1
* P0[7]/I2STX_CLK/SCK1/MAT2[1] 78 SCK1
* P0[8]/I2STX_WS/MISO1/MAT2[2] 77 MISO1
* P0[9]/I2STX_SDA/MOSI1/MAT2[3] 76 MOSI1
* P0[21]/RI1/RD1 57 MMC PWR
*/
#define LPC1766STK_MMC_CS (GPIO_OUTPUT | GPIO_VALUE_ONE | GPIO_PORT0 | GPIO_PIN6)
#define LPC1766STK_MMC_PWR (GPIO_OUTPUT | GPIO_VALUE_ZERO | GPIO_PORT0 | GPIO_PIN21)
/* AD GPIO PIN SIGNAL NAME

View File

@ -81,9 +81,11 @@
/* Dump GPIO registers */
#ifdef SSP_VERBOSE
# define ssp_dumpgpio(m) lpc17_dumpgpio(SDCCS_GPIO, m)
# define ssp_dumpssp0gpio(m) lpc17_dumpgpio(LPC1766STK_LCD_CS, m)
# define ssp_dumpssp1gpio(m) lpc17_dumpgpio(LPC1766STK_MMC_CS, m)
#else
# define ssp_dumpgpio(m)
# define ssp_dumpssp0gpio(m)
# define ssp_dumpssp1gpio(m)
#endif
/************************************************************************************
@ -104,11 +106,21 @@
void weak_function lpc17_sspinitialize(void)
{
/* Configure the SPI chip select GPIOs */
/* Configure the SSP0 chip select GPIOs. Only the Nokia LCD is connected to SSP0 */
ssp_dumpgpio("lpc17_sspinitialize() Entry)");
#warning "Not implemented"
ssp_dumpgpio("lpc17_sspinitialize() Exit");
#ifdef CONFIG_LPC17_SSP0
ssp_dumpssp0gpio("BEFORE SSP0 Initialization");
lpc17_configgpio(LPC1766STK_LCD_CS);
ssp_dumpssp0gpio("AFTER SSP0 Initialization");
#endif
/* Configure SSP1 chip select GPIOs. Only the SD/MMC card slot is connected to SSP1 */
#ifdef CONFIG_LPC17_SSP1
ssp_dumpssp0gpio("BEFORE SSP1 Initialization");
lpc17_configgpio(LPC1766STK_MMC_CS);
ssp_dumpssp0gpio("AFTER SSP1 Initialization");
#endif
}
/************************************************************************************
@ -140,20 +152,42 @@ void weak_function lpc17_sspinitialize(void)
void lpc17_ssp0select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
ssp_dumpgpio("lpc17_spiselect() Entry");
#warning "Not implemented"
ssp_dumpgpio("lpc17_spiselect() Exit");
if (devid == SPIDEV_DISPLAY)
{
/* Assert/de-assert the CS pin to the card */
ssp_dumpssp0gpio("lpc17_ssp0select() Entry");
lm3s_gpiowrite(LPC1766STK_LCD_CS, !selected);
ssp_dumpssp0gpio("lpc17_ssp0select() Exit");
}
}
uint8_t lpc17_ssp0status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
sspdbg("Returning nothing\n");
return 0;
}
#endif
#ifdef CONFIG_LPC17_SSP1
void lpc17_ssp1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
sspdbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
if (devid == SPIDEV_MMCSD)
{
/* Assert/de-assert the CS pin to the card */
ssp_dumpssp1gpio("lpc17_ssp1select() Entry");
lm3s_gpiowrite(LPC1766STK_MMC_CS, !selected);
ssp_dumpssp1gpio("lpc17_ssp1select() Exit");
}
}
uint8_t lpc17_ssp1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
sspdbg("Returning SPI_STATUS_PRESENT\n");
return SPI_STATUS_PRESENT;
}
#endif
#ifdef CONFIG_LPC17_SSP1
# warning "SSP1 chip selects not known"
#endif
#endif /* CONFIG_LPC17_SSP0 || CONFIG_LPC17_SSP1 */