本文整理汇总了C++中OSSemCreate函数的典型用法代码示例。如果您正苦于以下问题:C++ OSSemCreate函数的具体用法?C++ OSSemCreate怎么用?C++ OSSemCreate使用的例子?那么, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了OSSemCreate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: BSP_Init
void BSP_Init (void)
{
// Interrupt initialization
BSP_IntInit();
// Initailize system services, clocks, etc.
BSP_SysInit();
// RGB LED initialization
BSP_LED_Init();
// Push Button initialization
BSP_SWITCH_Init();
// PIR sensor initialization
BSP_PIR_Init();
// UART initialization
BSP_UART_Init();
// Semaphore Create
sharedDataSem = OSSemCreate(1);
// semaphore Create
sharedDataSemUart = OSSemCreate(1);
// Mailbox Create
MailBox1 = OSMboxCreate(&global_pir_val);
}
示例2: main
/*
*********************************************************************************************************
* MAIN
*********************************************************************************************************
*/
int main (void)
{
OSInit(); /* Initialize uC/OS-II */
OSTaskCreateExt(Task_Start,
(void *)0,
&TASK_START_STK[127],
TASK_START_PRIO,
TASK_START_ID,
&TASK_START_STK[0],
300,
(void *)0,//&TaskUserData[TASK_4_ID]
0);
RecPackedFlag= OSSemCreate(0);
RecBufOverFlowFlag= OSSemCreate(0);
RecTcpPackedFlag= OSSemCreate(0);
RecPingPackedFlag= OSSemCreate(0);
SendFlag= OSSemCreate(1);
RecIcmpQFlag= OSQCreate(&RecIcmpQ[0],Q_Max_Size);
RecTcpQFlag= OSQCreate(&RecTcpQ[0],Q_Max_Size);
RecUdpQFlag= OSQCreate(&RecUdpQ[0],Q_Max_Size);
OSStart(); /* Start multitasking */
}
示例3: Task_START
void Task_START(void *p_arg)
{
(void)p_arg; //'p_arg'没有用到,防止编译器警告
adc_MBOX = OSMboxCreate((void *)0);
key_SEM = OSSemCreate(0);
keyDis_SEM = OSSemCreate(0);
A8_SEM = OSSemCreate(0);
OSTaskCreate(Task_LED,(void *)0,
&led_task_stk[LED_TASK_STK_SIZE-1],LED_TASK_PRIO);
OSTaskCreate(Task_USART1,(void *)0,
&usart1_task_stk[USART1_TASK_STK_SIZE-1],USART1_TASK_PRIO);
OSTaskCreate(Task_LEDDIS,(void *)0,
&ledDis_task_stk[LEDDIS_TASK_STK_SIZE-1],LEDDIS_TASK_PRIO);
OSTaskCreate(Task_ADC1,(void *)0,
&adc1_task_stk[ADC1_TASK_STK_SIZE-1],ADC1_TASK_PRIO);
OSTaskCreate(Task_EXTI,(void *)0,
&exti_task_stk[EXTI_TASK_STK_SIZE-1],EXTI_TASK_PRIO);
OSTaskCreate(Task_CALCULATE,(void *)0,
&calculate_task_stk[CALCULATE_TASK_STK_SIZE-1],CALCULATE_TASK_PRIO);
OSTaskCreate(Task_A8CONNECT,(void *)0,
&A8connect_task_stk[A8CONNECT_TASK_STK_SIZE-1],A8CONNECT_TASK_PRIO);
while(1)
{
OSTimeDlyHMSM(0,0,0,10);
}
}
示例4: App_EventCreate
/*
*********************************************************************************************************
* App_EventCreate
*
* Description : Creates the application events.
*
* Argument(s) : none.
*
* Return(s) : none.
*
* Caller(s) : App_TaskStart().
*
* Note(s) : none.
*********************************************************************************************************
*/
static void App_EventCreate (void)
{
g_key_para.sem = OSSemCreate(0);
g_sem_end = OSSemCreate(0);
g_sem_pc = OSSemCreate(0);
g_sem_mems = OSSemCreate(0);
}
示例5: AnalogCaptureTask
/*
*********************************************************************************************************
* AnalogCaptureTask TASK
*
*********************************************************************************************************
*/
void AnalogCaptureTask (void *p_arg)
{
(void)p_arg; /* Prevent compiler warning */
OS_ERR err = 0;
CPU_INT32U uCount = 0;
static ADC_CONTROL_BLOCK_t strAdcControlBlock;
InitAdcControlBlock(&strAdcControlBlock); /* Initialize ADC control structures */
InitADCPort(); /* Initialize the ADC */
OSSemCreate(&semAdcIntSignal,"ADC EOC Int signal",0,&err);
OSSemCreate(&semADC_Complete,"ADC completed semaphore",0,&err);
OSMutexCreate(&mutADC,"ADC value",&err);
OSMutexCreate(&mutTMR3,"PWM in",&err);
while (TRUE) {
OSTimeDlyHMSM(0, 0, 0, 50, /* Performs conversions every 100 ms. */
OS_OPT_TIME_HMSM_STRICT,
&err);
ADC1->CR2 |= 1<<21; /* Trigger the conversion */
OSSemPend(&semAdcIntSignal, /* Wait for the end of conversion */
0, /* (This semaphore is posted by the ADC1_ISR) */
OS_OPT_PEND_BLOCKING,
(CPU_TS*)NULL,&err);
ReportAdcSample(ADC_CHANNEL_1, &strAdcControlBlock);
if (++uCount > 5)
{
BSP_LED_Toggle(2); /* Toggle the BSP Led #3 */
uCount = 0;
}
}
}
示例6: OSTmr_Init
void OSTmr_Init( void )
{
#if OS_EVENT_NAME_SIZE > 10
INT8U err;
#endif
INT16U i;
OS_TMR *ptmr1;
OS_TMR *ptmr2;
OS_MemClr( ( INT8U * ) & OSTmrTbl[0], sizeof( OSTmrTbl ) ); /* Clear all the TMRs */
OS_MemClr( ( INT8U * ) & OSTmrWheelTbl[0], sizeof( OSTmrWheelTbl ) ); /* Clear the timer wheel */
ptmr1 = &OSTmrTbl[0];
ptmr2 = &OSTmrTbl[1];
for ( i = 0; i < ( OS_TMR_CFG_MAX - 1 ); i++ )
{ /* Init. list of free TMRs */
ptmr1->OSTmrType = OS_TMR_TYPE;
ptmr1->OSTmrState = OS_TMR_STATE_UNUSED; /* Indicate that timer is inactive */
ptmr1->OSTmrNext = ( void * ) ptmr2; /* Link to next timer */
#if OS_TMR_CFG_NAME_SIZE > 1
ptmr1->OSTmrName[0] = '?'; /* Unknown name */
ptmr1->OSTmrName[1] = OS_ASCII_NUL;
#endif
ptmr1++;
ptmr2++;
}
ptmr1->OSTmrType = OS_TMR_TYPE;
ptmr1->OSTmrState = OS_TMR_STATE_UNUSED; /* Indicate that timer is inactive */
ptmr1->OSTmrNext = ( void * ) 0; /* Last OS_TMR */
#if OS_TMR_CFG_NAME_SIZE > 1
ptmr1->OSTmrName[0] = '?'; /* Unknown name */
ptmr1->OSTmrName[1] = OS_ASCII_NUL;
#endif
OSTmrTime = 0;
OSTmrUsed = 0;
OSTmrFree = OS_TMR_CFG_MAX;
OSTmrFreeList = &OSTmrTbl[0];
OSTmrSem = OSSemCreate( 1 );
OSTmrSemSignal = OSSemCreate( 0 );
#if OS_EVENT_NAME_SIZE > 18
OSEventNameSet( OSTmrSem, ( INT8U * ) "uC/OS-II TmrLock", &err ); /* Assign names to semaphores */
#else
#if OS_EVENT_NAME_SIZE > 10
OSEventNameSet( OSTmrSem, ( INT8U * ) "OS-TmrLock", &err );
#endif
#endif
#if OS_EVENT_NAME_SIZE > 18
OSEventNameSet( OSTmrSemSignal, ( INT8U * ) "uC/OS-II TmrSignal", &err );
#else
#if OS_EVENT_NAME_SIZE > 10
OSEventNameSet( OSTmrSemSignal, ( INT8U * ) "OS-TmrSig", &err );
#endif
#endif
OSTmr_InitTask( );
}
示例7: USART_File_Init
void USART_File_Init()
{
file_usart1.semaphore = OSSemCreate(0);
file_usart2.semaphore = OSSemCreate(0);
file_usart3.semaphore = OSSemCreate(0);
#ifdef STM32F10X_CL
file_uart4.semaphore = OSSemCreate(0);
file_uart5.semaphore = OSSemCreate(0);
#endif
}
示例8: alt_iniche_init
void alt_iniche_init(void)
{
extern OS_EVENT * mheap_sem_ptr;
extern void *net_task_sem_ptr;
/* initialize the npalloc() heap semaphore */
mheap_sem_ptr = OSSemCreate(1);
if (!mheap_sem_ptr)
panic("mheap_sem_ptr create err");
/* get the uCOS semaphore used for LOCK_NET_RESOURCE(NET_RESID) */
net_task_sem_ptr = (void*)OSSemCreate(1);
if (!net_task_sem_ptr)
panic("net_task_sem_ptr create err");
rcvdq_sem_ptr = OSSemCreate(0);
if (!rcvdq_sem_ptr)
panic("rcvdq_sem_ptr create err");
#ifdef OS_PREEMPTIVE
ping_sem_ptr = OSSemCreate(0); /* PING app */
if (!ping_sem_ptr)
panic("ping_sem_ptr create err");
ftpc_sem_ptr = OSSemCreate(0); /* FTP Client app */
if (!ftpc_sem_ptr)
panic("ftpc_sem_ptr create err");
#endif /* OS_PREEMPTIVE */
#ifndef TCPWAKE_RTOS
/*
* clear global_TCPwakeup_set
*/
{
int i;
for (i = 0; i < GLOBWAKE_SZ; i++)
{
global_TCPwakeup_set[i].ctick = 0;
}
global_TCPwakeup_setIndx = 0;
}
{
INT8U mute_err;
global_wakeup_Mutex = OSMutexCreate(WAKEUP_MUTEX_PRIO, &mute_err);
if (mute_err != OS_NO_ERR)
{
dprintf("*** uCOS init, can't create global_wakeup_Mutex = %d\n", mute_err);
dtrap();
}
}
#endif /* TCPWAKE_RTOS */
}
示例9: GUI_X_InitOS
/* Init OS */
void GUI_X_InitOS(void)
{
/* Create Mutex lock */
g_gui_mutx = OSSemCreate (1);
//configASSERT (xQueueMutex != NULL);
/* Queue Semaphore */
g_gui_sem = OSSemCreate (0);
//vSemaphoreCreateBinary( xSemaTxDone );
//configASSERT ( xSemaTxDone != NULL );
}
示例10: C491_Init
/// -----------------------------------------------------------------------------------------------------
/// @brief 491 communication initialization function.
/// must be called before calling any other of the user accessible functions.
/// 模块初始化
/// @param None
/// @retval : None
/// -----------------------------------------------------------------------------------------------------
void C491_Init (void)
{
C491_R_N = 0; /// 缓冲区数据初始化
C491_R_BufInIx = 0;
C491_R_BufOutIx = 0;
C491_R_SemPtr = OSSemCreate(0); /// 初始化接收使用的信号量
C491_T_N = 0; /// 缓冲区数据初始化
C491_T_BufOutIx = 0;
C491_T_SemPtr = OSSemCreate(1); /// 初始化发送使用的信号量
BSP_491_Init(); /// 初始化IO及中断
}
示例11: main
int main (void)
{
OS_ERR err;
#if (CPU_CFG_NAME_EN == DEF_ENABLED)
CPU_ERR cpu_err;
#endif
hardware_init();
GPIO_DRV_Init(switchPins, ledPins);
#if (CPU_CFG_NAME_EN == DEF_ENABLED)
CPU_NameSet((CPU_CHAR *)"MK64FN1M0VMD12",
(CPU_ERR *)&cpu_err);
#endif
OSA_Init(); /* Init uC/OS-III. */
OSSemCreate(&MySem1, /* Create Semaphore 1 */
"sem 1",
0,
&err);
OSSemCreate(&MySem2, /* Create Semaphore 2 */
"sem 2",
0,
&err);
INT_SYS_InstallHandler(PORTC_IRQn, SW1_Intr_Handler); // associate ISR with sw1 intr source
INT_SYS_InstallHandler(PORTA_IRQn, SW2_Intr_Handler); // associate ISR with sw2 intr source
OSTaskCreate(&AppTaskStartTCB, /* Create the start task */
"App Task Start",
AppTaskStart,
0u,
APP_CFG_TASK_START_PRIO,
&AppTaskStartStk[0u],
(APP_CFG_TASK_START_STK_SIZE / 10u),
APP_CFG_TASK_START_STK_SIZE,
0u,
0u,
0u,
(OS_OPT_TASK_STK_CHK | OS_OPT_TASK_STK_CLR | OS_OPT_TASK_SAVE_FP),
&err);
OSA_Start(); /* Start multitasking (i.e. give control to uC/OS-III). */
while (DEF_ON) { /* Should Never Get Here */
;
}
}
示例12: main
int main (void)
{
AvrInit(); /* Initialize the AVR UART and Timer */
OSInit();
RandomSem = OSSemCreate(1); /* Random number semaphore */
DispStrSem = OSSemCreate(1); /* Display string semaphore */
UartTxSem = OSSemCreate(254); /* Initialize Uart transmit buffer semaphore to 2 */
OSTaskCreate(TaskStart, (void *)0, (void *)&TaskStartStk[TASK_STK_SIZE - 1], 0);
RndNext = 1; /* set random generator seed to 1 */
OSStart(); /* Start multitasking */
return 0;
}
示例13: InitEvent
static INT32S InitEvent(void)
{
INT32S re = 0;
g_EventStatic = OSSemCreate(0);
g_EventDynamic = OSSemCreate(0);
//g_EventTran = OSQCreate(g_pTranEventArray, _MAX_TRAN_EVENT);
g_EventRTData = OSSemCreate(0);
//OSSemCreate(&g_EventStatic, (CPU_CHAR *)"g_EventStatic", 0, &err);
//OSSemCreate(&g_EventDynamic, (CPU_CHAR *)"g_EventDynamic", 0, &err);
//OSQCreate(&g_EventTran, (CPU_CHAR *)"g_EventTran", _MAX_TRAN_EVENT, &err);
//OSSemCreate(&g_EventRTData, (CPU_CHAR *)"g_EventRTData", 0, &err);
return re;
}
示例14: Main
void Main (void){
INT16U freq;
S3C_SysInit();
OSInit();
LCDInit();
LCDString(0x00," Bitman\n Spartan 117");
delay(10);
for(freq = 10;freq < 300;freq += 10){
S3C_SetPWMBuzzer(freq,freq/2);
delay(1);
}
LCDClear();
delay(8);
LCDString(0," Bitman Lab\n Log System.");
S3C_SetPWMBuzzer(650,10);
S3C_StartPWMBuzzer();
delay(3);
S3C_StopPWMBuzzer();
delay(1);
S3C_StartPWMBuzzer();
delay(3);
S3C_StopPWMBuzzer();
delay(10);
Sem_UART0Tx = OSSemCreate(1);
Sem_UART1Tx = OSSemCreate(1);
Mbox_UART0Rx = OSMboxCreate((void *)0);
Mbox_UART0Tx = OSMboxCreate((void *)0);
Mbox_LEDMAN = OSMboxCreate((void *)0);
Mbox_BEEPMAN = OSMboxCreate((void *)0);
Mbox_LCDMAN = OSMboxCreate((void *)0);
iOPcode = TYPE_DEFAULT;
OSTaskCreate(TaskStart,(void *)0,&Stk_TaskStart[99],10);
OSStart();
}
示例15: OSTmr_Init
void OSTmr_Init (void)
{
#if OS_EVENT_NAME_EN > 0u
INT8U err;
#endif
INT16U ix;
INT16U ix_next;
OS_TMR *ptmr1;
OS_TMR *ptmr2;
OS_MemClr((INT8U *)&OSTmrTbl[0], sizeof(OSTmrTbl)); /* Clear all the TMRs */
OS_MemClr((INT8U *)&OSTmrWheelTbl[0], sizeof(OSTmrWheelTbl)); /* Clear the timer wheel */
/* 创建空闲定时器控制块链表 */
for (ix = 0u; ix < (OS_TMR_CFG_MAX - 1u); ix++) { /* Init. list of free TMRs */
ix_next = ix + 1u;
ptmr1 = &OSTmrTbl[ix];
ptmr2 = &OSTmrTbl[ix_next];
ptmr1->OSTmrType = OS_TMR_TYPE;
ptmr1->OSTmrState = OS_TMR_STATE_UNUSED; /* Indicate that timer is inactive */
ptmr1->OSTmrNext = (void *)ptmr2; /* Link to next timer */
#if OS_TMR_CFG_NAME_EN > 0u
ptmr1->OSTmrName = (INT8U *)(void *)"?";
#endif
}
/* 创建链表尾 */
ptmr1 = &OSTmrTbl[ix];
ptmr1->OSTmrType = OS_TMR_TYPE;
ptmr1->OSTmrState = OS_TMR_STATE_UNUSED; /* Indicate that timer is inactive */
ptmr1->OSTmrNext = (void *)0; /* Last OS_TMR */
#if OS_TMR_CFG_NAME_EN > 0u
ptmr1->OSTmrName = (INT8U *)(void *)"?";
#endif
OSTmrTime = 0u;
OSTmrUsed = 0u;
OSTmrFree = OS_TMR_CFG_MAX;
/* 空闲定时器控制块链表头 */
OSTmrFreeList = &OSTmrTbl[0];
OSTmrSem = OSSemCreate(1u);
OSTmrSemSignal = OSSemCreate(0u);
#if OS_EVENT_NAME_EN > 0u /* Assign names to semaphores */
OSEventNameSet(OSTmrSem, (INT8U *)(void *)"uC/OS-II TmrLock", &err);
OSEventNameSet(OSTmrSemSignal, (INT8U *)(void *)"uC/OS-II TmrSignal", &err);
#endif
/* 创建定时器线程 */
OSTmr_InitTask();
}