diff options
author | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2011-10-04 17:08:59 +0000 |
---|---|---|
committer | patacongo <patacongo@7fd9a85b-ad96-42d3-883c-3090e2eb8679> | 2011-10-04 17:08:59 +0000 |
commit | 6f56da01b312d7fef2b480eda53d7682fb4dd540 (patch) | |
tree | 2acea35bd828c7017ca8e48dd2bafc4fe2610c15 /nuttx/configs/sam3u-ek/src | |
parent | 72bddba8c0fb108a2d5a7d343750900f06e1c4f5 (diff) |
ADS7843E driver is code complete
git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@4018 7fd9a85b-ad96-42d3-883c-3090e2eb8679
Diffstat (limited to 'nuttx/configs/sam3u-ek/src')
-rw-r--r-- | nuttx/configs/sam3u-ek/src/sam3uek_internal.h | 7 | ||||
-rw-r--r-- | nuttx/configs/sam3u-ek/src/up_spi.c | 1 | ||||
-rwxr-xr-x | nuttx/configs/sam3u-ek/src/up_touchscreen.c | 72 |
3 files changed, 62 insertions, 18 deletions
diff --git a/nuttx/configs/sam3u-ek/src/sam3uek_internal.h b/nuttx/configs/sam3u-ek/src/sam3uek_internal.h index c7f9d42783..1aa66d517c 100644 --- a/nuttx/configs/sam3u-ek/src/sam3uek_internal.h +++ b/nuttx/configs/sam3u-ek/src/sam3uek_internal.h @@ -46,6 +46,7 @@ #include <stdint.h> +#include <arch/irq.h> #include <nuttx/irq.h> /************************************************************************************ @@ -138,8 +139,10 @@ /* Touchscreen controller (TSC) */ -#define GPIO_TCS_IRQ (PIO_INPUT|GPIO_CFG_PULLUP|GPIO_PORT_PIOA|GPIO_PIN6) -#define GPIO_TCS_BUSY (PIO_INPUT|GPIO_CFG_PULLUP|GPIO_PORT_PIOA|GPIO_PIN6) +#define GPIO_TCS_IRQ (GPIO_INPUT|GPIO_CFG_PULLUP|GPIO_PORT_PIOA|GPIO_PIN24) +#define GPIO_TCS_BUSY (GPIO_INPUT|GPIO_CFG_PULLUP|GPIO_PORT_PIOA|GPIO_PIN2) + +#define SAM3U_TCS_IRQ SAM3U_IRQ_PA24 /* LEDs */ diff --git a/nuttx/configs/sam3u-ek/src/up_spi.c b/nuttx/configs/sam3u-ek/src/up_spi.c index 5c70a5ab53..515dab2e75 100644 --- a/nuttx/configs/sam3u-ek/src/up_spi.c +++ b/nuttx/configs/sam3u-ek/src/up_spi.c @@ -43,6 +43,7 @@ #include <stdint.h> #include <stdbool.h> #include <debug.h> +#include <errno.h> #include <nuttx/spi.h> #include <arch/board/board.h> diff --git a/nuttx/configs/sam3u-ek/src/up_touchscreen.c b/nuttx/configs/sam3u-ek/src/up_touchscreen.c index 40dd2db15b..699c245b78 100755 --- a/nuttx/configs/sam3u-ek/src/up_touchscreen.c +++ b/nuttx/configs/sam3u-ek/src/up_touchscreen.c @@ -45,7 +45,7 @@ #include <debug.h> #include <errno.h> -#include <nuttx/sdio.h> +#include <nuttx/spi.h> #include <nuttx/input/touchscreen.h> #include <nuttx/input/ads7843e.h> @@ -66,6 +66,26 @@ # error "Touchscreen support requires CONFIG_SAM3U_SPI" #endif +#ifndef CONFIG_GPIOA_IRQ +# error "Touchscreen support requires CONFIG_GPIOA_IRQ" +#endif + +#ifndef CONFIG_ADS7843E_FREQUENCY +# define CONFIG_ADS7843E_FREQUENCY 500000 +#endif + +#ifndef CONFIG_ADS7843E_SPIDEV +# define CONFIG_ADS7843E_SPIDEV 0 +#endif + +#if CONFIG_ADS7843E_SPIDEV != 0 +# error "CONFIG_ADS7843E_SPIDEV must be zero" +#endif + +#ifndef CONFIG_ADS7843E_DEVMINOR +# define CONFIG_ADS7843E_DEVMINOR 0 +#endif + /**************************************************************************** * Static Function Prototypes ****************************************************************************/ @@ -85,6 +105,7 @@ static int tsc_attach(FAR struct ads7843e_config_s *state, xcpt_t isr); static void tsc_enable(FAR struct ads7843e_config_s *state, bool enable); static void tsc_clear(FAR struct ads7843e_config_s *state); +static bool tsc_busy(FAR struct ads7843e_config_s *state); static bool tsc_pendown(FAR struct ads7843e_config_s *state); /**************************************************************************** @@ -103,12 +124,12 @@ static bool tsc_pendown(FAR struct ads7843e_config_s *state); static struct ads7843e_config_s g_tscinfo = { - .calib = CONFIG_INPUT_TSCCALIB, - .frequency = CONFIG_INPUT_TSCFREQUENCY, + .frequency = CONFIG_ADS7843E_FREQUENCY, .attach = tsc_attach, .enable = tsc_enable, .clear = tsc_clear, + .busy = tsc_busy, .pendown = tsc_pendown, }; @@ -130,22 +151,24 @@ static struct ads7843e_config_s g_tscinfo = static int tsc_attach(FAR struct ads7843e_config_s *state, xcpt_t isr) { -#warning "Missing logic" - return OK; + /* Attach the ADS7843E interrupt */ + + ivdbg("Attaching %p to IRQ %d\n", isr, SAM3U_TCS_IRQ); + return irq_attach(SAM3U_TCS_IRQ, isr); } static void tsc_enable(FAR struct ads7843e_config_s *state, bool enable) { /* Attach and enable, or detach and disable */ - if (enable && g_tschandler) + ivdbg("IRQ:%d enable:%d\n", SAM3U_TCS_IRQ, enable); + if (enable) { - /* Configure and enable the ADS7843E interrupt */ -#warning "Missing logic" + sam3u_gpioirqenable(SAM3U_TCS_IRQ); } else { -#warning "Missing logic" + sam3u_gpioirqdisable(SAM3U_TCS_IRQ); } } @@ -154,11 +177,22 @@ static void tsc_clear(FAR struct ads7843e_config_s *state) /* Does nothing */ } +static bool tsc_busy(FAR struct ads7843e_config_s *state) +{ + /* REVISIT: This might need to be inverted */ + + bool busy = sam3u_gpioread(GPIO_TCS_BUSY); + ivdbg("busy:%d\n", busy); + return busy; +} + static bool tsc_pendown(FAR struct ads7843e_config_s *state) { /* REVISIT: This might need to be inverted */ - return sam3u_gpioread(GPIO_ADS7843E); + bool pendown = sam3u_gpioread(GPIO_TCS_IRQ); + ivdbg("pendown:%d\n", pendown); + return pendown; } /**************************************************************************** @@ -178,26 +212,32 @@ int up_tcinitialize(void) FAR struct spi_dev_s *dev; int ret; + ivdbg("Initializing\n"); + /* Configure and enable the ADS7843E interrupt pin as an input */ - (void)sam3u_configgpio(GPIO_ADS7843E_BUY); - (void)sam3u_configgpio(GPIO_ADS7843E_IRQ); + (void)sam3u_configgpio(GPIO_TCS_BUSY); + (void)sam3u_configgpio(GPIO_TCS_IRQ); + + /* Configure the PIO interrupt */ + + sam3u_gpioirq(GPIO_TCS_IRQ); /* Get an instance of the SPI interface */ - dev = up_spiinitialize(CONFIG_INPUT_TSCSPIDEV); + dev = up_spiinitialize(CONFIG_ADS7843E_SPIDEV); if (!dev) { - dbg("Failed to initialize SPI bus %d\n", CONFIG_INPUT_TSCSPIDEV); + idbg("Failed to initialize SPI bus %d\n", CONFIG_ADS7843E_SPIDEV); return -ENODEV; } /* Initialize and register the SPI touschscreen device */ - ret = ads7843e_register(dev, &g_tscinfo, CONFIG_INPUT_TSCMINOR); + ret = ads7843e_register(dev, &g_tscinfo, CONFIG_ADS7843E_DEVMINOR); if (ret < 0) { - dbg("Failed to initialize SPI bus %d\n", CONFIG_INPUT_TSCSPIDEV); + idbg("Failed to initialize SPI bus %d\n", CONFIG_ADS7843E_SPIDEV); /* up_spiuninitialize(dev); */ return -ENODEV; } |