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


C++ osThreadSuspend函数代码示例

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


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

示例1: AUDIO_RECORDER_PauseResume

/**
  * @brief  Pause Audio stream
  * @param  None.
  * @retval Audio state.
  */
AUDIO_RECORDER_ErrorTypdef  AUDIO_RECORDER_PauseResume(void)
{
  if(haudio.in.state == AUDIO_RECORDER_PLAYING)
  {  
    osThreadSuspend(AudioThreadId);     
    BSP_AUDIO_OUT_Pause();
    haudio.in.state = AUDIO_RECORDER_PLAY_PAUSE;
  }
  else if(haudio.in.state == AUDIO_RECORDER_RECORDING)
  {
    osThreadSuspend(AudioThreadId);     
    BSP_AUDIO_IN_Pause();
    haudio.in.state = AUDIO_RECORDER_RECORD_PAUSE;    
  }
  
  else if(haudio.in.state == AUDIO_RECORDER_PLAY_PAUSE)
  { 
    osThreadResume(AudioThreadId);  
    BSP_AUDIO_OUT_Resume();
    haudio.in.state = AUDIO_RECORDER_PLAYING;
  }
  else if(haudio.in.state == AUDIO_RECORDER_RECORD_PAUSE)
  {
    osThreadResume(AudioThreadId);  
    BSP_AUDIO_IN_Resume();
    haudio.in.state = AUDIO_RECORDER_RECORDING;    
  }  
  return AUDIO_RECORDER_ERROR_NONE;
}
开发者ID:nguyenvuhung,项目名称:STM32Cube_FW_F4,代码行数:34,代码来源:audio_recorder_app.c

示例2: LED_Thread2

/**
  * @brief  Toggle LED2 thread
  * @param  argument not used
  * @retval None
  */
static void LED_Thread2(void const *argument)
{
  uint32_t count;
  (void) argument;

  for(;;)
  {
    count = osKernelSysTick() + 10000;

    /* Toggle LED2 every 500 ms for 10 s */
    while (count >= osKernelSysTick())
    {
      BSP_LED_Toggle(LED2);

      osDelay(500);
    }

    /* Turn off LED2 */
    BSP_LED_Off(LED2);

    /* Resume Thread 1 */
    osThreadResume(LEDThread1Handle);

    /* Suspend Thread 2 */
    osThreadSuspend(NULL);
  }
}
开发者ID:Joe-Merten,项目名称:Stm32-Tools-Evaluation,代码行数:32,代码来源:main.c

示例3: AUDIO_RECORDER_StopRec

/**
  * @brief  Stop audio stream.
  * @param  None.
  * @retval Audio state.
  */
AUDIO_RECORDER_ErrorTypdef  AUDIO_RECORDER_StopRec(void)
{
  uint32_t byteswritten = 0;
  AUDIO_RECORDER_ErrorTypdef audio_error = AUDIO_RECORDER_ERROR_IO;
  

  BSP_AUDIO_IN_Stop();  
  haudio.in.state = AUDIO_RECORDER_IDLE;      
  if(f_lseek(&wav_file, 0) == FR_OK)
  {
    /* Update the wav file header save it into wav file */
    WavProcess_HeaderUpdate(pHeaderBuff, &AudioInfo);
    
    if(f_write(&wav_file, pHeaderBuff, sizeof(WAV_InfoTypedef), (void*)&byteswritten) == FR_OK)
    {   
      audio_error = AUDIO_RECORDER_ERROR_NONE;
    }
  }

  haudio.in.state = AUDIO_RECORDER_SUSPENDED;
  f_close(&wav_file);

  _cbNotifyStateChange();
  
  if(AudioThreadId != 0)
  {  
    osThreadSuspend(AudioThreadId); 
  }
  return audio_error;
}
开发者ID:nguyenvuhung,项目名称:STM32Cube_FW_F4,代码行数:35,代码来源:audio_recorder_app.c

示例4: LED_Thread2

/**
  * @brief  Toggle LED3 thread
  * @param  argument not used
  * @retval None
  */
static void LED_Thread2(void const *argument)
{
  uint32_t count;
  (void) argument;

  for (;;)
  {
    count = osKernelSysTick() + 10000;

    while (count >= osKernelSysTick())
    {
      BSP_LED_On(LED3);
      osDelay(100);
      BSP_LED_Off(LED3);
      osDelay(100);
      BSP_LED_On(LED3);
      osDelay(100);
      BSP_LED_Off(LED3);
      HAL_Delay(1000); 
    }

    /* Turn off LED3 */
    BSP_LED_Off(LED3);

    /* Resume Thread 1 */
    osThreadResume(LEDThread1Handle);

    /* Suspend Thread 2 */
    osThreadSuspend(NULL);
  }
}
开发者ID:pengphei,项目名称:STM32Cube_L0,代码行数:36,代码来源:main.c

示例5: AUDIOPLAYER_Pause

/**
  * @brief  Pause Audio stream
  * @param  None.
  * @retval Audio state.
  */
AUDIOPLAYER_ErrorTypdef  AUDIOPLAYER_Pause(void)
{
  if(AudioThreadId != 0)
  {
    osThreadSuspend(AudioThreadId); 
  }
  BSP_AUDIO_OUT_Pause();
  return AUDIOPLAYER_ERROR_NONE;
}
开发者ID:MrZANE42,项目名称:verisure1512,代码行数:14,代码来源:audio_player_app.c

示例6: MutexMeduimPriorityThread

/**
  * @brief  Mutex Medium Priority Thread.
  * @param  argument: Not used
  * @retval None
  */
static void MutexMeduimPriorityThread(void const *argument)
{
  /* Just to remove compiler warning */
  (void) argument;
  
  for(;;)
  {
    /* This thread will run while the high-priority thread is blocked, and the
    high-priority thread will block only once it has the mutex - therefore
    this call should block until the high-priority thread has given up the 
    mutex, and not actually execute past this call until the high-priority 
    thread is suspended. */
    if(osMutexWait(osMutex, osWaitForever) == osOK)
    {
      if(osThreadGetState(osHighPriorityThreadHandle) != osThreadSuspended)
      {
        /* Did not expect to execute until the high priority thread was
        suspended.
        Toggle LED 3 to indicate error */
        BSP_LED_Toggle(LED3);
      }
      else
      {
        /* Give the mutex back before suspending ourselves to allow
        the low priority thread to obtain the mutex. */
        if(osMutexRelease(osMutex) != osOK)
        {
          /* Toggle LED 3 to indicate error */
          BSP_LED_Toggle(LED3);
        } 
        osThreadSuspend(NULL);
      }
    }
    else
    {
      /* We should not leave the osMutexWait() function
      until the mutex was obtained. 
      Toggle LED 3 to indicate error */
      BSP_LED_Toggle(LED3);
    }
    
    /* The High and Medium priority threads should be in lock step. */
    if(HighPriorityThreadCycles != (MediumPriorityThreadCycles + 1))
    {
      /* Toggle LED 3 to indicate error */
      BSP_LED_Toggle(LED3);
    }
    
    /* Keep count of the number of cycles this task has performed so a 
    stall can be detected. */
    MediumPriorityThreadCycles++;
    BSP_LED_Toggle(LED2);
  }
}
开发者ID:451506709,项目名称:automated_machine,代码行数:59,代码来源:main.c

示例7: AUDIOPLAYER_Stop

/**
  * @brief  Stop audio stream.
  * @param  None.
  * @retval Audio state.
  */
AUDIOPLAYER_ErrorTypdef  AUDIOPLAYER_Stop(void)
{    
  AUDIOPLAYER_Mute(1); 
  BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW);    
  f_close(&wav_file);  
  osThreadSuspend(AudioThreadId); 

  haudio.state = AUDIOPLAYER_STOP;      

  return AUDIOPLAYER_ERROR_NONE;
}
开发者ID:Lembed,项目名称:STM32CubeF4-mirrors,代码行数:16,代码来源:audioplayer_app.c

示例8: AUDIOPLAYER_Stop

/**
  * @brief  Stop audio stream.
  * @param  None.
  * @retval Audio state.
  */
AUDIOPLAYER_ErrorTypdef  AUDIOPLAYER_Stop(void)
{

  BSP_AUDIO_OUT_Stop(CODEC_PDWN_SW);  
  haudio.out.state = AUDIOPLAYER_STOP;
  f_close(&wav_file);
  if(AudioThreadId != 0)
  {  
    osThreadSuspend(AudioThreadId); 
  }
  return AUDIOPLAYER_ERROR_NONE;
}
开发者ID:CamelShoko,项目名称:RadioYuN,代码行数:17,代码来源:audio_player_app.c

