X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fchips%2Fmsp430%2Fusci%2FHplMsp430UsciInt1P.nc;h=2b9b1d4fa052a57766677ff98330b624e1ecc5ea;hb=59a38cc43b09cc83e1a414ec0531588abab72cc9;hp=c083cdb9a637d7dfa4847b11cc78cdfd79713c06;hpb=97db9cf16631f784eea3fc7a3ec925f09bc65c08;p=tinyos-2.x.git diff --git a/tos/chips/msp430/usci/HplMsp430UsciInt1P.nc b/tos/chips/msp430/usci/HplMsp430UsciInt1P.nc index c083cdb9..2b9b1d4f 100644 --- a/tos/chips/msp430/usci/HplMsp430UsciInt1P.nc +++ b/tos/chips/msp430/usci/HplMsp430UsciInt1P.nc @@ -55,40 +55,55 @@ implementation MSP430REG_NORACE(UCB1RXBUF); #endif - /* This USCI_Ax and USCI_Bx interrupt vector signals receive events for UART - * and SPI modes, and status events for I2C modes. Only Bx can do I2C. + /* This interrupt vector signals receive events. USCI_A1 can receive events + * for UART and SPI modes, while USCI_B1 can receive events for I2C and SPI + * modes. */ TOSH_SIGNAL(USCIAB1RX_VECTOR) { - if (READ_FLAG(UC1IFG, UCA1RXIFG)) { + if (READ_FLAG(UC1IFG & UC1IE, UCA1RXIE)) { volatile uint8_t c = UCA1RXBUF; /* read to clear UCA1RXIFG */ if (READ_FLAG(UCA1CTL1, UCBRK)) { - UCA1CTL1 &= ~UCBRK; + CLR_FLAG(UCA1CTL1, UCBRK); if (READ_FLAG(UCA1CTL0, UCMODE_3) == UCMODE_3) - UCA1CTL1 &= ~UCDORM; + CLR_FLAG(UCA1CTL1, UCDORM); signal IntA.brk(); } else signal IntA.rx(c); - } else if (READ_FLAG(UC1IFG, UCB1RXIFG)) + } else if (READ_FLAG(UC1IFG & UC1IE, UCB1RXIE)) { signal IntB.rx(UCB1RXBUF); /* read clears UCB1RXIFG */ - else if (READ_FLAG(UCB1STAT, UCALIFG)) + + /* FIXME: the arbitration of I2C interrupts are not vetted. If, for example + * the UCALIFG bit gets set and neither it nor the corresponding interrupt + * enable bit is never unset, then an ISR configured for UCSTTIFG or + * UCSTPIFG will never be signalled. + */ + + } else if (READ_FLAG(UCB1STAT, UCALIFG)) { + CLR_FLAG(UCB1STAT, UCALIFG); signal IntB.i2cCal(); - else if (READ_FLAG(UCB1STAT, UCNACKIFG)) + } else if (READ_FLAG(UCB1STAT, UCNACKIFG)) { + CLR_FLAG(UCB1STAT, UCNACKIFG); + CLR_FLAG(UC1IFG, UCB1TXIFG); /* Errata USCI25; 'reset' means clear? */ signal IntB.i2cNak(); - else if (READ_FLAG(UCB1STAT, UCSTTIFG)) + } else if (READ_FLAG(UCB1STAT, UCSTTIFG)) { + CLR_FLAG(UCB1STAT, UCSTTIFG); signal IntB.i2cStart(); - else if (READ_FLAG(UCB1STAT, UCSTPIFG)) + } else if (READ_FLAG(UCB1STAT, UCSTPIFG)) { + CLR_FLAG(UCB1STAT, UCSTPIFG); signal IntB.i2cStop(); + } } - /* This USCI_Ax and USCI_Bx interrupt vector signals transmit events for UART - * and SPI modes, and rx/tx events for I2C modes. Only Bx can do I2C. + /* This interrupt vector signals transmit events. USCI_A1 can receive events + * for UART and SPI modes, while USCI_B1 can receive events for I2C and SPI + * modes. */ TOSH_SIGNAL(USCIAB1TX_VECTOR) { - if (READ_FLAG(UC1IFG, UCB1RXIFG)) + if (READ_FLAG(UC1IFG & UC1IE, UCB1RXIE)) signal IntB.rx(UCB1RXBUF); /* I2C receive */ - else if (READ_FLAG(UC1IFG, UCA1TXIFG)) + else if (READ_FLAG(UC1IFG & UC1IE, UCA1TXIFG)) signal IntA.tx(); - else if (READ_FLAG(UC1IFG, UCB1TXIFG)) + else if (READ_FLAG(UC1IFG & UC1IE, UCB1TXIFG)) signal IntB.tx(); } @@ -101,6 +116,7 @@ implementation default async event void IntA.i2cStart() {} default async event void IntA.i2cStop() {} + /* UART is not available for B devices, so IntB.brk() is never sitnalled */ default async event void IntB.brk() {} default async event void IntB.rx(uint8_t byte) {} default async event void IntB.tx() {}