2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
24 #include "common/axis.h"
25 #include "common/utils.h"
27 #include "fc/runtime_config.h"
29 #include "drivers/accgyro/accgyro.h"
30 #include "drivers/accgyro/accgyro_fake.h"
35 static float fakeGyroADC
[XYZ_AXIS_COUNT
];
37 static void fakeGyroInit(gyroDev_t
*gyro
)
42 void fakeGyroSet(int16_t x
, int16_t y
, int16_t z
)
49 static bool fakeGyroRead(gyroDev_t
*gyro
)
51 gyro
->gyroADCRaw
[X
] = fakeGyroADC
[X
];
52 gyro
->gyroADCRaw
[Y
] = fakeGyroADC
[Y
];
53 gyro
->gyroADCRaw
[Z
] = fakeGyroADC
[Z
];
57 static bool fakeGyroReadTemperature(gyroDev_t
*gyro
, int16_t *temperatureData
)
60 UNUSED(temperatureData
);
64 static bool fakeGyroInitStatus(gyroDev_t
*gyro
)
70 bool fakeGyroDetect(gyroDev_t
*gyro
)
72 gyro
->initFn
= fakeGyroInit
;
73 gyro
->intStatusFn
= fakeGyroInitStatus
;
74 gyro
->readFn
= fakeGyroRead
;
75 gyro
->temperatureFn
= fakeGyroReadTemperature
;
76 gyro
->scale
= 0.0625f
;
81 static int16_t fakeAccData
[XYZ_AXIS_COUNT
];
83 static void fakeAccInit(accDev_t
*acc
)
88 void fakeAccSet(int16_t x
, int16_t y
, int16_t z
)
95 static bool fakeAccRead(accDev_t
*acc
)
97 acc
->ADCRaw
[X
] = fakeAccData
[X
];
98 acc
->ADCRaw
[Y
] = fakeAccData
[Y
];
99 acc
->ADCRaw
[Z
] = fakeAccData
[Z
];
103 bool fakeAccDetect(accDev_t
*acc
)
105 acc
->initFn
= fakeAccInit
;
106 acc
->readFn
= fakeAccRead
;