123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342 |
- #ifndef __DRV_LSM6DS3TR_C_H__
- #define __DRV_LSM6DS3TR_C_H__
- #ifdef __cplusplus
- extern "C" {
- #endif
- #include <stdint.h>
- #include <stdio.h>
- #include <stdbool.h>
- #include "lsm6ds3tr-c_reg.h"
- typedef enum{
- LSM_ACC_ODR_OFF = LSM6DS3TR_C_XL_ODR_OFF,
-
- LSM_ACC_ODR_12HZ5 = LSM6DS3TR_C_XL_ODR_12Hz5,
-
- LSM_ACC_ODR_104HZ = LSM6DS3TR_C_XL_ODR_104Hz,
-
- LSM_ACC_ODR_208HZ = LSM6DS3TR_C_XL_ODR_208Hz,
-
- LSM_ACC_ODR_416HZ = LSM6DS3TR_C_XL_ODR_416Hz,
-
- LSM_ACC_ODR_833HZ = LSM6DS3TR_C_XL_ODR_833Hz,
-
- } LSM_ACC_ODR_e;
- typedef enum{
- LSM_GRY_ODR_OFF = LSM6DS3TR_C_GY_ODR_OFF,
-
- LSM_GRY_ODR_12HZ5 = LSM6DS3TR_C_GY_ODR_12Hz5,
-
- LSM_GRY_ODR_104HZ = LSM6DS3TR_C_GY_ODR_104Hz,
-
- LSM_GRY_ODR_208HZ = LSM6DS3TR_C_GY_ODR_208Hz,
- LSM_GRY_ODR_416HZ = LSM6DS3TR_C_GY_ODR_416Hz,
- LSM_GRY_ODR_833HZ = LSM6DS3TR_C_GY_ODR_833Hz,
-
- } LSM_GRY_ODR_e;
- typedef enum{
- LSM_MAG_ODR_OFF = 0x00,
-
- LSM_MAG_ODR_10HZ = 0x31,
-
- LSM_MAG_ODR_100HZ = 0x39,
-
- LSM_MAG_ODR_200HZ = 0x3D,
-
- } LSM_MAG_ODR_e;
- typedef enum{
- LSM_FIFO_ODR_OFF = LSM6DS3TR_C_FIFO_DISABLE,
-
- LSM_FIFO_ODR_12HZ5 = LSM6DS3TR_C_FIFO_12Hz5,
-
- LSM_FIFO_ODR_104HZ = LSM6DS3TR_C_FIFO_104Hz,
-
- LSM_FIFO_ODR_208HZ = LSM6DS3TR_C_FIFO_208Hz,
-
- LSM_FIFO_ODR_416HZ = LSM6DS3TR_C_FIFO_416Hz,
-
- LSM_FIFO_ODR_833HZ = LSM6DS3TR_C_FIFO_833Hz,
-
- } LSM_FIFO_ODR_e;
- typedef enum{
- LSM_ACC_POWER_MODE_HIGH_PERFORMANCE = LSM6DS3TR_C_XL_HIGH_PERFORMANCE,
-
- LSM_ACC_POWER_MODE_NORMAL = LSM6DS3TR_C_XL_NORMAL,
-
- } LSM_ACC_POWER_MODE_e;
- typedef enum{
- LSM_GRY_POWER_MODE_HIGH_PERFORMANCE = LSM6DS3TR_C_GY_HIGH_PERFORMANCE,
-
- LSM_GRY_POWER_MODE_NORMAL = LSM6DS3TR_C_GY_NORMAL,
-
- } LSM_GRY_POWER_MODE_e;
- typedef enum{
- LSM_TIMESTAMP_6MS4 = LSM6DS3TR_C_LSB_6ms4,
-
- LSM_TIMESTAMP_25US = LSM6DS3TR_C_LSB_25us,
-
- } LSM_TIMESTAMP_RESOLUTION_e;
- typedef enum{
- LSM_TIMESTAMP_OFF = 0,
-
- LSM_TIMESTAMP_ON = 1,
-
- } LSM_TIMESTAMP_SWITCH_e;
- typedef enum{
- LSM_ACC_FS_2G = LSM6DS3TR_C_2g,
-
- LSM_ACC_FS_16G = LSM6DS3TR_C_16g,
-
- } LSM_ACC_FS_e;
- typedef enum{
- LSM_GRY_FS_250DPS = LSM6DS3TR_C_250dps,
-
- LSM_GRY_FS_2000DPS = LSM6DS3TR_C_2000dps,
-
- } LSM_GRY_FS_e;
- typedef enum{
- LSM_MAG_FS_30GS = 0x00,
-
- } LSM_MAG_FS_e;
- typedef struct
- {
- LSM_ACC_POWER_MODE_e acc_power_mode;
-
- LSM_GRY_POWER_MODE_e gry_power_mode;
-
- LSM_FIFO_ODR_e fifo_odr;
-
- LSM_TIMESTAMP_RESOLUTION_e timestamp_resolution;
-
- LSM_TIMESTAMP_SWITCH_e timestamp_switch;
-
- LSM_ACC_ODR_e acc_odr;
-
- LSM_GRY_ODR_e gry_odr;
-
- LSM_MAG_ODR_e mag_odr;
-
- LSM_ACC_FS_e acc_fs;
-
- LSM_GRY_FS_e gry_fs;
-
- LSM_MAG_FS_e mag_fs;
-
- } drv_lsm_config_param_t;
- typedef struct
- {
- int16_t acc[3];
-
- int16_t gry[3];
-
- int16_t mag[3];
-
- int32_t fifo_timestamp;
-
- } lsm_data_t;
- int drv_lsm_Init(void);
- int drv_lsm_power_off(void);
- int drv_lsm_power_on(void);
- int drv_lsm_set_acc_power_mode(LSM_ACC_POWER_MODE_e acc_power_mode);
- int drv_lsm_set_gry_power_mode(LSM_GRY_POWER_MODE_e gry_power_mode);
- int drv_lsm_set_timestamp_resolution(LSM_TIMESTAMP_RESOLUTION_e timestamp_resolution);
- int drv_lsm_set_timestamp_switch(LSM_TIMESTAMP_SWITCH_e timestamp_switch);
- int drv_lsm_set_fifo_odr(LSM_FIFO_ODR_e fifo_odr, LSM_ACC_ODR_e acc_odr, LSM_GRY_ODR_e gry_odr, LSM_MAG_ODR_e mag_odr, LSM_TIMESTAMP_SWITCH_e timestamp_switch);
- int drv_lsm_set_acc_fs(LSM_ACC_FS_e acc_fs);
- int drv_lsm_set_acc_odr(LSM_ACC_ODR_e acc_odr);
- int drv_lsm_set_gry_fs(LSM_GRY_FS_e gry_fs);
- int drv_lsm_set_gry_odr(LSM_GRY_ODR_e gry_odr);
- int drv_lsm_get_mag_fs_flow(void);
- int drv_lsm_set_mag_fs(LSM_MAG_FS_e mag_fs, int flow);
- int drv_lsm_get_mag_odr_flow(void);
- int drv_lsm_set_mag_odr(LSM_MAG_ODR_e mag_odr, bool set_hub, int flow);
- int drv_lsm_get_config_param(drv_lsm_config_param_t *p_param);
- int drv_lsm_get_fifo_group_num(void);
- int drv_lsm_get_fifo_data(lsm_data_t *p_data);
- int drv_lsm_get_acc_data(lsm_data_t *p_data);
- int drv_lsm_self_check_1(void);
- int drv_lsm_self_check_2(void);
- int drv_lsm_self_check_3(void);
- int drv_lsm_self_check_4(void);
- int drv_lsm_self_check_5(void);
- int drv_lsm_get_lsm_id(void);
- int drv_lsm_get_mag_id(void);
- #ifdef __cplusplus
- }
- #endif
- #endif
|