[Tinyos-2-commits] CVS: tinyos-2.x/tos/chips/atm128 Atm128UartP.nc,
1.4, 1.5
Phil Levis
scipio at users.sourceforge.net
Tue Nov 27 11:26:50 PST 2007
Update of /cvsroot/tinyos/tinyos-2.x/tos/chips/atm128
In directory sc8-pr-cvs10.sourceforge.net:/tmp/cvs-serv23077
Modified Files:
Atm128UartP.nc
Log Message:
Fold in Alec's changes, with bug fix for RX interrupt.
Index: Atm128UartP.nc
===================================================================
RCS file: /cvsroot/tinyos/tinyos-2.x/tos/chips/atm128/Atm128UartP.nc,v
retrieving revision 1.4
retrieving revision 1.5
diff -C2 -d -r1.4 -r1.5
*** Atm128UartP.nc 12 Dec 2006 18:23:02 -0000 1.4
--- Atm128UartP.nc 27 Nov 2007 19:26:45 -0000 1.5
***************
*** 33,37 ****
--- 33,43 ----
* @author Alec Woo <awoo at archrock.com>
* @author Jonathan Hui <jhui at archrock.com>
+ * @author Philip Levis <pal at cs.stanford.edu> (maintainer)
* @version $Revision$ $Date$
+ *
+ * Modification @ 11/27 (pal): Folded in Alec's reimplementation
+ * from the -devel branch. Fixed bug in RX interrupts, where
+ * they were not enabled on start. Possibly due to alternative
+ * ARC TEP113 implementation that uses UartStream?
*/
***************
*** 58,61 ****
--- 64,69 ----
norace uint16_t m_tx_pos, m_rx_pos;
norace uint16_t m_byte_time;
+ norace uint8_t m_rx_intr;
+ norace uint8_t m_tx_intr;
command error_t Init.init() {
***************
*** 68,73 ****
--- 76,91 ----
command error_t StdControl.start(){
+ /* make sure interupts are off and set flags */
+ call HplUart.disableTxIntr();
+ call HplUart.disableRxIntr();
+ m_rx_intr = 0;
+ m_tx_intr = 0;
+
+ /* enable tx/rx */
call HplUartTxControl.start();
call HplUartRxControl.start();
+
+ // Bug fix: pal 11/26/07: RX interrupts should be enabled on start
+ call HplUart.enableRxIntr();
return SUCCESS;
}
***************
*** 80,89 ****
async command error_t UartStream.enableReceiveInterrupt(){
! call HplUartRxControl.start();
return SUCCESS;
}
async command error_t UartStream.disableReceiveInterrupt(){
! call HplUartRxControl.stop();
return SUCCESS;
}
--- 98,113 ----
async command error_t UartStream.enableReceiveInterrupt(){
! atomic{
! m_rx_intr = 3;
! call HplUart.enableRxIntr();
! }
return SUCCESS;
}
async command error_t UartStream.disableReceiveInterrupt(){
! atomic{
! call HplUart.disableRxIntr();
! m_rx_intr = 0;
! }
return SUCCESS;
}
***************
*** 99,102 ****
--- 123,128 ----
m_rx_len = len;
m_rx_pos = 0;
+ m_rx_intr |= 1;
+ call HplUart.enableRxIntr();
}
***************
*** 111,115 ****
if ( m_rx_pos >= m_rx_len ) {
uint8_t* buf = m_rx_buf;
! m_rx_buf = NULL;
signal UartStream.receiveDone( buf, m_rx_len, SUCCESS );
}
--- 137,147 ----
if ( m_rx_pos >= m_rx_len ) {
uint8_t* buf = m_rx_buf;
! atomic{
! m_rx_buf = NULL;
! if(m_rx_intr != 3){
! call HplUart.disableRxIntr();
! m_rx_intr = 0;
! }
! }
signal UartStream.receiveDone( buf, m_rx_len, SUCCESS );
}
***************
*** 131,134 ****
--- 163,168 ----
m_tx_len = len;
m_tx_pos = 0;
+ m_tx_intr = 1;
+ call HplUart.enableTxIntr();
call HplUart.tx( buf[ m_tx_pos++ ] );
***************
*** 145,148 ****
--- 179,184 ----
uint8_t* buf = m_tx_buf;
m_tx_buf = NULL;
+ m_tx_intr = 0;
+ call HplUart.disableTxIntr();
signal UartStream.sendDone( buf, m_tx_len, SUCCESS );
}
***************
*** 151,154 ****
--- 187,193 ----
async command error_t UartByte.send( uint8_t byte ){
+ if(m_tx_intr)
+ return FAIL;
+
call HplUart.tx( byte );
while ( !call HplUart.isTxEmpty() );
***************
*** 157,164 ****
async command error_t UartByte.receive( uint8_t * byte, uint8_t timeout){
!
uint16_t timeout_micro = m_byte_time * timeout + 1;
uint16_t start;
start = call Counter.get();
while ( call HplUart.isRxEmpty() ) {
--- 196,206 ----
async command error_t UartByte.receive( uint8_t * byte, uint8_t timeout){
!
uint16_t timeout_micro = m_byte_time * timeout + 1;
uint16_t start;
+ if(m_rx_intr)
+ return FAIL;
+
start = call Counter.get();
while ( call HplUart.isRxEmpty() ) {
More information about the Tinyos-2-commits
mailing list