Jeff King wrote:
Has anyone tried using the new UartByte interface in the TinyOS 2.0
release? Sending and receiving serial data using UartStream works fine,
but the blocking UartByte.send never unblocks:
I've tracked this down to two problems. First, the TXCIE (TX Complete
Interrupt Enable) bit in UCSRnB needs to disabled before UartByte.send()
calls HplUart.tx() (and can be re-enabled before send() returns).
However, the second problem is that the enableTxIntr() and
disableTxIntr() commands implemented in HplAtm128UartP.nc don't set the
TXCIE bit, but rather the TXEN (Transmitter Enable). When TXCIE is
disabled, data can still be transmitted, but no interrupt occurs onces
the transmission completes. When TXEN is disabled, nothing can transmit
at all.
My solution was to add the following in the uart interface
(/tos/chips/atm128/HplAtm128Uart.nc)
async command error_t enableTxCIE();
async command error_t disableTxCIE();
Implementing the new commands in /tos/chips/atm128/HplArm128UartP.nc:
async command error_t HplUart0.enableTxCIE() {
SET_BIT(UCSR0B, TXCIE);
return SUCCESS;
}
async command error_t HplUart0.disableTxCIE() {
CLR_BIT(UCSR0B, TXCIE);
return SUCCESS;
}
async command error_t HplUart1.enableTxCIE() {
SET_BIT(UCSR1B, TXCIE);
return SUCCESS;
}
async command error_t HplUart1.disableTxCIE() {
CLR_BIT(UCSR1B, TXCIE);
return SUCCESS;
}
And then calling the new commands in the UartByte.send() implementation
in /tos/chips/atm128/Atm128UartP.nc:
async command error_t UartByte.send( uint8_t byte ){
call HplUart.disableTxCIE();
call HplUart.tx( byte );
while ( !call HplUart.isTxEmpty() );
call HplUart.enableTxCIE();
return SUCCESS;
}
_______________________________________________
Tinyos-help mailing list
Tinyos-help@Millennium.Berkeley.EDU
https://mail.millennium.berkeley.edu/cgi-bin/mailman/listinfo/tinyos-help