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

C++ portENTER_CRITICAL函数代码示例

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

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



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

示例1: vSerialClose

void vSerialClose( xComPortHandle xPort )
{
	uint8_t ucByte;

	/* The parameter is not used. */
	( void ) xPort;

	/* Turn off the interrupts.  We may also want to delete the queues and/or
	re-install the original ISR. */

	vPortFree (serialWorkBuffer);
	vQueueDelete(xRxedChars);
	vQueueDelete(xCharsForTx);

	portENTER_CRITICAL();
	{
		vInterruptOff();
		ucByte = UCSR0B;
		ucByte &= ~(_BV(RXCIE0));
		UCSR0B = ucByte;
	}
	portEXIT_CRITICAL();
}
开发者ID:eddiecastropineda,项目名称:CollegeBound,代码行数:23,代码来源:lib_serial.c


示例2: SetupOneSecondTimer

/* setup a timer so the Restart timer function can be used */
void SetupOneSecondTimer(tTimerId TimerId,
                         unsigned int Timeout,
                         unsigned char RepeatCount,
                         unsigned char Qindex,
                         eMessageType CallbackMsgType,
                         unsigned char MsgOptions)
{
  if (OneSecondTimers[TimerId].Allocated == 0 || TimerId < 0)
  {
    PrintString("Timer not Allocated\r\n");
    return;
  }
  
  portENTER_CRITICAL();
    
  OneSecondTimers[TimerId].RepeatCount = RepeatCount;
  OneSecondTimers[TimerId].Timeout = Timeout;
  OneSecondTimers[TimerId].Qindex = Qindex;
  OneSecondTimers[TimerId].CallbackMsgType = CallbackMsgType;
  OneSecondTimers[TimerId].CallbackMsgOptions = MsgOptions;
    
  portEXIT_CRITICAL();
}
开发者ID:ChrisSewell,项目名称:MetaWatch-Gen2,代码行数:24,代码来源:OneSecondTimers.c


示例3: ValidatorPulseProcessing

/*
*********************************************************************************************************
*                                                UartReadByte()
*
* Description : Receive a single byte.
*
* Argument(s) : number of UART.
*
* Return(s)   : The received byte.
*
* Caller(s)   : Application.
*
* Note(s)     : 
*********************************************************************************************************
*/
void ValidatorPulseProcessing (u32 call_period) {

	static u32 puls_with_cnt = 0;

    if (!GPIO_ReadInputDataBit(VALIDATOR_PULS_IN)) {

    	puls_with_cnt += call_period;
    }

    else if (puls_with_cnt > 0) {

    	if ((puls_with_cnt > ValidatorNV9.PeriodCntMin) && (puls_with_cnt < ValidatorNV9.PeriodCntMax)) {

//    		ValidatorNV9.SynchroFlag   = SET;
    		portENTER_CRITICAL();
    		ValidatorNV9.MoneyQuantity++;
    		portEXIT_CRITICAL();
//    		ValidatorNV9.SynchroFlag   = RESET;
    	}

    	puls_with_cnt = 0;
    }
}
开发者ID:Palladin1,项目名称:Snack_stm32_drv_modbus,代码行数:38,代码来源:nv9usb.c


示例4: __attribute__

/* The preemptive scheduler is defined as "naked" as the full context is saved
on entry as part of the context switch. */
__attribute__((__naked__)) static void vTick( void )
{
	/* Save the context of the interrupted task. */
	portSAVE_CONTEXT_OS_INT();

	#if( configTICK_USE_TC==1 )
		/* Clear the interrupt flag. */
		prvClearTcInt();
	#else
		/* Schedule the COUNT&COMPARE match interrupt in (configCPU_CLOCK_HZ/configTICK_RATE_HZ)
		clock cycles from now. */
		prvScheduleNextTick();
	#endif

	/* Because FreeRTOS is not supposed to run with nested interrupts, put all OS
	calls in a critical section . */
	portENTER_CRITICAL();
		xTaskIncrementTick();
	portEXIT_CRITICAL();

	/* Restore the context of the "elected task". */
	portRESTORE_CONTEXT_OS_INT();
}
开发者ID:Eclo,项目名称:FreeRTOS,代码行数:25,代码来源:port.c


