mirror of
https://gitee.com/mirrors_PX4/PX4-Autopilot.git
synced 2026-10-25 23:53:33 +08:00
Merge branch 'master' of file:///Users/Shared/NuttX
git-svn-id: http://svn.code.sf.net/p/nuttx/code/trunk@5231 42af7a65-404d-4744-a932-0658087f49c3
This commit is contained in:
@@ -11,6 +11,14 @@ config DEV_ZERO
|
||||
bool "Enable /dev/zero"
|
||||
default n
|
||||
|
||||
config ARCH_HAVE_RNG
|
||||
bool
|
||||
|
||||
config DEV_RANDOM
|
||||
bool "Enable /dev/random"
|
||||
default n
|
||||
depends on ARCH_HAVE_RNG
|
||||
|
||||
config LOOP
|
||||
bool "Enable loop device"
|
||||
default n
|
||||
|
||||
+190
-1
@@ -2,6 +2,7 @@
|
||||
# For a description of the syntax of this configuration file,
|
||||
# see misc/tools/kconfig-language.txt.
|
||||
#
|
||||
|
||||
config INPUT_TSC2007
|
||||
bool "TI TSC2007 touchscreen controller"
|
||||
default n
|
||||
@@ -9,7 +10,29 @@ config INPUT_TSC2007
|
||||
---help---
|
||||
Enable support for the TI TSC2007 touchscreen controller
|
||||
|
||||
|
||||
if INPUT_TSC2007
|
||||
|
||||
config TSC2007_8BIT
|
||||
bool "8-bit Conversions"
|
||||
default n
|
||||
---help---
|
||||
Use faster, but less accurate, 8-bit conversions. Default: 12-bit conversions.
|
||||
|
||||
config TSC2007_MULTIPLE
|
||||
bool "Multiple TSC2007 Devices"
|
||||
default n
|
||||
---help---
|
||||
Can be defined to support multiple TSC2007 devices on board.
|
||||
|
||||
config TSC2007_NPOLLWAITERS
|
||||
int "Number poll waiters"
|
||||
default 4
|
||||
depends on !DISABLE_POLL
|
||||
---help---
|
||||
Maximum number of threads that can be waiting on poll()
|
||||
|
||||
endif
|
||||
|
||||
config INPUT_ADS7843E
|
||||
bool "TI ADS7843/TSC2046 touchscreen controller"
|
||||
default n
|
||||
@@ -18,3 +41,169 @@ config INPUT_ADS7843E
|
||||
Enable support for the TI/Burr-Brown ADS7842 touchscreen controller. I believe
|
||||
that driver should be compatibile with the TI/Burr-Brown TSC2046 and XPT2046
|
||||
touchscreen controllers as well.
|
||||
|
||||
if INPUT_ADS7843E
|
||||
|
||||
config ADS7843E_MULTIPLE
|
||||
bool "Multiple ADS7843E Devices"
|
||||
default n
|
||||
---help---
|
||||
Can be defined to support multiple ADS7843E devices on board.
|
||||
|
||||
config ADS7843E_NPOLLWAITERS
|
||||
int "Number poll waiters"
|
||||
default 4
|
||||
depends on !DISABLE_POLL
|
||||
---help---
|
||||
Maximum number of threads that can be waiting on poll()
|
||||
|
||||
config ADS7843E_SPIMODE
|
||||
int "SPI mode"
|
||||
default 0
|
||||
range 0,3
|
||||
---help---
|
||||
Controls the SPI mode. The device should work in mode 0, but sometimes
|
||||
you need to experiment.
|
||||
|
||||
config ADS7843E_FREQUENCY
|
||||
int "SPI frequency"
|
||||
default 100000
|
||||
---help---
|
||||
Define to use a different SPI bus frequency.
|
||||
|
||||
config ADS7843E_SWAPXY
|
||||
bool "Swap X/Y"
|
||||
default n
|
||||
---help---
|
||||
Reverse the meaning of X and Y to handle different LCD orientations.
|
||||
|
||||
config ADS7843E_THRESHX
|
||||
int "X threshold"
|
||||
default 12
|
||||
---help---
|
||||
New touch positions will only be reported when the X or Y data changes by these
|
||||
thresholds. This trades reduces data rate for some loss in dragging accuracy. For
|
||||
12-bit values so the raw ranges are 0-4095. So for example, if your display is
|
||||
320x240, then THRESHX=13 and THRESHY=17 would correspond to one pixel. Default: 12
|
||||
|
||||
config ADS7843E_THRESHY
|
||||
int "Y threshold"
|
||||
default 12
|
||||
---help---
|
||||
New touch positions will only be reported when the X or Y data changes by these
|
||||
thresholds. This trades reduces data rate for some loss in dragging accuracy. For
|
||||
12-bit values so the raw ranges are 0-4095. So for example, if your display is
|
||||
320x240, then THRESHX=13 and THRESHY=17 would correspond to one pixel. Default: 12
|
||||
|
||||
endif
|
||||
|
||||
config INPUT_STMPE811
|
||||
bool "STMicro STMPE811 Driver"
|
||||
default n
|
||||
---help---
|
||||
Enables support for the STMPE811 driver
|
||||
|
||||
if INPUT_STMPE811
|
||||
|
||||
choice
|
||||
prompt "STMPE Interface"
|
||||
default STMPE811_I2C
|
||||
|
||||
config STMPE811_SPI
|
||||
bool "SPI Interface"
|
||||
select SPI
|
||||
---help---
|
||||
Enables support for the SPI interface (not currently supported)
|
||||
|
||||
config STMPE811_I2C
|
||||
bool "STMPE811 I2C Interface"
|
||||
select I2C
|
||||
---help---
|
||||
Enables support for the I2C interface
|
||||
|
||||
endchoice
|
||||
|
||||
config STMPE811_MULTIPLE
|
||||
bool "Multiple STMPE811 Devices"
|
||||
default n
|
||||
---help---
|
||||
Can be defined to support multiple STMPE811 devices on board.
|
||||
|
||||
config STMPE811_NPOLLWAITERS
|
||||
int "Number poll waiters"
|
||||
default 4
|
||||
depends on !DISABLE_POLL
|
||||
---help---
|
||||
Maximum number of threads that can be waiting on poll()
|
||||
|
||||
config STMPE811_TSC_DISABLE
|
||||
bool "Disable STMPE811 Touchscreen Support"
|
||||
default n
|
||||
---help---
|
||||
Disable driver touchscreen functionality.
|
||||
|
||||
config STMPE811_SWAPXY
|
||||
bool "Swap X/Y"
|
||||
default n
|
||||
depends on !STMPE811_TSC_DISABLE
|
||||
---help---
|
||||
Reverse the meaning of X and Y to handle different LCD orientations.
|
||||
|
||||
config STMPE811_THRESHX
|
||||
int "X threshold"
|
||||
default 12
|
||||
depends on !STMPE811_TSC_DISABLE
|
||||
---help---
|
||||
STMPE811 touchscreen data comes in a a very high rate. New touch positions
|
||||
will only be reported when the X or Y data changes by these thresholds.
|
||||
This trades reduces data rate for some loss in dragging accuracy. The
|
||||
STMPE811 is configure for 12-bit values so the raw ranges are 0-4095. So
|
||||
for example, if your display is 320x240, then THRESHX=13 and THRESHY=17
|
||||
would correspond to one pixel. Default: 12
|
||||
|
||||
config STMPE811_THRESHY
|
||||
int "Y threshold"
|
||||
default 12
|
||||
depends on !STMPE811_TSC_DISABLE
|
||||
---help---
|
||||
STMPE811 touchscreen data comes in a a very high rate. New touch positions
|
||||
will only be reported when the X or Y data changes by these thresholds.
|
||||
This trades reduces data rate for some loss in dragging accuracy. The
|
||||
STMPE811 is configure for 12-bit values so the raw ranges are 0-4095. So
|
||||
for example, if your display is 320x240, then THRESHX=13 and THRESHY=17
|
||||
would correspond to one pixel. Default: 12
|
||||
|
||||
config STMPE811_ADC_DISABLE
|
||||
bool "Disable STMPE811 ADC Support"
|
||||
default y
|
||||
---help---
|
||||
Disable driver ADC functionality.
|
||||
|
||||
config STMPE811_GPIO_DISABLE
|
||||
bool "Disable STMPE811 GPIO Support"
|
||||
default y
|
||||
---help---
|
||||
Disable driver GPIO functionality.
|
||||
|
||||
config STMPE811_GPIOINT_DISABLE
|
||||
bool "Disable STMPE811 GPIO Interrupt Support"
|
||||
default y
|
||||
depends on !STMPE811_GPIO_DISABLE
|
||||
---help---
|
||||
Disable driver GPIO interrupt functionlality (ignored if GPIO functionality is
|
||||
disabled).
|
||||
|
||||
config STMPE811_TEMP_DISABLE
|
||||
bool "Disable STMPE811 Temperature Sensor Support"
|
||||
default y
|
||||
---help---
|
||||
Disable driver temperature sensor functionality.
|
||||
|
||||
config STMPE811_REGDEBUG
|
||||
bool "Enable Register-Level STMPE811 Debug"
|
||||
default n
|
||||
depends on DEBUG
|
||||
---help---
|
||||
Enable very low register-level debug output.
|
||||
|
||||
endif
|
||||
|
||||
+151
-73
@@ -79,6 +79,12 @@
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
|
||||
/* This is a value for the threshold that guantees a big difference on the
|
||||
* first pendown (but can't overflow).
|
||||
*/
|
||||
|
||||
#define INVALID_THRESHOLD 0x1000
|
||||
|
||||
/****************************************************************************
|
||||
* Private Types
|
||||
****************************************************************************/
|
||||
@@ -88,13 +94,14 @@
|
||||
****************************************************************************/
|
||||
/* Low-level SPI helpers */
|
||||
|
||||
static inline void ads7843e_configspi(FAR struct spi_dev_s *spi);
|
||||
#ifdef CONFIG_SPI_OWNBUS
|
||||
static inline void ads7843e_select(FAR struct spi_dev_s *spi);
|
||||
static inline void ads7843e_deselect(FAR struct spi_dev_s *spi);
|
||||
static inline void ads7843e_configspi(FAR struct spi_dev_s *spi);
|
||||
# define ads7843e_lock(spi)
|
||||
# define ads7843e_unlock(spi)
|
||||
#else
|
||||
static void ads7843e_select(FAR struct spi_dev_s *spi);
|
||||
static void ads7843e_deselect(FAR struct spi_dev_s *spi);
|
||||
# define ads7843e_configspi(spi);
|
||||
static void ads7843e_lock(FAR struct spi_dev_s *spi);
|
||||
static void ads7843e_unlock(FAR struct spi_dev_s *spi);
|
||||
#endif
|
||||
|
||||
static inline void ads7843e_waitbusy(FAR struct ads7843e_dev_s *priv);
|
||||
@@ -157,13 +164,12 @@ static struct ads7843e_dev_s *g_ads7843elist;
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ads7843e_select
|
||||
* Function: ads7843e_lock
|
||||
*
|
||||
* Description:
|
||||
* Select the SPI, locking and re-configuring if necessary. This function
|
||||
* must be called before initiating any sequence of SPI operations. If we
|
||||
* are sharing the SPI bus with other devices (CONFIG_SPI_OWNBUS undefined)
|
||||
* then we need to lock and configure the SPI bus for each transfer.
|
||||
* Lock the SPI bus and re-configure as necessary. This function must be
|
||||
* to assure: (1) exclusive access to the SPI bus, and (2) to assure that
|
||||
* the shared bus is properly configured for the touchscreen controller.
|
||||
*
|
||||
* Parameters:
|
||||
* spi - Reference to the SPI driver structure
|
||||
@@ -175,42 +181,35 @@ static struct ads7843e_dev_s *g_ads7843elist;
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SPI_OWNBUS
|
||||
static inline void ads7843e_select(FAR struct spi_dev_s *spi)
|
||||
#ifndef CONFIG_SPI_OWNBUS
|
||||
static void ads7843e_lock(FAR struct spi_dev_s *spi)
|
||||
{
|
||||
/* We own the SPI bus, so just select the chip */
|
||||
|
||||
SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, true);
|
||||
}
|
||||
#else
|
||||
static void ads7843e_select(FAR struct spi_dev_s *spi)
|
||||
{
|
||||
/* Select ADS7843 chip (locking the SPI bus in case there are multiple
|
||||
* devices competing for the SPI bus
|
||||
/* Lock the SPI bus because there are multiple devices competing for the
|
||||
* SPI bus
|
||||
*/
|
||||
|
||||
(void)SPI_LOCK(spi, true);
|
||||
SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, true);
|
||||
|
||||
/* Now make sure that the SPI bus is configured for the ADS7843 (it
|
||||
* might have gotten configured for a different device while unlocked)
|
||||
/* We have the lock. Now make sure that the SPI bus is configured for the
|
||||
* ADS7843 (it might have gotten configured for a different device while
|
||||
* unlocked)
|
||||
*/
|
||||
|
||||
SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, true);
|
||||
SPI_SETMODE(spi, CONFIG_ADS7843E_SPIMODE);
|
||||
SPI_SETBITS(spi, 8);
|
||||
SPI_SETFREQUENCY(spi, CONFIG_ADS7843E_FREQUENCY);
|
||||
SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, false);
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Function: ads7843e_deselect
|
||||
* Function: ads7843e_unlock
|
||||
*
|
||||
* Description:
|
||||
* De-select the SPI, unlocking as necessary. This function must be
|
||||
* after completing a sequence of SPI operations. If we are sharing the SPI
|
||||
* bus with other devices (CONFIG_SPI_OWNBUS undefined) then we need to
|
||||
* un-lock the SPI bus for each transfer, possibly losing the current
|
||||
* configuration.
|
||||
* If we are sharing the SPI bus with other devices (CONFIG_SPI_OWNBUS
|
||||
* undefined) then we need to un-lock the SPI bus for each transfer,
|
||||
* possibly losing the current configuration.
|
||||
*
|
||||
* Parameters:
|
||||
* spi - Reference to the SPI driver structure
|
||||
@@ -222,19 +221,11 @@ static void ads7843e_select(FAR struct spi_dev_s *spi)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SPI_OWNBUS
|
||||
static inline void ads7843e_deselect(FAR struct spi_dev_s *spi)
|
||||
#ifndef CONFIG_SPI_OWNBUS
|
||||
static void ads7843e_unlock(FAR struct spi_dev_s *spi)
|
||||
{
|
||||
/* We own the SPI bus, so just de-select the chip */
|
||||
/* Relinquish the SPI bus. */
|
||||
|
||||
SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, false);
|
||||
}
|
||||
#else
|
||||
static void ads7843e_deselect(FAR struct spi_dev_s *spi)
|
||||
{
|
||||
/* De-select ADS7843 chip and relinquish the SPI bus. */
|
||||
|
||||
SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, false);
|
||||
(void)SPI_LOCK(spi, false);
|
||||
}
|
||||
#endif
|
||||
@@ -258,23 +249,20 @@ static void ads7843e_deselect(FAR struct spi_dev_s *spi)
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef CONFIG_SPI_OWNBUS
|
||||
static inline void ads7843e_configspi(FAR struct spi_dev_s *spi)
|
||||
{
|
||||
idbg("Mode: %d Bits: 8 Frequency: %d\n",
|
||||
CONFIG_ADS7843E_SPIMODE, CONFIG_ADS7843E_FREQUENCY);
|
||||
|
||||
/* Configure SPI for the ADS7843. But only if we own the SPI bus. Otherwise, don't
|
||||
* bother because it might change.
|
||||
*/
|
||||
|
||||
#ifdef CONFIG_SPI_OWNBUS
|
||||
SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, true);
|
||||
SPI_SETMODE(spi, CONFIG_ADS7843E_SPIMODE);
|
||||
SPI_SETBITS(spi, 8);
|
||||
SPI_SETFREQUENCY(spi, CONFIG_ADS7843E_FREQUENCY);
|
||||
SPI_SELECT(spi, SPIDEV_TOUCHSCREEN, false);
|
||||
#endif
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: ads7843e_waitbusy
|
||||
@@ -296,7 +284,7 @@ static uint16_t ads7843e_sendcmd(FAR struct ads7843e_dev_s *priv, uint8_t cmd)
|
||||
|
||||
/* Select the ADS7843E */
|
||||
|
||||
ads7843e_select(priv->spi);
|
||||
SPI_SELECT(priv->spi, SPIDEV_TOUCHSCREEN, true);
|
||||
|
||||
/* Send the command */
|
||||
|
||||
@@ -306,7 +294,7 @@ static uint16_t ads7843e_sendcmd(FAR struct ads7843e_dev_s *priv, uint8_t cmd)
|
||||
/* Read the data */
|
||||
|
||||
SPI_RECVBLOCK(priv->spi, buffer, 2);
|
||||
ads7843e_deselect(priv->spi);
|
||||
SPI_SELECT(priv->spi, SPIDEV_TOUCHSCREEN, false);
|
||||
|
||||
result = ((uint16_t)buffer[0] << 8) | (uint16_t)buffer[1];
|
||||
result = result >> 4;
|
||||
@@ -554,7 +542,12 @@ static void ads7843e_worker(FAR void *arg)
|
||||
{
|
||||
FAR struct ads7843e_dev_s *priv = (FAR struct ads7843e_dev_s *)arg;
|
||||
FAR struct ads7843e_config_s *config;
|
||||
uint16_t x;
|
||||
uint16_t y;
|
||||
uint16_t xdiff;
|
||||
uint16_t ydiff;
|
||||
bool pendown;
|
||||
int ret;
|
||||
|
||||
ASSERT(priv != NULL);
|
||||
|
||||
@@ -565,10 +558,30 @@ static void ads7843e_worker(FAR void *arg)
|
||||
config = priv->config;
|
||||
DEBUGASSERT(config != NULL);
|
||||
|
||||
/* Disable the watchdog timer */
|
||||
/* Disable the watchdog timer. This is safe because it is started only
|
||||
* by this function and this function is serialized on the worker thread.
|
||||
*/
|
||||
|
||||
wd_cancel(priv->wdog);
|
||||
|
||||
/* Lock the SPI bus so that we have exclusive access */
|
||||
|
||||
ads7843e_lock(priv->spi);
|
||||
|
||||
/* Get exclusive access to the driver data structure */
|
||||
|
||||
do
|
||||
{
|
||||
ret = sem_wait(&priv->devsem);
|
||||
|
||||
/* This should only fail if the wait was canceled by an signal
|
||||
* (and the worker thread will receive a lot of signals).
|
||||
*/
|
||||
|
||||
DEBUGASSERT(ret == OK || errno == EINTR);
|
||||
}
|
||||
while (ret < 0);
|
||||
|
||||
/* Check for pen up or down by reading the PENIRQ GPIO. */
|
||||
|
||||
pendown = config->pendown(config);
|
||||
@@ -577,13 +590,20 @@ static void ads7843e_worker(FAR void *arg)
|
||||
|
||||
if (!pendown)
|
||||
{
|
||||
/* Ignore the interrupt if the pen was already up (CONTACT_NONE == pen up and
|
||||
* already reported. CONTACT_UP == pen up, but not reported)
|
||||
/* The pen is up.. reset thresholding variables. */
|
||||
|
||||
priv->threshx = INVALID_THRESHOLD;
|
||||
priv->threshy = INVALID_THRESHOLD;
|
||||
|
||||
/* Ignore the interrupt if the pen was already up (CONTACT_NONE == pen up
|
||||
* and already reported; CONTACT_UP == pen up, but not reported)
|
||||
*/
|
||||
|
||||
if (priv->sample.contact == CONTACT_NONE)
|
||||
if (priv->sample.contact == CONTACT_NONE ||
|
||||
priv->sample.contact == CONTACT_UP)
|
||||
|
||||
{
|
||||
goto errout;
|
||||
goto ignored;
|
||||
}
|
||||
|
||||
/* The pen is up. NOTE: We know from a previous test, that this is a
|
||||
@@ -601,14 +621,57 @@ static void ads7843e_worker(FAR void *arg)
|
||||
|
||||
else if (priv->sample.contact == CONTACT_UP)
|
||||
{
|
||||
goto errout;
|
||||
/* If we have not yet processed the last pen up event, then we
|
||||
* cannot handle this pen down event. We will have to discard it. That
|
||||
* should be okay because we will set the timer to to sample again
|
||||
* later.
|
||||
*/
|
||||
|
||||
wd_start(priv->wdog, ADS7843E_WDOG_DELAY, ads7843e_wdog, 1, (uint32_t)priv);
|
||||
goto ignored;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Handle pen down events. First, sample positional values. */
|
||||
|
||||
priv->sample.x = ads7843e_sendcmd(priv, ADS7843_CMD_XPOSITION);
|
||||
priv->sample.y = ads7843e_sendcmd(priv, ADS7843_CMD_YPOSITION);
|
||||
#ifdef CONFIG_ADS7843E_SWAPXY
|
||||
x = ads7843e_sendcmd(priv, ADS7843_CMD_YPOSITION);
|
||||
y = ads7843e_sendcmd(priv, ADS7843_CMD_XPOSITION);
|
||||
#else
|
||||
x = ads7843e_sendcmd(priv, ADS7843_CMD_XPOSITION);
|
||||
y = ads7843e_sendcmd(priv, ADS7843_CMD_YPOSITION);
|
||||
#endif
|
||||
|
||||
/* Perform a thresholding operation so that the results will be more stable.
|
||||
* If the difference from the last sample is small, then ignore the event.
|
||||
* REVISIT: Should a large change in pressure also generate a event?
|
||||
*/
|
||||
|
||||
xdiff = x > priv->threshx ? (x - priv->threshx) : (priv->threshx - x);
|
||||
ydiff = y > priv->threshy ? (y - priv->threshy) : (priv->threshy - y);
|
||||
|
||||
/* Continue to sample the position while the pen is down */
|
||||
|
||||
wd_start(priv->wdog, ADS7843E_WDOG_DELAY, ads7843e_wdog, 1, (uint32_t)priv);
|
||||
|
||||
/* Check the thresholds. Bail if there is no significant difference */
|
||||
|
||||
if (xdiff < CONFIG_ADS7843E_THRESHX && ydiff < CONFIG_ADS7843E_THRESHY)
|
||||
{
|
||||
/* Little or no change in either direction ... don't report anything. */
|
||||
|
||||
goto ignored;
|
||||
}
|
||||
|
||||
/* When we see a big difference, snap to the new x/y thresholds */
|
||||
|
||||
priv->threshx = x;
|
||||
priv->threshy = y;
|
||||
|
||||
/* Update the x/y position in the sample data */
|
||||
|
||||
priv->sample.x = priv->threshx;
|
||||
priv->sample.y = priv->threshy;
|
||||
|
||||
/* The X/Y positional data is now valid */
|
||||
|
||||
@@ -625,10 +688,6 @@ static void ads7843e_worker(FAR void *arg)
|
||||
|
||||
priv->sample.contact = CONTACT_DOWN;
|
||||
}
|
||||
|
||||
/* Continue to sample the position while the pen is down */
|
||||
|
||||
wd_start(priv->wdog, ADS7843E_WDOG_DELAY, ads7843e_wdog, 1, (uint32_t)priv);
|
||||
}
|
||||
|
||||
/* Indicate the availability of new sample data for this ID */
|
||||
@@ -642,9 +701,15 @@ static void ads7843e_worker(FAR void *arg)
|
||||
|
||||
/* Exit, re-enabling ADS7843E interrupts */
|
||||
|
||||
errout:
|
||||
ignored:
|
||||
|
||||
(void)ads7843e_sendcmd(priv, ADS7843_CMD_ENABPINIRQ);
|
||||
config->enable(config, true);
|
||||
|
||||
/* Release our lock on the state structure and unlock the SPI bus */
|
||||
|
||||
sem_post(&priv->devsem);
|
||||
ads7843e_unlock(priv->spi);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
@@ -871,7 +936,7 @@ static ssize_t ads7843e_read(FAR struct file *filep, FAR char *buffer, size_t le
|
||||
report = (FAR struct touch_sample_s *)buffer;
|
||||
memset(report, 0, SIZEOF_TOUCH_SAMPLE_S(1));
|
||||
report->npoints = 1;
|
||||
report->point[0].id = priv->id;
|
||||
report->point[0].id = sample.id;
|
||||
report->point[0].x = sample.x;
|
||||
report->point[0].y = sample.y;
|
||||
|
||||
@@ -886,8 +951,7 @@ static ssize_t ads7843e_read(FAR struct file *filep, FAR char *buffer, size_t le
|
||||
|
||||
if (sample.valid)
|
||||
{
|
||||
report->point[0].flags = TOUCH_UP | TOUCH_ID_VALID |
|
||||
TOUCH_POS_VALID | TOUCH_PRESSURE_VALID;
|
||||
report->point[0].flags = TOUCH_UP | TOUCH_ID_VALID | TOUCH_POS_VALID;
|
||||
}
|
||||
else
|
||||
{
|
||||
@@ -1098,7 +1162,7 @@ errout:
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
int ads7843e_register(FAR struct spi_dev_s *dev,
|
||||
int ads7843e_register(FAR struct spi_dev_s *spi,
|
||||
FAR struct ads7843e_config_s *config, int minor)
|
||||
{
|
||||
FAR struct ads7843e_dev_s *priv;
|
||||
@@ -1108,11 +1172,11 @@ int ads7843e_register(FAR struct spi_dev_s *dev,
|
||||
#endif
|
||||
int ret;
|
||||
|
||||
ivdbg("dev: %p minor: %d\n", dev, minor);
|
||||
ivdbg("spi: %p minor: %d\n", spi, minor);
|
||||
|
||||
/* Debug-only sanity checks */
|
||||
|
||||
DEBUGASSERT(dev != NULL && config != NULL && minor >= 0 && minor < 100);
|
||||
DEBUGASSERT(spi != NULL && config != NULL && minor >= 0 && minor < 100);
|
||||
|
||||
/* Create and initialize a ADS7843E device driver instance */
|
||||
|
||||
@@ -1130,11 +1194,14 @@ int ads7843e_register(FAR struct spi_dev_s *dev,
|
||||
/* Initialize the ADS7843E device driver instance */
|
||||
|
||||
memset(priv, 0, sizeof(struct ads7843e_dev_s));
|
||||
priv->spi = dev; /* Save the SPI device handle */
|
||||
priv->config = config; /* Save the board configuration */
|
||||
priv->wdog = wd_create(); /* Create a watchdog timer */
|
||||
sem_init(&priv->devsem, 0, 1); /* Initialize device structure semaphore */
|
||||
sem_init(&priv->waitsem, 0, 0); /* Initialize pen event wait semaphore */
|
||||
priv->spi = spi; /* Save the SPI device handle */
|
||||
priv->config = config; /* Save the board configuration */
|
||||
priv->wdog = wd_create(); /* Create a watchdog timer */
|
||||
priv->threshx = INVALID_THRESHOLD; /* Initialize thresholding logic */
|
||||
priv->threshy = INVALID_THRESHOLD; /* Initialize thresholding logic */
|
||||
|
||||
sem_init(&priv->devsem, 0, 1); /* Initialize device structure semaphore */
|
||||
sem_init(&priv->waitsem, 0, 0); /* Initialize pen event wait semaphore */
|
||||
|
||||
/* Make sure that interrupts are disabled */
|
||||
|
||||
@@ -1150,14 +1217,25 @@ int ads7843e_register(FAR struct spi_dev_s *dev,
|
||||
goto errout_with_priv;
|
||||
}
|
||||
|
||||
idbg("Mode: %d Bits: 8 Frequency: %d\n",
|
||||
CONFIG_ADS7843E_SPIMODE, CONFIG_ADS7843E_FREQUENCY);
|
||||
|
||||
/* Lock the SPI bus so that we have exclusive access */
|
||||
|
||||
ads7843e_lock(spi);
|
||||
|
||||
/* Configure the SPI interface */
|
||||
|
||||
ads7843e_configspi(dev);
|
||||
ads7843e_configspi(spi);
|
||||
|
||||
/* Enable the PEN IRQ */
|
||||
|
||||
ads7843e_sendcmd(priv, ADS7843_CMD_ENABPINIRQ);
|
||||
|
||||
/* Unlock the bus */
|
||||
|
||||
ads7843e_unlock(spi);
|
||||
|
||||
/* Register the device as an input device */
|
||||
|
||||
(void)snprintf(devname, DEV_NAMELEN, DEV_FORMAT, minor);
|
||||
|
||||
@@ -139,6 +139,8 @@ struct ads7843e_dev_s
|
||||
uint8_t nwaiters; /* Number of threads waiting for ADS7843E data */
|
||||
uint8_t id; /* Current touch point ID */
|
||||
volatile bool penchange; /* An unreported event is buffered */
|
||||
uint16_t threshx; /* Thresholding X value */
|
||||
uint16_t threshy; /* Thresholding Y value */
|
||||
sem_t devsem; /* Manages exclusive access to this structure */
|
||||
sem_t waitsem; /* Used to wait for the availability of data */
|
||||
|
||||
|
||||
+111
-12
@@ -229,8 +229,8 @@
|
||||
/* Debug ******************************************************************************/
|
||||
|
||||
#ifdef CONFIG_DEBUG_LCD
|
||||
# define lcddbg dbg
|
||||
# define lcdvdbg vdbg
|
||||
# define lcddbg dbg
|
||||
# define lcdvdbg vdbg
|
||||
#else
|
||||
# define lcddbg(x...)
|
||||
# define lcdvdbg(x...)
|
||||
@@ -253,6 +253,16 @@ struct ssd1289_dev_s
|
||||
FAR struct ssd1289_lcd_s *lcd; /* The contained platform-specific, LCD interface */
|
||||
uint8_t power; /* Current power setting */
|
||||
|
||||
/* These fields simplify and reduce debug output */
|
||||
|
||||
#ifdef CONFIG_DEBUG_LCD
|
||||
bool put; /* Last raster operation was a putrun */
|
||||
fb_coord_t firstrow; /* First row of the run */
|
||||
fb_coord_t lastrow; /* Last row of the run */
|
||||
fb_coord_t col; /* Column of the run */
|
||||
size_t npixels; /* Length of the run */
|
||||
#endif
|
||||
|
||||
/* This is working memory allocated by the LCD driver for each LCD device
|
||||
* and for each color plane. This memory will hold one raster line of data.
|
||||
* The size of the allocated run buffer must therefore be at least
|
||||
@@ -287,6 +297,19 @@ static void ssd1289_setcursor(FAR struct ssd1289_lcd_s *lcd, uint16_t column,
|
||||
|
||||
/* LCD Data Transfer Methods */
|
||||
|
||||
#if 0 /* Sometimes useful */
|
||||
static void ssd1289_dumprun(FAR const char *msg, FAR uint16_t *run, size_t npixels);
|
||||
#else
|
||||
# define ssd1289_dumprun(m,r,n)
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_DEBUG_LCD
|
||||
static void ssd1289_showrun(FAR struct ssd1289_dev_s *priv, fb_coord_t row,
|
||||
fb_coord_t col, size_t npixels, bool put);
|
||||
#else
|
||||
# define ssd1289_showrun(p,r,c,n,b)
|
||||
#endif
|
||||
|
||||
static int ssd1289_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buffer,
|
||||
size_t npixels);
|
||||
static int ssd1289_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
|
||||
@@ -488,6 +511,64 @@ static void ssd1289_dumprun(FAR const char *msg, FAR uint16_t *run, size_t npixe
|
||||
}
|
||||
#endif
|
||||
|
||||
/**************************************************************************************
|
||||
* Name: ssd1289_showrun
|
||||
*
|
||||
* Description:
|
||||
* When LCD debug is enabled, try to reduce then amount of ouptut data generated by
|
||||
* ssd1289_putrun and ssd1289_getrun
|
||||
*
|
||||
**************************************************************************************/
|
||||
|
||||
#ifdef CONFIG_DEBUG_LCD
|
||||
static void ssd1289_showrun(FAR struct ssd1289_dev_s *priv, fb_coord_t row,
|
||||
fb_coord_t col, size_t npixels, bool put)
|
||||
{
|
||||
fb_coord_t nextrow = priv->lastrow + 1;
|
||||
|
||||
/* Has anything changed (other than the row is the next row in the sequence)? */
|
||||
|
||||
if (put == priv->put && row == nextrow && col == priv->col &&
|
||||
npixels == priv->npixels)
|
||||
{
|
||||
/* No, just update the last row */
|
||||
|
||||
priv->lastrow = nextrow;
|
||||
}
|
||||
else
|
||||
{
|
||||
/* Yes... then this is the end of the preceding sequence. Output the last run
|
||||
* (if there were more than one run in the sequence).
|
||||
*/
|
||||
|
||||
if (priv->firstrow != priv->lastrow)
|
||||
{
|
||||
lcddbg("...\n");
|
||||
lcddbg("%s row: %d col: %d npixels: %d\n",
|
||||
priv->put ? "PUT" : "GET",
|
||||
priv->lastrow, priv->col, priv->npixels);
|
||||
}
|
||||
|
||||
/* And we are starting a new sequence. Output the first run of the
|
||||
* new sequence
|
||||
*/
|
||||
|
||||
lcddbg("%s row: %d col: %d npixels: %d\n",
|
||||
put ? "PUT" : "GET", row, col, npixels);
|
||||
|
||||
/* And save information about the run so that we can detect continuations
|
||||
* of the sequence.
|
||||
*/
|
||||
|
||||
priv->put = put;
|
||||
priv->firstrow = row;
|
||||
priv->lastrow = row;
|
||||
priv->col = col;
|
||||
priv->npixels = npixels;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
/**************************************************************************************
|
||||
* Name: ssd1289_putrun
|
||||
*
|
||||
@@ -512,7 +593,7 @@ static int ssd1289_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buf
|
||||
|
||||
/* Buffer must be provided and aligned to a 16-bit address boundary */
|
||||
|
||||
lcdvdbg("row: %d col: %d npixels: %d\n", row, col, npixels);
|
||||
ssd1289_showrun(priv, row, col, npixels, true);
|
||||
DEBUGASSERT(buffer && ((uintptr_t)buffer & 1) == 0);
|
||||
|
||||
/* Select the LCD */
|
||||
@@ -536,7 +617,7 @@ static int ssd1289_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buf
|
||||
ssd1289_gramselect(lcd);
|
||||
ssd1289_gramwrite(lcd, *src);
|
||||
|
||||
/* Increment to next column */
|
||||
/* Increment to the next column */
|
||||
|
||||
src++;
|
||||
col++;
|
||||
@@ -581,7 +662,7 @@ static int ssd1289_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buf
|
||||
ssd1289_gramselect(lcd);
|
||||
ssd1289_gramwrite(lcd, *src);
|
||||
|
||||
/* Increment to next column */
|
||||
/* Increment to the next column */
|
||||
|
||||
src++;
|
||||
col--;
|
||||
@@ -604,7 +685,7 @@ static int ssd1289_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buf
|
||||
ssd1289_gramselect(lcd);
|
||||
ssd1289_gramwrite(lcd, *src);
|
||||
|
||||
/* Decrement to next column */
|
||||
/* Decrement to the next column */
|
||||
|
||||
src++;
|
||||
col++;
|
||||
@@ -632,7 +713,7 @@ static int ssd1289_putrun(fb_coord_t row, fb_coord_t col, FAR const uint8_t *buf
|
||||
**************************************************************************************/
|
||||
|
||||
static int ssd1289_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
|
||||
size_t npixels)
|
||||
size_t npixels)
|
||||
{
|
||||
#ifndef CONFIG_LCD_NOGETRUN
|
||||
FAR struct ssd1289_dev_s *priv = &g_lcddev;
|
||||
@@ -643,7 +724,7 @@ static int ssd1289_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
|
||||
|
||||
/* Buffer must be provided and aligned to a 16-bit address boundary */
|
||||
|
||||
lcdvdbg("row: %d col: %d npixels: %d\n", row, col, npixels);
|
||||
ssd1289_showrun(priv, row, col, npixels, false);
|
||||
DEBUGASSERT(buffer && ((uintptr_t)buffer & 1) == 0);
|
||||
|
||||
/* Select the LCD */
|
||||
@@ -666,7 +747,7 @@ static int ssd1289_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
|
||||
ssd1289_readsetup(lcd, &accum);
|
||||
*dest++ = ssd1289_gramread(lcd, &accum);
|
||||
|
||||
/* Increment to next column */
|
||||
/* Increment to the next column */
|
||||
|
||||
col++;
|
||||
}
|
||||
@@ -715,7 +796,7 @@ static int ssd1289_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
|
||||
ssd1289_readsetup(lcd, &accum);
|
||||
*dest++ = ssd1289_gramread(lcd, &accum);
|
||||
|
||||
/* Increment to next column */
|
||||
/* Increment to the next column */
|
||||
|
||||
col--;
|
||||
}
|
||||
@@ -738,7 +819,7 @@ static int ssd1289_getrun(fb_coord_t row, fb_coord_t col, FAR uint8_t *buffer,
|
||||
ssd1289_readsetup(lcd, &accum);
|
||||
*dest++ = ssd1289_gramread(lcd, &accum);
|
||||
|
||||
/* Decrement to next column */
|
||||
/* Decrement to the next column */
|
||||
|
||||
col++;
|
||||
}
|
||||
@@ -931,9 +1012,27 @@ static inline int ssd1289_hwinitialize(FAR struct ssd1289_dev_s *priv)
|
||||
|
||||
lcd->select(lcd);
|
||||
|
||||
/* Read the device ID. Skip verification of the device ID is the LCD is
|
||||
* write-only. What choice do we have?
|
||||
*/
|
||||
|
||||
#ifndef CONFIG_LCD_NOGETRUN
|
||||
id = ssd1289_readreg(lcd, SSD1289_DEVCODE);
|
||||
lcddbg("LCD ID: %04x\n", id);
|
||||
if (id != 0)
|
||||
{
|
||||
lcddbg("LCD ID: %04x\n", id);
|
||||
}
|
||||
|
||||
/* If we could not get the ID, then let's just assume that this is an SSD1289.
|
||||
* Perhaps we have some early register access issues. This seems to happen.
|
||||
* But then perhaps we should not even bother to read the device ID at all?
|
||||
*/
|
||||
|
||||
else
|
||||
{
|
||||
lcddbg("No LCD ID, assuming SSD1289\n");
|
||||
id = SSD1289_DEVCODE_VALUE;
|
||||
}
|
||||
|
||||
/* Check if the ID is for the SSD1289 */
|
||||
|
||||
|
||||
+115
-103
@@ -98,7 +98,7 @@
|
||||
#define RAMTRON_WRITE 0x02 /* 1 Write A 0 1-256 */
|
||||
#define RAMTRON_SLEEP 0xb9 // TODO:
|
||||
#define RAMTRON_RDID 0x9f /* 1 Read Identification 0 0 1-3 */
|
||||
#define RAMTRON_SN 0xc3 // TODO:
|
||||
#define RAMTRON_SN 0xc3 // TODO:
|
||||
|
||||
|
||||
/* Status register bit definitions */
|
||||
@@ -125,12 +125,12 @@
|
||||
|
||||
struct ramtron_parts_s
|
||||
{
|
||||
const char *name;
|
||||
uint8_t id1;
|
||||
uint8_t id2;
|
||||
uint32_t size;
|
||||
uint8_t addr_len;
|
||||
uint32_t speed;
|
||||
const char *name;
|
||||
uint8_t id1;
|
||||
uint8_t id2;
|
||||
uint32_t size;
|
||||
uint8_t addr_len;
|
||||
uint32_t speed;
|
||||
};
|
||||
|
||||
/* This type represents the state of the MTD device. The struct mtd_dev_s
|
||||
@@ -146,84 +146,86 @@ struct ramtron_dev_s
|
||||
uint8_t pageshift;
|
||||
uint16_t nsectors;
|
||||
uint32_t npages;
|
||||
const struct ramtron_parts_s *part; /* part instance */
|
||||
const struct ramtron_parts_s *part; /* part instance */
|
||||
};
|
||||
|
||||
/************************************************************************************
|
||||
* Supported Part Lists
|
||||
************************************************************************************/
|
||||
|
||||
// Defines the initial speed compatible with all devices. In case of RAMTRON
|
||||
// the defined devices within the part list have all the same speed.
|
||||
#define RAMTRON_INIT_CLK_MAX 40000000UL
|
||||
/* Defines the initial speed compatible with all devices. In case of RAMTRON
|
||||
* the defined devices within the part list have all the same speed.
|
||||
*/
|
||||
|
||||
#define RAMTRON_INIT_CLK_MAX 40000000UL
|
||||
|
||||
static struct ramtron_parts_s ramtron_parts[] =
|
||||
{
|
||||
{
|
||||
"FM25V02", /* name */
|
||||
0x22, /* id1 */
|
||||
0x00, /* id2 */
|
||||
32L*1024L, /* size */
|
||||
2, /* addr_len */
|
||||
40000000 /* speed */
|
||||
},
|
||||
{
|
||||
"FM25VN02", /* name */
|
||||
0x22, /* id1 */
|
||||
0x01, /* id2 */
|
||||
32L*1024L, /* size */
|
||||
2, /* addr_len */
|
||||
40000000 /* speed */
|
||||
},
|
||||
{
|
||||
"FM25V05", /* name */
|
||||
0x23, /* id1 */
|
||||
0x00, /* id2 */
|
||||
64L*1024L, /* size */
|
||||
2, /* addr_len */
|
||||
40000000 /* speed */
|
||||
},
|
||||
{
|
||||
"FM25VN05", /* name */
|
||||
0x23, /* id1 */
|
||||
0x01, /* id2 */
|
||||
64L*1024L, /* size */
|
||||
2, /* addr_len */
|
||||
40000000 /* speed */
|
||||
},
|
||||
{
|
||||
"FM25V10", /* name */
|
||||
0x24, /* id1 */
|
||||
0x00, /* id2 */
|
||||
128L*1024L, /* size */
|
||||
3, /* addr_len */
|
||||
40000000 /* speed */
|
||||
},
|
||||
{
|
||||
"FM25VN10", /* name */
|
||||
0x24, /* id1 */
|
||||
0x01, /* id2 */
|
||||
128L*1024L, /* size */
|
||||
3, /* addr_len */
|
||||
40000000 /* speed */
|
||||
},
|
||||
{
|
||||
"FM25V02", /* name */
|
||||
0x22, /* id1 */
|
||||
0x00, /* id2 */
|
||||
32L*1024L, /* size */
|
||||
2, /* addr_len */
|
||||
40000000 /* speed */
|
||||
},
|
||||
{
|
||||
"FM25VN02", /* name */
|
||||
0x22, /* id1 */
|
||||
0x01, /* id2 */
|
||||
32L*1024L, /* size */
|
||||
2, /* addr_len */
|
||||
40000000 /* speed */
|
||||
},
|
||||
{
|
||||
"FM25V05", /* name */
|
||||
0x23, /* id1 */
|
||||
0x00, /* id2 */
|
||||
64L*1024L, /* size */
|
||||
2, /* addr_len */
|
||||
40000000 /* speed */
|
||||
},
|
||||
{
|
||||
"FM25VN05", /* name */
|
||||
0x23, /* id1 */
|
||||
0x01, /* id2 */
|
||||
64L*1024L, /* size */
|
||||
2, /* addr_len */
|
||||
40000000 /* speed */
|
||||
},
|
||||
{
|
||||
"FM25V10", /* name */
|
||||
0x24, /* id1 */
|
||||
0x00, /* id2 */
|
||||
128L*1024L, /* size */
|
||||
3, /* addr_len */
|
||||
40000000 /* speed */
|
||||
},
|
||||
{
|
||||
"FM25VN10", /* name */
|
||||
0x24, /* id1 */
|
||||
0x01, /* id2 */
|
||||
128L*1024L, /* size */
|
||||
3, /* addr_len */
|
||||
40000000 /* speed */
|
||||
},
|
||||
#ifdef CONFIG_RAMTRON_FRAM_NON_JEDEC
|
||||
{
|
||||
"FM25H20", /* name */
|
||||
0xff, /* id1 */
|
||||
0xff, /* id2 */
|
||||
256L*1024L, /* size */
|
||||
3, /* addr_len */
|
||||
40000000 /* speed */
|
||||
},
|
||||
{
|
||||
NULL, /* name */
|
||||
0, /* id1 */
|
||||
0, /* id2 */
|
||||
0, /* size */
|
||||
0, /* addr_len */
|
||||
0 /* speed */
|
||||
}
|
||||
{
|
||||
"FM25H20", /* name */
|
||||
0xff, /* id1 */
|
||||
0xff, /* id2 */
|
||||
256L*1024L, /* size */
|
||||
3, /* addr_len */
|
||||
40000000 /* speed */
|
||||
},
|
||||
{
|
||||
NULL, /* name */
|
||||
0, /* id1 */
|
||||
0, /* id2 */
|
||||
0, /* size */
|
||||
0, /* addr_len */
|
||||
0 /* speed */
|
||||
}
|
||||
#endif
|
||||
};
|
||||
|
||||
@@ -240,17 +242,17 @@ static inline int ramtron_readid(struct ramtron_dev_s *priv);
|
||||
static void ramtron_waitwritecomplete(struct ramtron_dev_s *priv);
|
||||
static void ramtron_writeenable(struct ramtron_dev_s *priv);
|
||||
static inline void ramtron_pagewrite(struct ramtron_dev_s *priv, FAR const uint8_t *buffer,
|
||||
off_t offset);
|
||||
off_t offset);
|
||||
|
||||
/* MTD driver methods */
|
||||
|
||||
static int ramtron_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks);
|
||||
static ssize_t ramtron_bread(FAR struct mtd_dev_s *dev, off_t startblock,
|
||||
size_t nblocks, FAR uint8_t *buf);
|
||||
size_t nblocks, FAR uint8_t *buf);
|
||||
static ssize_t ramtron_bwrite(FAR struct mtd_dev_s *dev, off_t startblock,
|
||||
size_t nblocks, FAR const uint8_t *buf);
|
||||
size_t nblocks, FAR const uint8_t *buf);
|
||||
static ssize_t ramtron_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,
|
||||
FAR uint8_t *buffer);
|
||||
FAR uint8_t *buffer);
|
||||
static int ramtron_ioctl(FAR struct mtd_dev_s *dev, int cmd, unsigned long arg);
|
||||
|
||||
/************************************************************************************
|
||||
@@ -317,31 +319,37 @@ static inline int ramtron_readid(struct ramtron_dev_s *priv)
|
||||
/* Send the "Read ID (RDID)" command and read the first three ID bytes */
|
||||
|
||||
(void)SPI_SEND(priv->dev, RAMTRON_RDID);
|
||||
for (i=0; i<6; i++) manufacturer = SPI_SEND(priv->dev, RAMTRON_DUMMY);
|
||||
memory = SPI_SEND(priv->dev, RAMTRON_DUMMY);
|
||||
capacity = SPI_SEND(priv->dev, RAMTRON_DUMMY); // fram.id1
|
||||
part = SPI_SEND(priv->dev, RAMTRON_DUMMY); // fram.id2
|
||||
for (i = 0; i < 6; i++)
|
||||
{
|
||||
manufacturer = SPI_SEND(priv->dev, RAMTRON_DUMMY);
|
||||
}
|
||||
|
||||
memory = SPI_SEND(priv->dev, RAMTRON_DUMMY);
|
||||
capacity = SPI_SEND(priv->dev, RAMTRON_DUMMY); // fram.id1
|
||||
part = SPI_SEND(priv->dev, RAMTRON_DUMMY); // fram.id2
|
||||
|
||||
/* Deselect the FLASH and unlock the bus */
|
||||
|
||||
SPI_SELECT(priv->dev, SPIDEV_FLASH, false);
|
||||
ramtron_unlock(priv->dev);
|
||||
|
||||
// Select part from the part list
|
||||
/* Select part from the part list */
|
||||
|
||||
for (priv->part = ramtron_parts;
|
||||
priv->part->name != NULL && !(priv->part->id1 == capacity && priv->part->id2 == part);
|
||||
priv->part++);
|
||||
|
||||
if (priv->part->name) {
|
||||
fvdbg("RAMTRON %s of size %d bytes (mf:%02x mem:%02x cap:%02x part:%02x)\n",
|
||||
priv->part->name, priv->part->size, manufacturer, memory, capacity, part);
|
||||
priv->part->name != NULL && !(priv->part->id1 == capacity && priv->part->id2 == part);
|
||||
priv->part++);
|
||||
|
||||
if (priv->part->name)
|
||||
{
|
||||
fvdbg("RAMTRON %s of size %d bytes (mf:%02x mem:%02x cap:%02x part:%02x)\n",
|
||||
priv->part->name, priv->part->size, manufacturer, memory, capacity, part);
|
||||
|
||||
priv->sectorshift = RAMTRON_EMULATE_SECTOR_SHIFT;
|
||||
priv->nsectors = priv->part->size / (1 << RAMTRON_EMULATE_SECTOR_SHIFT);
|
||||
priv->pageshift = RAMTRON_EMULATE_PAGE_SHIFT;
|
||||
priv->npages = priv->part->size / (1 << RAMTRON_EMULATE_PAGE_SHIFT);
|
||||
return OK;
|
||||
}
|
||||
priv->sectorshift = RAMTRON_EMULATE_SECTOR_SHIFT;
|
||||
priv->nsectors = priv->part->size / (1 << RAMTRON_EMULATE_SECTOR_SHIFT);
|
||||
priv->pageshift = RAMTRON_EMULATE_PAGE_SHIFT;
|
||||
priv->npages = priv->part->size / (1 << RAMTRON_EMULATE_PAGE_SHIFT);
|
||||
return OK;
|
||||
}
|
||||
|
||||
fvdbg("RAMTRON device not found\n");
|
||||
return -ENODEV;
|
||||
@@ -408,8 +416,10 @@ static inline void ramtron_sendaddr(const struct ramtron_dev_s *priv, uint32_t a
|
||||
DEBUGASSERT(priv->part->addr_len == 3 || priv->part->addr_len == 2);
|
||||
|
||||
if (priv->part->addr_len == 3)
|
||||
(void)SPI_SEND(priv->dev, (addr >> 16) & 0xff);
|
||||
|
||||
{
|
||||
(void)SPI_SEND(priv->dev, (addr >> 16) & 0xff);
|
||||
}
|
||||
|
||||
(void)SPI_SEND(priv->dev, (addr >> 8) & 0xff);
|
||||
(void)SPI_SEND(priv->dev, addr & 0xff);
|
||||
}
|
||||
@@ -419,7 +429,7 @@ static inline void ramtron_sendaddr(const struct ramtron_dev_s *priv, uint32_t a
|
||||
************************************************************************************/
|
||||
|
||||
static inline void ramtron_pagewrite(struct ramtron_dev_s *priv, FAR const uint8_t *buffer,
|
||||
off_t page)
|
||||
off_t page)
|
||||
{
|
||||
off_t offset = page << priv->pageshift;
|
||||
|
||||
@@ -475,7 +485,7 @@ static int ramtron_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nbl
|
||||
************************************************************************************/
|
||||
|
||||
static ssize_t ramtron_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks,
|
||||
FAR uint8_t *buffer)
|
||||
FAR uint8_t *buffer)
|
||||
{
|
||||
FAR struct ramtron_dev_s *priv = (FAR struct ramtron_dev_s *)dev;
|
||||
ssize_t nbytes;
|
||||
@@ -489,6 +499,7 @@ static ssize_t ramtron_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t
|
||||
{
|
||||
return nbytes >> priv->pageshift;
|
||||
}
|
||||
|
||||
return (int)nbytes;
|
||||
}
|
||||
|
||||
@@ -497,7 +508,7 @@ static ssize_t ramtron_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t
|
||||
************************************************************************************/
|
||||
|
||||
static ssize_t ramtron_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks,
|
||||
FAR const uint8_t *buffer)
|
||||
FAR const uint8_t *buffer)
|
||||
{
|
||||
FAR struct ramtron_dev_s *priv = (FAR struct ramtron_dev_s *)dev;
|
||||
size_t blocksleft = nblocks;
|
||||
@@ -512,8 +523,8 @@ static ssize_t ramtron_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_
|
||||
ramtron_pagewrite(priv, buffer, startblock);
|
||||
startblock++;
|
||||
}
|
||||
ramtron_unlock(priv->dev);
|
||||
|
||||
ramtron_unlock(priv->dev);
|
||||
return nblocks;
|
||||
}
|
||||
|
||||
@@ -522,7 +533,7 @@ static ssize_t ramtron_bwrite(FAR struct mtd_dev_s *dev, off_t startblock, size_
|
||||
************************************************************************************/
|
||||
|
||||
static ssize_t ramtron_read(FAR struct mtd_dev_s *dev, off_t offset, size_t nbytes,
|
||||
FAR uint8_t *buffer)
|
||||
FAR uint8_t *buffer)
|
||||
{
|
||||
FAR struct ramtron_dev_s *priv = (FAR struct ramtron_dev_s *)dev;
|
||||
|
||||
@@ -662,6 +673,7 @@ FAR struct mtd_dev_s *ramtron_initialize(FAR struct spi_dev_s *dev)
|
||||
if (ramtron_readid(priv) != OK)
|
||||
{
|
||||
/* Unrecognized! Discard all of that work we just did and return NULL */
|
||||
|
||||
kfree(priv);
|
||||
priv = NULL;
|
||||
}
|
||||
|
||||
+6
-15
@@ -693,7 +693,7 @@ static void w25_pagewrite(struct w25_dev_s *priv, FAR const uint8_t *buffer,
|
||||
uint8_t status;
|
||||
|
||||
fvdbg("address: %08lx nwords: %d\n", (long)address, (int)nbytes);
|
||||
DEBUGASSERT(priv && buffer && ((uintptr_t)buffer & 0xff) == 0 &&
|
||||
DEBUGASSERT(priv && buffer && (address & 0xff) == 0 &&
|
||||
(nbytes & 0xff) == 0);
|
||||
|
||||
for (; nbytes > 0; nbytes -= W25_PAGE_SIZE)
|
||||
@@ -955,36 +955,27 @@ static int w25_erase(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks
|
||||
static ssize_t w25_bread(FAR struct mtd_dev_s *dev, off_t startblock, size_t nblocks,
|
||||
FAR uint8_t *buffer)
|
||||
{
|
||||
#ifdef CONFIG_W25_SECTOR512
|
||||
ssize_t nbytes;
|
||||
|
||||
fvdbg("startblock: %08lx nblocks: %d\n", (long)startblock, (int)nblocks);
|
||||
|
||||
/* On this device, we can handle the block read just like the byte-oriented read */
|
||||
|
||||
#ifdef CONFIG_W25_SECTOR512
|
||||
nbytes = w25_read(dev, startblock << W25_SECTOR512_SHIFT, nblocks << W25_SECTOR512_SHIFT, buffer);
|
||||
if (nbytes > 0)
|
||||
{
|
||||
return nbytes >> W25_SECTOR512_SHIFT;
|
||||
nbytes >>= W25_SECTOR512_SHIFT;
|
||||
}
|
||||
|
||||
return (int)nbytes;
|
||||
#else
|
||||
FAR struct w25_dev_s *priv = (FAR struct w25_dev_s *)dev;
|
||||
ssize_t nbytes;
|
||||
|
||||
fvdbg("startblock: %08lx nblocks: %d\n", (long)startblock, (int)nblocks);
|
||||
|
||||
/* On this device, we can handle the block read just like the byte-oriented read */
|
||||
|
||||
nbytes = w25_read(dev, startblock << W25_SECTOR_SHIFT, nblocks << W25_SECTOR_SHIFT, buffer);
|
||||
if (nbytes > 0)
|
||||
{
|
||||
return nbytes >> W25_SECTOR_SHIFT;
|
||||
nbytes >>= W25_SECTOR_SHIFT;
|
||||
}
|
||||
|
||||
return (int)nbytes;
|
||||
#endif
|
||||
|
||||
return nbytes;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
|
||||
Reference in New Issue
Block a user