mbed library sources

Fork of mbed-src by mbed official

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Tue Apr 21 11:45:19 2015 +0100
Parent:
518:0334fb94f264
Child:
520:7182721120da
Commit message:
Synchronized with git revision aec674b45f9b9cb313063c9a40db63bbc6a3290f

Full URL: https://github.com/mbedmicro/mbed/commit/aec674b45f9b9cb313063c9a40db63bbc6a3290f/

Revert "Fixed interrupt handler in serial_api.c for the Nordic NRF51.

Changed in this revision

targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/serial_api.c Show annotated file Show diff for this revision Revisions of this file
--- a/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/serial_api.c	Mon Apr 20 11:30:09 2015 +0100
+++ b/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/serial_api.c	Tue Apr 21 11:45:19 2015 +0100
@@ -76,7 +76,7 @@
     obj->uart->TXD = 0;
 
     obj->index = 0;
-
+    
     obj->uart->PSELRTS = RTS_PIN_NUMBER;
     obj->uart->PSELTXD = tx; //TX_PIN_NUMBER;
     obj->uart->PSELCTS = CTS_PIN_NUMBER;
@@ -162,20 +162,14 @@
 #endif
 void UART0_IRQHandler()
 {
-    if((NRF_UART0->INTENSET & UART_INTENSET_TXDRDY_Msk) && NRF_UART0->EVENTS_TXDRDY)
-    {
-        uart_irq(1, 0);
+    uint32_t irtype = 0;
 
-        /*  Explicitly clear TX flag to prevent interrupt from firing
-            immediately after returning from ISR. This ensures that the
-            last interrupt in a transmission sequence is correcly handled.
-        */
-        NRF_UART0->EVENTS_TXDRDY = 0;
+    if((NRF_UART0->INTENSET & 0x80) && NRF_UART0->EVENTS_TXDRDY) {
+        irtype = 1;
+    } else if((NRF_UART0->INTENSET & 0x04) && NRF_UART0->EVENTS_RXDRDY) {
+        irtype = 2;
     }
-    else if((NRF_UART0->INTENSET & UART_INTENSET_RXDRDY_Msk) && NRF_UART0->EVENTS_RXDRDY)
-    {
-        uart_irq(2, 0);
-    }
+    uart_irq(irtype, 0);
 }
 
 #ifdef __cplusplus
@@ -245,24 +239,11 @@
 
 void serial_putc(serial_t *obj, int c)
 {
-    /*  In interrupt mode, send character immediately. Otherwise, block until
-        UART is ready to receive next character before sending.
+    while (!serial_writable(obj)) {
+    }
 
-        The TXDRDY flag is cleared in interrupt handler to ensure that it is
-        cleared even if there are no more characters to send.
-    */
-    if (NRF_UART0->INTENSET & UART_INTENSET_TXDRDY_Msk)
-    {
-        obj->uart->TXD = (uint8_t)c;
-    }
-    else
-    {
-        while (!serial_writable(obj)) {
-        }
-
-        obj->uart->EVENTS_TXDRDY = 0;
-        obj->uart->TXD = (uint8_t)c;
-    }
+    obj->uart->EVENTS_TXDRDY = 0;
+    obj->uart->TXD = (uint8_t)c;
 }
 
 int serial_readable(serial_t *obj)