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


C++ osMutexWait函数代码示例

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


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

示例1: wireless_RX

/**
  * @brief  Function that receives data and performs Triple Modular Redundancy. This is a blocking call.
  * @param  *receiver: pointer to a Receiver structure. 
  * @retval None.
  */
void wireless_RX(struct Receiver *receiver) {
	uint8_t i=0;
	uint8_t temp_data=0;
	
	osMutexWait(receiver->mutexID, osWaitForever);	
	uint8_t raw_data[sizeof(receiver->data)/sizeof(receiver->data[0]) * 3];
	CC2500_StrobeSend(SRX_R,&(receiver->state),&(receiver->buffer_space));
	osMutexRelease(receiver->mutexID);
	
	osDelay(STROBE_DELAY);
	
	while (i<(sizeof(receiver->data)/sizeof(receiver->data[0]) * 3)) {
		osMutexWait(receiver->mutexID, osWaitForever);
		CC2500_StrobeSend(SNOP_R,&(receiver->state),&(receiver->buffer_space));	
		
		if (receiver->buffer_space>0) {
			CC2500_Read(&temp_data, 0x3F, 1);
			if ((temp_data&0xF0)==0xF0) {
				raw_data[0]=temp_data&0x0F;
				i=1;
			} else if (i>0) {
				if ((temp_data&0xF0)==i<<4) {
					raw_data[i]=temp_data&0x0F;
					i++;
				} else {
					i=0;
				}
			}
		}
		
		osMutexRelease(receiver->mutexID);
		
		osDelay(STROBE_DELAY);
	}
	
	osMutexWait(receiver->mutexID, osWaitForever);
	for(uint32_t j=0;j<sizeof(receiver->data)/sizeof(receiver->data[0]);j++){
		receiver->data[j] = ((raw_data[3*j]&raw_data[3*j+1]) | (raw_data[3*j]&raw_data[3*j+2]) | (raw_data[3*j+2]&raw_data[3*j+1]));
	}
	
	CC2500_StrobeSend(SIDLE_R,&(receiver->state),&(receiver->buffer_space));
	osMutexRelease(receiver->mutexID);
	osDelay(STROBE_DELAY);
	
	osMutexWait(receiver->mutexID, osWaitForever);
	CC2500_StrobeSend(SNOP_R,&(receiver->state),&(receiver->buffer_space));
	osMutexRelease(receiver->mutexID);
	osDelay(STROBE_DELAY);
}
开发者ID:jmweeks,项目名称:SuperAwesomeFinalProject,代码行数:54,代码来源:CC2500.c

示例2: SevenSegment_StartFlashing

/**
   * @brief Starts flashing the display.
   * @param None
   * @retval None
   */
void SevenSegment_StartFlashing(void)
{
	/* We have race conditions. Need to use mutexes to protect these global flags. */
	osMutexWait(segment_mutex, osWaitForever);
	flashing = 1;
	osMutexRelease(segment_mutex);
}
开发者ID:Lone-L,项目名称:MicroP_Labs,代码行数:12,代码来源:seven_segment.c

示例3: xb_SendF

//Send data in specified format. Same syntax as printf
util_ErrTd xb_SendF(char *format, ...){
	util_ErrTd Status = util_ErrTd_Ok;
	va_list va;
	int32_t i;


	if( osMutexWait(xb_MutexId, 100) == osOK ){																//Wait for shared resource (tx buffer access)
		HAL_NVIC_DisableIRQ(XB_DMA_TX_IRQN);																//Disable DMA interrupts (TXC could acces TxBuffer in the middle of writing data to it

		va_start(va, format);																				//Start reading of parameters
		vsnprintf(xb_TmpStr, sizeof(xb_TmpStr), format, va);												//Format new string and save its length
		va_end(va);																							//End of reading parameters

	//	if( Cnt <= 0 || Cnt >= sizeof(com_TmpStr) ){						//If formatted string doesnt fit into buffer
	//		snprintf(com_TmpStr, sizeof(com_TmpStr), "<erre %d %d>\r\n", (int)Cnt, (int)sizeof(com_TmpStr));	//Format error message instead
	//		Status = util_ErrTd_Overflow;
	//	}

		for( i=0; i<strlen(xb_TmpStr); i++ ){																//Copy byte by byte into tx buffer
			xb_TxBuffer[ xb_TxHead++ ] = xb_TmpStr[i];
			xb_TxHead &= XB_TXBUFHEADMASK;
		}

		HAL_NVIC_EnableIRQ(XB_DMA_TX_IRQN);																	//Enable DMA interrupts again
		xb_TransmitTxBuffer();																				//Transmit TX buffer

		osMutexRelease(xb_MutexId);																			//Release shared resource
	}
	return Status;
}
开发者ID:kevarek,项目名称:CanFireWall,代码行数:31,代码来源:xbee.c

