Both sensors now run over interrupts in pulse mode. This still needs
tweaking as its buggy but works for now on full speed for both sensors.
This commit is contained in:
+35
-26
@@ -30,6 +30,7 @@
|
||||
#include "bmm350.h"
|
||||
#include "bmm350_defs.h"
|
||||
#include "bmm350_oor.h"
|
||||
#include "task.h"
|
||||
|
||||
// CDC functionality
|
||||
#include "usbd_cdc_if.h"
|
||||
@@ -695,6 +696,10 @@ static void MX_GPIO_Init(void)
|
||||
GPIO_InitStruct.Pull = GPIO_NOPULL;
|
||||
HAL_GPIO_Init(GPIO_MAGN_INT_GPIO_Port, &GPIO_InitStruct);
|
||||
|
||||
/* EXTI interrupt init*/
|
||||
HAL_NVIC_SetPriority(EXTI15_10_IRQn, 5, 0);
|
||||
HAL_NVIC_EnableIRQ(EXTI15_10_IRQn);
|
||||
|
||||
/* USER CODE BEGIN MX_GPIO_Init_2 */
|
||||
|
||||
/* USER CODE END MX_GPIO_Init_2 */
|
||||
@@ -716,8 +721,12 @@ void Start_DataAnalysis(void *argument)
|
||||
/* init code for USB_Device */
|
||||
MX_USB_Device_Init();
|
||||
/* USER CODE BEGIN 5 */
|
||||
|
||||
// TODO: USB/BLE Connection in beide Richtungen (MCU-PC)
|
||||
// TODO: Einstellungen setzbar durch trinity control für IMU, Magnetometer, etc.
|
||||
|
||||
// HAL_StatusTypeDef status;
|
||||
// char output_buffer[128];
|
||||
char output_buffer[128];
|
||||
ICM45686_Data imu_data;
|
||||
struct bmm350_mag_temp_data magn_data;
|
||||
// struct bmm350_raw_mag_data magn_data;
|
||||
@@ -735,12 +744,12 @@ void Start_DataAnalysis(void *argument)
|
||||
osMessageQueueGet(Q_BMMHandle, &magn_data, NULL, osWaitForever);
|
||||
osMessageQueueGet(Q_ICMHandle, &imu_data, NULL, osWaitForever);
|
||||
|
||||
// MadgwickAHRS_update(&IMUQuat, imu_data.processed_imu_data[3], imu_data.processed_imu_data[4], imu_data.processed_imu_data[5], //gx, gy, gz
|
||||
// imu_data.processed_imu_data[0], imu_data.processed_imu_data[1], imu_data.processed_imu_data[2], // ax, ay, yz
|
||||
// magn_data.x, magn_data.y, magn_data.z); // mx, my, mz
|
||||
|
||||
MadgwickAHRS_update_IMU(&IMUQuat, imu_data.processed_imu_data[3], imu_data.processed_imu_data[4], imu_data.processed_imu_data[5], //gx, gy, gz
|
||||
imu_data.processed_imu_data[0], imu_data.processed_imu_data[1], imu_data.processed_imu_data[2]); // ax, ay, yz)
|
||||
MadgwickAHRS_update(&IMUQuat, imu_data.processed_imu_data[3], imu_data.processed_imu_data[4], imu_data.processed_imu_data[5], //gx, gy, gz
|
||||
imu_data.processed_imu_data[0], imu_data.processed_imu_data[1], imu_data.processed_imu_data[2], // ax, ay, yz
|
||||
magn_data.x, magn_data.y, magn_data.z); // mx, my, mz
|
||||
//
|
||||
// MadgwickAHRS_update_IMU(&IMUQuat, imu_data.processed_imu_data[3], imu_data.processed_imu_data[4], imu_data.processed_imu_data[5], //gx, gy, gz
|
||||
// imu_data.processed_imu_data[0], imu_data.processed_imu_data[1], imu_data.processed_imu_data[2]); // ax, ay, yz)
|
||||
|
||||
|
||||
Quat_Dat.qw = IMUQuat.q[0];
|
||||
@@ -761,8 +770,8 @@ void Start_DataAnalysis(void *argument)
|
||||
// sprintf(output_buffer, "ICM:\ta_x: %.2f a_y: %.2f a_z: %.2f\t g_x: %.2f g_y: %.2f g_z: %.2f temp: %.2f \n", imu_data.processed_imu_data[0], imu_data.processed_imu_data[1], imu_data.processed_imu_data[2],
|
||||
// imu_data.processed_imu_data[3], imu_data.processed_imu_data[4], imu_data.processed_imu_data[5], imu_data.processed_imu_data[6]);
|
||||
// CDC_Transmit_FS((uint8_t*)output_buffer, (uint16_t)strlen(output_buffer));
|
||||
//
|
||||
// // compensated mag data
|
||||
////
|
||||
//// // compensated mag data
|
||||
// sprintf(output_buffer, "BMM:\tX: %.2f uT, Y: %.2f uT, Z: %.2f uT, Temp: %.2f C\n",
|
||||
// magn_data.x, magn_data.y, magn_data.z, magn_data.temperature);
|
||||
// CDC_Transmit_FS((uint8_t*)output_buffer, (uint16_t)strlen(output_buffer));
|
||||
@@ -777,7 +786,7 @@ void Start_DataAnalysis(void *argument)
|
||||
//
|
||||
// sprintf(output_buffer, "------------\n");
|
||||
// CDC_Transmit_FS((uint8_t*)output_buffer, (uint16_t)strlen(output_buffer));
|
||||
osDelay(100);
|
||||
// osDelay(100);
|
||||
}
|
||||
|
||||
/* USER CODE END 5 */
|
||||
@@ -816,14 +825,16 @@ void Start_ICM45686(void *argument)
|
||||
tx[0] = 0x00 | 0x80;
|
||||
|
||||
init_icm(&imu);
|
||||
osDelay(50);
|
||||
configure_interrupt_icm(&imu);
|
||||
enable_interrupt_icm(&imu);
|
||||
// osDelay(500);
|
||||
// calibrate_icm(&imu, 1000);
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
// imu
|
||||
// HAL_GPIO_WritePin(GPIOA, GPIO_SPI1_IMU_CS_Pin, GPIO_PIN_RESET);
|
||||
// status = HAL_SPI_TransmitReceive_DMA(&hspi1, tx, raw_imu_data, sizeof(raw_imu_data)); //(&hspi1, tx, raw_imu_data, sizeof(raw_imu_data), 50);
|
||||
status = read_icm_dma(&imu, tx, raw_imu_data);
|
||||
ulTaskNotifyTake(pdFALSE, osWaitForever);
|
||||
status = read_icm_dma(&imu, tx, raw_imu_data, sizeof(tx));
|
||||
if (status != HAL_OK) {
|
||||
printf("Reading IMU sensordata failed: %d\n", status);
|
||||
}
|
||||
@@ -854,12 +865,8 @@ void Start_ICM45686(void *argument)
|
||||
processed_data.processed_imu_data[6] -= imu.imu_bias[7];
|
||||
|
||||
}
|
||||
// printf("[0]: %.2f [3]: %.2f [6]: %.2f\n", processed_data.processed_imu_data[0], processed_data.processed_imu_data[3], processed_data.processed_imu_data[6]);
|
||||
|
||||
osMessageQueuePut(Q_ICMHandle, &processed_data, 0, 5);
|
||||
osDelay(100);
|
||||
|
||||
|
||||
}
|
||||
/* USER CODE END Start_ICM45686 */
|
||||
}
|
||||
@@ -881,21 +888,26 @@ void Start_BMM350(void *argument)
|
||||
struct bmm350_dev dev = {0x00};
|
||||
int8_t rslt;
|
||||
struct bmm350_mag_temp_data mag_data;
|
||||
osDelay(250);
|
||||
osDelay(500);
|
||||
// struct bmm350_raw_mag_data mag_data;
|
||||
|
||||
// struct bmm350_mag_temp_data mag_temp_data;
|
||||
// struct bmm350_pmu_cmd_status_0 pmu_cmd_stat_0;
|
||||
|
||||
// ODR: 200HZ, AVG:
|
||||
rslt = init_bmm(&dev);
|
||||
if (rslt != BMM350_OK) {
|
||||
printf("BMM350 initialization failed: %d\n", rslt);
|
||||
printf("Chip id: 0x%02X\n", dev.chip_id);
|
||||
}
|
||||
|
||||
rslt = bmm_configure_interrupt(&dev);
|
||||
if (rslt != BMM350_OK) {
|
||||
printf("Configuring interrupt failed: %d\n", rslt);
|
||||
}
|
||||
// osDelay(200);
|
||||
/* Infinite loop */
|
||||
for(;;)
|
||||
{
|
||||
// wait for the interrupt
|
||||
ulTaskNotifyTake(pdFALSE, osWaitForever);
|
||||
// magnetometer
|
||||
rslt = bmm350_get_compensated_mag_xyz_temp_data(&mag_data, &dev);
|
||||
// rslt = bmm350_read_uncomp_mag_temp_data(&mag_data, &dev);
|
||||
@@ -906,10 +918,7 @@ void Start_BMM350(void *argument)
|
||||
// CDC_Transmit_FS((uint8_t*)output_buffer, (uint16_t)strlen(output_buffer));
|
||||
osMessageQueuePut(Q_BMMHandle, &mag_data, 0, 5);
|
||||
}
|
||||
|
||||
osDelay(100);
|
||||
|
||||
|
||||
// osDelay(100);
|
||||
}
|
||||
/* USER CODE END Start_BMM350 */
|
||||
}
|
||||
|
||||
+103
-15
@@ -47,29 +47,47 @@ void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *I2C_address) {
|
||||
void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c) {
|
||||
if (hi2c->Instance == I2C1) {
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
printf("ErrorCallback: %ld", HAL_I2C_GetError(hi2c));
|
||||
printf("ErrorCallback: %ld\n", HAL_I2C_GetError(hi2c));
|
||||
vTaskNotifyGiveFromISR(xMagn_Task, &xHigherPriorityTaskWoken);
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
}
|
||||
}
|
||||
|
||||
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin) {
|
||||
// was macht das?
|
||||
BaseType_t xHigherPriorityTaskWoken = pdFALSE;
|
||||
|
||||
if (GPIO_Pin == GPIO_IMU_INT_Pin) {
|
||||
vTaskNotifyGiveFromISR(xIMU_Task, &xHigherPriorityTaskWoken);
|
||||
// printf("Triggered ICM45686 EXTI\n");
|
||||
}
|
||||
|
||||
if (GPIO_Pin == GPIO_MAGN_INT_Pin) {
|
||||
vTaskNotifyGiveFromISR(xMagn_Task, &xHigherPriorityTaskWoken);
|
||||
// printf("Triggered BMM350 EXTI\n");
|
||||
}
|
||||
// was macht das?
|
||||
portYIELD_FROM_ISR(xHigherPriorityTaskWoken);
|
||||
|
||||
}
|
||||
|
||||
// ICM 45686
|
||||
HAL_StatusTypeDef read_icm (ICM45686_HandleTypeDef *imu, uint8_t tx[], uint8_t rx[]) {
|
||||
HAL_StatusTypeDef read_icm (ICM45686_HandleTypeDef *imu, uint8_t tx[], uint8_t rx[], uint16_t len_tx) {
|
||||
HAL_GPIO_WritePin(imu->GPIO_Port, imu->GPIO_Pin, GPIO_PIN_RESET);
|
||||
HAL_StatusTypeDef status = HAL_SPI_TransmitReceive(imu->hspi, tx, rx, sizeof(tx), 50);
|
||||
HAL_StatusTypeDef status = HAL_SPI_TransmitReceive(imu->hspi, tx, rx, len_tx, 50);
|
||||
HAL_GPIO_WritePin(imu->GPIO_Port, imu->GPIO_Pin, GPIO_PIN_SET);
|
||||
return status;
|
||||
}
|
||||
|
||||
HAL_StatusTypeDef read_icm_dma (ICM45686_HandleTypeDef *imu, uint8_t tx[], uint8_t rx[]) {
|
||||
HAL_StatusTypeDef read_icm_dma (ICM45686_HandleTypeDef *imu, uint8_t tx[], uint8_t rx[], uint16_t len_tx) {
|
||||
HAL_GPIO_WritePin(imu->GPIO_Port, imu->GPIO_Pin, GPIO_PIN_RESET);
|
||||
HAL_StatusTypeDef status = HAL_SPI_TransmitReceive_DMA(imu->hspi, tx, rx, sizeof(rx));
|
||||
HAL_StatusTypeDef status = HAL_SPI_TransmitReceive_DMA(imu->hspi, tx, rx, len_tx);
|
||||
return status;
|
||||
}
|
||||
|
||||
HAL_StatusTypeDef write_icm (ICM45686_HandleTypeDef *imu, uint8_t tx[]) {
|
||||
HAL_StatusTypeDef write_icm (ICM45686_HandleTypeDef *imu, uint8_t tx[], uint16_t len_tx) {
|
||||
HAL_GPIO_WritePin(imu->GPIO_Port, imu->GPIO_Pin, GPIO_PIN_RESET);
|
||||
HAL_StatusTypeDef status = HAL_SPI_Transmit(imu->hspi, tx, sizeof(tx), 50);
|
||||
HAL_StatusTypeDef status = HAL_SPI_Transmit(imu->hspi, tx, len_tx, 50);
|
||||
HAL_GPIO_WritePin(imu->GPIO_Port, imu->GPIO_Pin, GPIO_PIN_SET);
|
||||
return status;
|
||||
}
|
||||
@@ -78,6 +96,18 @@ void init_icm(ICM45686_HandleTypeDef *imu) {
|
||||
// TODO: Add settings as enum to choose from
|
||||
// FIFO
|
||||
// Interrupt
|
||||
/* Interrupt functionality is configured via the Interrupt Configuration register. Items that are configurable include the
|
||||
interrupt pins configuration, the interrupt latching and clearing method, and triggers for the interrupt. Items that
|
||||
can trigger an interrupt are (1) Clock generator locked to new reference oscillator (used when switching clock
|
||||
sources); (2) new data is available to be read (from the FIFO and Data registers); (3) accelerometer event
|
||||
interrupts; (4) FIFO watermark; (5) FIFO overflow. The interrupt status can be read from the Interrupt Status
|
||||
register.
|
||||
- Configure interrupt pin on icm
|
||||
- configure interrupt pin on bmm
|
||||
- -> push/pull or open drain, latch, polarity
|
||||
- everything stays as is only that a interrupt callback gets added, that when called wakes up the
|
||||
corresponding task for the sensor
|
||||
*/
|
||||
// APEX???
|
||||
// EDMP???
|
||||
|
||||
@@ -90,7 +120,7 @@ void init_icm(ICM45686_HandleTypeDef *imu) {
|
||||
// HAL_GPIO_WritePin(imu->GPIO_Port, imu->GPIO_Pin, GPIO_PIN_RESET);
|
||||
// status = HAL_SPI_TransmitReceive(imu->hspi, tx, rx, sizeof(tx), 50);
|
||||
// HAL_GPIO_WritePin(GPIOA, GPIO_SPI1_IMU_CS_Pin, GPIO_PIN_SET);
|
||||
status = read_icm(imu, tx, rx);
|
||||
status = read_icm(imu, tx, rx, sizeof(tx));
|
||||
if (status != HAL_OK) {
|
||||
printf("Error in reading WHO AM I:%d\n", status);
|
||||
} else {
|
||||
@@ -103,7 +133,7 @@ void init_icm(ICM45686_HandleTypeDef *imu) {
|
||||
// HAL_GPIO_WritePin(GPIOA, GPIO_SPI1_IMU_CS_Pin, GPIO_PIN_RESET);
|
||||
// status = HAL_SPI_Transmit(imu->hspi, tx, sizeof(tx), 50);
|
||||
// HAL_GPIO_WritePin(GPIOA, GPIO_SPI1_IMU_CS_Pin, GPIO_PIN_SET);
|
||||
status = write_icm(imu, tx);
|
||||
status = write_icm(imu, tx, sizeof(tx));
|
||||
if (status != HAL_OK) {
|
||||
printf("Error in setting ACCEL_CONFIG0:%d\n", status);
|
||||
} else {
|
||||
@@ -115,7 +145,7 @@ void init_icm(ICM45686_HandleTypeDef *imu) {
|
||||
// HAL_GPIO_WritePin(GPIOA, GPIO_SPI1_IMU_CS_Pin, GPIO_PIN_RESET);
|
||||
// status = HAL_SPI_TransmitReceive(imu->hspi, tx, rx, sizeof(tx), 50);
|
||||
// HAL_GPIO_WritePin(GPIOA, GPIO_SPI1_IMU_CS_Pin, GPIO_PIN_SET);
|
||||
status = read_icm(imu, tx, rx);
|
||||
status = read_icm(imu, tx, rx, sizeof(tx));
|
||||
if (status != HAL_OK) {
|
||||
printf("Error reading ACCEL_CONFIG0:%d\n", status);
|
||||
} else {
|
||||
@@ -128,7 +158,7 @@ void init_icm(ICM45686_HandleTypeDef *imu) {
|
||||
// HAL_GPIO_WritePin(GPIOA, GPIO_SPI1_IMU_CS_Pin, GPIO_PIN_RESET);
|
||||
// status = HAL_SPI_Transmit(imu->hspi, tx, sizeof(tx), 50);
|
||||
// HAL_GPIO_WritePin(GPIOA, GPIO_SPI1_IMU_CS_Pin, GPIO_PIN_SET);
|
||||
status = write_icm(imu, tx);
|
||||
status = write_icm(imu, tx, sizeof(tx));
|
||||
if (status != HAL_OK) {
|
||||
printf("Error in setting GYRO_CONFIG0:%d\n", status);
|
||||
} else {
|
||||
@@ -140,7 +170,7 @@ void init_icm(ICM45686_HandleTypeDef *imu) {
|
||||
// HAL_GPIO_WritePin(GPIOA, GPIO_SPI1_IMU_CS_Pin, GPIO_PIN_RESET);
|
||||
// status = HAL_SPI_TransmitReceive(imu->hspi, tx, rx, sizeof(tx), 50);
|
||||
// HAL_GPIO_WritePin(GPIOA, GPIO_SPI1_IMU_CS_Pin, GPIO_PIN_SET);
|
||||
status = read_icm(imu, tx, rx);
|
||||
status = read_icm(imu, tx, rx, sizeof(tx));
|
||||
if (status != HAL_OK) {
|
||||
printf("Error reading GYRO_CONFIG0:%d\n", status);
|
||||
} else {
|
||||
@@ -153,7 +183,7 @@ void init_icm(ICM45686_HandleTypeDef *imu) {
|
||||
// HAL_GPIO_WritePin(GPIOA, GPIO_SPI1_IMU_CS_Pin, GPIO_PIN_RESET);
|
||||
// status = HAL_SPI_Transmit(imu->hspi, tx, sizeof(tx), 50);
|
||||
// HAL_GPIO_WritePin(GPIOA, GPIO_SPI1_IMU_CS_Pin, GPIO_PIN_SET);
|
||||
status = write_icm(imu, tx);
|
||||
status = write_icm(imu, tx, sizeof(tx));
|
||||
if (status != HAL_OK) {
|
||||
printf("Error in setting PWR_MGMT0:%d\n", status);
|
||||
} else {
|
||||
@@ -165,7 +195,7 @@ void init_icm(ICM45686_HandleTypeDef *imu) {
|
||||
// HAL_GPIO_WritePin(GPIOA, GPIO_SPI1_IMU_CS_Pin, GPIO_PIN_RESET);
|
||||
// status = HAL_SPI_TransmitReceive(imu->hspi, tx, rx, sizeof(tx), 50);
|
||||
// HAL_GPIO_WritePin(GPIOA, GPIO_SPI1_IMU_CS_Pin, GPIO_PIN_SET);
|
||||
status = read_icm(imu, tx, rx);
|
||||
status = read_icm(imu, tx, rx, sizeof(tx));
|
||||
if (status != HAL_OK) {
|
||||
printf("Error reading PWR_MGMT0:%d\n", status);
|
||||
} else {
|
||||
@@ -183,7 +213,7 @@ void calibrate_icm(ICM45686_HandleTypeDef *imu, int samples) {
|
||||
tx[0] = 0x00 | 0x80;
|
||||
|
||||
for (int i = 1; i <= samples; i++) {
|
||||
status = read_icm_dma(imu, tx, raw_data);
|
||||
status = read_icm_dma(imu, tx, raw_data, sizeof(tx));
|
||||
if (status != HAL_OK) {
|
||||
printf("Calibration read ICM failed: %d\n", status);
|
||||
}
|
||||
@@ -217,6 +247,48 @@ void calibrate_icm(ICM45686_HandleTypeDef *imu, int samples) {
|
||||
|
||||
}
|
||||
|
||||
void enable_interrupt_icm(ICM45686_HandleTypeDef *imu) {
|
||||
uint8_t tx[2], rx[2] = {0x00, 0x00};
|
||||
tx[0] = ICM45686_INT1_CONFIG0;
|
||||
tx[1] = 0x04;
|
||||
printf("Enabling IMU INT pin\n");
|
||||
|
||||
HAL_StatusTypeDef status = write_icm(imu, tx, sizeof(tx));
|
||||
if (status != HAL_OK) {
|
||||
printf("Enabling of IMU INT failed: %d\n", status);
|
||||
}
|
||||
|
||||
tx[0] = ICM45686_INT1_CONFIG0 | 0x80;
|
||||
tx[1] = 0x00;
|
||||
status = read_icm(imu, tx, rx, sizeof(tx));
|
||||
if (status != HAL_OK) {
|
||||
printf("Reading IMU INT configuration0 failed: %d\n", status);
|
||||
} else {
|
||||
printf("INT1_CONFIG0 read: 0x%02X\n", rx[1]);
|
||||
}
|
||||
}
|
||||
|
||||
void configure_interrupt_icm (ICM45686_HandleTypeDef *imu) {
|
||||
uint8_t tx[2], rx[2] = {0x00, 0x00};
|
||||
|
||||
tx[0] = ICM45686_INT1_CONFIG2;
|
||||
tx[1] = 0x01;
|
||||
printf("Configuring IMU INT\n");
|
||||
HAL_StatusTypeDef status = write_icm(imu, tx, sizeof(tx));
|
||||
if (status != HAL_OK) {
|
||||
printf("Configuration of IMU INT failed: %d\n", status);
|
||||
}
|
||||
|
||||
tx[0] = ICM45686_INT1_CONFIG2 | 0x80;
|
||||
tx[1] = 0x00;
|
||||
status = read_icm(imu, tx, rx, sizeof(tx));
|
||||
if (status != HAL_OK) {
|
||||
printf("Reading IMU INT configuration2 failed: %d\n", status);
|
||||
} else {
|
||||
printf("INT1_CONFIG2 read: 0x%02X\n", rx[1]);
|
||||
}
|
||||
}
|
||||
|
||||
// BMM350
|
||||
void bmm_init_DWT(void){
|
||||
// Enable trace and debug block (TRCENA)
|
||||
@@ -301,5 +373,21 @@ int8_t init_bmm(struct bmm350_dev *dev) {
|
||||
rslt = bmm350_set_odr_performance(BMM350_DATA_RATE_200HZ, BMM350_AVERAGING_2, dev);
|
||||
printf("ODR(%d) and AVG(%d): %d\n", BMM350_DATA_RATE_200HZ, BMM350_AVERAGING_2, rslt);
|
||||
|
||||
// // configure interrupt
|
||||
// rslt = bmm350_enable_interrupt(BMM350_ENABLE_INTERRUPT, dev);
|
||||
// printf("Interrupt enable: %d", rslt);
|
||||
// rslt = bmm350_configure_interrupt(BMM350_LATCHED, BMM350_ACTIVE_HIGH, BMM350_INTR_OPEN_DRAIN, BMM350_MAP_TO_PIN, dev);
|
||||
// printf("Configure interrupt: %d", rslt);
|
||||
|
||||
return BMM350_OK;
|
||||
}
|
||||
|
||||
int8_t bmm_configure_interrupt (struct bmm350_dev *dev) {
|
||||
int8_t rslt;
|
||||
rslt = bmm350_enable_interrupt(BMM350_ENABLE_INTERRUPT, dev);
|
||||
printf("Interrupt enable: %d\n", rslt);
|
||||
rslt = bmm350_configure_interrupt(BMM350_PULSED, BMM350_ACTIVE_HIGH, BMM350_INTR_PUSH_PULL, BMM350_MAP_TO_PIN, dev);
|
||||
printf("Configure interrupt: %d\n", rslt);
|
||||
|
||||
return BMM350_OK;
|
||||
}
|
||||
|
||||
+10
-4
@@ -64,7 +64,9 @@ typedef enum {
|
||||
ICM45686_ACCEL_DATA = 0x00,
|
||||
ICM45686_GYRO_DATA = 0x06,
|
||||
ICM45686_FIFO_COUNT = 0x12,
|
||||
ICM45686_FIFO_DATA = 0x14
|
||||
ICM45686_FIFO_DATA = 0x14,
|
||||
ICM45686_INT1_CONFIG2 = 0x18,
|
||||
ICM45686_INT1_CONFIG0 = 0x16
|
||||
} ICM45686_registers;
|
||||
|
||||
typedef enum {
|
||||
@@ -138,13 +140,16 @@ void HAL_SPI_TxRxCpltCallback(SPI_HandleTypeDef *hspi);
|
||||
void HAL_I2C_MemRxCpltCallback(I2C_HandleTypeDef *I2C_address);
|
||||
void HAL_I2C_MemTxCpltCallback(I2C_HandleTypeDef *I2C_address);
|
||||
void HAL_I2C_ErrorCallback(I2C_HandleTypeDef *hi2c);
|
||||
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin);
|
||||
|
||||
// ICM45686
|
||||
void init_icm(ICM45686_HandleTypeDef *imu);
|
||||
HAL_StatusTypeDef read_icm (ICM45686_HandleTypeDef *imu, uint8_t tx[], uint8_t rx[]);
|
||||
HAL_StatusTypeDef read_icm_dma (ICM45686_HandleTypeDef *imu, uint8_t tx[], uint8_t rx[]);
|
||||
HAL_StatusTypeDef write_icm (ICM45686_HandleTypeDef *imu, uint8_t tx[]);
|
||||
HAL_StatusTypeDef read_icm (ICM45686_HandleTypeDef *imu, uint8_t tx[], uint8_t rx[], uint16_t len_tx);
|
||||
HAL_StatusTypeDef read_icm_dma (ICM45686_HandleTypeDef *imu, uint8_t tx[], uint8_t rx[], uint16_t len_tx);
|
||||
HAL_StatusTypeDef write_icm (ICM45686_HandleTypeDef *imu, uint8_t tx[], uint16_t len_tx);
|
||||
void calibrate_icm (ICM45686_HandleTypeDef * imu, int samples);
|
||||
void enable_interrupt_icm(ICM45686_HandleTypeDef *imu);
|
||||
void configure_interrupt_icm (ICM45686_HandleTypeDef *imu);
|
||||
|
||||
// BMM350 - Declarations of read/write/delay functions for the BMM350 API
|
||||
void bmm_init_DWT(void);
|
||||
@@ -152,6 +157,7 @@ BMM350_INTF_RET_TYPE bmm350_i2c_read(uint8_t reg_addr, uint8_t *reg_data, uint32
|
||||
BMM350_INTF_RET_TYPE bmm350_i2c_write(uint8_t reg_addr, const uint8_t *reg_data, uint32_t length, void *intf_ptr);
|
||||
void bmm350_delay(uint32_t period_us, void *intf_ptr);
|
||||
int8_t init_bmm(struct bmm350_dev *dev);
|
||||
int8_t bmm_configure_interrupt (struct bmm350_dev *dev);
|
||||
|
||||
// structs that hold the sensor data
|
||||
typedef struct {
|
||||
|
||||
@@ -293,6 +293,21 @@ void I2C1_ER_IRQHandler(void)
|
||||
/* USER CODE END I2C1_ER_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles EXTI line[15:10] interrupts.
|
||||
*/
|
||||
void EXTI15_10_IRQHandler(void)
|
||||
{
|
||||
/* USER CODE BEGIN EXTI15_10_IRQn 0 */
|
||||
|
||||
/* USER CODE END EXTI15_10_IRQn 0 */
|
||||
HAL_GPIO_EXTI_IRQHandler(GPIO_IMU_INT_Pin);
|
||||
HAL_GPIO_EXTI_IRQHandler(GPIO_MAGN_INT_Pin);
|
||||
/* USER CODE BEGIN EXTI15_10_IRQn 1 */
|
||||
|
||||
/* USER CODE END EXTI15_10_IRQn 1 */
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function handles IPCC RX occupied interrupt.
|
||||
*/
|
||||
|
||||
Reference in New Issue
Block a user