interrupt void prvSelectButtonInterrupt( void ) { /* Define the message sent to the LCD task from this interrupt. */ static const xQueueMessage xMessage = { mainMESSAGE_BUTTON_SEL, ( unsigned long ) "Select Interrupt" }; portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* This is the interrupt handler for the joystick select button input. The button has been pushed, write a message to the LCD via the LCD task. */ xQueueSendFromISR( xLCDQueue, &xMessage, &xHigherPriorityTaskWoken ); P2IFG = 0; /* If writing to xLCDQueue caused a task to unblock, and the unblocked task has a priority equal to or above the task that this interrupt interrupted, then lHigherPriorityTaskWoken will have been set to pdTRUE internally within xQueuesendFromISR(), and portEND_SWITCHING_ISR() will ensure that this interrupt returns directly to the higher priority unblocked task. */ portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); }
void GPIO0_IRQHandler() { portBASE_TYPE xSwitchRequired1; if (Chip_PININT_GetFallStates(LPC_GPIO_PIN_INT)&PININTCH0) { Chip_PININT_ClearIntStatus(LPC_GPIO_PIN_INT,PININTCH0); //xSemaphoreGiveFromISR(xSemaphore,&xSwitchRequired1); uint8_t aux=0; xQueueSendFromISR( xQueue1, ( void * ) &aux, &xSwitchRequired1); //NO USAR - xSemaphoreGive(xSemaphore); } portEND_SWITCHING_ISR(xSwitchRequired1); }
void EXTI9_5_IRQHandler( void ) { /* Define the message sent to the LCD task from this interrupt. */ const xQueueMessage xMessage = { mainMESSAGE_BUTTON_SEL, ( unsigned long ) "Select Interrupt!" }; long lHigherPriorityTaskWoken = pdFALSE; /* This is the interrupt handler for the joystick select button input. The button has been pushed, write a message to the LCD via the LCD task. */ xQueueSendFromISR( xLCDQueue, &xMessage, &lHigherPriorityTaskWoken ); EXTI_ClearITPendingBit( SEL_BUTTON_EXTI_LINE ); /* If writing to xLCDQueue caused a task to unblock, and the unblocked task has a priority equal to or above the task that this interrupt interrupted, then lHigherPriorityTaskWoken will have been set to pdTRUE internally within xQueuesendFromISR(), and portEND_SWITCHING_ISR() will ensure that this interrupt returns directly to the higher priority unblocked task. */ portEND_SWITCHING_ISR( lHigherPriorityTaskWoken ); }
/* * UART RX interrupt service routine. */ interrupt (UART1RX_VECTOR) wakeup vRxISR( void ) { signed char cChar; portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* Get the character from the UART and post it on the queue of Rxed characters. */ cChar = U1RXBUF; xQueueSendFromISR( xRxedChars, &cChar, &xHigherPriorityTaskWoken ); if( xHigherPriorityTaskWoken ) { /*If the post causes a task to wake force a context switch as the woken task may have a higher priority than the task we have interrupted. */ taskYIELD(); } }
/* * UART RX interrupt service routine. */ __interrupt void UART2_RxISR (void) { signed portCHAR cChar; portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* Get the character from the UART and post it on the queue of Rxed characters. */ cChar = RDR02; xQueueSendFromISR( xRxedChars, &cChar, &xHigherPriorityTaskWoken ); if( xHigherPriorityTaskWoken ) { /*If the post causes a task to wake force a context switch as the woken task may have a higher priority than the task we have interrupted. */ portYIELD_FROM_ISR(); } }
/* Serial port ISR. This can cause a context switch so is not defined as a standard ISR using the __irq keyword. Instead a wrapper function is defined within serialISR.s79 which in turn calls this function. See the port documentation on the FreeRTOS.org website for more information. */ __arm void vSerialISR( void ) { unsigned short usStatus; signed char cChar; portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* What caused the interrupt? */ usStatus = UART_FlagStatus( UART0 ); if( usStatus & UART_TxHalfEmpty ) { /* The interrupt was caused by the THR becoming empty. Are there any more characters to transmit? */ if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE ) { /* A character was retrieved from the queue so can be sent to the THR now. */ UART0->TxBUFR = cChar; } else { /* Queue empty, nothing to send so turn off the Tx interrupt. */ serINTERRUPT_OFF(); } } if( usStatus & UART_RxBufFull ) { /* The interrupt was caused by a character being received. Grab the character from the RHR and place it in the queue of received characters. */ cChar = UART0->RxBUFR; xQueueSendFromISR( xRxedChars, &cChar, &xHigherPriorityTaskWoken ); } /* If a task was woken by either a character being received or a character being transmitted then we may need to switch to another task. */ portEND_SWITCHING_ISR( xHigherPriorityTaskWoken ); /* End the interrupt in the EIC. */ portCLEAR_EIC(); }
/* Serial port ISR. This can cause a context switch so is not defined as a standard ISR using the __irq keyword. Instead a wrapper function is defined within serialISR.s79 which in turn calls this function. See the port documentation on the FreeRTOS.org website for more information. */ __arm void vSerialISR( void ) { unsigned long ulStatus; signed char cChar; portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* What caused the interrupt? */ ulStatus = serCOM0->US_CSR &= serCOM0->US_IMR; if( ulStatus & AT91C_US_TXRDY ) { /* The interrupt was caused by the THR becoming empty. Are there any more characters to transmit? */ if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE ) { /* A character was retrieved from the queue so can be sent to the THR now. */ serCOM0->US_THR = cChar; } else { /* Queue empty, nothing to send so turn off the Tx interrupt. */ vInterruptOff(); } } if( ulStatus & AT91C_US_RXRDY ) { /* The interrupt was caused by a character being received. Grab the character from the RHR and place it in the queue or received characters. */ cChar = serCOM0->US_RHR; xQueueSendFromISR( xRxedChars, &cChar, &xHigherPriorityTaskWoken ); } /* If a task was woken by either a character being received or a character being transmitted then we may need to switch to another task. */ portEND_SWITCHING_ISR( xHigherPriorityTaskWoken ); /* End the interrupt in the AIC. */ AT91C_BASE_AIC->AIC_EOICR = 0; }
void vApplicationTickHook( void ) { static unsigned long ulCounter = 0; static const unsigned long ulCheckFrequency = 5000UL / portTICK_RATE_MS; long lHigherPriorityTaskWoken = pdFALSE; /* Define the status message that is sent to the LCD task. By default the status is PASS. */ static xQueueMessage xStatusMessage = { mainMESSAGE_STATUS, pdPASS }; /* This is called from within the tick interrupt and performs the 'check' functionality as described in the comments at the top of this file. Is it time to perform the 'check' functionality again? */ ulCounter++; if( ulCounter >= ulCheckFrequency ) { /* See if the standard demo tasks are executing as expected, changing the message that is sent to the LCD task from PASS to an error code if any tasks set reports an error. */ if( xAreDynamicPriorityTasksStillRunning() != pdPASS ) { xStatusMessage.lMessageValue = mainERROR_DYNAMIC_TASKS; } if( xAreComTestTasksStillRunning() != pdPASS ) { xStatusMessage.lMessageValue = mainERROR_COM_TEST; } if( xAreGenericQueueTasksStillRunning() != pdPASS ) { xStatusMessage.lMessageValue = mainERROR_GEN_QUEUE_TEST; } /* As this is the tick hook the lHigherPriorityTaskWoken parameter is not needed (a context switch is going to be performed anyway), but it must still be provided. */ xQueueSendFromISR( xLCDQueue, &xStatusMessage, &lHigherPriorityTaskWoken ); ulCounter = 0; } }
static __interrupt void prvUSCI_A1_ISR( void ) { signed char cChar; portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; while( ( UCA1IFG & UCRXIFG ) != 0 ) { /* Get the character from the UART and post it on the queue of Rxed characters. */ cChar = UCA1RXBUF; xQueueSendFromISR( xRxedChars, &cChar, &xHigherPriorityTaskWoken ); } /* If there is a Tx interrupt pending and the tx interrupts are enabled. */ if( ( UCA1IFG & UCTXIFG ) != 0 ) { /* The previous character has been transmitted. See if there are any further characters waiting transmission. */ if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE ) { /* There was another character queued - transmit it now. */ UCA1TXBUF = cChar; } else { /* There were no other characters to transmit - disable the Tx interrupt. */ UCA1IE &= ~UCTXIE; } } __bic_SR_register_on_exit( SCG1 + SCG0 + OSCOFF + CPUOFF ); /* If writing to a queue caused a task to unblock, and the unblocked task has a priority equal to or above the task that this interrupt interrupted, then lHigherPriorityTaskWoken will have been set to pdTRUE internally within xQueuesendFromISR(), and portEND_SWITCHING_ISR() will ensure that this interrupt returns directly to the higher priority unblocked task. THIS MUST BE THE LAST THING DONE IN THE ISR. */ portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); }
/** * Bus UART RX interrupt. */ void bus_rxISR( void ) { uint8_t byte; /* Get the character from the UART and post it on the queue of Rxed characters. */ byte = USART_ReceiveData(USART1); if( xQueueSendFromISR(debug_rx, &byte, pdFALSE ) ) { /*If the post causes a task to wake force a context switch as the woken task may have a higher priority than the task we have interrupted. */ taskYIELD(); } #ifdef HAVE_POWERSAVE power_interrupt_epilogue(); #endif }
portBASE_TYPE EncolarEventoFromISR (Modulo_t * receptor, Signal_t senial, int valor) { //xQueueHandle colaEventos = getColaEventos(receptor->prioridad); portBASE_TYPE cambiarCtx = pdFALSE; /*Evento_t evn; evn.receptor = receptor; evn.signal = senial; evn.valor = valor; */ EventoDriver_t msg; msg.codigo = 3; //timeoutSalud msg.dato = 0; xQueueSendFromISR(colaEventosDrivers, &msg, &cambiarCtx); //xQueueSendFromISR(colaEventos, &evn, &cambiarCtx); return cambiarCtx; }
void __attribute__((__interrupt__, auto_psv)) _U2RXInterrupt( void ) { char cChar; portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* Get the character and post it on the queue of Rxed characters. If the post causes a task to wake force a context switch as the woken task may have a higher priority than the task we have interrupted. */ IFS1bits.U2RXIF = serCLEAR_FLAG; while( U2STAbits.URXDA ) { cChar = U2RXREG; xQueueSendFromISR( xRxedChars, &cChar, &xHigherPriorityTaskWoken ); } if( xHigherPriorityTaskWoken != pdFALSE ) { taskYIELD(); } }
static inline void __gmsReceiveCSQData(unsigned char data) { if (data == 0x0A) { GsmTaskMessage *message; portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; buffer[bufferIndex++] = 0; message = __gsmCreateMessage(TYPE_CSQ_DATA, buffer, bufferIndex); if (pdTRUE == xQueueSendFromISR(__queue, &message, &xHigherPriorityTaskWoken)) { if (xHigherPriorityTaskWoken) { taskYIELD(); } } else { __gsmDestroyMessage(message); } isCSQ = 0; bufferIndex = 0; } else if (data != 0x0D) { buffer[bufferIndex++] = data; } }
/******** Timer_GetCCPPeriod ************************************************ // Count the number of system ticks during one period of CCP input frequency // Input: timer is one of the Timer_T value ( Timer1A, Timer1B... ) // Output: none // ------------------------------------------------------------------------*/ void Timer_GetCCPPeriod ( Timer_T timer ) { unsigned long ticks = 0; static unsigned long last_time = 0; static unsigned long this_time = 0; static char counter = 0; portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; if ( counter ) { // finish this_time = Timer_GetTime ( timer ); if ( this_time >= last_time ) { // sysTick overflow, flush data last_time = 0; this_time = 0; counter = 0; } else { // get the number of ticks in a period, push on to the Queue ticks = last_time - this_time; while ( xQueueSendFromISR (CCPQueue[timer], &ticks, &xHigherPriorityTaskWoken) != pdTRUE ); // reset ISR and disable interrupt counter = 0; Timer_Disable ( timer ) ; } } else { // begin last_time = Timer_GetTime ( timer ); // next interrupt will finish system tick calculation counter = 1; } }
/* * When the WIZnet device asserts an interrupt we send an (empty) message to * the TCP task. This wakes the task so the interrupt can be processed. The * source of the interrupt has to be ascertained by the TCP task as this * requires an I2C transaction which cannot be performed from this ISR. * Note this code predates the introduction of semaphores, a semaphore should * be used in place of the empty queue message. */ void vEINT0_ISR_Handler( void ) { extern xQueueHandle xTCPISRQueue; portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* Just wake the TCP task so it knows an ISR has occurred. */ xQueueSendFromISR( xTCPISRQueue, ( void * ) &lDummyVariable, &xHigherPriorityTaskWoken ); /* We cannot carry on processing interrupts until the TCP task has processed this one - so for now interrupts are disabled. The TCP task will re-enable it. */ VICIntEnClear |= tcpEINT0_VIC_CHANNEL_BIT; /* Clear the interrupt bit. */ VICVectAddr = tcpCLEAR_VIC_INTERRUPT; if( xHigherPriorityTaskWoken ) { portYIELD_FROM_ISR(); } }
/** * \brief TDC interrupt handler, called after the propagation delay measurement. */ void tdcMeasurementHandler(void) { uint32_t result; event_t error_event; BaseType_t xTaskWoken = pdFALSE; /* Check the pointer */ if (g_rawDataPtr != NULL) { /* Read the calibration value */ bsp_GP22RegRead(GP22_RD_RES_0, &result, 4); /* Safe the raw data */ g_rawDataPtr->raw[g_rawDataPtr->raw_ctr++] = result; } else { /* Send error event */ error_event.event = Fault_MemoryPoolPtr; xQueueSendFromISR(queueEvent, &error_event, &xTaskWoken); } /* Check if a higher prior task is woken up */ portEND_SWITCHING_ISR(xTaskWoken); }
/*********************************************************************************************************************** * Function Name: r_scifa2_callback_receiveend * Description : This function is a callback function when SCIFA2 finishes reception. * Arguments : None * Return Value : None ***********************************************************************************************************************/ void r_scifa2_callback_receiveend(void) { /* Start user code. Do not edit comment generated here */ uint8_t ucRxedChar = 0; BaseType_t xHigherPriorityTaskWoken = pdFALSE; /* Read the received data */ ucRxedChar = SCIFA2.FRDR; /* Characters received from the UART are stored in this queue, ready to be received by the application. ***NOTE*** Using a queue in this way is very convenient, but also very inefficient. It can be used here because characters will only arrive slowly. In a higher bandwidth system a circular RAM buffer or DMA should be used in place of this queue. */ xQueueSendFromISR( xRxQueue, ( void * ) &ucRxedChar, &xHigherPriorityTaskWoken ); /* Re-enable receptions */ SCIFA2.SCR.BIT.RE = 1U; /* End user code. Do not edit comment generated here */ }
/* Define a callback function which is called when data is available. */ void vAsyncSerialIODataAvailableISR( int iFileDescriptor, void *pContext ) { portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; ssize_t iReadResult = -1; unsigned char ucRx; /* This handler only processes a single byte/character at a time. */ iReadResult = read( iFileDescriptor, &ucRx, 1 ); if ( 1 == iReadResult ) { if ( NULL != pContext ) { /* Send the received byte to the queue. */ if ( pdTRUE != xQueueSendFromISR( (xQueueHandle)pContext, &ucRx, &xHigherPriorityTaskWoken ) ) { /* the queue is full. */ } } } portEND_SWITCHING_ISR( xHigherPriorityTaskWoken ); }
// DMA interrupt handler. It is called each time a DMA block is finished processing. static void dma_isr_handler(void) { portBASE_TYPE task_awoken = pdFALSE; if (i2s_dma_is_eof_interrupt()) { dma_descriptor_t *descr = i2s_dma_get_eof_descriptor(); if (xQueueIsQueueFullFromISR(dma_queue)) { // List of empty blocks is full. Sender don't send data fast enough. int dummy; underrun_counter++; // Discard top of the queue xQueueReceiveFromISR(dma_queue, &dummy, &task_awoken); } // Push the processed buffer to the queue so sender can refill it. xQueueSendFromISR(dma_queue, (void*)(&descr->buf_ptr), &task_awoken); } i2s_dma_clear_interrupt(); portEND_SWITCHING_ISR(task_awoken); }
BOOL xMBPortEventPost( eMBEventType eEvent ) { portBASE_TYPE xEventSent = pdFALSE; ENTER_CRITICAL_SECTION( ); if( bIsInitialized ) { if( bMBPIsWithinException( ) ) { xEventSent = xQueueSendFromISR( arxEventHdls[0].xQueueHdl, ( const void * )&eEvent, pdFALSE ); } else { xEventSent = xQueueSend( arxEventHdls[0].xQueueHdl, ( const void * )&eEvent, pdFALSE ); } } EXIT_CRITICAL_SECTION( ); return xEventSent == pdTRUE ? TRUE : FALSE; }
/// Put a Message to a Queue. /// \param[in] queue_id message queue ID obtained with \ref osMessageCreate. /// \param[in] info message information. /// \param[in] millisec timeout value or 0 in case of no time-out. /// \return status code that indicates the execution status of the function. /// \note MUST REMAIN UNCHANGED: \b osMessagePut shall be consistent in every CMSIS-RTOS. osStatus osMessagePut (osMessageQId queue_id, uint32_t info, uint32_t millisec) { portBASE_TYPE taskWoken = pdFALSE; portTickType ticks; if (inHandlerMode()) { if (xQueueSendFromISR(queue_id, (const void *)info, &taskWoken) != pdTRUE) { return osErrorOS; } portEND_SWITCHING_ISR(taskWoken); } else { ticks = millisec_to_ticks(millisec); if (xQueueSend(queue_id, (const void *)info, ticks) != pdTRUE) { return osErrorOS; } } return osOK; }
void vUART_ISR(void) { unsigned long ulStatus; char cRxedChar; portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* What caused the interrupt. */ ulStatus = UARTIntStatus( UART0_BASE, pdTRUE ); /* Clear the interrupt. */ UARTIntClear( UART0_BASE, ulStatus ); /* Was an Rx interrpt pending? */ if( ulStatus & UART_INT_RX ) { if( ( HWREG(UART0_BASE + UART_O_FR ) & UART_FR_RXFF ) ) { /* Get the char from the buffer and post it onto the queue of Rxed chars. Posting the character should wake the task that is blocked on the queue waiting for characters. */ cRxedChar = ( char ) HWREG( UART0_BASE + UART_O_DR ); xQueueSendFromISR( xCommsQueue, &cRxedChar, &xHigherPriorityTaskWoken ); } } /* Was a Tx interrupt pending? */ if( ulStatus & UART_INT_TX ) { /* Send the next character in the string. We are not using the FIFO. */ if( cNextChar <= mainLAST_TX_CHAR ) { if( !( HWREG( UART0_BASE + UART_O_FR ) & UART_FR_TXFF ) ) { HWREG( UART0_BASE + UART_O_DR ) = cNextChar; } cNextChar++; } } /* If a task was woken by the character being received then we force a context switch to occur in case the task is of higher priority than the currently executing task (i.e. the task that this interrupt interrupted.) */ portEND_SWITCHING_ISR( xHigherPriorityTaskWoken ); }
__arm void vSerialISR( void ) { signed char cChar; portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; do { if( UART0->MIS & UART_IT_Transmit ) { /* The interrupt was caused by the THR becoming empty. Are there any more characters to transmit? */ if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE ) { /* A character was retrieved from the queue so can be sent to the THR now. */ UART0->DR = cChar; } else { xQueueEmpty = pdTRUE; } UART_ClearITPendingBit( UART0, UART_IT_Transmit ); } if( UART0->MIS & UART_IT_Receive ) { /* The interrupt was caused by a character being received. Grab the character from the RHR and place it in the queue of received characters. */ cChar = UART0->DR; xQueueSendFromISR( xRxedChars, &cChar, &xHigherPriorityTaskWoken ); UART_ClearITPendingBit( UART0, UART_IT_Receive ); } } while( UART0->MIS ); /* If a task was woken by either a character being received or a character being transmitted then we may need to switch to another task. */ portEND_SWITCHING_ISR( xHigherPriorityTaskWoken ); }
BaseType_t FreeRTOS_FD_SET( xSocket_t xSocket, xSocketSet_t xSocketSet ) { xFreeRTOS_Socket_t *pxSocket = ( xFreeRTOS_Socket_t * ) xSocket; BaseType_t xReturn = pdFALSE; UBaseType_t uxMessagesWaiting; configASSERT( xSocket ); /* Is the socket already a member of a select group? */ if( pxSocket->xSelectQueue == NULL ) { taskENTER_CRITICAL(); { /* Are there packets queued on the socket already? */ uxMessagesWaiting = uxQueueMessagesWaiting( pxSocket->xWaitingPacketSemaphore ); /* Are there enough notification spaces in the select queue for the number of packets already queued on the socket? */ if( uxQueueSpacesAvailable( ( xQueueHandle ) xSocketSet ) >= uxMessagesWaiting ) { /* Store a pointer to the select group in the socket for future reference. */ pxSocket->xSelectQueue = ( xQueueHandle ) xSocketSet; while( uxMessagesWaiting > 0 ) { /* Add notifications of the number of packets that are already queued on the socket to the select queue. */ xQueueSendFromISR( pxSocket->xSelectQueue, &pxSocket, NULL ); uxMessagesWaiting--; } xReturn = pdPASS; } } taskEXIT_CRITICAL(); } return xReturn; }
static portBASE_TYPE xComPortISR( xComPort * const pxPort ) { unsigned short usStatusRegister; char cChar; portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* NOTE: THIS IS NOT AN EFFICIENT ISR AS IT IS DESIGNED SOLELY TO TEST THE SCHEDULER FUNCTIONALITY. REAL APPLICATIONS SHOULD NOT USE THIS FUNCTION. */ usStatusRegister = portINPUT_WORD( pxPort->usStatusReg ); if( usStatusRegister & serRX_READY ) { cChar = ( char ) portINPUT_WORD( pxPort->usRxReg ); xQueueSendFromISR( pxPort->xRxedChars, &cChar, &xHigherPriorityTaskWoken ); /* Also release the semaphore - this does nothing interesting and is just a test. */ xSemaphoreGiveFromISR( pxPort->xTestSem, &xHigherPriorityTaskWoken ); } else if( pxPort->sTxInterruptOn && ( usStatusRegister & serTX_EMPTY ) ) { if( xQueueReceiveFromISR( pxPort->xCharsForTx, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE ) { portOUTPUT_WORD( pxPort->usTxReg, ( unsigned short ) cChar ); } else { /* Queue empty, nothing to send */ vInterruptOff( pxPort, serTX_HOLD_EMPTY_INT ); } } serRESET_PIC( pxPort->usIRQVector ); /* If posting to the queue woke a task that was blocked on the queue we may want to switch to the woken task - depending on its priority relative to the task interrupted by this ISR. */ return xHigherPriorityTaskWoken; }
/* * UART RX interrupt service routine. */ void vRxISR( void ) __interrupt[ UART1RX_VECTOR ] { signed char cChar; portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* Get the character from the UART and post it on the queue of Rxed characters. */ cChar = U1RXBUF; xQueueSendFromISR( xRxedChars, &cChar, &xHigherPriorityTaskWoken ); if( xHigherPriorityTaskWoken ) { /*If the post causes a task to wake force a context switch as the woken task may have a higher priority than the task we have interrupted. */ taskYIELD(); } /* Make sure any low power mode bits are clear before leaving the ISR. */ __bic_SR_register_on_exit( SCG1 + SCG0 + OSCOFF + CPUOFF ); }
static void prvEMACEventListener( unsigned long ulISREvents ) { long lHigherPriorityTaskWoken = pdFALSE; const unsigned long ulRxEvent = uipETHERNET_RX_EVENT; /* Sanity check that the event queue was indeed created. */ configASSERT( xEMACEventQueue ); if( ( ulISREvents & MSS_MAC_EVENT_PACKET_SEND ) != 0UL ) { /* An Ethernet Tx event has occurred. */ MSS_MAC_FreeTxBuffers(); } if( ( ulISREvents & MSS_MAC_EVENT_PACKET_RECEIVED ) != 0UL ) { /* An Ethernet Rx event has occurred. */ xQueueSendFromISR( xEMACEventQueue, &ulRxEvent, &lHigherPriorityTaskWoken ); } portEND_SWITCHING_ISR( lHigherPriorityTaskWoken ); }
static bool dma_rx_isr(volatile struct usart_info *ui) { const uint16_t dma_counter = (uint16_t) ui->dma_rx.stream->NDTR; volatile uint8_t* tail = ui->dma_rx.ptr; volatile uint8_t* const buff = ui->dma_rx.buff; volatile uint8_t* const edge = buff + ui->dma_rx.buff_size; volatile uint8_t* const head = dma_counter ? edge - dma_counter : buff; xQueueHandle queue = serial_get_rx_queue(ui->serial); portBASE_TYPE task_awoke = pdFALSE; while (tail != head) { uint8_t val = *tail; if (!xQueueSendFromISR(queue, &val, &task_awoke)) ui->char_dropped = true; if (++tail >= edge) tail = buff; } ui->dma_rx.ptr = head; return task_awoke; }
static void prvSendToQueueInSetFromISR( void ) { static BaseType_t xQueueToWriteTo = 0; if( xQueueSendFromISR( xQueues[ xQueueToWriteTo ], ( void * ) &ulISRTxValue, NULL ) == pdPASS ) { ulISRTxValue++; /* If the Tx value has wrapped then set it back to its initial value. */ if( ulISRTxValue == 0UL ) { ulISRTxValue = queuesetINITIAL_ISR_TX_VALUE; } /* Use a different queue next time. */ xQueueToWriteTo++; if( xQueueToWriteTo >= queuesetNUM_QUEUES_IN_SET ) { xQueueToWriteTo = 0; } } }
void USART1_IRQHandler(void) { /* if(USART_GetITStatus(USART1, USART_IT_RXNE)) { u8 RxData = (u8)USART_ReceiveData(USART1); test[testlen++] = RxData; } DisplayString(0, 0, (u8*)test); */ portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; portCHAR cChar; if( USART_GetITStatus( USART1, USART_IT_TXE ) == SET ) { /* The interrupt was caused by the THR becoming empty. Are there any more characters to transmit? */ if( xQueueReceiveFromISR( xCharsForTx, &cChar, &xHigherPriorityTaskWoken ) == pdTRUE ) { /* A character was retrieved from the queue so can be sent to the THR now. */ USART_SendData( USART1, cChar ); } else { USART_ITConfig( USART1, USART_IT_TXE, DISABLE ); } } if( USART_GetITStatus( USART1, USART_IT_RXNE ) == SET ) { cChar = USART_ReceiveData( USART1 ); xQueueSendFromISR( xRxedChars, &cChar, &xHigherPriorityTaskWoken ); } portEND_SWITCHING_ISR( xHigherPriorityTaskWoken ); }