2 * This file is part of Cleanflight and Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
23 #include "common/time.h"
25 #include "drivers/accgyro/accgyro.h"
26 #include "sensors/sensors.h"
28 // Type of accelerometer used/detected
51 } accelerationSensor_e
;
53 typedef struct acc_s
{
55 uint16_t sampleRateHz
;
56 float accADC
[XYZ_AXIS_COUNT
];
57 bool isAccelUpdatedAtLeastOnce
;
62 typedef struct rollAndPitchTrims_s
{
65 } rollAndPitchTrims_t_def
;
67 typedef union rollAndPitchTrims_u
{
69 rollAndPitchTrims_t_def values
;
70 } rollAndPitchTrims_t
;
73 typedef struct accelerometerConfig_s
{
74 uint16_t acc_lpf_hz
; // cutoff frequency for the low pass filter used on the acc z-axis for althold in Hz
75 uint8_t acc_hardware
; // Which acc hardware to use on boards with more than one device
77 flightDynamicsTrims_t accZero
;
78 rollAndPitchTrims_t accelerometerTrims
;
79 } accelerometerConfig_t
;
81 PG_DECLARE(accelerometerConfig_t
, accelerometerConfig
);
84 bool accInit(uint16_t accSampleRateHz
);
85 bool accIsCalibrationComplete(void);
86 bool accHasBeenCalibrated(void);
87 void accStartCalibration(void);
88 void resetRollAndPitchTrims(rollAndPitchTrims_t
*rollAndPitchTrims
);
89 void accUpdate(timeUs_t currentTimeUs
, rollAndPitchTrims_t
*rollAndPitchTrims
);
90 bool accGetAccumulationAverage(float *accumulation
);
91 union flightDynamicsTrims_u
;
92 void setAccelerationTrims(union flightDynamicsTrims_u
*accelerationTrimsToUse
);
93 void accInitFilters(void);
94 void applyAccelerometerTrimsDelta(union rollAndPitchTrims_u
*rollAndPitchTrimsDelta
);