diff options
author | Rocco Marco Guglielmi <roccomarco.guglielmi@gmail.com> | 2018-02-05 11:24:13 +0000 |
---|---|---|
committer | Rocco Marco Guglielmi <roccomarco.guglielmi@gmail.com> | 2018-02-05 11:24:13 +0000 |
commit | 8c23b103dd0c50f98dec7509b0452bae2043dcae (patch) | |
tree | 987c8858757be2c11db3f3f0bf0b17ae086e4767 /os/ex | |
parent | 11eb30f8fe72f663071b8204b122ee5e1d7fdfcd (diff) | |
download | ChibiOS-8c23b103dd0c50f98dec7509b0452bae2043dcae.tar.gz ChibiOS-8c23b103dd0c50f98dec7509b0452bae2043dcae.tar.bz2 ChibiOS-8c23b103dd0c50f98dec7509b0452bae2043dcae.zip |
Updated LPS25H driver to v 1.0.4 (Fixing Bug #915).
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@11446 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'os/ex')
-rw-r--r-- | os/ex/ST/lps25h.c | 11 | ||||
-rw-r--r-- | os/ex/ST/lps25h.h | 125 |
2 files changed, 79 insertions, 57 deletions
diff --git a/os/ex/ST/lps25h.c b/os/ex/ST/lps25h.c index 8af5f6e01..ad5b197c9 100644 --- a/os/ex/ST/lps25h.c +++ b/os/ex/ST/lps25h.c @@ -83,7 +83,8 @@ msg_t lps25hI2CReadRegister(I2CDriver *i2cp, lps25h_sad_t sad, uint8_t reg, * @notapi
* @return the operation status.
*/
-msg_t lps25hI2CWriteRegister(I2CDriver *i2cp, lps25h_sad_t sad, uint8_t* txbuf, size_t n) {
+msg_t lps25hI2CWriteRegister(I2CDriver *i2cp, lps25h_sad_t sad, uint8_t* txbuf,
+ size_t n) {
if (n > 1)
(*txbuf) |= LPS25H_SUB_MS;
return i2cMasterTransmitTimeout(i2cp, sad, txbuf, n + 1, NULL, 0,
@@ -196,11 +197,11 @@ static msg_t reset_sensivity(void *ip) { return MSG_OK;
}
-static const struct BaseSensorVMT vmt_basesensor = {
+static const struct BaseSensorVMT vmt_sensor = {
get_axes_number, read_raw, read_cooked
};
-static const struct BaseBarometerVMT vmt_basebarometer = {
+static const struct LPS25HBarometerVMT vmt_barometer = {
get_axes_number, read_raw, read_cooked,
set_bias, reset_bias, set_sensivity, reset_sensivity
};
@@ -218,8 +219,8 @@ static const struct BaseBarometerVMT vmt_basebarometer = { */
void lps25hObjectInit(LPS25HDriver *devp) {
- devp->vmt_basesensor = &vmt_basesensor;
- devp->vmt_basebarometer = &vmt_basebarometer;
+ devp->vmt_sensor = &vmt_sensor;
+ devp->vmt_barometer = &vmt_barometer;
devp->config = NULL;
devp->bias = 0;
devp->state = LPS25H_STOP;
diff --git a/os/ex/ST/lps25h.h b/os/ex/ST/lps25h.h index 657a05427..c99af55df 100644 --- a/os/ex/ST/lps25h.h +++ b/os/ex/ST/lps25h.h @@ -42,22 +42,22 @@ /**
* @brief LPS25H driver version string.
*/
-#define EX_LPS25H_VERSION "1.0.3"
+#define EX_LPS25H_VERSION "1.0.4"
/**
* @brief LPS25H driver version major number.
*/
-#define EX_LPS25H_MAJOR 1
+#define EX_LPS25H_MAJOR 1
/**
* @brief LPS25H driver version minor number.
*/
-#define EX_LPS25H_MINOR 0
+#define EX_LPS25H_MINOR 0
/**
* @brief LPS25H driver version patch number.
*/
-#define EX_LPS25H_PATCH 3
+#define EX_LPS25H_PATCH 4
/** @} */
/**
@@ -65,52 +65,52 @@ *
* @{
*/ -#define LPS25H_NUMBER_OF_AXES 1U -
-#define LPS25H_SENS 0.00024414f /**< hPa/LSB */ +#define LPS25H_NUMBER_OF_AXES 1U +
+#define LPS25H_SENS 0.00024414f /** @} */ /** * @name LPS25H communication interfaces related bit masks * @{ */ -#define LPS25H_DI_MASK 0xFF /**< Data In mask */ -#define LPS25H_DI(n) (1 << n) /**< Data In bit n */ -#define LPS25H_AD_MASK 0x3F /**< Address Data mask */ -#define LPS25H_AD(n) (1 << n) /**< Address Data bit n */ -#define LPS25H_MS (1 << 6) /**< Multiple read write */ -#define LPS25H_RW (1 << 7) /**< Read Write selector */
-
-#define LPS25H_SUB_MS (1 << 7) /**< Multiple read write in I2C mode */ +#define LPS25H_DI_MASK 0xFF +#define LPS25H_DI(n) (1 << n) +#define LPS25H_AD_MASK 0x3F +#define LPS25H_AD(n) (1 << n) +#define LPS25H_MS (1 << 6) +#define LPS25H_RW (1 << 7)
+
+#define LPS25H_SUB_MS (1 << 7) /** @} */ /** * @name LPS25H register addresses * @{ */ -#define LPS25H_AD_REF_P_XL 0x08
-#define LPS25H_AD_REF_P_L 0x09
-#define LPS25H_AD_REF_P_H 0x0A
-#define LPS25H_AD_WHO_AM_I 0x0F
-#define LPS25H_AD_RES_CONF 0x10 -#define LPS25H_AD_CTRL_REG1 0x20 -#define LPS25H_AD_CTRL_REG2 0x21 -#define LPS25H_AD_CTRL_REG3 0x22 -#define LPS25H_AD_CTRL_REG4 0x23
-#define LPS25H_AD_INT_CFG 0x24
-#define LPS25H_AD_INT_SRC 0x25
-#define LPS25H_AD_STATUS_REG 0x27 -#define LPS25H_AD_PRESS_OUT_XL 0x28 -#define LPS25H_AD_PRESS_OUT_L 0x29 -#define LPS25H_AD_PRESS_OUT_H 0x2A -#define LPS25H_AD_TEMP_OUT_L 0x2B -#define LPS25H_AD_TEMP_OUT_H 0x2C -#define LPS25H_AD_FIFO_CTRL 0x2E -#define LPS25H_AD_FIFO_SRC 0x2F -#define LPS25H_AD_THS_P_L 0x30
-#define LPS25H_AD_THS_P_H 0x31
-#define LPS25H_AD_RPDS_L 0x39
-#define LPS25H_AD_RPDS_H 0x3A +#define LPS25H_AD_REF_P_XL 0x08
+#define LPS25H_AD_REF_P_L 0x09
+#define LPS25H_AD_REF_P_H 0x0A
+#define LPS25H_AD_WHO_AM_I 0x0F
+#define LPS25H_AD_RES_CONF 0x10 +#define LPS25H_AD_CTRL_REG1 0x20 +#define LPS25H_AD_CTRL_REG2 0x21 +#define LPS25H_AD_CTRL_REG3 0x22 +#define LPS25H_AD_CTRL_REG4 0x23
+#define LPS25H_AD_INT_CFG 0x24
+#define LPS25H_AD_INT_SRC 0x25
+#define LPS25H_AD_STATUS_REG 0x27 +#define LPS25H_AD_PRESS_OUT_XL 0x28 +#define LPS25H_AD_PRESS_OUT_L 0x29 +#define LPS25H_AD_PRESS_OUT_H 0x2A +#define LPS25H_AD_TEMP_OUT_L 0x2B +#define LPS25H_AD_TEMP_OUT_H 0x2C +#define LPS25H_AD_FIFO_CTRL 0x2E +#define LPS25H_AD_FIFO_SRC 0x2F +#define LPS25H_AD_THS_P_L 0x30
+#define LPS25H_AD_THS_P_H 0x31
+#define LPS25H_AD_RPDS_L 0x39
+#define LPS25H_AD_RPDS_H 0x3A /** @} */ /** @@ -377,18 +377,34 @@ typedef struct { */
lps25h_avgt_t restemperature; #endif -} LPS25HConfig; - -/** - * @brief Structure representing a LPS25H driver. - */ -typedef struct LPS25HDriver LPS25HDriver; - +} LPS25HConfig;
+
+/**
+ * @brief @p LPS25H barometer subsystem specific methods.
+ * @note No methods so far, just a common ancestor interface.
+ */
+#define _lps25h_barometer_methods_alone
+
+/**
+ * @brief @p LPS25H barometer subsystem specific methods.
+ */
+#define _lps25h_barometer_methods \
+ _base_barometer_methods \
+ _lps25h_barometer_methods_alone
+
+/**
+ * @extends BaseBarometerVMT
+ *
+ * @brief @p LPS25H barometer virtual methods table.
+ */
+struct LPS25HBarometerVMT {
+ _lps25h_barometer_methods
+};
+ /** * @brief @p LPS25HDriver specific data. */ #define _lps25h_data \ - _base_barometer_data \ /* Driver state.*/ \ lps25h_state_t state; \ /* Current configuration data.*/ \ @@ -407,13 +423,18 @@ typedef struct LPS25HDriver LPS25HDriver; */ struct LPS25HDriver { /** @brief BaseSensor Virtual Methods Table. */ - const struct BaseSensorVMT *vmt_basesensor; - /** @brief BaseBarometer Virtual Methods Table. */ - const struct BaseBarometerVMT *vmt_basebarometer; - /** @brief LPS25H Virtual Methods Table. */ - const struct LPS25HVMT *vmt_lps25h; + const struct BaseSensorVMT *vmt_sensor;
+ _base_sensor_data + /** @brief LPS25H Barometer Virtual Methods Table. */ + const struct LPS25HBarometerVMT *vmt_barometer;
+ _base_barometer_data _lps25h_data -}; +};
+
+/**
+ * @brief Structure representing a LPS25H driver.
+ */
+typedef struct LPS25HDriver LPS25HDriver; /** @} */ /*===========================================================================*/ |