summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorGregory Nutt <gnutt@nuttx.org>2014-07-06 08:03:34 -0600
committerGregory Nutt <gnutt@nuttx.org>2014-07-06 08:03:34 -0600
commitc3070812dbaca9e6368097eae94f406a5a19f21f (patch)
treeeaa09d0b3a2b6a6d4bcc087fd4c43b3a96176460
parentfafdc7ed6cf36f6bd50b9ad087458fd49e047ec0 (diff)
downloadpx4-nuttx-c3070812dbaca9e6368097eae94f406a5a19f21f.tar.gz
px4-nuttx-c3070812dbaca9e6368097eae94f406a5a19f21f.tar.bz2
px4-nuttx-c3070812dbaca9e6368097eae94f406a5a19f21f.zip
maXTouch: Fix I2C address, errors when debug enable, reorganize some data
-rw-r--r--nuttx/configs/sama5d4-ek/src/sam_maxtouch.c11
-rw-r--r--nuttx/drivers/input/mxt.c23
-rw-r--r--nuttx/drivers/input/mxt.h21
-rw-r--r--nuttx/include/nuttx/input/mxt.h9
4 files changed, 30 insertions, 34 deletions
diff --git a/nuttx/configs/sama5d4-ek/src/sam_maxtouch.c b/nuttx/configs/sama5d4-ek/src/sam_maxtouch.c
index 7a8fb3965..b6a4f6030 100644
--- a/nuttx/configs/sama5d4-ek/src/sam_maxtouch.c
+++ b/nuttx/configs/sama5d4-ek/src/sam_maxtouch.c
@@ -70,9 +70,10 @@
# define CONFIG_SAMA5D4EK_MXT_DEVMINOR 0
#endif
-/* The touchscreen communicates on TWI0 */
+/* The touchscreen communicates on TWI0, I2C address 0x4c */
-#define MXT_BUSNUM 0
+#define MXT_TWI_BUS 0
+#define MXT_I2C_ADDRESS 0x4c
/****************************************************************************
* Private Types
@@ -128,7 +129,7 @@ static struct sama5d4ek_tscinfo_s g_mxtinfo =
{
.lower =
{
- .address = (0x4c >> 1),
+ .address = MXT_I2C_ADDRESS,
.frequency = CONFIG_SAMA5D4EK_MXT_I2CFREQUENCY,
.attach = mxt_attach,
@@ -259,10 +260,10 @@ int arch_tcinitialize(int minor)
/* Get an instance of the I2C interface for the touchscreen chip select */
- i2c = up_i2cinitialize(MXT_BUSNUM);
+ i2c = up_i2cinitialize(MXT_TWI_BUS);
if (!i2c)
{
- idbg("Failed to initialize I2C%d\n", MXT_BUSNUM);
+ idbg("Failed to initialize I2C%d\n", MXT_TWI_BUS);
return -ENODEV;
}
diff --git a/nuttx/drivers/input/mxt.c b/nuttx/drivers/input/mxt.c
index 05ab05bb0..46a3ab9a1 100644
--- a/nuttx/drivers/input/mxt.c
+++ b/nuttx/drivers/input/mxt.c
@@ -126,21 +126,6 @@ struct mxt_info_s
};
#define MXT_INFO_SIZE 7
-struct mxt_object_s
-{
- uint8_t type; /* Object type */
- uint8_t addr[2]; /* Start address */
- uint8_t size; /* Size of each instance - 1 */
- uint8_t ninstances; /* Number of instances - 1 */
- uint8_t nids; /* Number of report IDs */
-};
-
-struct mxt_msg_s
-{
- uint8_t id; /* Report ID */
- uint8_t body[7]; /* Message body */
-};
-
/* Describes the state of the MXT driver */
struct mxt_dev_s
@@ -814,7 +799,7 @@ static void mxt_worker(FAR void *arg)
uint32_t chksum;
int status;
- status = msg_body[0]
+ status = msg.body[0];
chksum = (uint32_t)msg.body[1] |
((uint32_t)msg.body[2] << 8) |
((uint32_t)msg.body[3] << 16);
@@ -845,8 +830,8 @@ static void mxt_worker(FAR void *arg)
else
{
ivdbg("Ignored: id=%u message={%02x %02x %02x %02x %02x %02x %02x}\n",
- msg->id, msg->body[0], msg->body[1], msg->body[2], msg->body[3],
- msg->body[4], msg->body[5], msg->body[6], msg->body[7]);
+ msg.id, msg.body[0], msg.body[1], msg.body[2], msg.body[3],
+ msg.body[4], msg.body[5], msg.body[6]);
}
}
while (id != 0xff);
@@ -1705,7 +1690,7 @@ int mxt_register(FAR struct i2c_dev_s *i2c,
ret = mxt_hwinitialize(priv);
if (ret < 0)
{
- idbg("ERROR: mxt_hwinitialize failed: %d\n", reg);
+ idbg("ERROR: mxt_hwinitialize failed: %d\n", ret);
goto errout_with_irq;
}
diff --git a/nuttx/drivers/input/mxt.h b/nuttx/drivers/input/mxt.h
index 48e469423..cfbcfd82e 100644
--- a/nuttx/drivers/input/mxt.h
+++ b/nuttx/drivers/input/mxt.h
@@ -70,8 +70,6 @@
# define MXT_OBJECT_NUM 0x06 /* Number of objects */
#define MXT_OBJECT_START 0x07
-#define MXT_OBJECT_SIZE 6
-
/* Object types */
#define MXT_DEBUG_DIAGNOSTIC_T37 37
@@ -255,6 +253,25 @@
/****************************************************************************
* Public Types
****************************************************************************/
+/* This structure describes one maXTouch object */
+
+struct mxt_object_s
+{
+ uint8_t type; /* Object type */
+ uint8_t addr[2]; /* Start address */
+ uint8_t size; /* Size of each instance - 1 */
+ uint8_t ninstances; /* Number of instances - 1 */
+ uint8_t nids; /* Number of report IDs */
+};
+#define MXT_OBJECT_SIZE 6
+
+/* This structure describes one maXTouch message */
+
+struct mxt_msg_s
+{
+ uint8_t id; /* Report ID */
+ uint8_t body[7]; /* Message body */
+};
/****************************************************************************
* Public Data
diff --git a/nuttx/include/nuttx/input/mxt.h b/nuttx/include/nuttx/input/mxt.h
index 5563758a2..855e1bd02 100644
--- a/nuttx/include/nuttx/input/mxt.h
+++ b/nuttx/include/nuttx/input/mxt.h
@@ -79,13 +79,6 @@
# error "Work queue support required. CONFIG_SCHED_WORKQUEUE must be selected."
#endif
-/* I2C addresses ************************************************************/
-
-#define MXT_APP_LOW 0x4a
-#define MXT_APP_HIGH 0x4b
-#define MXT_BOOT_LOW 0x24
-#define MXT_BOOT_HIGH 0x25
-
/* Helper macros ************************************************************/
#define MXT_ATTACH(s,isr,arg) ((s)->attach(s,isr,arg))
@@ -120,8 +113,8 @@ struct mxt_lower_s
{
/* Device characterization */
+ uint32_t frequency; /* Initial I2C frequency */
uint8_t address; /* 7-bit I2C address (only bits 0-6 used) */
- uint32_t frequency; /* I2C frequency */
/* True: Swap X and Y values */