git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@53 35acf78f-673a-0410-8e92-d51de3d6d3f4
parent
779840691f
commit
70c86d43ec
|
@ -69,7 +69,7 @@ void PlaySound(int freq, t_time duration) {
|
|||
|
||||
chSysLock();
|
||||
|
||||
if (bvt.vt_func) { // If a sound is already being played
|
||||
if (chVTIsArmedI(&bvt)) { // If a sound is already being played
|
||||
chVTResetI(&bvt); // then aborts it.
|
||||
StopCounter(tc);
|
||||
}
|
||||
|
|
|
@ -51,6 +51,10 @@
|
|||
* function is included in the kernel.*/
|
||||
#define CH_USE_RESUME
|
||||
|
||||
/** Configuration option: if specified then the \p chThdSuspend()
|
||||
* function is included in the kernel.*/
|
||||
#define CH_USE_SUSPEND
|
||||
|
||||
/** Configuration option: if specified then the \p chThdTerminate()
|
||||
* and \p chThdShouldTerminate() functions are included in the kernel.*/
|
||||
#define CH_USE_TERMINATE
|
||||
|
|
|
@ -52,6 +52,10 @@
|
|||
* function is included in the kernel.*/
|
||||
#define CH_USE_RESUME
|
||||
|
||||
/** Configuration option: if specified then the \p chThdSuspend()
|
||||
* function is included in the kernel.*/
|
||||
#define CH_USE_SUSPEND
|
||||
|
||||
/** Configuration option: if specified then the \p chThdTerminate()
|
||||
* and \p chThdShouldTerminate() functions are included in the kernel.*/
|
||||
#define CH_USE_TERMINATE
|
||||
|
|
|
@ -56,6 +56,10 @@
|
|||
* function is included in the kernel.*/
|
||||
#define CH_USE_RESUME
|
||||
|
||||
/** Configuration option: if specified then the \p chThdSuspend()
|
||||
* function is included in the kernel.*/
|
||||
#define CH_USE_SUSPEND
|
||||
|
||||
/** Configuration option: if specified then the \p chThdTerminate()
|
||||
* and \p chThdShouldTerminate() functions are included in the kernel.*/
|
||||
#define CH_USE_TERMINATE
|
||||
|
|
|
@ -56,6 +56,10 @@
|
|||
* function is included in the kernel.*/
|
||||
#define CH_USE_RESUME
|
||||
|
||||
/** Configuration option: if specified then the \p chThdSuspend()
|
||||
* function is included in the kernel.*/
|
||||
#define CH_USE_SUSPEND
|
||||
|
||||
/** Configuration option: if specified then the \p chThdTerminate()
|
||||
* and \p chThdShouldTerminate() functions are included in the kernel.*/
|
||||
#define CH_USE_TERMINATE
|
||||
|
|
|
@ -227,6 +227,7 @@ PREDEFINED = __JUST_STUBS__ \
|
|||
CH_USE_SYSTEMTIME \
|
||||
CH_USE_SLEEP \
|
||||
CH_USE_RESUME \
|
||||
CH_USE_SUSPEND \
|
||||
CH_USE_TERMINATE \
|
||||
CH_USE_WAITEXIT \
|
||||
CH_USE_SEMAPHORES \
|
||||
|
|
|
@ -106,12 +106,12 @@ static void OutNotify2(void) {
|
|||
u->UART_IER |= IER_THRE;
|
||||
}
|
||||
|
||||
void UART0Irq(void){
|
||||
void UART0Irq(void) {
|
||||
|
||||
ServeInterrupt(U0Base, &COM1);
|
||||
}
|
||||
|
||||
void UART1Irq(void){
|
||||
void UART1Irq(void) {
|
||||
|
||||
ServeInterrupt(U1Base, &COM2);
|
||||
}
|
||||
|
|
|
@ -40,8 +40,10 @@ AVR-AT90CANx-GCC - Port on AVER AT90CAN128, not complete yet.
|
|||
|
||||
*** 0.3.4 ***
|
||||
- Fixed a problem in chVTSetI().
|
||||
- Modified chEvtWaitTimeout() to work correctly in the TIME_INFINITE
|
||||
scenario.
|
||||
- New API, chVTIsArmedI(), it is a macro in delta.h.
|
||||
- New API, chThdResumeI(), it is a macro in threads.h. This function is just
|
||||
an alias for chSchReadyI() but makes the code more readable.
|
||||
- New API, chThdSuspend(). New switch CH_USE_SUSPEND added to chconf.h.
|
||||
|
||||
*** 0.3.3 ***
|
||||
- Modified the chVTSetI(), now for the "time" parameter can have value zero
|
||||
|
@ -54,7 +56,7 @@ AVR-AT90CANx-GCC - Port on AVER AT90CAN128, not complete yet.
|
|||
- Modified the chSysInit() to give the idle thread absolute priority, the
|
||||
priority is then lowered to the minimum value into the chSysPause(). This
|
||||
is done in order to ensure that the initializations performed into the
|
||||
main() procedure are performed before any thread starts.
|
||||
main() procedure are finished before any thread starts.
|
||||
- Added chThdSetPriority() new API.
|
||||
- Added a generic events generator timer modulee to the library code.
|
||||
- Modified the ARM7-LPC214x-GCC demo to show the use of the event timer.
|
||||
|
|
|
@ -40,7 +40,9 @@ void chVTInit(void) {
|
|||
* Enables a virtual timer.
|
||||
* @param vtp the \p VirtualTimer structure pointer
|
||||
* @param time the number of time ticks, the value zero is allowed with
|
||||
* meaning "infinite".
|
||||
* meaning "infinite". In this case the structure is initialized
|
||||
* but not inserted in the delta list, the timer will never be
|
||||
* triggered.
|
||||
* @param vtfunc the timer callback function. After invoking the callback
|
||||
* the timer is disabled and the structure can be disposed or
|
||||
* reused.
|
||||
|
@ -51,8 +53,8 @@ void chVTInit(void) {
|
|||
void chVTSetI(VirtualTimer *vtp, t_time time, t_vtfunc vtfunc, void *par) {
|
||||
|
||||
vtp->vt_par = par;
|
||||
if (time) {
|
||||
vtp->vt_func = vtfunc;
|
||||
if (time) {
|
||||
VirtualTimer *p = dlist.dl_next;
|
||||
while (p->vt_dtime < time) {
|
||||
time -= p->vt_dtime;
|
||||
|
@ -66,7 +68,7 @@ void chVTSetI(VirtualTimer *vtp, t_time time, t_vtfunc vtfunc, void *par) {
|
|||
p->vt_dtime -= time;
|
||||
}
|
||||
else
|
||||
vtp->vt_func = NULL;
|
||||
vtp->vt_next = vtp->vt_prev = vtp; // Allows a chVTResetI() on the fake timer.
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
@ -205,7 +205,6 @@ t_eventid chEvtWaitTimeout(t_eventmask ewmask,
|
|||
t_time time) {
|
||||
t_eventid i;
|
||||
t_eventmask m;
|
||||
t_msg msg;
|
||||
|
||||
chSysLock();
|
||||
|
||||
|
@ -221,11 +220,10 @@ t_eventid chEvtWaitTimeout(t_eventmask ewmask,
|
|||
chVTSetI(&vt, time, unwait, currp);
|
||||
currp->p_ewmask = ewmask;
|
||||
chSchGoSleepS(PRWTEVENT);
|
||||
if (!vt.vt_func) {
|
||||
t_msg msg = currp->p_rdymsg;
|
||||
if (!chVTIsArmedI(&vt)) {
|
||||
|
||||
chSysUnlock();
|
||||
return msg;
|
||||
return RDY_TIMEOUT;
|
||||
}
|
||||
chVTResetI(&vt);
|
||||
}
|
||||
|
|
|
@ -115,7 +115,7 @@ t_msg chMsgSendTimeout(Thread *tp, t_msg msg, t_time time) {
|
|||
currp->p_msg = msg;
|
||||
chSchGoSleepS(PRSNDMSG);
|
||||
msg = currp->p_rdymsg;
|
||||
if (vt.vt_func)
|
||||
if (chVTIsArmedI(&vt))
|
||||
chVTResetI(&vt);
|
||||
|
||||
chSysUnlock();
|
||||
|
|
|
@ -139,7 +139,7 @@ t_msg chSemWaitTimeout(Semaphore *sp, t_time time) {
|
|||
currp->p_semp = sp;
|
||||
chSchGoSleepS(PRWTSEM);
|
||||
msg = currp->p_rdymsg;
|
||||
if (vt.vt_func)
|
||||
if (chVTIsArmedI(&vt))
|
||||
chVTResetI(&vt);
|
||||
|
||||
chSysUnlock();
|
||||
|
@ -169,7 +169,7 @@ t_msg chSemWaitTimeoutS(Semaphore *sp, t_time time) {
|
|||
fifo_insert(currp, &sp->s_queue);
|
||||
currp->p_semp = sp;
|
||||
chSchGoSleepS(PRWTSEM);
|
||||
if (vt.vt_func)
|
||||
if (chVTIsArmedI(&vt))
|
||||
chVTResetI(&vt);
|
||||
return currp->p_rdymsg;
|
||||
}
|
||||
|
|
|
@ -121,9 +121,34 @@ void chThdSetPriority(t_prio newprio) {
|
|||
chSysUnlock();
|
||||
}
|
||||
|
||||
#ifdef CH_USE_SUSPEND
|
||||
/**
|
||||
* Suspends the invoking thread.
|
||||
*
|
||||
* @param tpp pointer to a \p Thread pointer, the \p Thread pointer is set
|
||||
* to point to the suspended process before it enters the
|
||||
* \p PRSUSPENDED state, it is set to \p NULL after it is resumed.
|
||||
* This allows to implement a "test and resume" on the variable
|
||||
* into interrupt handlers.
|
||||
* @note The function is available only if the \p CH_USE_SUSPEND
|
||||
* option is enabled in \p chconf.h.
|
||||
*/
|
||||
void chThdSuspend(Thread **tpp) {
|
||||
|
||||
chSysLock();
|
||||
|
||||
*tpp = currp;
|
||||
chSchGoSleepS(PRSUSPENDED);
|
||||
*tpp = NULL;
|
||||
|
||||
chSysUnlock();
|
||||
}
|
||||
#endif /* CH_USE_SUSPEND */
|
||||
|
||||
#ifdef CH_USE_RESUME
|
||||
/**
|
||||
* Resumes a thread created with the \p P_SUSPENDED option.
|
||||
* Resumes a thread created with the \p P_SUSPENDED option or suspended with
|
||||
* \p chThdSuspend().
|
||||
* @param tp the pointer to the thread
|
||||
* @note The function has no effect on threads in any other state than
|
||||
* \p PRSUSPENDED.
|
||||
|
@ -134,8 +159,8 @@ void chThdResume(Thread *tp) {
|
|||
|
||||
chSysLock();
|
||||
|
||||
if (tp->p_state == PRSUSPENDED)
|
||||
chSchWakeupS(tp, RDY_OK);
|
||||
if ((tp)->p_state == PRSUSPENDED)
|
||||
chSchWakeupS((tp), RDY_OK);
|
||||
|
||||
chSysUnlock();
|
||||
}
|
||||
|
|
|
@ -97,6 +97,9 @@ extern "C" {
|
|||
}
|
||||
#endif
|
||||
|
||||
/** Returns TRUE if the speciified timer is armed.*/
|
||||
#define chVTIsArmedI(vtp) ((vtp)->vt_func != NULL)
|
||||
|
||||
#endif /* CH_USE_VIRTUAL_TIMER */
|
||||
|
||||
#endif /* _DELTA_H_ */
|
||||
|
|
|
@ -192,8 +192,10 @@ extern "C" {
|
|||
Thread *chThdCreate(t_prio prio, t_tmode mode, void *workspace,
|
||||
t_size wsize, t_tfunc pf, void *arg);
|
||||
void chThdSetPriority(t_prio newprio);
|
||||
void chThdResume(Thread *tp);
|
||||
void chThdExit(t_msg msg);
|
||||
#ifdef CH_USE_RESUME
|
||||
void chThdResume(Thread *tp);
|
||||
#endif
|
||||
#ifdef CH_USE_TERMINATE
|
||||
void chThdTerminate(Thread *tp);
|
||||
#endif
|
||||
|
@ -240,6 +242,13 @@ extern "C" {
|
|||
*/
|
||||
#define chThdGetExitEventSource(tp) (&(tp)->p_exitesource)
|
||||
|
||||
/**
|
||||
* Resumes a thread created with the \p P_SUSPENDED option or suspended with
|
||||
* \p chThdSuspend().
|
||||
* @param tp the pointer to the thread
|
||||
*/
|
||||
#define chThdResumeI(tp) chSchReadyI(tp)
|
||||
|
||||
#endif /* _THREADS_H_ */
|
||||
|
||||
/** @} */
|
||||
|
|
|
@ -45,7 +45,7 @@ void evtStart(EvTimer *etp) {
|
|||
|
||||
chSysLock();
|
||||
|
||||
if (!etp->et_vt.vt_func)
|
||||
if (!chVTIsArmedI(&etp->et_vt))
|
||||
chVTSetI(&etp->et_vt, etp->et_interval, tmrcb, etp);
|
||||
|
||||
chSysUnlock();
|
||||
|
@ -60,7 +60,7 @@ void evtStop(EvTimer *etp) {
|
|||
|
||||
chSysLock();
|
||||
|
||||
if (etp->et_vt.vt_func)
|
||||
if (chVTIsArmedI(&etp->et_vt))
|
||||
chVTResetI(&etp->et_vt);
|
||||
|
||||
chSysUnlock();
|
||||
|
|
|
@ -52,6 +52,10 @@
|
|||
* function is included in the kernel.*/
|
||||
#define CH_USE_RESUME
|
||||
|
||||
/** Configuration option: if specified then the \p chThdSuspend()
|
||||
* function is included in the kernel.*/
|
||||
#define CH_USE_SUSPEND
|
||||
|
||||
/** Configuration option: if specified then the \p chThdTerminate()
|
||||
* and \p chThdShouldTerminate() functions are included in the kernel.*/
|
||||
#define CH_USE_TERMINATE
|
||||
|
|
Loading…
Reference in New Issue