• 设为首页
  • 点击收藏
  • 手机版
    手机扫一扫访问
    迪恩网络手机版
  • 关注官方公众号
    微信扫一扫关注
    公众号

C++ osSignalWait函数代码示例

原作者: [db:作者] 来自: [db:来源] 收藏 邀请

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



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

示例1: temperature_DispFlag_thread

/*!
 @brief Thread to display temperature
 @param argument Unused
*/
void temperature_DispFlag_thread(void const * argument)
{
	// Extracts the semaphore object from the argument.
	// This semaphore object was created in the main
	osSemaphoreId* semaphore;
	semaphore = (osSemaphoreId*)argument;
	
	uint8_t ResourceLocked = 1;  // Flag gets turned on if semaphore_lock achieved
	uint32_t tokentemp;          // Return of semwait
	
	// Wait for the semaphore with 1ms timeout
  osEvent event = osSignalWait(SIGNAL_DISP_TEMPERATURE, 1);

	while(1)
	{
		tokentemp=osSemaphoreWait (*semaphore, osWaitForever);
    ResourceLocked=1; // turn flag on if resource_locked		
		
    while (ResourceLocked)
		{
			// wait for a signal with 1ms timeout
			event = osSignalWait(SIGNAL_DISP_TEMPERATURE, 1);
			if (event.status == osEventTimeout)
			{
				// in case of timeout display
				LCD_DisplayTemperature(temp);
			}
			else
			{
				// signal received which is not timeout
				// clear the signal flag for the tilt display thread
				osSignalClear (tilt_TurnDispFlag_thread, SIGNAL_DISP_TILT);
				
				//clear the screen
				LCD_clear_display();
				
				// turn the resource_locked flag off
				ResourceLocked = 0;
				tokentemp=0;
				
				// turn the flag to display the string "temperature" once
				GLB_Temperature_display_flag=1;
				
				// release the semaphore 
				osSemaphoreRelease(*semaphore);
				
				//wait 5ms for the other thread to grab the semaphore
			  osDelay(5);
			}
		}
		
	}
	
}
开发者ID:YangZhou91,项目名称:MicroProcessor,代码行数:58,代码来源:temperature_thread.c


示例2: blinkLED

void blinkLED(void const *argument) {
  while (1) {
    __GPIO_WRITE(GPIOA, 5, GPIO_PIN_SET);
    osSignalWait(0x0001, osWaitForever);
    __GPIO_WRITE(GPIOA, 5, GPIO_PIN_RESET);
    osSignalWait(0x0001, osWaitForever);
    
    //sprintf(Buf, "%x\r\n", serbuff);
    //HAL_UART_Transmit(&huart2, (uint8_t *) Buf, strlen(Buf), 0xffffffff);
  }
}
开发者ID:adzil,项目名称:f446-softser,代码行数:11,代码来源:main.c


示例3: Thread_ACCELEROMETER

/*----------------------------------------------------------------------------
 *      Thread  'Accelerometer': Reads Accelerometer
 *---------------------------------------------------------------------------*/
void Thread_ACCELEROMETER (void const *argument) 
{		
	/* These are preserved between function calls (static) */
	KalmanState kstate_pitch = {0.001, 0.0032, 0.0, 0.0, 0.0};	/* Filter parameters obtained by experiment and variance calculations */
	KalmanState kstate_roll  = {0.001, 0.0032, 0.0, 0.0, 0.0};	/* Filter parameters obtained by experiment and variance calculations */
	
	float ax, ay, az;
	float roll, pitch;

	osTimerId doubletap_timer_id, accel_dataready_timer_id;
	
	doubletap_timer_id = osTimerCreate(osTimer(doubletap_timer), osTimerOnce, NULL);
	accel_dataready_timer_id = osTimerCreate(osTimer(accel_dataready_timer), osTimerOnce, NULL);
	
	while(1)
	{
		/* Wait for accelerometer new data signal or Nucleo board SPI signal for read request.
		   No need to send data all the time. */
		osSignalWait(ACCELEROMETER_SIGNAL, osWaitForever);

		Accelerometer_ReadAccel(&ax, &ay, &az);
		Accelerometer_Calibrate(&ax, &ay, &az);
					
		Accelerometer_GetRollPitch(ax, ay, az, &pitch, &roll);		
		Kalmanfilter_asm(&pitch, &filtered_pitch, 1, &kstate_pitch);	/* filter the pitch angle */
		Kalmanfilter_asm(&roll, &filtered_roll, 1, &kstate_roll);			/* filter the roll angle 	*/
				
		if (Accelerometer_DetectDoubletap(sqrtf(ax * ax + ay * ay + az * az)))
			NucleoSPI_SetDoubletap(doubletap_timer_id, DOUBLETAP_TIMEOUT_MS);

		NucleoSPI_SetAccelDataready(accel_dataready_timer_id, ACCEL_DATAREADY_TIMEOUT_MS);
	}
}
开发者ID:Lone-L,项目名称:ECSE426_Final_Project,代码行数:36,代码来源:accelerometer.c


示例4: main

/*----------------------------------------------------------------------------
 *      Main: Initialise and start RTX Kernel
 *---------------------------------------------------------------------------*/
int main(void) {

   // Get main thread ID
   mainFunctionId = osThreadGetId();

   // Create thread
   threadFunctionId = osThreadCreate(osThread(threadFunction), NULL);
   if (threadFunctionId == NULL) {
      __asm__("bkpt");
   }

// Need suitable features for the stdio & leds
//   printf("Main thread ID = %d\n", (int)mainFunctionId);
//   printf("Thread ID      = %d\n", (int)threadFunctionId);

//   led_initialise();

   for (;;) {
      // Wait for signal from thread
      osSignalWait(SIGNAL_MASK, osWaitForever);

//      printf("Thread signaled\n");
//      greenLedToggle();
   }

}
开发者ID:podonoghue,项目名称:usbdm-eclipse-makefiles-build,代码行数:29,代码来源:main-RTX.c


示例5: Thread_SEGMENT

 /*----------------------------------------------------------------------------
*      Thread  'SEGMENT': Display values on 7-segment display
 *---------------------------------------------------------------------------*/
void Thread_SEGMENT (void const *argument) 
{
	int counter = 0;
	DisplayMode mode;
	
	while(1)
	{
		osSignalWait(SEGMENT_SIGNAL, osWaitForever);
		
		if (counter % FLASH_PERIOD == 0)
		{
			if (SevenSegment_GetFlashing()) {
				osMutexWait(segment_mutex, osWaitForever);
				activated = !activated;
				osMutexRelease(segment_mutex);
			}
		}
		
		mode = SevenSegment_GetDisplayMode();
		
		if (mode == TEMP_MODE) {
			SevenSegment_ToggleDisplayedDigit_Angle();
		} else if (mode == ANGLE_MODE) {
			SevenSegment_ToggleDisplayedDigit_Temp();
		}

		counter++;
	}
}
开发者ID:Lone-L,项目名称:MicroP_Labs,代码行数:32,代码来源:seven_segment.c


示例6: ledOff

/*----------------------------------------------------------------------------
  Task 2 'ledOff': switches the LED off
 *---------------------------------------------------------------------------*/
 void ledOff (void const *argument) {
  for (;;) {
    osSignalWait (0x0001, osWaitForever); /* wait for an event flag 0x0001   */
    osDelay(800);                         /* delay 800ms                     */
    LED_Off(0);                           /* Turn LED Off                    */
  }
}
开发者ID:ggajoch,项目名称:stm32-sudoku,代码行数:10,代码来源:Blinky.c


示例7: Thread_ADC

/**
* @brief Main loop for the adc
* @param None
* @retval None 
*/
void Thread_ADC (void const *argument) {
		while(1){
			osSignalWait (ADC_FLAG,osWaitForever); 
			osSignalClear(tid_Thread_ADC,ADC_FLAG); 
			poll();
		}
}
开发者ID:ShivanKaul,项目名称:MicroProcessorLabs,代码行数:12,代码来源:Thread_ADC.c


示例8: TC_MutexTimeout

/**
\brief Test case: TC_MutexTimeout
\details
- Create and initialize a mutex object
- Create a thread that acquires a mutex but never release it
- Wait for mutex release until timeout
*/
void TC_MutexTimeout (void) {
  osThreadId ctrl_id, lock_id;
  osEvent    evt;

  /* Get control thread id */
  ctrl_id = osThreadGetId ();
  ASSERT_TRUE (ctrl_id != NULL);
  
  if (ctrl_id != NULL) {
    /* - Create and initialize a mutex object */
    G_MutexId = osMutexCreate (osMutex (MutexTout));
    ASSERT_TRUE (G_MutexId != NULL);
    
    if (G_MutexId != NULL) {
      /* - Create a thread that acquires a mutex but never release it */
      lock_id = osThreadCreate (osThread (Th_MutexLock), &ctrl_id);
      ASSERT_TRUE (lock_id != NULL);
      
      if (lock_id != NULL) {
        /* - Wait for mutex release until timeout */
        ASSERT_TRUE (osMutexWait (G_MutexId, 10) == osErrorTimeoutResource);
        /* - Release a mutex */
        osSignalSet (lock_id, 0x01);
        evt = osSignalWait (0x01, 100);
        ASSERT_TRUE (evt.status == osEventSignal);
        /* - Terminate locking thread */
        ASSERT_TRUE (osThreadTerminate (lock_id)  == osOK);
      }
      /* Delete mutex object */
      ASSERT_TRUE (osMutexDelete (G_MutexId)  == osOK);
    }
  }
}
开发者ID:Goodjamp,项目名称:ble_app_template,代码行数:40,代码来源:RV_Mutex.c


示例9: lights

/*----------------------------------------------------------------------------
  Thread 3 'lights': executes if current time is between start & end time
 *---------------------------------------------------------------------------*/
void lights (void const *argument) {          /* traffic light operation     */
  SetLights (RED, 1);                         /* RED & STOP lights on        */
  SetLights (STOP, 1);
  SetLights (YELLOW, 0);
  SetLights (GREEN, 0);
  SetLights (WALK, 0);
  while (1) {                                 /* endless loop                */
    osDelay(500);                             /* wait for timeout: 500ms     */
    if (!signalon ()) {                       /* if traffic signal time over */
      tid_blinking = osThreadCreate(osThread(blinking), NULL);
                                              /* start blinking              */
      return;                                 /* STOP lights                 */
    }
    SetLights (YELLOW, 1);
    osDelay(500);                             /* wait for timeout: 500ms     */
    SetLights (RED, 0);                       /* GREEN light for cars        */
    SetLights (YELLOW, 0);
    SetLights (GREEN, 1);
    osSignalClear(tid_lights, 0x0010);
    osDelay(500);                             /* wait for timeout: 500ms     */
    osSignalWait(0x0010, 7500);               /* wait for event with timeout */
    SetLights (YELLOW, 1);                    /* timeout value: 7.5s         */
    SetLights (GREEN, 0);
    osDelay(500);                             /* wait for timeout: 500ms     */
    SetLights (RED, 1);                       /* RED light for cars          */
    SetLights (YELLOW, 0);
    osDelay(500);                             /* wait for timeout: 500ms     */
    SetLights (STOP, 0);                      /* GREEN light for WALKers     */    
    SetLights (WALK, 1);
    osDelay(2500);                            /* wait for timeout: 2.5s      */
    SetLights (STOP, 1);                      /* RED light for WALKers       */        
    SetLights (WALK, 0);
  }
}
开发者ID:EnergyMicro,项目名称:RTX,代码行数:37,代码来源:Traffic.c


示例10: oModeTransThread

void oModeTransThread(void const *args)
{
  while (1)
  {
    osSignalWait(SIG_START, osWaitForever);
    send_block_angles(totalNum, _rolls, _pitches, _deltas);
  }  
}
开发者ID:headyin,项目名称:Wireless-Board-Orientation-Control-System-ARM-Micro-Processor-Lab-,代码行数:8,代码来源:oModeTrans.c


示例11: Keypad

/*!
	Get pressed key after keypad interrupt occurs
 */
void Keypad(void const *argument){
	while (1){
		//wait until called
		osSignalWait(SIGNAL_KEYPAD, osWaitForever);
		get_press();
		osDelay(150);
	}
}
开发者ID:scarter93,项目名称:MicroP-Lab4,代码行数:11,代码来源:keypad.c


示例12: clock

/*----------------------------------------------------------------------------
  Thread 5 'clock': Signal Clock
 *---------------------------------------------------------------------------*/
void clock (void const *argument) {
  for (;;) {
    osSignalWait(0x0100, osWaitForever);    /* wait for an event flag 0x0100 */
    LED_on (LED_CLK);
    osDelay(80);                            /* delay 80ms                    */
    LED_off(LED_CLK);
  }
}
开发者ID:ADARSHBU,项目名称:LPC11U_LPC13U_CodeBase,代码行数:11,代码来源:Blinky.c


示例13: blinkLED