示例4: cmd_bluetooth_check

/*---------------------------------------------------------------------------
     TITLE   : cmd_bluetooth_check
     WORK    :
     ARG     : void
     RET     : void
---------------------------------------------------------------------------*/
void cmd_bluetooth_check( void )
{
	uint32_t time_out;
	uint8_t  ch;
	uint8_t  ch_array[2];
	uint8_t  ch_i;
	osStatus ret;

	ret = osMutexWait( Mutex_Loop, 1000 );

	if( ret != osOK )
	{
		_menu_printf("Fail to osMutexWait\r\n");
		return;
	}

	core.blueport = uartOpen(USART2, NULL, 115200, MODE_RXTX);

	_menu_printf("\r\n");
	_menu_printf("AT -> ");

	serialPrint(core.blueport, "AT");


	ch_array[0] = 0;
	ch_array[1] = 0;
	ch_i  = 0;

	//-- 응답이 올때까지 기다림
	time_out = 1000;
	while(time_out--)
	{
		if( serialTotalBytesWaiting(core.blueport) )
		{
			ch = serialRead(core.blueport);
			_menu_putch(ch);
			ch_array[ch_i++] = ch;

			if( ch_i >= 2 ) break;
		}

		osDelay(1);
	}


	if( ch_array[0] == 'O' && ch_array[1] == 'K' )
	{
		_menu_printf("\r\nBluetooth OK");
	}
	else
	{
		_menu_printf("\r\nBluetooth Fail");
	}

	_menu_printf("\r\n");

	serialInit(mcfg.serial_baudrate);

	osMutexRelease( Mutex_Loop );
}
开发者ID:oroca,项目名称:SkyRover_Nano,代码行数:66,代码来源:thread_menu.c

示例5: Thread_DISP2

void Thread_DISP2(void const *argument){
	
	float roll_temp, pitch_temp;
	
	while(1){
		// osDelay(10);
		osMutexWait(mems_mutex_id, osWaitForever);
		roll_temp = roll;
		osMutexRelease(mems_mutex_id);
		// printf("mems: roll= %f\n", roll_temp);
		printf("mems: temp= %f\n", output);
				
		if(roll_temp < 100){
			Parse_Mems(parsed, roll_temp);								
			// printf("disp2: %d %d %d %d %d\n", parsed[3], parsed[2], parsed[1], parsed[0], parsed[4]);
		}
		
		else{
			parsed[0] = (int) roll_temp % 10;
			parsed[2] = ((int) roll_temp / 10) % 10;
			parsed[3] = ((int) roll_temp / 100) % 10;
			parsed[1] = 0;
			parsed[4] = 0;				
			// printf("disp2: %d %d %d %d %d\n", parsed[3], parsed[2], parsed[1], parsed[0], parsed[4]);
		}
		
		if(parsed[4] < 0 || parsed[3] < 0 || parsed[2] < 0 || parsed[1] < 0 || parsed[0] < 0) Show_Negative();
		else Show();
	}
}
开发者ID:asaha2,项目名称:microprocessor-systems,代码行数:30,代码来源:Thread_DISP2.c

示例6: SPI_DMA_Transfer

