Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
added interrupt handler for UART1 (->uart0 & stdin) to MSB-430(h)
- Loading branch information
Showing
4 changed files
with
44 additions
and
6 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,21 +1,57 @@ | ||
#include "board.h" | ||
|
||
#define UART1_TX TXBUF1 | ||
#define UART1_TX TXBUF1 | ||
#define UART1_WAIT_TXDONE() while( (UTCTL1 & TXEPT) == 0 ) { _NOP(); } | ||
|
||
#include <stdio.h> | ||
#include <kernel.h> | ||
|
||
#include <board_uart0.h> | ||
|
||
int putchar(int c) | ||
{ | ||
UART1_TX = c; | ||
UART1_WAIT_TXDONE(); | ||
|
||
if (c == 10) { | ||
UART1_TX = 13; | ||
UART1_WAIT_TXDONE(); | ||
} | ||
|
||
return c; | ||
} | ||
|
||
void usart0irq(void); | ||
/** | ||
* \brief the interrupt function | ||
*/ | ||
interrupt(USART1RX_VECTOR) usart0irq(void) | ||
{ | ||
U1TCTL &= ~URXSE; /* Clear the URXS signal */ | ||
U1TCTL |= URXSE; /* Re-enable URXS - needed here?*/ | ||
int c = 0; | ||
/* Check status register for receive errors. */ | ||
if(U1RCTL & RXERR) { | ||
if (U1RCTL & FE) { | ||
puts("rx framing error"); | ||
} | ||
if (U1RCTL & OE) { | ||
puts("rx overrun error"); | ||
} | ||
if (U1RCTL & PE) { | ||
puts("rx parity error"); | ||
} | ||
if (U1RCTL & BRK) { | ||
puts("rx break error"); | ||
} | ||
/* Clear error flags by forcing a dummy read. */ | ||
c = U1RXBUF; | ||
} | ||
#ifdef MODULE_UART0 | ||
else if (uart0_handler_pid) { | ||
c = U1RXBUF; | ||
uart0_handle_incoming(c); | ||
uart0_notify_thread(); | ||
} | ||
#endif | ||
} | ||
|
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -1,3 +1,4 @@ | ||
export INCLUDES += -I$(RIOTBOARD)/msb-430h/include -I$(RIOTBOARD)/msb-430-common/include | ||
include $(RIOTBOARD)/$(BOARD)/Makefile.dep | ||
|
||
include $(RIOTBOARD)/msb-430-common/Makefile.include |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters