mbed library sources. Supersedes mbed-src. Add PORTG support for STM32L476JG (SensorTile kit)

Dependents:   SensorTileTest

Fork of mbed-dev by mbed official

Files at this revision

API Documentation at this revision

Comitter:
mbed_official
Date:
Tue Apr 26 19:30:12 2016 +0100
Parent:
115:33c68e1b9487
Child:
117:24bb08393888
Commit message:
Synchronized with git revision 0b67bf08c8c2ce634f489a85e1c044812034bca2

Full URL: https://github.com/mbedmicro/mbed/commit/0b67bf08c8c2ce634f489a85e1c044812034bca2/

Our UART doesn't have the ability to send a break, so we make the TX a GPIO and drive it low during the break_set() and then release it back to the UART in the break_clear().

Changed in this revision

targets/hal/TARGET_Maxim/TARGET_MAX32600/serial_api.c Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_Maxim/TARGET_MAX32610/TARGET_MAXWSNENV/PinNames.h Show annotated file Show diff for this revision Revisions of this file
targets/hal/TARGET_Maxim/TARGET_MAX32610/serial_api.c Show annotated file Show diff for this revision Revisions of this file
--- a/targets/hal/TARGET_Maxim/TARGET_MAX32600/serial_api.c	Tue Apr 26 17:30:10 2016 +0100
+++ b/targets/hal/TARGET_Maxim/TARGET_MAX32600/serial_api.c	Tue Apr 26 19:30:12 2016 +0100
@@ -35,7 +35,9 @@
 #include "mbed_assert.h"
 #include "cmsis.h"
 #include "serial_api.h"
+#include "gpio_api.h"
 #include "uart_regs.h"
+#include "ioman_regs.h"
 #include "PeripheralPins.h"
 
 #define UART_NUM 2
@@ -290,24 +292,77 @@
     obj->uart->ctrl |= (MXC_F_UART_CTRL_TX_FIFO_FLUSH  | MXC_F_UART_CTRL_RX_FIFO_FLUSH );
 }
 
-
 //******************************************************************************
 void serial_break_set(serial_t *obj)
 {
     // Make sure that nothing is being sent
-    while(obj->uart->status & MXC_F_UART_STATUS_RX_BUSY) {}
+    while (!(obj->uart->status & MXC_F_UART_STATUS_TX_FIFO_EMPTY));
+    while (obj->uart->status & MXC_F_UART_STATUS_TX_BUSY);
 
-    // Disable the clock to pause any transmission
-    obj->uart->ctrl &= ~MXC_F_UART_CTRL_BAUD_CLK_EN ;
+    // Configure the GPIO to outpu 0
+    gpio_t tx_gpio;
+    switch (((UARTName)(obj->uart))) {
+        case UART_0:
+            gpio_init_out(&tx_gpio, UART0_TX);
+            break;
+        case UART_1:
+            gpio_init_out(&tx_gpio, UART1_TX);
+            break;
+        default:
+            gpio_init_out(&tx_gpio, (PinName)NC);
+            break;
+    }
+
+    gpio_write(&tx_gpio, 0);
+
+    // GPIO is setup now, but we need to maps gpio to the pin
+    switch (((UARTName)(obj->uart))) {
+        case UART_0:
+            MXC_IOMAN->uart0_req &= ~MXC_F_IOMAN_UART_CORE_IO;
+            MBED_ASSERT((MXC_IOMAN->uart0_ack & (MXC_F_IOMAN_UART_CORE_IO | MXC_F_IOMAN_UART_CORE_IO)) == 0);
+            break;
+        case UART_1:
+            MXC_IOMAN->uart1_req &= ~MXC_F_IOMAN_UART_CORE_IO;
+            MBED_ASSERT((MXC_IOMAN->uart1_ack & (MXC_F_IOMAN_UART_CORE_IO | MXC_F_IOMAN_UART_CORE_IO)) == 0);
+            break;
+        default:
+            break;
+    }
 }
 
 //******************************************************************************
 void serial_break_clear(serial_t *obj)
 {
-    obj->uart->ctrl |= MXC_F_UART_CTRL_BAUD_CLK_EN;
+    // Configure the GPIO to output 1
+    gpio_t tx_gpio;
+    switch (((UARTName)(obj->uart))) {
+        case UART_0:
+            gpio_init_out(&tx_gpio, UART0_TX);
+            break;
+        case UART_1:
+            gpio_init_out(&tx_gpio, UART1_TX);
+            break;
+        default:
+            gpio_init_out(&tx_gpio, (PinName)NC);
+            break;
+    }
+
+    gpio_write(&tx_gpio, 1);
+
+    // Renable UART
+    switch (((UARTName)(obj->uart))) {
+        case UART_0:
+            serial_pinout_tx(UART0_TX);
+            break;
+        case UART_1:
+            serial_pinout_tx(UART1_TX);
+            break;
+        default:
+            serial_pinout_tx((PinName)NC);
+            break;
+    }
 }
 
