/*
 *  ======== UARTMSP432_hwiIntFxn ========
 *  Hwi function that processes UART interrupts.
 *
 *  @param(arg)         The UART_Handle for this Hwi.
 */
void UARTMSP432_hwiIntFxn(uintptr_t arg)
{
    bool                      readSuccess = true;
    uint8_t                   status;
    uintptr_t                 errorFlags;
    UARTMSP432_Object        *object = ((UART_Handle) arg)->object;
    UARTMSP432_HWAttrs const *hwAttrs = ((UART_Handle) arg)->hwAttrs;

    /* Clear interrupts */
    status = MAP_UART_getEnabledInterruptStatus(hwAttrs->baseAddr);
    MAP_UART_clearInterruptFlag(hwAttrs->baseAddr, status);

    if (status & EUSCI_A_UART_RECEIVE_INTERRUPT_FLAG) {
        readSuccess = object->readFxns.readIsrFxn((UART_Handle)arg);
    }

    if (status & EUSCI_A_UART_TRANSMIT_INTERRUPT_FLAG) {
        writeData((UART_Handle)arg);
    }

    if (status & (EUSCI_A_UART_RECEIVE_ERRONEOUSCHAR_INTERRUPT |
        EUSCI_A_UART_BREAKCHAR_INTERRUPT) || !readSuccess) {

        errorFlags = MAP_UART_queryStatusFlags(hwAttrs->baseAddr,
            EUSCI_A_UART_OVERRUN_ERROR | EUSCI_A_UART_BREAK_DETECT |
            EUSCI_A_UART_PARITY_ERROR | EUSCI_A_UART_FRAMING_ERROR);

        errorCallback((UART_Handle)arg, errorFlags);
    }
}
/* EUSCI A0 UART ISR - Echoes data back to PC host */
void euscia0_isr(void)
{
    uint32_t status = MAP_UART_getEnabledInterruptStatus(EUSCI_A0_MODULE);

    MAP_UART_clearInterruptFlag(EUSCI_A0_MODULE, status);

    if(status & EUSCI_A_UART_RECEIVE_INTERRUPT)
    {
        MAP_UART_transmitData(EUSCI_A0_MODULE, MAP_UART_receiveData(EUSCI_A0_MODULE));
    }

}
/* EUSCI A0 UART ISR - Echos data back to PC host */
void euscia0_isr(void)
{
    uint32_t status = MAP_UART_getEnabledInterruptStatus(EUSCI_A0_MODULE);

    MAP_UART_clearInterruptFlag(EUSCI_A0_MODULE, status);

    if(status & EUSCI_A_UART_RECEIVE_INTERRUPT)
    {
        RXData = MAP_UART_receiveData(EUSCI_A0_MODULE);

        if(RXData != TXData)              // Check value
        {
            MAP_GPIO_setOutputHighOnPin(GPIO_PORT_P1, GPIO_PIN0);
            while(1);                       // Trap CPU
        }
        TXData++;
        MAP_Interrupt_disableSleepOnIsrExit();
    }

}
Beispiel #4
0
/*
 * See the serial2.h header file.
 */
xComPortHandle xSerialPortInitMinimal( unsigned long ulWantedBaud, unsigned long uxQueueLength )
{
	/* Create the queue used to hold received characters.  NOTE THE COMMENTS AT
	THE TOP OF THIS FILE REGARDING THE USE OF QUEUES FOR THIS PURPSOE. */
	xRxQueue = xQueueCreate( uxQueueLength, sizeof( char ) );
	configASSERT( xRxQueue );

	/* Use the library functions to initialise and enable the UART. */
	MAP_UART_initModule( EUSCI_A0_MODULE, &xUARTConfig );
	MAP_UART_enableModule( EUSCI_A0_MODULE );
	MAP_UART_clearInterruptFlag( EUSCI_A0_MODULE, EUSCI_A_UART_RECEIVE_INTERRUPT | EUSCI_A_UART_TRANSMIT_INTERRUPT );
	MAP_UART_enableInterrupt( EUSCI_A0_MODULE, EUSCI_A_UART_RECEIVE_INTERRUPT );

	/* The interrupt handler uses the FreeRTOS API function so its priority must
	be at or below the configured maximum system call interrupt priority.
	configKERNEL_INTERRUPT_PRIORITY is the priority used by the RTOS tick and
	(should) always be set to the minimum priority. */
	MAP_Interrupt_setPriority( INT_EUSCIA0, configKERNEL_INTERRUPT_PRIORITY );
	MAP_Interrupt_enableInterrupt( INT_EUSCIA0 );

	/* Only one UART is supported so the handle is not used. */
	return ( xComPortHandle ) 0;
}