changed usart code to handle LPM3
This commit is contained in:
parent
5d860b1df2
commit
8748230ead
|
@ -26,7 +26,7 @@
|
||||||
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
||||||
* SUCH DAMAGE.
|
* SUCH DAMAGE.
|
||||||
*
|
*
|
||||||
* @(#)$Id: uart1.c,v 1.6 2008/07/03 23:59:20 adamdunkels Exp $
|
* @(#)$Id: uart1.c,v 1.7 2008/09/18 17:59:27 joxe Exp $
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
/*
|
||||||
|
@ -118,24 +118,34 @@ uart1_init(unsigned long ubr)
|
||||||
UCTL1 &= ~SWRST;
|
UCTL1 &= ~SWRST;
|
||||||
|
|
||||||
/* XXX Clear pending interrupts before enable!!! */
|
/* XXX Clear pending interrupts before enable!!! */
|
||||||
|
U1TCTL |= URXSE;
|
||||||
|
|
||||||
IE2 |= URXIE1; /* Enable USART1 RX interrupt */
|
IE2 |= URXIE1; /* Enable USART1 RX interrupt */
|
||||||
|
|
||||||
}
|
}
|
||||||
/*---------------------------------------------------------------------------*/
|
/*---------------------------------------------------------------------------*/
|
||||||
interrupt(UART1RX_VECTOR)
|
interrupt(UART1RX_VECTOR)
|
||||||
uart1_interrupt(void)
|
uart1_interrupt(void)
|
||||||
{
|
{
|
||||||
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
ENERGEST_ON(ENERGEST_TYPE_IRQ);
|
||||||
/* Check status register for receive errors. */
|
|
||||||
if(URCTL1 & RXERR) {
|
if (!(URXIFG1 & IFG2)) {
|
||||||
volatile unsigned dummy;
|
/* Edge detect if IFG not set? */
|
||||||
dummy = RXBUF1; /* Clear error flags by forcing a dummy read. */
|
U1TCTL &= ~URXSE; /* Clear the URXS signal */
|
||||||
|
U1TCTL |= URXSE; /* Re-enable URXS - needed here?*/
|
||||||
|
LPM4_EXIT;
|
||||||
} else {
|
} else {
|
||||||
|
/* Check status register for receive errors. */
|
||||||
|
if(URCTL1 & RXERR) {
|
||||||
|
volatile unsigned dummy;
|
||||||
|
dummy = RXBUF1; /* Clear error flags by forcing a dummy read. */
|
||||||
|
} else {
|
||||||
if(uart1_input_handler != NULL) {
|
if(uart1_input_handler != NULL) {
|
||||||
if(uart1_input_handler(RXBUF1)) {
|
if(uart1_input_handler(RXBUF1)) {
|
||||||
LPM4_EXIT;
|
LPM4_EXIT;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
}
|
||||||
}
|
}
|
||||||
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
|
ENERGEST_OFF(ENERGEST_TYPE_IRQ);
|
||||||
}
|
}
|
||||||
|
|
Loading…
Reference in a new issue