34 uint8_t
raw[15] = {
MPU_RA_ACCEL_XOUT_H | 0x80, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0};
75 for (
int i = 0;
i < 100;
i++)
103 accel_scale_ = (4.0 * 9.80665f) / (static_cast<float>(0x7FFF));
104 gyro_scale_= (2000.0 * 3.14159f/180.0f) / (static_cast<float>(0x7FFF));
114 temp_ =
static_cast<float>(
static_cast<int16_t
>((
raw[7] << 8) |
raw[8])) / 340.0
f + 36.53
f;
123 accel_data[0] =
acc_[0];
124 accel_data[1] =
acc_[1];
125 accel_data[2] =
acc_[2];
126 gyro_data[0] =
gyro_[0];
127 gyro_data[1] =
gyro_[1];
128 gyro_data[2] =
gyro_[2];
FunctionalState EXTI_LineCmd
#define MPU_BITS_FS_2000DPS
EXTITrigger_TypeDef EXTI_Trigger
#define MPU_CLK_SEL_PLLGYROZ
#define MPU_RA_SMPLRT_DIV
#define MPU_RA_PWR_MGMT_1
void NVIC_Init(NVIC_InitTypeDef *NVIC_InitStruct)
Initializes the NVIC peripheral according to the specified parameters in the NVIC_InitStruct.
EXTI Init Structure definition.
#define MPU_RA_PWR_MGMT_2
void delayMicroseconds(uint32_t us)
bool transfer(uint8_t *out_data, uint32_t num_bytes, uint8_t *in_data, GPIO *cs=NULL, void(*cb)(void)=NULL)
uint8_t NVIC_IRQChannelSubPriority
NVIC Init Structure definition.
volatile uint64_t micros(void)
volatile int16_t temp_data
#define MPU_RA_GYRO_CONFIG
void init(GPIO_TypeDef *BasePort, uint16_t pin, gpio_mode_t mode)
void EXTI_Init(EXTI_InitTypeDef *EXTI_InitStruct)
Initializes the EXTI peripheral according to the specified parameters in the EXTI_InitStruct. EXTI_Line specifies the EXTI line (EXTI0....EXTI35). EXTI_Mode specifies which EXTI line is used as interrupt or an event. EXTI_Trigger selects the trigger. When the trigger occurs, interrupt pending bit will be set. EXTI_LineCmd controls (Enable/Disable) the EXTI line.
EXTIMode_TypeDef EXTI_Mode
#define MPU_RA_INT_ENABLE
#define MPU_RA_ACCEL_XOUT_H
static volatile uint8_t reg
volatile int16_t accel_data[3]
void data_transfer_callback()
void EXTI4_IRQHandler(void)
FunctionalState NVIC_IRQChannelCmd
uint8_t transfer_byte(uint8_t data, GPIO *cs=NULL)
#define MPU_BIT_I2C_IF_DIS
uint8_t NVIC_IRQChannelPreemptionPriority
void set_divisor(uint16_t new_divisor)
void SYSCFG_EXTILineConfig(uint8_t EXTI_PortSourceGPIOx, uint8_t EXTI_PinSourcex)
Selects the GPIO pin used as EXTI Line.
void EXTI_ClearITPendingBit(uint32_t EXTI_Line)
Clears the EXTI's line pending bits.
#define EXTI_PortSourceGPIOC
#define MPU_RA_TEMP_OUT_H
void read(float *accel_data, float *gyro_data, float *temp_data, uint64_t *time_us)
void write(uint8_t reg, uint8_t data)
void data_transfer_cb(void)
#define MPU_BITS_DLPF_CFG_98HZ
volatile int16_t gyro_data[3]
#define MPU_RA_ACCEL_CONFIG