diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-10-04 17:08:59 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2011-10-04 17:08:59 +0000 |
commit | 68c47baf9fce581d0078384ef0fcdb6436292fcb (patch) | |
tree | 2acea35bd828c7017ca8e48dd2bafc4fe2610c15 /nuttx/configs/sam3u-ek/src/up_touchscreen.c | |
parent | 0eda7244af71108683fb409517ccb18dd78dd65c (diff) | |
download | px4-nuttx-68c47baf9fce581d0078384ef0fcdb6436292fcb.tar.gz px4-nuttx-68c47baf9fce581d0078384ef0fcdb6436292fcb.tar.bz2 px4-nuttx-68c47baf9fce581d0078384ef0fcdb6436292fcb.zip |
ADS7843E driver is code complete
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4018 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/configs/sam3u-ek/src/up_touchscreen.c')
-rwxr-xr-x | nuttx/configs/sam3u-ek/src/up_touchscreen.c | 72 |
1 files changed, 56 insertions, 16 deletions
diff --git a/nuttx/configs/sam3u-ek/src/up_touchscreen.c b/nuttx/configs/sam3u-ek/src/up_touchscreen.c index 40dd2db15..699c245b7 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; } |