Add SAM3U board-specific SPI support

git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4011 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
patacongo 2011-10-03 15:09:47 +00:00
parent 9b9a25d1aa
commit ae205f2c8f
12 changed files with 405 additions and 402 deletions

0
configs/sam3u-ek/src/Makefile Executable file → Normal file
View File

6
configs/sam3u-ek/src/sam3uek_internal.h Executable file → Normal file
View File

@ -3,7 +3,7 @@
* arch/arm/src/board/sam3uek_internal.n
*
* Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -161,9 +161,9 @@
/* SPI Chip Selects */
/* Chip select pin connected to the touchscreen controller. */
/* Chip select pin connected to the touchscreen controller and to ZigBee module connector. */
#define GPIO_TSC_NPCS GPIO_SPI0_NPCS2_PC14
#define GPIO_TSC_NPCS2 GPIO_SPI0_NPCS2_3
/************************************************************************************
* Public Types

4
configs/sam3u-ek/src/up_boot.c Executable file → Normal file
View File

@ -3,7 +3,7 @@
* arch/arm/src/board/up_boot.c
*
* Copyright (C) 2009-2010 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -75,7 +75,7 @@ void sam3u_boardinitialize(void)
* sam3u_spiinitialize() has been brought into the link.
*/
#if defined(CONFIG_SAM3U_SPI1) || defined(CONFIG_SAM3U_SPI2)
#ifdef CONFIG_SAM3U_SPI
if (sam3u_spiinitialize)
{
sam3u_spiinitialize();

0
configs/sam3u-ek/src/up_buttons.c Executable file → Normal file
View File

0
configs/sam3u-ek/src/up_lcd.c Executable file → Normal file
View File

0
configs/sam3u-ek/src/up_leds.c Executable file → Normal file
View File

0
configs/sam3u-ek/src/up_mmcsd.c Executable file → Normal file
View File

0
configs/sam3u-ek/src/up_nsh.c Executable file → Normal file
View File

81
configs/sam3u-ek/src/up_spi.c Executable file → Normal file
View File

@ -3,7 +3,7 @@
* arch/arm/src/board/up_spi.c
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
* Author: Gregory Nutt <gnutt@nuttx.org>
*
* Redistribution and use in source and binary forms, with or without
* modification, are permitted provided that the following conditions
@ -52,7 +52,7 @@
#include "sam3u_internal.h"
#include "sam3uek_internal.h"
#if defined(CONFIG_SAM3U_SPI1) || defined(CONFIG_SAM3U_SPI2) || defined(CONFIG_SAM3U_SPI3)
#ifdef CONFIG_SAM3U_SPI
/************************************************************************************
* Definitions
@ -94,25 +94,37 @@
void weak_function sam3u_spiinitialize(void)
{
/* The ZigBee module connects used NPCS0. However, there is not yet any
* ZigBee support.
*/
/* The touchscreen connects using NPCS2 (PC14). */
#if defined(CONFIG_INPUT) && defined(CONFIG_INPUT_ADS7843E)
sam3u_configgpio(GPIO_TSC_NPCS2);
#endif
}
/****************************************************************************
* Name: sam3u_spi1/2/3select and sam3u_spi1/2/3status
* Name: sam3u_spiselect, sam3u_spistatus, and sam3u_spicmddata
*
* Description:
* The external functions, sam3u_spi1/2/3select and sam3u_spi1/2/3status 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
* include/nuttx/spi.h). All other methods (including up_spiinitialize())
* are provided by common SAM3U logic. To use this common SPI logic on your
* board:
* These external functions must be provided by board-specific logic. They
* are 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 including up_spiinitialize()) are provided by common SAM3U
* logic. To use this common SPI logic on your board:
*
* 1. Provide logic in sam3u_boardinitialize() to configure SPI chip select
* pins.
* 2. Provide sam3u_spi1/2/3select() and sam3u_spi1/2/3status() functions in your
* board-specific logic. These functions will perform chip selection and
* status operations using GPIOs in the way your board is configured.
* 3. Add a calls to up_spiinitialize() in your low level application
* 2. Provide sam3u_spiselect() and sam3u_spistatus() functions in your
* board-specific logic. These functions will perform chip selection
* and status operations using GPIOs in the way your board is configured.
* 2. If CONFIG_SPI_CMDDATA is defined in the NuttX configuration, provide
* sam3u_spicmddata() functions in your board-specific logic. This
* function will perform cmd/data selection operations using GPIOs in
* the way your board is configured.
* 3. Add a call to up_spiinitialize() in your low level application
* initialization logic
* 4. The handle returned by up_spiinitialize() may then be used to bind the
* SPI driver to higher level logic (e.g., calling
@ -121,40 +133,25 @@ void weak_function sam3u_spiinitialize(void)
*
****************************************************************************/
#ifdef CONFIG_SAM3U_SPI1
void sam3u_spi1select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
#ifdef CONFIG_SAM3U_SPI
void sam3u_spiselect(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
#if defined(CONFIG_INPUT) && defined(CONFIG_INPUT_ADS7843E)
if (devid == SPIDEV_TOUCHSCREEN)
{
/* Assert the CS pin to the OLED display */
(void)lpc17_gpiowrite(GPIO_TSC_NPCS2, !selected);
}
#endif
}
uint8_t sam3u_spi1status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
uint8_t sam3u_spistatus(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
return SPI_STATUS_PRESENT;
return 0;
}
#endif
#ifdef CONFIG_SAM3U_SPI2
void sam3u_spi2select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
}
uint8_t sam3u_spi2status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
return SPI_STATUS_PRESENT;
}
#endif
#ifdef CONFIG_SAM3U_SPI3
void sam3u_spi3select(FAR struct spi_dev_s *dev, enum spi_dev_e devid, bool selected)
{
spidbg("devid: %d CS: %s\n", (int)devid, selected ? "assert" : "de-assert");
}
uint8_t sam3u_spi3status(FAR struct spi_dev_s *dev, enum spi_dev_e devid)
{
return SPI_STATUS_PRESENT;
}
#endif
#endif /* CONFIG_SAM3U_SPI1 || CONFIG_SAM3U_SPI2 || CONFIG_SAM3U_SPI3 */
#endif /* CONFIG_SAM3U_SPI */

0
configs/sam3u-ek/src/up_usbdev.c Executable file → Normal file
View File

0
configs/sam3u-ek/src/up_usbstrg.c Executable file → Normal file
View File

View File

@ -179,6 +179,12 @@ CONFIG_USART1_2STOP=0
CONFIG_USART2_2STOP=0
CONFIG_USART3_2STOP=0
#
# Input device configuration
#
CONFIG_INPUT=y
CONFIG_INPUT_ADS7843E=y
#
# General build options
#