示例5: rtcWrite

//
//  Set clock to new values.
//
static void rtcWrite (struct tm *newTime)
{
  rtcWake ();
  portENTER_CRITICAL ();

  RTC_CCR &= ~RTC_CCR_CLKEN;
  RTC_CCR |=  RTC_CCR_CTCRST;

  RTC_SEC   = newTime->tm_sec;
  RTC_MIN   = newTime->tm_min;
  RTC_HOUR  = newTime->tm_hour;
  RTC_DOM   = newTime->tm_mday;
  RTC_MONTH = newTime->tm_mon + 1;
  RTC_YEAR  = newTime->tm_year + 1900;
  RTC_DOW   = newTime->tm_wday;
  RTC_DOY   = newTime->tm_yday + 1;

  RTC_CCR &= ~RTC_CCR_CTCRST;
  RTC_CCR |=  RTC_CCR_CLKEN;

  portEXIT_CRITICAL ();
  rtcSleep ();
}
开发者ID:kidfiction,项目名称:openDrive,代码行数:26,代码来源:rtc.c


示例6: portTASK_FUNCTION

static portTASK_FUNCTION( vPolledQueueConsumer, pvParameters )
{
    uint16_t usData, usExpectedValue = ( uint16_t ) 0;
    BaseType_t xError = pdFALSE;

    for( ;; ) {
        /* Loop until the queue is empty. */
        while( uxQueueMessagesWaiting( *( ( QueueHandle_t * ) pvParameters ) ) ) {
            if( xQueueReceive( *( ( QueueHandle_t * ) pvParameters ), &usData, pollqNO_DELAY ) == pdPASS ) {
                if( usData != usExpectedValue ) {
                    /* This is not what we expected to receive so an error has
                    occurred. */
                    xError = pdTRUE;

                    /* Catch-up to the value we received so our next expected
                    value should again be correct. */
                    usExpectedValue = usData;
                } else {
                    if( xError == pdFALSE ) {
                        /* Only increment the check variable if no errors have
                        occurred. */
                        portENTER_CRITICAL();
                        xPollingConsumerCount++;
                        portEXIT_CRITICAL();
                    }
                }

                /* Next time round we would expect the number to be one higher. */
                usExpectedValue++;
            }
        }

        /* Now the queue is empty we block, allowing the producer to place more
        items in the queue. */
        vTaskDelay( pollqCONSUMER_DELAY );
    }
} /*lint !e818 Function prototype must conform to API. */
开发者ID:peterliu2,项目名称:tivaWare,代码行数:37,代码来源:PollQ.c


示例7: xSerialPortInitMinimal

/*-----------------------------------------------------------*/
xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
{
	/* Initialise the hardware. */
	portENTER_CRITICAL();
	{
		/* Create the queues used by the com test task. */
		xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof(signed char) );
		xCharsForTx = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof(signed char) );

		if( xRxedChars == 0 )
		{
			queueFail = pdTRUE;
		}

		if( xCharsForTx == 0 )
		{
			queueFail = pdTRUE;
		}

		/* Initialize UART asynchronous mode */
		BGR0 = configCLKP1_CLOCK_HZ / ulWantedBaud;

		SCR0 = 0x17;	/* 8N1 */
		SMR0 = 0x0d;	/* enable SOT3, Reset, normal mode */
		SSR0 = 0x02;	/* LSB first, enable receive interrupts */

		PIER08_IE2 = 1; /* enable input */
		DDR08_D2 = 0;	/* switch P08_2 to input */
		DDR08_D3 = 1;	/* switch P08_3 to output */
	}
	portEXIT_CRITICAL();

	/* Unlike other ports, this serial code does not allow for more than one
	com port.  We therefore don't return a pointer to a port structure and can
	instead just return NULL. */
	return NULL;
}
开发者ID:BuiChien,项目名称:FreeRTOS-TM4C123GXL,代码行数:38,代码来源:serial.c


示例8: prvMACB_ISR_NonNakedBehaviour

