Paparazzi UAS  v6.2_unstable
Paparazzi is a free software Unmanned Aircraft System.
bmi088.c
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2019 Gautier Hattenberger <gautier.hattenberger@enac.fr>
3  *
4  * This file is part of paparazzi.
5  *
6  * paparazzi is free software; you can redistribute it and/or modify
7  * it under the terms of the GNU General Public License as published by
8  * the Free Software Foundation; either version 2, or (at your option)
9  * any later version.
10  *
11  * paparazzi is distributed in the hope that it will be useful,
12  * but WITHOUT ANY WARRANTY; without even the implied warranty of
13  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
14  * GNU General Public License for more details.
15  *
16  * You should have received a copy of the GNU General Public License
17  * along with paparazzi; see the file COPYING. If not, see
18  * <http://www.gnu.org/licenses/>.
19  */
20 
29 #include "peripherals/bmi088.h"
30 
31 const float BMI088_GYRO_SENS[5] = {
37 };
38 
39 const struct Int32Rates BMI088_GYRO_SENS_FRAC[5][2] = {
50 };
51 
52 const float BMI088_ACCEL_SENS[4] = {
57 };
58 
59 const struct Int32Vect3 BMI088_ACCEL_SENS_FRAC[4][2] = {
68 };
69 
71 {
77 }
78 
79 void bmi088_send_config(Bmi088ConfigSet bmi_set, void *bmi, struct Bmi088Config *config)
80 {
81  switch (config->init_status) {
83  /* configure accelerometer range */
84  bmi_set(bmi, BMI088_ACCEL_RANGE, config->accel_range, BMI088_CONFIG_ACCEL);
85  config->init_status++;
86  break;
88  /* configure accelerometer odr and bw */
89  bmi_set(bmi, BMI088_ACCEL_CONF, ((config->accel_bw << 4) | config->accel_odr), BMI088_CONFIG_ACCEL);
90  config->init_status++;
91  break;
93  /* switch on accel */
95  config->init_status++;
96  break;
98  /* switch on accel */
100  config->init_status++;
101  break;
103  /* configure gyro range */
104  bmi_set(bmi, BMI088_GYRO_RANGE, config->gyro_range, BMI088_CONFIG_GYRO);
105  config->init_status++;
106  break;
108  /* configure gyro odr */
109  bmi_set(bmi, BMI088_GYRO_BAND_WIDTH, config->gyro_odr, BMI088_CONFIG_GYRO);
110  config->init_status++;
111  break;
113  /* switch on gyro */
115  config->init_status++;
116  break;
117  case BMI088_CONF_DONE:
118  config->initialized = true;
119  break;
120  default:
121  break;
122  }
123 }
124 
void bmi088_set_default_config(struct Bmi088Config *c)
Definition: bmi088.c:70
const float BMI088_ACCEL_SENS[4]
Definition: bmi088.c:52
const struct Int32Vect3 BMI088_ACCEL_SENS_FRAC[4][2]
Definition: bmi088.c:59
void bmi088_send_config(Bmi088ConfigSet bmi_set, void *bmi, struct Bmi088Config *config)
Configuration sequence called once before normal use.
Definition: bmi088.c:79
const struct Int32Rates BMI088_GYRO_SENS_FRAC[5][2]
Definition: bmi088.c:39
const float BMI088_GYRO_SENS[5]
Definition: bmi088.c:31
BMI088 driver common interface (I2C and SPI).
#define BMI088_DEFAULT_ACCEL_BW
Default accel bandwidth.
Definition: bmi088.h:45
#define BMI088_GYRO_SENS_500
Definition: bmi088.h:58
#define BMI088_ACCEL_SENS_6G
Definition: bmi088.h:82
#define BMI088_ACCEL_SENS_12G
Definition: bmi088.h:85
enum Bmi088AccelODR accel_odr
output data rate
Definition: bmi088.h:118
#define BMI088_CONFIG_ACCEL
Definition: bmi088.h:109
void(* Bmi088ConfigSet)(void *bmi, uint8_t _reg, uint8_t _val, uint8_t _type)
Configuration function prototype.
Definition: bmi088.h:112
#define BMI088_ACCEL_SENS_3G_NUM
Definition: bmi088.h:80
#define BMI088_ACCEL_SENS_24G
Definition: bmi088.h:88
#define BMI088_ACCEL_SENS_6G_DEN
Definition: bmi088.h:84
enum Bmi088AccelRanges accel_range
g Range
Definition: bmi088.h:117
#define BMI088_DEFAULT_GYRO_RANGE
Default gyro full scale range +- 1000°/s.
Definition: bmi088.h:37
enum Bmi088GyroODR gyro_odr
output data rate
Definition: bmi088.h:116
enum Bmi088AccelBW accel_bw
bandwidth
Definition: bmi088.h:119
#define BMI088_GYRO_SENS_1000_NUM
Definition: bmi088.h:62
#define BMI088_CONFIG_GYRO
Definition: bmi088.h:110
#define BMI088_ACCEL_SENS_24G_NUM
Definition: bmi088.h:89
#define BMI088_ACCEL_SENS_6G_NUM
Definition: bmi088.h:83
#define BMI088_GYRO_SENS_500_DEN
Definition: bmi088.h:60
#define BMI088_ACCEL_SENS_12G_NUM
Definition: bmi088.h:86
#define BMI088_GYRO_SENS_2000_NUM
Definition: bmi088.h:65
#define BMI088_GYRO_SENS_250_DEN
Definition: bmi088.h:57
#define BMI088_GYRO_SENS_250_NUM
Definition: bmi088.h:56
#define BMI088_GYRO_SENS_2000
Definition: bmi088.h:64
#define BMI088_GYRO_SENS_125_NUM
Definition: bmi088.h:53
#define BMI088_ACCEL_SENS_12G_DEN
Definition: bmi088.h:87
#define BMI088_DEFAULT_ACCEL_RANGE
Default accel full scale range +- 6g.
Definition: bmi088.h:41
#define BMI088_GYRO_SENS_500_NUM
Definition: bmi088.h:59
@ BMI088_CONF_ACCEL_RANGE
Definition: bmi088.h:99
@ BMI088_CONF_GYRO_PWR
Definition: bmi088.h:105
@ BMI088_CONF_ACCEL_ODR
Definition: bmi088.h:100
@ BMI088_CONF_GYRO_ODR
Definition: bmi088.h:104
@ BMI088_CONF_ACCEL_PWR_CTRL
Definition: bmi088.h:102
@ BMI088_CONF_DONE
Definition: bmi088.h:106
@ BMI088_CONF_GYRO_RANGE
Definition: bmi088.h:103
@ BMI088_CONF_ACCEL_PWR_CONF
Definition: bmi088.h:101
#define BMI088_GYRO_SENS_1000
Definition: bmi088.h:61
#define BMI088_ACCEL_SENS_3G_DEN
Definition: bmi088.h:81
#define BMI088_ACCEL_SENS_24G_DEN
Definition: bmi088.h:90
#define BMI088_DEFAULT_GYRO_ODR
Default gyro output rate.
Definition: bmi088.h:39
#define BMI088_GYRO_SENS_125_DEN
Definition: bmi088.h:54
enum Bmi088GyroRanges gyro_range
deg/s Range
Definition: bmi088.h:115
#define BMI088_GYRO_SENS_1000_DEN
Definition: bmi088.h:63
#define BMI088_GYRO_SENS_2000_DEN
Definition: bmi088.h:66
#define BMI088_GYRO_SENS_250
Definition: bmi088.h:55
#define BMI088_DEFAULT_ACCEL_ODR
Default accel output rate.
Definition: bmi088.h:43
#define BMI088_ACCEL_SENS_3G
default accel sensitivy from the datasheet sens = 9.81 [m/s^2] / [LSB/g] * 2^INT32_ACCEL_FRAC ex: BMI...
Definition: bmi088.h:79
#define BMI088_GYRO_SENS_125
default gyro sensitivy from the datasheet sens = 1/ [LSB/(deg/s)] * pi/180 * 2^INT32_RATE_FRAC ex: BM...
Definition: bmi088.h:52
#define BMI088_ACCEL_RANGE
Definition: bmi088_regs.h:55
#define BMI088_GYRO_RANGE
Definition: bmi088_regs.h:82
@ BMI088_ACCEL_ACTIVE
Definition: bmi088_regs.h:132
#define BMI088_GYRO_LPM_1
Definition: bmi088_regs.h:85
#define BMI088_GYRO_BAND_WIDTH
Definition: bmi088_regs.h:83
#define BMI088_ACCEL_PWR_CONF
Definition: bmi088_regs.h:63
#define BMI088_ACCEL_CONF
Definition: bmi088_regs.h:54
@ BMI088_GYRO_NORMAL
Definition: bmi088_regs.h:173
@ BMI088_ACCEL_POWER_ON
Definition: bmi088_regs.h:141
#define BMI088_ACCEL_PWR_CTRl
Definition: bmi088_regs.h:64
angular rates
static const struct usb_config_descriptor config
Definition: usb_ser_hw.c:200