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


C++ osMutexRelease函数代码示例

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


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

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

示例2: udpInvokeRxCallback

error_t udpInvokeRxCallback(NetInterface *interface, const IpPseudoHeader *pseudoHeader,
   const UdpHeader *header, const ChunkedBuffer *buffer, size_t offset)
{
   uint_t i;
   void *params;
   UdpRxCallbackDesc *entry;

   //This flag tells whether a matching entry has been found
   bool_t found = FALSE;

   //Acquire exclusive access to the callback table
   osMutexAcquire(udpCallbackMutex);

   //Loop through the table
   for(i = 0; i < UDP_CALLBACK_TABLE_SIZE; i++)
   {
      //Point to the current entry
      entry = &udpCallbackTable[i];

      //Check whether the entry is currently in used
      if(entry->callback != NULL)
      {
         //Bound to a particular interface?
         if(entry->interface == NULL || entry->interface == interface)
         {
            //Does the specified port number match the current entry?
            if(entry->port == ntohs(header->destPort))
            {
               //Retrieve callback parameters
               params = entry->params;

               //Release mutex to prevent any deadlock
               if(params == NULL)
                  osMutexRelease(udpCallbackMutex);

               //Invoke user callback function
               entry->callback(interface, pseudoHeader,
                  header, buffer, offset, params);

               //Acquire mutex
               if(params == NULL)
                  osMutexAcquire(udpCallbackMutex);

               //A matching entry was found
               found = TRUE;
            }
         }
      }
   }

   //Release exclusive access to the callback table
   osMutexRelease(udpCallbackMutex);

   //Return status code
   return found ? NO_ERROR : ERROR_PORT_UNREACHABLE;
}
开发者ID:rpc-fw,项目名称:analyzer,代码行数:56,代码来源:udp.c

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

示例4: Thread_Mutex

void Thread_Mutex(void const *argument) {
  osStatus status;

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

    status = osMutexWait(mid_Thread_Mutex, NULL);
    switch(status) {
      case osOK:
        ; // Use protected code here...
        osMutexRelease(mid_Thread_Mutex);
        break;
      case osErrorTimeoutResource:
        break;
      case osErrorResource:
        break;
      case osErrorParameter:
        break;
      case osErrorISR:
        break;
      default:
        break;
    }

    osThreadYield();        // suspend thread
  }
}
开发者ID:CheMosaico,项目名称:RTX,代码行数:27,代码来源:Mutex.c

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

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

示例7: memPoolFree

void memPoolFree(void *p)
{
//Use fixed-size blocks allocation?
#if (MEM_POOL_SUPPORT == ENABLED)
   uint_t i;

   //Acquire exclusive access to the memory pool
   osMutexAcquire(memPoolMutex);

   //Loop through allocation table
   for(i = 0; i < MEM_POOL_BUFFER_COUNT; i++)
   {
      if(memPool[i] == p)
      {
         //Mark the current block as free
         memPoolAllocTable[i] = FALSE;
         //Exit immediately
         break;
      }
   }

   //Release exclusive access to the memory pool
   osMutexRelease(memPoolMutex);
#else
   //Release memory block
   osMemFree(p);
#endif
}
开发者ID:hyper123,项目名称:CycloneTCP,代码行数:28,代码来源:tcp_ip_stack_mem.c

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

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

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

示例11: SevenSegment_SetDisplayMode

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

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

示例13: SevenSegment_TurnOff

/**
   * @brief Deactivates 7-segment display and turn off the LEDs.
   * @param None
   * @retval None
   */
void SevenSegment_TurnOff(void)
{
	osMutexWait(segment_mutex, osWaitForever);
	GPIOE->ODR &= 0x000F;	/* Clear the bits corresponding to GPIO_PIN_4 to GPIO_PIN_15 */
	activated = 0;
	osMutexRelease(segment_mutex);
}
开发者ID:Lone-L,项目名称:MicroP_Labs,代码行数:12,代码来源:seven_segment.c

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

示例15: Th_LowPrioJob

/*-----------------------------------------------------------------------------
 * Low priority job used for priority inversion test
 *----------------------------------------------------------------------------*/
void Th_LowPrioJob (void const *arg) {
  osThreadId *ctrl_id = (osThreadId *)arg;
  osStatus    stat;
  uint32_t    i;

  /* Obtain a mutex object */
  stat = osMutexWait (G_MutexId, 0);
  ASSERT_TRUE (stat == osOK);

  if (stat == osOK) {
    /* Mutex acquired, inform control thread */
    osSignalSet (*ctrl_id, (1 << 0));
    
    /* Set mark into execution array */
    for (i = 0; i < 3; i++) {
      if (G_ExecArr[i] == 0) {
        G_ExecArr[i] = 'L';             /* L as Low priority job              */

        /* Inform control thread */
        osSignalSet (*ctrl_id, (1 << 1));
        break;
      }
    }
    ASSERT_TRUE (osMutexRelease (G_MutexId) == osOK);
  }
}
开发者ID:Goodjamp,项目名称:ble_app_template,代码行数:29,代码来源:RV_Mutex.c


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