本文整理汇总了C++中osSemaphoreCreate函数的典型用法代码示例。如果您正苦于以下问题:C++ osSemaphoreCreate函数的具体用法?C++ osSemaphoreCreate怎么用?C++ osSemaphoreCreate使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了osSemaphoreCreate函数的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的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);
}
开发者ID:outsidersdelaelectronica,项目名称:tiic-2015,代码行数:28,代码来源:tasks_input.c
示例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));
}
开发者ID:liudanghao,项目名称:DAVE4500,代码行数:8,代码来源:myCAN.c
示例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 ));
}
开发者ID:github188,项目名称:JSD-KB6120E_V2.x,代码行数:10,代码来源:MBM_Port.C
示例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 ();
}
开发者ID:buczio,项目名称:RTX_RTOS_THREAD_SYNCHRO,代码行数:18,代码来源:barrier_example.c
示例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);
}
开发者ID:project-reservoir,项目名称:project-dandelion,代码行数:30,代码来源:sensors.c
示例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);
}
开发者ID:samuelint,项目名称:FreeRTOS-STM32F4-Eclipse-Template,代码行数:27,代码来源:main.cpp
示例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);
}
开发者ID:AlienEngineer,项目名称:demo-cortex-m3,代码行数:8,代码来源:EthernetInterface_c.c
示例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);
}
开发者ID:liudanghao,项目名称:DAVE4500,代码行数:16,代码来源:myQEP.c
示例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);
}
开发者ID:23chrischen,项目名称:mbed,代码行数:7,代码来源:Semaphore.cpp
示例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(;;);
}
开发者ID:451506709,项目名称:automated_machine,代码行数:40,代码来源:main.c
示例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;
}
}
开发者ID:frankzzcn,项目名称:M2_SE_RTOS_Project,代码行数:27,代码来源:os_port_cmsis_rtos.c
示例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");
}
开发者ID:Archcady,项目名称:mbed-os,代码行数:8,代码来源:main.cpp
示例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);
}
开发者ID:ClintHaerinck,项目名称:STM32Cube_FW_F4,代码行数:63,代码来源:main.c
示例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 (;;);
}
开发者ID:AndreMiras,项目名称:EFM32-Library,代码行数:13,代码来源:Semaphore.c
示例16: low_level_init
/**
* @brief In this function, the hardware should be initialized.
* Called from ethernetif_init().
*
* @param netif the already initialized lwip network interface structure
* for this ethernetif
*/
static void low_level_init(struct netif *netif)
{
uint8_t macaddress[6]= { MAC_ADDR0, MAC_ADDR1, MAC_ADDR2, MAC_ADDR3, MAC_ADDR4, MAC_ADDR5 };
EthHandle.Instance = ETH;
EthHandle.Init.MACAddr = macaddress;
EthHandle.Init.AutoNegotiation = ETH_AUTONEGOTIATION_ENABLE;
EthHandle.Init.Speed = ETH_SPEED_100M;
EthHandle.Init.DuplexMode = ETH_MODE_FULLDUPLEX;
EthHandle.Init.MediaInterface = ETH_MEDIA_INTERFACE_RMII;
EthHandle.Init.RxMode = ETH_RXINTERRUPT_MODE;
EthHandle.Init.ChecksumMode = ETH_CHECKSUM_BY_HARDWARE;
EthHandle.Init.PhyAddress = LAN8742A_PHY_ADDRESS;
/* configure ethernet peripheral (GPIOs, clocks, MAC, DMA) */
if (HAL_ETH_Init(&EthHandle) == HAL_OK)
{
/* Set netif link flag */
netif->flags |= NETIF_FLAG_LINK_UP;
}
/* Initialize Tx Descriptors list: Chain Mode */
HAL_ETH_DMATxDescListInit(&EthHandle, DMATxDscrTab, &Tx_Buff[0][0], ETH_TXBUFNB);
/* Initialize Rx Descriptors list: Chain Mode */
HAL_ETH_DMARxDescListInit(&EthHandle, DMARxDscrTab, &Rx_Buff[0][0], ETH_RXBUFNB);
/* set netif MAC hardware address length */
netif->hwaddr_len = ETHARP_HWADDR_LEN;
/* set netif MAC hardware address */
netif->hwaddr[0] = MAC_ADDR0;
netif->hwaddr[1] = MAC_ADDR1;
netif->hwaddr[2] = MAC_ADDR2;
netif->hwaddr[3] = MAC_ADDR3;
netif->hwaddr[4] = MAC_ADDR4;
netif->hwaddr[5] = MAC_ADDR5;
/* set netif maximum transfer unit */
netif->mtu = 1500;
/* Accept broadcast address and ARP traffic */
netif->flags |= NETIF_FLAG_BROADCAST | NETIF_FLAG_ETHARP;
/* create a binary semaphore used for informing ethernetif of frame reception */
osSemaphoreDef(SEM);
s_xSemaphore = osSemaphoreCreate(osSemaphore(SEM) , 1 );
/* create the task that handles the ETH_MAC */
osThreadDef(EthIf, ethernetif_input, osPriorityRealtime, 0, INTERFACE_THREAD_STACK_SIZE);
osThreadCreate (osThread(EthIf), netif);
/* Enable MAC and DMA transmission and reception */
HAL_ETH_Start(&EthHandle);
}
开发者ID:acrepina,项目名称:STM32F7_serverWEB,代码行数:62,代码来源:ethernetif.c
示例17: sys_sem_new
/*---------------------------------------------------------------------------*
* Routine: sys_sem_new
*---------------------------------------------------------------------------*
* Description:
* Creates and returns a new semaphore. The "ucCount" argument specifies
* the initial state of the semaphore.
* NOTE: Currently this routine only creates counts of 1 or 0
* Inputs:
* sys_sem_t sem -- Handle of semaphore
* u8_t count -- Initial count of semaphore
* Outputs:
* err_t -- ERR_OK if semaphore created
*---------------------------------------------------------------------------*/
err_t sys_sem_new(sys_sem_t *sem, u8_t count) {
#ifdef CMSIS_OS_RTX
memset(sem->data, 0, sizeof(uint32_t)*2);
sem->def.semaphore = sem->data;
#endif
sem->id = osSemaphoreCreate(&sem->def, count);
if (sem->id == NULL)
error("sys_sem_new create error\n");
return ERR_OK;
}
开发者ID:brucetsao,项目名称:arduino-ameba,代码行数:24,代码来源:sys_arch.c
示例18: Init_Semaphore
int Init_Semaphore (void) {
sid_Thread_Semaphore = osSemaphoreCreate (osSemaphore(SampleSemaphore), 1);
if (!sid_Thread_Semaphore) {
; // Semaphore object not created, handle failure
}
tid_Thread_Semaphore = osThreadCreate (osThread(Thread_Semaphore), NULL);
if (!tid_Thread_Semaphore) return(-1);
return(0);
}
开发者ID:AdrK,项目名称:STM32F7_ADC_DMA_LCD,代码行数:12,代码来源:Semaphore.c
示例19: init_task
static void init_task(void *arg)
{
sem_def.name = "sem";
sem_def.sem = &sem;
pSem = osSemaphoreCreate (&sem_def, 2);
if (pSem == NULL) {
printf("osSemaphoreCreate failed\n");
} else {
printf("osSemaphoreCreate ok\n");
}
}
开发者ID:wosayttn,项目名称:aos,代码行数:12,代码来源:sem_test.c
示例20: ff_cre_syncobj
int ff_cre_syncobj ( /* TRUE:Function succeeded, FALSE:Could not create due to any error */
BYTE vol, /* Corresponding logical drive being processed */
_SYNC_t *sobj /* Pointer to return the created sync object */
)
{
int ret;
osSemaphoreDef(SEM);
*sobj = osSemaphoreCreate(osSemaphore(SEM), 1);
ret = (*sobj != NULL);
return ret;
}
开发者ID:Joe-Merten,项目名称:Stm32-Tools-Evaluation,代码行数:13,代码来源:syscall.c
注:本文中的osSemaphoreCreate函数示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论