summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2015-04-04 10:02:31 -0600
committerGregory Nutt <gnutt@nuttx.org>2015-04-04 10:02:31 -0600
commit0d7c6b589c7b82fb1b47d715c7ea2f98cca75e15 (patch)
tree6619ea32a69a0da9499063395c462e5c141aaa93
parent7aee7140e76304e219976003bb1868da5904f330 (diff)
downloadpx4-nuttx-0d7c6b589c7b82fb1b47d715c7ea2f98cca75e15.tar.gz
px4-nuttx-0d7c6b589c7b82fb1b47d715c7ea2f98cca75e15.tar.bz2
px4-nuttx-0d7c6b589c7b82fb1b47d715c7ea2f98cca75e15.zip
ILI9488: Correct logic that gets the LCD ID
-rw-r--r--nuttx/configs/samv71-xult/src/sam_ili9488.c49
1 files changed, 44 insertions, 5 deletions
diff --git a/nuttx/configs/samv71-xult/src/sam_ili9488.c b/nuttx/configs/samv71-xult/src/sam_ili9488.c
index cc60a4d9b..68d8d394a 100644
--- a/nuttx/configs/samv71-xult/src/sam_ili9488.c
+++ b/nuttx/configs/samv71-xult/src/sam_ili9488.c
@@ -352,7 +352,7 @@ struct sam_dev_s
volatile int result; /* Result of the DMA transfer */
sem_t waitsem; /* Used to way for DMA completion */
volatile bool dmabusy; /* True: DMA is in progress */
- volatile bool cmd; /* True: Command transefer */
+ volatile bool cmd; /* True: Command transfer */
/* Private LCD-specific information follows */
@@ -374,6 +374,8 @@ static int sam_lcd_put(FAR struct sam_dev_s *priv, uint16_t cmd,
FAR const uint16_t *buffer, unsigned int buflen);
static int sam_lcd_get(FAR struct sam_dev_s *priv, uint8_t cmd,
FAR uint16_t *buffer, unsigned int buflen);
+static int sam_lcd_getreg(FAR struct sam_dev_s *priv, uint8_t cmd,
+ FAR uint8_t *buffer, unsigned int nbytes);
static int sam_setwindow(FAR struct sam_dev_s *priv, sam_color_t row,
sam_color_t col, sam_color_t width, sam_color_t height);
@@ -540,7 +542,7 @@ static int sam_sendcmd(FAR struct sam_dev_s *priv, uint16_t cmd)
sam_gpiowrite(GPIO_ILI9488_CDS, false);
- /* Send the command */
+ /* Send the command via TX DMA */
ret = sam_lcd_txtransfer(priv, &cmd, sizeof(uint16_t));
if (ret < 0)
@@ -600,7 +602,7 @@ static int sam_lcd_put(FAR struct sam_dev_s *priv, uint16_t cmd,
* Name: sam_lcd_get
*
* Description:
- * Read from a multi-byte ILI9488 register
+ * Send a command and read 16-bit data from the ILI9488
*
****************************************************************************/
@@ -624,6 +626,39 @@ static int sam_lcd_get(FAR struct sam_dev_s *priv, uint8_t cmd,
}
/****************************************************************************
+ * Name: sam_lcd_getreg
+ *
+ * Description:
+ * Read from a multi-byte ILI9488 register
+ *
+ ****************************************************************************/
+
+static int sam_lcd_getreg(FAR struct sam_dev_s *priv, uint8_t cmd,
+ FAR uint8_t *buffer, unsigned int nbytes)
+{
+ uint32_t tmp[4];
+ int ret;
+ int i;
+
+ DEBUGASSERT(nbytes <= 4);
+
+ /* Read the request number of byes (as 16-bit values) plus a leading
+ * dummy read.
+ */
+
+ ret = sam_lcd_get(priv, cmd, (FAR uint16_t *)tmp, nbytes << 2);
+ if (ret == OK)
+ {
+ for (i = 0; i < nbytes; i++)
+ {
+ buffer[i] = tmp[i] & 0xff;
+ }
+ }
+
+ return ret;
+}
+
+/****************************************************************************
* Name: sam_setwindow
*
* Description:
@@ -1435,15 +1470,19 @@ static inline int sam_lcd_initialize(void)
/* Check the LCD ID */
- ret = sam_lcd_get(priv, ILI9488_CMD_READ_ID4, (FAR uint16_t *)buffer, 4);
+ ret = sam_lcd_getreg(priv, ILI9488_CMD_READ_ID4, buffer, 4);
if (ret < 0)
{
return ret;
}
- id = ((uint16_t)buffer[2] << 8) | (uint16_t)buffer[3];
+ id = ((uint16_t)buffer[2] << 8) | ((uint16_t)buffer[3] & 0xff);
+ lcdvdbg("ID: %04x\n", id);
+
if (id != ILI9488_DEVICE_CODE)
{
+ lcddbg("ERROR: Unsupported LCD ID: %04x (vs. %04x)\n",
+ id, ILI9488_DEVICE_CODE);
return -ENODEV;
}