From 5b1afe32cf7496acea8182278aca83f59e8384e3 Mon Sep 17 00:00:00 2001 From: Florian Pritz Date: Mon, 11 Feb 2013 22:58:16 +0100 Subject: Make code launchpad/energia compatible Signed-off-by: Florian Pritz --- lib/msp430/usci_isr_handler.c | 59 +++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 59 insertions(+) create mode 100644 lib/msp430/usci_isr_handler.c (limited to 'lib/msp430/usci_isr_handler.c') diff --git a/lib/msp430/usci_isr_handler.c b/lib/msp430/usci_isr_handler.c new file mode 100644 index 0000000..a112ce7 --- /dev/null +++ b/lib/msp430/usci_isr_handler.c @@ -0,0 +1,59 @@ +#include "Energia.h" +#if defined(__MSP430_HAS_USCI__) || defined(__MSP430_HAS_EUSCI_A0__) +#include "usci_isr_handler.h" + +/* This dummy function ensures that, when called from any module that + * is interested in having the USCIAB0TX_VECTOR and USCIAB0TX_VECTOR + * installed, the linker won't strip the vectors.*/ +void usci_isr_install(){} + + + +#if defined(__MSP430_HAS_EUSCI_A0__) +__attribute__((interrupt(USCI_A0_VECTOR))) +void USCIA0_ISR(void) +{ + switch ( UCA0IV ) + { + case USCI_UART_UCRXIFG: uart_rx_isr(); break; + case USCI_UART_UCTXIFG: uart_tx_isr(); break; + } +} + +#else // #if defined(__MSP430_HAS_EUSCI_A0__) +/* USCI_Ax and USCI_Bx share the same TX interrupt vector. + * UART: + * USCIAB0TX_VECTOR services the UCA0TXIFG set in UC0IFG. + * USCIAB0RX_VECTOR services the UCA0RXIFG set in UC0IFG. + * I2C: + * USCIAB0TX_VECTOR services both UCB0TXIFG and UCB0RXIFG + * set in UC0IFG. + * USCIAB0RX_VECTOR services the state change interrupts + * UCSTTIFG, UCSTPIFG, UCIFG, UCALIFG set in UCB0STAT.*/ + +__attribute__((interrupt(USCIAB0TX_VECTOR))) +void USCIAB0TX_ISR(void) +{ + /* USCI_A0 UART interrupt? */ + if (UC0IFG & UCA0TXIFG) + uart_tx_isr(); + + /* USCI_B0 I2C TX RX interrupt. */ + if ((UC0IFG & (UCB0TXIFG | UCB0RXIFG)) != 0) + i2c_txrx_isr(); + +} + +__attribute__((interrupt(USCIAB0RX_VECTOR))) +void USCIAB0RX_ISR(void) +{ + /* USCI_A0 UART interrupt? */ + if (UC0IFG & UCA0RXIFG) + uart_rx_isr(); + + /* USCI_B0 I2C state change interrupt. */ + if ((UCB0STAT & (UCALIFG | UCNACKIFG | UCSTTIFG | UCSTPIFG)) != 0) + i2c_state_isr(); +} +#endif // #if defined(__MSP430_HAS_EUSCI_A0__) +#endif // if defined(__MSP430_HAS_USCI__) || defined(__MSP430_HAS_EUSCI_A0__) -- cgit v1.2.3-24-g4f1b