git-svn-id: svn://svn.code.sf.net/p/chibios/svn/trunk@7379 35acf78f-673a-0410-8e92-d51de3d6d3f4
parent
e55acb6b05
commit
855065f239
|
@ -220,6 +220,61 @@ osStatus osTimerDelete (osTimerId timer_id) {
|
||||||
return osOK;
|
return osOK;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Send signals.
|
||||||
|
*/
|
||||||
|
int32_t osSignalSet(osThreadId thread_id, int32_t signals) {
|
||||||
|
int32_t oldsignals;
|
||||||
|
|
||||||
|
syssts_t sts = chSysGetStatusAndLockX();
|
||||||
|
oldsignals = (int32_t)thread_id->p_epending;
|
||||||
|
chEvtSignalI((thread_t *)thread_id, (eventmask_t)signals);
|
||||||
|
chSysRestoreStatusX(sts);
|
||||||
|
|
||||||
|
return oldsignals;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Clear signals.
|
||||||
|
*/
|
||||||
|
int32_t osSignalClear(osThreadId thread_id, int32_t signals) {
|
||||||
|
eventmask_t m;
|
||||||
|
|
||||||
|
chSysLock();
|
||||||
|
|
||||||
|
m = thread_id->p_epending & (eventmask_t)signals;
|
||||||
|
thread_id->p_epending &= ~(eventmask_t)signals;
|
||||||
|
|
||||||
|
chSysUnlock();
|
||||||
|
|
||||||
|
return (int32_t)m;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Wait for signals.
|
||||||
|
*/
|
||||||
|
osEvent osSignalWait(int32_t signals, uint32_t millisec) {
|
||||||
|
osEvent event;
|
||||||
|
|
||||||
|
systime_t timeout = millisec == osWaitForever ? TIME_INFINITE :
|
||||||
|
(systime_t)millisec;
|
||||||
|
|
||||||
|
if (signals == 0)
|
||||||
|
event.value.signals = (uint32_t)chEvtWaitAnyTimeout((eventmask_t)signals,
|
||||||
|
timeout);
|
||||||
|
else
|
||||||
|
event.value.signals = (uint32_t)chEvtWaitAllTimeout((eventmask_t)signals,
|
||||||
|
timeout);
|
||||||
|
|
||||||
|
/* Type of event.*/
|
||||||
|
if (event.value.signals == 0)
|
||||||
|
event.status = osEventTimeout;
|
||||||
|
else
|
||||||
|
event.status = osEventSignal;
|
||||||
|
|
||||||
|
return event;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Create a semaphore.
|
* @brief Create a semaphore.
|
||||||
* @note @p semaphore_def is not used.
|
* @note @p semaphore_def is not used.
|
||||||
|
|
|
@ -105,6 +105,14 @@
|
||||||
#error "CMSIS RTOS requires CH_CFG_USE_MEMPOOLS"
|
#error "CMSIS RTOS requires CH_CFG_USE_MEMPOOLS"
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
|
#if !CH_CFG_USE_EVENTS
|
||||||
|
#error "CMSIS RTOS requires CH_CFG_USE_EVENTS"
|
||||||
|
#endif
|
||||||
|
|
||||||
|
#if !CH_CFG_USE_EVENTS_TIMEOUT
|
||||||
|
#error "CMSIS RTOS requires CH_CFG_USE_EVENTS_TIMEOUT"
|
||||||
|
#endif
|
||||||
|
|
||||||
#if !CH_CFG_USE_SEMAPHORES
|
#if !CH_CFG_USE_SEMAPHORES
|
||||||
#error "CMSIS RTOS requires CH_CFG_USE_SEMAPHORES"
|
#error "CMSIS RTOS requires CH_CFG_USE_SEMAPHORES"
|
||||||
#endif
|
#endif
|
||||||
|
@ -196,6 +204,22 @@ typedef binary_semaphore_t *osMutexId;
|
||||||
*/
|
*/
|
||||||
typedef semaphore_t *osSemaphoreId;
|
typedef semaphore_t *osSemaphoreId;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* @brief Type of an event.
|
||||||
|
*/
|
||||||
|
typedef struct {
|
||||||
|
osStatus status;
|
||||||
|
union {
|
||||||
|
uint32_t v;
|
||||||
|
void *p;
|
||||||
|
int32_t signals;
|
||||||
|
} value;
|
||||||
|
/* union {
|
||||||
|
osMailQId mail_id;
|
||||||
|
osMessageQId message_id;
|
||||||
|
} def;*/
|
||||||
|
} osEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* @brief Type of a thread definition block.
|
* @brief Type of a thread definition block.
|
||||||
*/
|
*/
|
||||||
|
@ -324,6 +348,9 @@ extern "C" {
|
||||||
osStatus osTimerStart (osTimerId timer_id, uint32_t millisec);
|
osStatus osTimerStart (osTimerId timer_id, uint32_t millisec);
|
||||||
osStatus osTimerStop (osTimerId timer_id);
|
osStatus osTimerStop (osTimerId timer_id);
|
||||||
osStatus osTimerDelete (osTimerId timer_id);
|
osStatus osTimerDelete (osTimerId timer_id);
|
||||||
|
int32_t osSignalSet (osThreadId thread_id, int32_t signals);
|
||||||
|
int32_t osSignalClear (osThreadId thread_id, int32_t signals);
|
||||||
|
osEvent osSignalWait (int32_t signals, uint32_t millisec);
|
||||||
osSemaphoreId osSemaphoreCreate (const osSemaphoreDef_t *semaphore_def,
|
osSemaphoreId osSemaphoreCreate (const osSemaphoreDef_t *semaphore_def,
|
||||||
int32_t count);
|
int32_t count);
|
||||||
int32_t osSemaphoreWait (osSemaphoreId semaphore_id, uint32_t millisec);
|
int32_t osSemaphoreWait (osSemaphoreId semaphore_id, uint32_t millisec);
|
||||||
|
|
Loading…
Reference in New Issue