/*
 *Function name: LEUART0_IRQHandler
 *Description : Interrupt Service Routine for LEUART0.
 */
void LEUART0_IRQHandler(void)
{
	leuartif = LEUART_IntGet(LEUART0); 	// Store the interrupt flag

	LEUART_IntClear(LEUART0, leuartif); //Clear interrupts

	if (leuartif & LEUART_IF_SIGF)
	{
		int temp = 0, i = 0;
		char tempChar[7];						// To store the Value of Temperature in char to transmit
		char temp_string[TX_bufferSize];	// Concatenated string for Message and Temperature, this will be transfered
		char copyCmp[sizeof(commandString)/sizeof(char)];							// string to store the Received string from Buffer to compare

		// Stop the LEUART reception and DMA Transfers
		for (i = 0; i < (strlen(commandString)); i++)		// Run loop till the return message (RetTemp!) length and copy RX buffer to copyCmp for comparing

		{
			copyCmp[i] = RX_Buffer[i];
		}

		copyCmp[8]='\0';

    	/* To extract the digits of the temperature variable and put in tempChar. A basic digit extraction algorithm is used and then each digit is passed one by one. */
		if (!strcmp(commandString,copyCmp)) 			// If valid Command is Received ie RetTemp!
		{
			temp = temperature*10;
			tempChar[0] = (temp/100)+48;
			temp = temp%100;
			tempChar[1] = (temp/10)+48;
			temp  = temp%10;
			tempChar[2] = '.';
			tempChar[3] = (temp)+48;
			tempChar[4] = 'C';
			tempChar[5] = '\r';
			tempChar[6] = '\n';

			strcpy(temp_string,returnMsg);					//Copy the returnMsg message in the temporary string
			strcat(temp_string,tempChar);					// Concatenate with tempChar to get the final message to be transfered

			// Enable DMA wake-up from LEUART0 TX
			LEUART0->CTRL = LEUART_CTRL_TXDMAWU;				// Enable DMA wake up for LEUART TX in EM2
			// Activate DMA for LEUART TX transfers
			DMA_ActivateBasic(DMA_CHANNEL_TX, true, false, (void *)&(LEUART0->TXDATA), (void *)temp_string, strlen(temp_string)- 1);	// -1 for the Null character which we wont transmit
		}
		else
		{
			LEUART0->CTRL = LEUART_CTRL_TXDMAWU;				// Enable DMA wake up for LEUART0 TX in EM2
			// Activate DMA for LEUART TX transfers
			DMA_ActivateBasic(DMA_CHANNEL_TX, true, false, (void *)&(LEUART0->TXDATA), (void *)errorMsg, strlen(errorMsg)-2);	// -1 for the Null character which we wont transmit
		}
		LEUART_IntEnable(LEUART0, LEUART_IF_RXDATAV); //Enable RXDATA Interrupt to check for received characters
		DMA_ActivateBasic(DMA_CHANNEL_RX, true, false, NULL, NULL, LEUART0_BUFFER-1);
	}
	else if (leuartif & LEUART_IF_RXDATAV)
	{
		LEUART_IntDisable(LEUART0, LEUART_IF_RXDATAV);	// Disable after receiving
	}

}
示例#2
0
void LEUART0_IRQHandler(void)
{
    uint32_t flags = LEUART_IntGet(LEUART0);
    LEUART_IntClear(LEUART0, flags);

    if (flags & LEUART_IF_SIGF)
    {
        DMADRV_StopTransfer(dmaChannel);

        xSemaphoreGiveFromISR(lineEndReceived, NULL);
    }

    portEND_SWITCHING_ISR(NULL);
}