/**
*@brief A function that starts a DMA transfer using the buffers provided, on SPI1 using the passed chip select port
*@param[inout] rx A pointer to the receive buffer in Bytes
*@param[in] tx A pointer to the transmit buffer in Bytes
*@param[in] bufferSize The size of the rx and tx buffer
*@param[in] csPort The GPIO port that has the CS line for SPI1
*@param[in] csPin The GPIO pin that the CS line is connected to for SPI1
*@retval None
*/
void SPI_DMA_Transfer(const uint8_t* rx, const uint8_t* tx, const uint8_t bufferSize, GPIO_TypeDef* csPort, uint8_t csPin){
	osMutexWait(dmaId, osWaitForever);//Check that DMA is avaible using mutex

	if((csPort == GPIOE) && (csPin == 0x0008)){
		dmaFromAccFlag = 1; 
	}
	
	if((csPort == WIRELESS_CS_PORT) && (csPin == WIRELESS_CS_PIN)){
		dmaFromWirelessFlag = 1;
	}
	
	//Configure DMA
	DMA2_Stream0->NDTR = bufferSize;
	DMA2_Stream0->M0AR = (uint32_t)rx;

	DMA2_Stream3->NDTR = bufferSize;
	DMA2_Stream3->M0AR = (uint32_t)tx;

	GPIO_ResetBits(csPort, csPin);	//lower CS line

	//Enable DMA
	DMA_Cmd(DMA2_Stream0, ENABLE); // RX
	DMA_Cmd(DMA2_Stream3, ENABLE); // TX
	
}
开发者ID:Dirk7589,项目名称:ECSE426Lab6,代码行数:34,代码来源:spi.c

示例7: behaviour_welcome

/* State behaviour */
void behaviour_welcome(state_ptr state)
{
  /* Set events to react to */

  /* Do state actions */

  /* Set menu */
  osMutexWait(mutex_menuHandle, osWaitForever);
  menu_copy(&menu_welcome, &current_menu);
  osMutexRelease(mutex_menuHandle);

  /* Display menu */
  uint32_t i;
  for (i = 0; i < menu_welcome.item_num; i++)
  {
    while (osMailPut(queue_lcdHandle, (void *) &menu_welcome.items[i]) != osOK)
    {
      osDelay(1);
    }
  }

  /* Do state actions */
  bluetooth_init();
  osDelay(2500);
  entry_to_running(state);
}
开发者ID:outsidersdelaelectronica,项目名称:tiic-2015,代码行数:27,代码来源:state_welcome.c

示例8: spifs_unlink

bool spifs_unlink(const char *filename)
{
    int16_t fileId;
    char cleanname[SPIFS_FILENAME_LEN];
    SPIFlash handler;

    // Clean the filename of problem characters.
    if (!clean_filename(filename, cleanname)) return false;

    // Wait for exclusive access to the SPI master bus.
    osMutexWait(spiMasterMutex, osWaitForever);

    // Open the SPI flash device.
    spi_flash_open(SPI0, SPI_MODE0, false, Freq_1Mbps, &handler);

    // Find a file id associated with the filename.
    fileId = spifs_find_filename(&handler, cleanname);

    // Erase each fileblock associated with the file.
    if (SPIFS_FILEID_VALID(fileId)) spifs_erase_blocks(&handler, fileId);

    // Close the SPI flash device.
    spi_flash_close(&handler);

    // Release exclusive access to the SPI master bus.
    osMutexRelease(spiMasterMutex);

    return true;
}
开发者ID:robgarbanati,项目名称:P9_proto,代码行数:29,代码来源:spi_fs.c

示例9: SevenSegment_SetDisplayValue_Angle

/**
   * @brief Set value to be displayed on the seven-segment display.
   * @param float angle: angle to be displayed
   * @retval None
   */
void SevenSegment_SetDisplayValue_Angle(float angle)
{
	/* We have race conditions. Need to use mutexes to protect these global flags. */
	osMutexWait(segment_mutex, osWaitForever);
	displayed_angle = angle;
	osMutexRelease(segment_mutex);
}
开发者ID:Lone-L,项目名称:MicroP_Labs,代码行数:12,代码来源:seven_segment.c

示例10: SevenSegment_SetDisplayValue_Temp

/**
   * @brief Set value to be displayed on the seven-segment display.
   * @param float angle: angle to be displayed
   * @retval None
   */
void SevenSegment_SetDisplayValue_Temp(float temp)
{
	/* We have race conditions. Need to use mutexes to protect these global flags. */
	osMutexWait(segment_mutex, osWaitForever);
	displayed_temp = temp;
	osMutexRelease(segment_mutex);
}
开发者ID:Lone-L,项目名称:MicroP_Labs,代码行数:12,代码来源:seven_segment.c

示例11: 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

示例12: TC_MutexNestedAcquire

/**
\brief Test case: TC_MutexNestedAcquire
\details
- Create a mutex object
- Obtain a mutex object
- Create a high priority thread that waits for the same mutex
- Recursively acquire and release a mutex object
- Release a mutex
- Verify that every subsequent call released the mutex
- Delete a mutex object
- Mutex object must be released after each acquisition
*/
void TC_MutexNestedAcquire (void) {
  osStatus stat;
  
  /* - Create a mutex object */
  G_MutexId = osMutexCreate (osMutex (Mutex_Nest));
  ASSERT_TRUE (G_MutexId != NULL);

  if (G_MutexId  != NULL) {
    /* - Obtain a mutex object */
    stat = osMutexWait (G_MutexId, 0);
    ASSERT_TRUE (stat == osOK);
    
    if (stat == osOK) {
      /* - Create a high priority thread that will wait for the same mutex */
      G_Mutex_ThreadId = osThreadCreate (osThread (Th_MutexWait), NULL);
      ASSERT_TRUE (G_Mutex_ThreadId != NULL);
    
      /* - Recursively acquire and release a mutex object */
      RecursiveMutexAcquire (5, 5);

      /* - Release a mutex */
      stat = osMutexRelease (G_MutexId);
      ASSERT_TRUE (stat == osOK);

      /* - Verify that every subsequent call released the mutex */
      ASSERT_TRUE (osMutexRelease (G_MutexId) == osErrorResource);
    }
    /* - Delete a mutex object */
    ASSERT_TRUE (osMutexDelete (G_MutexId) == osOK);
  }
}
开发者ID:Goodjamp,项目名称:ble_app_template,代码行数:43,代码来源:RV_Mutex.c

示例13: RTC_Read_datetime

//-------------------------------------------------------------------
//read date time
void RTC_Read_datetime(uint8_t * data,uint8_t flag)
{
	uint8_t temp[3];
	//first read tiem ,then read date, or not time is not run;
	RTC_DateTypeDef sdatestructureget;
  RTC_TimeTypeDef stimestructureget;
	HAL_RTCStateTypeDef status;

	if(data!=NULL)
	{	
		osMutexWait(rtc_mutex, osWaitForever);
		/* Get the RTC current Time */
		HAL_RTC_GetTime(&hrtc, &stimestructureget, RTC_FORMAT_BIN);
		temp[0]=stimestructureget.Hours;
		temp[1]=stimestructureget.Minutes;
		temp[2]=stimestructureget.Seconds;
		
		memcpy(&current_datetime[3],temp,3);
		
		/* Get the RTC current Date */
		HAL_RTC_GetDate(&hrtc, &sdatestructureget, RTC_FORMAT_BIN);
		data[0]=sdatestructureget.Year;
		data[1]=sdatestructureget.Month;
		data[2]=sdatestructureget.Date;
		current_datetime[6]=sdatestructureget.WeekDay;

		memcpy(&current_datetime[0],data,3);

		if(flag==1)
		{
			memcpy(data,temp,3);
		}
		osMutexRelease(rtc_mutex);
	}
}
开发者ID:hlmpost,项目名称:code_backup,代码行数:37,代码来源:eric_rtc.c

示例14: 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

示例15: SevenSegment_TurnOn

/**
   * @brief Activates 7-segment display.
   * @param None
   * @retval None
   */
void SevenSegment_TurnOn(void)
{
	/* We have race conditions. Need to use mutexes to protect these global flags. */
	osMutexWait(segment_mutex, osWaitForever);
	activated = 1;
	osMutexRelease(segment_mutex);
}
开发者ID:Lone-L,项目名称:MicroP_Labs,代码行数:12,代码来源:seven_segment.c


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