这篇教程C++ xSemaphoreGiveFromISR函数代码示例写得很实用,希望能帮到您。
本文整理汇总了C++中xSemaphoreGiveFromISR函数的典型用法代码示例。如果您正苦于以下问题:C++ xSemaphoreGiveFromISR函数的具体用法?C++ xSemaphoreGiveFromISR怎么用?C++ xSemaphoreGiveFromISR使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。 在下文中一共展示了xSemaphoreGiveFromISR函数的28个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。 示例1: vSoftwareInterruptHandlervoid vSoftwareInterruptHandler(void){portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* 'Give' the semaphore to unblock the task. */ xSemaphoreGiveFromISR(xBinarySemaphore, &xHigherPriorityTaskWoken); /* Clear the software interrupt bit using the interrupt controllers Clear Pending register. */ mainCLEAR_INTERRUPT(); /* Giving the semaphore may have unblocked a task - if it did and the unblocked task has a priority equal to or above the currently executing task then xHigherPriorityTaskWoken will have been set to pdTRUE and portEND_SWITCHING_ISR() will force a context switch to the newly unblocked higher priority task. NOTE: The syntax for forcing a context switch within an ISR varies between FreeRTOS ports. The portEND_SWITCHING_ISR() macro is provided as part of the Cortex M3 port layer for this purpose. taskYIELD() must never be called from an ISR! */ portEND_SWITCHING_ISR(xHigherPriorityTaskWoken);}
开发者ID:JamesHyunKim,项目名称:STM32F4-Discovery_FW_V1.1.0_Makefiles,代码行数:23,
示例2: vEMACISR__arm void vEMACISR( void ){volatile unsigned long ulIntStatus, ulRxStatus;portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; ulIntStatus = AT91C_BASE_EMAC->EMAC_ISR; ulRxStatus = AT91C_BASE_EMAC->EMAC_RSR; if( ( ulIntStatus & AT91C_EMAC_RCOMP ) || ( ulRxStatus & AT91C_EMAC_REC ) ) { /* A frame has been received, signal the uIP task so it can process the Rx descriptors. */ xSemaphoreGiveFromISR( xSemaphore, &xHigherPriorityTaskWoken ); AT91C_BASE_EMAC->EMAC_RSR = AT91C_EMAC_REC; } /* 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 ); /* Clear the interrupt. */ AT91C_BASE_AIC->AIC_EOICR = 0;}
开发者ID:ptracton,项目名称:experimental,代码行数:23,
示例3: USART3_IRQHandler/*=====================================================================================================*/void USART3_IRQHandler(){ long lHigherPriorityTaskWoken = pdFALSE; serial_msg rx_msg; if (USART_GetITStatus(USART3, USART_IT_TXE) != RESET) { xSemaphoreGiveFromISR(serial_tx_wait_sem, &lHigherPriorityTaskWoken); USART_ITConfig(USART3, USART_IT_TXE, DISABLE); } else if (USART_GetITStatus(USART3, USART_IT_RXNE) != RESET) { rx_msg.ch = USART_ReceiveData(USART3); if (!xQueueSendToBackFromISR(serial_rx_queue, &rx_msg, &lHigherPriorityTaskWoken)) portEND_SWITCHING_ISR(lHigherPriorityTaskWoken); } else { while (1); } portEND_SWITCHING_ISR(lHigherPriorityTaskWoken);}
开发者ID:huntercggc,项目名称:QuadcopterFlightControl,代码行数:24,
示例4: Dummy_IRQHandlervoid Dummy_IRQHandler(void){ long lHigherPriorityTaskWoken = pdFALSE; /* Clear the interrupt if necessary. */ Dummy_ClearITPendingBit(); /* This interrupt does nothing more than demonstrate how to synchronise a task with an interrupt. A semaphore is used for this purpose. Note lHigherPriorityTaskWoken is initialised to zero. Only FreeRTOS API functions that end in "FromISR" can be called from an ISR. */ xSemaphoreGiveFromISR( xTestSemaphore, &lHigherPriorityTaskWoken ); /* If there was a task that was blocked on the semaphore, and giving the semaphore caused the task to unblock, and the unblocked task has a priority higher than the current Running state task (the task that this interrupt interrupted), then lHigherPriorityTaskWoken will have been set to pdTRUE internally within xSemaphoreGiveFromISR(). Passing pdTRUE into the portEND_SWITCHING_ISR() macro will result in a context switch being pended to ensure this interrupt returns directly to the unblocked, higher priority, task. Passing pdFALSE into portEND_SWITCHING_ISR() has no effect. */ portEND_SWITCHING_ISR( lHigherPriorityTaskWoken );}
开发者ID:KISSMonX,项目名称:FreeRTOS_F0Discovery_TEST,代码行数:23,
示例5: EXTI0_IRQHandler/* Handles interrupts generated by pressing the USER button. */void EXTI0_IRQHandler(void){ static const TickType_t xIncrement = 200UL / portTICK_PERIOD_MS; /* If xSendBlockTime is already portMAX_DELAY then the Tx task was blocked indefinitely, and this interrupt is bringing the MCU out of STOP low power mode. */ if( xSendBlockTime == portMAX_DELAY ) { portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* Unblock the Tx task. */ xSemaphoreGiveFromISR( xTxSemaphore, &xHigherPriorityTaskWoken ); /* Start over with the 'short' block time as described at the top of this file. */ xSendBlockTime = xMinBlockTime; /* Request a yield if calling xSemaphoreGiveFromISR() caused a task to leave the Blocked state (which it will have done) and the task that left the Blocked state has a priority higher than the currently running task (which it will have). */ portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); } else { /* Increase the block time used by the Tx task, as described at the top of this file. */ xSendBlockTime += xIncrement; /* If the block time has gone over the configured maximum then set it to an infinite block time to allow the MCU to go into its STOP low power mode. */ if( xSendBlockTime > xMaxBlockTime ) { xSendBlockTime = portMAX_DELAY; } } EXTI_ClearITPendingBit( EXTI_Line0 );}
开发者ID:peterliu2,项目名称:FreeRTOS,代码行数:38,
示例6: prvMACB_ISR_NonNakedBehaviourstatic 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,
示例7: USART2_IRQHandler/* IRQ handler to handle USART2 interruptss (both transmit and * receive interrupts). */void USART2_IRQHandler(){ static signed portBASE_TYPE xHigherPriorityTaskWoken; serial_ch_msg rx_msg; /* If this interrupt is for a transmit... */ if (USART_GetITStatus(USART2, USART_IT_TXE) != RESET) { /* "give" the serial_tx_wait_sem semaphore to notfiy processes * that the buffer has a spot free for the next byte. */ xSemaphoreGiveFromISR(serial_tx_wait_sem, &xHigherPriorityTaskWoken); /* Diables the transmit interrupt. */ USART_ITConfig(USART2, USART_IT_TXE, DISABLE); /* If this interrupt is for a receive... */ } else if (USART_GetITStatus(USART2, USART_IT_RXNE) != RESET) { /* Receive the byte from the buffer. */ rx_msg.ch = USART_ReceiveData(USART2); /* Queue the received byte. */ if (!xQueueSendToBackFromISR(serial_rx_queue, &rx_msg, &xHigherPriorityTaskWoken)) { /* If there was an error queueing the received byte, * freeze. */ while (1); } } else { /* Only transmit and receive interrupts should be enabled. * If this is another type of interrupt, freeze. */ while (1); } if (xHigherPriorityTaskWoken) taskYIELD();}
开发者ID:hongyunnchen,项目名称:visualizer,代码行数:39,
示例8: uartadapter_uart_irqstatic void uartadapter_uart_irq(uint32_t id, SerialIrq event){ portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; if(event == RxIrq) { ua_rcv_ch = serial_getc(&ua_sobj); ua_uart_recv_buf[ua_pwrite] = ua_rcv_ch; ua_pwrite++; //point to uart data recved xSemaphoreGiveFromISR( ua_uart_action_sema, &xHigherPriorityTaskWoken ); //up action semaphore if(ua_pwrite > (UA_UART_RECV_BUFFER_LEN -1)){ //restart from head if reach tail ua_pwrite = 0; ua_overlap = 1; } if(ua_overlap && (ua_pwrite - 1) >= ua_pread ){ //ua_printf(UA_ERROR, "IRQ missing data %d byte!", ua_pread - ua_pwrite + 1); irq_miss_cnt ++; ua_pread = ua_pwrite; //if pwrite overhead pread ,pread is always flow rwrite } ua_tick_last_update = xTaskGetTickCountFromISR(); // update tick everytime recved data irq_rx_cnt ++; }}
开发者ID:geliang201201,项目名称:RTL_Ameba,代码行数:24,
示例9: vT5InterruptHandlervoid vT5InterruptHandler( void ){ portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; /* This function is the handler for the peripheral timer interrupt. The interrupt is initially signalled in a separate assembly file which switches to the system stack and then calls this function. It gives a semaphore which signals the prvISRBlockTask */ /* Give the semaphore. If giving the semaphore causes the task to leave the Blocked state, and the priority of the task is higher than the priority of the interrupted task, then xHigherPriorityTaskWoken will be set to pdTRUE inside the xSemaphoreGiveFromISR() function. xHigherPriorityTaskWoken is later passed into portEND_SWITCHING_ISR(), where a context switch is requested if it is pdTRUE. The context switch ensures the interrupt returns directly to the unblocked task. */ xSemaphoreGiveFromISR( xBlockSemaphore, &xHigherPriorityTaskWoken ); /* Clear the interrupt */ IFS0CLR = _IFS0_T5IF_MASK; /* See comment above the call to xSemaphoreGiveFromISR(). */ portEND_SWITCHING_ISR( xHigherPriorityTaskWoken );}
开发者ID:bleuelotus,项目名称:SweepRobot_Testing_Host,代码行数:24,
示例10: vExternalInt8Handler/* Handler for the SW2 button push interrupt. */__interrupt void vExternalInt8Handler( void ){short sHigherPriorityTaskWoken = pdFALSE; /* Reset the interrupt. */ EIRR1_ER8 = 0; /* Check the semaphore has been created before attempting to use it. */ if( xSemaphores[ configLEFT_DISPLAY ] != NULL ) { /* Send a message via the semaphore to the dice task that controls the left side display. This will unblock the task if it is blocked waiting for a button push. */ xSemaphoreGiveFromISR( xSemaphores[ configLEFT_DISPLAY ], &sHigherPriorityTaskWoken ); } /* If sending the semaphore unblocked a task, and the unblocked task has a priority that is higher than the currently running task, then force a context switch. */ if( sHigherPriorityTaskWoken != pdFALSE ) { portYIELD_FROM_ISR(); }}
开发者ID:vmandrews,项目名称:CSDC-OBC-Software,代码行数:25,
示例11: usb_general_interrupt__interrupt#endifstatic void usb_general_interrupt(void)#endif{#ifdef FREERTOS_USED portBASE_TYPE task_woken = pdFALSE;#endif#if USB_HOST_FEATURE == true && USB_HOST_PIPE_INTERRUPT_TRANSFER == ENABLE U8 i;#endif// ---------- DEVICE/HOST events management ------------------------------------#if USB_DEVICE_FEATURE == true && USB_HOST_FEATURE == true // ID pin change detection if (Is_usb_id_transition() && Is_usb_id_interrupt_enabled()) { g_usb_mode = (Is_usb_id_device()) ? USB_MODE_DEVICE : USB_MODE_HOST; Usb_ack_id_transition(); if (g_usb_mode != g_old_usb_mode) // Basic debounce { // Previously in device mode, check if disconnection was detected if (g_old_usb_mode == USB_MODE_DEVICE) { if (usb_connected) { // Device mode disconnection actions usb_connected = false; usb_configuration_nb = 0; Usb_vbus_off_action(); } } // Previously in host mode, check if disconnection was detected else if (Is_host_attached()) { // Host mode disconnection actions device_state = DEVICE_UNATTACHED; Host_device_disconnection_action(); } //LOG_STR(log_pin_id_changed); if (Is_usb_id_device() == USB_MODE_DEVICE) { LOG_STR(log_pin_id_changed_to_device); } else { LOG_STR(log_pin_id_changed_to_host); } Usb_send_event((Is_usb_device()) ? EVT_USB_DEVICE_FUNCTION : EVT_USB_HOST_FUNCTION); Usb_id_transition_action(); // Easier to recover from ID signal de-bounce and ID pin transitions by shutting down the USB and resetting state machine to re-init#if ID_PIN_CHANGE_SHUTDOWN_USB == ENABLE Usb_disable(); Usb_disable_otg_pad();extern void UsbResetStateMachine(void); UsbResetStateMachine(); #ifdef FREERTOS_USED // Release the semaphore in order to start a new device/host task taskENTER_CRITICAL(); xSemaphoreGiveFromISR(usb_tsk_semphr, &task_woken); taskEXIT_CRITICAL(); #endif#endif#if ID_PIN_CHANGE_GENERATE_RESET == ENABLE Reset_CPU();#endif } }#endif // End DEVICE/HOST FEATURE MODE// ---------- DEVICE events management -----------------------------------------#if USB_DEVICE_FEATURE == true #if USB_HOST_FEATURE == true // If both device and host features are enabled, check if device mode is engaged // (accessing the USB registers of a non-engaged mode, even with load operations, // may corrupt USB FIFO data). if (Is_usb_device()) #endif { // VBus state detection if (Is_usb_vbus_transition() && Is_usb_vbus_interrupt_enabled()) { Usb_ack_vbus_transition(); if (Is_usb_vbus_high()) { usb_start_device(); Usb_send_event(EVT_USB_POWERED); Usb_vbus_on_action(); } else { Usb_unfreeze_clock(); Usb_detach(); usb_connected = false; usb_configuration_nb = 0; Usb_send_event(EVT_USB_UNPOWERED); Usb_vbus_off_action(); #ifdef FREERTOS_USED//.........这里部分代码省略.........
开发者ID:jerpeter,项目名称:NS8100,代码行数:101,
示例12: ISRISR(usb_general_interrupt, AVR32_USBB_IRQ_GROUP, USB_INT_LEVEL)#endif{#ifdef FREERTOS_USED portBASE_TYPE task_woken = pdFALSE;#endif uint8_t i; /* avoid Cppcheck Warning */ UNUSED(i);// ---------- DEVICE/HOST events management ------------------------------------#if USB_DEVICE_FEATURE == true && USB_HOST_FEATURE == true // ID pin change detection if (Is_usb_id_transition() && Is_usb_id_interrupt_enabled()) { g_usb_mode = (Is_usb_id_device()) ? USB_MODE_DEVICE : USB_MODE_HOST; Usb_ack_id_transition(); if (g_usb_mode != g_old_usb_mode) // Basic debounce { // Previously in device mode, check if disconnection was detected if (g_old_usb_mode == USB_MODE_DEVICE) { if (usb_connected) { // Device mode diconnection actions usb_connected = false; usb_configuration_nb = 0; Usb_vbus_off_action(); } } // Previously in host mode, check if disconnection was detected else if (Is_host_attached()) { // Host mode diconnection actions device_state = DEVICE_UNATTACHED; Host_device_disconnection_action(); } LOG_STR(log_pin_id_changed); Usb_send_event((Is_usb_device()) ? EVT_USB_DEVICE_FUNCTION : EVT_USB_HOST_FUNCTION); Usb_id_transition_action(); //! @todo ID pin hot state change!!! // Preliminary management: HARDWARE RESET!!! #if ID_PIN_CHANGE_GENERATE_RESET == ENABLE // Hot ID transition generates CPU reset Usb_disable(); Usb_disable_otg_pad(); #ifdef FREERTOS_USED // Release the semaphore in order to start a new device/host task taskENTER_CRITICAL(); xSemaphoreGiveFromISR(usb_tsk_semphr, &task_woken); taskEXIT_CRITICAL(); #else#if defined(CPU_RESET_CALLBACK) CPU_RESET_CALLBACK();#endif Reset_CPU(); #endif #endif g_old_usb_mode = g_usb_mode; // Store current USB mode, for mode change detection } }#endif // End DEVICE/HOST FEATURE MODE// ---------- DEVICE events management -----------------------------------------#if USB_DEVICE_FEATURE == true #if USB_HOST_FEATURE == true // If both device and host features are enabled, check if device mode is engaged // (accessing the USB registers of a non-engaged mode, even with load operations, // may corrupt USB FIFO data). if (Is_usb_device()) #endif { // VBus state detection if (Is_usb_vbus_transition() && Is_usb_vbus_interrupt_enabled()) { Usb_ack_vbus_transition(); if (Is_usb_vbus_high()) { usb_start_device(); Usb_send_event(EVT_USB_POWERED); Usb_vbus_on_action(); } else { Usb_unfreeze_clock(); Usb_detach(); usb_connected = false; usb_configuration_nb = 0; Usb_send_event(EVT_USB_UNPOWERED); Usb_vbus_off_action(); #ifdef FREERTOS_USED // Release the semaphore in order to start a new device/host task taskENTER_CRITICAL(); xSemaphoreGiveFromISR(usb_tsk_semphr, &task_woken); taskEXIT_CRITICAL(); #endif } }//.........这里部分代码省略.........
开发者ID:kerichsen,项目名称:asf,代码行数:101,
示例13: UART2_IRQHandler void UART2_IRQHandler(void) { uint32_t intsrc, tmp, tmp1; char c = 0; uint32_t bToRecv=256, timeOut=0; uint8_t recvData = 0; /* Determine the interrupt source */ intsrc = (LPC_UART2->IIR & 0x03CF); tmp = intsrc & UART_IIR_INTID_MASK; // Receive Line Status if (tmp == UART_IIR_INTID_RLS) { // Check line status tmp1 = ((LPC_UART2->LSR) & UART_LSR_BITMASK); // Mask out the Receive Ready and Transmit Holding empty status tmp1 &= (UART_LSR_OE | UART_LSR_PE | UART_LSR_FE / | UART_LSR_BI | UART_LSR_RXFE); // If any error exist if (tmp1) { while(1); } } // Receive Data Available or Character time-out if ((tmp == UART_IIR_INTID_RDA) || (tmp == UART_IIR_INTID_CTI)) { while (bToRecv) { if (!(LPC_UART2->LSR & UART_LSR_RDR)) { printf("here1/n"); gBuffer[bRecvInt++] = '/0'; printf("-->%s/n",gBuffer); bRecvInt =0; xSemaphoreGiveFromISR(gUartSemaphore,NULL); break; } else { recvData= LPC_UART2->RBR; printf("%c/n",recvData); if ((recvData == 0xA) | (recvData == 0xD)) { continue; } //delay_ms(5); printf("%c/n",recvData); gBuffer[bRecvInt] = recvData; bRecvInt++; bToRecv--; } } } // Transmit Holding Empty if (tmp == UART_IIR_INTID_THRE) { //UART_IntTransmit(); } //bRecvInt ++; //gBuffer[bRecv] = '/0'; }
开发者ID:ankit4970,项目名称:project_wifitrack,代码行数:67,
示例14: configASSERT/*------------------------------------------------------------------------------ * MSS I2C interrupt service routine. *------------------------------------------------------------------------------ * Parameters: * * mss_i2c_instance_t * this_i2c: * Pointer to the mss_i2c_instance_t data structure holding all data related to * the MSS I2C instance that generated the interrupt. */static void mss_i2c_isr( mss_i2c_instance_t * this_i2c){ volatile uint8_t status; uint8_t data; uint8_t hold_bus; uint8_t clear_irq = 1; long lHigherPriorityTaskWoken = pdFALSE; configASSERT( ( this_i2c->xI2CCompleteSemaphore ) ); ASSERT( (this_i2c == &g_mss_i2c0) || (this_i2c == &g_mss_i2c1) ); status = this_i2c->hw_reg->STATUS; switch( status ) { /************** MASTER TRANSMITTER / RECEIVER *******************/ case ST_START: /* start has been xmt'd */ case ST_RESTART: /* repeated start has been xmt'd */ this_i2c->hw_reg_bit->CTRL_STA = 0x0; this_i2c->hw_reg->DATA = this_i2c->target_addr; this_i2c->hw_reg_bit->DATA_DIR = this_i2c->dir; this_i2c->tx_idx = 0; this_i2c->rx_idx = 0; break; case ST_LOST_ARB: /* Set start bit. Let's keep trying! Don't give up! */ this_i2c->hw_reg_bit->CTRL_STA = 0x01; break; /******************* MASTER TRANSMITTER *************************/ case ST_SLAW_ACK: /* call address has been xmt'd with ACK, time to send data byte and increment index. */ if ( this_i2c->tx_idx < this_i2c->tx_size ) { /* load data byte */ this_i2c->hw_reg->DATA = this_i2c->tx_buffer[this_i2c->tx_idx++]; } else { NVIC_DisableIRQ( this_i2c->irqn ); } break; case ST_SLAW_NACK:#if 0 /* SLA+W has been transmitted; not ACK has been received - let's stop. */ this_i2c->hw_reg_bit->CTRL_STO = 0x01; this_i2c->status = MSS_I2C_FAILED;#endif /* call address has been xmt'd with ACK, time to send data byte and increment index. */ if ( this_i2c->tx_idx < this_i2c->tx_size ) { /* load data byte */ this_i2c->hw_reg->DATA = this_i2c->tx_buffer[this_i2c->tx_idx++]; } else { NVIC_DisableIRQ( this_i2c->irqn ); } break; case ST_TX_DATA_ACK: /* data byte has been xmt'd with ACK, time to send stop bit or repeated start. */ if (this_i2c->tx_idx < this_i2c->tx_size) { this_i2c->hw_reg->DATA = this_i2c->tx_buffer[this_i2c->tx_idx++]; } else if ( this_i2c->transaction == MASTER_RANDOM_READ_TRANSACTION ) { /* We are finished sending the address offset part of a random read transaction. * It is is time to send a restart in order to change direction. */ this_i2c->dir = READ_DIR; this_i2c->hw_reg_bit->CTRL_STA = 0x01; } else { /* done sending. let's stop */ hold_bus = this_i2c->options & MSS_I2C_HOLD_BUS; if ( hold_bus == 0 ) { this_i2c->hw_reg_bit->CTRL_STO = 0x01; /*xmt stop condition */ } else { NVIC_DisableIRQ( this_i2c->irqn ); clear_irq = 0; } this_i2c->status = MSS_I2C_SUCCESS; xSemaphoreGiveFromISR( this_i2c->xI2CCompleteSemaphore, &lHigherPriorityTaskWoken ); } break; case ST_TX_DATA_NACK:#if 0 /* data byte SENT, ACK to be received * In fact, this means we've received a NACK (This may not be * obvious, but if we've rec'd an ACK then we would be in state * 0x28!) hence, let's send a stop bit */ this_i2c->hw_reg_bit->CTRL_STO = 0x01; this_i2c->status = MSS_I2C_FAILED;//.........这里部分代码省略.........
开发者ID:peterliu2,项目名称:FreeRTOS,代码行数:101,
示例15: USART3_IRQHandlervoid USART3_IRQHandler(void){ volatile u32 tem_reg; volatile u16 u16BufferUsedLen = 0; BaseType_t xHigherPriorityTaskWoken, xResult; // xHigherPriorityTaskWoken must be initialised to pdFALSE. xHigherPriorityTaskWoken = pdFALSE; // error happen if(USART_GetITStatus(USART3, USART_IT_PE) != RESET) { USART_ClearITPendingBit(USART3, USART_IT_PE); xSerialRxParityFlag = DMA_UART_PACKET_PARITY_ERR; } // uart idle interrupt if(USART_GetITStatus(USART3, USART_IT_IDLE) != RESET) { USART_ClearITPendingBit(USART3, USART_IT_IDLE); DMA_ClearFlag(DMA1_FLAG_GL3);//clear all interrupt flags DMA_Cmd(DMA1_Channel3, DISABLE); //close DMA incase receive data while handling xResult = xSemaphoreTakeFromISR( xSerialRxHandleLock, &xHigherPriorityTaskWoken); if( pdTRUE == xResult) { if (uart3_rx_dma_buf.IdleBufferIndex) //buf1 busy, buf2 idle { u16BufferUsedLen = uart3_rx_dma_buf.nBuff1MaxLength - DMA_GetCurrDataCounter(DMA1_Channel3); if (u16BufferUsedLen > 0) { uart3_rx_dma_buf.nBuff1Offset = u16BufferUsedLen; DMA1_Channel3->CMAR = (uint32_t)uart3_rx_dma_buf.pPingPongBuff2; DMA1_Channel3->CNDTR = uart3_rx_dma_buf.nBuff2MaxLength; uart3_rx_dma_buf.IdleBufferIndex = 0; } } else { u16BufferUsedLen = uart3_rx_dma_buf.nBuff2MaxLength - DMA_GetCurrDataCounter(DMA1_Channel3); if (u16BufferUsedLen > 0) { uart3_rx_dma_buf.nBuff2Offset = u16BufferUsedLen; DMA1_Channel3->CMAR = (uint32_t)uart3_rx_dma_buf.pPingPongBuff1; DMA1_Channel3->CNDTR = uart3_rx_dma_buf.nBuff1MaxLength; uart3_rx_dma_buf.IdleBufferIndex = 1; } } xResult = xSemaphoreGiveFromISR( xSerialRxHandleLock ,&xHigherPriorityTaskWoken); if (u16BufferUsedLen > 0) { //boardcast message to handle xResult = xEventGroupSetBitsFromISR( xUart3RxEventGroup, // The event group being updated. UART_DMA_RX_INCOMPLETE_EVENT_BIT,// The bits being set. &xHigherPriorityTaskWoken ); } //End if u16BufferUsedLen > 0 }// End if pdTRUE == xSemaphoreTakeFromISR DMA_Cmd(DMA1_Channel3, ENABLE); //open DMA after handled //clear Idle flag by read SR and DR tem_reg = USART3->SR; tem_reg = USART3->DR; tem_reg = tem_reg; // slove warning }// End if USART_IT_IDLE if(USART_GetITStatus(USART3, USART_IT_FE | USART_IT_NE) != RESET) { USART_ClearITPendingBit(USART3, USART_IT_FE | USART_IT_NE); } if( xResult == pdPASS ) { // If xHigherPriorityTaskWoken is now set to pdTRUE then a context // switch should be requested. The macro used is port specific and // will be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() - // refer to the documentation page for the port being used. portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); }}
开发者ID:webom2008,项目名称:AIO.TestFixture,代码行数:81,
示例16: UART_IRQHandlervoid UART_IRQHandler(void){ uint8_t IIRValue, LSRValue; uint8_t temp = temp; static signed portBASE_TYPE xHigherPriorityTaskWoken; IIRValue = LPC_UART->IIR; IIRValue >>= 1; /* skip pending bit in IIR */ IIRValue &= 0x07; /* check bit 1~3, interrupt identification */ if (IIRValue == IIR_RLS) /* Receive Line Status */ { LSRValue = LPC_UART->LSR; /* Receive Line Status */ if (LSRValue & (LSR_OE | LSR_PE | LSR_FE | LSR_RXFE | LSR_BI)) { /* There are errors or break interrupt */ /* Read LSR will clear the interrupt */ temp = LPC_UART->RBR; /* temp read on RX to clear interrupt, then bail out */ return; } if (LSRValue & LSR_RDR) /* Receive Data Ready */ { /* If no error on RLS, normal ready, save into the data buffer. */ /* Note: read RBR will clear the interrupt */ temp = LPC_UART->RBR; } } else if (IIRValue == IIR_RDA) /* Receive Data Available */ { /* Receive Data Available */ temp = LPC_UART->RBR; if (InCount == 0) { if (temp == 0xAA) { InSum = 0xAA; InCount++; } } else if (InCount == 1) { if (temp == 0x55) { InCount++; InSum += 0x55; } else if(temp != 0xAA) { InCount = 0; } } else if (InCount == 2) { InTempLength = temp; if(InTempLength > MAX_PAYLOAD_LENGTH+4) InCount = 0; else { InCount++; InSum += temp; } } else if(InCount == 3) { InCount++; InSum += temp; } else if(InCount < MAX_PAYLOAD_LENGTH+4) { InputPayload[InBuff][InCount-4] = temp; InCount++; InSum += temp; if (InCount >= InTempLength) { if (InSum == 0) { InBuff = (InBuff+1) & 0x3; InLength = InTempLength - 4; NewInData = 1; xHigherPriorityTaskWoken = pdFALSE; if(xSerialSemaphore != 0) xSemaphoreGiveFromISR(xSerialSemaphore,&xHigherPriorityTaskWoken); } InCount = 0; InTempLength = 0; } } else { InCount = 0; } } else if (IIRValue == IIR_CTI) /* Character timeout indicator */ { /* Character Time-out indicator */ } else if (IIRValue == IIR_THRE) /* THRE, transmit holding register empty */ {//.........这里部分代码省略.........
开发者ID:Cheng-SG,项目名称:BubbleCode,代码行数:101,
示例17: enable_usart1//.........这里部分代码省略......... .DMA_FIFOThreshold = DMA_FIFOThreshold_Full, .DMA_MemoryBurst = DMA_MemoryBurst_Single, .DMA_MemoryDataSize = DMA_MemoryDataSize_Byte, .DMA_MemoryInc = DMA_MemoryInc_Enable, .DMA_Mode = DMA_Mode_Normal, .DMA_PeripheralBaseAddr = (uint32_t)(&(USART2->DR)), .DMA_PeripheralBurst = DMA_PeripheralBurst_Single, .DMA_PeripheralDataSize = DMA_PeripheralDataSize_Byte, .DMA_PeripheralInc = DMA_PeripheralInc_Disable, .DMA_Priority = DMA_Priority_Medium, /* Configure TX DMA */ .DMA_Channel = DMA_Channel_4, .DMA_DIR = DMA_DIR_MemoryToPeripheral, .DMA_Memory0BaseAddr = (uint32_t)s }; DMA_Init(DMA1_Stream6, &DMA_InitStructure); DMA_Cmd(DMA1_Stream6, ENABLE); USART_DMACmd(USART2, USART_DMAReq_Tx, ENABLE);}int _write(int fd, char *ptr, int len){ /* Write "len" of char from "ptr" to file id "fd" * Return number of char written. * Need implementing with UART here. */ int i = 0; fd=fd; for (i = 0; i < len ; i++) { USART_SendData(PRINTF_USART, (uint8_t) *ptr); /* Loop until USART2 DR register is empty */ while (USART_GetFlagStatus(PRINTF_USART, USART_FLAG_TXE) == RESET); ptr++; } return len;}xSemaphoreHandle serial_tx_wait_sem = NULL;xQueueHandle serial_rx_queue = NULL;xQueueHandle gps_serial_queue = NULL;void USART3_IRQHandler(void){ long lHigherPriorityTaskWoken = pdFALSE; serial_msg rx_msg; if (USART_GetITStatus(USART3, USART_IT_TXE) != RESET) { xSemaphoreGiveFromISR(serial_tx_wait_sem, &lHigherPriorityTaskWoken); USART_ITConfig(USART3, USART_IT_TXE, DISABLE); } if (USART_GetITStatus(USART3, USART_IT_RXNE) != RESET) { rx_msg.ch = USART_ReceiveData(USART3); if (!xQueueSendToBackFromISR(serial_rx_queue, &rx_msg, &lHigherPriorityTaskWoken)) portEND_SWITCHING_ISR(lHigherPriorityTaskWoken); } portEND_SWITCHING_ISR(lHigherPriorityTaskWoken);}char usart3_read(void){ serial_msg msg; while (!xQueueReceive(serial_rx_queue, &msg, portMAX_DELAY)); return msg.ch;}void usart3_send(char str){ while (!xSemaphoreTake(serial_tx_wait_sem, portMAX_DELAY)); USART_SendData(USART3, (uint16_t)str); USART_ITConfig(USART3, USART_IT_TXE, ENABLE);}void uart8_puts(uint8_t *ptr){ while(*ptr!='/0'){ USART_SendData(PRINTF_USART, (uint8_t) *ptr); /* Loop until USART8 DR register is empty */ while (USART_GetFlagStatus(PRINTF_USART, USART_FLAG_TXE) == RESET); ptr++; }}
开发者ID:ProSlatisa,项目名称:firmware,代码行数:101,
示例18: EXTI2_IRQHandlervoid EXTI2_IRQHandler(void) // nRF24_IRQ_PIN{ EXTI_ClearITPendingBit(NRF24L01_IRQ_LINE); xSemaphoreGiveFromISR(xNRF_IRQ_Semaphore, NULL);}
开发者ID:InnoMerk,项目名称:remote,代码行数:5,
示例19: local_spi_handler/* * For internal use only. * A common SPI interrupt handler that is called for all SPI peripherals. */static void local_spi_handler(const portBASE_TYPE spi_index){ portBASE_TYPE higher_priority_task_woken = pdFALSE; uint32_t spi_status; Spi *spi_port; spi_port = all_spi_definitions[spi_index].peripheral_base_address; spi_status = spi_read_status(spi_port); spi_status &= spi_read_interrupt_mask(spi_port); /* Has the PDC completed a transmission? */ if ((spi_status & SPI_SR_ENDTX) != 0UL) { spi_disable_interrupt(spi_port, SPI_IDR_ENDTX); /* If the driver is supporting multi-threading, then return the access mutex. */ if (tx_dma_control[spi_index].peripheral_access_mutex != NULL) { xSemaphoreGiveFromISR( tx_dma_control[spi_index].peripheral_access_mutex, &higher_priority_task_woken); } /* if the sending task supplied a notification semaphore, then * notify the task that the transmission has completed. */ if (tx_dma_control[spi_index].transaction_complete_notification_semaphore != NULL) { xSemaphoreGiveFromISR( tx_dma_control[spi_index].transaction_complete_notification_semaphore, &higher_priority_task_woken); } } /* Has the PDC completed a reception? */ if ((spi_status & SPI_SR_ENDRX) != 0UL) { spi_disable_interrupt(spi_port, SPI_IDR_ENDRX); /* If the driver is supporting multi-threading, then return the access mutex. NOTE: As a reception is performed by first performing a transmission, the SPI receive function uses the tx access semaphore. */ if (tx_dma_control[spi_index].peripheral_access_mutex != NULL) { xSemaphoreGiveFromISR( tx_dma_control[spi_index].peripheral_access_mutex, &higher_priority_task_woken); } /* If the receiving task supplied a notification semaphore, then notify the task that the transmission has completed. */ if (rx_dma_control[spi_index].transaction_complete_notification_semaphore != NULL) { xSemaphoreGiveFromISR( rx_dma_control[spi_index].transaction_complete_notification_semaphore, &higher_priority_task_woken); } } if ((spi_status & SR_ERROR_INTERRUPTS) != 0) { /* An mode error occurred in either a transmission or reception. Abort. Stop the transmission, disable interrupts used by the peripheral, and ensure the peripheral access mutex is made available to tasks. As this peripheral is half duplex, only the Tx peripheral access mutex exits. */ spi_disable_interrupt(spi_port, SPI_IDR_ENDTX); spi_disable_interrupt(spi_port, SPI_IDR_ENDRX); if (tx_dma_control[spi_index].peripheral_access_mutex != NULL) { xSemaphoreGiveFromISR( tx_dma_control[spi_index].peripheral_access_mutex, &higher_priority_task_woken); } /* The SPI port will have been disabled, re-enable it. */ spi_enable(spi_port); } /* If giving a semaphore caused a task to unblock, and the unblocked task has a priority equal to or higher than the currently running task (the task this ISR interrupted), then higher_priority_task_woken will have automatically been set to pdTRUE within the semaphore function. portEND_SWITCHING_ISR() will then ensure that this ISR returns directly to the higher priority unblocked task. */ portEND_SWITCHING_ISR(higher_priority_task_woken);}
开发者ID:kerichsen,项目名称:asf,代码行数:84,
示例20: local_twi_handler/* * For internal use only. * A common TWI interrupt handler that is called for all TWI peripherals. */static void local_twi_handler(const portBASE_TYPE twi_index){ portBASE_TYPE higher_priority_task_woken = pdFALSE; uint32_t twi_status; Twi *twi_port; bool transfer_timeout = false; twi_port = all_twi_definitions[twi_index].peripheral_base_address; twi_status = twi_get_interrupt_status(twi_port); twi_status &= twi_get_interrupt_mask(twi_port); /* Has the PDC completed a transmission? */ if ((twi_status & TWI_SR_ENDTX) != 0UL) { /* Disable PDC */ pdc_disable_transfer(all_twi_definitions[twi_index].pdc_base_address, PERIPH_PTCR_TXTDIS); twi_disable_interrupt(twi_port, TWI_IDR_ENDTX); uint8_t status; uint32_t timeout_counter = 0; /* Wait for TX ready flag */ while (1) { status = twi_port->TWI_SR; if (status & TWI_SR_TXRDY) { break; } /* Check timeout condition. */ if (++timeout_counter >= TWI_TIMEOUT_COUNTER) { transfer_timeout = true; break; } } /* Complete the transfer - stop and last byte */ twi_port->TWI_CR = TWI_CR_STOP; twi_port->TWI_THR = twis[twi_index].buffer[twis[twi_index].length-1]; /* Wait for TX complete flag */ while (1) { status = twi_port->TWI_SR; if (status & TWI_SR_TXCOMP) { break; } /* Check timeout condition. */ if (++timeout_counter >= TWI_TIMEOUT_COUNTER) { transfer_timeout = true; break; } } /* If the driver is supporting multi-threading, then return the access mutex. */ if (tx_dma_control[twi_index].peripheral_access_mutex != NULL) { xSemaphoreGiveFromISR( tx_dma_control[twi_index].peripheral_access_mutex, &higher_priority_task_woken); } /* if the sending task supplied a notification semaphore, then notify the task that the transmission has completed. */ if (!(timeout_counter >= TWI_TIMEOUT_COUNTER)) { if (tx_dma_control[twi_index]. transaction_complete_notification_semaphore != NULL) { xSemaphoreGiveFromISR( tx_dma_control[twi_index].transaction_complete_notification_semaphore, &higher_priority_task_woken); } } } /* Has the PDC completed a reception? */ if ((twi_status & TWI_SR_ENDRX) != 0UL) { uint32_t timeout_counter = 0; uint32_t status; /* Must handle the two last bytes */ /* Disable PDC */ pdc_disable_transfer(all_twi_definitions[twi_index].pdc_base_address, PERIPH_PTCR_RXTDIS); twi_disable_interrupt(twi_port, TWI_IDR_ENDRX); /* Wait for RX ready flag */ while (1) { status = twi_port->TWI_SR; if (status & TWI_SR_RXRDY) { break; } /* Check timeout condition. */ if (++timeout_counter >= TWI_TIMEOUT_COUNTER) { break; } } /* Complete the transfer. */ twi_port->TWI_CR = TWI_CR_STOP; /* Read second last data */ twis[twi_index].buffer[(twis[twi_index].length)-2] = twi_port->TWI_RHR; /* Wait for RX ready flag */ while (1) {//.........这里部分代码省略.........
开发者ID:AndreyMostovov,项目名称:asf,代码行数:101,
示例21: __attribute__/*! * Interrupt routine notifying us a new character is available from the * GPS's uart module. * This function buffers a valid (structure and checksum) RMC sentence. The * used buffer is nmea_buffer_RMC. */void __attribute__((__interrupt__, __shadow__, __auto_psv__)) _U2RXInterrupt(void){ unsigned char c = U2RXREG; //uart1_putc(c); if (c == '$') // Beginnng of new sequence { state = 1; checksum = 0; } else if (c == '*') { if (state == 7) state = 98; else if (state == 11) state = 90; } else if (state == 90) { checksum -= (hexchar2int(c)*16); state = 91; } else if (state == 91) { nmea_buffer_GGA[nmea_buffer_GGA_counter++] = '/0'; checksum -= (hexchar2int(c)); if (checksum == 0) gga_sentence_number++; state = 92;#ifndef TEST static portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; xSemaphoreGiveFromISR( xGpsSemaphore, &xHigherPriorityTaskWoken );#endif } else if (state == 98) { checksum -= (hexchar2int(c)*16); state = 99; } else if (state == 99) { nmea_buffer_RMC[nmea_buffer_RMC_counter++] = '/0'; checksum -= (hexchar2int(c)); if (checksum == 0) rmc_sentence_number++; state = 100;// small test programs don't use FreeRTOS so we need a way to avoid #ifndef TEST static portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; xSemaphoreGiveFromISR( xGpsSemaphore, &xHigherPriorityTaskWoken );#endif } else { checksum ^= c; switch(state) { case 1: if (c == 'G') state = 2; break; case 2: if (c == 'P') state = 3; break; case 3: if (c == 'R') state = 4; else if (c == 'G') state = 8; break; case 4: if (c == 'M') state = 5; break; case 5: if (c == 'C') state = 6; break; case 6: if (c == ',') { state = 7; nmea_buffer_RMC_counter = 0; } break; case 7: if (nmea_buffer_RMC_counter < 100) nmea_buffer_RMC[nmea_buffer_RMC_counter++] = c; break;//.........这里部分代码省略.........
开发者ID:Safieddine90,项目名称:gluonpilot,代码行数:101,
示例22: DMA1_Channel2_IRQHandler/***************************************************************************** Prototype : DMA1_Channel2_IRQHandler Description : uart3 DMA-Tx Handler Input : void Output : None Return Value : Calls : Called By : History : 1.Date : 2015/9/7 Author : qiuweibo Modification : Created function*****************************************************************************/void DMA1_Channel2_IRQHandler(void){ BaseType_t xHigherPriorityTaskWoken, xResult; // xHigherPriorityTaskWoken must be initialised to pdFALSE. xHigherPriorityTaskWoken = pdFALSE; DMA_ClearITPendingBit(DMA1_IT_TC2); DMA_Cmd(DMA1_Channel2, DISABLE); // close DMA xResult = xSemaphoreTakeFromISR( xSerialTxHandleLock, &xHigherPriorityTaskWoken); if( pdTRUE != xResult) { return; } //After finish this send mission, need to do: clear status --> check next mission if (uart3_tx_dma_buf.IdleBufferIndex) { // reset buffer1 uart3_tx_dma_buf.nBuff1Offset = 0; // check for buffer2 if (uart3_tx_dma_buf.nBuff2Offset > 0) { DMA1_Channel2->CMAR = (uint32_t)uart3_tx_dma_buf.pPingPongBuff2; DMA1_Channel2->CNDTR = uart3_tx_dma_buf.nBuff2Offset; uart3_tx_dma_buf.IdleBufferIndex = 0; DMA_Cmd(DMA1_Channel2, ENABLE); // open DMA } else { uart3_tx_dma_buf.IsDMAWroking = 0; } } else { //reset buffer2 uart3_tx_dma_buf.nBuff2Offset = 0; // check for buffer1 if (uart3_tx_dma_buf.nBuff1Offset > 0) { DMA1_Channel2->CMAR = (uint32_t)uart3_tx_dma_buf.pPingPongBuff1; DMA1_Channel2->CNDTR = uart3_tx_dma_buf.nBuff1Offset; uart3_tx_dma_buf.IdleBufferIndex = 1; DMA_Cmd(DMA1_Channel2, ENABLE); // open DMA } else { uart3_tx_dma_buf.IsDMAWroking = 0; } } xResult = xSemaphoreGiveFromISR( xSerialTxHandleLock , &xHigherPriorityTaskWoken); if( xResult == pdPASS ) { // If xHigherPriorityTaskWoken is now set to pdTRUE then a context // switch should be requested. The macro used is port specific and // will be either portYIELD_FROM_ISR() or portEND_SWITCHING_ISR() - // refer to the documentation page for the port being used. portYIELD_FROM_ISR( xHigherPriorityTaskWoken ); }}
开发者ID:webom2008,项目名称:AIO.TestFixture,代码行数:79,
示例23: __ISR/******************************************************************************* * ISR: UART 2 Interrupt. * * DESCRIPTIONS: * Interrupt vector for UART 2. * *******************************************************************************/void __ISR(_UART_2_VECTOR, IPL7AUTO) UART2Interrupt(void){ unsigned char ucReceivedData; xSystemState.bBluetoothBusy = 1; // Rx interrupt. if (INTGetEnable(INT_U2RX) && INTGetFlag(INT_U2RX)) { INTClearFlag(INT_U2RX); // Read out all data available. while (UARTReceivedDataIsAvailable(UART2)) { // Read the received data. ucReceivedData = UARTGetDataByte(UART2); // Make sure there is empty space in the buffer. if ((prv_xRx.uiBufferSize - prv_xRx.uiDataCount) > 0) { // Copy the data to the buffer. prv_xRx.pucBuffer[prv_xRx.uiWritePt] = ucReceivedData; // Increase the write pointer and data count. prv_vIncPointer(&prv_xRx.uiWritePt, prv_xRx.uiBufferSize); prv_xRx.uiDataCount++; portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; xSemaphoreGiveFromISR(xBluetoothRxSemaphore, &xHigherPriorityTaskWoken); } else { xSystemError.bBluetoothError = 1; } } } // Tx interrupt. if (INTGetEnable(INT_U2TX) && INTGetFlag(INT_U2TX)) { // Loop until the Tx buffer is fully filled. while (UARTTransmitterIsReady(UART2)) { // If there is data to transmit... if (prv_xTx.uiDataCount > 0) { // Shift in the data to the transmit buffer. UARTSendDataByte(UART2, prv_xTx.pucBuffer[prv_xTx.uiReadPt]); // Increase the read pointer and decrease the data count. prv_vIncPointer(&prv_xTx.uiReadPt, prv_xTx.uiBufferSize); prv_xTx.uiDataCount--; } // Else, disable the transmit interrupt. else { INTEnable(INT_U2TX, INT_DISABLED); break; } } } // Error Interrupt. if (INTGetEnable(INT_U2E) && INTGetFlag(INT_U2E)) { INTClearFlag(INT_U2E); // Discard all data available. while (UARTReceivedDataIsAvailable(UART2)) { // Read the received data. ucReceivedData = UARTGetDataByte(UART2); } // Clear the overrun flag. if (UARTGetLineStatus(UART2) & UART_OVERRUN_ERROR) { U2STAbits.OERR = 0; } xSystemError.bBluetoothError = 1; }}
开发者ID:ReRoKit,项目名称:Rero-Main-Controller-Firmware,代码行数:87,
示例24: local_uart_handler/* * For internal use only. * A common UART interrupt handler that is called for all UART peripherals. */static void local_uart_handler(const portBASE_TYPE uart_index){ portBASE_TYPE higher_priority_task_woken = pdFALSE; uint32_t uart_status; freertos_pdc_rx_control_t *rx_buffer_definition; uart_status = uart_get_status( all_uart_definitions[uart_index].peripheral_base_address); uart_status &= uart_get_interrupt_mask( all_uart_definitions[uart_index].peripheral_base_address); rx_buffer_definition = &(rx_buffer_definitions[uart_index]); /* Has the PDC completed a transmission? */ if ((uart_status & UART_SR_ENDTX) != 0UL) { uart_disable_interrupt( all_uart_definitions[uart_index].peripheral_base_address, UART_IDR_ENDTX); /* If the driver is supporting multi-threading, then return the access mutex. */ if (tx_dma_control[uart_index].peripheral_access_mutex != NULL) { xSemaphoreGiveFromISR( tx_dma_control[uart_index].peripheral_access_mutex, &higher_priority_task_woken); } /* if the sending task supplied a notification semaphore, then notify the task that the transmission has completed. */ if (tx_dma_control[uart_index].transaction_complete_notification_semaphore != NULL) { xSemaphoreGiveFromISR( tx_dma_control[uart_index].transaction_complete_notification_semaphore, &higher_priority_task_woken); } } if ((uart_status & UART_SR_ENDRX) != 0UL) { /* It is possible to initialise the peripheral to only use Tx and not Rx. Check that Rx has been initialised. */ configASSERT(rx_buffer_definition->next_byte_to_read); configASSERT(rx_buffer_definition->next_byte_to_read != RX_NOT_USED); /* Out of DMA buffer, configure the next buffer. Start by moving the DMA buffer start address up to the end of the previously defined buffer. */ rx_buffer_definition->rx_pdc_parameters.ul_addr += rx_buffer_definition->rx_pdc_parameters.ul_size; /* If the end of the buffer has been reached, wrap back to the start. */ if (rx_buffer_definition->rx_pdc_parameters.ul_addr >= rx_buffer_definition->past_rx_buffer_end_address) { rx_buffer_definition->rx_pdc_parameters.ul_addr = rx_buffer_definition->rx_buffer_start_address; } /* Reset the Rx DMA to receive data into whatever free space remains in the Rx buffer. */ configure_rx_dma(uart_index, data_added); if (rx_buffer_definition->rx_event_semaphore != NULL) { /* Notify that new data is available. */ xSemaphoreGiveFromISR( rx_buffer_definition->rx_event_semaphore, &higher_priority_task_woken); } } /** * Normally the uart_status can't be "0" when the interrupt happened. * It happened only when in PDC mode with TXRDY and RXRDY interrupts since * the flags has been cleared by PDC. * As the TXRDY is never enabled in this service, here we * check the RXRDY interrupt case. */ if (uart_status == 0UL) { /* Character has been placed into the Rx buffer. */ if (rx_buffer_definition->rx_event_semaphore != NULL) { /* Notify that new data is available. */ xSemaphoreGiveFromISR( rx_buffer_definition->rx_event_semaphore, &higher_priority_task_woken); } } if ((uart_status & SR_ERROR_INTERRUPTS) != 0) { /* An error occurred in either a transmission or reception. Abort, and ensure the peripheral access mutex is made available to tasks. */ uart_reset_status( all_uart_definitions[uart_index].peripheral_base_address); if (tx_dma_control[uart_index].peripheral_access_mutex != NULL) { xSemaphoreGiveFromISR( tx_dma_control[uart_index].peripheral_access_mutex, &higher_priority_task_woken); }//.........这里部分代码省略.........
开发者ID:Gr3yR0n1n,项目名称:SAINTCON-2015-Badge,代码行数:101,
示例25: vI2C_ISR_Handler//.........这里部分代码省略......... /* Don't ack the last byte of the message. */ I2C_I2CONSET = i2cAA_BIT; } } else { /* Something unexpected happened - give up. */ i2cEND_TRANSMISSION( pdFAIL ); } break; case eReceiveData : /* We have just received a byte from the slave. */ if( ( I2C_I2STAT == i2cSTATUS_DATA_RXED ) || ( I2C_I2STAT == i2cSTATUS_LAST_BYTE_RXED ) ) { /* Buffer the byte just received then increment the index so it points to the next free space. */ pxCurrentMessage->pucBuffer[ lMessageIndex ] = I2C_I2DAT; lMessageIndex++; /* How many more bytes are we expecting to receive? */ lBytesLeft = pxCurrentMessage->lMessageLength - lMessageIndex; if( lBytesLeft == ( unsigned long ) 0 ) { /* This was the last byte in the message. */ i2cEND_TRANSMISSION( pdPASS ); /* If xMessageCompleteSemaphore is not null then there is a task waiting for this message to complete and we must 'give' the semaphore so the task is woken.*/ if( pxCurrentMessage->xMessageCompleteSemaphore ) { xSemaphoreGiveFromISR( pxCurrentMessage->xMessageCompleteSemaphore, &xHigherPriorityTaskWoken ); } /* Are there any other messages to transact? */ if( xQueueReceiveFromISR( xMessagesForTx, &pxCurrentMessage, &xHigherPriorityTaskWoken ) == pdTRUE ) { /* Start the next message - which was retrieved from the queue. */ I2C_I2CONSET = i2cSTA_BIT; } else { /* No more messages were found to be waiting for transaction so the bus is free. */ ulBusFree = ( unsigned long ) pdTRUE; } } else { /* There are more bytes to receive but don't ack the last byte. */ if( lBytesLeft <= i2cJUST_ONE_BYTE_TO_RX ) { I2C_I2CONCLR = i2cAA_BIT; } } } else { /* Something unexpected happened - give up. */ i2cEND_TRANSMISSION( pdFAIL ); }
开发者ID:vmandrews,项目名称:CSDC-OBC-Software,代码行数:66,
示例26: USART1_IRQHandlervoid USART1_IRQHandler (void)//следует разработать систему распознавания старого протокола или заменить на выбор вручную{ static portBASE_TYPE xHigherPriorityTaskWoken; xHigherPriorityTaskWoken = pdFALSE;// if(USART_GetITStatus(USART1, USART_IT_RXNE) != RESET) { USART_ClearITPendingBit(USART1, USART_IT_RXNE); symbol=USART_ReceiveData (USART1); //----------------------обрабатываем возможные ошибки длины кадра------------- if(recieve_count>MAX_LENGTH_REC_BUF) //если посылка слишком длинная { recieve_count=0x0; return; } if(recieve_count==0x0) { if(symbol==':')//признак старого протокола { proto_type=PROTO_TYPE_OLD; } else { if((symbol==0x0) || (symbol==0xD7))//новый протокол { proto_type=PROTO_TYPE_NEW; } else//ошибка кадра или не с начала { return; } } }switch(proto_type){ case PROTO_TYPE_OLD: { if(symbol==':') { recieve_count=0x0; } tab.tablo_proto_buf[recieve_count]=symbol; recieve_count++; if(recieve_count>1) { if(tab.tablo_proto_buf[1]==(recieve_count-2))//кадр принят { USART_ITConfig(USART1, USART_IT_RXNE , DISABLE); xSemaphoreGiveFromISR( xProtoSemaphore, &xHigherPriorityTaskWoken ); if( xHigherPriorityTaskWoken != pdFALSE ) { portEND_SWITCHING_ISR( xHigherPriorityTaskWoken ); } } } } break; case PROTO_TYPE_NEW: { //--------------------------начало кадра...проверка до длины кадра-------- if(recieve_count<6) { switch(recieve_count) { case 0: //первый символ 0 { if(symbol!=0x00) { recieve_count=0; fr_err++; //return; } } break; case 1: //второй символ 0xD7 { if(symbol!=0xD7) { recieve_count=0; //return; } } break;//.........这里部分代码省略.........
开发者ID:glocklueng,项目名称:STM32_LEVEL_INDICATOR,代码行数:101,
示例27: ADC_IRQHandler/* * ISR routines */void ADC_IRQHandler() { static signed portBASE_TYPE xHigherPriorityTaskWoken; xSemaphoreGiveFromISR(adc_conversion_semaphore, &xHigherPriorityTaskWoken);}
开发者ID:marcelobarrosalmeida,项目名称:cc2538em,代码行数:7,
示例28: semphr_give_from_isr_wrapperstatic int32_t IRAM_ATTR semphr_give_from_isr_wrapper(void *semphr, void *hptw){ return (int32_t)xSemaphoreGiveFromISR(semphr, hptw);}
开发者ID:A-Paul,项目名称:RIOT,代码行数:4,
注:本文中的xSemaphoreGiveFromISR函数示例整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 C++ xSemaphoreGiveRecursive函数代码示例 C++ xSemaphoreGive函数代码示例 |