Permalink
Browse files

Messing with events

  • Loading branch information...
1 parent 9fd7b04 commit 140f9195ee8475b8388e40bf8883edd68a252dcc @grantmd committed Mar 24, 2012
Showing with 10 additions and 2 deletions.
  1. +3 −2 GPS.c
  2. +2 −0 GPS.h
  3. +3 −0 Spektrum.c
  4. +2 −0 Spektrum.h
View
@@ -27,11 +27,10 @@ static msg_t GPS(void *arg){
(void)arg;
chRegSetThreadName("GPS");
while (TRUE){
- unsigned char newdata = 0;
// Read a byte off the GPS
uint8_t c = chIOGet((BaseChannel *)&SD1);
if (TinyGPS_encode(c)){
- newdata = 1;
+ chEvtBroadcastI(&gps_event);
}
}
return 0;
@@ -48,5 +47,7 @@ void GPSInit(void){
palSetPadMode(GPIOA, 9, PAL_MODE_ALTERNATE(7)); // not currently connected
palSetPadMode(GPIOA, 10, PAL_MODE_ALTERNATE(7)); // incoming data from the GPS
+ chEvtInit(&gps_event);
+
chThdCreateStatic(GPSWA, sizeof(GPSWA), NORMALPRIO, GPS, NULL);
}
View
@@ -8,6 +8,8 @@
#ifndef _GPS_H_
#define _GPS_H_
+static EventSource gps_event;
+
// Public functions
void GPSInit(void);
View
@@ -19,6 +19,7 @@ static msg_t Spektrum(void *arg){
// Read a byte off the receiver
uint8_t c = chIOGet((BaseChannel *)&SD3);
if (_SpektrumParse(c)){
+ chEvtBroadcastI(&spektrum_event);
}
}
return 0;
@@ -67,6 +68,8 @@ void SpektrumInit(void){
rx_state.valid = 0;
rx_state.frameNum = 0L;
+ chEvtInit(&spektrum_event);
+
chThdCreateStatic(SPEKTRUMWA, sizeof(SPEKTRUMWA), NORMALPRIO, Spektrum, NULL);
}
View
@@ -18,6 +18,8 @@
#define GEAR_CHANNEL 5
#define AUX2_CHANNEL 6
+static EventSource spektrum_event;
+
// Public functions
void SpektrumInit(void);
int getSpektrumData(int channel);

0 comments on commit 140f919

Please sign in to comment.