diff options
author | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-02-25 11:35:51 +0000 |
---|---|---|
committer | gdisirio <gdisirio@35acf78f-673a-0410-8e92-d51de3d6d3f4> | 2012-02-25 11:35:51 +0000 |
commit | 27ab89ce98afa26410ef763190ba5b68e2981678 (patch) | |
tree | 64b3eba593f5bf24511dcf2a33f72929f138ba54 /testhal | |
parent | b136bcadfd7d190833e2c454d2c15f021184310a (diff) | |
download | ChibiOS-27ab89ce98afa26410ef763190ba5b68e2981678.tar.gz ChibiOS-27ab89ce98afa26410ef763190ba5b68e2981678.tar.bz2 ChibiOS-27ab89ce98afa26410ef763190ba5b68e2981678.zip |
git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@3976 35acf78f-673a-0410-8e92-d51de3d6d3f4
Diffstat (limited to 'testhal')
-rw-r--r-- | testhal/STM32F1xx/MAC/main.c | 28 |
1 files changed, 27 insertions, 1 deletions
diff --git a/testhal/STM32F1xx/MAC/main.c b/testhal/STM32F1xx/MAC/main.c index b1eac6fce..e563f779f 100644 --- a/testhal/STM32F1xx/MAC/main.c +++ b/testhal/STM32F1xx/MAC/main.c @@ -21,12 +21,21 @@ #include "ch.h"
#include "hal.h"
+#include "evtimer.h"
+
+#define PERIODIC_TIMER_ID 1
+#define FRAME_RECEIVED_ID 2
+
static const MACConfig mac_config = {NULL};
+static uint8_t frame[STM32_MAC_BUFFERS_SIZE];
+
/*
* Application entry point.
*/
int main(void) {
+ EvTimer evt;
+ EventListener el0, el1;
/*
* System initializations.
@@ -43,11 +52,28 @@ int main(void) { */
macStart(ÐD1, &mac_config);
+ /* Setup event sources.*/
+ evtInit(&evt, S2ST(5));
+ evtStart(&evt);
+ chEvtRegisterMask(&evt.et_es, &el0, PERIODIC_TIMER_ID);
+ chEvtRegisterMask(macGetReceiveEventSource(ÐD1), &el1, FRAME_RECEIVED_ID);
+ chEvtAddFlags(PERIODIC_TIMER_ID | FRAME_RECEIVED_ID);
+
/*
* Normal main() thread activity, in this demo it enables and disables the
* button EXT channel using 5 seconds intervals.
*/
while (TRUE) {
- chThdSleepMilliseconds(500);
+ eventmask_t mask = chEvtWaitAny(ALL_EVENTS);
+ if (mask & PERIODIC_TIMER_ID)
+ (void)macPollLinkStatus(ÐD1);
+ if (mask & FRAME_RECEIVED_ID) {
+ MACReceiveDescriptor rd;
+
+ if (macWaitReceiveDescriptor(ÐD1, &rd, TIME_IMMEDIATE) == RDY_OK) {
+ macReadReceiveDescriptor(&rd, frame, STM32_MAC_BUFFERS_SIZE);
+ macReleaseReceiveDescriptor(&rd);
+ }
+ }
}
}
|