Sensor Fusion Library 0.6.1
Orientation sensing for Espressif (ESP32, ESP8266) processors
Loading...
Searching...
No Matches
hal_axis_remap.c
Go to the documentation of this file.
1/*
2 * Copyright (c) 2015, Freescale Semiconductor, Inc.
3 * Copyright (c) 2016-2017 NXP
4 * All rights reserved.
5 *
6 * SPDX-License-Identifier: BSD-3-Clause
7 */
8
55#include "sensor_fusion.h" // top level magCal and sensor fusion interfaces
56
57// remap the Accelerometer axes
58void ApplyAccelHAL(struct AccelSensor *Accel) {
59 int8_t i; // loop counter
60 int16_t itmp16;
61
62 // remap all measurements in FIFO buffer
63 for (i = 0; i < Accel->iFIFOCount; i++) {
64 // apply mapping for coordinate system used
65#if THISCOORDSYSTEM == NED
66 itmp16 = Accel->iGsFIFO[i][CHX];
67 Accel->iGsFIFO[i][CHX] = Accel->iGsFIFO[i][CHY];
68 Accel->iGsFIFO[i][CHY] = itmp16;
69#endif // NED
70#if THISCOORDSYSTEM == ANDROID
71 // the ANDROID transformation has not been confirmed
72#endif // Android
73#if (THISCOORDSYSTEM == WIN8)
74 // the Windows transformation has not been confirmed
75#endif // Win8
76 } // end of loop over FIFO count
77 return;
78} // end ApplyAccelHAL()
79
80// remap the Magnetometer axes
81void ApplyMagHAL(struct MagSensor *Mag) {
82 int8_t i; // loop counter
83 int16_t itmp16;
84
85 // remap all measurements in FIFO buffer
86 for (i = 0; i < Mag->iFIFOCount; i++) {
87 // apply mapping for coordinate system used
88#if THISCOORDSYSTEM == NED
89 itmp16 = Mag->iBsFIFO[i][CHX];
90 Mag->iBsFIFO[i][CHX] = -Mag->iBsFIFO[i][CHY];
91 Mag->iBsFIFO[i][CHY] = -itmp16;
92 Mag->iBsFIFO[i][CHZ] = -Mag->iBsFIFO[i][CHZ];
93#endif // NED
94#if THISCOORDSYSTEM == ANDROID
95#endif // Android
96#if THISCOORDSYSTEM == WIN8
97#endif
98 } // end of loop over FIFO count
99 return;
100}//end ApplyMagHAL()
101
102
103// remap the Gyroscope axes
104void ApplyGyroHAL(struct GyroSensor *Gyro) {
105 int8_t i; // loop counter
106 int16_t itmp16;
107 // remap all measurements in FIFO buffer
108 for (i = 0; i < Gyro->iFIFOCount; i++) {
109 // apply mapping for coordinate system used
110#if THISCOORDSYSTEM == NED
111 itmp16 = Gyro->iYsFIFO[i][CHX];
112 Gyro->iYsFIFO[i][CHX] = -Gyro->iYsFIFO[i][CHY];
113 Gyro->iYsFIFO[i][CHY] = -itmp16;
114 Gyro->iYsFIFO[i][CHZ] = -Gyro->iYsFIFO[i][CHZ];
115#endif // NED
116#if THISCOORDSYSTEM == ANDROID
117#endif // Android
118#if THISCOORDSYSTEM == WIN8
119#endif // Win8
120
121 } // end of loop over FIFO count
122
123 return;
124}//end ApplyGyroHAL()
void ApplyMagHAL(struct MagSensor *Mag)
Apply the magnetometer Hardware Abstraction Layer.
void ApplyGyroHAL(struct GyroSensor *Gyro)
Apply the gyroscope Hardware Abstraction Layer.
void ApplyAccelHAL(struct AccelSensor *Accel)
Apply the accelerometer Hardware Abstraction Layer.
The sensor_fusion.h file implements the top level programming interface.
#define CHX
Used to access X-channel entries in various data data structures.
#define CHY
Used to access Y-channel entries in various data data structures.
#define CHZ
Used to access Z-channel entries in various data data structures.
The AccelSensor structure stores raw and processed measurements for a 3-axis accelerometer.
uint8_t iFIFOCount
number of measurements read from FIFO
int16_t iGsFIFO[ACCEL_FIFO_SIZE][3]
FIFO measurements (counts)
The GyroSensor structure stores raw and processed measurements for a 3-axis gyroscope.
int16_t iYsFIFO[GYRO_FIFO_SIZE][3]
FIFO measurements (counts)
uint8_t iFIFOCount
number of measurements read from FIFO
The MagSensor structure stores raw and processed measurements for a 3-axis magnetic sensor.
uint8_t iFIFOCount
number of measurements read from FIFO
int16_t iBsFIFO[MAG_FIFO_SIZE][3]
FIFO measurements (counts)