From 1b052e2af96b3e515673ad43bf0435a2fe782b4d Mon Sep 17 00:00:00 2001 From: Craig Hutchinson <54269136+CraigHutchinson@users.noreply.github.com> Date: Tue, 21 Jul 2020 11:45:15 +0100 Subject: [PATCH 1/2] Add DataReady (DRDY) Reguister addresses --- bno055.h | 55 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 55 insertions(+) diff --git a/bno055.h b/bno055.h index fcdcce5..0e17b8a 100644 --- a/bno055.h +++ b/bno055.h @@ -1502,6 +1502,19 @@ struct bno055_sic_matrix_t #define BNO055_SELFTEST_MCU_REG BNO055_SELFTEST_RESULT_ADDR /*Interrupt status registers*/ + +/* @note Firmware >v3.14 */ +#define BNO055_INTR_STAT_ACC_BSX_DRDY_POS (0) +#define BNO055_INTR_STAT_ACC_BSX_DRDY_MSK (0X01) +#define BNO055_INTR_STAT_ACC_BSX_DRDY_LEN (1) +#define BNO055_INTR_STAT_ACC_BSX_DRDY_REG BNO055_INTR_STAT_ADDR + +/* @note Firmware >v3.14 */ +#define BNO055_INTR_STAT_MAG_DRDY_POS (1) +#define BNO055_INTR_STAT_MAG_DRDY_MSK (0X02) +#define BNO055_INTR_STAT_MAG_DRDY_LEN (1) +#define BNO055_INTR_STAT_MAG_DRDY_REG BNO055_INTR_STAT_ADDR + #define BNO055_INTR_STAT_GYRO_ANY_MOTION_POS (2) #define BNO055_INTR_STAT_GYRO_ANY_MOTION_MSK (0X04) #define BNO055_INTR_STAT_GYRO_ANY_MOTION_LEN (1) @@ -1512,6 +1525,12 @@ struct bno055_sic_matrix_t #define BNO055_INTR_STAT_GYRO_HIGHRATE_LEN (1) #define BNO055_INTR_STAT_GYRO_HIGHRATE_REG BNO055_INTR_STAT_ADDR +/* @note Firmware >v3.14 */ +#define BNO055_INTR_STAT_GYR_DRDY_POS (4) +#define BNO055_INTR_STAT_GYR_DRDY_MSK (0X10) +#define BNO055_INTR_STAT_GYR_DRDY_LEN (1) +#define BNO055_INTR_STAT_GYR_DRDY_REG BNO055_INTR_STAT_ADDR + #define BNO055_INTR_STAT_ACCEL_HIGH_G_POS (5) #define BNO055_INTR_STAT_ACCEL_HIGH_G_MSK (0X20) #define BNO055_INTR_STAT_ACCEL_HIGH_G_LEN (1) @@ -1946,6 +1965,18 @@ struct bno055_sic_matrix_t #define BNO055_MAG_SLEEP_DURN_REG BNO055_MAG_SLEEP_CONFIG_ADDR /* Interrupt registers*/ +/* Accelerometer Data-Ready interrupt msk register @note Firmware >v3.14 */ +#define BNO055_ACC_BSX_DRDY_INTR_MASK_POS (0) +#define BNO055_ACC_BSX_DRDY_INTR_MASK_MSK (0X01) +#define BNO055_ACC_BSX_DRDY_INTR_MASK_LEN (1) +#define BNO055_ACC_BSX_DRDY_INTR_MASK_REG BNO055_INT_MASK_ADDR + +/* Magnetometer Data-Ready interrupt msk register @note Firmware >v3.14 */ +#define BNO055_MAG_DRDY_INTR_MASK_POS (1) +#define BNO055_MAG_DRDY_INTR_MASK_MSK (0X02) +#define BNO055_MAG_DRDY_INTR_MASK_LEN (1) +#define BNO055_MAG_DRDY_INTR_MASK_REG BNO055_INT_MASK_ADDR + /* Gyro any motion interrupt msk register*/ #define BNO055_GYRO_ANY_MOTION_INTR_MASK_POS (2) #define BNO055_GYRO_ANY_MOTION_INTR_MASK_MSK (0X04) @@ -1958,6 +1989,12 @@ struct bno055_sic_matrix_t #define BNO055_GYRO_HIGHRATE_INTR_MASK_LEN (1) #define BNO055_GYRO_HIGHRATE_INTR_MASK_REG BNO055_INT_MASK_ADDR +/* Magnetometer Data-Ready interrupt msk register @note Firmware >v3.14 */ +#define BNO055_GYR_DRDY_INTR_MASK_POS (4) +#define BNO055_GYR_DRDY_INTR_MASK_MSK (0X10) +#define BNO055_GYR_DRDY_INTR_MASK_LEN (1) +#define BNO055_GYR_DRDY_INTR_MASK_REG BNO055_INT_MASK_ADDR + /* Accel high g interrupt msk register*/ #define BNO055_ACCEL_HIGH_G_INTR_MASK_POS (5) #define BNO055_ACCEL_HIGH_G_INTR_MASK_MSK (0X20) @@ -1976,6 +2013,18 @@ struct bno055_sic_matrix_t #define BNO055_ACCEL_NO_MOTION_INTR_MASK_LEN (1) #define BNO055_ACCEL_NO_MOTION_INTR_MASK_REG BNO055_INT_MASK_ADDR +/* Accelerometer Data-Ready interrupt register @note Firmware >v3.14 */ +#define BNO055_ACC_BSX_DRDY_INTR_POS (0) +#define BNO055_ACC_BSX_DRDY_INTR_MSK (0X01) +#define BNO055_ACC_BSX_DRDY_INTR_LEN (1) +#define BNO055_ACC_BSX_DRDY_INTR_REG BNO055_INT_ADDR + +/* Magnetometer Data-Ready interrupt register @note Firmware >v3.14*/ +#define BNO055_MAG_DRDY_INTR_POS (1) +#define BNO055_MAG_DRDY_INTR_MSK (0X02) +#define BNO055_MAG_DRDY_INTR_LEN (1) +#define BNO055_MAG_DRDY_INTR_REG BNO055_INT_ADDR + /* Gyro any motion interrupt register*/ #define BNO055_GYRO_ANY_MOTION_INTR_POS (2) #define BNO055_GYRO_ANY_MOTION_INTR_MSK (0X04) @@ -1988,6 +2037,12 @@ struct bno055_sic_matrix_t #define BNO055_GYRO_HIGHRATE_INTR_LEN (1) #define BNO055_GYRO_HIGHRATE_INTR_REG BNO055_INT_ADDR +/* Gyro Data-Ready interrupt register @note Firmware >v3.14*/ +#define BNO055_GYR_DRDY_INTR_POS (4) +#define BNO055_GYR_DRDY_INTR_MSK (0X10) +#define BNO055_GYR_DRDY_INTR_LEN (1) +#define BNO055_GYR_DRDY_INTR_REG BNO055_INT_ADDR + /* Accel high g interrupt register*/ #define BNO055_ACCEL_HIGH_G_INTR_POS (5) #define BNO055_ACCEL_HIGH_G_INTR_MSK (0X20) From 192c39246afa5b18e089bb1bc914e49ffe7dac3b Mon Sep 17 00:00:00 2001 From: Craig Hutchinson <54269136+CraigHutchinson@users.noreply.github.com> Date: Tue, 21 Jul 2020 12:36:02 +0100 Subject: [PATCH 2/2] Supports enable/disable of multiple interupts in a single op *Added bno055_enable_intr() and bno055_disable_intr --- bno055.c | 126 +++++++++++++++++++++++++++++++++++++++++++++++++++++++ bno055.h | 41 ++++++++++++++++++ 2 files changed, 167 insertions(+) diff --git a/bno055.c b/bno055.c index 007438c..f4ab280 100644 --- a/bno055.c +++ b/bno055.c @@ -14458,6 +14458,132 @@ BNO055_RETURN_FUNCTION_TYPE bno055_set_intr_mask_accel_no_motion(u8 accel_nomoti return com_rslt; } +/*! + * @brief This API used to write the Accelerometer Data-Ready interrupt + * from page one register from 0x10 bit 0 + * * + * @param intrmask_u8 : Mask of interrupts to enable: + * - BNO055_ACC_BSX_DRDY_INTR_MSK + * - BNO055_MAG_DRDY_INTR_MSK + * - BNO055_GYRO_ANY_MOTION_INTR_MSK + * - BNO055_GYRO_HIGHRATE_INTR_MSK + * - BNO055_GYR_DRDY_INTR_MSK + * - BNO055_ACCEL_HIGH_G_INTR_MSK + * - BNO055_ACCEL_ANY_MOTION_INTR_MSK + * - BNO055_ACCEL_NO_MOTION_INTR_MSK + * + * @return results of bus communication function + * @retval 0 -> BNO055_SUCCESS + * @retval 1 -> BNO055_ERROR + */ +BNO055_RETURN_FUNCTION_TYPE bno055_enable_intr( u8 intrmask_u8 ) +{ + BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR; + u8 data_u8r = BNO055_INIT_VALUE; + s8 stat_s8 = BNO055_ERROR; + + /* Check the struct p_bno055 is empty */ + if( p_bno055 == NULL ) + { + return BNO055_E_NULL_PTR; + } + else + { + /*condition check for page, Accelerometer Data-Ready interrupt is + * available in the page one*/ + if( p_bno055->page_id != BNO055_PAGE_ONE ) + { + /* Write page as one */ + stat_s8 = bno055_write_page_id( BNO055_PAGE_ONE ); + } + if( (stat_s8 == BNO055_SUCCESS) || (p_bno055->page_id == BNO055_PAGE_ONE) ) + { + /* Write the value of Accelerometer Data-Ready interrupt */ + com_rslt = p_bno055->BNO055_BUS_READ_FUNC( p_bno055->dev_addr, + BNO055_INT_ADDR, + &data_u8r, + BNO055_GEN_READ_WRITE_LENGTH ); + if( com_rslt == BNO055_SUCCESS ) + { + data_u8r |= intrmask_u8; + com_rslt += p_bno055->BNO055_BUS_WRITE_FUNC( p_bno055->dev_addr, + BNO055_INT_ADDR, + &data_u8r, + BNO055_GEN_READ_WRITE_LENGTH ); + } + } + else + { + com_rslt = BNO055_ERROR; + } + } + + return com_rslt; +} + +/*! + * @brief This API used to write the Accelerometer Data-Ready interrupt + * from page one register from 0x10 bit 0 + * * + * @param intrmask_u8 : Mask of interrupts to disable: + * - BNO055_ACC_BSX_DRDY_INTR_MSK + * - BNO055_MAG_DRDY_INTR_MSK + * - BNO055_GYRO_ANY_MOTION_INTR_MSK + * - BNO055_GYRO_HIGHRATE_INTR_MSK + * - BNO055_GYR_DRDY_INTR_MSK + * - BNO055_ACCEL_HIGH_G_INTR_MSK + * - BNO055_ACCEL_ANY_MOTION_INTR_MSK + * - BNO055_ACCEL_NO_MOTION_INTR_MSK + * + * @return results of bus communication function + * @retval 0 -> BNO055_SUCCESS + * @retval 1 -> BNO055_ERROR + */ +BNO055_RETURN_FUNCTION_TYPE bno055_disable_intr( u8 intrmask_u8 ) +{ + BNO055_RETURN_FUNCTION_TYPE com_rslt = BNO055_ERROR; + u8 data_u8r = BNO055_INIT_VALUE; + s8 stat_s8 = BNO055_ERROR; + + /* Check the struct p_bno055 is empty */ + if( p_bno055 == NULL ) + { + return BNO055_E_NULL_PTR; + } + else + { + /*condition check for page, Accelerometer Data-Ready interrupt is + * available in the page one*/ + if( p_bno055->page_id != BNO055_PAGE_ONE ) + { + /* Write page as one */ + stat_s8 = bno055_write_page_id( BNO055_PAGE_ONE ); + } + if( (stat_s8 == BNO055_SUCCESS) || (p_bno055->page_id == BNO055_PAGE_ONE) ) + { + /* Write the value of Accelerometer Data-Ready interrupt */ + com_rslt = p_bno055->BNO055_BUS_READ_FUNC( p_bno055->dev_addr, + BNO055_INT_ADDR, + &data_u8r, + BNO055_GEN_READ_WRITE_LENGTH ); + if( com_rslt == BNO055_SUCCESS ) + { + data_u8r &= ~intrmask_u8; + com_rslt += p_bno055->BNO055_BUS_WRITE_FUNC( p_bno055->dev_addr, + BNO055_INT_ADDR, + &data_u8r, + BNO055_GEN_READ_WRITE_LENGTH ); + } + } + else + { + com_rslt = BNO055_ERROR; + } + } + + return com_rslt; +} + /*! * @brief This API used to read the gyro anymotion interrupt * from page one register from 0x10 bit 2 diff --git a/bno055.h b/bno055.h index 0e17b8a..729ca82 100644 --- a/bno055.h +++ b/bno055.h @@ -6662,6 +6662,47 @@ BNO055_RETURN_FUNCTION_TYPE bno055_get_intr_mask_accel_no_motion(u8 *accel_nomot */ BNO055_RETURN_FUNCTION_TYPE bno055_set_intr_mask_accel_no_motion(u8 accel_nomotion_u8); + +/*! + * @brief This API used to write the Accelerometer Data-Ready interrupt + * from page one register from 0x10 bit 0 + * * + * @param intrmask_u8 : Mask of interrupts to enable: + * - BNO055_ACC_BSX_DRDY_INTR_MSK + * - BNO055_MAG_DRDY_INTR_MSK + * - BNO055_GYRO_ANY_MOTION_INTR_MSK + * - BNO055_GYRO_HIGHRATE_INTR_MSK + * - BNO055_GYR_DRDY_INTR_MSK + * - BNO055_ACCEL_HIGH_G_INTR_MSK + * - BNO055_ACCEL_ANY_MOTION_INTR_MSK + * - BNO055_ACCEL_NO_MOTION_INTR_MSK + * + * @return results of bus communication function + * @retval 0 -> BNO055_SUCCESS + * @retval 1 -> BNO055_ERROR + */ +BNO055_RETURN_FUNCTION_TYPE bno055_enable_intr( u8 intrmask_u8 ); + +/*! + * @brief This API used to write the Accelerometer Data-Ready interrupt + * from page one register from 0x10 bit 0 + * * + * @param intrmask_u8 : Mask of interrupts to disable: + * - BNO055_ACC_BSX_DRDY_INTR_MSK + * - BNO055_MAG_DRDY_INTR_MSK + * - BNO055_GYRO_ANY_MOTION_INTR_MSK + * - BNO055_GYRO_HIGHRATE_INTR_MSK + * - BNO055_GYR_DRDY_INTR_MSK + * - BNO055_ACCEL_HIGH_G_INTR_MSK + * - BNO055_ACCEL_ANY_MOTION_INTR_MSK + * - BNO055_ACCEL_NO_MOTION_INTR_MSK + * + * @return results of bus communication function + * @retval 0 -> BNO055_SUCCESS + * @retval 1 -> BNO055_ERROR + */ +BNO055_RETURN_FUNCTION_TYPE bno055_disable_intr( u8 intrmask_u8 ); + /*****************************************************/ /**\name FUNCTIONS FOR GYRO INTERRUPT */ /*****************************************************/