43#define CHIP_NAME "STMicroelectronic L3GD20H"
44#define MANUFACTURER_NAME "STMicroelectronic"
45#define SUPPLY_VOLTAGE_MIN 2.2f
46#define SUPPLY_VOLTAGE_MAX 3.6f
47#define MAX_CURRENT 5.0f
48#define TEMPERATURE_MIN -40.0f
49#define TEMPERATURE_MAX 85.0f
50#define DRIVER_VERSION 2000
55#define L3GD20H_REG_WHO_AM_I 0x0F
56#define L3GD20H_REG_CTRL1 0x20
57#define L3GD20H_REG_CTRL2 0x21
58#define L3GD20H_REG_CTRL3 0x22
59#define L3GD20H_REG_CTRL4 0x23
60#define L3GD20H_REG_CTRL5 0x24
61#define L3GD20H_REG_REFERENCE 0x25
62#define L3GD20H_REG_OUT_TEMP 0x26
63#define L3GD20H_REG_STATUS 0x27
64#define L3GD20H_REG_OUT_X_L 0x28
65#define L3GD20H_REG_OUT_X_H 0x29
66#define L3GD20H_REG_OUT_Y_L 0x2A
67#define L3GD20H_REG_OUT_Y_H 0x2B
68#define L3GD20H_REG_OUT_Z_L 0x2C
69#define L3GD20H_REG_OUT_Z_H 0x2D
70#define L3GD20H_REG_FIFO_CTRL 0x2E
71#define L3GD20H_REG_FIFO_SRC 0x2F
72#define L3GD20H_REG_IG_CFG 0x30
73#define L3GD20H_REG_IG_SRC 0x31
74#define L3GD20H_REG_IG_THS_XH 0x32
75#define L3GD20H_REG_IG_THS_XL 0x33
76#define L3GD20H_REG_IG_THS_YH 0x34
77#define L3GD20H_REG_IG_THS_YL 0x35
78#define L3GD20H_REG_IG_THS_ZH 0x36
79#define L3GD20H_REG_IG_THS_ZL 0x37
80#define L3GD20H_REG_IG_DURATION 0x38
81#define L3GD20H_REG_LOW_ODR 0x39
94static uint8_t a_l3gd20h_iic_spi_read(
l3gd20h_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
120 if (handle->
spi_read(reg, buf, len) != 0)
142static uint8_t a_l3gd20h_iic_spi_write(
l3gd20h_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
168 if (handle->
spi_write(reg, buf, len) != 0)
195 handle->
iic_spi = (uint8_t)interface;
237 handle->
iic_addr = (uint8_t)addr_pin;
290 handle->
debug_print(
"l3gd20h: read ctrl1 failed.\n");
338 handle->
debug_print(
"l3gd20h: read ctrl1 failed.\n");
342 if ((prev & 0x07) != 0)
349 if ((prev & (1 << 3)) != 0)
391 handle->
debug_print(
"l3gd20h: read ctrl1 failed.\n");
395 prev &= ~(1 << axis);
396 prev |= enable << axis;
429 handle->
debug_print(
"l3gd20h: read ctrl1 failed.\n");
466 handle->
debug_print(
"l3gd20h: read ctrl1 failed.\n");
471 prev |= (rate_bandwidth & 0xF) << 4;
472 if (a_l3gd20h_iic_spi_write(handle,
L3GD20H_REG_CTRL1, (uint8_t *)&prev, 1) != 0)
474 handle->
debug_print(
"l3gd20h: write ctrl1 failed.\n");
482 handle->
debug_print(
"l3gd20h: read low odr failed.\n");
487 prev |= ((rate_bandwidth & 0x10) >> 4) & 0x01;
490 handle->
debug_print(
"l3gd20h: write low odr failed.\n");
511 uint8_t res, prev1, prev2;
525 handle->
debug_print(
"l3gd20h: read ctrl1 failed.\n");
532 handle->
debug_print(
"l3gd20h: read low odr failed.\n");
568 handle->
debug_print(
"l3gd20h: read ctrl2 failed.\n");
605 handle->
debug_print(
"l3gd20h: read ctrl2 failed.\n");
643 handle->
debug_print(
"l3gd20h: read ctrl2 failed.\n");
680 handle->
debug_print(
"l3gd20h: read ctrl2 failed.\n");
717 handle->
debug_print(
"l3gd20h: read ctrl2 failed.\n");
754 handle->
debug_print(
"l3gd20h: read ctrl2 failed.\n");
791 handle->
debug_print(
"l3gd20h: read ctrl2 failed.\n");
828 handle->
debug_print(
"l3gd20h: read ctrl2 failed.\n");
865 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
902 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
939 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
976 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1013 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1050 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1087 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1092 prev |= pin_type << 4;
1124 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1161 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1166 prev |= enable << 3;
1198 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1235 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1240 prev |= enable << 2;
1272 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1309 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1314 prev |= enable << 1;
1346 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1383 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1388 prev |= enable << 0;
1420 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1457 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1462 prev |= enable << 7;
1494 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1531 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1536 prev |= data_format << 6;
1568 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1605 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1610 prev |= full_scale << 4;
1642 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1679 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1684 prev |= enable << 3;
1716 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1753 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1758 prev |= self_test << 1;
1790 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1827 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1832 prev |= spi_wire << 0;
1864 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1901 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
1938 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
1975 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
1980 prev |= enable << 6;
2012 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
2049 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
2054 prev |= enable << 5;
2086 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
2123 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
2128 prev |= enable << 4;
2160 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
2197 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
2202 prev |= selection << 2;
2234 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
2271 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
2276 prev |= selection << 0;
2308 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
2396 handle->
debug_print(
"l3gd20h: read temperature failed.\n");
2400 *temp = (float)(*raw) * (-1.0f) + 25.0f;
2457 handle->
debug_print(
"l3gd20h: read fifo ctrl failed.\n");
2462 prev |= fifo_mode << 5;
2494 handle->
debug_print(
"l3gd20h: read fifo ctrl failed.\n");
2531 handle->
debug_print(
"l3gd20h: threshold is invalid.\n");
2538 handle->
debug_print(
"l3gd20h: read fifo ctrl failed.\n");
2575 handle->
debug_print(
"l3gd20h: read fifo ctrl failed.\n");
2612 handle->
debug_print(
"l3gd20h: read fifo src failed.\n");
2650 handle->
debug_print(
"l3gd20h: read interrupt cfg failed.\n");
2654 prev &= ~(1 << interrupt_event);
2655 prev |= enable << interrupt_event;
2688 handle->
debug_print(
"l3gd20h: read interrupt cfg failed.\n");
2692 prev &= (1 << interrupt_event);
2725 handle->
debug_print(
"l3gd20h: read interrupt source failed.\n");
2758 if (threshold > 0x8000U)
2760 handle->
debug_print(
"l3gd20h: threshold is invalid.\n");
2768 handle->
debug_print(
"l3gd20h: read x interrupt threshold failed.\n");
2772 buf[0] = (buf[0] & 0x80) | ((threshold >> 8) & 0x7F);
2773 buf[1] = (threshold) & 0xFF;
2778 handle->
debug_print(
"l3gd20h: write x interrupt high threshold failed.\n");
2786 handle->
debug_print(
"l3gd20h: write x interrupt low threshold failed.\n");
2820 handle->
debug_print(
"l3gd20h: read x interrupt high threshold failed.\n");
2826 handle->
debug_print(
"l3gd20h: read x interrupt low threshold failed.\n");
2830 *threshold = (uint16_t)((uint16_t)buf[0] << 8) | buf[1];
2831 *threshold &= ~(1 << 15);
2861 if (threshold > 0x8000U)
2863 handle->
debug_print(
"l3gd20h: threshold is invalid.\n");
2868 buf[0] = (threshold >> 8) & 0xFF;
2869 buf[1] = (threshold) & 0xFF;
2874 handle->
debug_print(
"l3gd20h: write y interrupt high threshold failed.\n");
2881 handle->
debug_print(
"l3gd20h: write y interrupt low threshold failed.\n");
2915 handle->
debug_print(
"l3gd20h: read y interrupt high threshold failed.\n");
2921 handle->
debug_print(
"l3gd20h: read y interrupt low threshold failed.\n");
2925 *threshold = (uint16_t)(buf[0] << 8) | buf[1];
2926 *threshold &= ~(1 << 15);
2956 if (threshold > 0x8000U)
2958 handle->
debug_print(
"l3gd20h: threshold is invalid.\n");
2963 buf[0] = (threshold >> 8) & 0xFF;
2964 buf[1] = (threshold) & 0xFF;
2969 handle->
debug_print(
"l3gd20h: write z interrupt high threshold failed.\n");
2976 handle->
debug_print(
"l3gd20h: write z interrupt low threshold failed.\n");
3010 handle->
debug_print(
"l3gd20h: read z interrupt high threshold failed.\n");
3016 handle->
debug_print(
"l3gd20h: read z interrupt low threshold failed.\n");
3020 *threshold = (uint16_t)((uint16_t)buf[0] << 8) | buf[1];
3021 *threshold &= ~(1 << 15);
3053 handle->
debug_print(
"l3gd20h: read x interrupt threshold failed.\n");
3058 prev |= counter_mode << 7;
3090 handle->
debug_print(
"l3gd20h: read x interrupt threshold failed.\n");
3127 handle->
debug_print(
"l3gd20h: read duration failed.\n");
3132 prev |= enable << 7;
3164 handle->
debug_print(
"l3gd20h: read duration failed.\n");
3197 if (duration > 0x7F)
3199 handle->
debug_print(
"l3gd20h: duration is over 0x7F.\n");
3207 handle->
debug_print(
"l3gd20h: read duration failed.\n");
3211 prev |= duration & 0x7F;
3243 handle->
debug_print(
"l3gd20h: read duration failed.\n");
3280 handle->
debug_print(
"l3gd20h: read low odr failed.\n");
3317 handle->
debug_print(
"l3gd20h: read low odr failed.\n");
3354 handle->
debug_print(
"l3gd20h: read low odr failed.\n");
3359 prev |= enable << 3;
3391 handle->
debug_print(
"l3gd20h: read low odr failed.\n");
3427 handle->
debug_print(
"l3gd20h: read low odr failed.\n");
3451 uint8_t range, prev;
3462 if (a_l3gd20h_iic_spi_read(handle,
L3GD20H_REG_CTRL4, (uint8_t *)&prev, 1) != 0)
3464 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
3468 range = (prev & (3 << 4)) >> 4;
3471 *reg = (uint16_t)(dps * 1000.0f / 8.75f);
3473 else if (range == 1)
3475 *reg = (uint16_t)(dps * 1000.0f / 17.50f);
3479 *reg = (uint16_t)(dps * 1000.0f / 70.0f);
3499 uint8_t range, prev;
3510 if (a_l3gd20h_iic_spi_read(handle,
L3GD20H_REG_CTRL4, (uint8_t *)&prev, 1) != 0)
3512 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
3516 range = (prev & (3 << 4)) >> 4;
3519 *dps = (float)(reg * 8.75f / 1000.0f);
3521 else if (range == 1)
3523 *dps = (float)(reg * 17.50f / 1000.0f);
3527 *dps = (float)(reg * 70.0f / 1000.0f);
3562 handle->
debug_print(
"l3gd20h: read interrupt source failed.\n");
3566 if ((prev & (1 << 6)) != 0)
3573 if ((prev & (1 << 5)) != 0)
3580 if ((prev & (1 << 4)) != 0)
3587 if ((prev & (1 << 3)) != 0)
3594 if ((prev & (1 << 2)) != 0)
3601 if ((prev & (1 << 1)) != 0)
3608 if ((prev & (1 << 0)) != 0)
3623 handle->
debug_print(
"l3gd20h: read status failed.\n");
3687 handle->
debug_print(
"l3gd20h: read fifo source failed.\n");
3691 if ((prev & (1 << 7)) != 0)
3698 if ((prev & (1 << 6)) != 0)
3705 if ((prev & (1 << 5)) != 0)
3717 handle->
debug_print(
"l3gd20h: interrupt number is invalid.\n");
3749 handle->
debug_print(
"l3gd20h: iic_init is null.\n");
3755 handle->
debug_print(
"l3gd20h: iic_deinit is null.\n");
3761 handle->
debug_print(
"l3gd20h: iic_read is null.\n");
3767 handle->
debug_print(
"l3gd20h: iic_write is null.\n");
3773 handle->
debug_print(
"l3gd20h: spi_init is null.\n");
3779 handle->
debug_print(
"l3gd20h: spi_deinit is null.\n");
3785 handle->
debug_print(
"l3gd20h: spi_read is null.\n");
3791 handle->
debug_print(
"l3gd20h: spi_write is null.\n");
3797 handle->
debug_print(
"l3gd20h: delay_ms is null.\n");
3806 handle->
debug_print(
"l3gd20h: iic init failed.\n");
3815 handle->
debug_print(
"l3gd20h: spi init failed.\n");
3822 handle->
debug_print(
"l3gd20h: read id failed.\n");
3852 handle->
debug_print(
"l3gd20h: read low odr failed.\n");
3869 handle->
debug_print(
"l3gd20h: write low odr failed.\n");
3885 handle->
debug_print(
"l3gd20h: read low odr failed.\n");
3897 if (((prev >> 2) & 0x01) != 0x0)
3899 handle->
debug_print(
"l3gd20h: reset chip failed.\n");
3944 handle->
debug_print(
"l3gd20h: read ctrl1 failed.\n");
3952 handle->
debug_print(
"l3gd20h: write ctrl1 failed.\n");
3978 uint8_t mode, cnt, i;
3979 uint8_t ble, range, enable;
3980 uint8_t buf[32 * 6];
3993 handle->
debug_print(
"l3gd20h: length is zero.\n");
3999 handle->
debug_print(
"l3gd20h: read fifo ctrl failed.\n");
4004 if (a_l3gd20h_iic_spi_read(handle,
L3GD20H_REG_CTRL5, (uint8_t *)&prev, 1) != 0)
4006 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
4010 enable = (prev & (1 << 6)) >> 6;
4011 if (a_l3gd20h_iic_spi_read(handle,
L3GD20H_REG_CTRL4, (uint8_t *)&prev, 1) != 0)
4013 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
4017 range = (prev & (3 << 4)) >> 4;
4018 ble = (prev & (1 << 6)) >> 6;
4019 if ((mode && enable) != 0)
4024 handle->
debug_print(
"l3gd20h: read fifo source failed.\n");
4029 *len = ((*len) < cnt) ? (*len) : cnt;
4033 handle->
debug_print(
"l3gd20h: read data failed.\n");
4037 for (i = 0; i < (*len); i++)
4041 raw[i][0] = (int16_t)(((uint16_t)buf[1 + i * 6] << 8) | buf[0 + i * 6]);
4042 raw[i][1] = (int16_t)(((uint16_t)buf[3 + i * 6] << 8) | buf[2 + i * 6]);
4043 raw[i][2] = (int16_t)(((uint16_t)buf[5 + i * 6] << 8) | buf[4 + i * 6]);
4047 raw[i][0] = (int16_t)(((uint16_t)buf[0 + i * 6] << 8) | buf[1 + i * 6]);
4048 raw[i][1] = (int16_t)(((uint16_t)buf[2 + i * 6] << 8) | buf[3 + i * 6]);
4049 raw[i][2] = (int16_t)(((uint16_t)buf[4 + i * 6] << 8) | buf[5 + i * 6]);
4053 dps[i][0] = (float)(raw[i][0]) * 8.75f / 1000.0f;
4054 dps[i][1] = (float)(raw[i][1]) * 8.75f / 1000.0f;
4055 dps[i][2] = (float)(raw[i][2]) * 8.75f / 1000.0f;
4057 else if (range == 1)
4059 dps[i][0] = (float)(raw[i][0]) * 17.5f / 1000.0f;
4060 dps[i][1] = (float)(raw[i][1]) * 17.5f / 1000.0f;
4061 dps[i][2] = (float)(raw[i][2]) * 17.5f / 1000.0f;
4065 dps[i][0] = (float)(raw[i][0]) * 70.0f / 1000.0f;
4066 dps[i][1] = (float)(raw[i][1]) * 70.0f / 1000.0f;
4067 dps[i][2] = (float)(raw[i][2]) * 70.0f / 1000.0f;
4077 handle->
debug_print(
"l3gd20h: read data failed.\n");
4083 raw[0][0] = (int16_t)(((uint16_t)buf[1] << 8) | buf[0]);
4084 raw[0][1] = (int16_t)(((uint16_t)buf[3] << 8) | buf[2]);
4085 raw[0][2] = (int16_t)(((uint16_t)buf[5] << 8) | buf[4]);
4089 raw[0][0] = (int16_t)(((uint16_t)buf[0] << 8) | buf[1]);
4090 raw[0][1] = (int16_t)(((uint16_t)buf[2] << 8) | buf[3]);
4091 raw[0][2] = (int16_t)(((uint16_t)buf[4] << 8) | buf[5]);
4095 dps[0][0] = (float)(raw[0][0]) * 8.75f / 1000.0f;
4096 dps[0][1] = (float)(raw[0][1]) * 8.75f / 1000.0f;
4097 dps[0][2] = (float)(raw[0][2]) * 8.75f / 1000.0f;
4099 else if (range == 1)
4101 dps[0][0] = (float)(raw[0][0]) * 17.5f / 1000.0f;
4102 dps[0][1] = (float)(raw[0][1]) * 17.5f / 1000.0f;
4103 dps[0][2] = (float)(raw[0][2]) * 17.5f / 1000.0f;
4107 dps[0][0] = (float)(raw[0][0]) * 70.0f / 1000.0f;
4108 dps[0][1] = (float)(raw[0][1]) * 70.0f / 1000.0f;
4109 dps[0][2] = (float)(raw[0][2]) * 70.0f / 1000.0f;
4140 return a_l3gd20h_iic_spi_write(handle, reg, buf, len);
4167 return a_l3gd20h_iic_spi_read(handle, reg, buf, len);
#define L3GD20H_REG_WHO_AM_I
chip register definition
#define L3GD20H_REG_REFERENCE
#define L3GD20H_REG_IG_CFG
#define L3GD20H_REG_CTRL4
#define L3GD20H_REG_CTRL2
#define L3GD20H_REG_FIFO_SRC
#define L3GD20H_REG_CTRL3
#define L3GD20H_REG_IG_THS_ZH
#define L3GD20H_REG_IG_THS_YH
#define L3GD20H_REG_CTRL1
#define L3GD20H_REG_FIFO_CTRL
#define L3GD20H_REG_IG_SRC
#define SUPPLY_VOLTAGE_MAX
#define L3GD20H_REG_IG_THS_XH
#define L3GD20H_REG_IG_THS_ZL
#define MANUFACTURER_NAME
#define L3GD20H_REG_OUT_X_L
#define SUPPLY_VOLTAGE_MIN
#define L3GD20H_REG_OUT_TEMP
#define L3GD20H_REG_CTRL5
#define L3GD20H_REG_IG_DURATION
#define L3GD20H_REG_IG_THS_YL
#define L3GD20H_REG_IG_THS_XL
#define CHIP_NAME
chip register definition
#define L3GD20H_REG_STATUS
#define L3GD20H_REG_LOW_ODR
driver l3gd20h header file
uint8_t l3gd20h_set_high_pass_filter(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable high pass filter
uint8_t l3gd20h_set_data_format(l3gd20h_handle_t *handle, l3gd20h_data_format_t data_format)
set the data format
uint8_t l3gd20h_get_status(l3gd20h_handle_t *handle, uint8_t *status)
get the chip status
struct l3gd20h_info_s l3gd20h_info_t
l3gd20h information structure definition
uint8_t l3gd20h_set_block_data_update(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the block data update
uint8_t l3gd20h_soft_reset(l3gd20h_handle_t *handle)
soft reset the device
l3gd20h_boot_t
l3gd20h boot enumeration definition
uint8_t l3gd20h_set_mode(l3gd20h_handle_t *handle, l3gd20h_mode_t mode)
set the chip mode
uint8_t l3gd20h_get_boot(l3gd20h_handle_t *handle, l3gd20h_boot_t *boot)
get the boot
uint8_t l3gd20h_get_high_pass_filter_reference(l3gd20h_handle_t *handle, uint8_t *value)
get the high pass filter reference
uint8_t l3gd20h_get_axis(l3gd20h_handle_t *handle, l3gd20h_axis_t axis, l3gd20h_bool_t *enable)
get the axis
uint8_t l3gd20h_get_mode(l3gd20h_handle_t *handle, l3gd20h_mode_t *mode)
get the chip mode
uint8_t l3gd20h_get_out_selection(l3gd20h_handle_t *handle, l3gd20h_selection_t *selection)
get the out selection
uint8_t l3gd20h_info(l3gd20h_info_t *info)
get chip's information
l3gd20h_spi_wire_t
l3gd20h spi wire enumeration definition
uint8_t l3gd20h_read_temperature(l3gd20h_handle_t *handle, int8_t *raw, float *temp)
read the temperature
uint8_t l3gd20h_get_full_scale(l3gd20h_handle_t *handle, l3gd20h_full_scale_t *full_scale)
get the full scale
uint8_t l3gd20h_set_high_pass_filter_mode(l3gd20h_handle_t *handle, l3gd20h_high_pass_filter_mode_t mode)
set the high pass filter mode
l3gd20h_self_test_t
l3gd20h self test type enumeration definition
uint8_t l3gd20h_set_rate_bandwidth(l3gd20h_handle_t *handle, l3gd20h_lodr_odr_bw_t rate_bandwidth)
set the rate bandwidth
uint8_t l3gd20h_get_rate_bandwidth(l3gd20h_handle_t *handle, l3gd20h_lodr_odr_bw_t *rate_bandwidth)
get the rate bandwidth
uint8_t l3gd20h_set_level_sensitive_latched(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the level sensitive latched
uint8_t l3gd20h_read(l3gd20h_handle_t *handle, int16_t(*raw)[3], float(*dps)[3], uint16_t *len)
read the data
uint8_t l3gd20h_set_out_selection(l3gd20h_handle_t *handle, l3gd20h_selection_t selection)
set the out selection
l3gd20h_full_scale_t
l3gd20h full scale type enumeration definition
uint8_t l3gd20h_set_boot(l3gd20h_handle_t *handle, l3gd20h_boot_t boot)
set the boot
uint8_t l3gd20h_set_addr_pin(l3gd20h_handle_t *handle, l3gd20h_address_t addr_pin)
set the iic address pin
l3gd20h_address_t
l3gd20h address enumeration definition
uint8_t l3gd20h_set_interface(l3gd20h_handle_t *handle, l3gd20h_interface_t interface)
set the chip interface
uint8_t l3gd20h_set_iic(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the iic interface
l3gd20h_high_pass_filter_mode_t
l3gd20h high pass filter mode enumeration definition
uint8_t l3gd20h_get_level_trigger(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the level trigger status
l3gd20h_data_format_t
l3gd20h data format enumeration definition
l3gd20h_high_pass_filter_cut_off_frequency_t
l3gd20h high pass filter cut off frequency enumeration definition
uint8_t l3gd20h_set_high_pass_filter_reference(l3gd20h_handle_t *handle, uint8_t value)
set the high pass filter reference
uint8_t l3gd20h_deinit(l3gd20h_handle_t *handle)
close the chip
uint8_t l3gd20h_get_addr_pin(l3gd20h_handle_t *handle, l3gd20h_address_t *addr_pin)
get the iic address pin
uint8_t l3gd20h_set_edge_trigger(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the edge trigger
l3gd20h_interface_t
l3gd20h interface enumeration definition
uint8_t l3gd20h_set_full_scale(l3gd20h_handle_t *handle, l3gd20h_full_scale_t full_scale)
set the full scale
l3gd20h_axis_t
l3gd20h axis enumeration definition
uint8_t l3gd20h_irq_handler(l3gd20h_handle_t *handle, uint8_t num)
interrupt handler
l3gd20h_selection_t
l3gd20h selection enumeration definition
uint8_t l3gd20h_get_high_pass_filter_cut_off_frequency(l3gd20h_handle_t *handle, l3gd20h_high_pass_filter_cut_off_frequency_t *frequency)
get the high pass filter cut off frequency
uint8_t l3gd20h_init(l3gd20h_handle_t *handle)
initialize the chip
uint8_t l3gd20h_get_high_pass_filter(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get high pass filter status
uint8_t l3gd20h_get_data_format(l3gd20h_handle_t *handle, l3gd20h_data_format_t *data_format)
get the data format
uint8_t l3gd20h_get_interface(l3gd20h_handle_t *handle, l3gd20h_interface_t *interface)
get the chip interface
uint8_t l3gd20h_get_high_pass_filter_mode(l3gd20h_handle_t *handle, l3gd20h_high_pass_filter_mode_t *mode)
get the high pass filter mode
l3gd20h_mode_t
l3gd20h mode enumeration definition
uint8_t l3gd20h_set_spi_wire(l3gd20h_handle_t *handle, l3gd20h_spi_wire_t spi_wire)
set the spi wire
uint8_t l3gd20h_set_level_trigger(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the level trigger
uint8_t l3gd20h_get_block_data_update(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the block data update status
l3gd20h_bool_t
l3gd20h bool enumeration definition
uint8_t l3gd20h_get_edge_trigger(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the edge trigger status
l3gd20h_lodr_odr_bw_t
l3gd20h low odr odr bw enumeration definition
uint8_t l3gd20h_get_spi_wire(l3gd20h_handle_t *handle, l3gd20h_spi_wire_t *spi_wire)
get the spi wire
uint8_t l3gd20h_set_self_test(l3gd20h_handle_t *handle, l3gd20h_self_test_t self_test)
set the self test
uint8_t l3gd20h_set_high_pass_filter_cut_off_frequency(l3gd20h_handle_t *handle, l3gd20h_high_pass_filter_cut_off_frequency_t frequency)
set the high pass filter cut off frequency
uint8_t l3gd20h_set_axis(l3gd20h_handle_t *handle, l3gd20h_axis_t axis, l3gd20h_bool_t enable)
set the axis
uint8_t l3gd20h_get_level_sensitive_latched(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the level sensitive latched status
uint8_t l3gd20h_get_iic(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the iic interface status
uint8_t l3gd20h_get_self_test(l3gd20h_handle_t *handle, l3gd20h_self_test_t *self_test)
get the self test
struct l3gd20h_handle_s l3gd20h_handle_t
l3gd20h handle structure definition
@ L3GD20H_STATUS_XYZ_OVERRUN
@ L3GD20H_STATUS_Y_DATA_READY
@ L3GD20H_STATUS_Y_OVERRUN
@ L3GD20H_STATUS_Z_OVERRUN
@ L3GD20H_STATUS_X_DATA_READY
@ L3GD20H_STATUS_Z_DATA_READY
@ L3GD20H_STATUS_XYZ_DATA_READY
@ L3GD20H_STATUS_X_OVERRUN
uint8_t l3gd20h_set_reg(l3gd20h_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
set the chip register
uint8_t l3gd20h_get_reg(l3gd20h_handle_t *handle, uint8_t reg, uint8_t *buf, uint16_t len)
get the chip register
uint8_t l3gd20h_get_fifo_mode(l3gd20h_handle_t *handle, l3gd20h_fifo_mode_t *fifo_mode)
get the fifo mode
uint8_t l3gd20h_get_fifo_threshold(l3gd20h_handle_t *handle, uint8_t *threshold)
get the fifo threshold
uint8_t l3gd20h_set_stop_on_fifo_threshold(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable stop on fifo threshold
uint8_t l3gd20h_set_fifo_mode(l3gd20h_handle_t *handle, l3gd20h_fifo_mode_t fifo_mode)
set the fifo mode
uint8_t l3gd20h_get_fifo_level(l3gd20h_handle_t *handle, uint8_t *level)
get the fifo level
uint8_t l3gd20h_set_fifo(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the fifo
l3gd20h_fifo_mode_t
l3gd20h fifo mode enumeration definition
uint8_t l3gd20h_set_fifo_threshold(l3gd20h_handle_t *handle, uint8_t threshold)
set the fifo threshold
uint8_t l3gd20h_get_fifo(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the fifo status
uint8_t l3gd20h_get_stop_on_fifo_threshold(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get stop on fifo threshold status
uint8_t l3gd20h_set_interrupt_pin_type(l3gd20h_handle_t *handle, l3gd20h_pin_type_t pin_type)
set the interrupt pin type
uint8_t l3gd20h_set_data_ready_on_interrupt2(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the data ready on interrupt2
uint8_t l3gd20h_get_interrupt_source(l3gd20h_handle_t *handle, uint8_t *src)
get the interrupt source
uint8_t l3gd20h_get_interrupt_active_level(l3gd20h_handle_t *handle, l3gd20h_interrupt_active_level_t *level)
get the interrupt active level
uint8_t l3gd20h_get_duration(l3gd20h_handle_t *handle, uint8_t *duration)
get the wait duration
uint8_t l3gd20h_get_interrupt_event(l3gd20h_handle_t *handle, l3gd20h_interrupt_event_t interrupt_event, l3gd20h_bool_t *enable)
get the interrupt event
uint8_t l3gd20h_get_x_interrupt_threshold(l3gd20h_handle_t *handle, uint16_t *threshold)
get the x interrupt threshold
uint8_t l3gd20h_get_fifo_empty_on_interrupt2(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the fifo empty on interrupt2 status
uint8_t l3gd20h_get_interrupt_pin_type(l3gd20h_handle_t *handle, l3gd20h_pin_type_t *pin_type)
get the interrupt pin type
uint8_t l3gd20h_get_counter_mode(l3gd20h_handle_t *handle, l3gd20h_counter_mode_t *counter_mode)
get the counter mode
uint8_t l3gd20h_set_boot_on_interrupt1(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable boot on the interrupt1
uint8_t l3gd20h_set_x_interrupt_threshold(l3gd20h_handle_t *handle, uint16_t threshold)
set the x interrupt threshold
l3gd20h_interrupt_event_t
l3gd20h interrupt event enumeration definition
uint8_t l3gd20h_interrupt_threshold_convert_to_data(l3gd20h_handle_t *handle, uint16_t reg, float *dps)
convert the interrupt threshold register raw data to the real data
uint8_t l3gd20h_set_wait(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the wait
uint8_t l3gd20h_set_interrupt_event(l3gd20h_handle_t *handle, l3gd20h_interrupt_event_t interrupt_event, l3gd20h_bool_t enable)
set the interrupt event
l3gd20h_counter_mode_t
l3gd20h counter mode enumeration definition
uint8_t l3gd20h_set_duration(l3gd20h_handle_t *handle, uint8_t duration)
set the wait duration
uint8_t l3gd20h_set_fifo_threshold_on_interrupt2(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the fifo threshold on interrupt2
uint8_t l3gd20h_get_y_interrupt_threshold(l3gd20h_handle_t *handle, uint16_t *threshold)
get the y interrupt threshold
uint8_t l3gd20h_get_fifo_threshold_on_interrupt2(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the fifo threshold on interrupt2 status
uint8_t l3gd20h_get_wait(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the wait status
uint8_t l3gd20h_set_data_ready_active_level(l3gd20h_handle_t *handle, l3gd20h_interrupt_active_level_t level)
set the data ready active level
uint8_t l3gd20h_get_fifo_overrun_on_interrupt2(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the fifo overrun on interrupt2 status
uint8_t l3gd20h_set_counter_mode(l3gd20h_handle_t *handle, l3gd20h_counter_mode_t counter_mode)
set the counter mode
uint8_t l3gd20h_get_data_ready_on_interrupt2(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the data ready on interrupt2 status
uint8_t l3gd20h_get_boot_on_interrupt1(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the boot on the interrupt1 status
uint8_t l3gd20h_get_interrupt1(l3gd20h_handle_t *handle, l3gd20h_bool_t *enable)
get the interrupt1 status
uint8_t l3gd20h_set_interrupt_active_level(l3gd20h_handle_t *handle, l3gd20h_interrupt_active_level_t level)
set the interrupt active level
uint8_t l3gd20h_set_fifo_overrun_on_interrupt2(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the fifo overrun on interrupt2
l3gd20h_interrupt_active_level_t
l3gd20h interrupt active level enumeration definition
uint8_t l3gd20h_interrupt_threshold_convert_to_register(l3gd20h_handle_t *handle, float dps, uint16_t *reg)
convert the interrupt threshold real data to the register raw data
uint8_t l3gd20h_get_z_interrupt_threshold(l3gd20h_handle_t *handle, uint16_t *threshold)
get the z interrupt threshold
uint8_t l3gd20h_set_interrupt_selection(l3gd20h_handle_t *handle, l3gd20h_selection_t selection)
set the interrupt selection
uint8_t l3gd20h_get_interrupt_selection(l3gd20h_handle_t *handle, l3gd20h_selection_t *selection)
get the interrupt selection
uint8_t l3gd20h_set_fifo_empty_on_interrupt2(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the fifo empty on interrupt2
uint8_t l3gd20h_set_z_interrupt_threshold(l3gd20h_handle_t *handle, uint16_t threshold)
set the z interrupt threshold
uint8_t l3gd20h_get_data_ready_active_level(l3gd20h_handle_t *handle, l3gd20h_interrupt_active_level_t *level)
get the data ready active level
uint8_t l3gd20h_set_interrupt1(l3gd20h_handle_t *handle, l3gd20h_bool_t enable)
enable or disable the interrupt1
uint8_t l3gd20h_set_y_interrupt_threshold(l3gd20h_handle_t *handle, uint16_t threshold)
set the y interrupt threshold
l3gd20h_pin_type_t
l3gd20h interrupt pin type enumeration definition
@ L3GD20H_INTERRUPT1_Y_HIGH
@ L3GD20H_INTERRUPT2_Y_DATA_READY
@ L3GD20H_INTERRUPT1_X_LOW
@ L3GD20H_INTERRUPT2_FIFO_EMPTY
@ L3GD20H_INTERRUPT1_X_HIGH
@ L3GD20H_INTERRUPT2_FIFO_THRESHOLD
@ L3GD20H_INTERRUPT1_Z_HIGH
@ L3GD20H_INTERRUPT2_FIFO_OVERRRUN
@ L3GD20H_INTERRUPT2_X_OVERRUN
@ L3GD20H_INTERRUPT2_Y_OVERRUN
@ L3GD20H_INTERRUPT2_X_DATA_READY
@ L3GD20H_INTERRUPT1_Y_LOW
@ L3GD20H_INTERRUPT1_INTERRUPT_ACTIVE
@ L3GD20H_INTERRUPT2_XYZ_DATA_READY
@ L3GD20H_INTERRUPT2_Z_OVERRUN
@ L3GD20H_INTERRUPT2_XYZ_OVERRUN
@ L3GD20H_INTERRUPT2_Z_DATA_READY
@ L3GD20H_INTERRUPT1_Z_LOW
uint8_t(* spi_init)(void)
void(* delay_ms)(uint32_t ms)
uint8_t(* spi_read)(uint8_t reg, uint8_t *buf, uint16_t len)
void(* receive_callback)(uint8_t type)
uint8_t(* spi_write)(uint8_t reg, uint8_t *buf, uint16_t len)
void(* debug_print)(const char *const fmt,...)
uint8_t(* iic_init)(void)
uint8_t(* spi_deinit)(void)
uint8_t(* iic_write)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_read)(uint8_t addr, uint8_t reg, uint8_t *buf, uint16_t len)
uint8_t(* iic_deinit)(void)
float supply_voltage_max_v
char manufacturer_name[32]
float supply_voltage_min_v