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/>.
24 * Created on: 3 aug. 2015
33 #include "drivers/sensor.h"
34 #include "drivers/accgyro/accgyro.h"
35 #include "drivers/accgyro/gyro_sync.h"
38 bool gyroSyncCheckUpdate(gyroDev_t
*gyro
)
41 if (gyro
->dataReady
) {
43 gyro
->dataReady
= false;
50 uint16_t gyroSetSampleRate(gyroDev_t
*gyro
)
52 uint16_t gyroSampleRateHz
;
53 uint16_t accSampleRateHz
;
55 switch (gyro
->mpuDetectionResult
.sensor
) {
57 gyro
->gyroRateKHz
= GYRO_RATE_3200_Hz
;
58 gyroSampleRateHz
= 3200;
59 accSampleRateHz
= 800;
62 #ifdef USE_GYRO_DLPF_EXPERIMENTAL
63 if (gyro
->hardware_lpf
== GYRO_HARDWARE_LPF_EXPERIMENTAL
) {
64 // 6.4KHz sampling, but data is unfiltered (no hardware DLPF)
65 gyro
->gyroRateKHz
= GYRO_RATE_6400_Hz
;
66 gyroSampleRateHz
= 6400;
70 gyro
->gyroRateKHz
= GYRO_RATE_3200_Hz
;
71 gyroSampleRateHz
= 3200;
73 accSampleRateHz
= 800;
76 gyro
->gyroRateKHz
= GYRO_RATE_9_kHz
;
77 gyroSampleRateHz
= 9000;
78 accSampleRateHz
= 1125;
80 #ifdef USE_ACCGYRO_LSM6DSO
82 gyro
->gyroRateKHz
= GYRO_RATE_6664_Hz
;
83 gyroSampleRateHz
= 6664; // Yes, this is correct per the datasheet. Will effectively round to 150us and 6.67KHz.
84 accSampleRateHz
= 833;
88 gyro
->gyroRateKHz
= GYRO_RATE_8_kHz
;
89 gyroSampleRateHz
= 8000;
90 accSampleRateHz
= 1000;
94 gyro
->mpuDividerDrops
= 0; // we no longer use the gyro's sample divider
95 gyro
->accSampleRateHz
= accSampleRateHz
;
96 return gyroSampleRateHz
;