static long prvMACB_ISR_NonNakedBehaviour( void )
{

  // Variable definitions can be made now.
  volatile unsigned long ulIntStatus, ulEventStatus;
  long xHigherPriorityTaskWoken = FALSE;

  // Find the cause of the interrupt.
  ulIntStatus = AVR32_MACB.isr;
  ulEventStatus = AVR32_MACB.rsr;

  if( ( ulIntStatus & AVR32_MACB_IDR_RCOMP_MASK ) || ( ulEventStatus & AVR32_MACB_REC_MASK ) )
  {
    // A frame has been received, signal the IP task so it can process
    // the Rx descriptors.
    portENTER_CRITICAL();
#ifdef FREERTOS_USED
    xSemaphoreGiveFromISR( xSemaphore, &xHigherPriorityTaskWoken );
#else
    DataToRead = TRUE;   
#endif      
    portEXIT_CRITICAL();
    AVR32_MACB.rsr =  AVR32_MACB_REC_MASK;
    AVR32_MACB.rsr;
  }

  if( ulIntStatus & AVR32_MACB_TCOMP_MASK )
  {
    // A frame has been transmitted.  Mark all the buffers used by the
    // frame just transmitted as free again.
    vClearMACBTxBuffer();
    AVR32_MACB.tsr =  AVR32_MACB_TSR_COMP_MASK;
    AVR32_MACB.tsr;
  }

  return ( xHigherPriorityTaskWoken );
}
开发者ID:DIYzzuzpb,项目名称:PIC32USB,代码行数:37,代码来源:macb.c


示例9: portTASK_FUNCTION

static portTASK_FUNCTION( vPolledQueueProducer, pvParameters )
{
unsigned short usValue = ( unsigned short ) 0;
signed portBASE_TYPE xError = pdFALSE, xLoop;

	for( ;; )
	{		
		for( xLoop = 0; xLoop < pollqVALUES_TO_PRODUCE; xLoop++ )
		{
			/* Send an incrementing number on the queue without blocking. */
			if( xQueueSend( *( ( xQueueHandle * ) pvParameters ), ( void * ) &usValue, pollqNO_DELAY ) != pdPASS )
			{
				/* We should never find the queue full so if we get here there
				has been an error. */
				xError = pdTRUE;
			}
			else
			{
				if( xError == pdFALSE )
				{
					/* If an error has ever been recorded we stop incrementing the
					check variable. */
					portENTER_CRITICAL();
						xPollingProducerCount++;
					portEXIT_CRITICAL();
				}

				/* Update the value we are going to post next time around. */
				usValue++;
			}
		}

		/* Wait before we start posting again to ensure the consumer runs and
		empties the queue. */
		vTaskDelay( pollqPRODUCER_DELAY );
	}
}  /*lint !e818 Function prototype must conform to API. */
开发者ID:DonjetaE,项目名称:FreeRTOS,代码行数:37,代码来源:PollQ.c


示例10: esp_task_wdt_delete

void esp_task_wdt_delete() {
    TaskHandle_t handle=xTaskGetCurrentTaskHandle();
    wdt_task_t *wdttask=wdt_task_list;
    portENTER_CRITICAL(&taskwdt_spinlock);

    //Wdt task list can't be empty
    if (!wdt_task_list) {
        ESP_LOGE(TAG, "task_wdt_delete: No tasks in list?");
        portEXIT_CRITICAL(&taskwdt_spinlock);
        return;
    }
    if (handle==wdt_task_list) {
        //Current task is first on list.
        wdt_task_list=wdt_task_list->next;
        free(wdttask);
    } else {
        //Find current task in list
        if (wdt_task_list->task_handle==handle) {
            //Task is the very first one.
            wdt_task_t *freeme=wdt_task_list;
            wdt_task_list=wdt_task_list->next;
            free(freeme);
            portEXIT_CRITICAL(&taskwdt_spinlock);
            return;
        }
        while (wdttask->next!=NULL && wdttask->next->task_handle!=handle) wdttask=wdttask->next;
        if (!wdttask->next) {
            ESP_LOGE(TAG, "task_wdt_delete: Task never called task_wdt_feed!");
            portEXIT_CRITICAL(&taskwdt_spinlock);
            return;
        }
        wdt_task_t *freeme=wdttask->next;
        wdttask->next=wdttask->next->next;
        free(freeme);
    }
    portEXIT_CRITICAL(&taskwdt_spinlock);
}
开发者ID:mr-nice,项目名称:esp-idf,代码行数:37,代码来源:task_wdt.c


