From 68c47d29ea4f9b4f7e2480a02aa80c6124f2dbe1 Mon Sep 17 00:00:00 2001 From: Joakim Gebart Date: Tue, 7 Jul 2015 00:44:10 +0200 Subject: [PATCH] boards/z1: Add getchar implementation --- boards/z1/uart.c | 27 +++++++++++++++------------ 1 file changed, 15 insertions(+), 12 deletions(-) diff --git a/boards/z1/uart.c b/boards/z1/uart.c index b89eb74d4b..cc168f4630 100644 --- a/boards/z1/uart.c +++ b/boards/z1/uart.c @@ -87,6 +87,15 @@ int putchar(int c) return c; } +int getchar(void) +{ +#ifdef MODULE_UART0 + return uart0_readc(); +#else + return UCA0RXBUF; +#endif +} + uint8_t uart_readByte(void) { return UCA0RXBUF; @@ -95,15 +104,9 @@ uint8_t uart_readByte(void) /** * \brief the interrupt handler for UART reception */ -interrupt(USCIAB0RX_VECTOR) __attribute__ ((naked)) usart1irq(void) +interrupt(USCIAB0RX_VECTOR) usart1irq(void) { - __enter_isr(); - -#ifndef MODULE_UART0 - int __attribute__ ((unused)) c; -#else - int c; -#endif + volatile int c; /* Check status register for receive errors. */ if (UCA0STAT & UCRXERR) { @@ -121,14 +124,14 @@ interrupt(USCIAB0RX_VECTOR) __attribute__ ((naked)) usart1irq(void) } /* Clear error flags by forcing a dummy read. */ c = UCA0RXBUF; + (void)c; + } #ifdef MODULE_UART0 - } else if (uart0_handler_pid != KERNEL_PID_UNDEF) { + else if (uart0_handler_pid != KERNEL_PID_UNDEF) { /* All went well -> let's signal the reception to adequate callbacks */ c = UCA0RXBUF; uart0_handle_incoming(c); uart0_notify_thread(); -#endif } - - __exit_isr(); +#endif }