LPC17xx SPI and SSP initialization functions both called up_spiinitialize(); Changed to lpc17_spinitialize() and lpc17_sspinitialize().

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@5809 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2013-04-01 15:02:22 +00:00
parent 83c4c55b12
commit e185c5404a
22 changed files with 118 additions and 54 deletions

View File

@ -4486,4 +4486,13 @@
chips. Contributed by Mike Smith (2014-4-01). chips. Contributed by Mike Smith (2014-4-01).
* configs/zkit-arm-1769/src/up_can.c: Add support for both CAN1 * configs/zkit-arm-1769/src/up_can.c: Add support for both CAN1
and CAN2. Contributed by M.Kannan (2014-4-01). and CAN2. Contributed by M.Kannan (2014-4-01).
* arch/arm/src/lpc17xx/lpc17_spi.c and lpc17_ssp.c and
configs/olimex-lpc1766stk, nucleus2g, zkit-arm-1769, and
lpcxpresso-lpc1768: The initialization function for both the LPC17xx
SPI and SSP blocks was called up_spinitialize() which is the common API
definition of include/nuttx/spi.h. But this raises a problem when the
MCU has multiple blocks for differ SPI implementatins as does the
LPC17xx (and also as does other architectures like STM32 that have
USARTs that can serve as SPI interfaces as well). These were renamed
to lpc17_spiinitialize() and lpc17_sspinitialize() in this case.
Problem reported by M. Kannan (2014-4-01).

View File