示例11: xSerialPortInitMinimal

/*
 * See the serial2.h header file.
 */
xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
{
    xComPortHandle xReturn = serHANDLE;

    /* Create the queues used to hold Rx and Tx characters. */
    xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed char ) );
    xCharsForTx = xQueueCreate( uxQueueLength + 1, ( unsigned portBASE_TYPE ) sizeof( signed char ) );

    /* If the queues were created correctly then setup the serial port
    hardware. */
    if( ( xRxedChars != serINVALID_QUEUE ) && ( xCharsForTx != serINVALID_QUEUE ) ) {
        PMC_EnablePeripheral( AT91C_ID_US0 );
        portENTER_CRITICAL();
        {
            USART_Configure( serCOM0, ( AT91C_US_CHRL_8_BITS | AT91C_US_PAR_NONE ), ulWantedBaud, configCPU_CLOCK_HZ );

            /* Enable Rx and Tx. */
            USART_SetTransmitterEnabled( serCOM0, pdTRUE );
            USART_SetReceiverEnabled( serCOM0, pdTRUE );

            /* Enable the Rx interrupts.  The Tx interrupts are not enabled
            until there are characters to be transmitted. */
            serCOM0->US_IER = AT91C_US_RXRDY;

            /* Enable the interrupts in the AIC. */
            AIC_ConfigureIT( AT91C_ID_US0, AT91C_AIC_PRIOR_LOWEST, ( void (*)( void ) ) vSerialISR );
            AIC_EnableIT( AT91C_ID_US0 );
        }
        portEXIT_CRITICAL();
    } else {
        xReturn = ( xComPortHandle ) 0;
    }

    /* This demo file only supports a single port but we have to return
    something to comply with the standard demo header file. */
    return xReturn;
}
开发者ID:peterliu2,项目名称:FreeRTOS,代码行数:40,代码来源:serial.c


示例12: xSerialPutChar

signed portBASE_TYPE xSerialPutChar( xComPortHandle pxPort, signed char cOutChar, portTickType xBlockTime )
{
portBASE_TYPE xReturn = pdTRUE;

	portENTER_CRITICAL();
	{
		/* If the UART FIFO is full we can block posting the new data on the
		Tx queue. */
		if( XUartLite_mIsTransmitFull( XPAR_RS232_UART_BASEADDR ) )
		{
			if( xQueueSend( xCharsForTx, &cOutChar, xBlockTime ) != pdPASS )
			{
				xReturn = pdFAIL;
			}
		}
		/* Otherwise, if there is data already in the queue we should add the
		new data to the back of the queue to ensure the sequencing is 
		maintained. */
		else if( uxQueueMessagesWaiting( xCharsForTx ) )
		{
			if( xQueueSend( xCharsForTx, &cOutChar, xBlockTime ) != pdPASS )
			{
				xReturn = pdFAIL;
			}			
		}
		/* If the UART FIFO is not full and there is no data already in the
		queue we can write directly to the FIFO without disrupting the 
		sequence. */
		else
		{
			XIo_Out32( XPAR_RS232_UART_BASEADDR + XUL_TX_FIFO_OFFSET, cOutChar );
		}
	}
	portEXIT_CRITICAL();

	return xReturn;
}
开发者ID:LinuxJohannes,项目名称:FreeRTOS,代码行数:37,代码来源:serial.c


示例13: xSerialPortInitMinimal

xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned portBASE_TYPE uxQueueLength )
{
unsigned long ulBaudRateCounter;
unsigned char ucByte;

	portENTER_CRITICAL();
	{
		/* Create the queues used by the com test task. */
		xRxedChars = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed char ) );
		xCharsForTx = xQueueCreate( uxQueueLength, ( unsigned portBASE_TYPE ) sizeof( signed char ) );

		/* Calculate the baud rate register value from the equation in the
		data sheet. */
		ulBaudRateCounter = ( configCPU_CLOCK_HZ / ( serBAUD_DIV_CONSTANT * ulWantedBaud ) ) - ( unsigned long ) 1;

		/* Set the baud rate. */	
		ucByte = ( unsigned char ) ( ulBaudRateCounter & ( unsigned long ) 0xff );	
		outb( UBRRL, ucByte );

		ulBaudRateCounter >>= ( unsigned long ) 8;
		ucByte = ( unsigned char ) ( ulBaudRateCounter & ( unsigned long ) 0xff );	
		outb( UBRRH, ucByte );

		/* Enable the Rx interrupt.  The Tx interrupt will get enabled
		later. Also enable the Rx and Tx. */
		outb( UCSRB, serRX_INT_ENABLE | serRX_ENABLE | serTX_ENABLE );

		/* Set the data bits to 8. */
		outb( UCSRC, serUCSRC_SELECT | serEIGHT_DATA_BITS );
	}
	portEXIT_CRITICAL();
	
	/* Unlike other ports, this serial code does not allow for more than one
	com port.  We therefore don't return a pointer to a port structure and can
	instead just return NULL. */
	return NULL;
}
开发者ID:RitikaGupta1207,项目名称:freertos,代码行数:37,代码来源:serial.c


示例14: AddUser

static void AddUser(unsigned char User,unsigned int CrystalTicks)
{
  portENTER_CRITICAL();
  
  /* minimum value of 1 tick */
  if ( CrystalTicks < 1 )
  {
    CrystalTicks = 1;
  }  
  
  unsigned int CaptureTime = TA0R + CrystalTicks;

  /* clear ifg, add to ccr register, enable interrupt */
  switch (User)
  {
  case 0: TA0CCTL0 = 0; TA0CCR0 = CaptureTime; TA0CCTL0 = CCIE; break;
  case 1: TA0CCTL1 = 0; TA0CCR1 = CaptureTime; TA0CCTL1 = CCIE; break;
  case 2: TA0CCTL2 = 0; TA0CCR2 = CaptureTime; TA0CCTL2 = CCIE; break;
  case 3: TA0CCTL3 = 0; TA0CCR3 = CaptureTime; TA0CCTL3 = CCIE; break;
  case 4: TA0CCTL4 = 0; TA0CCR4 = CaptureTime; TA0CCTL4 = CCIE; break;
  default: break;
    
  }
  
  /* start counting up in continuous mode if not already doing so */
  if ( Timer0Users == 0 )
  {
    TA0CTL |= TASSEL_1 | MC_2 | ID_2; 
  }
  
  /* keep track of users */
  Timer0Users |= (1 << User);
  
  portEXIT_CRITICAL();
  
}
开发者ID:Alucard3571,项目名称:MetaWatch-WDS11x,代码行数:36,代码来源:hal_rtos_timer.c


示例15: vParTestSetLED

void vParTestSetLED( unsigned portBASE_TYPE uxLED, signed portBASE_TYPE xValue )
{
unsigned char ucLED = 1U;

	/* Only attempt to set the LED if it is in range. */
	if( uxLED < partstMAX_LED )
	{
		ucLED <<= ( unsigned char ) uxLED;

		portENTER_CRITICAL();
		{
			if( xValue == pdFALSE )
			{
				ucGPIOState &= ~ucLED;
			}
			else
			{
				ucGPIOState |= ucLED;
			}
			XGpio_DiscreteWrite( &xOutputGPIOInstance, uxGPIOOutputChannel, ucGPIOState );
		}
		portEXIT_CRITICAL();
	}
}
开发者ID:niesteszeck,项目名称:FreeRTOS,代码行数:24,代码来源:ParTest.c


示例16: RxThread

 void RxThread()
 {
     while (1)
     {
         os_sem_wait(&rxSem);
         portENTER_CRITICAL();
         // we read the packet received to our assembly buffer
         bool result = readEP_NB(rxData, &rxSize);
         portEXIT_CRITICAL();
         if (!result)
         {
             diewith(0x80000CCC);
         }
         for (uint32_t i = 0; i < rxSize; i++)
         {
           /// @todo (balazs.racz) this needs to be replaced with something
           /// that works in the new select based model.
           //os_mq_send(rxQ, rxData + i);
         }
         rxSize = 0;
         // We reactivate the endpoint to receive next characters
         // readStart(EPBULK_OUT, MAX_PACKET_SIZE_EPBULK);
     }
 }
