当前位置: 首页>>代码示例>>C++>>正文


C++ osSemaphoreRelease函数代码示例

本文整理汇总了C++中osSemaphoreRelease函数的典型用法代码示例。如果您正苦于以下问题:C++ osSemaphoreRelease函数的具体用法?C++ osSemaphoreRelease怎么用?C++ osSemaphoreRelease使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了osSemaphoreRelease函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C++代码示例。

示例1: HAL_GPIO_EXTI_Callback

/**
  * @brief  EXTI line detection callbacks.
  * @param  GPIO_Pin: Specifies the pins connected EXTI line
  * @retval None
  */
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{  
  __IO JOYState_TypeDef JoyState = JOY_NONE;
  
  if(GPIO_Pin == MFX_IRQOUT_PIN)
  {
    /* The different functionalities of MFX (TS, Joystick, SD detection, etc. )  
    can be configured in exti mode to generate an IRQ on given events.
    The MFX IRQ_OUT pin is unique and common to all functionalities, so if several 
    functionalities are configured in exit mode, the MCU has to enquire MFX about  
    the IRQ source (see BSP_IO_ITGetStatus). Communication with Mfx is done by I2C. 
    Often the sw requires ISRs (irq service routines) to be quick while communication 
    with I2C can be considered relatively long (hundreds of usec depending on I2C clk). 
    In order to avoid to use "blocking I2C communication" on interrupt service routines 
    it's suggested (as alternative to this implementation) to use dedicated semaphore*/

    /* Get the Joystick State */
    JoyState = BSP_JOY_GetState();
    
    HID_DEMO_ProbeKey(JoyState); 
    
    switch(JoyState)
    {
    case JOY_LEFT:
      LCD_LOG_ScrollBack();
      break;
           
    case JOY_RIGHT:
      LCD_LOG_ScrollForward();
      break;          
      
    default:
      break;           
    }
    /* Clear joystick interrupt pending bits */
    BSP_IO_ITClear();
    osSemaphoreRelease(MenuEvent);
  }
}
开发者ID:pierreroth64,项目名称:STM32Cube_FW_F4,代码行数:44,代码来源:menu.c

示例2: Menu_Init

/**
  * @brief  Demo state machine.
  * @param  None
  * @retval None
  */
void Menu_Init(void)
{
  /* Create Menu Semaphore */
  osSemaphoreDef(osSem);

  MenuEvent = osSemaphoreCreate(osSemaphore(osSem), 1);

  /* Force menu to show Item 0 by default */
  osSemaphoreRelease(MenuEvent);

  /* Menu task */
#if defined(__GNUC__)
  osThreadDef(Menu_Thread, MSC_MenuThread, osPriorityHigh, 0, 8 * configMINIMAL_STACK_SIZE);
#else
  osThreadDef(Menu_Thread, MSC_MenuThread, osPriorityHigh, 0, 4 * configMINIMAL_STACK_SIZE);
#endif
  osThreadCreate(osThread(Menu_Thread), NULL);

  BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
  BSP_LCD_DisplayStringAtLine(15, (uint8_t *)"Use [Joystick Left/Right] to scroll up/down");
  BSP_LCD_DisplayStringAtLine(16, (uint8_t *)"Use [Joystick Up/Down] to scroll MSC menu");
}
开发者ID:Joe-Merten,项目名称:Stm32-Tools-Evaluation,代码行数:27,代码来源:menu.c

示例3: Thread_Semaphore

void Thread_Semaphore (void const *argument) {
  int32_t val;

  while (1) {
    ; // Insert thread code here...

    val = osSemaphoreWait (sid_Thread_Semaphore, 10);           // wait 10 mSec
    switch (val) {
      case osOK:
        ; // Use protected code here...
        osSemaphoreRelease (sid_Thread_Semaphore);              // Return a token back to a semaphore
        break;
      case osErrorResource:
        break;
      case osErrorParameter:
        break;
      default:
        break;
    }

    osThreadYield ();                                           // suspend thread
  }
}
开发者ID:AdrK,项目名称:STM32F7_ADC_DMA_LCD,代码行数:23,代码来源:Semaphore.c

示例4: threadBaseCode