/*----------------------------------------------------------------------------
 * blinkLED: blink LED and check button state
 *----------------------------------------------------------------------------*/
void blinkLED(void const *argument) {
  int32_t max_num = LED_GetCount();
  int32_t num = 0;

  for (;;) {
    LED_On(num);                                           // Turn specified LED on
    osSignalWait(0x0001, osWaitForever);
    LED_Off(num);                                          // Turn specified LED off
    osSignalWait(0x0001, osWaitForever);

    num++;                                                 // Change LED number
    if (num >= max_num) {
      num = 0;                                             // Restart with first LED
    }
  }

}
开发者ID:tiongpatrick86,项目名称:Practise,代码行数:20,代码来源:RTX_Blinky.c


示例14: phaseA

/*----------------------------------------------------------------------------
  Thread 1 'phaseA': Phase A output
 *---------------------------------------------------------------------------*/
void phaseA (void const *argument) {
  for (;;) {
    osSignalWait(0x0001, osWaitForever);    /* wait for an event flag 0x0001 */
    LED_on (LED_A);
    signal_func (tid_phaseB);               /* call common signal function   */
    LED_off(LED_A);
  }
}
开发者ID:ADARSHBU,项目名称:LPC11U_LPC13U_CodeBase,代码行数:11,代码来源:Blinky.c


示例15: phaseD

/*----------------------------------------------------------------------------
 *      Thread 4 'phaseD': Phase D output
 *---------------------------------------------------------------------------*/
void phaseD (void  const *argument) {
  for (;;) {
    osSignalWait(0x0001, osWaitForever);    /* wait for an event flag 0x0001 */
    Switch_On (LED_D);
    signal_func(tid_phaseA);                /* call common signal function   */
    Switch_Off(LED_D);
  }
}
开发者ID:mad-et,项目名称:ex,代码行数:11,代码来源:Blinky.c


示例16: wait_for_all_signals

void wait_for_all_signals(thread::signal_set flags)
{
    WEOS_ASSERT(flags > 0 && flags <= thread::all_signals());
    osEvent result = osSignalWait(flags, osWaitForever);
    if (result.status != osEventSignal)
        WEOS_THROW_SYSTEM_ERROR(cmsis_error::cmsis_error_t(result.status),
                                "wait_for_signalflags failed");
}
开发者ID:kaidokert,项目名称:weos,代码行数:8,代码来源:thread.cpp


示例17: Thread_Accelerometer

/**
  * @brief  Accelerometer thread
  * @param  arguments
  * @retval None
  */
void Thread_Accelerometer(void const *argument){
	while(1){
	osSignalWait (data_ready_flag,osWaitForever); 
	osSignalClear(tid_Thread_Accelerometer,data_ready_flag); 
	calculateAngles();
	}
	
}
开发者ID:ShivanKaul,项目名称:MicroProcessorLabs,代码行数:13,代码来源:accelerometer.c


示例18: segment_display

// display thread handler
void segment_display(void const * arg){
	uint16_t LED_pins[4] = { GPIO_Pin_12, GPIO_Pin_13, GPIO_Pin_14, GPIO_Pin_15 };
	int count = 0;
	char key = DUMMY_KEY, led = '1';
	int mode = TEMP_MODE;
	float temperature = 50.0;
	float pitch = 0.0;
		
	display_init();
	
	float data; 
	
	while(1){
		osSignalWait(DISPLAY_READY, osWaitForever);
				
		// try to get the keypad message		
		if (receive_message(&data, keypad_queue)){
			key = (char)(((int)data) + '0');
			
			// figure out which type of key was pressed (i.e. mode or led) and adjust variables accordingly. 
			if (key == TEMP_MODE_KEY || key == MEMS_MODE_KEY){
				mode = key == TEMP_MODE_KEY ? TEMP_MODE : MEMS_MODE;
			} else {
				led = key;
			}			
		}
		
		// try to get the pitch message
		if (receive_message(&data, pitch_queue)){
			pitch = data;
		}
		
		// try to get the temperature message
		if (receive_message(&data, temp_queue)){
			temperature = data;
		}
				
		GPIO_ResetBits(GPIOD, GPIO_SEGMENT_PINS);
		GPIO_ResetBits(GPIOE, GPIO_DIGIT_SELECT_PINS);
	
		// run the display effect depending on whether or not an alarm is triggerd and the type of mode.
		if (temperature < ALARM_THRESHOLD || (count % (2 * TIM3_DESIRED_RATE)) < TIM3_DESIRED_RATE) {		
			if (mode == TEMP_MODE){
				GPIO_ResetBits(GPIOD, ALL_LED_PINS);
				display_value(temperature, count, TEMP_MODE); 
			} else {
				display_value(pitch, count, MEMS_MODE);
			}
		}
		
		if (mode == MEMS_MODE){
			display_LED(pitch, count, LED_pins[(led - '1')]);
		}
		
		count++;
	}
}
开发者ID:TheTypoMaster,项目名称:ECSE-426-Microprocessor-System,代码行数:58,代码来源:threads.c