-
 //******************************************************************************
 void serial_pinout_tx(PinName tx)
 {
--- a/targets/hal/TARGET_Maxim/TARGET_MAX32610/TARGET_MAXWSNENV/PinNames.h	Tue Apr 26 17:30:10 2016 +0100
+++ b/targets/hal/TARGET_Maxim/TARGET_MAX32610/TARGET_MAXWSNENV/PinNames.h	Tue Apr 26 19:30:12 2016 +0100
@@ -130,11 +130,16 @@
     SW1 = P1_5,
 
     // UART Pins
-    USBTX = P1_3,
-    USBRX = P1_2,
+    UART0_RX  = P1_0,
+    UART0_TX  = P1_1,
+    UART1_RX  = P1_2,
+    UART1_TX  = P1_3,
+    USBTX = UART1_TX,
+    USBRX = UART1_RX,
     STDIO_UART_TX = USBTX,
     STDIO_UART_RX = USBRX,
 
+    // I2C Pins
     I2C_SCL = P0_5,
     I2C_SDA = P0_4,
 
--- a/targets/hal/TARGET_Maxim/TARGET_MAX32610/serial_api.c	Tue Apr 26 17:30:10 2016 +0100
+++ b/targets/hal/TARGET_Maxim/TARGET_MAX32610/serial_api.c	Tue Apr 26 19:30:12 2016 +0100
@@ -35,7 +35,9 @@
 #include "mbed_assert.h"
 #include "cmsis.h"
 #include "serial_api.h"
+#include "gpio_api.h"
 #include "uart_regs.h"
+#include "ioman_regs.h"
 #include "PeripheralPins.h"
 
 #define UART_NUM 2
@@ -290,24 +292,77 @@
     obj->uart->ctrl |= (MXC_F_UART_CTRL_TX_FIFO_FLUSH  | MXC_F_UART_CTRL_RX_FIFO_FLUSH );
 }
 
-
 //******************************************************************************
 void serial_break_set(serial_t *obj)
 {
     // Make sure that nothing is being sent
-    while(obj->uart->status & MXC_F_UART_STATUS_RX_BUSY) {}
+    while (!(obj->uart->status & MXC_F_UART_STATUS_TX_FIFO_EMPTY));
+    while (obj->uart->status & MXC_F_UART_STATUS_TX_BUSY);
 
-    // Disable the clock to pause any transmission
-    obj->uart->ctrl &= ~MXC_F_UART_CTRL_BAUD_CLK_EN ;
+    // Configure the GPIO to outpu 0
+    gpio_t tx_gpio;
+    switch (((UARTName)(obj->uart))) {
+        case UART_0:
+            gpio_init_out(&tx_gpio, UART0_TX);
+            break;
+        case UART_1:
+            gpio_init_out(&tx_gpio, UART1_TX);
+            break;
+        default:
+            gpio_init_out(&tx_gpio, (PinName)NC);
+            break;
+    }
+
+    gpio_write(&tx_gpio, 0);
+
+    // GPIO is setup now, but we need to maps gpio to the pin
+    switch (((UARTName)(obj->uart))) {
+        case UART_0:
+            MXC_IOMAN->uart0_req &= ~MXC_F_IOMAN_UART_CORE_IO;
+            MBED_ASSERT((MXC_IOMAN->uart0_ack & (MXC_F_IOMAN_UART_CORE_IO | MXC_F_IOMAN_UART_CORE_IO)) == 0);
+            break;
+        case UART_1:
+            MXC_IOMAN->uart1_req &= ~MXC_F_IOMAN_UART_CORE_IO;
+            MBED_ASSERT((MXC_IOMAN->uart1_ack & (MXC_F_IOMAN_UART_CORE_IO | MXC_F_IOMAN_UART_CORE_IO)) == 0);
+            break;
+        default:
+            break;
+    }
 }
 
 //******************************************************************************
 void serial_break_clear(serial_t *obj)
 {
-    obj->uart->ctrl |= MXC_F_UART_CTRL_BAUD_CLK_EN;
+    // Configure the GPIO to output 1
+    gpio_t tx_gpio;
+    switch (((UARTName)(obj->uart))) {
+        case UART_0:
+            gpio_init_out(&tx_gpio, UART0_TX);
+            break;
+        case UART_1:
+            gpio_init_out(&tx_gpio, UART1_TX);
+            break;
+        default:
+            gpio_init_out(&tx_gpio, (PinName)NC);
+            break;
+    }
+
+    gpio_write(&tx_gpio, 1);
+
+    // Renable UART
+    switch (((UARTName)(obj->uart))) {
+        case UART_0:
+            serial_pinout_tx(UART0_TX);
+            break;
+        case UART_1:
+            serial_pinout_tx(UART1_TX);
+            break;
+        default:
+            serial_pinout_tx((PinName)NC);
+            break;
+    }
 }
 
-
 //******************************************************************************
 void serial_pinout_tx(PinName tx)
 {