* (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE
* USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*/
-
+
/**
* Uart implementation using a USCI device.
*
*
* @author R. Steve McKown <rsmckown@gmail.com>
*/
-
+
generic module Msp430UartP() {
provides {
interface UartStream;
atomic {
if (m_sobuf || !buf || !len)
return FAIL;
- m_sobuf = buf;
- m_solen = len;
- while (!call Registers.getIfgTx());
+ m_sbuf = m_sobuf = buf;
+ m_slen = m_solen = len;
call Registers.setIeTx();
- call Registers.setTxbuf(*m_sobuf);
- m_slen = m_solen - 1;
- if (m_slen)
- m_sbuf = m_sobuf + 1;
return SUCCESS;
}
}
/* FIXME: this can cause an arbitrarily long ISR, if m_slen is large.
* But depending on timing, we may always only write 1 byte.
*/
+ while (!call Registers.getIfgTx()); /* in case interleaved UB.send */
while (m_slen && call Registers.getIfgTx()) {
call Registers.setTxbuf(*m_sbuf);
if (--m_slen)
m_sbuf++;
}
- if (m_slen == 0 && m_sobuf) {
+ if (m_slen == 0) {
call Registers.clrIeTx();
m_sobuf = 0;
signal UartStream.sendDone(m_sobuf, m_solen, SUCCESS);
default async command const msp430_usci_uart_t* Configure.get()
{
- const static msp430_usci_uart_t def = {
+ const static msp430_usci_uart_t def = {
ctl0: UCMODE_0, /* async, lsb first, 8N1 */
ctl1: UCSWRST | UCSSEL_3, /* clock uart from SMCLK */
brx: UBRX_1MHZ_115200,