summaryrefslogtreecommitdiff
path: root/apps/system/i2c/i2ctool.h
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-08-30 15:07:21 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2011-08-30 15:07:21 +0000
commit6da7839685a296ef4324847306de9be7b0e6722b (patch)
tree9f94cee3c1c7c9f9af0bde818facefddbe3df440 /apps/system/i2c/i2ctool.h
parent226c8f246cfc548246c021393aab56b0a8be7968 (diff)
downloadnuttx-6da7839685a296ef4324847306de9be7b0e6722b.tar.gz
nuttx-6da7839685a296ef4324847306de9be7b0e6722b.tar.bz2
nuttx-6da7839685a296ef4324847306de9be7b0e6722b.zip
First cut at I2C tool
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@3927 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'apps/system/i2c/i2ctool.h')
-rw-r--r--apps/system/i2c/i2ctool.h57
1 files changed, 36 insertions, 21 deletions
diff --git a/apps/system/i2c/i2ctool.h b/apps/system/i2c/i2ctool.h
index dde1b7a13..962600f43 100644
--- a/apps/system/i2c/i2ctool.h
+++ b/apps/system/i2c/i2ctool.h
@@ -53,6 +53,19 @@
* Definitions
****************************************************************************/
/* Configuration ************************************************************/
+/* CONFIG_I2CTOOL_BUILTIN - Build the tools as an NSH built-in command
+ * CONFIG_I2CTOOL_MINBUS - Smallest bus index supported by the hardware (default 0).
+ * CONFIG_I2CTOOL_MAXBUS - Largest bus index supported by the hardware (default 3)
+ * CONFIG_I2CTOOL_MINADDR - Minium device address (default: 0x03)
+ * CONFIG_I2CTOOL_MAXADDR - Largest device address (default: 0x77)
+ * CONFIG_I2CTOOL_MAXREGADDR - Largest register address (default: 0xff)
+ * CONFIG_I2CTOOL_DEFFREQ - Default frequency (default: 4000000)
+ */
+
+#ifndef CONFIG_I2C_TRANSFER
+# error "CONFIG_I2C_TRANSFER is required in the configuration"
+#endif
+
#ifndef CONFIG_I2CTOOL_MINBUS
# define CONFIG_I2CTOOL_MINBUS 0
#endif
@@ -73,6 +86,10 @@
# define CONFIG_I2CTOOL_MAXREGADDR 0xff
#endif
+#ifndef CONFIG_I2CTOOL_DEFFREQ
+# define CONFIG_I2CTOOL_DEFFREQ 400000
+#endif
+
/* This is the maximum number of arguments that will be accepted for a
* command
*/
@@ -117,11 +134,12 @@ struct i2ctool_s
{
/* Sticky options */
- uint8_t addr; /* [-a addr] is the I2C device address */
- uint8_t bus; /* [-b bus] is the I2C bus number */
- uint8_t regaddr; /* [-r regaddr] is the I2C device register address */
- uint8_t width; /* [-w width] is the data width (8 or 16) */
- bool start; /* [-s|n], send/don't send start between command and data */
+ uint8_t addr; /* [-a addr] is the I2C device address */
+ uint8_t bus; /* [-b bus] is the I2C bus number */
+ uint8_t regaddr; /* [-r regaddr] is the I2C device register address */
+ uint8_t width; /* [-w width] is the data width (8 or 16) */
+ bool start; /* [-s|n], send/don't send start between command and data */
+ uint32_t freq; /* [-f freq] I2C frequency */
/* Output streams */
@@ -131,7 +149,7 @@ struct i2ctool_s
#endif
};
-typedef int (*cmd_t)(FAR struct i2ctool_s *i2ctool, int argc, char **argv);
+typedef int (*cmd_t)(FAR struct i2ctool_s *i2ctool, int argc, FAR char **argv);
struct cmdmap_s
{
@@ -145,16 +163,13 @@ struct cmdmap_s
* Public Data
****************************************************************************/
-extern const char g_syntax[];
-extern const char g_fmtargrequired[];
-extern const char g_fmtarginvalid[];
-extern const char g_fmtargrange[];
-extern const char g_fmtcmdnotfound[];
-extern const char g_fmtnosuch[];
-extern const char g_fmttoomanyargs[];
-extern const char g_fmtcmdfailed[];
-extern const char g_fmtcmdoutofmemory[];
-extern const char g_fmtinternalerror[];
+extern const char g_i2cargrequired[];
+extern const char g_i2carginvalid[];
+extern const char g_i2cargrange[];
+extern const char g_i2ccmdnotfound[];
+extern const char g_i2ctoomanyargs[];
+extern const char g_i2ccmdfailed[];
+extern const char g_i2cxfrerror[];
/****************************************************************************
* Public Function Prototypes
@@ -167,11 +182,11 @@ int i2ctool_printf(FAR struct i2ctool_s *i2ctool, const char *fmt, ...);
/* Command handlers */
-int cmd_bus(FAR struct i2ctool_s *i2ctool, int argc, char **argv);
-int cmd_dev(FAR struct i2ctool_s *i2ctool, int argc, char **argv);
-int cmd_dump(FAR struct i2ctool_s *i2ctool, int argc, char **argv);
-int cmd_get(FAR struct i2ctool_s *i2ctool, int argc, char **argv);
-int cmd_set(FAR struct i2ctool_s *i2ctool, int argc, char **argv);
+int cmd_bus(FAR struct i2ctool_s *i2ctool, int argc, FAR char **argv);
+int cmd_dev(FAR struct i2ctool_s *i2ctool, int argc, FAR char **argv);
+int cmd_dump(FAR struct i2ctool_s *i2ctool, int argc, FAR char **argv);
+int cmd_get(FAR struct i2ctool_s *i2ctool, int argc, FAR char **argv);
+int cmd_set(FAR struct i2ctool_s *i2ctool, int argc, FAR char **argv);
/* Common logic */