From 2dd62cd71f099d27f9c915342590830e8a41fd16 Mon Sep 17 00:00:00 2001 From: BSP1RT Date: Thu, 12 Sep 2024 14:34:24 +0550 Subject: [PATCH] BMA580 Sensor API v4.2.0 Github release. --- bma5.c | 15 +- bma5.h | 4 +- bma580.c | 4 +- bma580.h | 4 +- bma580_context.h | 4 +- bma580_features.c | 4 +- bma580_features.h | 4 +- bma5_defs.h | 26 +-- examples/accel_foc/Makefile | 2 +- examples/accel_foc/accel_foc.c | 182 ++++++++++++++---- examples/accelerometer/Makefile | 2 +- examples/accelerometer/accelerometer.c | 29 ++- examples/common/common.h | 8 + examples/feature_axis_exchange/Makefile | 2 +- .../feature_axis_exchange.c | 43 ++++- .../Makefile | 2 +- ...ifo_full_16_bit_dedicated_frame_comp_dis.c | 58 +++--- .../Makefile | 2 +- .../fifo_full_16_bit_each_frame_comp_dis.c | 61 +++--- .../Makefile | 2 +- .../fifo_full_8_bit_dedicated_frame_comp_en.c | 61 +++--- .../Makefile | 2 +- .../fifo_full_8_bit_each_frame_comp_en.c | 57 +++--- .../Makefile | 2 +- .../fifo_wm_16_bit_dedicated_frame_comp_dis.c | 63 +++--- .../Makefile | 2 +- .../fifo_wm_16_bit_each_frame_comp_dis.c | 61 +++--- .../Makefile | 2 +- .../fifo_wm_8_bit_dedicated_frame_comp_en.c | 58 +++--- .../fifo_wm_8_bit_each_frame_comp_en/Makefile | 2 +- .../fifo_wm_8_bit_each_frame_comp_en.c | 63 +++--- examples/flat/flat.c | 15 +- examples/generic_interrupt_1/Makefile | 2 +- .../generic_interrupt_1/generic_interrupt_1.c | 38 +++- examples/generic_interrupt_2/Makefile | 2 +- .../generic_interrupt_2/generic_interrupt_2.c | 39 +++- examples/generic_interrupt_3/Makefile | 2 +- .../generic_interrupt_3/generic_interrupt_3.c | 41 +++- examples/motion_detected/motion_detected.c | 18 +- examples/self_test/Makefile | 2 +- examples/self_test/self_test.c | 2 +- examples/self_wake_up/Makefile | 2 +- examples/self_wake_up/self_wake_up.c | 126 ++++++------ .../stationary_detected/stationary_detected.c | 17 +- examples/tap/Makefile | 2 +- examples/tap/tap.c | 21 +- examples/temperature/Makefile | 2 +- examples/temperature/temperature.c | 18 +- examples/vad/Makefile | 2 +- examples/vad/vad.c | 18 +- 50 files changed, 811 insertions(+), 389 deletions(-) diff --git a/bma5.c b/bma5.c index 6b34238..2e374f0 100644 --- a/bma5.c +++ b/bma5.c @@ -31,8 +31,8 @@ * POSSIBILITY OF SUCH DAMAGE. * * @file bma5.c -* @date 2024-04-15 -* @version v4.1.0 +* @date 2024-07-29 +* @version v4.2.0 * */ @@ -513,8 +513,6 @@ int8_t bma5_get_temp_conf(struct bma5_temp_conf *config, struct bma5_dev *dev) config->temp_rate = BMA5_GET_BITS_POS_0(reg_value, BMA5_TEMP_RATE); config->temp_meas_src = BMA5_GET_BITS(reg_value, BMA5_TEMP_MEAS_SRC); config->temp_ext_sel = BMA5_GET_BITS(reg_value, BMA5_TEMP_EXT_SEL); - config->temp_tcs = BMA5_GET_BITS(reg_value, BMA5_TEMP_TCS); - config->temp_tco = BMA5_GET_BITS(reg_value, BMA5_TEMP_TCO); } } @@ -539,8 +537,6 @@ int8_t bma5_set_temp_conf(const struct bma5_temp_conf *config, struct bma5_dev * reg_value = BMA5_SET_BITS_POS_0(reg_value, BMA5_TEMP_RATE, config->temp_rate); reg_value = BMA5_SET_BITS(reg_value, BMA5_TEMP_MEAS_SRC, config->temp_meas_src); reg_value = BMA5_SET_BITS(reg_value, BMA5_TEMP_EXT_SEL, config->temp_ext_sel); - reg_value = BMA5_SET_BITS(reg_value, BMA5_TEMP_TCS, config->temp_tcs); - reg_value = BMA5_SET_BITS(reg_value, BMA5_TEMP_TCO, config->temp_tco); result = bma5_set_regs(BMA5_REG_TEMP_CONF, (const uint8_t *)®_value, sizeof(reg_value), dev); } @@ -1279,22 +1275,23 @@ int8_t bma5_get_acc_doff(struct bma5_accel_doff *accel_doff, struct bma5_dev *de else { result = bma5_get_regs(BMA5_REG_ACC_OFFSET_0, reg_value, 6, dev); + if (BMA5_OK == result) { acc_doff_7_0 = BMA5_GET_BITS_POS_0(reg_value[0], BMA5_ACC_DOFF_7_0); acc_doff_8 = BMA5_GET_BITS_POS_0(reg_value[1], BMA5_ACC_DOFF_8); - accel_doff->x_doff = (int16_t)(((uint16_t)acc_doff_8 << 8) | ((uint16_t)acc_doff_7_0)); + accel_doff->x_doff = (int16_t)((((uint16_t)acc_doff_8 << 8) | ((uint16_t)acc_doff_7_0)) << 7) >> 7; acc_doff_7_0 = BMA5_GET_BITS_POS_0(reg_value[2], BMA5_ACC_DOFF_7_0); acc_doff_8 = BMA5_GET_BITS_POS_0(reg_value[3], BMA5_ACC_DOFF_8); - accel_doff->y_doff = (int16_t)(((uint16_t)acc_doff_8 << 8) | ((uint16_t)acc_doff_7_0)); + accel_doff->y_doff = (int16_t)((((uint16_t)acc_doff_8 << 8) | ((uint16_t)acc_doff_7_0)) << 7) >> 7; acc_doff_7_0 = BMA5_GET_BITS_POS_0(reg_value[4], BMA5_ACC_DOFF_7_0); acc_doff_8 = BMA5_GET_BITS_POS_0(reg_value[5], BMA5_ACC_DOFF_8); - accel_doff->z_doff = (int16_t)(((uint16_t)acc_doff_8 << 8) | ((uint16_t)acc_doff_7_0)); + accel_doff->z_doff = (int16_t)((((uint16_t)acc_doff_8 << 8) | ((uint16_t)acc_doff_7_0)) << 7) >> 7; } } diff --git a/bma5.h b/bma5.h index d87dfe3..439efeb 100644 --- a/bma5.h +++ b/bma5.h @@ -31,8 +31,8 @@ * POSSIBILITY OF SUCH DAMAGE. * * @file bma5.h -* @date 2024-04-15 -* @version v4.1.0 +* @date 2024-07-29 +* @version v4.2.0 * */ diff --git a/bma580.c b/bma580.c index d708829..c8cc8c5 100644 --- a/bma580.c +++ b/bma580.c @@ -31,8 +31,8 @@ * POSSIBILITY OF SUCH DAMAGE. * * @file bma580.c -* @date 2024-04-15 -* @version v4.1.0 +* @date 2024-07-29 +* @version v4.2.0 * */ diff --git a/bma580.h b/bma580.h index 9a27b48..2e9b7e7 100644 --- a/bma580.h +++ b/bma580.h @@ -31,8 +31,8 @@ * POSSIBILITY OF SUCH DAMAGE. * * @file bma580.h -* @date 2024-04-15 -* @version v4.1.0 +* @date 2024-07-29 +* @version v4.2.0 * */ diff --git a/bma580_context.h b/bma580_context.h index 0c05052..d73f728 100644 --- a/bma580_context.h +++ b/bma580_context.h @@ -31,8 +31,8 @@ * POSSIBILITY OF SUCH DAMAGE. * * @file bma580_context.h -* @date 2024-04-15 -* @version v4.1.0 +* @date 2024-07-29 +* @version v4.2.0 * */ diff --git a/bma580_features.c b/bma580_features.c index 2160432..f5b67e9 100644 --- a/bma580_features.c +++ b/bma580_features.c @@ -31,8 +31,8 @@ * POSSIBILITY OF SUCH DAMAGE. * * @file bma580_features.c -* @date 2024-04-15 -* @version v4.1.0 +* @date 2024-07-29 +* @version v4.2.0 * */ diff --git a/bma580_features.h b/bma580_features.h index ad5805b..b3e09e5 100644 --- a/bma580_features.h +++ b/bma580_features.h @@ -31,8 +31,8 @@ * POSSIBILITY OF SUCH DAMAGE. * * @file bma580_features.h -* @date 2024-04-15 -* @version v4.1.0 +* @date 2024-07-29 +* @version v4.2.0 * */ diff --git a/bma5_defs.h b/bma5_defs.h index a23f91d..600bf4f 100644 --- a/bma5_defs.h +++ b/bma5_defs.h @@ -31,8 +31,8 @@ * POSSIBILITY OF SUCH DAMAGE. * * @file bma5_defs.h -* @date 2024-04-15 -* @version v4.1.0 +* @date 2024-07-29 +* @version v4.2.0 * */ @@ -421,14 +421,6 @@ #define BMA5_TEMP_EXT_SEL_MSK UINT8_C(0x10) #define BMA5_TEMP_EXT_SEL_POS UINT8_C(0x04) -/*! Enable temperature dependent sensitivity correction. */ -#define BMA5_TEMP_TCS_MSK UINT8_C(0x20) -#define BMA5_TEMP_TCS_POS UINT8_C(0x05) - -/*! Enable temperature dependent offset correction. */ -#define BMA5_TEMP_TCO_MSK UINT8_C(0x40) -#define BMA5_TEMP_TCO_POS UINT8_C(0x06) - /*! Output enable for INT pin */ #define BMA5_INT_MODE_MSK UINT8_C(0x03) #define BMA5_INT_MODE_POS UINT8_C(0x00) @@ -748,14 +740,6 @@ #define BMA5_TEMP_EXT_SEL_INT1 UINT8_C(0x00) /*! interrupt pin INT1 */ #define BMA5_TEMP_EXT_SEL_INT2 UINT8_C(0x01) /*! interrupt pin INT2 */ -/* Macros to define the supported temp_tcs values */ -#define BMA5_TEMP_TCS_DISABLE UINT8_C(0x00) /*! TCS correction disabled */ -#define BMA5_TEMP_TCS_ENABLE UINT8_C(0x01) /*! TCS correction enabled */ - -/* Macros to define the supported temp_tco values */ -#define BMA5_TEMP_TCO_DISABLE UINT8_C(0x00) /*! TCO correction disabled */ -#define BMA5_TEMP_TCO_ENABLE UINT8_C(0x01) /*! TCO correction enabled */ - /* Macros to define the supported int1_mode values */ #define BMA5_INT1_MODE_OFF UINT8_C(0x00) /*! Output disabled. */ #define BMA5_INT1_MODE_LATCHED UINT8_C(0x01) /*! Latched (level triggered) interrupts. */ @@ -1157,12 +1141,6 @@ struct bma5_temp_conf /*! Select the external pin as source for temperature ADC. */ uint8_t temp_ext_sel; - /*! Enable temperature dependent sensitivity correction. */ - uint8_t temp_tcs; - - /*! Enable temperature dependent offset correction. */ - uint8_t temp_tco; - }; /*! diff --git a/examples/accel_foc/Makefile b/examples/accel_foc/Makefile index af5899c..70a9051 100644 --- a/examples/accel_foc/Makefile +++ b/examples/accel_foc/Makefile @@ -14,5 +14,5 @@ $(COMMON_LOCATION)/common/common.c INCLUDEPATHS += \ $(API_LOCATION) \ $(COMMON_LOCATION)/common - +COINES_BACKEND ?= COINES_BRIDGE include $(COINES_INSTALL_PATH)/coines.mk \ No newline at end of file diff --git a/examples/accel_foc/accel_foc.c b/examples/accel_foc/accel_foc.c index 22eac0d..5abfd04 100644 --- a/examples/accel_foc/accel_foc.c +++ b/examples/accel_foc/accel_foc.c @@ -65,30 +65,34 @@ int main(void) uint8_t n_ints = 2; uint8_t n_status = 2; uint8_t loop; - uint8_t gpr_ctrl_host = BMA5_ENABLE; uint8_t sensor_ctrl; - + uint8_t limit = 10; float x, y, z; + /*Structue to hold the configurations */ struct bma5_dev dev; struct bma580_int_map int_map = { 0 }; struct bma580_int_status_types int_status[2]; struct bma5_int_conf_types int_config[2]; + struct bma5_acc_conf config; struct bma580_accel_foc_config conf; struct bma580_feat_eng_gpr_0 gpr_0; struct bma580_feat_eng_gp_flags gp_flags; struct bma5_accel_doff user_off; struct bma5_sensor_status status; struct bma5_accel sens_data = { 0 }; + struct bma5_feat_eng_gpr_ctrl gpr_ctrl_host; /* Assign context parameter selection */ enum bma5_context context; context = BMA5_SMARTPHONE; + /* Mapping to hardware interrupt pin on sensor */ int_config[0].int_src = BMA5_INT_1; int_config[1].int_src = BMA5_INT_2; + /* Variable to hold configurations related to interrupt pin */ int_status[0].int_src = BMA580_INT_STATUS_INT1; int_status[1].int_src = BMA580_INT_STATUS_INT2; @@ -99,9 +103,10 @@ int main(void) rslt = bma5_interface_init(&dev, BMA5_I2C_INTF, context); bma5_check_rslt("bma5_interface_init", rslt); + /* Initialize the BMA580 device instance */ rslt = bma580_init(&dev); bma5_check_rslt("bma580_init", rslt); - printf("BMA580 Chip ID is 0x%X\n", dev.chip_id); + printf("Chip ID :0x%X\n", dev.chip_id); /* Get accel configurations */ rslt = bma5_get_acc_conf_0(&sensor_ctrl, &dev); @@ -113,6 +118,10 @@ int main(void) rslt = bma5_set_acc_conf_0(sensor_ctrl, &dev); bma5_check_rslt("bma5_get_acc_conf_0", rslt); + rslt = bma5_get_acc_conf_0(&sensor_ctrl, &dev); + bma5_check_rslt("bma5_get_acc_conf_0", rslt); + + /* Map generic interrupts to hardware interrupt pin of the sensor */ rslt = bma580_get_int_map(&int_map, &dev); bma5_check_rslt("bma580_get_int_map", rslt); @@ -126,35 +135,62 @@ int main(void) bma5_check_rslt("bma580_set_int_map_0", rslt); /* Get accel configurations */ - rslt = bma5_get_acc_conf_0(&sensor_ctrl, &dev); - bma5_check_rslt("bma5_get_acc_conf_0", rslt); + rslt = bma5_get_acc_conf(&config, &dev); + bma5_check_rslt("bma5_get_acc_conf", rslt); + /* Set the accel configurations */ sensor_ctrl = BMA5_SENSOR_CTRL_ENABLE; + config.acc_odr = BMA5_ACC_ODR_HZ_50; + config.acc_range = BMA5_ACC_RANGE_MAX_16G; /* enable accel */ rslt = bma5_set_acc_conf_0(sensor_ctrl, &dev); bma5_check_rslt("bma5_set_acc_conf_0", rslt); + if (rslt == BMA5_OK) + { + printf("\nAccel is enabled\n"); + } + + /* Set the accel configurations */ + rslt = bma5_set_acc_conf(&config, &dev); + bma5_check_rslt("bma5_get_acc_conf", rslt); + + printf("\nAccel configurations:\n"); + printf("ODR : %s\t\n", enum_to_string(BMA5_ACC_ODR_HZ_50)); + printf("Range : %s\t\n", enum_to_string(BMA5_ACC_RANGE_MAX_16G)); + /* Map hardware interrupt pin configurations */ rslt = bma5_get_int_conf(int_config, n_ints, &dev); bma5_check_rslt("bma5_get_int_conf", rslt); + /* Set the hardware interrupt pin configuration */ int_config[0].int_conf.int_mode = BMA5_INT1_MODE_PULSED_LONG; int_config[0].int_conf.int_od = BMA5_INT1_OD_PUSH_PULL; int_config[0].int_conf.int_lvl = BMA5_INT1_LVL_ACTIVE_HIGH; int_config[1].int_conf.int_mode = BMA5_INT2_MODE_PULSED_LONG; int_config[1].int_conf.int_od = BMA5_INT2_OD_PUSH_PULL; - int_config[1].int_conf.int_lvl = BMA5_INT2_LVL_ACTIVE_LOW; + int_config[1].int_conf.int_lvl = BMA5_INT2_LVL_ACTIVE_HIGH; rslt = bma5_set_int_conf(int_config, n_ints, &dev); bma5_check_rslt("bma5_set_int_conf", rslt); + printf("\nInterrupt configurations\n"); + printf("\nINT1 Mode : %s\t\n", enum_to_string(BMA5_INT1_MODE_PULSED_LONG)); + printf("INT1 Output type : %s\t\n", enum_to_string(BMA5_INT1_OD_PUSH_PULL)); + printf("INT1 Active level : %s\t\n", enum_to_string(BMA5_INT1_LVL_ACTIVE_HIGH)); + + printf("\nINT2 Mode : %s\t\n", enum_to_string(BMA5_INT2_MODE_PULSED_LONG)); + printf("INT2 Output type : %s\t\n", enum_to_string(BMA5_INT2_OD_PUSH_PULL)); + printf("INT2 Active level : %s\t\n", enum_to_string(BMA5_INT2_LVL_ACTIVE_HIGH)); + + printf("Aquisition Iteration count : %d\n\n", limit); printf("Reading Accel values before FOC compensation\n"); - printf("\n# Count, Accel_LSB_X, Accel_LSB_Y, Accel_LSB_Z, Acc_ms2_X, Acc_ms2_Y, Acc_ms2_Z\n"); + printf("#Count, Accel_LSB_X, Accel_LSB_Y, Accel_LSB_Z, Acc_ms2_X, Acc_ms2_Y, Acc_ms2_Z\n"); loop = 0; - while (loop < 10) + while (loop < limit) { for (;;) { @@ -168,6 +204,7 @@ int main(void) rslt = bma580_get_int_status(int_status, n_status, &dev); bma5_check_rslt("bma580_get_int_status", rslt); + /*Checking interrupt status to check accel data ready */ if (int_status[0].int_status.acc_drdy_int_status & BMA580_ACC_DRDY_INT_STATUS_MSK) { rslt = bma5_set_sensor_status(&status, &dev); @@ -180,13 +217,13 @@ int main(void) rslt = bma5_get_acc(&sens_data, &dev); bma5_check_rslt("bma5_get_acc", rslt); - /* Converting lsb to mg for 16 bit resolution at 8G range */ - x = lsb_to_ms2(sens_data.x, (float)8, BMA5_16_BIT_RESOLUTION); - y = lsb_to_ms2(sens_data.y, (float)8, BMA5_16_BIT_RESOLUTION); - z = lsb_to_ms2(sens_data.z, (float)8, BMA5_16_BIT_RESOLUTION); + /* Converting lsb to m/s^2 for 16 bit resolution at 16G range */ + x = lsb_to_ms2(sens_data.x, (float)16, BMA5_16_BIT_RESOLUTION); + y = lsb_to_ms2(sens_data.y, (float)16, BMA5_16_BIT_RESOLUTION); + z = lsb_to_ms2(sens_data.z, (float)16, BMA5_16_BIT_RESOLUTION); - /* Print the data in mg */ - printf("%d, %d, %d, %d, %4.2f, %4.2f, %4.2f\n", + /* Print the data in m/s^2 */ + printf("%4d %11d %11d %11d %9.2f %9.2f %9.2f\n", loop + 1, sens_data.x, sens_data.y, @@ -202,64 +239,97 @@ int main(void) loop++; } - printf("Reading the offset values before FOC compensation\n"); + printf("\nReading the accel offset values before FOC compensation\n"); + /* Get the offset values */ rslt = bma5_get_acc_doff(&user_off, &dev); bma5_check_rslt("bma5_get_acc_doff", rslt); - printf("USER_OFFSET_X %d\t USER_OFFSET_Y %d\t USER_OFFSET_Z %d\n", user_off.x_doff, user_off.y_doff, - user_off.z_doff); + printf("USER_OFFSET_X: %d\n", user_off.x_doff); + printf("USER_OFFSET_Y: %d\n", user_off.y_doff); + printf("USER_OFFSET_Z: %d\n", user_off.z_doff); + /* Get the FOC configurations */ rslt = bma580_get_accel_foc_config(&conf, &dev); bma5_check_rslt("bma580_get_accel_foc_config", rslt); + printf("\nFOC Configurations for offset x, y and z axis:\n"); printf("foc_off_x:0x%x\n", conf.foc_off_x); printf("foc_off_y:0x%x\n", conf.foc_off_y); printf("foc_off_z:0x%x\n", conf.foc_off_z); + /* Set the FOC configurations */ conf.foc_apply_corr = BMA5_ENABLE; conf.foc_filter_coeff = 4; - conf.foc_axis_1g = BMA5_ACC_FOC_AXIS_Z_MINUS_1G; + conf.foc_axis_1g = BMA5_ACC_FOC_AXIS_Z_PLUS_1G; rslt = bma580_set_accel_foc_config(&conf, &dev); bma5_check_rslt("bma580_set_accel_foc_config", rslt); + /* Get the FOC configurations */ rslt = bma580_get_accel_foc_config(&conf, &dev); bma5_check_rslt("bma580_get_accel_foc_config", rslt); + printf("\nFOC Configurations for FOC corelation, filter coefficient and axis of 1g\n"); printf("foc_apply_corr:0x%x\n", conf.foc_apply_corr); printf("foc_filter_coeff:0x%x\n", conf.foc_filter_coeff); printf("foc_axis_1g:0x%x\n", conf.foc_axis_1g); + /* Get the feature engine configurations */ rslt = bma580_get_feat_eng_gpr_0(&gpr_0, &dev); bma5_check_rslt("bma580_get_feat_eng_gpr_0", rslt); + /* Enable FOC feature */ gpr_0.acc_foc_en = BMA5_ENABLE; rslt = bma580_set_feat_eng_gpr_0(&gpr_0, &dev); bma5_check_rslt("bma580_set_feat_eng_gpr_0", rslt); + printf("\nfoc en : %d\n", gpr_0.acc_foc_en); - rslt = bma5_set_regs(BMA5_REG_FEAT_ENG_GPR_CTRL, &gpr_ctrl_host, 1, &dev); - bma5_check_rslt("bma5_set_regs", rslt); + if (rslt == BMA5_OK) + { + printf("Accel FOC is enabled\n"); + + } + /* Update feature engine */ + gpr_ctrl_host.update_gprs = BMA5_ENABLE; + rslt = bma5_set_feat_eng_gpr_ctrl(&gpr_ctrl_host, &dev); + bma5_check_rslt("bma5_set_feat_eng_gpr_ctrl", rslt); + + /* Get the feature engine configurations */ rslt = bma580_get_feat_eng_gpr_0(&gpr_0, &dev); bma5_check_rslt("bma580_get_feat_eng_gpr_0", rslt); - printf("foc en : %d\n", gpr_0.acc_foc_en); + printf("\nDo not move the board to perform ACCEL FOC\n"); + + user_off.x_doff = 0; + user_off.y_doff = 0; + user_off.z_doff = 0; + rslt = bma5_set_acc_doff(&user_off, &dev); + bma5_check_rslt("bma5_get_acc_doff", rslt); + + printf("\nClearing the offset registers\n"); + printf("USER_OFFSET_X: %d\n", user_off.x_doff); + printf("USER_OFFSET_Y: %d\n", user_off.y_doff); + printf("USER_OFFSET_Z: %d\n", user_off.z_doff); + + /* Get the feature engine flag configurations */ rslt = bma580_get_feat_eng_gp_flags(&gp_flags, &dev); bma5_check_rslt("bma580_get_feat_eng_gp_flags", rslt); - printf("gp_flags.feat_init_stat : %d\n", gp_flags.feat_init_stat); + printf("\ngp_flags.feat_init_stat : %d\n", gp_flags.feat_init_stat); printf("gp_flags.foc_running : %d\n", gp_flags.foc_running); - printf("\nDo not move the board to perform ACCEL FOC\n"); for (;;) { + /* Get the interrupt status */ rslt = bma580_get_int_status(int_status, n_status, &dev); bma5_check_rslt("bma580_get_int_status", rslt); - if (int_status[0].int_status.acc_drdy_int_status & int_status[1].int_status.acc_foc_int_status & BMA5_ENABLE) + /* Check if FOC interrupt occurred */ + if (int_status[1].int_status.acc_foc_int_status & BMA5_ENABLE) { rslt = bma580_set_int_status(int_status, n_status, &dev); bma5_check_rslt("bma580_set_int_status", rslt); @@ -270,11 +340,45 @@ int main(void) } } - printf("\n# Count, Accel_LSB_X, Accel_LSB_Y, Accel_LSB_Z, Acc_ms2_X, Acc_ms2_Y, Acc_ms2_Z\n"); - printf("Reading Accel values after FOC compensation\n"); + /* Get the feature engine configurations */ + rslt = bma580_get_feat_eng_gpr_0(&gpr_0, &dev); + bma5_check_rslt("bma580_get_feat_eng_gpr_0", rslt); + + /* Disable FOC feature */ + gpr_0.acc_foc_en = BMA5_DISABLE; + + rslt = bma580_set_feat_eng_gpr_0(&gpr_0, &dev); + bma5_check_rslt("bma580_set_feat_eng_gpr_0", rslt); + + rslt = bma580_get_feat_eng_gpr_0(&gpr_0, &dev); + bma5_check_rslt("bma580_get_feat_eng_gpr_0", rslt); + + /* Update feature engine */ + gpr_ctrl_host.update_gprs = BMA5_ENABLE; + rslt = bma5_set_feat_eng_gpr_ctrl(&gpr_ctrl_host, &dev); + bma5_check_rslt("bma5_set_feat_eng_gpr_ctrl", rslt); + + sensor_ctrl = BMA5_SENSOR_CTRL_DISABLE; + + /* disable accel */ + rslt = bma5_set_acc_conf_0(sensor_ctrl, &dev); + bma5_check_rslt("bma5_get_acc_conf_0", rslt); + + /* Get the offset values */ + rslt = bma5_get_acc_conf_0(&sensor_ctrl, &dev); + bma5_check_rslt("bma5_get_acc_conf_0", rslt); + + sensor_ctrl = BMA5_SENSOR_CTRL_ENABLE; + + /* Enable accel */ + rslt = bma5_set_acc_conf_0(sensor_ctrl, &dev); + bma5_check_rslt("bma5_get_acc_conf_0", rslt); + + printf("\nReading Accel values after FOC compensation\n"); + printf("#Count, Accel_LSB_X, Accel_LSB_Y, Accel_LSB_Z, Acc_ms2_X, Acc_ms2_Y, Acc_ms2_Z\n"); loop = 0; - while (loop < 10) + while (loop < limit) { for (;;) { @@ -282,31 +386,33 @@ int main(void) rslt = bma5_get_sensor_status(&status, &dev); bma5_check_rslt("bma5_get_sensor_status", rslt); + /* Check if accel data is ready */ if (status.acc_data_rdy) { /* Get accel data ready interrupt status */ rslt = bma580_get_int_status(int_status, n_status, &dev); bma5_check_rslt("bma580_get_int_status", rslt); + /* Check if accel data ready interrupt occurred */ if (int_status[0].int_status.acc_drdy_int_status & BMA580_ACC_DRDY_INT_STATUS_MSK) { rslt = bma5_set_sensor_status(&status, &dev); bma5_check_rslt("bma5_set_sensor_status", rslt); rslt = bma580_set_int_status(int_status, n_status, &dev); - bma5_check_rslt("bma580_set_int_status_int1_0", rslt); + bma5_check_rslt("bma580_set_int_status", rslt); /* Get accel data */ rslt = bma5_get_acc(&sens_data, &dev); bma5_check_rslt("bma5_get_acc", rslt); - /* Converting lsb to mg for 16 bit resolution at 8G range */ - x = lsb_to_ms2(sens_data.x, (float)8, BMA5_16_BIT_RESOLUTION); - y = lsb_to_ms2(sens_data.y, (float)8, BMA5_16_BIT_RESOLUTION); - z = lsb_to_ms2(sens_data.z, (float)8, BMA5_16_BIT_RESOLUTION); + /* Converting lsb to m/s^2 for 16 bit resolution at 8G range */ + x = lsb_to_ms2(sens_data.x, (float)16, BMA5_16_BIT_RESOLUTION); + y = lsb_to_ms2(sens_data.y, (float)16, BMA5_16_BIT_RESOLUTION); + z = lsb_to_ms2(sens_data.z, (float)16, BMA5_16_BIT_RESOLUTION); - /* Print the data in mg */ - printf("%d, %d, %d, %d, %4.2f, %4.2f, %4.2f\n", + /* Print the data in m/s^2 */ + printf("%4d %11d %11d %11d %9.2f %9.2f %9.2f\n", loop + 1, sens_data.x, sens_data.y, @@ -322,13 +428,15 @@ int main(void) loop++; } - printf("Reading the offset values after FOC compensation\n"); + printf("\nReading the accel offset values after FOC compensation\n"); + /* Get the offset values */ rslt = bma5_get_acc_doff(&user_off, &dev); bma5_check_rslt("bma5_get_acc_doff", rslt); - printf("USER_OFFSET_X %d\t USER_OFFSET_Y %d\t USER_OFFSET_Z %d\n", user_off.x_doff, user_off.y_doff, - user_off.z_doff); + printf("USER_OFFSET_X: %d\n", user_off.x_doff); + printf("USER_OFFSET_Y: %d\n", user_off.y_doff); + printf("USER_OFFSET_Z: %d\n", user_off.z_doff); bma5_coines_deinit(); diff --git a/examples/accelerometer/Makefile b/examples/accelerometer/Makefile index 106b56a..34c5ee7 100644 --- a/examples/accelerometer/Makefile +++ b/examples/accelerometer/Makefile @@ -14,5 +14,5 @@ $(COMMON_LOCATION)/common/common.c INCLUDEPATHS += \ $(API_LOCATION) \ $(COMMON_LOCATION)/common - +COINES_BACKEND ?= COINES_BRIDGE include $(COINES_INSTALL_PATH)/coines.mk \ No newline at end of file diff --git a/examples/accelerometer/accelerometer.c b/examples/accelerometer/accelerometer.c index 6a5514e..4c62acd 100644 --- a/examples/accelerometer/accelerometer.c +++ b/examples/accelerometer/accelerometer.c @@ -67,7 +67,7 @@ int main(void) uint8_t n_status = 1; uint8_t loop = 0; float x = 0, y = 0, z = 0; - + uint8_t limit = 50; struct bma5_acc_conf acc_cfg; struct bma580_int_map int_map; struct bma5_accel sens_data; @@ -88,12 +88,12 @@ int main(void) * For I2C : BMA5_I2C_INTF * For SPI : BMA5_SPI_INTF */ - rslt = bma5_interface_init(&dev, BMA5_SPI_INTF, context); + rslt = bma5_interface_init(&dev, BMA5_I2C_INTF, context); bma5_check_rslt("bma5_interface_init", rslt); rslt = bma580_init(&dev); bma5_check_rslt("bma580_init", rslt); - printf("BMA580 Chip ID is 0x%X\n", dev.chip_id); + printf("Chip ID :0x%X\n", dev.chip_id); rslt = bma580_get_int_map(&int_map, &dev); bma5_check_rslt("bma580_get_int_map", rslt); @@ -123,12 +123,26 @@ int main(void) rslt = bma5_set_acc_conf(&acc_cfg, &dev); bma5_check_rslt("bma5_set_acc_conf", rslt); + printf("Accel Configurations:\n"); + printf("ODR : %s\t\n", enum_to_string(BMA5_ACC_ODR_HZ_25)); + printf("BWP : %s\t\n", enum_to_string(BMA5_ACC_BWP_NORM_AVG4)); + printf("Power mode : %s\t\n", enum_to_string(BMA5_POWER_MODE_HPM)); + printf("Range : %s\t\n", enum_to_string(BMA5_ACC_RANGE_MAX_2G)); + printf("IIR : %s\t\n", enum_to_string(BMA5_ACC_IIR_RO_DB_40)); + printf("Noise mode : %s\t\n", enum_to_string(BMA5_NOISE_MODE_LOWER_POWER)); + printf("DRDY auto clear : %s\t\n", enum_to_string(BMA5_ACC_DRDY_INT_AUTO_CLEAR_ENABLED)); + /* Enable accel */ sensor_ctrl = BMA5_SENSOR_CTRL_ENABLE; rslt = bma5_set_acc_conf_0(sensor_ctrl, &dev); bma5_check_rslt("bma5_set_acc_conf_0", rslt); + if (rslt == BMA5_OK) + { + printf("Accel enabled\n"); + } + /* Map hardware interrupt pin configurations */ rslt = bma5_get_int_conf(&int_config, n_conf, &dev); bma5_check_rslt("bma5_get_int_conf", rslt); @@ -140,11 +154,16 @@ int main(void) rslt = bma5_set_int_conf(&int_config, n_conf, &dev); bma5_check_rslt("bma5_set_int_conf", rslt); + printf("Interrupt configurations:\n"); + printf("Int mode : %s\t\n", enum_to_string(BMA5_INT1_MODE_LATCHED)); + printf("Int OD : %s\t\n", enum_to_string(BMA5_INT1_OD_PUSH_PULL)); + printf("Int level : %s\t\n", enum_to_string(BMA5_INT1_LVL_ACTIVE_HIGH)); + printf("Accelerometer data in 2G range\n"); printf("\nCount, Accel_LSB_X, Accel_LSB_Y, Accel_LSB_Z, Acc_ms2_X, Acc_ms2_Y, Acc_ms2_Z\n"); - while (loop < 50) + while (loop < limit) { /* Get accel data ready status */ rslt = bma5_get_sensor_status(&status, &dev); @@ -175,7 +194,7 @@ int main(void) z = lsb_to_ms2(sens_data.z, (float)2, BMA5_16_BIT_RESOLUTION); /* Print the data in m/s2 */ - printf("%d, %d, %d, %d, %4.2f, %4.2f, %4.2f\n", + printf("%4d %11d %11d %11d %9.2f %9.2f %9.2f\n", loop, sens_data.x, sens_data.y, diff --git a/examples/common/common.h b/examples/common/common.h index c3ce0e9..ce39232 100644 --- a/examples/common/common.h +++ b/examples/common/common.h @@ -43,6 +43,14 @@ extern "C" { #include #include "bma5.h" +/******************************************************************************/ +/*! Macro definitions */ + +/*! Enum to string converter*/ +#ifndef enum_to_string +#define enum_to_string(a) #a +#endif + /***************************************************************************/ /*! User function prototypes diff --git a/examples/feature_axis_exchange/Makefile b/examples/feature_axis_exchange/Makefile index 464a466..f87f00f 100644 --- a/examples/feature_axis_exchange/Makefile +++ b/examples/feature_axis_exchange/Makefile @@ -14,5 +14,5 @@ $(COMMON_LOCATION)/common/common.c INCLUDEPATHS += \ $(API_LOCATION) \ $(COMMON_LOCATION)/common - +COINES_BACKEND ?= COINES_BRIDGE include $(COINES_INSTALL_PATH)/coines.mk \ No newline at end of file diff --git a/examples/feature_axis_exchange/feature_axis_exchange.c b/examples/feature_axis_exchange/feature_axis_exchange.c index 760b46c..7863f99 100644 --- a/examples/feature_axis_exchange/feature_axis_exchange.c +++ b/examples/feature_axis_exchange/feature_axis_exchange.c @@ -57,6 +57,7 @@ int main(void) uint8_t n_status = 1; uint8_t gpr_ctrl_host = BMA5_ENABLE; + /*Structure to store the feature axis configurations */ struct bma5_dev dev; struct bma580_feat_axis conf, get_conf; struct bma580_int_map int_map = { 0 }; @@ -66,9 +67,14 @@ int main(void) struct bma580_feat_eng_gpr_0 gpr_0; struct bma5_feat_eng_status feat_eng_status; + /*Generic interrupt 1 configurations */ gen_conf.generic_interrupt = BMA580_GEN_INT_1; set_gen_conf.generic_interrupt = BMA580_GEN_INT_1; + + /* Variable to hold configurations related to interrupt pin */ int_status.int_src = BMA580_INT_STATUS_INT1; + + /* Mapping to hardware interrupt pin on sensor */ int_config.int_src = BMA5_INT_1; /* Assign context parameter selection */ @@ -79,16 +85,18 @@ int main(void) * For I2C : BMA5_I2C_INTF * For SPI : BMA5_SPI_INTF */ - rslt = bma5_interface_init(&dev, BMA5_SPI_INTF, context); + rslt = bma5_interface_init(&dev, BMA5_I2C_INTF, context); bma5_check_rslt("bma5_interface_init", rslt); + /*Initialize the device */ rslt = bma580_init(&dev); bma5_check_rslt("bma580_init", rslt); - printf("BMA580 Chip ID is 0x%X\n", dev.chip_id); + printf("Chip ID :0x%X\n", dev.chip_id); rslt = bma5_get_feat_eng_status(&feat_eng_status, &dev); bma5_check_rslt("bma5_get_feat_eng_status", rslt); + /*Print the feature engine status */ printf("feat_eng_status.feat_eng_gpr_update_pending : %d\n", feat_eng_status.feat_eng_gpr_update_pending); printf("feat_eng_status.feat_eng_halted : %d\n", feat_eng_status.feat_eng_halted); printf("feat_eng_status.feat_eng_running : %d\n", feat_eng_status.feat_eng_running); @@ -105,6 +113,11 @@ int main(void) rslt = bma580_set_feature_axis_config(&conf, &dev); bma5_check_rslt("bma580_set_feature_axis_config", rslt); + if (rslt == BMA5_OK) + { + printf("Feature axis configurations set successfully\n"); + } + rslt = bma580_get_feature_axis_config(&get_conf, &dev); bma5_check_rslt("bma580_get_feature_axis_config", rslt); @@ -113,6 +126,7 @@ int main(void) rslt = bma580_get_generic_int_config(&gen_conf, n_ints, &dev); bma5_check_rslt("bma580_get_generic_int_config", rslt); + /*Set Generic interrupt 1 configurations */ set_gen_conf.gen_int.slope_thres = 0xA; set_gen_conf.gen_int.comb_sel = 0x0; set_gen_conf.gen_int.axis_sel = BMA580_FEAT_AXIS_EX_SEL_Z; @@ -149,11 +163,17 @@ int main(void) rslt = bma580_get_feat_eng_gpr_0(&gpr_0, &dev); bma5_check_rslt("bma580_get_feat_eng_gpr_0", rslt); + /*Enable generic interrupt 1 */ gpr_0.gen_int1_en = BMA5_ENABLE; rslt = bma580_set_feat_eng_gpr_0(&gpr_0, &dev); bma5_check_rslt("bma580_set_feat_eng_gpr_0", rslt); + if (rslt == BMA5_OK) + { + printf("Generic interrupt 1 enabled\n"); + } + rslt = bma5_set_regs(BMA5_REG_FEAT_ENG_GPR_CTRL, &gpr_ctrl_host, 1, &dev); bma5_check_rslt("bma5_set_regs", rslt); @@ -181,13 +201,20 @@ int main(void) rslt = bma5_set_int_conf(&int_config, n_ints, &dev); bma5_check_rslt("bma5_set_int_conf", rslt); + printf("Int configurations:\n"); + printf("Int mode : %s\t\n", enum_to_string(BMA5_INT1_MODE_LATCHED)); + printf("Int OD : %s\t\n", enum_to_string(BMA5_INT1_OD_PUSH_PULL)); + printf("Int level : %s\t\n", enum_to_string(BMA5_INT1_LVL_ACTIVE_HIGH)); + printf("\nShake the board to get generic interrupt 1 interrupt\n"); for (;;) { + /*Get the interrupt status */ rslt = bma580_get_int_status(&int_status, n_status, &dev); bma5_check_rslt("bma580_get_int_status", rslt); + /*Check if generic interrupt 1 interrupt occurred */ if (int_status.int_status.gen_int1_int_status & BMA5_ENABLE) { rslt = bma580_set_int_status(&int_status, n_ints, &dev); @@ -212,32 +239,32 @@ static void feature_axis_selection(const struct bma580_feat_axis *conf) if ((conf->feat_axis_ex == BMA580_FEAT_AXIS_EX_DEFAULT_0) || (conf->feat_axis_ex == BMA580_FEAT_AXIS_EX_DEFAULT_6) || (conf->feat_axis_ex == BMA580_FEAT_AXIS_EX_DEFAULT_7)) { - printf("Selected axis is XYZ\n"); + printf("Selected axis : XYZ\n"); } if (conf->feat_axis_ex == BMA580_FEAT_AXIS_EX_YXZ) { - printf("Selected axis is YXZ\n"); + printf("Selected axis : YXZ\n"); } if (conf->feat_axis_ex == BMA580_FEAT_AXIS_EX_XZY) { - printf("Selected axis is XZY\n"); + printf("Selected axis : XZY\n"); } if (conf->feat_axis_ex == BMA580_FEAT_AXIS_EX_ZXY) { - printf("Selected axis is ZXY\n"); + printf("Selected axis : ZXY\n"); } if (conf->feat_axis_ex == BMA580_FEAT_AXIS_EX_YZX) { - printf("Selected axis is YZX\n"); + printf("Selected axis : YZX\n"); } if (conf->feat_axis_ex == BMA580_FEAT_AXIS_EX_ZYX) { - printf("Selected axis is ZYX\n"); + printf("Selected axis : ZYX\n"); } if (conf->feat_x_inv == BMA580_FEAT_X_INV_DEFAULT) diff --git a/examples/fifo_full_16_bit_dedicated_frame_comp_dis/Makefile b/examples/fifo_full_16_bit_dedicated_frame_comp_dis/Makefile index bf76b48..7aeb7fd 100644 --- a/examples/fifo_full_16_bit_dedicated_frame_comp_dis/Makefile +++ b/examples/fifo_full_16_bit_dedicated_frame_comp_dis/Makefile @@ -14,5 +14,5 @@ $(COMMON_LOCATION)/common/common.c INCLUDEPATHS += \ $(API_LOCATION) \ $(COMMON_LOCATION)/common - +COINES_BACKEND ?= COINES_BRIDGE include $(COINES_INSTALL_PATH)/coines.mk \ No newline at end of file diff --git a/examples/fifo_full_16_bit_dedicated_frame_comp_dis/fifo_full_16_bit_dedicated_frame_comp_dis.c b/examples/fifo_full_16_bit_dedicated_frame_comp_dis/fifo_full_16_bit_dedicated_frame_comp_dis.c index 4994422..8ce6138 100644 --- a/examples/fifo_full_16_bit_dedicated_frame_comp_dis/fifo_full_16_bit_dedicated_frame_comp_dis.c +++ b/examples/fifo_full_16_bit_dedicated_frame_comp_dis/fifo_full_16_bit_dedicated_frame_comp_dis.c @@ -134,21 +134,22 @@ int main(void) /* Initialize FIFO frame structure */ struct bma5_fifo_frame fifoframe = { 0 }; - enum bma5_context context; /* Assign context parameter selection */ + enum bma5_context context; + context = BMA5_SMARTPHONE; /* Interface reference is given as a parameter * For I2C : BMA5_I2C_INTF * For SPI : BMA5_SPI_INTF */ - rslt = bma5_interface_init(&dev, BMA5_SPI_INTF, context); + rslt = bma5_interface_init(&dev, BMA5_I2C_INTF, context); bma5_check_rslt("bma5_interface_init", rslt); rslt = bma580_init(&dev); bma5_check_rslt("bma580_init", rslt); - printf("BMA580 Chip ID is 0x%X\n", dev.chip_id); + printf("Chip ID :0x%X\n", dev.chip_id); rslt = bma580_get_int_map(&int_map, &dev); bma5_check_rslt("bma580_get_int_map", rslt); @@ -157,6 +158,11 @@ int main(void) rslt = bma580_set_int_map(&int_map, &dev); bma5_check_rslt("bma580_set_int_map", rslt); + if (rslt == BMA5_OK) + { + printf("FIFO full interrupt is mapped to INT2\n"); + } + rslt = bma580_get_int_map(&get_int_map, &dev); bma5_check_rslt("bma580_get_int_map", rslt); @@ -203,6 +209,7 @@ static int8_t get_accel_and_int_settings(struct bma5_dev *dev) struct bma5_acc_conf acc_cfg, get_acc_cfg; struct bma5_int_conf_types int_config; + /* Set INT2 as source */ int_config.int_src = BMA5_INT_2; /* Get accel configurations */ @@ -225,27 +232,32 @@ static int8_t get_accel_and_int_settings(struct bma5_dev *dev) rslt = bma5_set_acc_conf(&acc_cfg, dev); bma5_check_rslt("bma5_get_acc_conf", rslt); + printf("Accel configurations\n"); + printf("ODR : %s\t\n", enum_to_string(BMA5_ACC_ODR_HZ_6K4)); + printf("Bandwidth : %s\t\n", enum_to_string(BMA5_ACC_BWP_NORM_AVG4)); + printf("Power mode : %s\t\n", enum_to_string(BMA5_POWER_MODE_HPM)); + printf("Range : %s\t\n", enum_to_string(BMA5_ACC_RANGE_MAX_2G)); + printf("IIR RO : %s\t\n", enum_to_string(BMA5_ACC_IIR_RO_DB_60)); + printf("Noise mode : %s\t\n", enum_to_string(BMA5_NOISE_MODE_LOWER_POWER)); + printf("Auto Int clear : %s\t\n", enum_to_string(BMA5_ACC_DRDY_INT_AUTO_CLEAR_DISABLED)); + /* Enable accel */ sensor_ctrl = BMA5_SENSOR_CTRL_ENABLE; rslt = bma5_set_acc_conf_0(sensor_ctrl, dev); bma5_check_rslt("bma5_set_acc_conf_0", rslt); + if (rslt == BMA5_OK) + { + printf("Accel is enabled\n"); + } + rslt = bma5_get_acc_conf_0(&sensor_ctrl, dev); bma5_check_rslt("bma5_set_acc_conf_0", rslt); rslt = bma5_get_acc_conf(&get_acc_cfg, dev); bma5_check_rslt("bma5_get_acc_conf", rslt); - printf("Sensor CTRL : %d\n", sensor_ctrl); - printf("ODR : %d\n", get_acc_cfg.acc_odr); - printf("BW : %d\n", get_acc_cfg.acc_bwp); - printf("Power mode : %d\n", get_acc_cfg.power_mode); - printf("Range : %d\n", get_acc_cfg.acc_range); - printf("IIR RO : %d\n", get_acc_cfg.acc_iir_ro); - printf("Noise mode : %d\n", get_acc_cfg.noise_mode); - printf("Auto Int clear : %d\n", get_acc_cfg.acc_drdy_int_auto_clear); - rslt = bma5_get_int_conf(&int_config, n_ints, dev); bma5_check_rslt("bma5_get_int_conf", rslt); @@ -256,6 +268,11 @@ static int8_t get_accel_and_int_settings(struct bma5_dev *dev) rslt = bma5_set_int_conf(&int_config, n_ints, dev); bma5_check_rslt("bma5_set_int_conf", rslt); + printf("\nInt2 configurations\n"); + printf("\nInt2 mode : %s\t\n", enum_to_string(BMA5_INT2_MODE_LATCHED)); + printf("Int2 output type : %s\t\n", enum_to_string(BMA5_INT2_OD_PUSH_PULL)); + printf("Int2 level : %s\t\n", enum_to_string(BMA5_INT2_LVL_ACTIVE_HIGH)); + return rslt; } @@ -272,15 +289,6 @@ static int8_t get_fifo_conf(const struct bma5_fifo_conf *fifo_conf, struct bma5_ rslt = bma5_set_fifo_conf(fifo_conf, dev); bma5_check_rslt("bma5_set_fifo_conf", rslt); - printf("\nSet FIFO conf\n"); - printf("fifo en %d\n", fifo_conf->fifo_cfg); - printf("fifo_x_en %d\n", fifo_conf->fifo_acc_x); - printf("fifo_y_en %d\n", fifo_conf->fifo_acc_y); - printf("fifo_z_en %d\n", fifo_conf->fifo_acc_z); - printf("fifo_compression_en %d\n", fifo_conf->fifo_compression); - printf("fifo_sensor_time %d\n", fifo_conf->fifo_sensor_time); - printf("fifo_size %d\n", fifo_conf->fifo_size); - /* Get FIFO configuration register */ rslt = bma5_get_fifo_conf(&read_fifo_conf, dev); bma5_check_rslt("bma5_get_fifo_conf", rslt); @@ -310,18 +318,20 @@ static int8_t get_fifo_full_16_bit_data(struct bma5_sens_fifo_axes_data_16_bit * struct bma580_int_status_types int_status = { 0 }; uint8_t loop = 0; uint16_t idx = 0; + uint8_t iteration = 3; float x = 0, y = 0, z = 0; int_status.int_src = BMA580_INT_STATUS_INT2; - printf("Get FIFO data"); + printf("\nGet FIFO data"); - while (loop < 3) + while (loop < iteration) { /* Get fifo full interrupt 2 status */ rslt = bma580_get_int_status(&int_status, n_status, dev); bma5_check_rslt("bma580_get_int_status", rslt); + /* Check for fifo full interrupt */ if (int_status.int_status.fifo_full_int_status & BMA5_ENABLE) { printf("\n\nIteration %d\n\n", loop); @@ -350,7 +360,7 @@ static int8_t get_fifo_full_16_bit_data(struct bma5_sens_fifo_axes_data_16_bit * z = lsb_to_ms2(fifo_accel_data[idx].z, (float)2, BMA5_16_BIT_RESOLUTION); /* Print the data in m/s2 */ - printf("%d, %d, %d, %d, %4.2f, %4.2f, %4.2f\n", idx, fifo_accel_data[idx].x, + printf("%4d %11d %11d %11d %9.2f %9.2f %9.2f\n", idx, fifo_accel_data[idx].x, fifo_accel_data[idx].y, fifo_accel_data[idx].z, x, y, z); } diff --git a/examples/fifo_full_16_bit_each_frame_comp_dis/Makefile b/examples/fifo_full_16_bit_each_frame_comp_dis/Makefile index e7e1247..6324031 100644 --- a/examples/fifo_full_16_bit_each_frame_comp_dis/Makefile +++ b/examples/fifo_full_16_bit_each_frame_comp_dis/Makefile @@ -14,5 +14,5 @@ $(COMMON_LOCATION)/common/common.c INCLUDEPATHS += \ $(API_LOCATION) \ $(COMMON_LOCATION)/common - +COINES_BACKEND ?= COINES_BRIDGE include $(COINES_INSTALL_PATH)/coines.mk \ No newline at end of file diff --git a/examples/fifo_full_16_bit_each_frame_comp_dis/fifo_full_16_bit_each_frame_comp_dis.c b/examples/fifo_full_16_bit_each_frame_comp_dis/fifo_full_16_bit_each_frame_comp_dis.c index 117e6e4..8d8ae22 100644 --- a/examples/fifo_full_16_bit_each_frame_comp_dis/fifo_full_16_bit_each_frame_comp_dis.c +++ b/examples/fifo_full_16_bit_each_frame_comp_dis/fifo_full_16_bit_each_frame_comp_dis.c @@ -131,25 +131,29 @@ int main(void) /* Initialize FIFO frame structure */ struct bma5_fifo_frame fifoframe = { 0 }; - enum bma5_context context; /* Assign context parameter selection */ + enum bma5_context context; + context = BMA5_SMARTPHONE; /* Interface reference is given as a parameter * For I2C : BMA5_I2C_INTF * For SPI : BMA5_SPI_INTF */ - rslt = bma5_interface_init(&dev, BMA5_I2C_INTF, context); + rslt = bma5_interface_init(&dev, BMA5_SPI_INTF, context); bma5_check_rslt("bma5_interface_init", rslt); + /* Initialize the bma580 sensor */ rslt = bma580_init(&dev); bma5_check_rslt("bma580_init", rslt); - printf("BMA580 Chip ID is 0x%X\n", dev.chip_id); + printf("Chip ID :0x%X\n", dev.chip_id); + /* Map generic interrupts to hardware interrupt pin of the sensor */ rslt = bma580_get_int_map(&int_map, &dev); bma5_check_rslt("bma580_get_int_map", rslt); + /* Set the interrupt pin to INT2 */ int_map.fifo_full_int_map = BMA580_FIFO_FULL_INT_MAP_INT2; rslt = bma580_set_int_map(&int_map, &dev); bma5_check_rslt("bma580_set_int_map", rslt); @@ -222,27 +226,32 @@ static int8_t get_accel_and_int_settings(struct bma5_dev *dev) rslt = bma5_set_acc_conf(&acc_cfg, dev); bma5_check_rslt("bma5_get_acc_conf", rslt); + printf("Accel configurations\n"); + printf("ODR : %s\t\n", enum_to_string(BMA5_ACC_ODR_HZ_6K4)); + printf("Bandwidth : %s\t\n", enum_to_string(BMA5_ACC_BWP_NORM_AVG4)); + printf("Power mode : %s\t\n", enum_to_string(BMA5_POWER_MODE_HPM)); + printf("Range : %s\t\n", enum_to_string(BMA5_ACC_RANGE_MAX_2G)); + printf("IIR RO : %s\t\n", enum_to_string(BMA5_ACC_IIR_RO_DB_60)); + printf("Noise mode : %s\t\n", enum_to_string(BMA5_NOISE_MODE_LOWER_POWER)); + printf("Auto Int clear : %s\t\n", enum_to_string(BMA5_ACC_DRDY_INT_AUTO_CLEAR_DISABLED)); + /* Enable accel */ sensor_ctrl = BMA5_SENSOR_CTRL_ENABLE; rslt = bma5_set_acc_conf_0(sensor_ctrl, dev); bma5_check_rslt("bma5_set_acc_conf_0", rslt); + if (rslt == BMA5_OK) + { + printf("\nAccel enabled\n"); + } + rslt = bma5_get_acc_conf_0(&sensor_ctrl, dev); bma5_check_rslt("bma5_set_acc_conf_0", rslt); rslt = bma5_get_acc_conf(&get_acc_cfg, dev); bma5_check_rslt("bma5_get_acc_conf", rslt); - printf("Sensor CTRL : %d\n", sensor_ctrl); - printf("ODR : %d\n", get_acc_cfg.acc_odr); - printf("BW : %d\n", get_acc_cfg.acc_bwp); - printf("Power mode : %d\n", get_acc_cfg.power_mode); - printf("Range : %d\n", get_acc_cfg.acc_range); - printf("IIR RO : %d\n", get_acc_cfg.acc_iir_ro); - printf("Noise mode : %d\n", get_acc_cfg.noise_mode); - printf("Auto Int clear : %d\n", get_acc_cfg.acc_drdy_int_auto_clear); - rslt = bma5_get_int_conf(&int_config, n_ints, dev); bma5_check_rslt("bma5_get_int_conf", rslt); @@ -250,6 +259,11 @@ static int8_t get_accel_and_int_settings(struct bma5_dev *dev) int_config.int_conf.int_od = BMA5_INT2_OD_PUSH_PULL; int_config.int_conf.int_lvl = BMA5_INT2_LVL_ACTIVE_HIGH; + printf("\nInt configurations\n"); + printf("Int mode : %s\t\n", enum_to_string(BMA5_INT2_MODE_LATCHED)); + printf("Int OD : %s\t\n", enum_to_string(BMA5_INT2_OD_PUSH_PULL)); + printf("Int level : %s\t\n", enum_to_string(BMA5_INT2_LVL_ACTIVE_HIGH)); + rslt = bma5_set_int_conf(&int_config, n_ints, dev); bma5_check_rslt("bma5_set_int_conf", rslt); @@ -269,14 +283,14 @@ static int8_t get_fifo_conf(const struct bma5_fifo_conf *fifo_conf, struct bma5_ rslt = bma5_set_fifo_conf(fifo_conf, dev); bma5_check_rslt("bma5_set_fifo_conf", rslt); - printf("\nSet FIFO conf\n"); - printf("fifo en %d\n", fifo_conf->fifo_cfg); - printf("fifo_x_en %d\n", fifo_conf->fifo_acc_x); - printf("fifo_y_en %d\n", fifo_conf->fifo_acc_y); - printf("fifo_z_en %d\n", fifo_conf->fifo_acc_z); - printf("fifo_compression_en %d\n", fifo_conf->fifo_compression); - printf("fifo_sensor_time %d\n", fifo_conf->fifo_sensor_time); - printf("fifo_size %d\n", fifo_conf->fifo_size); + printf("\nFIFO conf\n"); + printf("fifo en %s\t\n", enum_to_string(BMA5_FIFO_CFG_ENABLE)); + printf("fifo_x_en %s\t\n", enum_to_string(BMA5_FIFO_ACC_X_ENABLE)); + printf("fifo_y_en %s\t\n", enum_to_string(BMA5_FIFO_ACC_Y_ENABLE)); + printf("fifo_z_en %s\t\n", enum_to_string(BMA5_FIFO_ACC_Z_ENABLE)); + printf("fifo_compression_en %s\t\n", enum_to_string(BMA5_FIFO_COMPRESSION_ACC_8BIT)); + printf("fifo_sensor_time %s\t\n", enum_to_string(BMA5_FIFO_SENSOR_TIME_EACH_FRAME)); + printf("fifo_size %s\t\n", enum_to_string(BMA5_FIFO_SIZE_MAX_512_BYTES)); /* Get FIFO configuration register */ rslt = bma5_get_fifo_conf(&read_fifo_conf, dev); @@ -307,13 +321,14 @@ static int8_t get_fifo_full_16_bit_data(struct bma5_sens_fifo_axes_data_16_bit * struct bma580_int_status_types int_status = { 0 }; uint8_t loop = 0; uint16_t idx = 0; + uint8_t iteration = 3; float x = 0, y = 0, z = 0; int_status.int_src = BMA580_INT_STATUS_INT2; - printf("Get FIFO data"); + printf("\nGet FIFO data"); - while (loop < 3) + while (loop < iteration) { /* Get fifo full interrupt 2 status */ rslt = bma580_get_int_status(&int_status, n_status, dev); @@ -348,7 +363,7 @@ static int8_t get_fifo_full_16_bit_data(struct bma5_sens_fifo_axes_data_16_bit * z = lsb_to_ms2(fifo_accel_data[idx].z, (float)2, BMA5_16_BIT_RESOLUTION); /* Print the data in m/s2 */ - printf("%d, %d, %d, %d, %4.2f, %4.2f, %4.2f, %.4lf s\n", + printf("%4d %11d %11d %11d %9.2f %9.2f %9.2f %10.4lf s\n", idx, fifo_accel_data[idx].x, fifo_accel_data[idx].y, diff --git a/examples/fifo_full_8_bit_dedicated_frame_comp_en/Makefile b/examples/fifo_full_8_bit_dedicated_frame_comp_en/Makefile index d925293..8036916 100644 --- a/examples/fifo_full_8_bit_dedicated_frame_comp_en/Makefile +++ b/examples/fifo_full_8_bit_dedicated_frame_comp_en/Makefile @@ -14,5 +14,5 @@ $(COMMON_LOCATION)/common/common.c INCLUDEPATHS += \ $(API_LOCATION) \ $(COMMON_LOCATION)/common - +COINES_BACKEND ?= COINES_BRIDGE include $(COINES_INSTALL_PATH)/coines.mk \ No newline at end of file diff --git a/examples/fifo_full_8_bit_dedicated_frame_comp_en/fifo_full_8_bit_dedicated_frame_comp_en.c b/examples/fifo_full_8_bit_dedicated_frame_comp_en/fifo_full_8_bit_dedicated_frame_comp_en.c index 8d7776f..68d8d22 100644 --- a/examples/fifo_full_8_bit_dedicated_frame_comp_en/fifo_full_8_bit_dedicated_frame_comp_en.c +++ b/examples/fifo_full_8_bit_dedicated_frame_comp_en/fifo_full_8_bit_dedicated_frame_comp_en.c @@ -135,21 +135,22 @@ int main(void) /* Initialize FIFO frame structure */ struct bma5_fifo_frame fifoframe = { 0 }; + /* Assign context parameter selection */ enum bma5_context context; - /* Assign context parameter selection */ context = BMA5_SMARTPHONE; /* Interface reference is given as a parameter * For I2C : BMA5_I2C_INTF * For SPI : BMA5_SPI_INTF */ - rslt = bma5_interface_init(&dev, BMA5_SPI_INTF, context); + rslt = bma5_interface_init(&dev, BMA5_I2C_INTF, context); bma5_check_rslt("bma5_interface_init", rslt); + /* Initialize the device */ rslt = bma580_init(&dev); bma5_check_rslt("bma580_init", rslt); - printf("BMA580 Chip ID is 0x%X\n", dev.chip_id); + printf("Chip ID :0x%X\n", dev.chip_id); rslt = bma580_get_int_map(&int_map, &dev); bma5_check_rslt("bma580_get_int_map", rslt); @@ -223,27 +224,32 @@ static int8_t get_accel_and_int_settings(struct bma5_dev *dev) rslt = bma5_set_acc_conf(&acc_cfg, dev); bma5_check_rslt("bma5_get_acc_conf", rslt); + printf("Accel Configurations:\n"); + printf("ODR : %s\t\n", enum_to_string(BMA5_ACC_ODR_HZ_6K4)); + printf("Bandwidth : %s\t\n", enum_to_string(BMA5_ACC_BWP_NORM_AVG4)); + printf("Power mode : %s\t\n", enum_to_string(BMA5_POWER_MODE_HPM)); + printf("Range : %s\t\n", enum_to_string(BMA5_ACC_RANGE_MAX_2G)); + printf("IIR RO : %s\t\n", enum_to_string(BMA5_ACC_IIR_RO_DB_60)); + printf("Noise mode : %s\t\n", enum_to_string(BMA5_NOISE_MODE_LOWER_POWER)); + printf("Auto Int clear : %s\t\n", enum_to_string(BMA5_ACC_DRDY_INT_AUTO_CLEAR_DISABLED)); + /* Enable accel */ sensor_ctrl = BMA5_SENSOR_CTRL_ENABLE; rslt = bma5_set_acc_conf_0(sensor_ctrl, dev); bma5_check_rslt("bma5_set_acc_conf_0", rslt); + if (rslt == BMA5_OK) + { + printf("Accel is enabled\n"); + } + rslt = bma5_get_acc_conf_0(&sensor_ctrl, dev); bma5_check_rslt("bma5_set_acc_conf_0", rslt); rslt = bma5_get_acc_conf(&get_acc_cfg, dev); bma5_check_rslt("bma5_get_acc_conf", rslt); - printf("Sensor CTRL : %d\n", sensor_ctrl); - printf("ODR : %d\n", get_acc_cfg.acc_odr); - printf("BW : %d\n", get_acc_cfg.acc_bwp); - printf("Power mode : %d\n", get_acc_cfg.power_mode); - printf("Range : %d\n", get_acc_cfg.acc_range); - printf("IIR RO : %d\n", get_acc_cfg.acc_iir_ro); - printf("Noise mode : %d\n", get_acc_cfg.noise_mode); - printf("Auto Int clear : %d\n", get_acc_cfg.acc_drdy_int_auto_clear); - rslt = bma5_get_int_conf(&int_config, n_ints, dev); bma5_check_rslt("bma5_get_int_conf", rslt); @@ -254,6 +260,11 @@ static int8_t get_accel_and_int_settings(struct bma5_dev *dev) rslt = bma5_set_int_conf(&int_config, n_ints, dev); bma5_check_rslt("bma5_set_int_conf", rslt); + printf("Int Configurations:\n"); + printf("Int mode : %s\t\n", enum_to_string(BMA5_INT2_MODE_LATCHED)); + printf("Int OD : %s\t\n", enum_to_string(BMA5_INT2_OD_PUSH_PULL)); + printf("Int level : %s\t\n", enum_to_string(BMA5_INT2_LVL_ACTIVE_HIGH)); + return rslt; } @@ -270,14 +281,15 @@ static int8_t get_fifo_conf(const struct bma5_fifo_conf *fifo_conf, struct bma5_ rslt = bma5_set_fifo_conf(fifo_conf, dev); bma5_check_rslt("bma5_set_fifo_conf", rslt); - printf("\nSet FIFO conf\n"); - printf("fifo en %d\n", fifo_conf->fifo_cfg); - printf("fifo_x_en %d\n", fifo_conf->fifo_acc_x); - printf("fifo_y_en %d\n", fifo_conf->fifo_acc_y); - printf("fifo_z_en %d\n", fifo_conf->fifo_acc_z); - printf("fifo_compression_en %d\n", fifo_conf->fifo_compression); - printf("fifo_sensor_time %d\n", fifo_conf->fifo_sensor_time); - printf("fifo_size %d\n", fifo_conf->fifo_size); + printf("\nFIFO conf\n"); + printf("Fifo en : %s\t\n", enum_to_string(BMA5_FIFO_CFG_ENABLE)); + printf("Fifo x en : %s\t\n", enum_to_string(BMA5_FIFO_ACC_X_ENABLE)); + printf("Fifo y en : %s\t\n", enum_to_string(BMA5_FIFO_ACC_Y_ENABLE)); + printf("Fifo z en : %s\t\n", enum_to_string(BMA5_FIFO_ACC_Z_ENABLE)); + printf("Fifo compression en : %s\t\n", enum_to_string(BMA5_FIFO_COMPRESSION_ACC_8BIT)); + printf("Fifo sensor time : %s\t\n", enum_to_string(BMA5_FIFO_SENSOR_TIME_DEDICATED_FRAME)); + printf("Fifo size : %s\t\n", enum_to_string(BMA5_FIFO_SIZE_MAX_512_BYTES)); + printf("Fifo stop on full : %s\t\n", enum_to_string(BMA5_ENABLE)); /* Get FIFO configuration register */ rslt = bma5_get_fifo_conf(&read_fifo_conf, dev); @@ -309,17 +321,20 @@ static int8_t get_fifo_full_8_bit_data(struct bma5_sens_fifo_axes_data_8_bit *fi uint8_t loop = 0; uint16_t idx = 0; float x = 0, y = 0, z = 0; + uint8_t iteration = 3; + /* Get the interrupt status */ int_status.int_src = BMA580_INT_STATUS_INT2; - printf("Get FIFO data"); + printf("\nGet FIFO data"); - while (loop < 3) + while (loop < iteration) { /* Get fifo full interrupt 2 status */ rslt = bma580_get_int_status(&int_status, n_status, dev); bma5_check_rslt("bma580_get_int_status", rslt); + /* Check for fifo full interrupt */ if (int_status.int_status.fifo_full_int_status & BMA5_ENABLE) { printf("\n\nIteration %d\n\n", loop); @@ -347,7 +362,7 @@ static int8_t get_fifo_full_8_bit_data(struct bma5_sens_fifo_axes_data_8_bit *fi z = lsb_to_ms2(fifo_accel_data[idx].z, (float)2, BMA5_8_BIT_RESOLUTION); /* Print the data in m/s2 */ - printf("%d, %d, %d, %d, %4.2f, %4.2f, %4.2f\n", idx, fifo_accel_data[idx].x, + printf("%4d %11d %11d %11d %9.2f %9.2f %9.2f\n", idx, fifo_accel_data[idx].x, fifo_accel_data[idx].y, fifo_accel_data[idx].z, x, y, z); } diff --git a/examples/fifo_full_8_bit_each_frame_comp_en/Makefile b/examples/fifo_full_8_bit_each_frame_comp_en/Makefile index 38f72f6..65f5bf3 100644 --- a/examples/fifo_full_8_bit_each_frame_comp_en/Makefile +++ b/examples/fifo_full_8_bit_each_frame_comp_en/Makefile @@ -14,5 +14,5 @@ $(COMMON_LOCATION)/common/common.c INCLUDEPATHS += \ $(API_LOCATION) \ $(COMMON_LOCATION)/common - +COINES_BACKEND ?= COINES_BRIDGE include $(COINES_INSTALL_PATH)/coines.mk \ No newline at end of file diff --git a/examples/fifo_full_8_bit_each_frame_comp_en/fifo_full_8_bit_each_frame_comp_en.c b/examples/fifo_full_8_bit_each_frame_comp_en/fifo_full_8_bit_each_frame_comp_en.c index 18d9e6d..b002c8d 100644 --- a/examples/fifo_full_8_bit_each_frame_comp_en/fifo_full_8_bit_each_frame_comp_en.c +++ b/examples/fifo_full_8_bit_each_frame_comp_en/fifo_full_8_bit_each_frame_comp_en.c @@ -132,21 +132,21 @@ int main(void) /* Initialize FIFO frame structure */ struct bma5_fifo_frame fifoframe = { 0 }; + /* Assign context parameter selection */ enum bma5_context context; - /* Assign context parameter selection */ context = BMA5_SMARTPHONE; /* Interface reference is given as a parameter * For I2C : BMA5_I2C_INTF * For SPI : BMA5_SPI_INTF */ - rslt = bma5_interface_init(&dev, BMA5_I2C_INTF, context); + rslt = bma5_interface_init(&dev, BMA5_SPI_INTF, context); bma5_check_rslt("bma5_interface_init", rslt); rslt = bma580_init(&dev); bma5_check_rslt("bma580_init", rslt); - printf("BMA580 Chip ID is 0x%X\n", dev.chip_id); + printf("Chip ID :0x%X\n", dev.chip_id); rslt = bma580_get_int_map(&int_map, &dev); bma5_check_rslt("bma580_get_int_map", rslt); @@ -220,27 +220,32 @@ static int8_t get_accel_and_int_settings(struct bma5_dev *dev) rslt = bma5_set_acc_conf(&acc_cfg, dev); bma5_check_rslt("bma5_get_acc_conf", rslt); + printf("Accel Configurations\n"); + printf("ODR : %s\t\n", enum_to_string(BMA5_ACC_ODR_HZ_6K4)); + printf("BWP : %s\t\n", enum_to_string(BMA5_ACC_BWP_NORM_AVG4)); + printf("Power mode : %s\t\n", enum_to_string(BMA5_POWER_MODE_HPM)); + printf("Range : %s\t\n", enum_to_string(BMA5_ACC_RANGE_MAX_2G)); + printf("IIR Filter : %s\t\n", enum_to_string(BMA5_ACC_IIR_RO_DB_60)); + printf("Noise Mode : %s\t\n", enum_to_string(BMA5_NOISE_MODE_LOWER_POWER)); + printf("DRDY Auto Clear : %s\t\n", enum_to_string(BMA5_ACC_DRDY_INT_AUTO_CLEAR_DISABLED)); + /* Enable accel */ sensor_ctrl = BMA5_SENSOR_CTRL_ENABLE; rslt = bma5_set_acc_conf_0(sensor_ctrl, dev); bma5_check_rslt("bma5_set_acc_conf_0", rslt); + if (rslt == BMA5_OK) + { + printf("Accel is enabled\n"); + } + rslt = bma5_get_acc_conf_0(&sensor_ctrl, dev); bma5_check_rslt("bma5_set_acc_conf_0", rslt); rslt = bma5_get_acc_conf(&get_acc_cfg, dev); bma5_check_rslt("bma5_get_acc_conf", rslt); - printf("Sensor CTRL : %d\n", sensor_ctrl); - printf("ODR : %d\n", get_acc_cfg.acc_odr); - printf("BW : %d\n", get_acc_cfg.acc_bwp); - printf("Power mode : %d\n", get_acc_cfg.power_mode); - printf("Range : %d\n", get_acc_cfg.acc_range); - printf("IIR RO : %d\n", get_acc_cfg.acc_iir_ro); - printf("Noise mode : %d\n", get_acc_cfg.noise_mode); - printf("Auto Int clear : %d\n", get_acc_cfg.acc_drdy_int_auto_clear); - rslt = bma5_get_int_conf(&int_config, n_ints, dev); bma5_check_rslt("bma5_get_int_conf", rslt); @@ -251,6 +256,11 @@ static int8_t get_accel_and_int_settings(struct bma5_dev *dev) rslt = bma5_set_int_conf(&int_config, n_ints, dev); bma5_check_rslt("bma5_set_int_conf", rslt); + printf("Interrupt Configurations\n"); + printf("Int mode : %s\t\n", enum_to_string(BMA5_INT1_MODE_LATCHED)); + printf("Int OD : %s\t\n", enum_to_string(BMA5_INT1_OD_PUSH_PULL)); + printf("Int Level : %s\t\n", enum_to_string(BMA5_INT1_LVL_ACTIVE_HIGH)); + return rslt; } @@ -267,14 +277,14 @@ static int8_t get_fifo_conf(const struct bma5_fifo_conf *fifo_conf, struct bma5_ rslt = bma5_set_fifo_conf(fifo_conf, dev); bma5_check_rslt("bma5_set_fifo_conf", rslt); - printf("\nSet FIFO conf\n"); - printf("fifo en %d\n", fifo_conf->fifo_cfg); - printf("fifo_x_en %d\n", fifo_conf->fifo_acc_x); - printf("fifo_y_en %d\n", fifo_conf->fifo_acc_y); - printf("fifo_z_en %d\n", fifo_conf->fifo_acc_z); - printf("fifo_compression_en %d\n", fifo_conf->fifo_compression); - printf("fifo_sensor_time %d\n", fifo_conf->fifo_sensor_time); - printf("fifo_size %d\n", fifo_conf->fifo_size); + printf("\nFIFO conf\n"); + printf("Fifo en : %s\t\n", enum_to_string(BMA5_FIFO_CFG_ENABLE)); + printf("Fifo x en : %s\t\n", enum_to_string(BMA5_FIFO_ACC_X_ENABLE)); + printf("Fifo y en : %s\t\n", enum_to_string(BMA5_FIFO_ACC_Y_ENABLE)); + printf("Fifo z en : %s\t\n", enum_to_string(BMA5_FIFO_ACC_Z_ENABLE)); + printf("Fifo compression en : %s\t\n", enum_to_string(BMA5_FIFO_COMPRESSION_ACC_8BIT)); + printf("Fifo sensor time : %s\t\n", enum_to_string(BMA5_FIFO_SENSOR_TIME_EACH_FRAME)); + printf("Fifo size : %s\t\n", enum_to_string(BMA5_FIFO_SIZE_MAX_512_BYTES)); /* Get FIFO configuration register */ rslt = bma5_get_fifo_conf(&read_fifo_conf, dev); @@ -306,12 +316,13 @@ static int8_t get_fifo_full_8_bit_data(struct bma5_sens_fifo_axes_data_8_bit *fi uint8_t loop = 0; uint16_t idx = 0; float x = 0, y = 0, z = 0; + uint8_t iteration = 3; int_status.int_src = BMA580_INT_STATUS_INT1; - printf("Get FIFO data"); + printf("\nGet FIFO data"); - while (loop < 3) + while (loop < iteration) { /* Get fifo full interrupt 2 status */ rslt = bma580_get_int_status(&int_status, n_status, dev); @@ -345,7 +356,7 @@ static int8_t get_fifo_full_8_bit_data(struct bma5_sens_fifo_axes_data_8_bit *fi z = lsb_to_ms2(fifo_accel_data[idx].z, (float)2, BMA5_8_BIT_RESOLUTION); /* Print the data in m/s2 */ - printf("%d, %d, %d, %d, %4.2f, %4.2f, %4.2f, %.4lf s\n", + printf("%4d %11d %11d %11d %9.2f %9.2f %9.2f %10.4lf s\n", idx, fifo_accel_data[idx].x, fifo_accel_data[idx].y, diff --git a/examples/fifo_wm_16_bit_dedicated_frame_comp_dis/Makefile b/examples/fifo_wm_16_bit_dedicated_frame_comp_dis/Makefile index 08c6d52..5481cd6 100644 --- a/examples/fifo_wm_16_bit_dedicated_frame_comp_dis/Makefile +++ b/examples/fifo_wm_16_bit_dedicated_frame_comp_dis/Makefile @@ -14,5 +14,5 @@ $(COMMON_LOCATION)/common/common.c INCLUDEPATHS += \ $(API_LOCATION) \ $(COMMON_LOCATION)/common - +COINES_BACKEND ?= COINES_BRIDGE include $(COINES_INSTALL_PATH)/coines.mk \ No newline at end of file diff --git a/examples/fifo_wm_16_bit_dedicated_frame_comp_dis/fifo_wm_16_bit_dedicated_frame_comp_dis.c b/examples/fifo_wm_16_bit_dedicated_frame_comp_dis/fifo_wm_16_bit_dedicated_frame_comp_dis.c index 9fed991..ad371a5 100644 --- a/examples/fifo_wm_16_bit_dedicated_frame_comp_dis/fifo_wm_16_bit_dedicated_frame_comp_dis.c +++ b/examples/fifo_wm_16_bit_dedicated_frame_comp_dis/fifo_wm_16_bit_dedicated_frame_comp_dis.c @@ -137,24 +137,25 @@ int main(void) /* Initialize FIFO frame structure */ struct bma5_fifo_frame fifoframe = { 0 }; - enum bma5_context context; /* Set FIFO water-mark level */ uint16_t fifo_watermark_level = WATERMARK_LEVEL; /* Assign context parameter selection */ + enum bma5_context context; + context = BMA5_SMARTPHONE; /* Interface reference is given as a parameter * For I2C : BMA5_I2C_INTF * For SPI : BMA5_SPI_INTF */ - rslt = bma5_interface_init(&dev, BMA5_I2C_INTF, context); + rslt = bma5_interface_init(&dev, BMA5_SPI_INTF, context); bma5_check_rslt("bma5_interface_init", rslt); rslt = bma580_init(&dev); bma5_check_rslt("bma580_init", rslt); - printf("BMA580 Chip ID is 0x%X\n", dev.chip_id); + printf("Chip ID :0x%X\n", dev.chip_id); rslt = bma580_get_int_map(&int_map, &dev); bma5_check_rslt("bma580_get_int_map", rslt); @@ -163,6 +164,11 @@ int main(void) rslt = bma580_set_int_map(&int_map, &dev); bma5_check_rslt("bma580_set_int_map", rslt); + if (rslt == BMA5_OK) + { + printf("FIFO full interrupt mapped to INT2\n"); + } + rslt = bma580_get_int_map(&get_int_map, &dev); bma5_check_rslt("bma580_get_int_map", rslt); @@ -234,27 +240,32 @@ static int8_t get_accel_and_int_settings(struct bma5_dev *dev) rslt = bma5_set_acc_conf(&acc_cfg, dev); bma5_check_rslt("bma5_get_acc_conf", rslt); + printf("\nAccel configurations\n"); + printf("ODR : %s\t\n", enum_to_string(BMA5_ACC_ODR_HZ_6K4)); + printf("Bandwidth : %s\t\n", enum_to_string(BMA5_ACC_BWP_NORM_AVG4)); + printf("Power mode : %s\t\n", enum_to_string(BMA5_POWER_MODE_HPM)); + printf("Range : %s\t\n", enum_to_string(BMA5_ACC_RANGE_MAX_2G)); + printf("IIR RO : %s\t\n", enum_to_string(BMA5_ACC_IIR_RO_DB_60)); + printf("Noise mode : %s\t\n", enum_to_string(BMA5_NOISE_MODE_LOWER_POWER)); + printf("Auto Int clear : %s\t\n", enum_to_string(BMA5_ACC_DRDY_INT_AUTO_CLEAR_DISABLED)); + /* Enable accel */ sensor_ctrl = BMA5_SENSOR_CTRL_ENABLE; rslt = bma5_set_acc_conf_0(sensor_ctrl, dev); bma5_check_rslt("bma5_set_acc_conf_0", rslt); + if (rslt == BMA5_OK) + { + printf("\nAccel enabled\n"); + } + rslt = bma5_get_acc_conf_0(&sensor_ctrl, dev); bma5_check_rslt("bma5_set_acc_conf_0", rslt); rslt = bma5_get_acc_conf(&get_acc_cfg, dev); bma5_check_rslt("bma5_get_acc_conf", rslt); - printf("Sensor CTRL : %d\n", sensor_ctrl); - printf("ODR : %d\n", get_acc_cfg.acc_odr); - printf("BW : %d\n", get_acc_cfg.acc_bwp); - printf("Power mode : %d\n", get_acc_cfg.power_mode); - printf("Range : %d\n", get_acc_cfg.acc_range); - printf("IIR RO : %d\n", get_acc_cfg.acc_iir_ro); - printf("Noise mode : %d\n", get_acc_cfg.noise_mode); - printf("Auto Int clear : %d\n", get_acc_cfg.acc_drdy_int_auto_clear); - rslt = bma5_get_int_conf(&int_config, n_ints, dev); bma5_check_rslt("bma5_get_int_conf", rslt); @@ -265,6 +276,11 @@ static int8_t get_accel_and_int_settings(struct bma5_dev *dev) rslt = bma5_set_int_conf(&int_config, n_ints, dev); bma5_check_rslt("bma5_set_int_conf", rslt); + printf("\nInt Configurations\n\n"); + printf("Int mode : %s\t\n", enum_to_string(BMA5_INT2_MODE_LATCHED)); + printf("Int push-pull : %s\t\n", enum_to_string(BMA5_INT2_OD_PUSH_PULL)); + printf("Int level : %s\t\n", enum_to_string(BMA5_INT2_LVL_ACTIVE_HIGH)); + return rslt; } @@ -281,14 +297,14 @@ static int8_t get_fifo_conf(const struct bma5_fifo_conf *fifo_conf, struct bma5_ rslt = bma5_set_fifo_conf(fifo_conf, dev); bma5_check_rslt("bma5_set_fifo_conf", rslt); - printf("\nSet FIFO conf\n"); - printf("fifo en %d\n", fifo_conf->fifo_cfg); - printf("fifo_x_en %d\n", fifo_conf->fifo_acc_x); - printf("fifo_y_en %d\n", fifo_conf->fifo_acc_y); - printf("fifo_z_en %d\n", fifo_conf->fifo_acc_z); - printf("fifo_compression_en %d\n", fifo_conf->fifo_compression); - printf("fifo_sensor_time %d\n", fifo_conf->fifo_sensor_time); - printf("fifo_size %d\n", fifo_conf->fifo_size); + printf("\nFIFO conf\n"); + printf("fifo en %s\t\n", enum_to_string(BMA5_FIFO_CFG_ENABLE)); + printf("fifo_x_en %s\t\n", enum_to_string(BMA5_FIFO_ACC_X_ENABLE)); + printf("fifo_y_en %s\t\n", enum_to_string(BMA5_FIFO_ACC_Y_ENABLE)); + printf("fifo_z_en %s\t\n", enum_to_string(BMA5_FIFO_ACC_Z_ENABLE)); + printf("fifo_compression_en %s\t\n", enum_to_string(BMA5_FIFO_COMPRESSION_ACC_8BIT)); + printf("fifo_sensor_time %s\t\n", enum_to_string(BMA5_FIFO_SENSOR_TIME_EACH_FRAME)); + printf("fifo_size %s\t\n", enum_to_string(BMA5_FIFO_SIZE_MAX_512_BYTES)); /* Get FIFO configuration register */ rslt = bma5_get_fifo_conf(&read_fifo_conf, dev); @@ -319,13 +335,14 @@ static int8_t get_fifo_full_16_bit_data(struct bma5_sens_fifo_axes_data_16_bit * struct bma580_int_status_types int_status = { 0 }; uint8_t loop = 0; uint16_t idx = 0; + uint8_t iteration = 3; float x = 0, y = 0, z = 0; int_status.int_src = BMA580_INT_STATUS_INT2; - printf("Get FIFO data"); + printf("\nGet FIFO data"); - while (loop < 3) + while (loop < iteration) { /* Get fifo full interrupt 2 status */ rslt = bma580_get_int_status(&int_status, n_status, dev); @@ -359,7 +376,7 @@ static int8_t get_fifo_full_16_bit_data(struct bma5_sens_fifo_axes_data_16_bit * z = lsb_to_ms2(fifo_accel_data[idx].z, (float)2, BMA5_16_BIT_RESOLUTION); /* Print the data in m/s2 */ - printf("%d, %d, %d, %d, %4.2f, %4.2f, %4.2f\n", idx, fifo_accel_data[idx].x, + printf("%4d %11d %11d %11d %9.2f %9.2f %9.2f\n", idx, fifo_accel_data[idx].x, fifo_accel_data[idx].y, fifo_accel_data[idx].z, x, y, z); } diff --git a/examples/fifo_wm_16_bit_each_frame_comp_dis/Makefile b/examples/fifo_wm_16_bit_each_frame_comp_dis/Makefile index 9fa9b01..636bf2f 100644 --- a/examples/fifo_wm_16_bit_each_frame_comp_dis/Makefile +++ b/examples/fifo_wm_16_bit_each_frame_comp_dis/Makefile @@ -14,5 +14,5 @@ $(COMMON_LOCATION)/common/common.c INCLUDEPATHS += \ $(API_LOCATION) \ $(COMMON_LOCATION)/common - +COINES_BACKEND ?= COINES_BRIDGE include $(COINES_INSTALL_PATH)/coines.mk \ No newline at end of file diff --git a/examples/fifo_wm_16_bit_each_frame_comp_dis/fifo_wm_16_bit_each_frame_comp_dis.c b/examples/fifo_wm_16_bit_each_frame_comp_dis/fifo_wm_16_bit_each_frame_comp_dis.c index 854d9f9..da51cff 100644 --- a/examples/fifo_wm_16_bit_each_frame_comp_dis/fifo_wm_16_bit_each_frame_comp_dis.c +++ b/examples/fifo_wm_16_bit_each_frame_comp_dis/fifo_wm_16_bit_each_frame_comp_dis.c @@ -137,25 +137,29 @@ int main(void) /* Initialize FIFO frame structure */ struct bma5_fifo_frame fifoframe = { 0 }; - enum bma5_context context; /* Assign context parameter selection */ + enum bma5_context context; + context = BMA5_SMARTPHONE; /* Interface reference is given as a parameter * For I2C : BMA5_I2C_INTF * For SPI : BMA5_SPI_INTF */ - rslt = bma5_interface_init(&dev, BMA5_I2C_INTF, context); + rslt = bma5_interface_init(&dev, BMA5_SPI_INTF, context); bma5_check_rslt("bma5_interface_init", rslt); + /* Initialize BMA580 */ rslt = bma580_init(&dev); bma5_check_rslt("bma580_init", rslt); - printf("BMA580 Chip ID is 0x%X\n", dev.chip_id); + printf("Chip ID :0x%X\n", dev.chip_id); + /* Map generic interrupts to hardware interrupt pin of the sensor */ rslt = bma580_get_int_map(&int_map, &dev); bma5_check_rslt("bma580_get_int_map", rslt); + /* Set FIFO full interrupt to INT2 */ int_map.fifo_full_int_map = BMA580_FIFO_FULL_INT_MAP_INT2; rslt = bma580_set_int_map(&int_map, &dev); bma5_check_rslt("bma580_set_int_map", rslt); @@ -231,27 +235,32 @@ static int8_t get_accel_and_int_settings(struct bma5_dev *dev) rslt = bma5_set_acc_conf(&acc_cfg, dev); bma5_check_rslt("bma5_get_acc_conf", rslt); + printf("Accel configurations\n"); + printf("ODR : %s\t\n", enum_to_string(BMA5_ACC_ODR_HZ_6K4)); + printf("Bandwidth : %s\t\n", enum_to_string(BMA5_ACC_BWP_NORM_AVG4)); + printf("Power mode : %s\t\n", enum_to_string(BMA5_POWER_MODE_HPM)); + printf("Range : %s\t\n", enum_to_string(BMA5_ACC_RANGE_MAX_2G)); + printf("IIR RO : %s\t\n", enum_to_string(BMA5_ACC_IIR_RO_DB_60)); + printf("Noise mode : %s\t\n", enum_to_string(BMA5_NOISE_MODE_LOWER_POWER)); + printf("Auto Int clear : %s\t\n", enum_to_string(BMA5_ACC_DRDY_INT_AUTO_CLEAR_DISABLED)); + /* Enable accel */ sensor_ctrl = BMA5_SENSOR_CTRL_ENABLE; rslt = bma5_set_acc_conf_0(sensor_ctrl, dev); bma5_check_rslt("bma5_set_acc_conf_0", rslt); + if (rslt == BMA5_OK) + { + printf("Accel enabled\n"); + } + rslt = bma5_get_acc_conf_0(&sensor_ctrl, dev); bma5_check_rslt("bma5_set_acc_conf_0", rslt); rslt = bma5_get_acc_conf(&get_acc_cfg, dev); bma5_check_rslt("bma5_get_acc_conf", rslt); - printf("Sensor CTRL : %d\n", sensor_ctrl); - printf("ODR : %d\n", get_acc_cfg.acc_odr); - printf("BW : %d\n", get_acc_cfg.acc_bwp); - printf("Power mode : %d\n", get_acc_cfg.power_mode); - printf("Range : %d\n", get_acc_cfg.acc_range); - printf("IIR RO : %d\n", get_acc_cfg.acc_iir_ro); - printf("Noise mode : %d\n", get_acc_cfg.noise_mode); - printf("Auto Int clear : %d\n", get_acc_cfg.acc_drdy_int_auto_clear); - rslt = bma5_get_int_conf(&int_config, n_ints, dev); bma5_check_rslt("bma5_get_int_conf", rslt); @@ -262,6 +271,11 @@ static int8_t get_accel_and_int_settings(struct bma5_dev *dev) rslt = bma5_set_int_conf(&int_config, n_ints, dev); bma5_check_rslt("bma5_set_int_conf", rslt); + printf("\nInt Configurations\n\n"); + printf("INT2 mode : %s\t\n", enum_to_string(BMA5_INT2_MODE_LATCHED)); + printf("INT2 OD : %s\t\n", enum_to_string(BMA5_INT2_OD_PUSH_PULL)); + printf("INT2 level : %s\t\n", enum_to_string(BMA5_INT2_LVL_ACTIVE_HIGH)); + return rslt; } @@ -278,14 +292,14 @@ static int8_t get_fifo_conf(const struct bma5_fifo_conf *fifo_conf, struct bma5_ rslt = bma5_set_fifo_conf(fifo_conf, dev); bma5_check_rslt("bma5_set_fifo_conf", rslt); - printf("\nSet FIFO conf\n"); - printf("fifo en %d\n", fifo_conf->fifo_cfg); - printf("fifo_x_en %d\n", fifo_conf->fifo_acc_x); - printf("fifo_y_en %d\n", fifo_conf->fifo_acc_y); - printf("fifo_z_en %d\n", fifo_conf->fifo_acc_z); - printf("fifo_compression_en %d\n", fifo_conf->fifo_compression); - printf("fifo_sensor_time %d\n", fifo_conf->fifo_sensor_time); - printf("fifo_size %d\n", fifo_conf->fifo_size); + printf("\nFIFO conf\n"); + printf("fifo en %s\t\n", enum_to_string(BMA5_FIFO_CFG_ENABLE)); + printf("fifo_x_en %s\t\n", enum_to_string(BMA5_FIFO_ACC_X_ENABLE)); + printf("fifo_y_en %s\t\n", enum_to_string(BMA5_FIFO_ACC_Y_ENABLE)); + printf("fifo_z_en %s\t\n", enum_to_string(BMA5_FIFO_ACC_Z_ENABLE)); + printf("fifo_compression_en %s\t\n", enum_to_string(BMA5_FIFO_COMPRESSION_ACC_8BIT)); + printf("fifo_sensor_time %s\t\n", enum_to_string(BMA5_FIFO_SENSOR_TIME_EACH_FRAME)); + printf("fifo_size %s\t\n", enum_to_string(BMA5_FIFO_SIZE_MAX_512_BYTES)); /* Get FIFO configuration register */ rslt = bma5_get_fifo_conf(&read_fifo_conf, dev); @@ -316,13 +330,14 @@ static int8_t get_fifo_full_16_bit_data(struct bma5_sens_fifo_axes_data_16_bit * struct bma580_int_status_types int_status = { 0 }; uint8_t loop = 0; uint16_t idx = 0; + uint8_t iteration = 3; float x = 0, y = 0, z = 0; int_status.int_src = BMA580_INT_STATUS_INT2; - printf("Get FIFO data"); + printf("\nGet FIFO data"); - while (loop < 3) + while (loop < iteration) { /* Get fifo full interrupt 2 status */ rslt = bma580_get_int_status(&int_status, n_status, dev); @@ -357,7 +372,7 @@ static int8_t get_fifo_full_16_bit_data(struct bma5_sens_fifo_axes_data_16_bit * z = lsb_to_ms2(fifo_accel_data[idx].z, (float)2, BMA5_16_BIT_RESOLUTION); /* Print the data in m/s2 */ - printf("%d, %d, %d, %d, %4.2f, %4.2f, %4.2f, %.4lf s\n", + printf("%4d %11d %11d %11d %9.2f %9.2f %9.2f %10.4lf s\n", idx, fifo_accel_data[idx].x, fifo_accel_data[idx].y, diff --git a/examples/fifo_wm_8_bit_dedicated_frame_comp_en/Makefile b/examples/fifo_wm_8_bit_dedicated_frame_comp_en/Makefile index 564f76e..4f76d77 100644 --- a/examples/fifo_wm_8_bit_dedicated_frame_comp_en/Makefile +++ b/examples/fifo_wm_8_bit_dedicated_frame_comp_en/Makefile @@ -14,5 +14,5 @@ $(COMMON_LOCATION)/common/common.c INCLUDEPATHS += \ $(API_LOCATION) \ $(COMMON_LOCATION)/common - +COINES_BACKEND ?= COINES_BRIDGE include $(COINES_INSTALL_PATH)/coines.mk \ No newline at end of file diff --git a/examples/fifo_wm_8_bit_dedicated_frame_comp_en/fifo_wm_8_bit_dedicated_frame_comp_en.c b/examples/fifo_wm_8_bit_dedicated_frame_comp_en/fifo_wm_8_bit_dedicated_frame_comp_en.c index a76f694..e95b876 100644 --- a/examples/fifo_wm_8_bit_dedicated_frame_comp_en/fifo_wm_8_bit_dedicated_frame_comp_en.c +++ b/examples/fifo_wm_8_bit_dedicated_frame_comp_en/fifo_wm_8_bit_dedicated_frame_comp_en.c @@ -141,21 +141,21 @@ int main(void) /* Set FIFO water-mark level */ uint16_t fifo_watermark_level = WATERMARK_LEVEL; + /* Assign context parameter selection */ enum bma5_context context; - /* Assign context parameter selection */ context = BMA5_SMARTPHONE; /* Interface reference is given as a parameter * For I2C : BMA5_I2C_INTF * For SPI : BMA5_SPI_INTF */ - rslt = bma5_interface_init(&dev, BMA5_SPI_INTF, context); + rslt = bma5_interface_init(&dev, BMA5_I2C_INTF, context); bma5_check_rslt("bma5_interface_init", rslt); rslt = bma580_init(&dev); bma5_check_rslt("bma580_init", rslt); - printf("BMA580 Chip ID is 0x%X\n", dev.chip_id); + printf("Chip ID :0x%X\n", dev.chip_id); rslt = bma580_get_int_map(&int_map, &dev); bma5_check_rslt("bma580_get_int_map", rslt); @@ -210,6 +210,7 @@ static int8_t get_accel_and_int_settings(struct bma5_dev *dev) struct bma5_acc_conf acc_cfg, get_acc_cfg; struct bma5_int_conf_types int_config; + /* Set interrupt configurations */ int_config.int_src = BMA5_INT_2; /* Get accel configurations */ @@ -232,27 +233,32 @@ static int8_t get_accel_and_int_settings(struct bma5_dev *dev) rslt = bma5_set_acc_conf(&acc_cfg, dev); bma5_check_rslt("bma5_get_acc_conf", rslt); + printf("Accel configurations\n"); + printf("ODR : %s\t\n", enum_to_string(BMA5_ACC_ODR_HZ_6K4)); + printf("Bandwidth : %s\t\n", enum_to_string(BMA5_ACC_BWP_NORM_AVG4)); + printf("Power mode : %s\t\n", enum_to_string(BMA5_POWER_MODE_HPM)); + printf("Range : %s\t\n", enum_to_string(BMA5_ACC_RANGE_MAX_2G)); + printf("IIR RO : %s\t\n", enum_to_string(BMA5_ACC_IIR_RO_DB_60)); + printf("Noise mode : %s\t\n", enum_to_string(BMA5_NOISE_MODE_LOWER_POWER)); + printf("Auto Int clear : %s\t\n", enum_to_string(BMA5_ACC_DRDY_INT_AUTO_CLEAR_DISABLED)); + /* Enable accel */ sensor_ctrl = BMA5_SENSOR_CTRL_ENABLE; rslt = bma5_set_acc_conf_0(sensor_ctrl, dev); bma5_check_rslt("bma5_set_acc_conf_0", rslt); + if (rslt == BMA5_OK) + { + printf("Accel enabled\n"); + } + rslt = bma5_get_acc_conf_0(&sensor_ctrl, dev); bma5_check_rslt("bma5_set_acc_conf_0", rslt); rslt = bma5_get_acc_conf(&get_acc_cfg, dev); bma5_check_rslt("bma5_get_acc_conf", rslt); - printf("Sensor CTRL : %d\n", sensor_ctrl); - printf("ODR : %d\n", get_acc_cfg.acc_odr); - printf("BW : %d\n", get_acc_cfg.acc_bwp); - printf("Power mode : %d\n", get_acc_cfg.power_mode); - printf("Range : %d\n", get_acc_cfg.acc_range); - printf("IIR RO : %d\n", get_acc_cfg.acc_iir_ro); - printf("Noise mode : %d\n", get_acc_cfg.noise_mode); - printf("Auto Int clear : %d\n", get_acc_cfg.acc_drdy_int_auto_clear); - rslt = bma5_get_int_conf(&int_config, n_ints, dev); bma5_check_rslt("bma5_get_int_conf", rslt); @@ -263,6 +269,11 @@ static int8_t get_accel_and_int_settings(struct bma5_dev *dev) rslt = bma5_set_int_conf(&int_config, n_ints, dev); bma5_check_rslt("bma5_set_int_conf", rslt); + printf("Int configurations\n"); + printf("Int mode : %s\t\n", enum_to_string(BMA5_INT2_MODE_LATCHED)); + printf("Int OD : %s\t\n", enum_to_string(BMA5_INT2_OD_PUSH_PULL)); + printf("Int level : %s\t\n", enum_to_string(BMA5_INT2_LVL_ACTIVE_HIGH)); + return rslt; } @@ -279,14 +290,14 @@ static int8_t get_fifo_conf(const struct bma5_fifo_conf *fifo_conf, struct bma5_ rslt = bma5_set_fifo_conf(fifo_conf, dev); bma5_check_rslt("bma5_set_fifo_conf", rslt); - printf("\nSet FIFO conf\n"); - printf("fifo en %d\n", fifo_conf->fifo_cfg); - printf("fifo_x_en %d\n", fifo_conf->fifo_acc_x); - printf("fifo_y_en %d\n", fifo_conf->fifo_acc_y); - printf("fifo_z_en %d\n", fifo_conf->fifo_acc_z); - printf("fifo_compression_en %d\n", fifo_conf->fifo_compression); - printf("fifo_sensor_time %d\n", fifo_conf->fifo_sensor_time); - printf("fifo_size %d\n", fifo_conf->fifo_size); + printf("\nFIFO conf\n"); + printf("fifo en %s\t\n", enum_to_string(BMA5_FIFO_CFG_ENABLE)); + printf("fifo_x_en %s\t\n", enum_to_string(BMA5_FIFO_ACC_X_ENABLE)); + printf("fifo_y_en %s\t\n", enum_to_string(BMA5_FIFO_ACC_Y_ENABLE)); + printf("fifo_z_en %s\t\n", enum_to_string(BMA5_FIFO_ACC_Z_ENABLE)); + printf("fifo_compression_en %s\t\n", enum_to_string(BMA5_FIFO_COMPRESSION_ACC_8BIT)); + printf("fifo_sensor_time %s\t\n", enum_to_string(BMA5_FIFO_SENSOR_TIME_EACH_FRAME)); + printf("fifo_size %s\t\n", enum_to_string(BMA5_FIFO_SIZE_MAX_512_BYTES)); /* Get FIFO configuration register */ rslt = bma5_get_fifo_conf(&read_fifo_conf, dev); @@ -317,13 +328,14 @@ static int8_t get_fifo_full_8_bit_data(struct bma5_sens_fifo_axes_data_8_bit *fi struct bma580_int_status_types int_status = { 0 }; uint8_t loop = 0; uint16_t idx = 0; + uint8_t iteration = 3; float x = 0, y = 0, z = 0; int_status.int_src = BMA580_INT_STATUS_INT2; - printf("Get FIFO data"); + printf("\nGet FIFO data"); - while (loop < 3) + while (loop < iteration) { /* Get fifo full interrupt 2 status */ rslt = bma580_get_int_status(&int_status, n_status, dev); @@ -356,7 +368,7 @@ static int8_t get_fifo_full_8_bit_data(struct bma5_sens_fifo_axes_data_8_bit *fi z = lsb_to_ms2(fifo_accel_data[idx].z, (float)2, BMA5_8_BIT_RESOLUTION); /* Print the data in m/s2 */ - printf("%d, %d, %d, %d, %4.2f, %4.2f, %4.2f\n", idx, fifo_accel_data[idx].x, + printf("%4d %11d %11d %11d %9.2f %9.2f %9.2f\n", idx, fifo_accel_data[idx].x, fifo_accel_data[idx].y, fifo_accel_data[idx].z, x, y, z); } diff --git a/examples/fifo_wm_8_bit_each_frame_comp_en/Makefile b/examples/fifo_wm_8_bit_each_frame_comp_en/Makefile index a07195c..75a1b27 100644 --- a/examples/fifo_wm_8_bit_each_frame_comp_en/Makefile +++ b/examples/fifo_wm_8_bit_each_frame_comp_en/Makefile @@ -14,5 +14,5 @@ $(COMMON_LOCATION)/common/common.c INCLUDEPATHS += \ $(API_LOCATION) \ $(COMMON_LOCATION)/common - +COINES_BACKEND ?= COINES_BRIDGE include $(COINES_INSTALL_PATH)/coines.mk \ No newline at end of file diff --git a/examples/fifo_wm_8_bit_each_frame_comp_en/fifo_wm_8_bit_each_frame_comp_en.c b/examples/fifo_wm_8_bit_each_frame_comp_en/fifo_wm_8_bit_each_frame_comp_en.c index a6df263..9f1302a 100644 --- a/examples/fifo_wm_8_bit_each_frame_comp_en/fifo_wm_8_bit_each_frame_comp_en.c +++ b/examples/fifo_wm_8_bit_each_frame_comp_en/fifo_wm_8_bit_each_frame_comp_en.c @@ -70,6 +70,9 @@ uint16_t fifo_accel_frame_length = ACCEL_FRAME_LEN; /*! Number of bytes of FIFO data */ uint8_t fifo_data[BMA580_FIFO_RAW_DATA_BUFFER_SIZE] = { 0 }; +/* Set FIFO water-mark level */ +uint16_t fifo_watermark_level = WATERMARK_LEVEL; + /*! Array of accelerometer and sensortime frames * Array size same as fifo_accel_frame_length */ struct bma5_sens_fifo_axes_data_8_bit fifo_acc_data[ACCEL_FRAME_LEN]; @@ -124,9 +127,6 @@ static int8_t get_fifo_full_8_bit_data(struct bma5_sens_fifo_axes_data_8_bit *fi */ static float lsb_to_ms2(int16_t val, float g_range, uint8_t bit_width); -/* Set FIFO water-mark level */ -uint16_t fifo_watermark_level = WATERMARK_LEVEL; - /******************************************************************************/ int main(void) { @@ -138,21 +138,21 @@ int main(void) /* Initialize FIFO frame structure */ struct bma5_fifo_frame fifoframe = { 0 }; + /* Assign context parameter selection */ enum bma5_context context; - /* Assign context parameter selection */ context = BMA5_SMARTPHONE; /* Interface reference is given as a parameter * For I2C : BMA5_I2C_INTF * For SPI : BMA5_SPI_INTF */ - rslt = bma5_interface_init(&dev, BMA5_SPI_INTF, context); + rslt = bma5_interface_init(&dev, BMA5_I2C_INTF, context); bma5_check_rslt("bma5_interface_init", rslt); rslt = bma580_init(&dev); bma5_check_rslt("bma580_init", rslt); - printf("BMA580 Chip ID is 0x%X\n", dev.chip_id); + printf("Chip ID :0x%X\n", dev.chip_id); rslt = bma580_get_int_map(&int_map, &dev); bma5_check_rslt("bma580_get_int_map", rslt); @@ -229,27 +229,32 @@ static int8_t get_accel_and_int_settings(struct bma5_dev *dev) rslt = bma5_set_acc_conf(&acc_cfg, dev); bma5_check_rslt("bma5_get_acc_conf", rslt); + printf("Accel configurations\n"); + printf("ODR : %s\t\n", enum_to_string(BMA5_ACC_ODR_HZ_6K4)); + printf("Bandwidth : %s\t\n", enum_to_string(BMA5_ACC_BWP_NORM_AVG4)); + printf("Power mode : %s\t\n", enum_to_string(BMA5_POWER_MODE_HPM)); + printf("Range : %s\t\n", enum_to_string(BMA5_ACC_RANGE_MAX_2G)); + printf("IIR RO : %s\t\n", enum_to_string(BMA5_ACC_IIR_RO_DB_60)); + printf("Noise mode : %s\t\n", enum_to_string(BMA5_NOISE_MODE_LOWER_POWER)); + printf("Auto Int clear : %s\t\n", enum_to_string(BMA5_ACC_DRDY_INT_AUTO_CLEAR_DISABLED)); + /* Enable accel */ sensor_ctrl = BMA5_SENSOR_CTRL_ENABLE; rslt = bma5_set_acc_conf_0(sensor_ctrl, dev); bma5_check_rslt("bma5_set_acc_conf_0", rslt); + if (rslt == BMA5_OK) + { + printf("\nAccel is enabled\n"); + } + rslt = bma5_get_acc_conf_0(&sensor_ctrl, dev); bma5_check_rslt("bma5_set_acc_conf_0", rslt); rslt = bma5_get_acc_conf(&get_acc_cfg, dev); bma5_check_rslt("bma5_get_acc_conf", rslt); - printf("Sensor CTRL : %d\n", sensor_ctrl); - printf("ODR : %d\n", get_acc_cfg.acc_odr); - printf("BW : %d\n", get_acc_cfg.acc_bwp); - printf("Power mode : %d\n", get_acc_cfg.power_mode); - printf("Range : %d\n", get_acc_cfg.acc_range); - printf("IIR RO : %d\n", get_acc_cfg.acc_iir_ro); - printf("Noise mode : %d\n", get_acc_cfg.noise_mode); - printf("Auto Int clear : %d\n", get_acc_cfg.acc_drdy_int_auto_clear); - rslt = bma5_get_int_conf(&int_config, n_ints, dev); bma5_check_rslt("bma5_get_int_conf", rslt); @@ -260,6 +265,11 @@ static int8_t get_accel_and_int_settings(struct bma5_dev *dev) rslt = bma5_set_int_conf(&int_config, n_ints, dev); bma5_check_rslt("bma5_set_int_conf", rslt); + printf("\nInt Configurations\n\n"); + printf("Int mode : %s\t\n", enum_to_string(BMA5_INT1_MODE_LATCHED)); + printf("Int od : %s\t\n", enum_to_string(BMA5_INT1_OD_PUSH_PULL)); + printf("Int level : %s\t\n", enum_to_string(BMA5_INT1_LVL_ACTIVE_HIGH)); + return rslt; } @@ -276,14 +286,14 @@ static int8_t get_fifo_conf(const struct bma5_fifo_conf *fifo_conf, struct bma5_ rslt = bma5_set_fifo_conf(fifo_conf, dev); bma5_check_rslt("bma5_set_fifo_conf", rslt); - printf("\nSet FIFO conf\n"); - printf("fifo en %d\n", fifo_conf->fifo_cfg); - printf("fifo_x_en %d\n", fifo_conf->fifo_acc_x); - printf("fifo_y_en %d\n", fifo_conf->fifo_acc_y); - printf("fifo_z_en %d\n", fifo_conf->fifo_acc_z); - printf("fifo_compression_en %d\n", fifo_conf->fifo_compression); - printf("fifo_sensor_time %d\n", fifo_conf->fifo_sensor_time); - printf("fifo_size %d\n", fifo_conf->fifo_size); + printf("\nFIFO conf\n"); + printf("fifo en %s\t\n", enum_to_string(BMA5_FIFO_CFG_ENABLE)); + printf("fifo_x_en %s\t\n", enum_to_string(BMA5_FIFO_ACC_X_ENABLE)); + printf("fifo_y_en %s\t\n", enum_to_string(BMA5_FIFO_ACC_Y_ENABLE)); + printf("fifo_z_en %s\t\n", enum_to_string(BMA5_FIFO_ACC_Z_ENABLE)); + printf("fifo_compression_en %s\t\n", enum_to_string(BMA5_FIFO_COMPRESSION_ACC_8BIT)); + printf("fifo_sensor_time %s\t\n", enum_to_string(BMA5_FIFO_SENSOR_TIME_EACH_FRAME)); + printf("fifo_size %s\t\n", enum_to_string(BMA5_FIFO_SIZE_MAX_512_BYTES)); /* Get FIFO configuration register */ rslt = bma5_get_fifo_conf(&read_fifo_conf, dev); @@ -314,13 +324,14 @@ static int8_t get_fifo_full_8_bit_data(struct bma5_sens_fifo_axes_data_8_bit *fi struct bma580_int_status_types int_status = { 0 }; uint8_t loop = 0; uint16_t idx = 0; + uint8_t iteration = 3; float x = 0, y = 0, z = 0; int_status.int_src = BMA580_INT_STATUS_INT1; - printf("Get FIFO data"); + printf("\nGet FIFO data"); - while (loop < 3) + while (loop < iteration) { /* Get fifo full interrupt 2 status */ rslt = bma580_get_int_status(&int_status, n_status, dev); @@ -354,7 +365,7 @@ static int8_t get_fifo_full_8_bit_data(struct bma5_sens_fifo_axes_data_8_bit *fi z = lsb_to_ms2(fifo_accel_data[idx].z, (float)2, BMA5_8_BIT_RESOLUTION); /* Print the data in m/s2 */ - printf("%d, %d, %d, %d, %4.2f, %4.2f, %4.2f, %.4lf s\n", + printf("%4d %11d %11d %11d %9.2f %9.2f %9.2f %10.4lf s\n", idx, fifo_accel_data[idx].x, fifo_accel_data[idx].y, diff --git a/examples/flat/flat.c b/examples/flat/flat.c index 89dc55a..08a2244 100644 --- a/examples/flat/flat.c +++ b/examples/flat/flat.c @@ -81,7 +81,7 @@ int main(void) /* Initialize the BMA5 device instance */ rslt = bma580_init(&dev); bma5_check_rslt("bma580_init", rslt); - printf("BMA580 Chip ID is 0x%X\n", dev.chip_id); + printf("Chip ID :0x%X\n", dev.chip_id); /* Updating the generic interrupt 1 and 2 configuration for face up and face down detection */ rslt = bma580_get_generic_int_config(conf, n_ints, &dev); @@ -133,6 +133,11 @@ int main(void) rslt = bma580_set_feat_eng_gpr_0(&gpr_0, &dev); bma5_check_rslt("bma580_set_feat_eng_gpr_0", rslt); + if (rslt == BMA5_OK) + { + printf("\nGeneric Interrupt 1 and 2 enabled\n"); + } + rslt = bma5_set_regs(BMA5_REG_FEAT_ENG_GPR_CTRL, &gpr_ctrl_host, 1, &dev); bma5_check_rslt("bma5_set_regs", rslt); @@ -161,7 +166,11 @@ int main(void) rslt = bma5_set_int_conf(&int_config, n_ints_conf, &dev); bma5_check_rslt("bma5_set_int_conf", rslt); - printf("Keep the board in Flat postion to genereate interrupt\n"); + printf("\nInt1 mode: %s\n", enum_to_string(BMA5_INT1_MODE_LATCHED)); + printf("Int1 OD: %s\n", enum_to_string(BMA5_INT1_OD_PUSH_PULL)); + printf("Int1 Level: %s\n", enum_to_string(BMA5_INT1_LVL_ACTIVE_HIGH)); + + printf("\nKeep the board in Flat position to generate interrupt\n"); for (;;) { @@ -176,7 +185,7 @@ int main(void) rslt = bma580_set_int_status(&int_status, n_status, &dev); bma5_check_rslt("bma580_set_int_status", rslt); - printf("Flat orientation detected\n"); + printf("\nFlat orientation detected\n"); break; } diff --git a/examples/generic_interrupt_1/Makefile b/examples/generic_interrupt_1/Makefile index 31d3107..5dfaaca 100644 --- a/examples/generic_interrupt_1/Makefile +++ b/examples/generic_interrupt_1/Makefile @@ -14,5 +14,5 @@ $(COMMON_LOCATION)/common/common.c INCLUDEPATHS += \ $(API_LOCATION) \ $(COMMON_LOCATION)/common - +COINES_BACKEND ?= COINES_BRIDGE include $(COINES_INSTALL_PATH)/coines.mk \ No newline at end of file diff --git a/examples/generic_interrupt_1/generic_interrupt_1.c b/examples/generic_interrupt_1/generic_interrupt_1.c index 79031f2..aa9b236 100644 --- a/examples/generic_interrupt_1/generic_interrupt_1.c +++ b/examples/generic_interrupt_1/generic_interrupt_1.c @@ -45,10 +45,19 @@ int main(void) uint8_t n_ints = 1; uint8_t n_status = 1; + /* Variable to hold interrupt mapping, mapping to hardware interrupt pin 1 on sensor */ struct bma580_int_map int_map; + + /* Variable to hold configurations related to interrupt pin 1 */ struct bma5_int_conf_types int_config; + + /* Variable to hold generic interrupt 1 configuation */ struct bma580_generic_interrupt_types conf, set_conf; + + /* Variable to store interrupt status */ struct bma580_int_status_types int_status; + + /* Variable to store Feature engine general purpose register 0 */ struct bma580_feat_eng_gpr_0 gpr_0; int_config.int_src = BMA5_INT_1; @@ -64,12 +73,12 @@ int main(void) * For I2C : BMA5_I2C_INTF * For SPI : BMA5_SPI_INTF */ - rslt = bma5_interface_init(&dev, BMA5_SPI_INTF, context); + rslt = bma5_interface_init(&dev, BMA5_I2C_INTF, context); bma5_check_rslt("bma5_interface_init", rslt); rslt = bma580_init(&dev); bma5_check_rslt("bma580_init", rslt); - printf("BMA580 Chip ID is 0x%X\n", dev.chip_id); + printf("Chip ID :0x%X\n", dev.chip_id); printf("Default configurations\n"); rslt = bma580_get_default_generic_int_config(&conf, n_ints, &dev); @@ -104,6 +113,20 @@ int main(void) rslt = bma580_set_generic_int_config(&set_conf, n_ints, &dev); bma5_check_rslt("bma580_set_generic_int_config", rslt); + printf("\nSet Interrupt configurations\n"); + printf("\nslope_thres 0x%x\n", set_conf.gen_int.slope_thres); + printf("comb_sel 0x%x\n", set_conf.gen_int.comb_sel); + printf("axis_sel 0x%x\n", set_conf.gen_int.axis_sel); + printf("hysteresis 0x%x\n", set_conf.gen_int.hysteresis); + printf("criterion_sel 0x%x\n", set_conf.gen_int.criterion_sel); + printf("acc_ref_up 0x%x\n", set_conf.gen_int.acc_ref_up); + printf("duration 0x%x\n", set_conf.gen_int.duration); + printf("wait_time 0x%x\n", set_conf.gen_int.wait_time); + printf("quiet_time 0x%x\n", set_conf.gen_int.quiet_time); + printf("ref_acc_x 0x%x\n", set_conf.gen_int.ref_acc_x); + printf("ref_acc_y 0x%x\n", set_conf.gen_int.ref_acc_y); + printf("ref_acc_z 0x%x\n", set_conf.gen_int.ref_acc_z); + rslt = bma580_get_feat_eng_gpr_0(&gpr_0, &dev); bma5_check_rslt("bma580_get_feat_eng_gpr_0", rslt); @@ -112,6 +135,11 @@ int main(void) rslt = bma580_set_feat_eng_gpr_0(&gpr_0, &dev); bma5_check_rslt("bma580_set_feat_eng_gpr_0", rslt); + if (rslt == BMA5_OK) + { + printf("Generic interrupt 1 enabled\n"); + } + rslt = bma5_set_regs(BMA5_REG_FEAT_ENG_GPR_CTRL, &gpr_ctrl_host, 1, &dev); bma5_check_rslt("bma5_set_regs", rslt); @@ -134,6 +162,11 @@ int main(void) rslt = bma5_set_int_conf(&int_config, n_ints, &dev); bma5_check_rslt("bma5_set_int_conf", rslt); + printf("Int Configurations\n"); + printf("\nInt1 mode: %s\n", enum_to_string(BMA5_INT1_MODE_LATCHED)); + printf("Int1 OD: %s\n", enum_to_string(BMA5_INT1_OD_PUSH_PULL)); + printf("Int1 Level: %s\n", enum_to_string(BMA5_INT1_LVL_ACTIVE_HIGH)); + printf("Shake the board to get generic interrupt 1 interrupt\n"); for (;;) @@ -141,6 +174,7 @@ int main(void) rslt = bma580_get_int_status(&int_status, n_status, &dev); bma5_check_rslt("bma580_get_int_status", rslt); + /* Check if generic interrupt 1 interrupt occurred */ if (int_status.int_status.gen_int1_int_status & BMA5_ENABLE) { rslt = bma580_set_int_status(&int_status, n_status, &dev); diff --git a/examples/generic_interrupt_2/Makefile b/examples/generic_interrupt_2/Makefile index 8902d31..fbe8237 100644 --- a/examples/generic_interrupt_2/Makefile +++ b/examples/generic_interrupt_2/Makefile @@ -14,5 +14,5 @@ $(COMMON_LOCATION)/common/common.c INCLUDEPATHS += \ $(API_LOCATION) \ $(COMMON_LOCATION)/common - +COINES_BACKEND ?= COINES_BRIDGE include $(COINES_INSTALL_PATH)/coines.mk \ No newline at end of file diff --git a/examples/generic_interrupt_2/generic_interrupt_2.c b/examples/generic_interrupt_2/generic_interrupt_2.c index 1674bbc..5c0a1ce 100644 --- a/examples/generic_interrupt_2/generic_interrupt_2.c +++ b/examples/generic_interrupt_2/generic_interrupt_2.c @@ -45,12 +45,22 @@ int main(void) uint8_t n_ints = 1; uint8_t n_status = 1; + /* Variable to hold interrupt mapping, mapping to hardware interrupt pin 1 on sensor */ struct bma580_int_map int_map; + + /* Variable to hold configurations related to interrupt pin 1 */ struct bma5_int_conf_types int_config; + + /* Variable to hold generic interrupt 2 configuation */ struct bma580_generic_interrupt_types conf, set_conf; + + /* Variable to store interrupt status */ struct bma580_int_status_types int_status; + + /* Variable to store Feature engine general purpose register 0 */ struct bma580_feat_eng_gpr_0 gpr_0; + /* Generic interrupt configurations */ int_config.int_src = BMA5_INT_2; int_status.int_src = BMA580_INT_STATUS_INT2; conf.generic_interrupt = BMA580_GEN_INT_2; @@ -64,12 +74,12 @@ int main(void) * For I2C : BMA5_I2C_INTF * For SPI : BMA5_SPI_INTF */ - rslt = bma5_interface_init(&dev, BMA5_SPI_INTF, context); + rslt = bma5_interface_init(&dev, BMA5_I2C_INTF, context); bma5_check_rslt("bma5_interface_init", rslt); rslt = bma580_init(&dev); bma5_check_rslt("bma580_init", rslt); - printf("BMA580 Chip ID is 0x%X\n", dev.chip_id); + printf("Chip ID :0x%X\n", dev.chip_id); printf("Default configurations\n"); rslt = bma580_get_default_generic_int_config(&conf, n_ints, &dev); @@ -104,6 +114,20 @@ int main(void) rslt = bma580_set_generic_int_config(&set_conf, n_ints, &dev); bma5_check_rslt("bma580_set_generic_int_config", rslt); + printf("\nSet Interrupt configurations\n"); + printf("\nslope_thres 0x%x\n", set_conf.gen_int.slope_thres); + printf("comb_sel 0x%x\n", set_conf.gen_int.comb_sel); + printf("axis_sel 0x%x\n", set_conf.gen_int.axis_sel); + printf("hysteresis 0x%x\n", set_conf.gen_int.hysteresis); + printf("criterion_sel 0x%x\n", set_conf.gen_int.criterion_sel); + printf("acc_ref_up 0x%x\n", set_conf.gen_int.acc_ref_up); + printf("duration 0x%x\n", set_conf.gen_int.duration); + printf("wait_time 0x%x\n", set_conf.gen_int.wait_time); + printf("quiet_time 0x%x\n", set_conf.gen_int.quiet_time); + printf("ref_acc_x 0x%x\n", set_conf.gen_int.ref_acc_x); + printf("ref_acc_y 0x%x\n", set_conf.gen_int.ref_acc_y); + printf("ref_acc_z 0x%x\n", set_conf.gen_int.ref_acc_z); + rslt = bma580_get_feat_eng_gpr_0(&gpr_0, &dev); bma5_check_rslt("bma580_get_feat_eng_gpr_0", rslt); @@ -112,6 +136,11 @@ int main(void) rslt = bma580_set_feat_eng_gpr_0(&gpr_0, &dev); bma5_check_rslt("bma580_set_feat_eng_gpr_0", rslt); + if (rslt == BMA5_OK) + { + printf("Generic interrupt 2 enabled\n"); + } + rslt = bma5_set_regs(BMA5_REG_FEAT_ENG_GPR_CTRL, &gpr_ctrl_host, 1, &dev); bma5_check_rslt("bma5_set_regs", rslt); @@ -134,6 +163,11 @@ int main(void) rslt = bma5_set_int_conf(&int_config, n_ints, &dev); bma5_check_rslt("bma5_set_int_conf", rslt); + printf("Int Configurations\n"); + printf("Int1 mode: %s\n", enum_to_string(BMA5_INT1_MODE_LATCHED)); + printf("Int1 OD: %s\n", enum_to_string(BMA5_INT1_OD_PUSH_PULL)); + printf("Int1 Level: %s\n", enum_to_string(BMA5_INT1_LVL_ACTIVE_HIGH)); + printf("Do not shake the board to get interrupt for generic interrupt 2\n"); for (;;) @@ -141,6 +175,7 @@ int main(void) rslt = bma580_get_int_status(&int_status, n_status, &dev); bma5_check_rslt("bma580_get_int_status_int", rslt); + /* Check if generic interrupt 2 interrupt occurred */ if (int_status.int_status.gen_int2_int_status & BMA5_ENABLE) { rslt = bma580_set_int_status(&int_status, n_status, &dev); diff --git a/examples/generic_interrupt_3/Makefile b/examples/generic_interrupt_3/Makefile index 0e2bc04..1a0f989 100644 --- a/examples/generic_interrupt_3/Makefile +++ b/examples/generic_interrupt_3/Makefile @@ -14,5 +14,5 @@ $(COMMON_LOCATION)/common/common.c INCLUDEPATHS += \ $(API_LOCATION) \ $(COMMON_LOCATION)/common - +COINES_BACKEND ?= COINES_BRIDGE include $(COINES_INSTALL_PATH)/coines.mk \ No newline at end of file diff --git a/examples/generic_interrupt_3/generic_interrupt_3.c b/examples/generic_interrupt_3/generic_interrupt_3.c index 43b4e61..973e017 100644 --- a/examples/generic_interrupt_3/generic_interrupt_3.c +++ b/examples/generic_interrupt_3/generic_interrupt_3.c @@ -45,12 +45,22 @@ int main(void) uint8_t n_ints = 1; uint8_t n_status = 1; + /* Variable to hold interrupt mapping, mapping to hardware interrupt pin 1 on sensor */ struct bma580_int_map int_map; + + /* Variable to hold configurations related to interrupt pin 1 */ struct bma5_int_conf_types int_config; + + /* Variable to hold generic interrupt 3 configuation */ struct bma580_generic_interrupt_types conf, set_conf; + + /* Variable to store interrupt status */ struct bma580_int_status_types int_status; + + /* Variable to store Feature engine general purpose register 0 */ struct bma580_feat_eng_gpr_0 gpr_0; + /*Generic interrupt configurations */ int_config.int_src = BMA5_INT_1; int_status.int_src = BMA580_INT_STATUS_INT1; conf.generic_interrupt = BMA580_GEN_INT_3; @@ -64,12 +74,13 @@ int main(void) * For I2C : BMA5_I2C_INTF * For SPI : BMA5_SPI_INTF */ - rslt = bma5_interface_init(&dev, BMA5_SPI_INTF, context); + rslt = bma5_interface_init(&dev, BMA5_I2C_INTF, context); bma5_check_rslt("bma5_interface_init", rslt); + /* Initialize BMA580 */ rslt = bma580_init(&dev); bma5_check_rslt("bma580_init", rslt); - printf("BMA580 Chip ID is 0x%X\n", dev.chip_id); + printf("Chip ID :0x%X\n", dev.chip_id); printf("Default configurations\n"); rslt = bma580_get_generic_int_config(&conf, n_ints, &dev); @@ -104,6 +115,20 @@ int main(void) rslt = bma580_set_generic_int_config(&set_conf, n_ints, &dev); bma5_check_rslt("bma580_set_generic_int_config", rslt); + printf("\nSet Generic interrupt 3 configurations\n"); + printf("\nslope_thres 0x%x\n", set_conf.gen_int.slope_thres); + printf("comb_sel 0x%x\n", set_conf.gen_int.comb_sel); + printf("axis_sel 0x%x\n", set_conf.gen_int.axis_sel); + printf("hysteresis 0x%x\n", set_conf.gen_int.hysteresis); + printf("criterion_sel 0x%x\n", set_conf.gen_int.criterion_sel); + printf("acc_ref_up 0x%x\n", set_conf.gen_int.acc_ref_up); + printf("duration 0x%x\n", set_conf.gen_int.duration); + printf("wait_time 0x%x\n", set_conf.gen_int.wait_time); + printf("quiet_time 0x%x\n", set_conf.gen_int.quiet_time); + printf("ref_acc_x 0x%x\n", set_conf.gen_int.ref_acc_x); + printf("ref_acc_y 0x%x\n", set_conf.gen_int.ref_acc_y); + printf("ref_acc_z 0x%x\n", set_conf.gen_int.ref_acc_z); + rslt = bma580_set_generic_int_config(&set_conf, n_ints, &dev); bma5_check_rslt("bma580_set_generic_int_config", rslt); @@ -115,6 +140,11 @@ int main(void) rslt = bma580_set_feat_eng_gpr_0(&gpr_0, &dev); bma5_check_rslt("bma580_set_feat_eng_gpr_0", rslt); + if (rslt == BMA5_OK) + { + printf("\nGeneric interrupt 3 enabled\n"); + } + rslt = bma5_set_regs(BMA5_REG_FEAT_ENG_GPR_CTRL, &gpr_ctrl_host, 1, &dev); bma5_check_rslt("bma5_set_regs", rslt); @@ -145,13 +175,20 @@ int main(void) rslt = bma5_set_int_conf(&int_config, n_ints, &dev); bma5_check_rslt("bma5_set_int_conf", rslt); + printf("\nInt Configurations\n"); + printf("Int1 mode: %s\n", enum_to_string(BMA5_INT1_MODE_LATCHED)); + printf("Int1 OD: %s\n", enum_to_string(BMA5_INT1_OD_PUSH_PULL)); + printf("Int1 Level: %s\n", enum_to_string(BMA5_INT1_LVL_ACTIVE_HIGH)); + printf("Drop the board to get generic interrupt 3 interrupt\n"); for (;;) { + /* Read the interrupt status */ rslt = bma580_get_int_status(&int_status, n_status, &dev); bma5_check_rslt("bma580_get_int_status", rslt); + /* Check if generic interrupt 3 interrupt occurred */ if (int_status.int_status.gen_int3_int_status & BMA5_ENABLE) { rslt = bma580_set_int_status(&int_status, n_status, &dev); diff --git a/examples/motion_detected/motion_detected.c b/examples/motion_detected/motion_detected.c index f03cd69..2bad53a 100644 --- a/examples/motion_detected/motion_detected.c +++ b/examples/motion_detected/motion_detected.c @@ -105,7 +105,7 @@ int main(void) /* Initialize the BMA5 device instance */ rslt = bma580_init(&dev); bma5_check_rslt("bma580_init", rslt); - printf("BMA580 Chip ID is 0x%X\n", dev.chip_id); + printf("Chip ID :0x%X\n", dev.chip_id); /* Updating the generic interrupt 1 for motion detection */ rslt = bma580_get_generic_int_config(&conf, n_ints, &dev); @@ -137,11 +137,17 @@ int main(void) rslt = bma580_get_feat_eng_gpr_0(&gpr_0, &dev); bma5_check_rslt("bma580_get_feat_eng_gpr_0", rslt); + /* Enable generic interrupt 1 */ gpr_0.gen_int1_en = BMA5_ENABLE; rslt = bma580_set_feat_eng_gpr_0(&gpr_0, &dev); bma5_check_rslt("bma580_set_feat_eng_gpr_0", rslt); + if (rslt == BMA5_OK) + { + printf("Generic Interrupt 1 enabled\n"); + } + rslt = bma5_set_regs(BMA5_REG_FEAT_ENG_GPR_CTRL, &gpr_ctrl_host, 1, &dev); bma5_check_rslt("bma5_set_regs", rslt); @@ -165,6 +171,11 @@ int main(void) rslt = bma5_set_int_conf(&int_config, n_ints, &dev); bma5_check_rslt("bma5_set_int_conf", rslt); + printf("Int Configurations:\n"); + printf("Int1 mode: %s\n", enum_to_string(BMA5_INT1_MODE_LATCHED)); + printf("Int1 OD: %s\n", enum_to_string(BMA5_INT1_OD_PUSH_PULL)); + printf("Int1 Level: %s\n", enum_to_string(BMA5_INT1_LVL_ACTIVE_HIGH)); + printf("Shake the board to trigger motion detected interrupt\n"); for (;;) @@ -197,6 +208,11 @@ int main(void) rslt = bma580_set_feat_eng_gpr_0(&gpr_0, &dev); bma5_check_rslt("bma580_set_feat_eng_gpr_0", rslt); + if (rslt == BMA5_OK) + { + printf("Generic Interrupt 1 disabled\n"); + } + /*Delay for generic interrupt reset*/ dev.delay_us(40000, dev.intf_ptr); diff --git a/examples/self_test/Makefile b/examples/self_test/Makefile index 84d954a..4c68f2f 100644 --- a/examples/self_test/Makefile +++ b/examples/self_test/Makefile @@ -14,5 +14,5 @@ $(COMMON_LOCATION)/common/common.c INCLUDEPATHS += \ $(API_LOCATION) \ $(COMMON_LOCATION)/common - +COINES_BACKEND ?= COINES_BRIDGE include $(COINES_INSTALL_PATH)/coines.mk \ No newline at end of file diff --git a/examples/self_test/self_test.c b/examples/self_test/self_test.c index be73408..d8b293c 100644 --- a/examples/self_test/self_test.c +++ b/examples/self_test/self_test.c @@ -99,7 +99,7 @@ int main(void) * For I2C : BMA5_I2C_INTF * For SPI : BMA5_SPI_INTF */ - rslt = bma5_interface_init(&dev, BMA5_I2C_INTF, context); + rslt = bma5_interface_init(&dev, BMA5_SPI_INTF, context); bma5_check_rslt("bma5_interface_init", rslt); rslt = bma580_init(&dev); diff --git a/examples/self_wake_up/Makefile b/examples/self_wake_up/Makefile index 534eaaa..5431ae6 100644 --- a/examples/self_wake_up/Makefile +++ b/examples/self_wake_up/Makefile @@ -14,5 +14,5 @@ $(COMMON_LOCATION)/common/common.c INCLUDEPATHS += \ $(API_LOCATION) \ $(COMMON_LOCATION)/common - +COINES_BACKEND ?= COINES_BRIDGE include $(COINES_INSTALL_PATH)/coines.mk diff --git a/examples/self_wake_up/self_wake_up.c b/examples/self_wake_up/self_wake_up.c index 8215b05..9f856c0 100644 --- a/examples/self_wake_up/self_wake_up.c +++ b/examples/self_wake_up/self_wake_up.c @@ -36,6 +36,10 @@ #include "common.h" #include "bma580_features.h" +/* Enum for power modes */ +#define BMA580_POWER_MODE_LOW 0 +#define BMA580_SELF_WAKE_UP_STAT_LOW_POWER 1 + /******************************************************************************/ int main(void) { @@ -48,16 +52,17 @@ int main(void) struct bma580_int_map int_map = { 0 }; struct bma5_int_conf_types int_config; struct bma580_feat_eng_gpr_0 gpr_0; + struct bma5_acc_conf acc_conf; struct bma580_feat_eng_gpr_1 gpr_1; struct bma580_feat_eng_gpr_2 gpr_2; struct bma580_int_status_types int_status; struct bma580_self_wakeup_config self_wake_up_config, get_self_wake_up_config; - enum bma5_context context; int_config.int_src = BMA5_INT_2; int_status.int_src = BMA580_INT_STATUS_INT2; /* Assign context parameter selection */ + enum bma5_context context; context = BMA5_HEARABLE; /* Interface reference is given as a parameter @@ -69,25 +74,27 @@ int main(void) rslt = bma580_init(&dev); bma5_check_rslt("bma580_init", rslt); - printf("BMA580 Chip ID is 0x%X\n", dev.chip_id); + printf("Chip ID :0x%X\n", dev.chip_id); rslt = bma580_get_self_wakeup_config(&self_wake_up_config, &dev); bma5_check_rslt("bma580_get_self_wakeup_config", rslt); - self_wake_up_config.acc_odr = BMA5_ACC_ODR_HZ_100; + /* Set the self wake-up configuration */ + self_wake_up_config.acc_odr = BMA5_ACC_ODR_HZ_50; self_wake_up_config.acc_bwp = BMA5_ACC_BWP_NORM_AVG4; self_wake_up_config.acc_perf_mode = BMA580_SELF_WAKE_UP_ACC_PERF_MODE_CIC_AVG; rslt = bma580_set_self_wakeup_config(&self_wake_up_config, &dev); bma5_check_rslt("bma580_set_self_wakeup_config", rslt); + printf("\nAccel Configurations\n"); + printf("ODR: %s\t\n", enum_to_string(BMA5_ACC_ODR_HZ_50)); + printf("BWP: %s\t\n", enum_to_string(BMA5_ACC_BWP_NORM_AVG4)); + printf("Performance Mode: %s\t\n", enum_to_string(BMA580_SELF_WAKE_UP_ACC_PERF_MODE_CIC_AVG)); + rslt = bma580_get_self_wakeup_config(&get_self_wake_up_config, &dev); bma5_check_rslt("bma580_get_self_wakeup_config", rslt); - printf("get_self_wake_up_config.acc_odr : %d\n", get_self_wake_up_config.acc_odr); - printf("get_self_wake_up_config.acc_bwp : %d\n", get_self_wake_up_config.acc_bwp); - printf("get_self_wake_up_config.acc_perf_mode : %d\n", get_self_wake_up_config.acc_perf_mode); - /* Map hardware interrupt pin configurations */ rslt = bma5_get_int_conf(&int_config, n_ints, &dev); bma5_check_rslt("bma5_get_int_conf", rslt); @@ -99,23 +106,39 @@ int main(void) rslt = bma5_set_int_conf(&int_config, n_ints, &dev); bma5_check_rslt("bma5_set_int_conf", rslt); + printf("\nInterrupt Configurations\n"); + printf("Int Mode: %s\t\n", enum_to_string(BMA5_INT2_MODE_LATCHED)); + printf("Int OD: %s\t\n", enum_to_string(BMA5_INT2_OD_PUSH_PULL)); + printf("Int Level: %s\t\n", enum_to_string(BMA5_INT2_LVL_ACTIVE_HIGH)); + rslt = bma580_get_int_map(&int_map, &dev); bma5_check_rslt("bma580_get_int_map", rslt); int_map.gen_int1_int_map = BMA580_GEN_INT1_INT_MAP_INT2; int_map.gen_int2_int_map = BMA580_GEN_INT2_INT_MAP_INT2; int_map.self_wake_up_int_map = BMA580_SELF_WAKE_UP_INT_MAP_INT2; + rslt = bma580_set_int_map(&int_map, &dev); bma5_check_rslt("bma580_set_int_map", rslt); + printf("\nGeneric Int Configurations\n"); + printf("Gen Int1 Map: %s\t\n", enum_to_string(BMA580_GEN_INT1_INT_MAP_INT2)); + printf("Gen Int2 Map: %s\t\n", enum_to_string(BMA580_GEN_INT2_INT_MAP_INT2)); + printf("Self Wake Up Map: %s\t\n", enum_to_string(BMA580_SELF_WAKE_UP_INT_MAP_INT2)); + rslt = bma580_get_feat_eng_gpr_1(&gpr_1, &dev); bma5_check_rslt("bma580_get_feat_eng_gpr_1", rslt); - gpr_1.gen_int1_data_src = BMA580_GEN_INT1_DATA_SRC_DATA_SRC_3; + gpr_1.gen_int1_data_src = BMA580_GEN_INT1_DATA_SRC_DATA_SRC_4; rslt = bma580_set_feat_eng_gpr_1(&gpr_1, &dev); bma5_check_rslt("bma580_set_feat_eng_gpr_1", rslt); + if (rslt == BMA5_OK) + { + printf("\nGeneric Interrupt 1 data source set\n"); + } + rslt = bma5_set_regs(BMA5_REG_FEAT_ENG_GPR_CTRL, &gpr_ctrl_host, 1, &dev); bma5_check_rslt("bma5_set_regs", rslt); @@ -134,6 +157,11 @@ int main(void) rslt = bma580_set_feat_eng_gpr_0(&gpr_0, &dev); bma5_check_rslt("bma580_set_feat_eng_gpr_0", rslt); + if (rslt == BMA5_OK) + { + printf("\nGeneric Interrupt 1, Generic Interrupt 2 and Self wake-up enabled\n"); + } + rslt = bma5_set_regs(BMA5_REG_FEAT_ENG_GPR_CTRL, &gpr_ctrl_host, 1, &dev); bma5_check_rslt("bma5_set_regs", rslt); @@ -147,59 +175,41 @@ int main(void) rslt = bma580_get_int_status(&int_status, n_status, &dev); bma5_check_rslt("bma580_get_int_status", rslt); - rslt = bma580_get_int_status(&int_status, n_status, &dev); - bma5_check_rslt("bma580_get_int_status", rslt); - printf("\nMove the board and keep idle and do the same for 5 to 10 times continuously\n"); - printf( - "In motion self wake-up state should be normal and in idle self wake-up state should be in low power mode\n\n"); + printf("In motion self wake-up state should be normal and in idle self wake-up state should be in low power mode\n"); while (loop > 0) { rslt = bma580_get_int_status(&int_status, n_status, &dev); bma5_check_rslt("bma580_get_int_status", rslt); - if (int_status.int_status.gen_int1_int_status == BMA5_ENABLE) - { - rslt = bma580_set_int_status(&int_status, n_status, &dev); - bma5_check_rslt("bma580_set_int_status", rslt); - - printf("\nInterrupt received : Generic Interrupt 1\n"); - - rslt = bma580_get_feat_eng_gpr_2(&gpr_2, &dev); - bma5_check_rslt("bma580_get_feat_eng_gpr_2", rslt); - - printf("gen_int1_stat : %d\n", gpr_2.gen_int1_stat); - printf("gen_int2_stat : %d\n", gpr_2.gen_int2_stat); - printf("self_wake_up_stat : %d\n", gpr_2.self_wake_up_stat); - - loop--; - } - - if (int_status.int_status.gen_int2_int_status == BMA5_ENABLE) + /* Check for the interrupt status */ + if (int_status.int_status.gen_int1_int_status == BMA5_ENABLE || + int_status.int_status.gen_int2_int_status == BMA5_ENABLE || + int_status.int_status.self_wake_up_int_status == BMA5_ENABLE) { rslt = bma580_set_int_status(&int_status, n_status, &dev); bma5_check_rslt("bma580_set_int_status", rslt); - printf("\nInterrupt received : Generic Interrupt 2\n"); + rslt = bma5_get_acc_conf(&acc_conf, &dev); + bma5_check_rslt("bma580_get_int_status", rslt); - rslt = bma580_get_feat_eng_gpr_2(&gpr_2, &dev); - bma5_check_rslt("bma580_get_feat_eng_gpr_2", rslt); + printf("\nInterrupt received:\n"); - printf("gen_int1_stat : %d\n", gpr_2.gen_int1_stat); - printf("gen_int2_stat : %d\n", gpr_2.gen_int2_stat); - printf("self_wake_up_stat : %d\n", gpr_2.self_wake_up_stat); + if (int_status.int_status.gen_int1_int_status == BMA5_ENABLE) + { + printf("Generic Interrupt 1\n"); + } - loop--; - } + if (int_status.int_status.gen_int2_int_status == BMA5_ENABLE) + { + printf("Generic Interrupt 2\n"); + } - if ((int_status.int_status.gen_int1_int_status == BMA5_ENABLE) && - (int_status.int_status.gen_int2_int_status == BMA5_ENABLE)) - { - rslt = bma580_set_int_status(&int_status, n_status, &dev); - bma5_check_rslt("bma580_set_int_status", rslt); - - printf("\nInterrupt received : Generic Interrupt 1 and Generic Interrupt 2\n"); + if (int_status.int_status.self_wake_up_int_status == BMA5_ENABLE) + { + printf("Self wake-up\n"); + } rslt = bma580_get_feat_eng_gpr_2(&gpr_2, &dev); bma5_check_rslt("bma580_get_feat_eng_gpr_2", rslt); @@ -207,26 +217,12 @@ int main(void) printf("gen_int1_stat : %d\n", gpr_2.gen_int1_stat); printf("gen_int2_stat : %d\n", gpr_2.gen_int2_stat); printf("self_wake_up_stat : %d\n", gpr_2.self_wake_up_stat); + printf("Self Wake Up Mode: %s\n", + (gpr_2.self_wake_up_stat == + BMA580_SELF_WAKE_UP_STAT_LOW_POWER) ? "Low Power" : "Normal (High Performance Mode)"); - loop--; - } - - rslt = bma580_get_int_status(&int_status, n_status, &dev); - bma5_check_rslt("bma580_get_int_status", rslt); - - if (int_status.int_status.self_wake_up_int_status & BMA5_ENABLE) - { - rslt = bma580_set_int_status(&int_status, n_status, &dev); - bma5_check_rslt("bma580_set_int_status", rslt); - - printf("\nInterrupt received : Self wake-up\n"); - - rslt = bma580_get_feat_eng_gpr_2(&gpr_2, &dev); - bma5_check_rslt("bma580_get_feat_eng_gpr_2", rslt); - - printf("gen_int1_stat : %d\n", gpr_2.gen_int1_stat); - printf("gen_int2_stat : %d\n", gpr_2.gen_int2_stat); - printf("self_wake_up_stat : %d\n", gpr_2.self_wake_up_stat); + printf("Accel Config Power Mode: %s\n", + (acc_conf.power_mode == BMA580_POWER_MODE_LOW) ? "Low Power" : "High Performance Mode"); loop--; } diff --git a/examples/stationary_detected/stationary_detected.c b/examples/stationary_detected/stationary_detected.c index 9809eaf..d8b2ccb 100644 --- a/examples/stationary_detected/stationary_detected.c +++ b/examples/stationary_detected/stationary_detected.c @@ -77,7 +77,7 @@ int main(void) /* Initialize the BMA5 device instance */ rslt = bma580_init(&dev); bma5_check_rslt("bma580_init", rslt); - printf("BMA580 Chip ID is 0x%X\n", dev.chip_id); + printf("Chip ID :0x%X\n", dev.chip_id); /* Updating the generic interrupt 1 configuration for stationary detection */ printf("Gen Int configurations\n"); @@ -115,6 +115,11 @@ int main(void) rslt = bma580_set_feat_eng_gpr_0(&gpr_0, &dev); bma5_check_rslt("bma580_set_feat_eng_gpr_0", rslt); + if (rslt == BMA5_OK) + { + printf("Stationary detection enabled\n"); + } + rslt = bma5_set_regs(BMA5_REG_FEAT_ENG_GPR_CTRL, &gpr_ctrl_host, 1, &dev); bma5_check_rslt("bma5_set_regs", rslt); @@ -139,6 +144,11 @@ int main(void) rslt = bma5_set_int_conf(&int_config, n_ints, &dev); bma5_check_rslt("bma5_set_int_conf", rslt); + printf("Int Configurations:\n"); + printf("Int1 mode: %s\n", enum_to_string(BMA5_INT1_MODE_LATCHED)); + printf("Int1 OD: %s\n", enum_to_string(BMA5_INT1_OD_PUSH_PULL)); + printf("Int1 Level: %s\n", enum_to_string(BMA5_INT1_LVL_ACTIVE_HIGH)); + printf("Keep the board stable\n"); for (;;) @@ -171,6 +181,11 @@ int main(void) rslt = bma580_set_feat_eng_gpr_0(&gpr_0, &dev); bma5_check_rslt("bma580_set_feat_eng_gpr_0", rslt); + if (rslt == BMA5_OK) + { + printf("Stationary detection disabled\n"); + } + /*Delay for generic interrupt reset*/ dev.delay_us(40000, dev.intf_ptr); diff --git a/examples/tap/Makefile b/examples/tap/Makefile index 0869ad7..30bed94 100644 --- a/examples/tap/Makefile +++ b/examples/tap/Makefile @@ -14,5 +14,5 @@ $(COMMON_LOCATION)/common/common.c INCLUDEPATHS += \ $(API_LOCATION) \ $(COMMON_LOCATION)/common - +COINES_BACKEND ?= COINES_BRIDGE include $(COINES_INSTALL_PATH)/coines.mk diff --git a/examples/tap/tap.c b/examples/tap/tap.c index cfdac92..8104077 100644 --- a/examples/tap/tap.c +++ b/examples/tap/tap.c @@ -50,12 +50,12 @@ int main(void) struct bma580_feat_eng_gpr_0 gpr_0; struct bma580_int_status_types int_status; uint8_t s_tap_count = 0, d_tap_count = 0, t_tap_count = 0; - enum bma5_context context; int_config.int_src = BMA5_INT_1; int_status.int_src = BMA580_INT_STATUS_INT1; /* Assign context parameter selection */ + enum bma5_context context; context = BMA5_HEARABLE; /* Interface reference is given as a parameter @@ -65,9 +65,10 @@ int main(void) rslt = bma5_interface_init(&dev, BMA5_SPI_INTF, context); bma5_check_rslt("bma5_interface_init", rslt); + /* Initialize the BMA580 device instance */ rslt = bma580_init(&dev); bma5_check_rslt("bma580_init", rslt); - printf("BMA580 Chip ID is 0x%X\n", dev.chip_id); + printf("Chip ID :0x%X\n", dev.chip_id); printf("\nDefault configurations\n\n"); rslt = bma580_get_default_tap_config(&conf, &dev); @@ -145,6 +146,11 @@ int main(void) rslt = bma580_set_feat_eng_gpr_0(&gpr_0, &dev); bma5_check_rslt("bma580_set_feat_eng_gpr_0", rslt); + if (rslt == BMA5_OK) + { + printf("Tap detection enabled\n"); + } + rslt = bma5_set_regs(BMA5_REG_FEAT_ENG_GPR_CTRL, &gpr_ctrl_host, 1, &dev); bma5_check_rslt("bma5_set_regs", rslt); @@ -164,6 +170,8 @@ int main(void) rslt = bma580_set_int_map(&int_map, &dev); bma5_check_rslt("bma580_set_int_map", rslt); + printf("\n\nMap tap to hardware interrupt pin 1\n"); + /* Map hardware interrupt pin configurations */ rslt = bma5_get_int_conf(&int_config, n_ints, &dev); bma5_check_rslt("bma5_get_int_conf", rslt); @@ -175,13 +183,20 @@ int main(void) rslt = bma5_set_int_conf(&int_config, n_ints, &dev); bma5_check_rslt("bma5_set_int_conf", rslt); + printf("\n\nInt Configurations:\n"); + printf("Int1 mode: %s\n", enum_to_string(BMA5_INT1_MODE_LATCHED)); + printf("Int1 OD: %s\n", enum_to_string(BMA5_INT1_OD_PUSH_PULL)); + printf("Int1 Level: %s\n", enum_to_string(BMA5_INT1_LVL_ACTIVE_HIGH)); + printf("\n\nTap the board to detect single, double, triple taps\n"); for (;;) { + /* Read the hardware interrupt pin 1 status */ rslt = bma580_get_int_status(&int_status, n_status, &dev); bma5_check_rslt("bma580_get_int_status", rslt); + /* Checking interrupt status to check tap detection */ if (int_status.int_status.stap_int_status & BMA5_ENABLE) { printf("Single Tap interrupt occurred\n"); @@ -192,6 +207,7 @@ int main(void) s_tap_count++; } + /* Checking interrupt status to check tap detection */ if (int_status.int_status.dtap_int_status & BMA5_ENABLE) { printf("Double Tap interrupt occurred\n"); @@ -202,6 +218,7 @@ int main(void) d_tap_count++; } + /* Checking interrupt status to check tap detection */ if (int_status.int_status.ttap_int_status & BMA5_ENABLE) { printf("Triple Tap interrupt occurred\n"); diff --git a/examples/temperature/Makefile b/examples/temperature/Makefile index 4851ccd..96d7198 100644 --- a/examples/temperature/Makefile +++ b/examples/temperature/Makefile @@ -14,5 +14,5 @@ $(COMMON_LOCATION)/common/common.c INCLUDEPATHS += \ $(API_LOCATION) \ $(COMMON_LOCATION)/common - +COINES_BACKEND ?= COINES_BRIDGE include $(COINES_INSTALL_PATH)/coines.mk \ No newline at end of file diff --git a/examples/temperature/temperature.c b/examples/temperature/temperature.c index 80d3c1b..415ecea 100644 --- a/examples/temperature/temperature.c +++ b/examples/temperature/temperature.c @@ -46,9 +46,11 @@ int main(void) struct bma5_sensor_status status; uint8_t temperature = 0; int8_t temp_celsius = 0; - enum bma5_context context; + uint8_t limit = 50; /* Assign context parameter selection */ + enum bma5_context context; + context = BMA5_HEARABLE; /* Interface reference is given as a parameter @@ -60,7 +62,7 @@ int main(void) rslt = bma580_init(&dev); bma5_check_rslt("bma580_init", rslt); - printf("BMA580 Chip ID is 0x%X\n", dev.chip_id); + printf("Chip ID :0x%X\n", dev.chip_id); /* Get temperature config */ rslt = bma5_get_temp_conf(&config, &dev); @@ -74,14 +76,20 @@ int main(void) rslt = bma5_set_temp_conf(&config, &dev); bma5_check_rslt("bma5_set_temp_conf", rslt); - printf("\nCount, Temparature data\n"); + printf("\nTemp Configurations\n"); + printf("Temp Rate: %s\n", enum_to_string(BMA5_TEMP_RATE_HZ_25)); + printf("Temp Meas Src: %s\n", enum_to_string(BMA5_TEMP_MEAS_SRC_TMP_INT)); + printf("Temp Ext Sel: %s\n", enum_to_string(BMA5_TEMP_EXT_SEL_INT2)); + + printf("\nCount, Temp\n"); - while (loop < 50) + while (loop < limit) { /* Get temperature data ready status */ rslt = bma5_get_sensor_status(&status, &dev); bma5_check_rslt("bma5_get_sensor_status", rslt); + /* Check if temperature data is ready */ if (status.temperature_rdy & BMA5_ENABLE) { rslt = bma5_set_sensor_status(&status, &dev); @@ -96,7 +104,7 @@ int main(void) temp_celsius = (int8_t)(temperature + 23); } - printf("%d, \t%d(Deg C)\n", loop, temp_celsius); + printf("%d \t%d(Deg C)\n", loop, temp_celsius); loop++; } diff --git a/examples/vad/Makefile b/examples/vad/Makefile index 3f295ba..013e605 100644 --- a/examples/vad/Makefile +++ b/examples/vad/Makefile @@ -14,5 +14,5 @@ $(COMMON_LOCATION)/common/common.c INCLUDEPATHS += \ $(API_LOCATION) \ $(COMMON_LOCATION)/common - +COINES_BACKEND ?= COINES_BRIDGE include $(COINES_INSTALL_PATH)/coines.mk diff --git a/examples/vad/vad.c b/examples/vad/vad.c index b72c3cd..f3fca9c 100644 --- a/examples/vad/vad.c +++ b/examples/vad/vad.c @@ -55,12 +55,11 @@ int main(void) struct bma580_feat_eng_gpr_2 config; struct bma580_vad_config vad_config, get_vad_config; - enum bma5_context context; - int_config.int_src = BMA5_INT_2; int_status.int_src = BMA580_INT_STATUS_INT2; /* Assign context parameter selection */ + enum bma5_context context; context = BMA5_HEARABLE; /* Interface reference is given as a parameter @@ -70,9 +69,10 @@ int main(void) rslt = bma5_interface_init(&dev, BMA5_SPI_INTF, context); bma5_check_rslt("bma5_interface_init", rslt); + /* Initialize the sensor */ rslt = bma580_init(&dev); bma5_check_rslt("bma580_init", rslt); - printf("BMA580 Chip ID is 0x%X\n", dev.chip_id); + printf("Chip ID :0x%X\n", dev.chip_id); rslt = bma580_get_vad_config(&vad_config, &dev); bma5_check_rslt("bma580_get_vad_config", rslt); @@ -102,6 +102,11 @@ int main(void) rslt = bma5_set_int_conf(&int_config, n_ints, &dev); bma5_check_rslt("bma5_set_int_conf", rslt); + printf("Int Configurations:\n"); + printf("Int mode: %s\t\n", enum_to_string(BMA5_INT2_MODE_PULSED_LONG)); + printf("Int OD: %s\t\n", enum_to_string(BMA5_INT2_OD_PUSH_PULL)); + printf("Int LVL: %s\t\n", enum_to_string(BMA5_INT2_LVL_ACTIVE_HIGH)); + rslt = bma580_get_int_map(&int_map, &dev); bma5_check_rslt("bma580_get_int_map", rslt); @@ -118,6 +123,11 @@ int main(void) rslt = bma580_set_feat_eng_gpr_0(&gpr_0, &dev); bma5_check_rslt("bma580_set_feat_eng_gpr_0", rslt); + if (rslt == BMA5_OK) + { + printf("VAD enabled\n"); + } + rslt = bma5_set_regs(BMA5_REG_FEAT_ENG_GPR_CTRL, &gpr_ctrl_host, 1, &dev); bma5_check_rslt("bma5_set_regs", rslt); @@ -128,9 +138,11 @@ int main(void) for (;;) { + /* Read the hardware interrupt pin 2 status */ rslt = bma580_get_int_status(&int_status, n_status, &dev); bma5_check_rslt("bma580_get_int_status", rslt); + /* Checking interrupt status to check VAD detection */ if (int_status.int_status.vad_int_status & BMA5_ENABLE) { printf("VAD interrupt occurred\n");