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)
163 if (handle->
spi_write(reg, buf, len) != 0)
190 handle->
iic_spi = (uint8_t)interface;
232 handle->
iic_addr = (uint8_t)addr_pin;
285 handle->
debug_print(
"l3gd20h: read ctrl1 failed.\n");
333 handle->
debug_print(
"l3gd20h: read ctrl1 failed.\n");
337 if ((prev & 0x07) != 0)
344 if ((prev & (1 << 3)) != 0)
386 handle->
debug_print(
"l3gd20h: read ctrl1 failed.\n");
390 prev &= ~(1 << axis);
391 prev |= enable << axis;
424 handle->
debug_print(
"l3gd20h: read ctrl1 failed.\n");
461 handle->
debug_print(
"l3gd20h: read ctrl1 failed.\n");
466 prev |= (rate_bandwidth & 0xF) << 4;
467 if (a_l3gd20h_iic_spi_write(handle,
L3GD20H_REG_CTRL1, (uint8_t *)&prev, 1) != 0)
469 handle->
debug_print(
"l3gd20h: write ctrl1 failed.\n");
477 handle->
debug_print(
"l3gd20h: read low odr failed.\n");
482 prev |= ((rate_bandwidth & 0x10) >> 4) & 0x01;
485 handle->
debug_print(
"l3gd20h: write low odr failed.\n");
506 uint8_t res, prev1, prev2;
520 handle->
debug_print(
"l3gd20h: read ctrl1 failed.\n");
527 handle->
debug_print(
"l3gd20h: read low odr failed.\n");
563 handle->
debug_print(
"l3gd20h: read ctrl2 failed.\n");
600 handle->
debug_print(
"l3gd20h: read ctrl2 failed.\n");
638 handle->
debug_print(
"l3gd20h: read ctrl2 failed.\n");
675 handle->
debug_print(
"l3gd20h: read ctrl2 failed.\n");
712 handle->
debug_print(
"l3gd20h: read ctrl2 failed.\n");
749 handle->
debug_print(
"l3gd20h: read ctrl2 failed.\n");
786 handle->
debug_print(
"l3gd20h: read ctrl2 failed.\n");
823 handle->
debug_print(
"l3gd20h: read ctrl2 failed.\n");
860 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
897 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
934 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
971 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1008 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1045 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1082 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1087 prev |= pin_type << 4;
1119 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1156 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1161 prev |= enable << 3;
1193 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1230 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1235 prev |= enable << 2;
1267 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1304 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1309 prev |= enable << 1;
1341 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1378 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1383 prev |= enable << 0;
1415 handle->
debug_print(
"l3gd20h: read ctrl3 failed.\n");
1452 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1457 prev |= enable << 7;
1489 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1526 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1531 prev |= data_format << 6;
1563 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1600 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1605 prev |= full_scale << 4;
1637 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1674 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1679 prev |= enable << 3;
1711 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1748 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1753 prev |= self_test << 1;
1785 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1822 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1827 prev |= spi_wire << 0;
1859 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
1896 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
1933 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
1970 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
1975 prev |= enable << 6;
2007 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
2044 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
2049 prev |= enable << 5;
2081 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
2118 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
2123 prev |= enable << 4;
2155 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
2192 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
2197 prev |= selection << 2;
2229 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
2266 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
2271 prev |= selection << 0;
2303 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
2391 handle->
debug_print(
"l3gd20h: read temperature failed.\n");
2395 *temp = (float)(*raw) * (-1.0f) + 25.0f;
2452 handle->
debug_print(
"l3gd20h: read fifo ctrl failed.\n");
2457 prev |= fifo_mode << 5;
2489 handle->
debug_print(
"l3gd20h: read fifo ctrl failed.\n");
2526 handle->
debug_print(
"l3gd20h: threshold is invalid.\n");
2533 handle->
debug_print(
"l3gd20h: read fifo ctrl failed.\n");
2570 handle->
debug_print(
"l3gd20h: read fifo ctrl failed.\n");
2607 handle->
debug_print(
"l3gd20h: read fifo src failed.\n");
2645 handle->
debug_print(
"l3gd20h: read interrupt cfg failed.\n");
2649 prev &= ~(1 << interrupt_event);
2650 prev |= enable << interrupt_event;
2683 handle->
debug_print(
"l3gd20h: read interrupt cfg failed.\n");
2687 prev &= (1 << interrupt_event);
2720 handle->
debug_print(
"l3gd20h: read interrupt source failed.\n");
2753 if (threshold > 0x8000U)
2755 handle->
debug_print(
"l3gd20h: threshold is invalid.\n");
2763 handle->
debug_print(
"l3gd20h: read x interrupt threshold failed.\n");
2767 buf[0] = buf[0] | ((threshold >> 8) & 0x7F);
2768 buf[1] = (threshold) & 0xFF;
2773 handle->
debug_print(
"l3gd20h: write x interrupt high threshold failed.\n");
2781 handle->
debug_print(
"l3gd20h: write x interrupt low threshold failed.\n");
2815 handle->
debug_print(
"l3gd20h: read x interrupt high threshold failed.\n");
2821 handle->
debug_print(
"l3gd20h: read x interrupt low threshold failed.\n");
2825 *threshold = (uint16_t)((uint16_t)buf[0] << 8) | buf[1];
2826 *threshold &= ~(1 << 15);
2856 if (threshold > 0x8000U)
2858 handle->
debug_print(
"l3gd20h: threshold is invalid.\n");
2863 buf[0] = (threshold >> 8) & 0xFF;
2864 buf[1] = (threshold) & 0xFF;
2869 handle->
debug_print(
"l3gd20h: write y interrupt high threshold failed.\n");
2876 handle->
debug_print(
"l3gd20h: write y interrupt low threshold failed.\n");
2910 handle->
debug_print(
"l3gd20h: read y interrupt high threshold failed.\n");
2916 handle->
debug_print(
"l3gd20h: read y interrupt low threshold failed.\n");
2920 *threshold = (uint16_t)(buf[0] << 8) | buf[1];
2921 *threshold &= ~(1 << 15);
2951 if (threshold > 0x8000U)
2953 handle->
debug_print(
"l3gd20h: threshold is invalid.\n");
2958 buf[0] = (threshold >> 8) & 0xFF;
2959 buf[1] = (threshold) & 0xFF;
2964 handle->
debug_print(
"l3gd20h: write z interrupt high threshold failed.\n");
2971 handle->
debug_print(
"l3gd20h: write z interrupt low threshold failed.\n");
3005 handle->
debug_print(
"l3gd20h: read z interrupt high threshold failed.\n");
3011 handle->
debug_print(
"l3gd20h: read z interrupt low threshold failed.\n");
3015 *threshold = (uint16_t)((uint16_t)buf[0] << 8) | buf[1];
3016 *threshold &= ~(1 << 15);
3048 handle->
debug_print(
"l3gd20h: read x interrupt threshold failed.\n");
3053 prev |= counter_mode << 7;
3085 handle->
debug_print(
"l3gd20h: read x interrupt threshold failed.\n");
3122 handle->
debug_print(
"l3gd20h: read duration failed.\n");
3127 prev |= enable << 7;
3159 handle->
debug_print(
"l3gd20h: read duration failed.\n");
3192 if (duration > 0x7F)
3194 handle->
debug_print(
"l3gd20h: duration is over 0x7F.\n");
3202 handle->
debug_print(
"l3gd20h: read duration failed.\n");
3206 prev |= duration & 0x7F;
3238 handle->
debug_print(
"l3gd20h: read duration failed.\n");
3275 handle->
debug_print(
"l3gd20h: read low odr failed.\n");
3312 handle->
debug_print(
"l3gd20h: read low odr failed.\n");
3349 handle->
debug_print(
"l3gd20h: read low odr failed.\n");
3354 prev |= enable << 3;
3386 handle->
debug_print(
"l3gd20h: read low odr failed.\n");
3422 handle->
debug_print(
"l3gd20h: read low odr failed.\n");
3446 uint8_t range, prev;
3457 if (a_l3gd20h_iic_spi_read(handle,
L3GD20H_REG_CTRL4, (uint8_t *)&prev, 1) != 0)
3459 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
3463 range = (prev & (3 << 4)) >> 4;
3466 *reg = (uint16_t)(dps * 1000.0f / 7.5f);
3468 else if (range == 1)
3470 *reg = (uint16_t)(dps * 1000.0f / 15.3f);
3474 *reg = (uint16_t)(dps * 1000.0f / 61.0f);
3494 uint8_t range, prev;
3505 if (a_l3gd20h_iic_spi_read(handle,
L3GD20H_REG_CTRL4, (uint8_t *)&prev, 1) != 0)
3507 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
3511 range = (prev & (3 << 4)) >> 4;
3514 *dps = (float)(reg * 8.75f / 1000.0f);
3516 else if (range == 1)
3518 *dps = (float)(reg * 17.50f / 1000.0f);
3522 *dps = (float)(reg * 70.0f / 1000.0f);
3557 handle->
debug_print(
"l3gd20h: read interrupt source failed.\n");
3561 if ((prev & (1 << 6)) != 0)
3568 if ((prev & (1 << 5)) != 0)
3575 if ((prev & (1 << 4)) != 0)
3582 if ((prev & (1 << 3)) != 0)
3589 if ((prev & (1 << 2)) != 0)
3596 if ((prev & (1 << 1)) != 0)
3603 if ((prev & (1 << 0)) != 0)
3618 handle->
debug_print(
"l3gd20h: read status failed.\n");
3682 handle->
debug_print(
"l3gd20h: read fifo source failed.\n");
3686 if ((prev & (1 << 7)) != 0)
3693 if ((prev & (1 << 6)) != 0)
3700 if ((prev & (1 << 5)) != 0)
3712 handle->
debug_print(
"l3gd20h: interrupt number is invalid.\n");
3744 handle->
debug_print(
"l3gd20h: iic_init is null.\n");
3750 handle->
debug_print(
"l3gd20h: iic_deinit is null.\n");
3756 handle->
debug_print(
"l3gd20h: iic_read is null.\n");
3762 handle->
debug_print(
"l3gd20h: iic_write is null.\n");
3768 handle->
debug_print(
"l3gd20h: spi_init is null.\n");
3774 handle->
debug_print(
"l3gd20h: spi_deinit is null.\n");
3780 handle->
debug_print(
"l3gd20h: spi_read is null.\n");
3786 handle->
debug_print(
"l3gd20h: spi_write is null.\n");
3792 handle->
debug_print(
"l3gd20h: delay_ms is null.\n");
3801 handle->
debug_print(
"l3gd20h: iic init failed.\n");
3810 handle->
debug_print(
"l3gd20h: spi init failed.\n");
3817 handle->
debug_print(
"l3gd20h: read id failed.\n");
3847 handle->
debug_print(
"l3gd20h: read low odr failed.\n");
3864 handle->
debug_print(
"l3gd20h: write low odr failed.\n");
3880 handle->
debug_print(
"l3gd20h: read low odr failed.\n");
3892 if (((prev >> 2) & 0x01) != 0x0)
3894 handle->
debug_print(
"l3gd20h: reset chip failed.\n");
3939 handle->
debug_print(
"l3gd20h: read ctrl1 failed.\n");
3947 handle->
debug_print(
"l3gd20h: write ctrl1 failed.\n");
3973 uint8_t mode, cnt, i;
3974 uint8_t ble, range, enable;
3975 uint8_t buf[32 * 6];
3988 handle->
debug_print(
"l3gd20h: length is zero.\n");
3994 handle->
debug_print(
"l3gd20h: read fifo ctrl failed.\n");
3999 if (a_l3gd20h_iic_spi_read(handle,
L3GD20H_REG_CTRL5, (uint8_t *)&prev, 1) != 0)
4001 handle->
debug_print(
"l3gd20h: read ctrl5 failed.\n");
4005 enable = (prev & (1 << 6)) >> 6;
4006 if (a_l3gd20h_iic_spi_read(handle,
L3GD20H_REG_CTRL4, (uint8_t *)&prev, 1) != 0)
4008 handle->
debug_print(
"l3gd20h: read ctrl4 failed.\n");
4012 range = (prev & (3 << 4)) >> 4;
4013 ble = (prev & (1 << 6)) >> 6;
4014 if ((mode && enable) != 0)
4019 handle->
debug_print(
"l3gd20h: read fifo source failed.\n");
4024 *len = ((*len) < cnt) ? (*len) : cnt;
4028 handle->
debug_print(
"l3gd20h: read data failed.\n");
4032 for (i = 0; i < (*len); i++)
4036 raw[i][0] = (int16_t)(((uint16_t)buf[1 + i * 6] << 8) | buf[0 + i * 6]);
4037 raw[i][1] = (int16_t)(((uint16_t)buf[3 + i * 6] << 8) | buf[2 + i * 6]);
4038 raw[i][2] = (int16_t)(((uint16_t)buf[5 + i * 6] << 8) | buf[4 + i * 6]);
4042 raw[i][0] = (int16_t)(((uint16_t)buf[0 + i * 6] << 8) | buf[1 + i * 6]);
4043 raw[i][1] = (int16_t)(((uint16_t)buf[2 + i * 6] << 8) | buf[3 + i * 6]);
4044 raw[i][2] = (int16_t)(((uint16_t)buf[4 + i * 6] << 8) | buf[5 + i * 6]);
4048 dps[i][0] = (float)(raw[i][0]) * 8.75f / 1000.0f;
4049 dps[i][1] = (float)(raw[i][1]) * 8.75f / 1000.0f;
4050 dps[i][2] = (float)(raw[i][2]) * 8.75f / 1000.0f;
4052 else if (range == 1)
4054 dps[i][0] = (float)(raw[i][0]) * 17.5f / 1000.0f;
4055 dps[i][1] = (float)(raw[i][1]) * 17.5f / 1000.0f;
4056 dps[i][2] = (float)(raw[i][2]) * 17.5f / 1000.0f;
4060 dps[i][0] = (float)(raw[i][0]) * 70.0f / 1000.0f;
4061 dps[i][1] = (float)(raw[i][1]) * 70.0f / 1000.0f;
4062 dps[i][2] = (float)(raw[i][2]) * 70.0f / 1000.0f;
4072 handle->
debug_print(
"l3gd20h: read data failed.\n");
4078 raw[0][0] = (int16_t)(((uint16_t)buf[1] << 8) | buf[0]);
4079 raw[0][1] = (int16_t)(((uint16_t)buf[3] << 8) | buf[2]);
4080 raw[0][2] = (int16_t)(((uint16_t)buf[5] << 8) | buf[4]);
4084 raw[0][0] = (int16_t)(((uint16_t)buf[0] << 8) | buf[1]);
4085 raw[0][1] = (int16_t)(((uint16_t)buf[2] << 8) | buf[3]);
4086 raw[0][2] = (int16_t)(((uint16_t)buf[4] << 8) | buf[5]);
4090 dps[0][0] = (float)(raw[0][0]) * 8.75f / 1000.0f;
4091 dps[0][1] = (float)(raw[0][1]) * 8.75f / 1000.0f;
4092 dps[0][2] = (float)(raw[0][2]) * 8.75f / 1000.0f;
4094 else if (range == 1)
4096 dps[0][0] = (float)(raw[0][0]) * 17.5f / 1000.0f;
4097 dps[0][1] = (float)(raw[0][1]) * 17.5f / 1000.0f;
4098 dps[0][2] = (float)(raw[0][2]) * 17.5f / 1000.0f;
4102 dps[0][0] = (float)(raw[0][0]) * 70.0f / 1000.0f;
4103 dps[0][1] = (float)(raw[0][1]) * 70.0f / 1000.0f;
4104 dps[0][2] = (float)(raw[0][2]) * 70.0f / 1000.0f;
4135 return a_l3gd20h_iic_spi_write(handle, reg, buf, len);
4162 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