mbed library sources

Dependents:   Nucleo_blink_led

Fork of mbed-src by mbed official

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Tue Apr 07 07:45:07 2015 +0100
Parent:
503:486aded571c7
Child:
505:0be0981777d7
Commit message:
Synchronized with git revision dc0b26d56af5e66054fd4afe32172c8d28c36a6f

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

LPC1549 - Properly disable usart interrupt

Changed in this revision

targets/hal/TARGET_NXP/TARGET_LPC15XX/serial_api.c Show annotated file Show diff for this revision Revisions of this file
--- a/targets/hal/TARGET_NXP/TARGET_LPC15XX/serial_api.c	Tue Apr 07 07:30:12 2015 +0100
+++ b/targets/hal/TARGET_NXP/TARGET_LPC15XX/serial_api.c	Tue Apr 07 07:45:07 2015 +0100
@@ -211,8 +211,18 @@
         default:
             break;
     }
-    
-    obj->uart->CFG = (data_bits << 2)
+
+    // First disable the the usart as described in documentation and then enable while updating CFG
+
+    // 24.6.1 USART Configuration register
+    // Remark: If software needs to change configuration values, the following sequence should
+    // be used: 1) Make sure the USART is not currently sending or receiving data. 2) Disable
+    // the USART by writing a 0 to the Enable bit (0 may be written to the entire register). 3)
+    // Write the new configuration value, with the ENABLE bit set to 1.
+    obj->uart->CFG &= ~(1 << 0);
+
+    obj->uart->CFG = (1 << 0) // this will enable the usart
+                   | (data_bits << 2)
                    | (paritysel << 4)
                    | (stop_bits << 6);
 }
@@ -251,7 +261,7 @@
     } else { // disable
         int all_disabled = 0;
         SerialIrq other_irq = (irq == RxIrq) ? (TxIrq) : (RxIrq);
-        obj->uart->INTENSET &= ~(1 << ((irq == RxIrq) ? 0 : 2));
+        obj->uart->INTENCLR |= (1 << ((irq == RxIrq) ? 0 : 2)); // disable the interrupt
         all_disabled = (obj->uart->INTENSET & (1 << ((other_irq == RxIrq) ? 0 : 2))) == 0;
         if (all_disabled)
             NVIC_DisableIRQ(irq_n);