|
|
@@ -27,11 +27,11 @@ |
|
|
#define INCR_EVENT_INDEX( x ) { if ( ++x == MAX_EVENTS ) x = 0; } |
|
|
|
|
|
// et/Put indexes inxto sysEvents[] array |
|
|
static int putIdx = 0; |
|
|
static int getIdx = 0; |
|
|
volatile static int putIdx = 0; |
|
|
volatile static int getIdx = 0; |
|
|
|
|
|
// The system event queue is a circular array of event records. |
|
|
static event_t sysEvents[ MAX_EVENTS ]; |
|
|
volatile static event_t sysEvents[ MAX_EVENTS ]; |
|
|
|
|
|
// initializes (or re-initializes) the system event queue. |
|
|
void init_events( void ) { |
|
|
@@ -75,16 +75,14 @@ u8 event_next( event_t *e ) { |
|
|
|
|
|
// add event to queue, return success status |
|
|
u8 event_post( event_t *e ) { |
|
|
u8 status = false; |
|
|
int saveIndex; |
|
|
|
|
|
// print_dbg("\r\n posting event, type: "); |
|
|
// print_dbg_ulong(e->type); |
|
|
|
|
|
irqflags_t flags = cpu_irq_save(); |
|
|
u8 status = false; |
|
|
|
|
|
// increment write idx, posbily wrapping |
|
|
saveIndex = putIdx; |
|
|
int saveIndex = putIdx; |
|
|
INCR_EVENT_INDEX( putIdx ); |
|
|
if ( putIdx != getIdx ) { |
|
|
sysEvents[ putIdx ].type = e->type; |
|
|
@@ -97,8 +95,8 @@ u8 event_post( event_t *e ) { |
|
|
|
|
|
cpu_irq_restore(flags); |
|
|
|
|
|
if (!status) |
|
|
print_dbg("\r\n event queue full!"); |
|
|
//if (!status) |
|
|
// print_dbg("\r\n event queue full!"); |
|
|
|
|
|
return status; |
|
|
} |