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"
37 bool gyroSyncCheckUpdate(gyroDev_t
*gyro
)
40 if (gyro
->dataReady
) {
42 gyro
->dataReady
= false;
49 uint16_t gyroSetSampleRate(gyroDev_t
*gyro
)
51 uint16_t gyroSampleRateHz
;
52 uint16_t accSampleRateHz
;
54 switch (gyro
->mpuDetectionResult
.sensor
) {
56 gyro
->gyroRateKHz
= GYRO_RATE_3200_Hz
;
57 gyroSampleRateHz
= 3200;
58 accSampleRateHz
= 800;
61 #ifdef USE_GYRO_DLPF_EXPERIMENTAL
62 if (gyro
->hardware_lpf
== GYRO_HARDWARE_LPF_EXPERIMENTAL
) {
63 // 6.4KHz sampling, but data is unfiltered (no hardware DLPF)
64 gyro
->gyroRateKHz
= GYRO_RATE_6400_Hz
;
65 gyroSampleRateHz
= 6400;
69 gyro
->gyroRateKHz
= GYRO_RATE_3200_Hz
;
70 gyroSampleRateHz
= 3200;
72 accSampleRateHz
= 800;
75 gyro
->gyroRateKHz
= GYRO_RATE_9_kHz
;
76 gyroSampleRateHz
= 9000;
77 accSampleRateHz
= 1125;
79 #ifdef USE_ACCGYRO_LSM6DSO
81 gyro
->gyroRateKHz
= GYRO_RATE_6664_Hz
;
82 gyroSampleRateHz
= 6664; // Yes, this is correct per the datasheet. Will effectively round to 150us and 6.67KHz.
83 accSampleRateHz
= 833;
87 gyro
->gyroRateKHz
= GYRO_RATE_8_kHz
;
88 gyroSampleRateHz
= 8000;
89 accSampleRateHz
= 1000;
93 gyro
->mpuDividerDrops
= 0; // we no longer use the gyro's sample divider
94 gyro
->accSampleRateHz
= accSampleRateHz
;
95 return gyroSampleRateHz
;