void threadBaseCode  (void const *argument) 			
{
uint32_t LED_data;
	
	LED_data = (uint32_t) argument;
	while(1)					
	{
		
//---------------------------------------------------------------------------------							

		osSemaphoreWait(Mutex,0xffff);			 				//Allow one task at a time to access the first turnstile
		count = count+1;					 									// Increment count
		if( count == 5) 					 									//When last section of code reaches this point run his code
		{
			osSemaphoreWait (Turnstile2,0xffff);	 		//Lock the second turnstile
			osSemaphoreRelease(Turnstile);				 		//Unlock the first turnstile
		}			
		osSemaphoreRelease(Mutex);									//Allow other tasks to access the turnstile
		osSemaphoreWait(Turnstile,0xFFFF);					//Turnstile Gate			
		osSemaphoreRelease(Turnstile);

//----------------------------------- GATE -----------------------------------

		LED_On(LED_data);
		osDelay(100);				   							//Critical instructions 
		LED_Off(LED_data);
		osDelay((LED_data*100));	
//---------------------------------- GATE ------------------------------------

		osSemaphoreWait(Mutex,0xffff);			 				//Allow one task at a time to access the turnstile
		count = count - 1;
		if(count ==0)						 										//When last section of code reaches this point run his code
		{
			osSemaphoreWait(Turnstile,0xffff);		 		//Lock the second turnstile
			osSemaphoreRelease(Turnstile2);			 			//Unlock the first turnstile
		}
		osSemaphoreRelease(Mutex);					 				//Allow other tasks to access the turnstile
		osSemaphoreWait(Turnstile2,0xffff);		 			//Turnstile Gate
		osSemaphoreRelease(Turnstile2);

//------------------------------------------------------------------------------		

	}
}		
开发者ID:buczio,项目名称:RTX_RTOS_THREAD_SYNCHRO,代码行数:44,代码来源:barrier_example.c

示例5: SemaphoreThread1

/**
  * @brief  Semaphore Thread 1 function
  * @param  argument: shared semaphore
  * @retval None
  */
static void SemaphoreThread1(void const *argument)
{
  uint32_t count = 0;
  osSemaphoreId semaphore = (osSemaphoreId) argument;

  for (;;)
  {

    if (semaphore != NULL)
    {
      /* Try to obtain the semaphore */
      if (osSemaphoreWait(semaphore , 100) == osOK)
      {
        count = osKernelSysTick() + 5000;

        /* Toggle LED2 every 200 ms for 5 seconds */
        while (count >= osKernelSysTick())
        {
          /* Toggle LED3 */
          BSP_LED_Toggle(LED3);

          /* Delay 200 ms */
          osDelay(200);
        }

        /* Turn off LED3*/
        BSP_LED_Off(LED3);
        /* Release the semaphore */
        osSemaphoreRelease(semaphore);

        /* Suspend ourseleves to execute thread 2 (lower priority)  */
        osThreadSuspend(NULL);
      }
    }
  }
}
开发者ID:pengphei,项目名称:STM32Cube_L0,代码行数:41,代码来源:main.c

示例6: Menu_Init

/**
  * @brief  Demo state machine.
  * @param  None
  * @retval None
  */
void Menu_Init(void)
{
  /* Create Menu Semaphore */
  osSemaphoreDef(osSem);

  MenuEvent = osSemaphoreCreate(osSemaphore(osSem), 1); 
  
  /* Force menu to show Item 0 by default */
  osSemaphoreRelease(MenuEvent);

  /* Menu task */
  osThreadDef(Menu_Thread, MSC_MenuThread, osPriorityHigh, 0, 8 * configMINIMAL_STACK_SIZE);
  osThreadCreate(osThread(Menu_Thread), NULL);
  
  /* Define used semaphore fot Joystick*/
  osSemaphoreDef(JOY_SEM);
  
  /* Create the semaphore used by the two threads. */
  osJoySemaphore = osSemaphoreCreate(osSemaphore(JOY_SEM) , 1);
  
  BSP_LCD_SetTextColor(LCD_COLOR_GREEN);
  BSP_LCD_DisplayStringAtLine(15, (uint8_t *)"Use [Joystick Left/Right] to scroll up/down");
  BSP_LCD_DisplayStringAtLine(16, (uint8_t *)"Use [Joystick Up/Down] to scroll MSC menu");  
}
开发者ID:z80,项目名称:stm32f429,代码行数:29,代码来源:menu.c

示例7: HID_MenuThread

