mbed library sources for airmote

Fork of mbed-src by mbed official

Revision:
340:28d1f895c6fe
Parent:
339:40bd4701f3e2
Child:
395:bfce16e86ea4
--- a/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/serial_api.c	Mon Oct 06 11:45:07 2014 +0100
+++ b/targets/hal/TARGET_NORDIC/TARGET_MCU_NRF51822/serial_api.c	Thu Oct 09 08:15:07 2014 +0100
@@ -166,9 +166,9 @@
 {
     uint32_t irtype = 0;
 
-    if (NRF_UART0->EVENTS_TXDRDY) {
+    if((NRF_UART0->INTENSET & 0x80) && NRF_UART0->EVENTS_TXDRDY) {
         irtype = 1;
-    } else if (NRF_UART0->EVENTS_RXDRDY) {
+    } else if((NRF_UART0->INTENSET & 0x04) && NRF_UART0->EVENTS_RXDRDY) {
         irtype = 2;
     }
     uart_irq(irtype, 0);
@@ -266,3 +266,34 @@
     obj->uart->TASKS_STARTTX = 1;
     obj->uart->TASKS_STARTRX = 1;
 }
+
+void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow)
+{
+
+    if (type == FlowControlRTSCTS || type == FlowControlRTS) {
+        NRF_GPIO->DIR |= (1<<rxflow);
+        pin_mode(rxflow, PullUp);
+        obj->uart->PSELRTS = rxflow;
+
+        obj->uart->CONFIG |= 0x01; // Enable HWFC
+    }
+
+    if (type == FlowControlRTSCTS || type == FlowControlCTS) {
+        NRF_GPIO->DIR &= ~(1<<txflow);
+        pin_mode(txflow, PullUp);
+        obj->uart->PSELCTS = txflow;
+
+        obj->uart->CONFIG |= 0x01; // Enable HWFC;
+    }
+
+    if (type == FlowControlNone) {
+        obj->uart->PSELRTS = 0xFFFFFFFF; // Disable RTS
+        obj->uart->PSELCTS = 0xFFFFFFFF; // Disable CTS
+
+        obj->uart->CONFIG &= ~0x01; // Enable HWFC;
+    }
+}
+
+void serial_clear(serial_t *obj) {
+}
+