--- /dev/null
+/*
+ * Copyright (c) 2008, Titanium Mirror, Inc.
+ * All rights reserved.
+ *
+ * Redistribution and use in source and binary forms, with or without
+ * modification, are permitted provided that the following conditions
+ * are met:
+ * - Redistributions of source code must retain the above copyright notice,
+ * this list of conditions and the following disclaimer.
+ * - Redistributions in binary form must reproduce the above copyright
+ * notice, this list of conditions and the following disclaimer in the
+ * documentation and/or other materials provided with the distribution.
+ * - Neither the name of the Technische Universität Berlin nor the names
+ * of its contributors may be used to endorse or promote products derived
+ * from this software without specific prior written permission.
+ *
+ * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
+ * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
+ * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
+ * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT
+ * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL,
+ * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED
+ * TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
+ * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY
+ * OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
+ * (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 USCI1 peripheral.
+ *
+ * @author R. Steve McKown <rsmckown@gmail.com>
+ */
+
+#include "Msp430Usci.h"
+#include "msp430hardware.h"
+
+module HplMsp430UsciInt1P @safe() {
+ provides {
+ interface HplMsp430UsciInt as IntA;
+ interface HplMsp430UsciInt as IntB;
+ }
+}
+
+implementation
+{
+#if 0
+ MSP430REG_NORACE(UC1IFG);
+ MSP430REG_NORACE(UCA1CTL0);
+ MSP430REG_NORACE(UCA1CTL1);
+ MSP430REG_NORACE(UCA1RXBUF);
+ MSP430REG_NORACE(UCB1CTL0);
+ MSP430REG_NORACE(UCB1CTL1);
+ 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.
+ */
+ TOSH_SIGNAL(USCIAB1RX_VECTOR) {
+ if (READ_FLAG(UC1IFG, UCA1RXIFG)) {
+ volatile uint8_t c = UCA1RXBUF; /* read to clear UCA1RXIFG */
+ if (READ_FLAG(UCA1CTL1, UCBRK)) {
+ UCA1CTL1 &= ~UCBRK;
+ if (READ_FLAG(UCA1CTL0, UCMODE_3) == UCMODE_3)
+ UCA1CTL1 &= ~UCDORM;
+ signal IntA.brk();
+ } else
+ signal IntA.rx(c);
+ } else if (READ_FLAG(UC1IFG, UCB1RXIFG)) {
+ volatile uint8_t c = UCB1RXBUF; /* read to clear UCB1RXIFG */
+ if (READ_FLAG(UCB1CTL1, UCBRK)) {
+ CLR_FLAG(UCB1CTL1, UCBRK);
+ if (READ_FLAG(UCB1CTL0, UCMODE_3) == UCMODE_3)
+ CLR_FLAG(UCB1CTL1, UCDORM);
+ signal IntB.brk();
+ } else
+ signal IntB.rx(c);
+ } else if (READ_FLAG(UCB1STAT, UCALIFG))
+ signal IntB.i2cCal();
+ else if (READ_FLAG(UCB1STAT, UCNACKIFG))
+ signal IntB.i2cNak();
+ else if (READ_FLAG(UCB1STAT, UCSTTIFG))
+ signal IntB.i2cStart();
+ else if (READ_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.
+ */
+ TOSH_SIGNAL(USCIAB1TX_VECTOR) {
+ if (READ_FLAG(UC1IFG, UCB1RXIFG))
+ signal IntB.rx(UCB1RXBUF); /* I2C receive */
+ else if (READ_FLAG(UC1IFG, UCA1TXIFG))
+ signal IntA.tx();
+ else if (READ_FLAG(UC1IFG, UCB1TXIFG))
+ signal IntB.tx();
+ }
+
+ default async event void IntA.brk() {}
+ default async event void IntA.rx(uint8_t byte) {}
+ 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.i2cStart() {}
+ default async event void IntA.i2cStop() {}
+
+ default async event void IntB.brk() {}
+ 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.i2cStart() {}
+ default async event void IntB.i2cStop() {}
+}