示例9: AUDIO_RECORDER_StopPlayer

/**
  * @brief  Stop audio stream.
  * @param  None.
  * @retval Audio state.
  */
AUDIO_RECORDER_ErrorTypdef  AUDIO_RECORDER_StopPlayer(void)
{
  BSP_AUDIO_OUT_Stop(CODEC_PDWN_HW);
  BSP_AUDIO_OUT_DeInit();  
  haudio.in.state = AUDIO_RECORDER_SUSPENDED;      
  f_close(&wav_file);
  _cbNotifyStateChange(); 
  
  if(AudioThreadId != 0)
  {  
    osThreadSuspend(AudioThreadId); 
  } 
  return AUDIO_RECORDER_ERROR_NONE;
}
开发者ID:nguyenvuhung,项目名称:STM32Cube_FW_F4,代码行数:19,代码来源:audio_recorder_app.c

示例10: LED_Thread1

/**
  * @brief  Toggle LED1
  * @param  thread not used
  * @retval None
  */
static void LED_Thread1(void const *argument)
{
	(void) argument;
  
	for (;;)
	{
		HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_SET);
		osDelay(2000);
		
		HAL_GPIO_WritePin(GPIOB, GPIO_PIN_6, GPIO_PIN_RESET);
		osThreadSuspend(LEDThread2Handle);
		osDelay(1900);
		
		osThreadResume(LEDThread2Handle);
	}
}
开发者ID:KhasanovBI,项目名称:STM32GENERATOR,代码行数:21,代码来源:GeneratorVisualGDB.c

示例11: MutexHighPriorityThread

/**
  * @brief  Mutex High Priority Thread.
  * @param  argument: Not used
  * @retval None
  */
static void MutexHighPriorityThread(void const *argument)
{
  /* Just to remove compiler warning. */
  (void) argument;

  for (;;)
  {

    /* The first time through the mutex will be immediately available, on
    subsequent times through the mutex will be held by the low priority thread
    at this point and this Take will cause the low priority thread to inherit
    the priority of this tadhr.  In this case the block time must be
    long enough to ensure the low priority thread will execute again before the
    block time expires.  If the block time does expire then the error
    flag will be set here. */
    if (osMutexWait(osMutex, mutexTWO_TICK_DELAY) != osOK)
    {
      /* Toggle LED3 to indicate error */
      BSP_LED_Toggle(LED3);
    }

    /* Ensure the other thread attempting to access the mutex
    are able to execute to ensure they either block (where a block
    time is specified) or return an error (where no block time is
    specified) as the mutex is held by this task. */
    osDelay(mutexSHORT_DELAY);


    /* We should now be able to release the mutex .
    When the mutex is available again the medium priority thread
    should be unblocked but not run because it has a lower priority
    than this thread.  The low priority thread should also not run
    at this point as it too has a lower priority than this thread. */
    if (osMutexRelease(osMutex) != osOK)
    {
      /* Toggle LED3 to indicate error */
      BSP_LED_Toggle(LED3);
    }

    /* Keep count of the number of cycles this thread has performed. */
    HighPriorityThreadCycles++;
    BSP_LED_Toggle(LED1);

    /* Suspend ourselves to the medium priority thread can execute. */
    osThreadSuspend(NULL);
  }
}
开发者ID:eleciawhite,项目名称:STM32Cube,代码行数:52,代码来源:main.c

示例12: LED_Thread1

/**
  * @brief  Toggle LED3 and LED4 thread
  * @param  thread not used
  * @retval None
  */
static void LED_Thread1(void const *argument)
{
  uint32_t count = 0;
  (void) argument;

  for (;;)
  {
    count = osKernelSysTick() + 5000;

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

      osDelay(200);
    }

    /* Turn off LED3 */
    BSP_LED_Off(LED3);

    /* Suspend Thread 1 */
    osThreadSuspend(NULL);

    count = osKernelSysTick() + 5000;

    /* Toggle LED3 every 400 ms for 5 s */
    while (count >= osKernelSysTick())
    {
      BSP_LED_Toggle(LED3);

      osDelay(400);
    }

    /* Resume Thread 2*/
    osThreadResume(LEDThread2Handle);

  }
}
开发者ID:eleciawhite,项目名称:STM32Cube,代码行数:43,代码来源:main.c


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