本文整理汇总了C++中portENTER_CRITICAL函数的典型用法代码示例。如果您正苦于以下问题:C++ portENTER_CRITICAL函数的具体用法?C++ portENTER_CRITICAL怎么用?C++ portENTER_CRITICAL使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。
在下文中一共展示了portENTER_CRITICAL函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的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();
}
示例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();
}
示例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;
}
}
示例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();
}
示例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 ();
}
示例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. */
示例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;
}
示例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 );
}
示例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. */
示例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);
}
示例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;
}
示例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;
}
示例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;
}
示例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();
}
示例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();
}
}