aboutsummaryrefslogtreecommitdiffstats
path: root/demos/ARM7-LPC214x-GCC/main.c
diff options
context:
space:
mode:
Diffstat (limited to 'demos/ARM7-LPC214x-GCC/main.c')
-rw-r--r--demos/ARM7-LPC214x-GCC/main.c85
1 files changed, 9 insertions, 76 deletions
diff --git a/demos/ARM7-LPC214x-GCC/main.c b/demos/ARM7-LPC214x-GCC/main.c
index d0a69b3d7..00aca0ec7 100644
--- a/demos/ARM7-LPC214x-GCC/main.c
+++ b/demos/ARM7-LPC214x-GCC/main.c
@@ -20,10 +20,6 @@
#include "ch.h"
#include "hal.h"
#include "test.h"
-#include "evtimer.h"
-
-#include "mmcsd.h"
-#include "buzzer.h"
#define BOTH_BUTTONS (PAL_PORT_BIT(PA_BUTTON1) | PAL_PORT_BIT(PA_BUTTON2))
@@ -63,73 +59,11 @@ static msg_t Thread2(void *arg) {
return 0;
}
-static WORKING_AREA(waTestThread, 128);
-
-/*
- * Executed as event handler at 500mS intervals.
- */
-static void TimerHandler(eventid_t id) {
-
- (void)id;
- if (!(palReadPort(IOPORT1) & BOTH_BUTTONS)) {
- Thread *tp = chThdCreateStatic(waTestThread, sizeof(waTestThread),
- NORMALPRIO, TestThread, &SD1);
- chThdWait(tp);
- PlaySound(500, MS2ST(100));
- }
- else {
- if (!palReadPad(IOPORT1, PA_BUTTON1))
- PlaySound(1000, MS2ST(100));
- if (!palReadPad(IOPORT1, PA_BUTTON2)) {
- sdWrite(&SD1, (uint8_t *)"Hello World!\r\n", 14);
- PlaySound(2000, MS2ST(100));
- }
- }
-}
-
-/*
- * Plays sounds when a MMC/SD card is inserted, then initializes the MMC
- * driver and reads a sector.
- */
-static void InsertHandler(eventid_t id) {
- static uint8_t rwbuf[512];
- MMCCSD data;
-
- (void)id;
- PlaySoundWait(1000, MS2ST(100));
- PlaySoundWait(2000, MS2ST(100));
- if (mmcInit())
- return;
- /* Card ready, do stuff.*/
- if (mmcGetSize(&data))
- return;
- if (mmcRead(rwbuf, 0))
- return;
- PlaySound(440, MS2ST(200));
-}
-
-/*
- * Plays sounds when a MMC/SD card is removed.
- */
-static void RemoveHandler(eventid_t id) {
-
- (void)id;
- PlaySoundWait(2000, MS2ST(100));
- PlaySoundWait(1000, MS2ST(100));
-}
-
/*
* Entry point, note, the main() function is already a thread in the system
* on entry.
*/
int main(int argc, char **argv) {
- static const evhandler_t evhndl[] = {
- TimerHandler,
- InsertHandler,
- RemoveHandler
- };
- static EvTimer evt;
- struct EventListener el0, el1, el2;
(void)argc;
(void)argv;
@@ -149,16 +83,15 @@ int main(int argc, char **argv) {
}
/*
- * Normal main() activity, in this demo it serves events generated by
- * various sources.
+ * Normal main() thread activity, in this demo it does nothing except
+ * sleeping in a loop and check the buttons state.
*/
- evtInit(&evt, MS2ST(500)); /* Initializes an event timer object. */
- evtStart(&evt); /* Starts the event timer. */
- chEvtRegister(&evt.et_es, &el0, 0); /* Registers on the timer event source. */
- mmcStartPolling(); /* Starts the MMC connector polling. */
- chEvtRegister(&MMCInsertEventSource, &el1, 1);
- chEvtRegister(&MMCRemoveEventSource, &el2, 2);
- while (TRUE) /* Just serve events. */
- chEvtDispatch(evhndl, chEvtWaitOne(ALL_EVENTS));
+ while (TRUE) {
+ if (!palReadPad(IOPORT1, PA_BUTTON1))
+ sdWrite(&SD1, (uint8_t *)"Hello World!\r\n", 14);
+ if (!palReadPad(IOPORT1, PA_BUTTON2))
+ TestThread(&SD1);
+ chThdSleepMilliseconds(500);
+ }
return 0;
}