void Uart::interruptHandler(void) { uint32_t status; // Read interrupt source status = UARTIntStatus(uart_.base, true); // Clear UART interrupt in the NVIC IntPendClear(uart_.interrupt); // Process TX interrupt if (status & UART_INT_TX) { UARTIntClear(uart_.base, UART_INT_TX); interruptHandlerTx(); } // Process RX interrupt if (status & UART_INT_RX || status & UART_INT_RT) { UARTIntClear(uart_.base, UART_INT_RX | UART_INT_RT); interruptHandlerRx(); } }
/************************************************************************************************* * @fn UART Rx/Tx ISR * * @brief Called when a serial byte is ready to read and/or write. * NOTE: Assumes that uartRecord.configured is TRUE if this interrupt is enabled. * * @param void * * @return void **************************************************************************************************/ void HalUartISR(void) { UARTIntClear(HAL_UART_PORT, (UART_INT_RX | UART_INT_RT)); procRx(); UARTIntClear(HAL_UART_PORT, (UART_INT_TX | UART_INT_CTS)); procTx(); }
/* * SIOの割込みサービスルーチン */ void sio_isr(intptr_t exinf) { SIOPCB *p_siopcb; p_siopcb = get_siopcb(exinf); /* * 割込みのクリア */ UARTIntClear(p_siopcb->p_siopinib->base, UARTIntStatus(p_siopcb->p_siopinib->base, true)); if (UARTCharsAvail(p_siopcb->p_siopinib->base)) { /* * 受信通知コールバックルーチンを呼び出す. */ sio_irdy_rcv(p_siopcb->exinf); } if (UARTSpaceAvail(p_siopcb->p_siopinib->base)) { /* * 送信可能コールバックルーチンを呼び出す. */ sio_irdy_snd(p_siopcb->exinf); } }
void UART0_Handler() { c_pos_intEnter(); uint32_t status; status = UARTIntStatus(PORTCFG_CON_USART, true); UARTIntClear(PORTCFG_CON_USART, status); if (status & UART_INT_TX) c_nos_putcharReady(); #if NOSCFG_FEATURE_CONIN == 1 if (status & (UART_INT_RX | UART_INT_RT)) { unsigned char ch; while (UARTCharsAvail(PORTCFG_CON_USART)) { ch = UARTCharGetNonBlocking(PORTCFG_CON_USART); c_nos_keyinput(ch); } } #endif c_pos_intExitQuick(); }
void UARTIntHandler(void) { uint32_t ui32Status; ui32Status = UARTIntStatus(UART0_BASE, true); //get interrupt status UARTIntClear(UART0_BASE, ui32Status); //clear the asserted interrupts if(UARTCharGetNonBlocking(UART0_BASE) == 'S'){ char m[] = "Enter The Temperature : "; char h[100] = "Set temperature Updated to "; int i; int l; l=0; for(i=0;m[i];i++){ UARTCharPut(UART0_BASE, m[i]); } int x=0; while(1){ char c; if(UARTCharsAvail(UART0_BASE)){ c= UARTCharGetNonBlocking(UART0_BASE); UARTCharPut(UART0_BASE, c); if(c=='\r') break; h[27+l]=c; x=10*x+c-'0'; l++; } } settemp = x; for(i=0;i<27+l;i++){ UARTCharPut(UART0_BASE, h[i]); } UARTCharPut(UART0_BASE, '*'); UARTCharPut(UART0_BASE, 'C'); UARTCharPut(UART0_BASE, '\r'); UARTCharPut(UART0_BASE,'\n'); } }
void UART1_Handler(void) { unsigned long ulStatus; // // Get the interrrupt status. // ulStatus = UARTIntStatus(UART1_BASE, true); if(ulStatus & UART_INT_TX) { // TX Interrupt fired // with fifos disabled this fires when there is nothing in the tx buffer } else if(ulStatus & UART_INT_RX) { // RX Interrupt fired // with fifos disabled this fires when there is something in the rx buffer UARTRX_FLAG = true; } // // Clear the asserted interrupts. // UARTIntClear(UART1_BASE, ulStatus); }
// UART-interrupt for bluetooth communication void uartIntHandler(void) { // Clear the interrupt UARTIntClear(UART5_BASE, UARTIntStatus(UART5_BASE, true)); // Set the corresponding flag in vector int_vec |= UART_INT; }
static void UART2_RxTxHandler(void) { uint32_t IntStatus, byteCnt, timeout = 1000000; uint8_t c; IntStatus = UARTIntStatus(UART2_BASE, true); UARTIntClear(UART2_BASE, IntStatus); if(IntStatus & UART_INT_TX) { byteCnt = RINGBUF_GetFill(&long_Uart2_TxRingBuf); if (byteCnt) { RINGBUF_Get(&long_Uart2_TxRingBuf, &c); UARTCharPutNonBlocking(UART2_BASE, c); if (byteCnt == 1) { UARTIntDisable(UART2_BASE, UART_INT_TX); } } else { UARTIntDisable(UART2_BASE, UART_INT_TX); } } else if (IntStatus & (UART_INT_RX | UART_INT_RT)) { while(!UARTCharsAvail(UART2_BASE) && (timeout--)); c = UARTCharGet(UART2_BASE); RINGBUF_Put(&long_Uart0_RxRingBuf,c); } else { c = UARTCharGet(UART2_BASE); } }
static void charIntHandler(char_device *dev) { portBASE_TYPE xHigherPriorityTaskWoken = pdFALSE; unsigned long ulStatus; unsigned char ucData; // // Get the interrrupt status. // ulStatus = UARTIntStatus(dev->PortBase, true); // // Clear the asserted interrupts. // UARTIntClear(dev->PortBase, ulStatus); if(ulStatus & UART_INT_RX){ ucData =UARTCharGet(dev->PortBase); xQueueSendFromISR(dev->RxQueue, &ucData, &xHigherPriorityTaskWoken); } if(ulStatus & UART_INT_TX){ if(xQueueReceiveFromISR(dev->TxQueue, &ucData, &xHigherPriorityTaskWoken)) UARTCharPut(dev->PortBase, ucData); } portEND_SWITCHING_ISR( xHigherPriorityTaskWoken ); }
void UARTIntHandler() { uint32_t ui32Status; uint32_t ui32ADC0Value[4]; // ADC FIFO volatile uint32_t ui32TempAvg; // Store average volatile uint32_t ui32TempValueC; // Temp in C volatile uint32_t ui32TempValueF; // Temp in F ui32Status = UARTIntStatus(UART0_BASE, true); //get interrupt status UARTIntClear(UART0_BASE, ui32Status); //clear the asserted interrupts ADCIntClear(ADC0_BASE, 2); // Clear ADC0 interrupt flag. ADCProcessorTrigger(ADC0_BASE, 2); // Trigger ADC conversion. while (!ADCIntStatus(ADC0_BASE, 2, false)) ; // wait for conversion to complete. ADCSequenceDataGet(ADC0_BASE, 2, ui32ADC0Value); // get converted data. // Average read values, and round. // Each Value in the array is the result of the mean of 64 samples. ui32TempAvg = (ui32ADC0Value[0] + ui32ADC0Value[1] + ui32ADC0Value[2] + ui32ADC0Value[3] + 2) / 4; ui32TempValueC = (1475 - ((2475 * ui32TempAvg)) / 4096) / 10; // calc temp in C ui32TempValueF = ((ui32TempValueC * 9) + 160) / 5; //while(UARTCharsAvail(UART0_BASE)) //loop while there are chars //{ // UARTCharPutNonBlocking(UART0_BASE, UARTCharGetNonBlocking(UART0_BASE)); //echo character GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2); //blink LED SysCtlDelay(SysCtlClockGet() / (1000 * 3)); //delay ~1 msec GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0); //turn off LED //} }
//UART Int Handler. Will handle the data recieved and put in an array. WILL NOT UNDERSTAND JUST STORE void Uart2IntHandler(void){ unsigned long ulStatus; ulStatus=UARTIntStatus(UART2_BASE, true); //This reports if the interrupt was a transmit recieve etc, only reports one's setup to be detected in initalization could possibly remove transmit detection UARTIntClear(UART2_BASE, ulStatus); //Clears the interrupt so it does not detect itself. if(ulStatus & UART_INT_TX){ //Transmit was requested I don't think anything needs to be done here I could probably get rid of this and the interrupt for it but for now im leaving it. UARTSend does this job in a cleaner way }else if(ulStatus & UART_INT_RX || ulStatus & UART_INT_RT){ //If recieved data GPIOPinWrite(GPIO_PORTF_BASE,GPIO_PIN_1|GPIO_PIN_2|GPIO_PIN_3,0x08); while(UARTCharsAvail(UART2_BASE)){ //While there is still data available to read char buffer = UARTCharGetNonBlocking(UART2_BASE); //Read the data into a buffer for scanning if((buffer == 0xFA)&&(commandAddress == -2)){ //Is it the first dummy byte commandAddress=-1; //Set the command Address to -1 this way the dummy byte is the only starting byte for a packet to be accepeted }else if((buffer == 0xEB)&&(commandAddress == -1)){ //Is the second dummy byte read commandAddress=0; //Prepare to read data the dummy byte's have been validated }else if(commandAddress>=0){ //Read in because it's not a dummy byte, prep for reading recievedCommands[commandAddress]=buffer; commandAddress++; //Some efficiency could be done here. Remove this line than change the bottom to have ++commandAddress. But that's nitpicky stuff commandAddress = (commandAddress>4) ? -2 : commandAddress; //If greater than 6 set to -1 else set to self } } //UARTCount = ((UARTCount+1)%65534); //Again not sure of datatype sizes so go with what works right. } }
/** * Turn off interrupt sources that may interrupt us (SysTick and Ethernet) and then switch control * to the Boot Loader. This will never return! */ void halSwitchToBootloader() { while(UARTCharsAvail(UART0_BASE)) { UARTCharGet(UART0_BASE); } EthernetIntDisable(ETH_BASE, 0xFFFF); SysTickIntDisable(); IntDisable(INT_UART0); UARTIntDisable(UART0_BASE, UART_INT_RX | UART_INT_RT); UARTIntClear(UART0_BASE, UART_INT_RX | UART_INT_RT); delayMs(100); // Call the boot loader so that it will listen for an update on the UART. (*((void (*)(void))(*(unsigned long *)0x2c)))(); // // The boot loader should take control, so this should never be reached. // Just in case, loop forever. // while(1) { } }
void uartb_intHandler(){ int tmp=0; // detect the event that triggered the interrupt unsigned long intStatus=UARTIntStatus(UART_BUFFERIZED_BASE,1); // Clear the interrupt (done early because rtfm) UARTIntClear(UART_BUFFERIZED_BASE,intStatus); // if it is on RX fifo limit or RX timeout, put these bits in circular buffer if (intStatus==UART_INT_RT || intStatus==UART_INT_RX){ UARTIntDisable(UART_BUFFERIZED_BASE,(UART_INT_RT | UART_INT_RX)); while (UARTCharsAvail(UART_BUFFERIZED_BASE)){ // RDA interrupt tmp = (rxbuf.head+1)%UART_BUFFERIZED_CBUFF_SIZE; if(tmp != rxbuf.tail){ rxbuf.cbuf[rxbuf.head] = UARTCharGetNonBlocking(UART_BUFFERIZED_BASE); rxbuf.head = tmp; } } UARTIntEnable(UART_BUFFERIZED_BASE,(UART_INT_RT | UART_INT_RX)); } // xxx if it is on TX fifo limit, what should we do ? loop until fifo is free again ? useless if blocking writes are used. // otherwise, discard whitout doing anything (done at the beginning of the function, see doc for "why ?". }
//***************************************************************************** // // The UART interrupt handler. // //***************************************************************************** void UART0IntHandler(void) { unsigned long ulStatus; // // Get the interrrupt status. // ulStatus = UARTIntStatus(UART0_BASE, true); // // Clear the asserted interrupts. // UARTIntClear(UART0_BASE, ulStatus); // // Loop while there are characters in the receive FIFO. // while(UARTCharsAvail(UART0_BASE)) { // // Read the next character from the UART and write it back to the UART. // UARTCharPutNonBlocking(UART0_BASE, UARTCharGetNonBlocking(UART0_BASE)); } }
void UARTIntHandler(void) { // UARTCharPut(UART0_BASE, 'a'); uint32_t ui32Status; ui32Status = UARTIntStatus(UART3_BASE, true); //get interrupt status // UARTCharPut(UART0_BASE, 'a'); UARTIntClear(UART3_BASE, ui32Status); //clear the asserted interrupts // UARTCharPut(UART0_BASE, 'a'); while(UARTCharsAvail(UART3_BASE)) //loop while there are chars { // UARTCharPut(UART0_BASE, 'a'); char x = UARTCharGetNonBlocking(UART3_BASE); UARTCharPut(UART0_BASE, x); buf[it++] = x; } buf[it]='\0'; char *ptr = strstr(buf,"OK\r\n"); if(ptr != NULL) { SIM908_status = true; } // UARTCharPutNonBlocking(UART0_BASE, 'a'); // buf[it]='\0'; // // if(strncmp(buf, "OK", 2) == 0) SIM908_status = true; // else if(strncmp(buf, "ERROR", 5) == 0) { // // } // else { // // } }
//***************************************************************************** // // This function handles the UART interrupt. It will copy data from the // software FIFO to the hardware. // //***************************************************************************** void LogIntHandler(void) { // // Clear the UART interrupt. // UARTIntClear(UART1_BASE, UART_INT_TX); // // Loop while there is more data to be transferred from the software FIFO. // while(g_ulReadPtr != g_ulWritePtr) { // // Transfer the next byte to the UART. Break out of the loop if the // hardware FIFO is full. // if(UARTCharPutNonBlocking(UART1_BASE, g_pcTransmitBuffer[g_ulReadPtr]) == false) { break; } // // This byte has been transferred to the UART, so remove it from the // software FIFO. // g_ulReadPtr = (g_ulReadPtr + 1) & (SOFT_FIFO_SIZE - 1); } }
void UARTinterrupcion(void) { char cThisChar; int n=0; int m_nTxBuffIn1 = 16; unsigned long ulStatus; // // Obtengo el estado de la interrupcion // ulStatus = UARTIntStatus(UART1_BASE, true); // // Limpio los flags de interrupcion // UARTIntClear(UART1_BASE, ulStatus); if(RIGHT_BUTTON){;} if(ulStatus && UART_INT_RX){ } while(m_nTxBuffIn1>0 && UARTCharsAvail(UART1_BASE)) { // // Lee el proximo caracter de la FIFO de recepcion. // cThisChar = UARTCharGetNonBlocking(UART1_BASE); UARTCharPut(UART0_BASE, cThisChar); m_nTxBuffIn1--; n=n+1; } }
void stellaris_uart0_irq(void) { arm_cm_irq_entry(); // // Get the interrrupt status. // unsigned long ulStatus = UARTIntStatus(DEBUG_UART, true); // // Clear the asserted interrupts. // UARTIntClear(DEBUG_UART, ulStatus); // // Loop while there are characters in the receive FIFO. // bool resched = false; while (UARTCharsAvail(DEBUG_UART)) { // // Read the next character from the UART and write it back to the UART. // unsigned char c = UARTCharGetNonBlocking(DEBUG_UART); cbuf_write_char(&debug_rx_buf, c, false); resched = true; } arm_cm_irq_exit(resched); }
//***************************************************************************** // // The UART interrupt handler. // //***************************************************************************** void UART0IntHandler(void) { unsigned long ulStatus; tBoolean bRc; // // Get the interrrupt status. // ulStatus = UARTIntStatus(UART0_BASE, true); // // Clear the asserted interrupts. // UARTIntClear(UART0_BASE, ulStatus); // // Check what is the source of the interrupt // //if(ulStatus & UART_INT_OE) //{ //} //else if(ulStatus & UART_INT_BE) //{ //} //else if(ulStatus & UART_INT_PE) //{ //} if(ulStatus & UART_INT_TX) { // TX int // Push next char to transmitter bRc = true; while(m_nTxBuffIn > 0 && bRc == true) { bRc = UARTCharPutNonBlocking(UART0_BASE,m_tTxBuff[m_nTxNextNdx]); if(bRc == true) { m_nTxNextNdx++; m_nTxBuffIn--; } } } else if(ulStatus & UART_INT_RX || ulStatus & UART_INT_RT) { // RX int // Read all RX fifo data while(UARTCharsAvail(UART0_BASE)) { // Read the next character from the UART // (and write it back to the UART) ? #if defined(stabilizition) ContropMessageLoop(UART0_BASE,0); #else MessageLoop(UART0_BASE,0); #endif } } }
void UARTIntHandler(void) { uint32_t ui32Status; ui32Status = UARTIntStatus(UART0_BASE, true); //get interrupt status UARTIntClear(UART0_BASE, ui32Status); //clear the asserted interrupts while(UARTCharsAvail(UART0_BASE)) //loop while there are chars { char x = UARTCharGetNonBlocking(UART0_BASE); if(mode == 0 && x == 's') { mode = 1; UARTStrPut("Enter the temperature : "); newSet = 0; } else if (mode == 1) { if (x == 127 && newSet > 0) { // backspace UARTCharPut(UART0_BASE, 127); newSet /= 10; } else if (x >= 48 && x <= 57) { // digit UARTCharPut(UART0_BASE, x); newSet = newSet*10 + (x - 48); } else if (x == 13) { // new line (enter) setTemp = newSet; UARTStrPut("\r\nSet Temperature updated to "); UARTIntPut(setTemp); UARTCharPut(UART0_BASE, 176); UARTStrPut("C\r\n"); mode = 0; } } } }
void rien(void) { unsigned long ulStatus; ulStatus = UARTIntStatus(UART5_BASE, true); UARTIntClear(UART5_BASE, ulStatus); while(UARTCharsAvail(UART5_BASE)) { char c = UARTCharGet(UART5_BASE); switch(UART5_buffer_state) { case 1: //On reçoit alpha, beta et gamma *UART5_buffer_pointer = c; UART5_buffer_pointer++; if (UART5_buffer_pointer - UART5_buffer >= 3) { UART5_buffer_state = 0; UART5_buffer_pointer = UART5_buffer; unsigned char should_move = UART5_buffer[2]; if (should_move) { go_angle = UART5_buffer[0] | (UART5_buffer[1] << 8); if (go_angle > 360) go_angle = 0; new_order = 1; } else { new_order = 0; } } break; default: //On reçoit un int de start ou une commande aimant if ((c == 0xFE) && (UART5_buffer_pointer - UART5_buffer == 3)) { //Aimant activé UART5_buffer_pointer = UART5_buffer; actuators_servo_raise(0); actuators_servo_raise(1); } else if ((c == 0xFD) && (UART5_buffer_pointer - UART5_buffer == 3)) { //Aimant désactivé actuators_servo_lower(0); actuators_servo_lower(1); UART5_buffer_pointer = UART5_buffer; } else if (c != 0xFF) { //Truc pas normal, on reset la stack UART5_buffer_pointer = UART5_buffer; } else { //Octet de start *UART5_buffer_pointer = c; UART5_buffer_pointer++; if (UART5_buffer_pointer - UART5_buffer >= 4) { //Passage en réception des angles UART5_buffer_state = 1; UART5_buffer_pointer = UART5_buffer; } } } } }
/** * @brief Tratamiento de interrupciones. * * @return - * * Tratamiento de las interrupciones de la UART. */ void UARTIntHandlerLogic(int nPort) { unsigned long ulStatus; /*El estado de la interrupcion*/ ulStatus = UARTIntStatus(gs_ul_uarts_bases[nPort], true); if(ulStatus & (UART_INT_RX | UART_INT_RT )) { fromHwFIFO(nPort); } if(ulStatus & UART_INT_TX) { if(gs_cu_uarts[nPort].outHead!=gs_cu_uarts[nPort].outTail) { if(!gs_cu_uarts[nPort].writingToBuf) toHwFIFO(nPort); else gs_cu_uarts[nPort].intWhileWriting=1; } UARTIntClear(gs_ul_uarts_bases[nPort], UART_INT_TX); } UARTIntClear(gs_ul_uarts_bases[nPort], ulStatus); }
void UARTIntHandler0() { unsigned long ulStatus; static char tempPacket = 0; ulStatus = UARTIntStatus(UART0_BASE, true); UARTIntClear(UART0_BASE, ulStatus); while (UARTCharsAvail(UART0_BASE)) { tempPacket = UARTCharGetNonBlocking(UART0_BASE); } }
void UARTIntHandler() { u32 temp; int c; temp = UARTIntStatus(uart_base[ CON_UART_ID ], true); UARTIntClear(uart_base[ CON_UART_ID ], temp); while( UARTCharsAvail( uart_base[ CON_UART_ID ] ) ) { c = UARTCharGetNonBlocking( uart_base[ CON_UART_ID ] ); buf_write( BUF_ID_UART, CON_UART_ID, ( t_buf_data* )&c ); } }
//UART0 interrupt handler void UARTIntHandler0(void) { unsigned long ulStatus; // Get the interrrupt status. ulStatus = UARTIntStatus(UART0_BASE, true); // Clear the asserted interrupts. UARTIntClear(UART0_BASE, ulStatus); }
void UARTINtHandler(void) { uint32_t ui32Status; ui32Status = UARTIntStatus(UART0_BASE, true); // Thuc hien lay trang thai ngat UARTIntClear(UART0_BASE, ui32Status); //Xoa co ngat uart while(UARTCharsAvail(UART0_BASE)) //Thuc hien cho ki tu { UARTCharPutNonBlocking(UART0_BASE, UARTCharGetNonBlocking(UART0_BASE)); //nhan ki tu GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, GPIO_PIN_2); //chop tat led SysCtlDelay(SysCtlClockGet()/(1000*3)); //Thuc hien delay khoang 1ms GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_2, 0); //Tat LED } }
void UART1_intHandler() { unsigned long intStatus; intStatus = UARTIntStatus(CC3100_UARTBASE,0); UARTIntClear(CC3100_UARTBASE,intStatus); #ifdef SL_IF_TYPE_UART if((pIrqEventHandler != 0) && (IntIsMasked == FALSE)) { pIrqEventHandler(0); } #endif }
int main(void) { char cThisChar; SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL |SYSCTL_XTAL_16MHZ| SYSCTL_OSC_MAIN ); //Para el SW1 /*SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF); GPIODirModeSet(GPIO_PORTF_BASE, 0xFF, GPIO_DIR_MODE_IN); GPIOPinIntEnable(GPIO_PORTB_BASE, 0xFF); IntEnable(INT_GPIOF);*/ SysCtlPeripheralEnable(SYSCTL_PERIPH_UART0); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOA); SysCtlPeripheralEnable(SYSCTL_PERIPH_UART1); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB); GPIOPinConfigure(GPIO_PA0_U0RX); GPIOPinConfigure(GPIO_PA1_U0TX); GPIOPinConfigure(GPIO_PB0_U1RX); GPIOPinConfigure(GPIO_PB1_U1TX); GPIOPinTypeUART(GPIO_PORTB_BASE, GPIO_PIN_0 | GPIO_PIN_1); GPIOPinTypeUART(GPIO_PORTA_BASE, GPIO_PIN_0 | GPIO_PIN_1); UARTConfigSetExpClk(UART1_BASE, SysCtlClockGet(), 9600, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); UARTConfigSetExpClk(UART0_BASE, SysCtlClockGet(), 9600, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE)); UARTFIFOLevelSet(UART1_BASE,UART_FIFO_TX7_8,UART_FIFO_RX7_8); UARTIntClear(UART1_BASE, UART_INT_TX | UART_INT_RX); UARTIntEnable(UART1_BASE, UART_INT_RX); UARTFIFOEnable(UART1_BASE); IntMasterEnable(); UARTEnable(UART1_BASE); IntEnable(INT_UART1); for(n=0; n<sizeof(buferA); n++){ UARTCharPut(UART1_BASE, buferA[n]);} for(m=0; m<sizeof(buferC); m++){ UARTCharPut(UART1_BASE, buferC[m]);} while(1){;} }
//UART1 interrupt handler void UARTIntHandler1 () { unsigned long ulStatus; unsigned long c; int display_offset = 0; int i; int errorFlag = 0; // Get the interrrupt status. ulStatus = UARTIntStatus(UART1_BASE, true); // Clear the asserted interrupts. UARTIntClear(UART1_BASE, ulStatus); // Loop while there are characters in the receive FIFO. while(UARTCharsAvail(UART1_BASE)) { c = UARTCharGet(UART1_BASE); display2[display_offset++] = (char)c; } display2[display_offset-1] = '\0'; for(i = 0; i < (display_offset - 1); i++) { if(display2[i] == 'p') { errorFlag = 1; } } if(errorFlag == 1) { RIT128x96x4Clear(); RIT128x96x4StringDraw("----------------------", 0, 50, 15); RIT128x96x4StringDraw("Error", 50, 75, 15); RIT128x96x4StringDraw(display, 0, 0, 15); } else { RIT128x96x4Clear(); RIT128x96x4StringDraw("----------------------", 0, 50, 15); RIT128x96x4StringDraw(display, 0, 0, 15); RIT128x96x4StringDraw(display2, 0, 60, 15); } }
void UART_IRQ(tUART* uart){ // Get raw interrupt status volatile int flag = UARTIntStatus(uart -> base, true); // Ack Interrupt UARTIntClear(uart -> base, flag); // Handle the interrupt // TODO: This is messy. Clean it up if (flag == uart_int_flags[0]) uart -> irq[0](); else if (flag == uart_int_flags[1]) uart -> irq[1](); }