1
0
Fork 0
mirror of https://github.com/betaflight/betaflight.git synced 2025-07-15 12:25:20 +03:00

SPRACING32/NAZE32 - Add support for MPU6050 data ready interrupt.

Currently the interrupt handler is unused.  Later it can be used as a
potential source for watchdog checking or to syncronize the system
around new acc/gyro data availability.

Verified on Naze32 rev 3/4/5 and SPRacingF3 targets.
This commit is contained in:
Dominic Clifton 2015-04-11 19:18:11 +01:00
parent d3d9721e91
commit c11c25514b
10 changed files with 157 additions and 20 deletions

View file

@ -15,6 +15,7 @@
* along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
*/
#include <string.h>
#include <stdbool.h>
#include <stdint.h>
#include <stdlib.h>
@ -30,6 +31,35 @@
#include "system.h"
#ifndef EXTI15_10_CALLBACK_HANDLER_COUNT
#define EXTI15_10_CALLBACK_HANDLER_COUNT 1
#endif
static extiCallbackHandler* exti15_10_handlers[EXTI15_10_CALLBACK_HANDLER_COUNT];
void registerExti15_10_CallbackHandler(extiCallbackHandler *fn)
{
for (int index = 0; index < EXTI15_10_CALLBACK_HANDLER_COUNT; index++) {
extiCallbackHandler *candidate = exti15_10_handlers[index];
if (!candidate) {
exti15_10_handlers[index] = fn;
break;
}
}
}
void EXTI15_10_IRQHandler(void)
{
for (int index = 0; index < EXTI15_10_CALLBACK_HANDLER_COUNT; index++) {
extiCallbackHandler *fn = exti15_10_handlers[index];
if (!fn) {
continue;
}
fn();
}
}
// cycles per microsecond
static uint32_t usTicks = 0;
// current uptime for 1kHz systick timer. will rollover after 49 days. hopefully we won't care.
@ -96,6 +126,8 @@ void systemInit(void)
// Init cycle counter
cycleCounterInit();
memset(exti15_10_handlers, 0, sizeof(exti15_10_handlers));
// SysTick
SysTick_Config(SystemCoreClock / 1000);
}
@ -158,5 +190,3 @@ void failureMode(uint8_t mode)
systemResetToBootloader();
}