开发者ID:kphannan,项目名称:openmrn,代码行数:24,代码来源:mbed_usbserial.cpp


示例17: vLogStackWatermark

/*******************************************************************************
 * FUNCTION: vLogStackWatermark
 *
 * PARAMETERS:
 * ~ szTaskName     - Task name.
 * ~ usWatermark    - Value for watermark.
 *
 * RETURN:
 * ~ void
 *
 * DESCRIPTIONS:
 * Log the RTOS low stack error.
 *
 *******************************************************************************/
void vLogStackWatermark(const char* szTaskName, unsigned short usWatermark)
{
    // Convert the watermark to string.
    char szWatermark[6];
    prv_vUShortToString(usWatermark, szWatermark);



    // Open the log file.
    xSemaphoreTake(xSdCardMutex, portMAX_DELAY);
    portENTER_CRITICAL();
    FSFILE *pxLogFile = FSfopen(pucLogFilePath, "a");


    // Write the message.
    const char szTxt1[] = "[Stack Error] ";
    FSfwrite(szTxt1, 1, sizeof(szTxt1) - 1, pxLogFile);
    FSfwrite(szTaskName, 1, strlen(szTaskName), pxLogFile);

    const char szTxt2[] = "    Watermark: ";
    FSfwrite(szTxt2, 1, sizeof(szTxt2) - 1, pxLogFile);
    FSfwrite(szWatermark, 1, strlen(szWatermark), pxLogFile);
    
    const char szTxt3[] = "    Firmware: ";
    FSfwrite(szTxt3, 1, sizeof(szTxt3) - 1, pxLogFile);
    FSfwrite(szFirmwareVersion, 1, strlen(szFirmwareVersion), pxLogFile);
    
    const char szCrLf[] = "\r\n";
    FSfwrite(szCrLf, 1, sizeof(szCrLf) - 1, pxLogFile);


    // Close the log file.
    FSfclose(pxLogFile);
    portEXIT_CRITICAL();
    xSemaphoreGive(xSdCardMutex);
}
开发者ID:ReRoKit,项目名称:Rero-Main-Controller-Firmware,代码行数:50,代码来源:Log.c


示例18: xMutexGive

signed portBASE_TYPE xMutexGive( xMutexHandle pxMutex, portBASE_TYPE Release )
{
    portENTER_CRITICAL( );
    if ( pxMutex->pxOwner != xTaskGetCurrentTaskHandle( ) )
    {
        portEXIT_CRITICAL( );
        return pdFALSE;
    }

    if ( Release )
        pxMutex->uxCount = 0;
    else
    {
        if ( --pxMutex->uxCount != 0 )
        {
            portEXIT_CRITICAL( );
            return pdFALSE;
        }
    }

    if( !listLIST_IS_EMPTY( &pxMutex->xTasksWaitingToTake ) )
    {
        pxMutex->pxOwner = (xTaskHandle) listGET_OWNER_OF_HEAD_ENTRY( ( &pxMutex->xTasksWaitingToTake ) );
        pxMutex->uxCount = 1;

        if( xTaskRemoveFromEventList( &pxMutex->xTasksWaitingToTake ) == pdTRUE )
            taskYIELD( );
    }
    else
    {
        pxMutex->pxOwner = NULL;
    }

    portEXIT_CRITICAL( );
    return pdTRUE;
}
开发者ID:119,项目名称:bcm-wiced-sdk,代码行数:36,代码来源:Mutex_FreeRTOS.c


示例19: APP_Background

