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

master
gdisirio 2007-11-23 13:53:53 +00:00
parent f851339621
commit f2ced068fb
8 changed files with 24 additions and 27 deletions

View File

@ -139,13 +139,13 @@ int main(int argc, char **argv) {
* Normal main() activity, in this demo it serves events generated by
* various sources.
*/
evtInit(&evt, 500); /* Initializes an event timer object. */
evtRegister(&evt, &el0, 0); /* Registers on the timer event source. */
evtStart(&evt); /* Starts the event timer. */
mmcStartPolling(); /* Starts the MMC connector polling. */
evtInit(&evt, 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. */
while (TRUE) /* Just serve events. */
chEvtWait(ALL_EVENTS, evhndl);
return 0;
}

View File

@ -60,6 +60,7 @@ AVR-AT90CANx-GCC - Port on AVR AT90CAN128, not complete yet.
It is expanded as:
ULONG32 waThread1[UserStackSpace(32) >> 2];
Now the demos use the new declaration style.
- Fixed a small problem in sleep functions introduced in 0.4.1.
*** 0.4.1 ***
- Modified the initialization code in order to have a dedicated idle thread in

View File

@ -25,13 +25,7 @@
#include <ch.h>
/** @cond never*/
ReadyList rlist;
#ifdef CH_USE_SYSTEMTIME
volatile t_time stime;
#endif
/** @endcond */
/**
@ -44,7 +38,7 @@ void chSchInit(void) {
rlist.r_prio = ABSPRIO;
rlist.r_preempt = CH_TIME_QUANTUM;
#ifdef CH_USE_SYSTEMTIME
stime = 0;
rlist.r_stime = 0;
#endif
}
@ -193,7 +187,7 @@ void chSchTimerHandlerI(void) {
rlist.r_preempt--;
#ifdef CH_USE_SYSTEMTIME
stime++;
rlist.r_stime++;
#endif
#ifdef CH_USE_VIRTUAL_TIMERS

View File

@ -113,6 +113,7 @@ void chSemWaitS(Semaphore *sp) {
#ifdef CH_USE_SEMAPHORES_TIMEOUT
static void wakeup(void *p) {
#ifdef CH_USE_DEBUG
if (((Thread *)p)->p_state != PRWTSEM)
chDbgPanic("chsem.c, wakeup()\r\n");

View File

@ -25,6 +25,15 @@
#include <ch.h>
#ifdef CH_USE_SLEEP
static void wakeup(void *p) {
#ifdef CH_USE_DEBUG
if (((Thread *)p)->p_state != PRSLEEP)
chDbgPanic("chsleep.c, wakeup()\r\n");
#endif
chSchReadyI(p, RDY_OK);
}
/**
* Suspends the invoking thread for the specified time.
* @param time the system ticks number
@ -34,7 +43,7 @@ void chThdSleep(t_time time) {
chSysLock();
chVTSetI(&vt, time, (t_vtfunc)chSchReadyI, currp);
chVTSetI(&vt, time, wakeup, currp);
chSchGoSleepS(PRSLEEP);
chSysUnlock();
@ -53,7 +62,7 @@ void chThdSleepUntil(t_time time) {
chSysLock();
chVTSetI(&vt, (t_time)(time - stime), (t_vtfunc)chSchReadyI, currp);
chVTSetI(&vt, (t_time)(time - rlist.r_stime), wakeup, currp);
chSchGoSleepS(PRSLEEP);
chSysUnlock();

View File

@ -44,6 +44,9 @@ typedef struct {
#ifndef CH_CURRP_REGISTER_CACHE
Thread *r_current;
#endif
#ifdef CH_USE_SYSTEMTIME
volatile t_time r_stime;
#endif
} ReadyList;
extern ReadyList rlist;

View File

@ -32,7 +32,6 @@ extern "C" {
void chThdSleep(t_time time);
#ifdef CH_USE_SYSTEMTIME
void chThdSleepUntil(t_time time);
t_time chSysGetTime(void);
#endif /* CH_USE_SYSTEMTIME */
#endif /* CH_USE_SLEEP */
#ifdef __cplusplus
@ -47,7 +46,7 @@ extern "C" {
* @note The function is available only if the \p CH_USE_SYSTEMTIME
* option is enabled in \p chconf.h.
*/
#define chSysGetTime() stime
#define chSysGetTime() rlist.r_stime
#endif /* _SLEEP_H_ */

View File

@ -50,16 +50,6 @@ extern "C" {
(etp)->et_vt.vt_func = NULL, \
(etp)->et_interval = (i))
/**
* Registers the invoking thread as listener on the timer event.
*/
#define evtRegister(etp, el, eid) chEvtRegister(&(etp)->et_es, el, eid)
/**
* Unregisters the invoking thread as listener on the timer event.
*/
#define evtUnregister(etp, el) chEvtUnregister(&(etp)->et_es, el)
#endif /* _EVTIMER_H_ */
/** @} */