S5info_H14
/
APP2
gfdh
Revision 4:6a242f5bc7fa, committed 2014-01-28
- Comitter:
- joGenie
- Date:
- Tue Jan 28 02:45:00 2014 +0000
- Parent:
- 2:6009cb96f273
- Commit message:
- Quelques changement;
Changed in this revision
main.cpp | Show annotated file Show diff for this revision Revisions of this file |
diff -r 6009cb96f273 -r 6a242f5bc7fa main.cpp --- a/main.cpp Mon Jan 27 20:58:48 2014 +0000 +++ b/main.cpp Tue Jan 28 02:45:00 2014 +0000 @@ -1,28 +1,41 @@ #include "mbed.h" #include "rtos.h" +// Digital in DigitalIn en_1(p15); DigitalIn en_2(p16); +// Analog in AnalogIn ea_1(p19); AnalogIn ea_2(p20); +// Serial port usb Serial pc(USBTX, USBRX); +// Mutex Mutex event_mutex; -struct event +/** + Event definition +*/ +struct Event { - char *def; - time_t time; + char *def; //! Description of event + time_t time; //! Timestamps }; -Queue<event, 16> queue; +// List FIFO of events +Queue<Event, 16> queue; -void put(event *ev) +/** Put event in a queue +* +* @param ev Event to put +*/ +void put(Event *ev) { event_mutex.lock(); queue.put(ev); + delete ev; event_mutex.unlock(); } @@ -67,7 +80,7 @@ } else { - event *ev = new event; + Event *ev = new Event; // lecture de l'étampe temporelle ev->time = time(NULL); @@ -117,7 +130,7 @@ // synchronisation sur la période d'échantillonnage Thread::signal_wait(0x1); - event *ev = new event; + Event *ev = new Event; // lecture de l'étampe temporelle ev->time = time(NULL); @@ -166,7 +179,7 @@ // écriture de l'événement en sortie (port série) if (evt.status == osEventMessage) { - event *ev = (event*)evt.value.p; + Event *ev = (Event*)evt.value.p; char *buffer = new char; showTime(buffer, ev->time);