/**
  * @brief  User task
  * @param  pvParameters not used
  * @retval None
  */
void HID_MenuThread(void const *argument)
{
  for(;;)
  {
    if(osSemaphoreWait(MenuEvent , osWaitForever) == osOK)
    {
      switch(hid_demo.state)
      {
      case HID_DEMO_IDLE:
        HID_SelectItem(DEMO_HID_menu, 0); 
        hid_demo.state = HID_DEMO_WAIT;
        hid_demo.select = 0;
        osSemaphoreRelease(MenuEvent);
        break;        
        
      case HID_DEMO_WAIT:
        if(hid_demo.select != prev_select)
        {
          prev_select = hid_demo.select;        
          
          HID_SelectItem(DEMO_HID_menu, hid_demo.select & 0x7F); 
          /* Handle select item */
          if(hid_demo.select & 0x80)
          {
            switch(hid_demo.select & 0x7F)
            {
            case 0:
              hid_demo.state = HID_DEMO_START; 
              osSemaphoreRelease(MenuEvent);
              break;
              
            case 1:
              hid_demo.state = HID_DEMO_REENUMERATE;
              osSemaphoreRelease(MenuEvent);
              break;
              
            default:
              break;
            }
          }
        }
        break; 
        
      case HID_DEMO_START:
        if(Appli_state == APPLICATION_READY)
        {
          if(USBH_HID_GetDeviceType(&hUSBHost) == HID_KEYBOARD)
          {
            hid_demo.keyboard_state = HID_KEYBOARD_IDLE; 
            hid_demo.state = HID_DEMO_KEYBOARD;
          }
          else if(USBH_HID_GetDeviceType(&hUSBHost) == HID_MOUSE)
          {
            hid_demo.mouse_state = HID_MOUSE_IDLE;  
            hid_demo.state = HID_DEMO_MOUSE;        
          }
        }
        else
        {
          LCD_ErrLog("No supported HID device!\n");
          hid_demo.state = HID_DEMO_WAIT;
        }
        osSemaphoreRelease(MenuEvent);
        break;
        
      case HID_DEMO_REENUMERATE:
        /* Force MSC Device to re-enumerate */
        USBH_ReEnumerate(&hUSBHost); 
        hid_demo.state = HID_DEMO_WAIT;
        osSemaphoreRelease(MenuEvent);
        break;
        
      case HID_DEMO_MOUSE:
        if(Appli_state == APPLICATION_READY)
        {
          HID_MouseMenuProcess();
          USBH_MouseDemo(&hUSBHost);
        }
        break; 
        
      case HID_DEMO_KEYBOARD:
        if(Appli_state == APPLICATION_READY)  
        {    
          HID_KeyboardMenuProcess();
          USBH_KeybdDemo(&hUSBHost);
        }   
        break;
        
      default:
        break;
      }
      
      if(Appli_state == APPLICATION_DISCONNECT)
      {
        Appli_state = APPLICATION_IDLE; 
//.........这里部分代码省略.........
开发者ID:nidhiyanandh,项目名称:STM32Cube_FW_F4_V1.5.0_GCC_Makefile,代码行数:101,代码来源:menu.c

示例8: EventHandlerCAN0

void EventHandlerCAN0()
{
/*
	  if(CAN001_GetMOFlagStatus(&CAN001_Handle0,1,TRANSMIT_PENDING) == CAN_SET)
	  {
	    CAN001_ClearMOFlagStatus(&CAN001_Handle0,1,TRANSMIT_PENDING);
	  }
	  if(CAN001_GetMOFlagStatus(&CAN001_Handle0,2,TRANSMIT_PENDING) == CAN_SET)
	  {
	    CAN001_ClearMOFlagStatus(&CAN001_Handle0,2,TRANSMIT_PENDING);
	  }
	  if(CAN001_GetMOFlagStatus(&CAN001_Handle0,3,TRANSMIT_PENDING) == CAN_SET)
	  {
	    CAN001_ClearMOFlagStatus(&CAN001_Handle0,3,TRANSMIT_PENDING);
	  }
	  if(CAN001_GetMOFlagStatus(&CAN001_Handle0,4,TRANSMIT_PENDING) == CAN_SET)
	  {
	    CAN001_ClearMOFlagStatus(&CAN001_Handle0,4,TRANSMIT_PENDING);
	  }
*/


	  if(CAN001_GetMOFlagStatus(&CAN001_Handle0,5,RECEIVE_PENDING) == CAN_SET)
	  {
	    CAN001_ClearMOFlagStatus(&CAN001_Handle0,5,RECEIVE_PENDING);
	    CAN001_ReadMsgObj(&CAN001_Handle0,&can0rx.buf[can0rx.WritePos],5);
	    can0rx.WritePos++;
	    can0rx.WritePos&=(MAXLINE-1);
	    osSemaphoreRelease(can0rx_semaphore_id);
	  }
	  if(CAN001_GetMOFlagStatus(&CAN001_Handle0,6,RECEIVE_PENDING) == CAN_SET)
	  {
	    CAN001_ClearMOFlagStatus(&CAN001_Handle0,6,RECEIVE_PENDING);
	    CAN001_ReadMsgObj(&CAN001_Handle0,&can0rx.buf[can0rx.WritePos],6);
	    can0rx.WritePos++;
	    can0rx.WritePos&=(MAXLINE-1);
	    osSemaphoreRelease(can0rx_semaphore_id);
	  }
	  if(CAN001_GetMOFlagStatus(&CAN001_Handle0,7,RECEIVE_PENDING) == CAN_SET)
	  {
	    CAN001_ClearMOFlagStatus(&CAN001_Handle0,7,RECEIVE_PENDING);
	    CAN001_ReadMsgObj(&CAN001_Handle0,&can0rx.buf[can0rx.WritePos],7);
	    can0rx.WritePos++;
	    can0rx.WritePos&=(MAXLINE-1);
	    osSemaphoreRelease(can0rx_semaphore_id);
	  }
	  if(CAN001_GetMOFlagStatus(&CAN001_Handle0,8,RECEIVE_PENDING) == CAN_SET)
	  {
	    CAN001_ClearMOFlagStatus(&CAN001_Handle0,8,RECEIVE_PENDING);
	    CAN001_ReadMsgObj(&CAN001_Handle0,&can0rx.buf[can0rx.WritePos],8);
	    can0rx.WritePos++;
	    can0rx.WritePos&=(MAXLINE-1);
	    osSemaphoreRelease(can0rx_semaphore_id);
	  }


	  if(CAN001_GetNodeFlagStatus(&CAN001_Handle0,CAN001_ALERT_STATUS) == CAN_SET)
	  {
	    CAN001_ClearNodeFlagStatus(&CAN001_Handle0,CAN001_ALERT_STATUS);
	  }

}
开发者ID:liudanghao,项目名称:DAVE4500,代码行数:62,代码来源:myCAN.c

示例9: HAL_GPIO_EXTI_Callback

/**
  * @brief  EXTI line detection callbacks
  * @param  GPIO_Pin: Specifies the pins connected EXTI line
  * @retval None
  */
void HAL_GPIO_EXTI_Callback(uint16_t GPIO_Pin)
{
  osSemaphoreRelease(osSemaphore);
}
开发者ID:451506709,项目名称:automated_machine,代码行数:9,代码来源:main.c

示例10: thread2

/*! 
    \brief Thread definition for thread 2.
    \param argument A pointer to the list of arguments.
*/
void thread2 (void const *argument) 
{
  if (addTraceProtected("thread2 start run") != TRACE_OK)
	{
		stop_cpu;
	}
	
  while (1) 
	{		
		if (addTraceProtected("thread2 take sem0 attempt") != TRACE_OK)
		{
			stop_cpu;
		}		
    if ( osSemaphoreWait (sid_Semaphore0, osWaitForever) != -1 ) // wait forever
		{					 
			if (addTraceProtected("thread2 take sem0 success") != TRACE_OK)
			{
				stop_cpu;
			}	
			
			task2(); // thread code
			count1Sec();
			task2();
			
			if (addTraceProtected("thread2 release sem0 attempt") != TRACE_OK)
			{
				stop_cpu;
			}				
			if (osSemaphoreRelease (sid_Semaphore0) != osOK)
			{
				if (addTraceProtected("thread2 release sem0 fail") != TRACE_OK)
				{
					stop_cpu;
				}						
			}
		}
		else
		{
			if (addTraceProtected("thread2 take sem0 fail") != TRACE_OK)
			{
				stop_cpu;
			}				
		}

		if (addTraceProtected("thread2 set priority to osPriorityBelowNormal") != TRACE_OK)
		{
			stop_cpu;
		}		
		osThreadSetPriority(osThreadGetId(), osPriorityBelowNormal);
		
		if (addTraceProtected("thread2 yields") != TRACE_OK)
		{
			stop_cpu;
		}		
    osThreadYield();                                            // suspend thread
		
		if (addTraceProtected("thread2 back from yield") != TRACE_OK)
		{
			stop_cpu;
		}
		
		// This should terminate the current thread2 thread		
		if (Terminate_thread2() != 0)
		{
			stop_cpu;		
		}
		
  }
}
开发者ID:rozmov,项目名称:RavenOS,代码行数:73,代码来源:thread2.c

示例11: osSemaphoreRelease

osStatus Semaphore::release(void)
{
    return osSemaphoreRelease(_id);
}
开发者ID:toyowata,项目名称:mbed,代码行数:4,代码来源:Semaphore.cpp

示例12: HID_MenuThread

/**
  * @brief  User task
  * @param  pvParameters not used
  * @retval None
  */
void HID_MenuThread(void const *argument)
{
  for(;;)
  {
    if(osSemaphoreWait(MenuEvent , osWaitForever) == osOK)
    {
      switch(hid_demo.state)
      {
      case HID_DEMO_IDLE:
          hid_demo.state = HID_DEMO_START;
          osSemaphoreRelease(MenuEvent);
        break;  
        
      case HID_DEMO_START:
        if(Appli_state == APPLICATION_READY)
        {
          /* Wait for User Input */
          if(ButtonPressed == 1)
          {
            ButtonPressed = 0;
            if(USBH_HID_GetDeviceType(&hUSBHost) == HID_KEYBOARD)
            {
              hid_demo.keyboard_state = HID_KEYBOARD_START;
              hid_demo.state = HID_DEMO_KEYBOARD;
              HID_KeyboardMenuProcess();
            }
            else if(USBH_HID_GetDeviceType(&hUSBHost) == HID_MOUSE)
            {
              hid_demo.mouse_state = HID_MOUSE_START;
              hid_demo.state = HID_DEMO_MOUSE;
              HID_MouseMenuProcess();
            }
            else
            {
              LCD_ErrLog("No supported HID device!\n");
              hid_demo.state = HID_DEMO_IDLE;
            }
          }
          osSemaphoreRelease(MenuEvent);          
        }
        break;
        
      case HID_DEMO_MOUSE:
        if(Appli_state == APPLICATION_READY)
        {
          USBH_MouseDemo(&hUSBHost);
        }
        break;
        
      case HID_DEMO_KEYBOARD:
        if(Appli_state == APPLICATION_READY)  
        {
          USBH_KeybdDemo(&hUSBHost);
        }   
        break;
        
      default:
        break;
      }
      
      if(Appli_state == APPLICATION_DISCONNECT)
      {
        Appli_state = APPLICATION_IDLE; 
        LCD_LOG_ClearTextZone();
        BSP_LCD_ClearStringLine(19);
        LCD_ErrLog("HID device disconnected!\n");
        hid_demo.state = HID_DEMO_IDLE;
      }
    }
  }
}
开发者ID:z80,项目名称:stm32f429,代码行数:76,代码来源:menu.c

示例13: vMBM_EventPut_Post

void	vMBM_EventPut_Post( void )
{	//	设置发送完成标志
	osSemaphoreRelease( semaphore_TX );
}
开发者ID:github188,项目名称:JSD-KB6120E_V2.x,代码行数:4,代码来源:MBM_Port.C

示例14: USBH_HID_EventCallback

/**
  * @brief  The function is a callback about HID Data events
  * @param  phost: Selected device
  * @retval None
  */
void USBH_HID_EventCallback(USBH_HandleTypeDef *phost)
{
  osSemaphoreRelease(MenuEvent);
}
开发者ID:nidhiyanandh,项目名称:STM32Cube_FW_F4_V1.5.0_GCC_Makefile,代码行数:9,代码来源:menu.c

示例15: osSetEvent

void osSetEvent(OsEvent *event)
{
   //Set the specified event to the signaled state
   osSemaphoreRelease(event->id);
}
开发者ID:frankzzcn,项目名称:M2_SE_RTOS_Project,代码行数:5,代码来源:os_port_cmsis_rtos.c


注:本文中的osSemaphoreRelease函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。