本文整理汇总了C++中chSemInit函数的典型用法代码示例。如果您正苦于以下问题:C++ chSemInit函数的具体用法?C++ chSemInit怎么用?C++ chSemInit使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了chSemInit函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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
}
开发者ID:dienbk7x,项目名称:STM32-mini-demo,代码行数:13,代码来源:mac.c
示例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);
}
开发者ID:Amirelecom,项目名称:brush-v1,代码行数:18,代码来源:chmboxes.c
示例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
}
开发者ID:ksskarthik,项目名称:Falcon,代码行数:17,代码来源:mac.c
示例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 */
}
开发者ID:Dionysios,项目名称:STM_Library_2,代码行数:22,代码来源:can.c
示例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;
}
开发者ID:bnahill,项目名称:wireless_logger,代码行数:7,代码来源:datasource.cpp
示例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
}
开发者ID:mcu786,项目名称:Quad-Rotor,代码行数:33,代码来源:i2c.c
示例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);
}
开发者ID:dancollins,项目名称:Quad-Rotor,代码行数:22,代码来源:chqueues.c
示例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);
}
开发者ID:dancollins,项目名称:Quad-Rotor,代码行数:22,代码来源:chqueues.c
示例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;
}
开发者ID:niamster,项目名称:ChibiOS-GFX,代码行数:26,代码来源:gdisp.c
示例10: _heap_init
void _heap_init(void) {
#if CH_USE_MUTEXES
chMtxInit(&hmtx);
#else
chSemInit(&hsem, 1);
#endif
}
开发者ID:Aljabri722,项目名称:legoino,代码行数:8,代码来源:chheap.c
示例11: osCreateSemaphore
bool_t osCreateSemaphore(OsSemaphore *semaphore, uint_t count)
{
//Initialize the semaphore object
chSemInit(semaphore, count);
//Semaphore successfully created
return TRUE;
}
开发者ID:rkun,项目名称:COMP3334,代码行数:8,代码来源:os_port_chibios.c
示例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);
}
开发者ID:plumbum,项目名称:vt100like,代码行数:15,代码来源:adc.c
示例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
}
开发者ID:Highway-Man,项目名称:ConVEX-Installer,代码行数:55,代码来源:vexaudio.c
示例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);
}
开发者ID:DapengLan,项目名称:FreeRTOS_vs_ChibiOS,代码行数:13,代码来源:semaphore_time_ChibiOS.c
示例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
}
开发者ID:bigzed,项目名称:uGFX,代码行数:13,代码来源:gos_chibios.c
示例16: sys_sem_new
err_t sys_sem_new(sys_sem_t *sem, u8_t count) {
*sem = chHeapAlloc(NULL, sizeof(Semaphore));
if (*sem == 0) {
SYS_STATS_INC(sem.err);
return ERR_MEM;
}
else {
chSemInit(*sem, (cnt_t)count);
SYS_STATS_INC_USED(sem);
return ERR_OK;
}
}
开发者ID:0x00f,项目名称:ChibiOS,代码行数:13,代码来源:sys_arch.c
示例17: chHeapInit
/**
* @brief Initializes a memory heap from a static memory area.
* @pre Both the heap buffer base and the heap size must be aligned to
* the @p stkalign_t type size.
* @pre In order to use this function the option @p CH_USE_MALLOC_HEAP
* must be disabled.
*
* @param[out] heapp pointer to the memory heap descriptor to be initialized
* @param[in] buf heap buffer base
* @param[in] size heap size
*
* @init
*/
void chHeapInit(MemoryHeap *heapp, void *buf, size_t size) {
union heap_header *hp;
chDbgCheck(MEM_IS_ALIGNED(buf) && MEM_IS_ALIGNED(size), "chHeapInit");
heapp->h_provider = (memgetfunc_t)NULL;
heapp->h_free.h.u.next = hp = buf;
heapp->h_free.h.size = 0;
hp->h.u.next = NULL;
hp->h.size = size - sizeof(union heap_header);
#if CH_USE_MUTEXES || defined(__DOXYGEN__)
chMtxInit(&heapp->h_mtx);
#else
chSemInit(&heapp->h_sem, 1);
#endif
}
开发者ID:Aljabri722,项目名称:legoino,代码行数:29,代码来源:chheap.c
示例18: 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->state = I2C_STOP;
i2cp->config = NULL;
#if I2C_USE_MUTUAL_EXCLUSION
#if CH_USE_MUTEXES
chMtxInit(&i2cp->mutex);
#else
chSemInit(&i2cp->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
}
开发者ID:Ankhbayar,项目名称:mlab-chibios,代码行数:24,代码来源:i2c.c
示例19: dacObjectInit
/**
* @brief Initializes the standard part of a @p DACDriver structure.
*
* @param[out] dacp pointer to the @p DACDriver object
*
* @init
*/
void dacObjectInit(DACDriver *dacp) {
dacp->state = DAC_STOP;
dacp->config = NULL;
#if DAC_USE_WAIT
dacp->thread = NULL;
#endif /* DAC_USE_WAIT */
#if DAC_USE_MUTUAL_EXCLUSION
#if CH_USE_MUTEXES
chMtxInit(&dacp->mutex);
#else
chSemInit(&dacp->semaphore, 1);
#endif
#endif /* DAC_USE_MUTUAL_EXCLUSION */
#if defined(DAC_DRIVER_EXT_INIT_HOOK)
DAC_DRIVER_EXT_INIT_HOOK(dacp);
#endif
}
开发者ID:Rossano,项目名称:ez430_ChibiOS,代码行数:25,代码来源:dac.c
示例20: spiObjectInit
/**
* @brief Initializes the standard part of a @p SPIDriver structure.
*
* @param[out] spip pointer to the @p SPIDriver object
*
* @init
*/
void spiObjectInit(SPIDriver *spip) {
spip->state = SPI_STOP;
spip->config = NULL;
#if SPI_USE_WAIT
spip->thread = NULL;
#endif /* SPI_USE_WAIT */
#if SPI_USE_MUTUAL_EXCLUSION
#if CH_USE_MUTEXES
chMtxInit(&spip->mutex);
#else
chSemInit(&spip->semaphore, 1);
#endif
#endif /* SPI_USE_MUTUAL_EXCLUSION */
#if defined(SPI_DRIVER_EXT_INIT_HOOK)
SPI_DRIVER_EXT_INIT_HOOK(spip);
#endif
}
开发者ID:DuinoPilot,项目名称:STM32F4Discovery-ethernet-PHY-DP83848-demo-ChibiOS,代码行数:25,代码来源:spi.c
注:本文中的chSemInit函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论