X-Git-Url: https://oss.titaniummirror.com/gitweb/?a=blobdiff_plain;f=tos%2Fchips%2Fmsp430%2Fusci%2FHplMsp430UsciInt0P.nc;h=d802a0bf3b66e2163998866bb63580d8934ff57f;hb=a4c683fb39c46c4a0382866e7ca1ab65a524fcf4;hp=9e69649cd7701f039c4fa3e132a562e394d956bd;hpb=59a38cc43b09cc83e1a414ec0531588abab72cc9;p=tinyos-2.x.git diff --git a/tos/chips/msp430/usci/HplMsp430UsciInt0P.nc b/tos/chips/msp430/usci/HplMsp430UsciInt0P.nc index 9e69649c..d802a0bf 100644 --- a/tos/chips/msp430/usci/HplMsp430UsciInt0P.nc +++ b/tos/chips/msp430/usci/HplMsp430UsciInt0P.nc @@ -26,13 +26,13 @@ * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE * USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */ - + /** * HPL interrupt interface for the USCI0 peripheral. - * + * * @author R. Steve McKown */ - + #include "Msp430Usci.h" #include "msp430hardware.h" @@ -91,7 +91,7 @@ implementation } else if (READ_FLAG(UCB0STAT, UCNACKIFG)) { CLR_FLAG(UCB0STAT, UCNACKIFG); CLR_FLAG(UC0IFG, UCB0TXIFG); /* Errata USCI25; 'reset' means clear? */ - signal IntB.i2cNak(); + signal IntB.i2cNack(); } else if (READ_FLAG(UCB0STAT, UCSTTIFG)) { CLR_FLAG(UCB0STAT, UCSTTIFG); signal IntB.i2cStart(); @@ -100,15 +100,19 @@ implementation signal IntB.i2cStop(); } } - + /* This interrupt vector signals transmit events. USCI_A0 can receive events * for UART and SPI modes, while USCI_B0 can receive events for I2C and SPI * modes. */ TOSH_SIGNAL(USCIAB0TX_VECTOR) { - if (READ_FLAG(UC0IFG & UC0IE, UCB0RXIE)) - signal IntB.rx(UCB0RXBUF); /* I2C receive */ - else if (READ_FLAG(UC0IFG & UC0IE, UCA0TXIFG)) + if (READ_FLAG(UC0IFG & UC0IE, UCB0RXIE)) { + /* I2C receive. Do not read UCB0RXBUF here, as the code receiving + * IntB.rx() may first need to set stop and/or start bits. The receiver + * must read UCB0RXBUF. + */ + signal IntB.rx(0); + } else if (READ_FLAG(UC0IFG & UC0IE, UCA0TXIFG)) signal IntA.tx(); else if (READ_FLAG(UC0IFG & UC0IE, UCB0TXIFG)) signal IntB.tx(); @@ -119,7 +123,7 @@ implementation default async event void IntA.tx() {} /* i2c is not available for A devices, so the below are never signalled */ default async event void IntA.i2cCal() {} - default async event void IntA.i2cNak() {} + default async event void IntA.i2cNack() {} default async event void IntA.i2cStart() {} default async event void IntA.i2cStop() {} @@ -128,7 +132,7 @@ implementation default async event void IntB.rx(uint8_t byte) {} default async event void IntB.tx() {} default async event void IntB.i2cCal() {} - default async event void IntB.i2cNak() {} + default async event void IntB.i2cNack() {} default async event void IntB.i2cStart() {} default async event void IntB.i2cStop() {} }