git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@46 35acf78f-673a-0410-8e92-d51de3d6d3f4

This commit is contained in:
gdisirio 2007-10-06 17:01:14 +00:00
parent 9229005c5d
commit 6264592246
5 changed files with 33 additions and 18 deletions

View File

@ -77,7 +77,7 @@ TSRC =
ASMSRC = crt0.s chcore2.s
# List all user directories here
UINCDIR = ../../src/include ../../ports/ARM7-LPC214x/GCC
UINCDIR = ../../src/include ../../src/lib ../../ports/ARM7-LPC214x/GCC
# List the user directory to look for the libraries here
ULIBDIR =

View File

@ -22,6 +22,7 @@
#include "lpc214x.h"
#include "lpc214x_serial.h"
#include "buzzer.h"
#include "evtimer.h"
static BYTE8 waThread1[UserStackSize(32)];
@ -53,24 +54,36 @@ static t_msg Thread2(void *arg) {
return 0;
}
static void TimerHandler(t_eventid id) {
t_msg TestThread(void *p);
if (!(IO0PIN & 0x00018000)) { // Both buttons
TestThread(&COM1);
PlaySound(500, 100);
}
else {
if (!(IO0PIN & 0x00008000)) // Button 1
PlaySound(1000, 100);
if (!(IO0PIN & 0x00010000)) // Button 2
chFDDWrite(&COM1, (BYTE8 *)"Hello World!\r\n", 14);
}
}
static BYTE8 waThread3[UserStackSize(64)];
static EvTimer evt;
static t_evhandler evhndl[1] = {
TimerHandler
};
static t_msg Thread3(void *arg) {
t_msg TestThread(void *p);
struct EventListener el;
while (TRUE) {
if (!(IO0PIN & 0x00018000)) {
TestThread(&COM1);
PlaySound(500, 100);
}
else {
if (!(IO0PIN & 0x00008000)) // Button 1
PlaySound(1000, 100);
if (!(IO0PIN & 0x00010000)) // Button 2
chFDDWrite(&COM1, (BYTE8 *)"Hello World!\r\n", 14);
}
chThdSleep(500);
}
evtInit(&evt, 500);
evtRegister(&evt, &el, 0);
evtStart(&evt);
while (TRUE)
chEvtWait(ALL_EVENTS, evhndl);
return 0;
}

View File

@ -45,6 +45,7 @@ AVR-AT90CANx-GCC - Port on AVER AT90CAN128, not complete yet.
main() procedure are performed before any thread starts.
- Added chThdSetPriority() new API.
- Added a generic events generator timer to the library code.
- Modified the ARM7-LPC214x-GCC demo to show the use of the event timer.
- Added the "#ifdef __cplusplus" stuff to the header files.
- Removed an obsolete definition in ./src/templates/chtypes.h.

View File

@ -32,6 +32,7 @@
static void tmrcb(void *p) {
EvTimer *etp = p;
chEvtSendI(&etp->et_es);
chVTSetI(&etp->et_vt, etp->et_interval, tmrcb, etp);
}

View File

@ -46,9 +46,9 @@ extern "C" {
/**
* Initializes an \p EvTimer structure.
*/
#define evtInit(et, i) (chEvtInit(&(etp)->et_es), \
(etp)->et_vt.vt_func = NULL, \
(etp)->et_interval = (i))
#define evtInit(etp, i) (chEvtInit(&(etp)->et_es), \
(etp)->et_vt.vt_func = NULL, \
(etp)->et_interval = (i))
/**
* Registers the invoking thread as listener on the timer event.