@ -56,7 +56,7 @@
typedef FAR void *DMA_HANDLE; typedef FAR void *DMA_HANDLE;
/* dma_callback_t a function pointer provided to lp17_dmastart. This function is /* dma_callback_t a function pointer provided to lpc17_dmastart. This function is
* called at the completion of the DMA transfer. 'arg' is the same 'arg' value * called at the completion of the DMA transfer. 'arg' is the same 'arg' value
* that was provided when lpc17_dmastart() was called and result indicates the result * that was provided when lpc17_dmastart() was called and result indicates the result
* of the transfer: Zero indicates a successful tranfers. On failure, a negated * of the transfer: Zero indicates a successful tranfers. On failure, a negated

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* arch/arm/src/lpc17xx/lpc17_spi.c * arch/arm/src/lpc17xx/lpc17_spi.c
* *
* Copyright (C) 2010, 2012 Gregory Nutt. All rights reserved. * Copyright (C) 2010, 2012-2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -539,10 +539,10 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t nw
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: up_spiinitialize * Name: lpc17_spiinitialize
* *
* Description: * Description:
* Initialize the selected SPI port * Initialize the selected SPI port.
* *
* Input Parameter: * Input Parameter:
* Port number (for hardware that has mutiple SPI interfaces) * Port number (for hardware that has mutiple SPI interfaces)
@ -552,7 +552,7 @@ static void spi_recvblock(FAR struct spi_dev_s *dev, FAR void *buffer, size_t nw
* *
****************************************************************************/ ****************************************************************************/
FAR struct spi_dev_s *up_spiinitialize(int port) FAR struct spi_dev_s *lpc17_spiinitialize(int port)
{ {
FAR struct lpc17_spidev_s *priv = &g_spidev; FAR struct lpc17_spidev_s *priv = &g_spidev;
irqstate_t flags; irqstate_t flags;

View File

@ -70,6 +70,22 @@ extern "C"
* Public Functions * Public Functions
************************************************************************************/ ************************************************************************************/
/************************************************************************************
* Name: lpc17_spiinitialize
*
* Description:
* Initialize the selected SPI port.
*
* Input Parameter:
* Port number (for hardware that has mutiple SPI interfaces)
*
* Returned Value:
* Valid SPI device structure reference on succcess; a NULL on failure
*
************************************************************************************/
FAR struct spi_dev_s *lpc17_spiinitialize(int port);
/************************************************************************************ /************************************************************************************
* Name: lpc17_spiselect, lpc17_status, and lpc17_spicmddata * Name: lpc17_spiselect, lpc17_status, and lpc17_spicmddata
* *
@ -77,7 +93,7 @@ extern "C"
* These external functions must be provided by board-specific logic. They are * These external functions must be provided by board-specific logic. They are
* implementations of the select, status, and cmddata methods of the SPI interface * implementations of the select, status, and cmddata methods of the SPI interface
* defined by struct spi_ops_s (see include/nuttx/spi.h). All other methods * defined by struct spi_ops_s (see include/nuttx/spi.h). All other methods
* including up_spiinitialize()) are provided by common LPC17xx logic. To use * including lpc17_spiinitialize()) are provided by common LPC17xx logic. To use
* this common SPI logic on your board: * this common SPI logic on your board:
* *
* 1. Provide logic in lpc17_boardinitialize() to configure SPI chip select pins. * 1. Provide logic in lpc17_boardinitialize() to configure SPI chip select pins.
@ -88,9 +104,9 @@ extern "C"
* lpc17_spicmddata() functions in your board-specific logic. This function * lpc17_spicmddata() functions in your board-specific logic. This function
* will perform cmd/data selection operations using GPIOs in the way your * will perform cmd/data selection operations using GPIOs in the way your
* board is configured. * board is configured.
* 3. Add a call to up_spiinitialize() in your low level application * 3. Add a call to lpc17_spiinitialize() in your low level application
* initialization logic * initialization logic
* 4. The handle returned by up_spiinitialize() may then be used to bind the * 4. The handle returned by lpc17_spiinitialize() may then be used to bind the
* SPI driver to higher level logic (e.g., calling mmcsd_spislotinitialize(), * SPI driver to higher level logic (e.g., calling mmcsd_spislotinitialize(),
* for example, will bind the SPI driver to the SPI MMC/SD driver). * for example, will bind the SPI driver to the SPI MMC/SD driver).
* *

View File

@ -814,10 +814,10 @@ static inline FAR struct lpc17_sspdev_s *lpc17_ssp1initialize(void)
****************************************************************************/ ****************************************************************************/
/**************************************************************************** /****************************************************************************
* Name: up_spiinitialize * Name: lpc17_sspinitialize
* *
* Description: * Description:
* Initialize the selected SPI port * Initialize the selected SSP port.
* *
* Input Parameter: * Input Parameter:
* Port number (for hardware that has mutiple SPI interfaces) * Port number (for hardware that has mutiple SPI interfaces)
@ -827,7 +827,7 @@ static inline FAR struct lpc17_sspdev_s *lpc17_ssp1initialize(void)
* *
****************************************************************************/ ****************************************************************************/
FAR struct spi_dev_s *up_spiinitialize(int port) FAR struct spi_dev_s *lpc17_sspinitialize(int port)
{ {
FAR struct lpc17_sspdev_s *priv; FAR struct lpc17_sspdev_s *priv;
uint32_t regval; uint32_t regval;

View File

@ -70,6 +70,22 @@ extern "C"
* Public Functions * Public Functions
************************************************************************************/ ************************************************************************************/
/************************************************************************************
* Name: lpc17_sspinitialize
*
* Description:
* Initialize the selected SSP port.
*
* Input Parameter:
* Port number (for hardware that has mutiple SPI interfaces)
*
* Returned Value:
* Valid SPI device structure reference on succcess; a NULL on failure
*
************************************************************************************/
FAR struct spi_dev_s *lpc17_sspinitialize(int port);
/************************************************************************************ /************************************************************************************
* Name: lpc17_ssp0/ssp1select, lpc17_ssp0/ssp1status, and lpc17_ssp0/ssp1cmddata * Name: lpc17_ssp0/ssp1select, lpc17_ssp0/ssp1status, and lpc17_ssp0/ssp1cmddata
* *
@ -77,7 +93,7 @@ extern "C"
* These external functions must be provided by board-specific logic. They are * These external functions must be provided by board-specific logic. They are
* implementations of the select, status, and cmddata methods of the SPI interface * implementations of the select, status, and cmddata methods of the SPI interface
* defined by struct spi_ops_s (see include/nuttx/spi.h). All other methods * defined by struct spi_ops_s (see include/nuttx/spi.h). All other methods
* including up_spiinitialize()) are provided by common LPC17xx logic. To use * including lpc17_sspinitialize()) are provided by common LPC17xx logic. To use
* this common SPI logic on your board: * this common SPI logic on your board:
* *
* 1. Provide logic in lpc17_boardinitialize() to configure SSP chip select pins. * 1. Provide logic in lpc17_boardinitialize() to configure SSP chip select pins.
@ -88,9 +104,9 @@ extern "C"
* lpc17_ssp0/ssp1cmddata() functions in your board-specific logic. These * lpc17_ssp0/ssp1cmddata() functions in your board-specific logic. These
* functions will perform cmd/data selection operations using GPIOs in the way * functions will perform cmd/data selection operations using GPIOs in the way
* your board is configured. * your board is configured.
* 3. Add a call to up_spiinitialize() in your low level application * 3. Add a call to lpc17_sspinitialize() in your low level application
* initialization logic * initialization logic
* 4. The handle returned by up_spiinitialize() may then be used to bind the * 4. The handle returned by lpc17_sspinitialize() may then be used to bind the
* SSP driver to higher level logic (e.g., calling mmcsd_spislotinitialize(), * SSP driver to higher level logic (e.g., calling mmcsd_spislotinitialize(),
* for example, will bind the SSP driver to the SPI MMC/SD driver). * for example, will bind the SSP driver to the SPI MMC/SD driver).
* *

View File

@ -143,7 +143,7 @@ int nsh_archinitialize(void)
/* Get the SSP port */ /* Get the SSP port */
ssp = up_spiinitialize(CONFIG_NSH_MMCSDSPIPORTNO); ssp = lpc17_sspinitialize(CONFIG_NSH_MMCSDSPIPORTNO);
if (!ssp) if (!ssp)
{ {
message("nsh_archinitialize: Failed to initialize SSP port %d\n", message("nsh_archinitialize: Failed to initialize SSP port %d\n",

View File

@ -123,25 +123,25 @@ FAR struct lcd_dev_s *up_nxdrvinit(unsigned int devno)
oleddc_dumpgpio("up_nxdrvinit: After OLED Power/DC setup"); oleddc_dumpgpio("up_nxdrvinit: After OLED Power/DC setup");
/* Get the SSI port (configure as a Freescale SPI port) */ /* Get the SPI1 port (configure as a Freescale SPI port) */
spi = up_spiinitialize(1); spi = lpc17_sspinitialize(1);
if (!spi) if (!spi)
{ {
glldbg("Failed to initialize SSI port 1\n"); glldbg("Failed to initialize SPI port 1\n");
} }
else else
{ {
/* Bind the SSI port to the OLED */ /* Bind the SPI port to the OLED */
dev = ug_initialize(spi, devno); dev = ug_initialize(spi, devno);
if (!dev) if (!dev)
{ {
glldbg("Failed to bind SSI port 1 to OLED %d: %d\n", devno); glldbg("Failed to bind SPI port 1 to OLED %d: %d\n", devno);
} }
else else
{ {
gllvdbg("Bound SSI port 1 to OLED %d\n", devno); gllvdbg("Bound SPI port 1 to OLED %d\n", devno);
/* And turn the OLED on (dim) */ /* And turn the OLED on (dim) */

View File

@ -134,7 +134,7 @@ void weak_function lpc17_sspinitialize(void)
* The external functions, lpc17_ssp0/ssp1select and lpc17_ssp0/ssp1status * The external functions, lpc17_ssp0/ssp1select and lpc17_ssp0/ssp1status
* must be provided by board-specific logic. They are implementations of the select * must be provided by board-specific logic. They are implementations of the select
* and status methods of the SPI interface defined by struct spi_ops_s (see * and status methods of the SPI interface defined by struct spi_ops_s (see
* include/nuttx/spi.h). All other methods (including up_spiinitialize()) * include/nuttx/spi.h). All other methods (including lpc17_sspinitialize())
* are provided by common LPC17xx logic. To use this common SPI logic on your * are provided by common LPC17xx logic. To use this common SPI logic on your
* board: * board:
* *
@ -143,9 +143,9 @@ void weak_function lpc17_sspinitialize(void)
* 2. Provide lpc17_ssp0/ssp1select() and lpc17_ssp0/ssp1status() functions * 2. Provide lpc17_ssp0/ssp1select() and lpc17_ssp0/ssp1status() functions
* in your board-specific logic. These functions will perform chip selection * in your board-specific logic. These functions will perform chip selection
* and status operations using GPIOs in the way your board is configured. * and status operations using GPIOs in the way your board is configured.
* 3. Add a calls to up_spiinitialize() in your low level application * 3. Add a calls to lpc17_sspinitialize() in your low level application
* initialization logic * initialization logic
* 4. The handle returned by up_spiinitialize() may then be used to bind the * 4. The handle returned by lpc17_sspinitialize() may then be used to bind the
* SPI driver to higher level logic (e.g., calling * SPI driver to higher level logic (e.g., calling
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to * mmcsd_spislotinitialize(), for example, will bind the SPI driver to
* the SPI MMC/SD driver). * the SPI MMC/SD driver).

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* configs/lpcxpresso-lpc1768/src/up_usbmsc.c * configs/lpcxpresso-lpc1768/src/up_usbmsc.c
* *
* Copyright (C) 2011 Gregory Nutt. All rights reserved. * Copyright (C) 2011, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Configure and register the LPC17xx MMC/SD SPI block driver. * Configure and register the LPC17xx MMC/SD SPI block driver.
@ -113,7 +113,7 @@ int usbmsc_archinitialize(void)
message("usbmsc_archinitialize: Initializing SPI port %d\n", message("usbmsc_archinitialize: Initializing SPI port %d\n",
LPC17XX_MMCSDSPIPORTNO); LPC17XX_MMCSDSPIPORTNO);
spi = up_spiinitialize(LPC17XX_MMCSDSPIPORTNO); spi = lpc17_sspinitialize(LPC17XX_MMCSDSPIPORTNO);
if (!spi) if (!spi)
{ {
message("usbmsc_archinitialize: Failed to initialize SPI port %d\n", message("usbmsc_archinitialize: Failed to initialize SPI port %d\n",

View File

@ -2,7 +2,7 @@
* config/nucleus2g/src/up_nsh.c * config/nucleus2g/src/up_nsh.c
* arch/arm/src/board/up_nsh.c * arch/arm/src/board/up_nsh.c
* *
* Copyright (C) 2010-2011 Gregory Nutt. All rights reserved. * Copyright (C) 2010-2011, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -136,7 +136,7 @@ int nsh_archinitialize(void)
/* Get the SSP port */ /* Get the SSP port */
ssp = up_spiinitialize(CONFIG_NSH_MMCSDSPIPORTNO); ssp = lpc17_sspinitialize(CONFIG_NSH_MMCSDSPIPORTNO);
if (!ssp) if (!ssp)
{ {
message("nsh_archinitialize: Failed to initialize SSP port %d\n", message("nsh_archinitialize: Failed to initialize SSP port %d\n",

View File

@ -137,7 +137,7 @@ void weak_function lpc17_sspinitialize(void)
* The external functions, lpc17_ssp0/ssp1select and lpc17_ssp0/ssp1status * The external functions, lpc17_ssp0/ssp1select and lpc17_ssp0/ssp1status
* must be provided by board-specific logic. They are implementations of the select * must be provided by board-specific logic. They are implementations of the select
* and status methods of the SPI interface defined by struct spi_ops_s (see * and status methods of the SPI interface defined by struct spi_ops_s (see
* include/nuttx/spi.h). All other methods (including up_spiinitialize()) * include/nuttx/spi.h). All other methods (including lpc17_sspinitialize())
* are provided by common LPC17xx logic. To use this common SPI logic on your * are provided by common LPC17xx logic. To use this common SPI logic on your
* board: * board:
* *
@ -146,9 +146,9 @@ void weak_function lpc17_sspinitialize(void)
* 2. Provide lpc17_ssp0/ssp1select() and lpc17_ssp0/ssp1status() functions * 2. Provide lpc17_ssp0/ssp1select() and lpc17_ssp0/ssp1status() functions
* in your board-specific logic. These functions will perform chip selection * in your board-specific logic. These functions will perform chip selection
* and status operations using GPIOs in the way your board is configured. * and status operations using GPIOs in the way your board is configured.
* 3. Add a calls to up_spiinitialize() in your low level application * 3. Add a calls to lpc17_sspinitialize() in your low level application
* initialization logic * initialization logic
* 4. The handle returned by up_spiinitialize() may then be used to bind the * 4. The handle returned by lpc17_sspinitialize() may then be used to bind the
* SPI driver to higher level logic (e.g., calling * SPI driver to higher level logic (e.g., calling
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to * mmcsd_spislotinitialize(), for example, will bind the SPI driver to
* the SPI MMC/SD driver). * the SPI MMC/SD driver).

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* configs/nucleus2g/src/up_usbmsc.c * configs/nucleus2g/src/up_usbmsc.c
* *
* Copyright (C) 2010 Gregory Nutt. All rights reserved. * Copyright (C) 2010, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Configure and register the LPC17xx MMC/SD SPI block driver. * Configure and register the LPC17xx MMC/SD SPI block driver.
@ -113,7 +113,7 @@ int usbmsc_archinitialize(void)
message("usbmsc_archinitialize: Initializing SPI port %d\n", message("usbmsc_archinitialize: Initializing SPI port %d\n",
LPC17XX_MMCSDSPIPORTNO); LPC17XX_MMCSDSPIPORTNO);
spi = up_spiinitialize(LPC17XX_MMCSDSPIPORTNO); spi = lpc17_sspinitialize(LPC17XX_MMCSDSPIPORTNO);
if (!spi) if (!spi)
{ {
message("usbmsc_archinitialize: Failed to initialize SPI port %d\n", message("usbmsc_archinitialize: Failed to initialize SPI port %d\n",

View File

@ -2,7 +2,7 @@
* config/olimex-lpc1766stk/src/up_lcd.c * config/olimex-lpc1766stk/src/up_lcd.c
* arch/arm/src/board/up_lcd.c * arch/arm/src/board/up_lcd.c
* *
* Copyright (C) 2010 Gregory Nutt. All rights reserved. * Copyright (C) 2010, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -207,9 +207,9 @@ FAR struct lcd_dev_s *up_nxdrvinit(unsigned int devno)
nokia_blinitialize(); nokia_blinitialize();
/* Get the SSP port (configure as a Freescale SPI port) */ /* Get the SSP0 port (configure as a Freescale SPI port) */
spi = up_spiinitialize(0); spi = lpc17_sspinitialize(0);
if (!spi) if (!spi)
{ {
glldbg("Failed to initialize SSP port 0\n"); glldbg("Failed to initialize SSP port 0\n");

View File

@ -209,7 +209,7 @@ static int nsh_sdinitialize(void)
/* Get the SSP port */ /* Get the SSP port */
ssp = up_spiinitialize(CONFIG_NSH_MMCSDSPIPORTNO); ssp = lpc17_sspinitialize(CONFIG_NSH_MMCSDSPIPORTNO);
if (!ssp) if (!ssp)
{ {
message("nsh_archinitialize: Failed to initialize SSP port %d\n", message("nsh_archinitialize: Failed to initialize SSP port %d\n",

View File

@ -2,7 +2,7 @@
* configs/olimex-lpc1766stk/src/up_ssp.c * configs/olimex-lpc1766stk/src/up_ssp.c
* arch/arm/src/board/up_ssp.c * arch/arm/src/board/up_ssp.c
* *
* Copyright (C) 2010 Gregory Nutt. All rights reserved. * Copyright (C) 2010, 2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -258,7 +258,7 @@ void weak_function lpc17_sspinitialize(void)
* The external functions, lpc17_ssp0/ssp1select and lpc17_ssp0/ssp1status * The external functions, lpc17_ssp0/ssp1select and lpc17_ssp0/ssp1status
* must be provided by board-specific logic. They are implementations of the select * must be provided by board-specific logic. They are implementations of the select
* and status methods of the SPI interface defined by struct spi_ops_s (see * and status methods of the SPI interface defined by struct spi_ops_s (see
* include/nuttx/spi.h). All other methods (including up_spiinitialize()) * include/nuttx/spi.h). All other methods (including lpc17_sspinitialize())
* are provided by common LPC17xx logic. To use this common SPI logic on your * are provided by common LPC17xx logic. To use this common SPI logic on your
* board: * board:
* *
@ -267,9 +267,9 @@ void weak_function lpc17_sspinitialize(void)
* 2. Provide lpc17_ssp0/ssp1select() and lpc17_ssp0/ssp1status() functions * 2. Provide lpc17_ssp0/ssp1select() and lpc17_ssp0/ssp1status() functions
* in your board-specific logic. These functions will perform chip selection * in your board-specific logic. These functions will perform chip selection
* and status operations using GPIOs in the way your board is configured. * and status operations using GPIOs in the way your board is configured.
* 3. Add a calls to up_spiinitialize() in your low level application * 3. Add a calls to lpc17_sspinitialize() in your low level application
* initialization logic * initialization logic
* 4. The handle returned by up_spiinitialize() may then be used to bind the * 4. The handle returned by lpc17_sspinitialize() may then be used to bind the
* SPI driver to higher level logic (e.g., calling * SPI driver to higher level logic (e.g., calling
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to * mmcsd_spislotinitialize(), for example, will bind the SPI driver to
* the SPI MMC/SD driver). * the SPI MMC/SD driver).

View File

@ -93,7 +93,6 @@
# endif # endif
#endif #endif
/**************************************************************************** /****************************************************************************
* Public Functions * Public Functions
****************************************************************************/ ****************************************************************************/
@ -120,7 +119,7 @@ int usbmsc_archinitialize(void)
message("usbmsc_archinitialize: Initializing SPI port %d\n", message("usbmsc_archinitialize: Initializing SPI port %d\n",
LPC17XX_MMCSDSPIPORTNO); LPC17XX_MMCSDSPIPORTNO);
spi = up_spiinitialize(LPC17XX_MMCSDSPIPORTNO); spi = lpc17_sspinitialize(LPC17XX_MMCSDSPIPORTNO);
if (!spi) if (!spi)
{ {
message("usbmsc_archinitialize: Failed to initialize SPI port %d\n", message("usbmsc_archinitialize: Failed to initialize SPI port %d\n",

View File

@ -85,6 +85,7 @@
# define leddbg(x...) # define leddbg(x...)
# define ledvdbg(x...) # define ledvdbg(x...)
#endif #endif
/**************************************************************************** /****************************************************************************
* Private Data * Private Data
****************************************************************************/ ****************************************************************************/
@ -113,12 +114,13 @@ int up_lcdinitialize(void)
lpc17_gpiowrite(ZKITARM_OLED_CS, 1); lpc17_gpiowrite(ZKITARM_OLED_CS, 1);
lpc17_gpiowrite(ZKITARM_OLED_RS, 1); lpc17_gpiowrite(ZKITARM_OLED_RS, 1);
spi = up_spiinitialize(0); spi = lpc17_sspinitialize(0);
if (!spi) if (!spi)
{ {
glldbg("Failed to initialize SSI port 0\n"); glldbg("Failed to initialize SSI port 0\n");
return 0; return 0;
} }
lpc17_gpiowrite(ZKITARM_OLED_RST, 0); lpc17_gpiowrite(ZKITARM_OLED_RST, 0);
up_mdelay(1); up_mdelay(1);
lpc17_gpiowrite(ZKITARM_OLED_RST, 1); lpc17_gpiowrite(ZKITARM_OLED_RST, 1);
@ -144,6 +146,7 @@ FAR struct lcd_dev_s *up_lcdgetdev(int lcddev)
(void)dev->setpower(dev, CONFIG_LCD_MAXPOWER); (void)dev->setpower(dev, CONFIG_LCD_MAXPOWER);
return dev; return dev;
} }
return NULL; return NULL;
} }

View File

@ -148,7 +148,7 @@ int nsh_archinitialize(void)
/* Get the SSP port */ /* Get the SSP port */
ssp = up_spiinitialize(CONFIG_NSH_MMCSDSPIPORTNO); ssp = lpc17_sspinitialize(CONFIG_NSH_MMCSDSPIPORTNO);
if (!ssp) if (!ssp)
{ {
message("nsh_archinitialize: Failed to initialize SSP port %d\n", message("nsh_archinitialize: Failed to initialize SSP port %d\n",

View File

@ -135,7 +135,7 @@ void weak_function lpc17_sspinitialize(void)
* The external functions, lpc17_ssp0/ssp1select and lpc17_ssp0/ssp1status * The external functions, lpc17_ssp0/ssp1select and lpc17_ssp0/ssp1status
* must be provided by board-specific logic. They are implementations of the select * must be provided by board-specific logic. They are implementations of the select
* and status methods of the SPI interface defined by struct spi_ops_s (see * and status methods of the SPI interface defined by struct spi_ops_s (see
* include/nuttx/spi.h). All other methods (including up_spiinitialize()) * include/nuttx/spi.h). All other methods (including lpc17_sspinitialize())
* are provided by common LPC17xx logic. To use this common SPI logic on your * are provided by common LPC17xx logic. To use this common SPI logic on your
* board: * board:
* *
@ -144,9 +144,9 @@ void weak_function lpc17_sspinitialize(void)
* 2. Provide lpc17_ssp0/ssp1select() and lpc17_ssp0/ssp1status() functions * 2. Provide lpc17_ssp0/ssp1select() and lpc17_ssp0/ssp1status() functions
* in your board-specific logic. These functions will perform chip selection * in your board-specific logic. These functions will perform chip selection
* and status operations using GPIOs in the way your board is configured. * and status operations using GPIOs in the way your board is configured.
* 3. Add a calls to up_spiinitialize() in your low level application * 3. Add a calls to lpc17_sspinitialize() in your low level application
* initialization logic * initialization logic
* 4. The handle returned by up_spiinitialize() may then be used to bind the * 4. The handle returned by lpc17_sspinitialize() may then be used to bind the
* SPI driver to higher level logic (e.g., calling * SPI driver to higher level logic (e.g., calling
* mmcsd_spislotinitialize(), for example, will bind the SPI driver to * mmcsd_spislotinitialize(), for example, will bind the SPI driver to
* the SPI MMC/SD driver). * the SPI MMC/SD driver).

View File

@ -117,7 +117,7 @@ int usbmsc_archinitialize(void)
message("usbmsc_archinitialize: Initializing SPI port %d\n", message("usbmsc_archinitialize: Initializing SPI port %d\n",
LPC17XX_MMCSDSPIPORTNO); LPC17XX_MMCSDSPIPORTNO);
spi = up_spiinitialize(LPC17XX_MMCSDSPIPORTNO); spi = lpc17_sspinitialize(LPC17XX_MMCSDSPIPORTNO);
if (!spi) if (!spi)
{ {
message("usbmsc_archinitialize: Failed to initialize SPI port %d\n", message("usbmsc_archinitialize: Failed to initialize SPI port %d\n",

View File

@ -1,7 +1,7 @@
/**************************************************************************** /****************************************************************************
* include/nuttx/spi.h * include/nuttx/spi.h
* *
* Copyright(C) 2008-2012 Gregory Nutt. All rights reserved. * Copyright(C) 2008-2013 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <gnutt@nuttx.org> * Author: Gregory Nutt <gnutt@nuttx.org>
* *
* Redistribution and use in source and binary forms, with or without * Redistribution and use in source and binary forms, with or without
@ -418,7 +418,8 @@ struct spi_dev_s
#undef EXTERN #undef EXTERN
#if defined(__cplusplus) #if defined(__cplusplus)
#define EXTERN extern "C" #define EXTERN extern "C"
extern "C" { extern "C"
{
#else #else
#define EXTERN extern #define EXTERN extern
#endif #endif
@ -429,15 +430,35 @@ extern "C" {
* Description: * Description:
* Initialize the selected SPI port. * Initialize the selected SPI port.
* *
* This is a generic prototype for the SPI initialize logic. Specific
* architectures may support different SPI initialization functions if,
* for example, those architectures support multiple, incompatible SPI
* implementations. In any event, the prototype of those architecture-
* specific initialization functions should be the same as
* up_spiinitialize()
*
* As an example, the LPC17xx family supports an SPI block and several SSP
* blocks that may be programmed to support the SPI function. In this
* case, the LPC17xx architecture supports these two initialization
* functions:
*
* FAR struct spi_dev_s *lpc17_spiinitialize(int port);
* FAR struct spi_dev_s *lpc17_sspinitialize(int port);
*
* Another example would be the STM32 families that support both SPI
* blocks as well as USARTs that can be configured to perform the SPI
* function as well (the STM32 USARTs do not suppor SPI as of this
* writing).
*
* Input Parameter: * Input Parameter:
* Port number (for hardware that has mutiple SPI interfaces) * Port number (for hardware that has mutiple SPI interfaces)
* *
* Returned Value: * Returned Value:
* Valid SPI device structre reference on succcess; a NULL on failure * Valid SPI device structure reference on succcess; a NULL on failure
* *
****************************************************************************/ ****************************************************************************/
EXTERN FAR struct spi_dev_s *up_spiinitialize(int port); FAR struct spi_dev_s *up_spiinitialize(int port);
#undef EXTERN #undef EXTERN
#if defined(__cplusplus) #if defined(__cplusplus)