/////////////////////////////////////////////////////////////////////////////
// This task is running endless in background
/////////////////////////////////////////////////////////////////////////////
void APP_Background(void)
{
  // clear LCD screen
  MIOS32_LCD_Clear();

  // endless loop: print status information on LCD
  while( 1 ) {
    // new message requested?
    // TODO: add FreeRTOS specific queue handling!
    u8 new_msg = PRINT_MSG_NONE;
    portENTER_CRITICAL(); // port specific FreeRTOS function to disable tasks (nested)
    if( print_msg ) {
      new_msg = print_msg;
      print_msg = PRINT_MSG_NONE; // clear request
    }
    portEXIT_CRITICAL(); // port specific FreeRTOS function to enable tasks (nested)

    switch( new_msg ) {
      case PRINT_MSG_INIT:
        MIOS32_LCD_CursorSet(0, 0);
        MIOS32_LCD_PrintString("see README.txt   ");
        MIOS32_LCD_CursorSet(0, 1);
        MIOS32_LCD_PrintString("for details     ");
	break;

      case PRINT_MSG_STATUS:
      {
        MIOS32_LCD_CursorSet(0, 0);

	// request status screen again (will stop once a new screen is requested by another task)
	print_msg = PRINT_MSG_STATUS;
      }
      break;
    }
  }
}
开发者ID:glocklueng,项目名称:MIOS32,代码行数:39,代码来源:app.c


示例20: vCounterControlTask

/*
 * Controller task as described above.
 */
static void vCounterControlTask( void * pvParameters )
{
unsigned long ulLastCounter;
short sLoops;
short sError = pdFALSE;
const char * const pcTaskStartMsg = "Priority manipulation tasks started.\r\n";
const char * const pcTaskFailMsg = "Priority manipulation Task Failed\r\n";

	/* Just to stop warning messages. */
	( void ) pvParameters;

	/* Queue a message for printing to say the task has started. */
	vPrintDisplayMessage( &pcTaskStartMsg );

	for( ;; )
	{
		/* Start with the counter at zero. */
		ulCounter = ( unsigned long ) 0;

		/* First section : */

		/* Check the continuous count task is running. */
		for( sLoops = 0; sLoops < priLOOPS; sLoops++ )
		{
			/* Suspend the continuous count task so we can take a mirror of the
			shared variable without risk of corruption. */
			vTaskSuspend( xContinuousIncrementHandle );
				ulLastCounter = ulCounter;
			vTaskResume( xContinuousIncrementHandle );
			
			/* Now delay to ensure the other task has processor time. */
			vTaskDelay( priSLEEP_TIME );

			/* Check the shared variable again.  This time to ensure mutual 
			exclusion the whole scheduler will be locked.  This is just for
			demo purposes! */
			vTaskSuspendAll();
			{
				if( ulLastCounter == ulCounter )
				{
					/* The shared variable has not changed.  There is a problem
					with the continuous count task so flag an error. */
					sError = pdTRUE;
					xTaskResumeAll();
						vPrintDisplayMessage( &pcTaskFailMsg );
					vTaskSuspendAll();
				}
			}
			xTaskResumeAll();
		}


		/* Second section: */

		/* Suspend the continuous counter task so it stops accessing the shared variable. */
		vTaskSuspend( xContinuousIncrementHandle );

		/* Reset the variable. */
		ulCounter = ( unsigned long ) 0;

		/* Resume the limited count task which has a higher priority than us.
		We should therefore not return from this call until the limited count
		task has suspended itself with a known value in the counter variable. 
		The scheduler suspension is not necessary but is included for test
		purposes. */
		vTaskSuspendAll();
			vTaskResume( xLimitedIncrementHandle );
		xTaskResumeAll();

		/* Does the counter variable have the expected value? */
		if( ulCounter != priMAX_COUNT )
		{
			sError = pdTRUE;
			vPrintDisplayMessage( &pcTaskFailMsg );
		}

		if( sError == pdFALSE )
		{
			/* If no errors have occurred then increment the check variable. */
			portENTER_CRITICAL();
				usCheckVariable++;
			portEXIT_CRITICAL();
		}

		#if configUSE_PREEMPTION == 0
			taskYIELD();
		#endif

		/* Resume the continuous count task and do it all again. */
		vTaskResume( xContinuousIncrementHandle );
	}
}
开发者ID:Cuixiaoxia198106,项目名称:freertos-sparc,代码行数:95,代码来源:dynamic.c



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


鲜花

握手

雷人

路过

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

请发表评论

全部评论

专题导读
上一篇:
C++ portEXIT_CRITICAL函数代码示例发布时间:2022-05-30
下一篇:
C++ portEND_SWITCHING_ISR函数代码示例发布时间: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