本文整理汇总了C++中osSemaphoreCreate函数的典型用法代码示例。如果您正苦于以下问题:C++ osSemaphoreCreate函数的具体用法?C++ osSemaphoreCreate怎么用?C++ osSemaphoreCreate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了osSemaphoreCreate函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。
示例1: tasks_input_init
void tasks_input_init()
{
/* Mutexes */
osMutexDef(mutex_menu);
mutex_menuHandle = osMutexCreate(osMutex(mutex_menu));
/* Semaphores */
/* sem_input_touch_pen */
osSemaphoreDef(sem_input_touch_pen);
sem_input_touch_penHandle = osSemaphoreCreate(osSemaphore(sem_input_touch_pen), 1);
/* sem_input_button_short_press */
osSemaphoreDef(sem_input_button_short_press);
sem_input_button_short_pressHandle = osSemaphoreCreate(osSemaphore(sem_input_button_short_press), 1);
/* sem_input_button_long_press */
osSemaphoreDef(sem_input_button_long_press);
sem_input_button_long_pressHandle = osSemaphoreCreate(osSemaphore(sem_input_button_long_press), 1);
/* Queues */
/* queue_input_click */
osMailQDef(queue_input_click, 16, click_t);
queue_input_clickHandle = osMailCreate(osMailQ(queue_input_click), NULL);
/* queue_input_menu */
osMailQDef(queue_input_menu, 4, menu_t *);
queue_input_menuHandle = osMailCreate(osMailQ(queue_input_menu), NULL);
}
示例2: myCANinit
void myCANinit()
{
can0rx_semaphore_id = osSemaphoreCreate(osSemaphore(can0rx_semaphore), 1);
memset(&can0rx,0,sizeof(my_CAN_BUF));
can1rx_semaphore_id = osSemaphoreCreate(osSemaphore(can1rx_semaphore), 1);
memset(&can1rx,0,sizeof(my_CAN_BUF));
}
示例3: vMBM_Event_Init
void vMBM_Event_Init( void )
{
static osSemaphoreDef ( semaphore_Send );
static osSemaphoreDef ( semaphore_Receive );
semaphore_TX = osSemaphoreCreate(osSemaphore(semaphore_Send), 0 );
semaphore_RX = osSemaphoreCreate(osSemaphore(semaphore_Receive), 0 );
assert(( NULL != semaphore_TX ) && ( NULL != semaphore_RX ));
}
示例4: main
/*----------------------------------------------------------------------------
* Main: Initialize and start RTX Kernel
*---------------------------------------------------------------------------*/
int main (void)
{
osKernelInitialize ();
LED_Initialize();
Turnstile = osSemaphoreCreate(osSemaphore(Turnstile), 0); // 0 tokens
Turnstile2 = osSemaphoreCreate(osSemaphore(Turnstile2), 1); // 1 token
Mutex = osSemaphoreCreate(osSemaphore(Mutex), 1);
tsk2_0 = osThreadCreate(osThread(threadBaseCode),(void *) 1U);
tsk2_1 = osThreadCreate(osThread(threadBaseCode),(void *) 2U);
tsk2_2 = osThreadCreate(osThread(threadBaseCode),(void *) 3U);
tsk2_3 = osThreadCreate(osThread(threadBaseCode),(void *) 4U);
tsk2_4 = osThreadCreate(osThread(threadBaseCode),(void *) 5U);
osKernelStart ();
}
示例5: SensorsTaskOSInit
void SensorsTaskOSInit(void)
{
osSemaphoreDef(i2cTransactSem);
i2cSem = osSemaphoreCreate(osSemaphore(i2cTransactSem), 1);
ALBI2CHandle.Instance = ALB_I2C;
ALBI2CHandle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
ALBI2CHandle.Init.Timing = I2C_TIMING_100KHZ;
ALBI2CHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED;
ALBI2CHandle.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
ALBI2CHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED;
ALBI2CHandle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED;
ALBI2CHandle.Init.OwnAddress1 = 0x00;
ALBI2CHandle.Init.OwnAddress2 = 0x00;
assert_param(HAL_I2C_Init(&ALBI2CHandle) == HAL_OK);
SLBI2CHandle.Instance = SLB_I2C;
SLBI2CHandle.Init.AddressingMode = I2C_ADDRESSINGMODE_7BIT;
SLBI2CHandle.Init.Timing = I2C_TIMING_100KHZ;
SLBI2CHandle.Init.DualAddressMode = I2C_DUALADDRESS_DISABLED;
SLBI2CHandle.Init.OwnAddress2Masks = I2C_OA2_NOMASK;
SLBI2CHandle.Init.GeneralCallMode = I2C_GENERALCALL_DISABLED;
SLBI2CHandle.Init.NoStretchMode = I2C_NOSTRETCH_DISABLED;
SLBI2CHandle.Init.OwnAddress1 = 0x00;
SLBI2CHandle.Init.OwnAddress2 = 0x00;
assert_param(HAL_I2C_Init(&SLBI2CHandle) == HAL_OK);
}
示例6: main
int main(void)
{
/* Reset of all peripherals, Initializes the Flash interface and the Systick. */
HAL_Init();
/* Initialize all configured peripherals */
MX_GPIO_Init();
/* Create the threads and semaphore */
osThreadDef(defaultTask, StartDefaultTask, osPriorityNormal, 0, 128);
defaultTaskHandle = osThreadCreate(osThread(defaultTask), NULL);
osThreadDef(blinkTask, BlinkTask, osPriorityNormal, 0, 128);
blinkTaskHandle = osThreadCreate(osThread(blinkTask), NULL);
osSemaphoreDef(sem);
semHandle = osSemaphoreCreate(osSemaphore(sem), 1);
osSemaphoreWait(semHandle, osWaitForever);
/* Start scheduler */
osKernelStart();
/* We should never get here as control is now taken by the scheduler */
/* Infinite loop */
while (1);
}
示例7: init_mySemaphore
// Semaphore
static void init_mySemaphore(struct mySemaphore *sem, int32_t count) {
#ifdef CMSIS_OS_RTX
memset(sem->_semaphore_data, 0, sizeof(sem->_semaphore_data));
sem->_osSemaphoreDef.semaphore = sem->_semaphore_data;
#endif
sem->_osSemaphoreId = osSemaphoreCreate(&sem->_osSemaphoreDef, count);
}
示例8: myQEPinit
void myQEPinit()
{
status_t Status;
depth_semaphore_id = osSemaphoreCreate(osSemaphore(depth_semaphore), 1);
speed_semaphore_id = osSemaphoreCreate(osSemaphore(speed_semaphore), 1);
Status=POSQE001_SetPeriodCounterPM(&POSQE001_Handle0, 32);
Status=POSQE001_SetPeriodCounterCM(&POSQE001_Handle0, 32/2);
if(Status!=DAVEApp_SUCCESS) depth=100;
Status=POSQE001_EnableEvent((POSQE001_HandleType*)&POSQE001_Handle0,POSQE001_POSITION_COUNTER,POSQE001_CCU_UP_COMPARE_MATCH);
if(Status!=DAVEApp_SUCCESS) depth+=50;
Status=POSQE001_EnableEvent((POSQE001_HandleType*)&POSQE001_Handle0,POSQE001_POSITION_COUNTER,POSQE001_CCU_DOWN_COMPARE_MATCH);
Status=POSQE001_EnableEvent((POSQE001_HandleType*)&POSQE001_Handle0,POSQE001_VELOCITY_TIMER0,POSQE001_CCU_PERIOD_MATCH);
if(Status!=DAVEApp_SUCCESS) depth+=25;
//POSQE001_Start(&POSQE001_Handle0);
}
示例9: memset
Semaphore::Semaphore(int32_t count) {
#ifdef CMSIS_OS_RTX
memset(_semaphore_data, 0, sizeof(_semaphore_data));
_osSemaphoreDef.semaphore = _semaphore_data;
#endif
_osSemaphoreId = osSemaphoreCreate(&_osSemaphoreDef, count);
}
示例10: main
/**
* @brief Main program
* @param None
* @retval None
*/
int main(void)
{
/* STM32F4xx HAL library initialization:
- Configure the Flash prefetch, instruction and Data caches
- Configure the Systick to generate an interrupt each 1 msec
- Set NVIC Group Priority to 4
- Global MSP (MCU Support Package) initialization
*/
HAL_Init();
/* Configure the system clock to 168 MHz */
SystemClock_Config();
/* Configure LED1, LED2, LED3 and LED4 */
BSP_LED_Init(LED1);
/* Configure Key Button */
BSP_PB_Init(BUTTON_KEY, BUTTON_MODE_EXTI);
/* Define used semaphore */
osSemaphoreDef(SEM);
/* Create the semaphore used by the two threads. */
osSemaphore = osSemaphoreCreate(osSemaphore(SEM) , 1);
/* Create the Thread that toggle LED1 */
osThreadDef(SEM_Thread, SemaphoreTest, osPriorityNormal, 0, semtstSTACK_SIZE);
osThreadCreate(osThread(SEM_Thread), (void *) osSemaphore);
/* Start scheduler */
osKernelStart();
/* We should never get here as control is now taken by the scheduler */
for(;;);
}
示例11: osCreateEvent
bool_t osCreateEvent(OsEvent *event)
{
osSemaphoreDef_t semaphoreDef;
#if defined(osCMSIS_RTX)
semaphoreDef.semaphore = event->cb;
#else
semaphoreDef.dummy = 0;
#endif
//Create a binary semaphore object
event->id = osSemaphoreCreate(&semaphoreDef, 1);
//Check whether the returned semaphore ID is valid
if(event->id != NULL)
{
//Force the specified event to the nonsignaled state
osSemaphoreWait(event->id, 0);
//Event successfully created
return TRUE;
}
else
{
//Failed to create event object
return FALSE;
}
}
示例12: main
int main (void) {
two_slots = osSemaphoreCreate(osSemaphore(two_slots), 2);
osThreadCreate(osThread(t2), NULL);
osThreadCreate(osThread(t3), NULL);
test_thread((void *)"Th 1");
}
示例13: Netif_Config
/**
* @brief Initializes the lwIP stack
* @param None
* @retval None
*/
static void Netif_Config(void)
{
struct ip_addr ipaddr;
struct ip_addr netmask;
struct ip_addr gw;
/* IP address setting */
IP4_ADDR(&ipaddr, IP_ADDR0, IP_ADDR1, IP_ADDR2, IP_ADDR3);
IP4_ADDR(&netmask, NETMASK_ADDR0, NETMASK_ADDR1 , NETMASK_ADDR2, NETMASK_ADDR3);
IP4_ADDR(&gw, GW_ADDR0, GW_ADDR1, GW_ADDR2, GW_ADDR3);
/* - netif_add(struct netif *netif, struct ip_addr *ipaddr,
struct ip_addr *netmask, struct ip_addr *gw,
void *state, err_t (* init)(struct netif *netif),
err_t (* input)(struct pbuf *p, struct netif *netif))
Adds your network interface to the netif_list. Allocate a struct
netif and pass a pointer to this structure as the first argument.
Give pointers to cleared ip_addr structures when using DHCP,
or fill them with sane numbers otherwise. The state pointer may be NULL.
The init function pointer must point to a initialization function for
your ethernet netif interface. The following code illustrates it's use.*/
netif_add(&gnetif, &ipaddr, &netmask, &gw, NULL, ðernetif_init, &tcpip_input);
/* Registers the default network interface. */
netif_set_default(&gnetif);
if (netif_is_link_up(&gnetif))
{
/* When the netif is fully configured this function must be called.*/
netif_set_up(&gnetif);
}
else
{
/* When the netif link is down this function must be called */
netif_set_down(&gnetif);
}
/* Set the link callback function, this function is called on change of link status*/
netif_set_link_callback(&gnetif, ethernetif_update_config);
/* create a binary semaphore used for informing ethernetif of frame reception */
osSemaphoreDef(Netif_SEM);
Netif_LinkSemaphore = osSemaphoreCreate(osSemaphore(Netif_SEM) , 1 );
link_arg.netif = &gnetif;
link_arg.semaphore = Netif_LinkSemaphore;
/* Create the Ethernet link handler thread */
#if defined(__GNUC__)
osThreadDef(LinkThr, ethernetif_set_link, osPriorityNormal, 0, configMINIMAL_STACK_SIZE * 5);
#else
osThreadDef(LinkThr, ethernetif_set_link, osPriorityNormal, 0, configMINIMAL_STACK_SIZE * 2);
#endif
osThreadCreate (osThread(LinkThr), &link_arg);
}
示例14: lcd_thread_create
/**
* @brief Create a new thread for LCD
* @param None
* @retval osThreadId the created tread id
*/
osThreadId lcd_thread_create(void)
{
lcd_display_init();
lcd_timer_init();
lcd_semaphore = osSemaphoreCreate(osSemaphore(lcd_semaphore), 1);
//create temperature thread
lcd_thread_id = osThreadCreate(osThread(lcd_thread), NULL);
return lcd_thread_id;
}
开发者ID:headyin,项目名称:Wireless-Board-Orientation-Control-System-ARM-Micro-Processor-Lab-,代码行数:14,代码来源:lcd16.c
示例15: main
/*----------------------------------------------------------------------------
* Main:
*---------------------------------------------------------------------------*/
int main (void) { /* program execution starts here */
semaphore = osSemaphoreCreate(osSemaphore(semaphore), 1);
tid_thread1 = osThreadCreate(osThread(thread1), NULL);
tid_thread2 = osThreadCreate(osThread(thread2), NULL);
osDelay(osWaitForever);
for (;;);
}