Bye bye Wii Motion Plus, hello MPU6050. Also, increase control loop

to 200Hz, add SD card logging, and a number of other changes.
This commit is contained in:
2014-05-06 21:03:48 +00:00
parent b482b85ffd
commit e8adff93c1
25 changed files with 1725 additions and 581 deletions

19
event.c
View File

@@ -1,6 +1,7 @@
#include "event.h"
#include "interrupt.h"
#include "types.h"
#include "log.h"
event_handler *event_handler_table[EVENT_MAX+1];
@@ -13,14 +14,18 @@ unsigned int event_pending[EVENT_WORDS];
#define EVENT_BIT(x) (x%EVENT_WORDLEN)
#define EVENT_MASK(x) (1<<EVENT_BIT(x))
/*
* This function must be called with interrupts disabled.
* This will normally be the case as it is typically called from within
* an interrupt handler anyway.
*/
void event_set(unsigned int event)
{
if (event > EVENT_MAX)
return;
interrupt_block();
event_pending[EVENT_WORD(event)] |= EVENT_MASK(event);
interrupt_unblock();
}
static int bitset(unsigned int x)
@@ -56,15 +61,21 @@ void event_clear(unsigned int event)
interrupt_unblock();
}
void event_dispatch(void)
bool event_dispatch(void)
{
unsigned int event;
if (event_get(&event)) {
event_clear(event);
if (event_handler_table[event] != NULL)
if (event_handler_table[event] != NULL) {
log_mark_busy();
(event_handler_table[event])();
log_mark_idle();
}
return TRUE;
}
return FALSE;
}
void event_register(unsigned int event, event_handler *handler)