本文整理汇总了C++中chSemInit函数的典型用法代码示例。如果您正苦于以下问题:C++ chSemInit函数的具体用法?C++ chSemInit怎么用?C++ chSemInit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了chSemInit函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: macObjectInit
/**
* @brief Initialize the standard part of a @p MACDriver structure.
*
* @param[in] macp pointer to the @p MACDriver object
*/
void macObjectInit(MACDriver *macp) {
chSemInit(&macp->md_tdsem, 0);
chSemInit(&macp->md_rdsem, 0);
#if CH_USE_EVENTS
chEvtInit(&macp->md_rdevent);
#endif
}
示例2: chMBInit
/**
* @brief Initializes a Mailbox object.
*
* @param[out] mbp the pointer to the Mailbox structure to be initialized
* @param[in] buf the circular messages buffer
* @param[in] n the buffer size as number of @p msg_t
*
* @init
*/
void chMBInit(Mailbox *mbp, msg_t *buf, cnt_t n) {
chDbgCheck((mbp != NULL) && (buf != NULL) && (n > 0), "chMBInit");
mbp->mb_buffer = mbp->mb_wrptr = mbp->mb_rdptr = buf;
mbp->mb_top = &buf[n];
chSemInit(&mbp->mb_emptysem, n);
chSemInit(&mbp->mb_fullsem, 0);
}
示例3: macObjectInit
/**
* @brief Initialize the standard part of a @p MACDriver structure.
*
* @param[out] macp pointer to the @p MACDriver object
*
* @init
*/
void macObjectInit(MACDriver *macp) {
macp->state = MAC_STOP;
macp->config = NULL;
chSemInit(&macp->tdsem, 0);
chSemInit(&macp->rdsem, 0);
#if MAC_USE_EVENTS
chEvtInit(&macp->rdevent);
#endif
}
示例4: canObjectInit
/**
* @brief Initializes the standard part of a @p CANDriver structure.
*
* @param[out] canp pointer to the @p CANDriver object
*
* @init
*/
void canObjectInit(CANDriver *canp) {
canp->state = CAN_STOP;
canp->config = NULL;
chSemInit(&canp->txsem, 0);
chSemInit(&canp->rxsem, 0);
chEvtInit(&canp->rxfull_event);
chEvtInit(&canp->txempty_event);
chEvtInit(&canp->error_event);
canp->status = 0;
#if CAN_USE_SLEEP_MODE
chEvtInit(&canp->sleep_event);
chEvtInit(&canp->wakeup_event);
#endif /* CAN_USE_SLEEP_MODE */
}
示例5: chSemInit
void DataListener< datatype >::init(datatype * listener_buf, uint32_t max_len){
len = max_len;
chSemInit(&sem, 0);
buf_head = listener_buf;
rd_head = buf_head;
wr_head = buf_head;
}
示例6: i2cObjectInit
/**
* @brief Initializes the standard part of a @p I2CDriver structure.
*
* @param[out] i2cp pointer to the @p I2CDriver object
*
* @init
*/
void i2cObjectInit(I2CDriver *i2cp) {
i2cp->id_state = I2C_STOP;
i2cp->id_config = NULL;
i2cp->rxbuff_p = NULL;
i2cp->txbuff_p = NULL;
i2cp->rxbuf = NULL;
i2cp->txbuf = NULL;
i2cp->id_slave_config = NULL;
#if I2C_USE_WAIT
i2cp->id_thread = NULL;
#endif /* I2C_USE_WAIT */
#if I2C_USE_MUTUAL_EXCLUSION
#if CH_USE_MUTEXES
chMtxInit(&i2cp->id_mutex);
#else
chSemInit(&i2cp->id_semaphore, 1);
#endif /* CH_USE_MUTEXES */
#endif /* I2C_USE_MUTUAL_EXCLUSION */
#if defined(I2C_DRIVER_EXT_INIT_HOOK)
I2C_DRIVER_EXT_INIT_HOOK(i2cp);
#endif
}
示例7: chIQInit
/**
* @brief Initializes an input queue.
* @details A Semaphore is internally initialized and works as a counter of
* the bytes contained in the queue.
* @note The callback is invoked from within the S-Locked system state,
* see @ref system_states.
*
* @param[out] iqp pointer to an @p InputQueue structure
* @param[in] bp pointer to a memory area allocated as queue buffer
* @param[in] size size of the queue buffer
* @param[in] infy pointer to a callback function that is invoked when
* data is read from the queue. The value can be @p NULL.
*
* @init
*/
void chIQInit(InputQueue *iqp, uint8_t *bp, size_t size, qnotify_t infy) {
iqp->q_buffer = iqp->q_rdptr = iqp->q_wrptr = bp;
iqp->q_top = bp + size;
iqp->q_notify = infy;
chSemInit(&iqp->q_sem, 0);
}
示例8: chOQInit
/**
* @brief Initializes an output queue.
* @details A Semaphore is internally initialized and works as a counter of
* the free bytes in the queue.
* @note The callback is invoked from within the S-Locked system state,
* see @ref system_states.
*
* @param[out] oqp pointer to an @p OutputQueue structure
* @param[in] bp pointer to a memory area allocated as queue buffer
* @param[in] size size of the queue buffer
* @param[in] onfy pointer to a callback function that is invoked when
* data is written to the queue. The value can be @p NULL.
*
* @init
*/
void chOQInit(OutputQueue *oqp, uint8_t *bp, size_t size, qnotify_t onfy) {
oqp->q_buffer = oqp->q_rdptr = oqp->q_wrptr = bp;
oqp->q_top = bp + size;
oqp->q_notify = onfy;
chSemInit(&oqp->q_sem, (cnt_t)size);
}
示例9: gdispInit
bool_t gdispInit(void) {
bool_t res;
unsigned i;
/* Mark all the Messages as free */
for(i=0; i < GDISP_QUEUE_SIZE; i++)
gdispMsgs[i].action = GDISP_LLD_MSG_NOP;
/* Initialise our Mailbox, Mutex's and Counting Semaphore.
* A Mutex is required as well as the Mailbox and Thread because some calls have to be synchronous.
* Synchronous calls get handled by the calling thread, asynchronous by our worker thread.
*/
chMBInit(&gdispMailbox, gdispMailboxQueue, sizeof(gdispMailboxQueue)/sizeof(gdispMailboxQueue[0]));
chMtxInit(&gdispMutex);
chMtxInit(&gdispMsgsMutex);
chSemInit(&gdispMsgsSem, GDISP_QUEUE_SIZE);
lldThread = chThdCreateStatic(waGDISPThread, sizeof(waGDISPThread), NORMALPRIO, GDISPThreadHandler, NULL);
/* Initialise driver - synchronous */
chMtxLock(&gdispMutex);
res = gdisp_lld_init();
chMtxUnlock();
return res;
}
示例10: _heap_init
void _heap_init(void) {
#if CH_USE_MUTEXES
chMtxInit(&hmtx);
#else
chSemInit(&hsem, 1);
#endif
}
示例11: osCreateSemaphore
bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count)
{
//Initialize the semaphore object
chSemInit(semaphore, count);
//Semaphore successfully created
return TRUE;
}
示例12: adcObjectInit
/**
* @brief Initializes the standard part of a @p ADCDriver structure.
*
* @param[in] adcp pointer to the @p ADCDriver object
*/
void adcObjectInit(ADCDriver *adcp) {
adcp->ad_state = ADC_STOP;
adcp->ad_config = NULL;
adcp->ad_callback = NULL;
adcp->ad_samples = NULL;
adcp->ad_depth = 0;
adcp->ad_grpp = NULL;
chSemInit(&adcp->ad_sem, 0);
}
示例13: vexAudioPlaySound
void
vexAudioPlaySound( int freq, int amplitude, int timems )
{
static int current_amplitude = DEFAULT_AMPLITUDE;
int f1, f2;
// Not available on the Olimex eval card
#if defined (STM32F10X_HD)
// init first time
if( vslThread == NULL )
{
VSL_Init();
// init counting semaphore with a value of 0
chSemInit( &vslSem, 0 );
vslThread = chThdCreateFromHeap(NULL, AUDIO_WA_SIZE, NORMALPRIO, vexAudioTask, (void *)NULL );
}
// try and stop pops
// a frequency of 0 means silence
if( freq == 0 )
{
freq = 1000;
amplitude = 0;
}
// create waveform
if( amplitude != current_amplitude )
{
VSL_CreateSineWave( amplitude );
current_amplitude = amplitude;
}
// limit range of frequencies 200Hz to 10KHz
if( freq < 200 ) freq = 200;
if( freq > 10000 ) freq = 10000;
// calculate prescale and period for the timer
VSL_Factorize( 72000000L / (32 * freq), &f1, &f2 );
// ReInit timer
VSL_InitTimer(f1, f2);
// Enable DMA for the DAC
DAC->CR |= (DAC_CR_EN1 << DAC_Channel_1);
/* TIM7 enable counter */
TIM7->CR1 |= TIM_CR1_CEN;
// stop after time
VSL_Counter = timems;
// this will wake audio thread if necessary
chSemReset(&vslSem, 0);
#endif
}
示例14: chSetup
//-----------------------------------------------------------------------------------------------------------------------
void chSetup() {
// initialize the counting semaphore to zero i.e.TAKEN
chSemInit(&sem, 0);
// start high priority thread
chThdCreateStatic(waThread1, sizeof(waThread1),
NORMALPRIO+2, Thread1, NULL);
// start lower priority thread
chThdCreateStatic(waThread2, sizeof(waThread2),
NORMALPRIO+1, Thread2, NULL);
}
示例15: gfxSemInit
void gfxSemInit(gfxSem *psem, semcount_t val, semcount_t limit)
{
if (val > limit)
val = limit;
psem->limit = limit;
#if CH_KERNEL_MAJOR == 2
chSemInit(&psem->sem, val);
#elif CH_KERNEL_MAJOR == 3
chSemObjectInit(&psem->sem, val);
#endif
}