示例19: wait_for_any_signal

thread::signal_set wait_for_any_signal()
{
    osEvent result = osSignalWait(0, osWaitForever);
    if (result.status != osEventSignal)
        WEOS_THROW_SYSTEM_ERROR(cmsis_error::cmsis_error_t(result.status),
                                "wait_for_any_signal failed");

    return result.value.signals;
}
开发者ID:kaidokert,项目名称:weos,代码行数:9,代码来源:thread.cpp


示例20: StartTask_Uart1Reception

void StartTask_Uart1Reception (void const *argument) 
{
	extern osMessageQId Q_CmdReceptionHandle;
	
	uint32_t reclen;
	osStatus qretval;								/*!< The return value which indicates the osMessagePut() implementation result */
	uint8_t* ptrdata;								/*!< Pointer to any byte in the uart buffer */
	uint8_t (*ptr_bufhead)[1],			/*!< Pointer to the head of the uart buffer */
					(*ptr_buftail)[1];			/*!< Pointer to the tail of the uart buffer */
	
  while (1) 
	{
    osSignalWait (0x01, osWaitForever);
		
		reclen = MAX_DEPTH_UART1_BUF - huart1.hdmarx->Instance->NDTR;
		ptrdata = *uart_buf + reclen - 1;		// point to the last char received
		ptr_bufhead = (uint8_t(*)[1])uart1_buf[0];
		ptr_buftail = (uint8_t(*)[1])uart1_buf[MAX_COUNT_UART1_BUF - 2];
		
		if(*ptrdata == '\n')
		{
			/* Insert a terminal into the string */
			*(ptrdata + 1) = 0x0;
			
			if(*(--ptrdata) == '\r')	// A command has been received
			{
				/*
				* The current buffer has been used and post to the working thread
				* switch to the next uart1 queue buffer to recevie the furture data
				*/
				qretval = osMessagePut(Q_CmdReceptionHandle, (uint32_t)(uart_buf), 0);	// Put the pointer of the data container to the queue
				if(qretval != osOK)
				{
					__breakpoint(0);
						//printk(KERN_ERR "It's failed to put the command into the message queue!\r\n");
				}

				/* Move to the next row of the buffer */
				uart_buf++;
				if(uart_buf > (uint8_t(*)[50])ptr_buftail)
				{
						uart_buf = (uint8_t(*)[50])ptr_bufhead;
				}
			}
			/* Reset DMA_EN bit can result in the TCIF interrupt.
			The interrupt raises the HAL_UART_RxCpltCallback() event, the DMA_Rx will be restarted in it */
			HAL_DMA_Abort(huart1.hdmarx);
			USART_Start_Receive_DMA(&huart1);
		
		}
		else	/* Continue recepition if the last char is not '\n' */
		{
			__HAL_UART_ENABLE_IT(&huart1, UART_IT_IDLE);
		}
	}
}
开发者ID:35408EF66CCE4377B1E3C2495CA1C18A,项目名称:freerots_console,代码行数:56,代码来源:usart_common.c



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


鲜花

握手

雷人

路过

鸡蛋
该文章已有0人参与评论

请发表评论

全部评论

专题导读
上一篇:
C++ osSystickHandler函数代码示例发布时间:2022-05-30
下一篇:
C++ osSignalSet函数代码示例发布时间:2022-05-30
热门推荐
阅读排行榜

扫描微信二维码

查看手机版网站

随时了解更新最新资讯

139-2527-9053

在线客服(服务时间 9:00~18:00)

在线QQ客服
地址:深圳市南山区西丽大学城创智工业园
电邮:jeky_zhao#qq.com
移动电话:139-2527-9053

Powered by 互联科技 X3.4© 2001-2213 极客世界.|Sitemap