diff --git a/ChangeLog b/ChangeLog index 7c4a4b0098..f541f393d5 100755 --- a/ChangeLog +++ b/ChangeLog @@ -12483,7 +12483,7 @@ to unregister a signal handler (2016-08-01). * configs/sim: Add simulator-based test support for apps/examples/gpio 2016-08-01). - * drivers/sensors: Add KXJT9 Accelerometer driver from the Motorola + * drivers/sensors: Add KXTJ9 Accelerometer driver from the Motorola Moto Z MDK (2016-08-02). * arch/arm/sim: Add a simulated I/O Expander driver (2016-08-03). * configs/sim: Add logic to set the simulated I/O expander for testing diff --git a/ReleaseNotes b/ReleaseNotes index e7d50a4053..f7dc36cdd4 100644 --- a/ReleaseNotes +++ b/ReleaseNotes @@ -11813,7 +11813,7 @@ Additional new features and extended functionality: * Sensor Drivers: - - Add KXJT9 Accelerometer driver from the Motorola Moto Z MDK. + - Add KXTJ9 Accelerometer driver from the Motorola Moto Z MDK. - Add MFRC522 RFID ISO14443 and Mifare transceiver driver. From Alan Carvalho de Assis. - Add driver for the LIS3MDL 3 axis magnetometer. From Alexander diff --git a/drivers/sensors/Make.defs b/drivers/sensors/Make.defs index 4a21504281..f99916d057 100644 --- a/drivers/sensors/Make.defs +++ b/drivers/sensors/Make.defs @@ -50,7 +50,7 @@ ifeq ($(CONFIG_AS5048B),y) endif ifeq ($(CONFIG_SENSOR_KXTJ9),y) - CSRCS += kxjt9.c + CSRCS += kxtj9.c endif ifeq ($(CONFIG_LIS3DSH),y) diff --git a/drivers/sensors/kxjt9.c b/drivers/sensors/kxtj9.c similarity index 88% rename from drivers/sensors/kxjt9.c rename to drivers/sensors/kxtj9.c index 36b23e2fa3..70ec5ec808 100644 --- a/drivers/sensors/kxjt9.c +++ b/drivers/sensors/kxtj9.c @@ -1,5 +1,5 @@ /**************************************************************************** - * drivers/sensors/kxjt9.c + * drivers/sensors/kxtj9.c * * Copyright (C) 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -50,7 +50,7 @@ #include #include #include -#include +#include #if defined(CONFIG_I2C) && defined(CONFIG_SENSOR_KXTJ9) @@ -123,7 +123,7 @@ /* This structure describes the state of one KXTJ9 device */ -struct kxjt9_dev_s +struct kxtj9_dev_s { FAR struct i2c_master_s *i2c; sem_t exclsem; @@ -142,29 +142,29 @@ struct kxjt9_dev_s /* I2C helpers */ -static int kxtj9_reg_read(FAR struct kxjt9_dev_s *priv, uint8_t regaddr, +static int kxtj9_reg_read(FAR struct kxtj9_dev_s *priv, uint8_t regaddr, FAR uint8_t *regval, unsigned int len); -static int kxtj9_reg_write(FAR struct kxjt9_dev_s *priv, +static int kxtj9_reg_write(FAR struct kxtj9_dev_s *priv, uint8_t regaddr, uint8_t regval); /* KXTJ9 helpers */ -static int kxtj9_configure(FAR struct kxjt9_dev_s *priv, uint8_t odr); -static int kxtj9_enable(FAR struct kxjt9_dev_s *priv, bool on); -static int kxtj9_read_sensor_data(FAR struct kxjt9_dev_s *priv, +static int kxtj9_configure(FAR struct kxtj9_dev_s *priv, uint8_t odr); +static int kxtj9_enable(FAR struct kxtj9_dev_s *priv, bool on); +static int kxtj9_read_sensor_data(FAR struct kxtj9_dev_s *priv, FAR struct kxtj9_sensor_data *sensor_data); -static void kxtj9_soft_reset(FAR struct kxjt9_dev_s *priv); -static void kxtj9_set_mode_standby(FAR struct kxjt9_dev_s *priv); +static void kxtj9_soft_reset(FAR struct kxtj9_dev_s *priv); +static void kxtj9_set_mode_standby(FAR struct kxtj9_dev_s *priv); /* Character driver methods */ -static int kxjt9_open(FAR struct file *filep); -static int kxjt9_close(FAR struct file *filep); -static ssize_t kxjt9_read(FAR struct file *filep, FAR char *buffer, +static int kxtj9_open(FAR struct file *filep); +static int kxtj9_close(FAR struct file *filep); +static ssize_t kxtj9_read(FAR struct file *filep, FAR char *buffer, size_t buflen); -static ssize_t kxjt9_write(FAR struct file *filep, FAR const char *buffer, +static ssize_t kxtj9_write(FAR struct file *filep, FAR const char *buffer, size_t buflen); -static int kxjt9_ioctl(FAR struct file *filep, int cmd, +static int kxtj9_ioctl(FAR struct file *filep, int cmd, unsigned long arg); /**************************************************************************** @@ -173,12 +173,12 @@ static int kxjt9_ioctl(FAR struct file *filep, int cmd, static const struct file_operations g_fops = { - kxjt9_open, - kxjt9_close, - kxjt9_read, - kxjt9_write, + kxtj9_open, + kxtj9_close, + kxtj9_read, + kxtj9_write, NULL, - kxjt9_ioctl, + kxtj9_ioctl, #ifndef CONFIG_DISABLE_POLL NULL, #endif @@ -199,7 +199,7 @@ static const struct file_operations g_fops = * ****************************************************************************/ -static int kxtj9_reg_read(FAR struct kxjt9_dev_s *priv, uint8_t regaddr, +static int kxtj9_reg_read(FAR struct kxtj9_dev_s *priv, uint8_t regaddr, FAR uint8_t *regval, unsigned int len) { struct i2c_msg_s msg[2]; @@ -246,7 +246,7 @@ static int kxtj9_reg_read(FAR struct kxjt9_dev_s *priv, uint8_t regaddr, * ****************************************************************************/ -static int kxtj9_reg_write(FAR struct kxjt9_dev_s *priv, uint8_t regaddr, +static int kxtj9_reg_write(FAR struct kxtj9_dev_s *priv, uint8_t regaddr, uint8_t regval) { struct i2c_msg_s msg; @@ -284,7 +284,7 @@ static int kxtj9_reg_write(FAR struct kxjt9_dev_s *priv, uint8_t regaddr, * ****************************************************************************/ -static void kxtj9_soft_reset(FAR struct kxjt9_dev_s *priv) +static void kxtj9_soft_reset(FAR struct kxtj9_dev_s *priv) { uint8_t wbuf[1]; @@ -313,7 +313,7 @@ static void kxtj9_soft_reset(FAR struct kxjt9_dev_s *priv) * ****************************************************************************/ -static void kxtj9_set_mode_standby(FAR struct kxjt9_dev_s *priv) +static void kxtj9_set_mode_standby(FAR struct kxtj9_dev_s *priv) { uint8_t wbuf[1]; @@ -336,7 +336,7 @@ static void kxtj9_set_mode_standby(FAR struct kxjt9_dev_s *priv) * ****************************************************************************/ -static int kxtj9_configure(FAR struct kxjt9_dev_s *priv, uint8_t odr) +static int kxtj9_configure(FAR struct kxtj9_dev_s *priv, uint8_t odr) { uint8_t wbuf[0]; int ret; @@ -389,7 +389,7 @@ static int kxtj9_configure(FAR struct kxjt9_dev_s *priv, uint8_t odr) * ****************************************************************************/ -static int kxtj9_enable(FAR struct kxjt9_dev_s *priv, bool on) +static int kxtj9_enable(FAR struct kxtj9_dev_s *priv, bool on) { uint8_t wbuf[1]; int ret; @@ -434,7 +434,7 @@ static int kxtj9_enable(FAR struct kxjt9_dev_s *priv, bool on) * ****************************************************************************/ -static int kxtj9_read_sensor_data(FAR struct kxjt9_dev_s *priv, +static int kxtj9_read_sensor_data(FAR struct kxtj9_dev_s *priv, FAR struct kxtj9_sensor_data *sensor_data) { int16_t acc_data[3]; @@ -463,44 +463,44 @@ static int kxtj9_read_sensor_data(FAR struct kxjt9_dev_s *priv, } /**************************************************************************** - * Name: kxjt9_open + * Name: kxtj9_open * * Description: * This method is called when the device is opened. * ****************************************************************************/ -static int kxjt9_open(FAR struct file *filep) +static int kxtj9_open(FAR struct file *filep) { return OK; } /**************************************************************************** - * Name: kxjt9_close + * Name: kxtj9_close * * Description: * This method is called when the device is closed. * ****************************************************************************/ -static int kxjt9_close(FAR struct file *filep) +static int kxtj9_close(FAR struct file *filep) { return OK; } /**************************************************************************** - * Name: kxjt9_read + * Name: kxtj9_read * * Description: * The standard read method. * ****************************************************************************/ -static ssize_t kxjt9_read(FAR struct file *filep, FAR char *buffer, +static ssize_t kxtj9_read(FAR struct file *filep, FAR char *buffer, size_t buflen) { FAR struct inode *inode; - FAR struct kxjt9_dev_s *priv; + FAR struct kxtj9_dev_s *priv; size_t nsamples; size_t i; int ret; @@ -523,7 +523,7 @@ static ssize_t kxjt9_read(FAR struct file *filep, FAR char *buffer, DEBUGASSERT(filep != NULL && filep->f_inode != NULL && buffer != NULL); inode = filep->f_inode; - priv = (FAR struct kxjt9_dev_s *)inode->i_private; + priv = (FAR struct kxtj9_dev_s *)inode->i_private; DEBUGASSERT(priv != NULL && priv->i2c != NULL); /* Return all of the samples that will fit in the user-provided buffer */ @@ -548,31 +548,31 @@ static ssize_t kxjt9_read(FAR struct file *filep, FAR char *buffer, } /**************************************************************************** - * Name: kxjt9_write + * Name: kxtj9_write * * Description: * A dummy write method. * ****************************************************************************/ -static ssize_t kxjt9_write(FAR struct file *filep, FAR const char *buffer, +static ssize_t kxtj9_write(FAR struct file *filep, FAR const char *buffer, size_t buflen) { return -ENOSYS; } /**************************************************************************** - * Name: kxjt9_ioctl + * Name: kxtj9_ioctl * * Description: * The standard ioctl method. * ****************************************************************************/ -static int kxjt9_ioctl(FAR struct file *filep, int cmd, unsigned long arg) +static int kxtj9_ioctl(FAR struct file *filep, int cmd, unsigned long arg) { FAR struct inode *inode; - FAR struct kxjt9_dev_s *priv; + FAR struct kxtj9_dev_s *priv; int ret; /* Sanity check */ @@ -580,7 +580,7 @@ static int kxjt9_ioctl(FAR struct file *filep, int cmd, unsigned long arg) DEBUGASSERT(filep != NULL && filep->f_inode != NULL); inode = filep->f_inode; - priv = (FAR struct kxjt9_dev_s *)inode->i_private; + priv = (FAR struct kxtj9_dev_s *)inode->i_private; DEBUGASSERT(priv != NULL && priv->i2c != NULL); /* Handle ioctl commands */ @@ -626,15 +626,15 @@ static int kxjt9_ioctl(FAR struct file *filep, int cmd, unsigned long arg) ****************************************************************************/ /**************************************************************************** - * Name: kxjt9_register + * Name: kxtj9_register * * Description: - * Register the KXJT9 accelerometer device as 'devpath'. + * Register the KXTJ9 accelerometer device as 'devpath'. * * Input Parameters: * devpath - The full path to the driver to register, e.g., "/dev/accel0". * i2c - An I2C driver instance. - * addr - The I2C address of the KXJT9 accelerometer, gyroscope or + * addr - The I2C address of the KXTJ9 accelerometer, gyroscope or * magnetometer. * * Returned Value: @@ -642,10 +642,10 @@ static int kxjt9_ioctl(FAR struct file *filep, int cmd, unsigned long arg) * ****************************************************************************/ -int kxjt9_register(FAR const char *devpath, FAR struct i2c_master_s *i2c, +int kxtj9_register(FAR const char *devpath, FAR struct i2c_master_s *i2c, uint8_t address) { - FAR struct kxjt9_dev_s *priv; + FAR struct kxtj9_dev_s *priv; int ret; /* Sanity check */ @@ -654,7 +654,7 @@ int kxjt9_register(FAR const char *devpath, FAR struct i2c_master_s *i2c, /* Initialize the device's structure */ - priv = (FAR struct kxjt9_dev_s *)kmm_zalloc(sizeof(struct kxjt9_dev_s)); + priv = (FAR struct kxtj9_dev_s *)kmm_zalloc(sizeof(struct kxtj9_dev_s)); if (priv == NULL) { snerr("ERROR: Failed to allocate driver instance\n"); diff --git a/include/nuttx/sensors/ioctl.h b/include/nuttx/sensors/ioctl.h index 036042a926..acbf31d810 100644 --- a/include/nuttx/sensors/ioctl.h +++ b/include/nuttx/sensors/ioctl.h @@ -57,7 +57,7 @@ #define SNIOC_OTLRM _SNIOC(0x0006) /* One Time L-Res Mode Arg: None */ #define SNIOC_CHMEATIME _SNIOC(0x0007) /* Change Meas. Time Arg: uint8_t */ -/* IOCTL commands unique to the KXJT9 */ +/* IOCTL commands unique to the KXTJ9 */ #define SNIOC_ENABLE _SNIOC(0x0008) /* Arg: None */ #define SNIOC_DISABLE _SNIOC(0x0009) /* Arg: None */ diff --git a/include/nuttx/sensors/kxjt9.h b/include/nuttx/sensors/kxtj9.h similarity index 91% rename from include/nuttx/sensors/kxjt9.h rename to include/nuttx/sensors/kxtj9.h index 9c4f234b11..4c3facaf73 100644 --- a/include/nuttx/sensors/kxjt9.h +++ b/include/nuttx/sensors/kxtj9.h @@ -1,5 +1,5 @@ /**************************************************************************** - * include/nuttx/sensors/kxjt9.h + * include/nuttx/sensors/kxtj9.h * * Copyright (C) 2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt @@ -35,8 +35,8 @@ * ****************************************************************************/ -#ifndef __INCLUDE_NUTTX_SENSORS_KXJT9_H -#define __INCLUDE_NUTTX_SENSORS_KXJT9_H +#ifndef __INCLUDE_NUTTX_SENSORS_KXTJ9_H +#define __INCLUDE_NUTTX_SENSORS_KXTJ9_H /**************************************************************************** * Included Files @@ -91,15 +91,15 @@ extern "C" #endif /**************************************************************************** - * Name: kxjt9_register + * Name: kxtj9_register * * Description: - * Register the KXJT9 accelerometer device as 'devpath'. + * Register the KXTJ9 accelerometer device as 'devpath'. * * Input Parameters: * devpath - The full path to the driver to register, e.g., "/dev/accel0". * i2c - An I2C driver instance. - * addr - The I2C address of the KXJT9 accelerometer, gyroscope or + * addr - The I2C address of the KXTJ9 accelerometer, gyroscope or * magnetometer. * * Returned Value: @@ -108,7 +108,7 @@ extern "C" ****************************************************************************/ struct i2c_master_s; -int kxjt9_register(FAR const char *devpath, FAR struct i2c_master_s *i2c, +int kxtj9_register(FAR const char *devpath, FAR struct i2c_master_s *i2c, uint8_t address); #ifdef __cplusplus @@ -116,4 +116,4 @@ int kxjt9_register(FAR const char *devpath, FAR struct i2c_master_s *i2c, #endif #endif /* CONFIG_I2C && CONFIG_SENSOR_KXTJ9 */ -#endif /* __INCLUDE_NUTTX_SENSORS_KXJT9_H */ +#endif /* __INCLUDE_NUTTX_SENSORS_KXTJ9_H */