mbed library sources

Fork of mbed-src by mbed official

Files at this revision

API Documentation at this revision

Comitter:
BigDotStu
Date:
Sat Nov 15 19:39:06 2014 +0000
Parent:
399:7c3047f858e1
Commit message:
Added serial IRQ getc to HAL

Changed in this revision

api/SerialBase.h Show annotated file Show diff for this revision Revisions of this file
common/SerialBase.cpp Show annotated file Show diff for this revision Revisions of this file
hal/serial_api.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/serial_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_NXP/TARGET_LPC176X/serial_api.c Show annotated file Show diff for this revision Revisions of this file
--- a/api/SerialBase.h	Wed Nov 12 14:15:07 2014 +0000
+++ b/api/SerialBase.h	Sat Nov 15 19:39:06 2014 +0000
@@ -125,6 +125,7 @@
     }
 
     int _base_getc();
+    int _base_getc_irq();
     int _base_putc(int c);
 
     serial_t        _serial;
--- a/common/SerialBase.cpp	Wed Nov 12 14:15:07 2014 +0000
+++ b/common/SerialBase.cpp	Sat Nov 15 19:39:06 2014 +0000
@@ -61,6 +61,10 @@
     return serial_getc(&_serial);
 }
 
+int SerialBase::_base_getc_irq() {
+    return serial_getc_irq(&_serial);
+}
+
 int SerialBase::_base_putc(int c) {
     serial_putc(&_serial, c);
     return c;
--- a/hal/serial_api.h	Wed Nov 12 14:15:07 2014 +0000
+++ b/hal/serial_api.h	Sat Nov 15 19:39:06 2014 +0000
@@ -57,6 +57,7 @@
 void serial_irq_set    (serial_t *obj, SerialIrq irq, uint32_t enable);
 
 int  serial_getc       (serial_t *obj);
+int  serial_getc_irq   (serial_t *obj);
 void serial_putc       (serial_t *obj, int c);
 int  serial_readable   (serial_t *obj);
 int  serial_writable   (serial_t *obj);
--- a/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/serial_api.c	Wed Nov 12 14:15:07 2014 +0000
+++ b/targets/hal/TARGET_Freescale/TARGET_KPSDK_MCUS/serial_api.c	Sat Nov 15 19:39:06 2014 +0000
@@ -189,6 +189,13 @@
     return data;
 }
 
+int serial_getc_irq(serial_t *obj) {
+    uint8_t data;
+    uint32_t uart_addrs[] = UART_BASE_ADDRS;
+    UART_HAL_Getchar(uart_addrs[obj->index], &data);
+
+    return data;
+}
 void serial_putc(serial_t *obj, int c) {
     while (!serial_writable(obj));
     uint32_t uart_addrs[] = UART_BASE_ADDRS;
--- a/targets/hal/TARGET_NXP/TARGET_LPC176X/serial_api.c	Wed Nov 12 14:15:07 2014 +0000
+++ b/targets/hal/TARGET_NXP/TARGET_LPC176X/serial_api.c	Sat Nov 15 19:39:06 2014 +0000
@@ -354,6 +354,16 @@
     return data;
 }
 
+int serial_getc_irq(serial_t *obj) {
+    uint32_t IRR = obj->uart->IIR;
+    int data = obj->uart->RBR;
+    if (NC != uart_data[obj->index].sw_rts.pin) {
+        gpio_write(&uart_data[obj->index].sw_rts, 0);
+        obj->uart->IER |= 1 << RxIrq;
+    }
+    return data;
+}
+
 void serial_putc(serial_t *obj, int c) {
     while (!serial_writable(obj));
     obj->uart->THR = c;