mbed library sources

Fork of mbed-src by mbed official

Committer:
mbed_official
Date:
Mon Apr 20 11:30:09 2015 +0100
Revision:
518:0334fb94f264
Parent:
501:36015dec7d16
Child:
519:ec58d8604398
Synchronized with git revision 41824de2eb7495879df846f572419ea9aeab7ada

Full URL: https://github.com/mbedmicro/mbed/commit/41824de2eb7495879df846f572419ea9aeab7ada/

Fixed interrupt handler in serial_api.c for the Nordic NRF51

Who changed what in which revision?

UserRevisionLine numberNew contents of line
mbed_official 85:e1a8e879a6a9 1 /* mbed Microcontroller Library
mbed_official 104:a6a92e2e5a92 2 * Copyright (c) 2013 Nordic Semiconductor
mbed_official 85:e1a8e879a6a9 3 *
mbed_official 85:e1a8e879a6a9 4 * Licensed under the Apache License, Version 2.0 (the "License");
mbed_official 85:e1a8e879a6a9 5 * you may not use this file except in compliance with the License.
mbed_official 85:e1a8e879a6a9 6 * You may obtain a copy of the License at
mbed_official 85:e1a8e879a6a9 7 *
mbed_official 85:e1a8e879a6a9 8 * http://www.apache.org/licenses/LICENSE-2.0
mbed_official 85:e1a8e879a6a9 9 *
mbed_official 85:e1a8e879a6a9 10 * Unless required by applicable law or agreed to in writing, software
mbed_official 85:e1a8e879a6a9 11 * distributed under the License is distributed on an "AS IS" BASIS,
mbed_official 85:e1a8e879a6a9 12 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
mbed_official 85:e1a8e879a6a9 13 * See the License for the specific language governing permissions and
mbed_official 85:e1a8e879a6a9 14 * limitations under the License.
mbed_official 85:e1a8e879a6a9 15 */
mbed_official 85:e1a8e879a6a9 16 // math.h required for floating point operations for baud rate calculation
mbed_official 85:e1a8e879a6a9 17 //#include <math.h>
mbed_official 85:e1a8e879a6a9 18 #include <string.h>
mbed_official 227:7bd0639b8911 19 #include "mbed_assert.h"
mbed_official 85:e1a8e879a6a9 20
mbed_official 85:e1a8e879a6a9 21 #include "serial_api.h"
mbed_official 85:e1a8e879a6a9 22 #include "cmsis.h"
mbed_official 85:e1a8e879a6a9 23 #include "pinmap.h"
mbed_official 227:7bd0639b8911 24
mbed_official 85:e1a8e879a6a9 25 /******************************************************************************
mbed_official 85:e1a8e879a6a9 26 * INITIALIZATION
mbed_official 85:e1a8e879a6a9 27 ******************************************************************************/
mbed_official 85:e1a8e879a6a9 28 #define UART_NUM 1
mbed_official 85:e1a8e879a6a9 29
mbed_official 85:e1a8e879a6a9 30 static uint32_t serial_irq_ids[UART_NUM] = {0};
mbed_official 85:e1a8e879a6a9 31 static uart_irq_handler irq_handler;
mbed_official 407:bbbab616ce8f 32 static uint32_t acceptedSpeeds[17][2] = {{1200, UART_BAUDRATE_BAUDRATE_Baud1200},
mbed_official 300:55638feb26a4 33 {2400, UART_BAUDRATE_BAUDRATE_Baud2400},
mbed_official 300:55638feb26a4 34 {4800, UART_BAUDRATE_BAUDRATE_Baud4800},
mbed_official 300:55638feb26a4 35 {9600, UART_BAUDRATE_BAUDRATE_Baud9600},
mbed_official 300:55638feb26a4 36 {14400, UART_BAUDRATE_BAUDRATE_Baud14400},
mbed_official 300:55638feb26a4 37 {19200, UART_BAUDRATE_BAUDRATE_Baud19200},
mbed_official 300:55638feb26a4 38 {28800, UART_BAUDRATE_BAUDRATE_Baud28800},
mbed_official 407:bbbab616ce8f 39 {31250, (0x00800000UL) /* 31250 baud */},
mbed_official 300:55638feb26a4 40 {38400, UART_BAUDRATE_BAUDRATE_Baud38400},
mbed_official 300:55638feb26a4 41 {57600, UART_BAUDRATE_BAUDRATE_Baud57600},
mbed_official 300:55638feb26a4 42 {76800, UART_BAUDRATE_BAUDRATE_Baud76800},
mbed_official 300:55638feb26a4 43 {115200, UART_BAUDRATE_BAUDRATE_Baud115200},
mbed_official 300:55638feb26a4 44 {230400, UART_BAUDRATE_BAUDRATE_Baud230400},
mbed_official 300:55638feb26a4 45 {250000, UART_BAUDRATE_BAUDRATE_Baud250000},
mbed_official 300:55638feb26a4 46 {460800, UART_BAUDRATE_BAUDRATE_Baud460800},
mbed_official 300:55638feb26a4 47 {921600, UART_BAUDRATE_BAUDRATE_Baud921600},
mbed_official 300:55638feb26a4 48 {1000000, UART_BAUDRATE_BAUDRATE_Baud1M}};
mbed_official 85:e1a8e879a6a9 49
mbed_official 85:e1a8e879a6a9 50 int stdio_uart_inited = 0;
mbed_official 85:e1a8e879a6a9 51 serial_t stdio_uart;
mbed_official 85:e1a8e879a6a9 52
mbed_official 85:e1a8e879a6a9 53
mbed_official 85:e1a8e879a6a9 54 void serial_init(serial_t *obj, PinName tx, PinName rx) {
mbed_official 288:17565898c031 55 UARTName uart = UART_0;
mbed_official 85:e1a8e879a6a9 56 obj->uart = (NRF_UART_Type *)uart;
mbed_official 300:55638feb26a4 57
mbed_official 227:7bd0639b8911 58 //pin configurations --
mbed_official 300:55638feb26a4 59 NRF_GPIO->DIR |= (1 << tx); //TX_PIN_NUMBER);
mbed_official 300:55638feb26a4 60 NRF_GPIO->DIR |= (1 << RTS_PIN_NUMBER);
mbed_official 85:e1a8e879a6a9 61
mbed_official 300:55638feb26a4 62 NRF_GPIO->DIR &= ~(1 << rx); //RX_PIN_NUMBER);
mbed_official 300:55638feb26a4 63 NRF_GPIO->DIR &= ~(1 << CTS_PIN_NUMBER);
mbed_official 300:55638feb26a4 64
mbed_official 300:55638feb26a4 65
mbed_official 85:e1a8e879a6a9 66 // set default baud rate and format
mbed_official 85:e1a8e879a6a9 67 serial_baud (obj, 9600);
mbed_official 85:e1a8e879a6a9 68 serial_format(obj, 8, ParityNone, 1);
mbed_official 300:55638feb26a4 69
mbed_official 300:55638feb26a4 70 obj->uart->ENABLE = (UART_ENABLE_ENABLE_Enabled << UART_ENABLE_ENABLE_Pos);
mbed_official 85:e1a8e879a6a9 71 obj->uart->TASKS_STARTTX = 1;
mbed_official 85:e1a8e879a6a9 72 obj->uart->TASKS_STARTRX = 1;
mbed_official 300:55638feb26a4 73 obj->uart->EVENTS_RXDRDY = 0;
mbed_official 433:73d4f6083dd2 74 // dummy write needed or TXDRDY trails write rather than leads write.
mbed_official 433:73d4f6083dd2 75 // pins are disconnected so nothing is physically transmitted on the wire
mbed_official 433:73d4f6083dd2 76 obj->uart->TXD = 0;
mbed_official 300:55638feb26a4 77
mbed_official 85:e1a8e879a6a9 78 obj->index = 0;
mbed_official 518:0334fb94f264 79
mbed_official 433:73d4f6083dd2 80 obj->uart->PSELRTS = RTS_PIN_NUMBER;
mbed_official 433:73d4f6083dd2 81 obj->uart->PSELTXD = tx; //TX_PIN_NUMBER;
mbed_official 433:73d4f6083dd2 82 obj->uart->PSELCTS = CTS_PIN_NUMBER;
mbed_official 433:73d4f6083dd2 83 obj->uart->PSELRXD = rx; //RX_PIN_NUMBER;
mbed_official 300:55638feb26a4 84
mbed_official 85:e1a8e879a6a9 85 // set rx/tx pins in PullUp mode
mbed_official 339:40bd4701f3e2 86 if (tx != NC) {
mbed_official 339:40bd4701f3e2 87 pin_mode(tx, PullUp);
mbed_official 339:40bd4701f3e2 88 }
mbed_official 339:40bd4701f3e2 89 if (rx != NC) {
mbed_official 339:40bd4701f3e2 90 pin_mode(rx, PullUp);
mbed_official 339:40bd4701f3e2 91 }
mbed_official 300:55638feb26a4 92
mbed_official 85:e1a8e879a6a9 93 if (uart == STDIO_UART) {
mbed_official 85:e1a8e879a6a9 94 stdio_uart_inited = 1;
mbed_official 85:e1a8e879a6a9 95 memcpy(&stdio_uart, obj, sizeof(serial_t));
mbed_official 85:e1a8e879a6a9 96 }
mbed_official 85:e1a8e879a6a9 97 }
mbed_official 85:e1a8e879a6a9 98
mbed_official 300:55638feb26a4 99 void serial_free(serial_t *obj)
mbed_official 300:55638feb26a4 100 {
mbed_official 85:e1a8e879a6a9 101 serial_irq_ids[obj->index] = 0;
mbed_official 85:e1a8e879a6a9 102 }
mbed_official 85:e1a8e879a6a9 103
mbed_official 85:e1a8e879a6a9 104 // serial_baud
mbed_official 85:e1a8e879a6a9 105 // set the baud rate, taking in to account the current SystemFrequency
mbed_official 300:55638feb26a4 106 void serial_baud(serial_t *obj, int baudrate)
mbed_official 300:55638feb26a4 107 {
mbed_official 300:55638feb26a4 108 if (baudrate<=1200) {
mbed_official 85:e1a8e879a6a9 109 obj->uart->BAUDRATE = UART_BAUDRATE_BAUDRATE_Baud1200;
mbed_official 85:e1a8e879a6a9 110 return;
mbed_official 227:7bd0639b8911 111 }
mbed_official 300:55638feb26a4 112
mbed_official 407:bbbab616ce8f 113 for (int i = 1; i<17; i++) {
mbed_official 300:55638feb26a4 114 if (baudrate<acceptedSpeeds[i][0]) {
mbed_official 300:55638feb26a4 115 obj->uart->BAUDRATE = acceptedSpeeds[i - 1][1];
mbed_official 85:e1a8e879a6a9 116 return;
mbed_official 85:e1a8e879a6a9 117 }
mbed_official 85:e1a8e879a6a9 118 }
mbed_official 85:e1a8e879a6a9 119 obj->uart->BAUDRATE = UART_BAUDRATE_BAUDRATE_Baud1M;
mbed_official 85:e1a8e879a6a9 120 }
mbed_official 85:e1a8e879a6a9 121
mbed_official 300:55638feb26a4 122 void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits)
mbed_official 300:55638feb26a4 123 {
mbed_official 85:e1a8e879a6a9 124 // 0: 1 stop bits, 1: 2 stop bits
mbed_official 300:55638feb26a4 125 // int parity_enable, parity_select;
mbed_official 85:e1a8e879a6a9 126 switch (parity) {
mbed_official 227:7bd0639b8911 127 case ParityNone:
mbed_official 300:55638feb26a4 128 obj->uart->CONFIG = 0;
mbed_official 300:55638feb26a4 129 break;
mbed_official 85:e1a8e879a6a9 130 default:
mbed_official 300:55638feb26a4 131 obj->uart->CONFIG = (UART_CONFIG_PARITY_Included << UART_CONFIG_PARITY_Pos);
mbed_official 85:e1a8e879a6a9 132 return;
mbed_official 85:e1a8e879a6a9 133 }
mbed_official 85:e1a8e879a6a9 134 //no Flow Control
mbed_official 85:e1a8e879a6a9 135 }
mbed_official 85:e1a8e879a6a9 136
mbed_official 85:e1a8e879a6a9 137 //******************************************************************************
mbed_official 85:e1a8e879a6a9 138 // * INTERRUPT HANDLING
mbed_official 85:e1a8e879a6a9 139 //******************************************************************************
mbed_official 300:55638feb26a4 140 static inline void uart_irq(uint32_t iir, uint32_t index)
mbed_official 300:55638feb26a4 141 {
mbed_official 85:e1a8e879a6a9 142 SerialIrq irq_type;
mbed_official 85:e1a8e879a6a9 143 switch (iir) {
mbed_official 227:7bd0639b8911 144 case 1:
mbed_official 227:7bd0639b8911 145 irq_type = TxIrq;
mbed_official 300:55638feb26a4 146 break;
mbed_official 227:7bd0639b8911 147 case 2:
mbed_official 227:7bd0639b8911 148 irq_type = RxIrq;
mbed_official 300:55638feb26a4 149 break;
mbed_official 300:55638feb26a4 150
mbed_official 300:55638feb26a4 151 default:
mbed_official 300:55638feb26a4 152 return;
mbed_official 85:e1a8e879a6a9 153 }
mbed_official 300:55638feb26a4 154
mbed_official 300:55638feb26a4 155 if (serial_irq_ids[index] != 0) {
mbed_official 85:e1a8e879a6a9 156 irq_handler(serial_irq_ids[index], irq_type);
mbed_official 85:e1a8e879a6a9 157 }
mbed_official 85:e1a8e879a6a9 158 }
mbed_official 300:55638feb26a4 159
mbed_official 85:e1a8e879a6a9 160 #ifdef __cplusplus
mbed_official 85:e1a8e879a6a9 161 extern "C" {
mbed_official 227:7bd0639b8911 162 #endif
mbed_official 85:e1a8e879a6a9 163 void UART0_IRQHandler()
mbed_official 85:e1a8e879a6a9 164 {
mbed_official 518:0334fb94f264 165 if((NRF_UART0->INTENSET & UART_INTENSET_TXDRDY_Msk) && NRF_UART0->EVENTS_TXDRDY)
mbed_official 518:0334fb94f264 166 {
mbed_official 518:0334fb94f264 167 uart_irq(1, 0);
mbed_official 300:55638feb26a4 168
mbed_official 518:0334fb94f264 169 /* Explicitly clear TX flag to prevent interrupt from firing
mbed_official 518:0334fb94f264 170 immediately after returning from ISR. This ensures that the
mbed_official 518:0334fb94f264 171 last interrupt in a transmission sequence is correcly handled.
mbed_official 518:0334fb94f264 172 */
mbed_official 518:0334fb94f264 173 NRF_UART0->EVENTS_TXDRDY = 0;
mbed_official 85:e1a8e879a6a9 174 }
mbed_official 518:0334fb94f264 175 else if((NRF_UART0->INTENSET & UART_INTENSET_RXDRDY_Msk) && NRF_UART0->EVENTS_RXDRDY)
mbed_official 518:0334fb94f264 176 {
mbed_official 518:0334fb94f264 177 uart_irq(2, 0);
mbed_official 518:0334fb94f264 178 }
mbed_official 85:e1a8e879a6a9 179 }
mbed_official 300:55638feb26a4 180
mbed_official 85:e1a8e879a6a9 181 #ifdef __cplusplus
mbed_official 85:e1a8e879a6a9 182 }
mbed_official 227:7bd0639b8911 183 #endif
mbed_official 300:55638feb26a4 184 void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id)
mbed_official 300:55638feb26a4 185 {
mbed_official 300:55638feb26a4 186 irq_handler = handler;
mbed_official 85:e1a8e879a6a9 187 serial_irq_ids[obj->index] = id;
mbed_official 85:e1a8e879a6a9 188 }
mbed_official 85:e1a8e879a6a9 189
mbed_official 300:55638feb26a4 190 void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable)
mbed_official 300:55638feb26a4 191 {
mbed_official 85:e1a8e879a6a9 192 IRQn_Type irq_n = (IRQn_Type)0;
mbed_official 85:e1a8e879a6a9 193
mbed_official 85:e1a8e879a6a9 194 switch ((int)obj->uart) {
mbed_official 300:55638feb26a4 195 case UART_0:
mbed_official 300:55638feb26a4 196 irq_n = UART0_IRQn;
mbed_official 85:e1a8e879a6a9 197 break;
mbed_official 85:e1a8e879a6a9 198 }
mbed_official 300:55638feb26a4 199
mbed_official 85:e1a8e879a6a9 200 if (enable) {
mbed_official 85:e1a8e879a6a9 201 switch (irq) {
mbed_official 300:55638feb26a4 202 case RxIrq:
mbed_official 501:36015dec7d16 203 obj->uart->INTENSET = (UART_INTENSET_RXDRDY_Msk);
mbed_official 300:55638feb26a4 204 break;
mbed_official 300:55638feb26a4 205 case TxIrq:
mbed_official 501:36015dec7d16 206 obj->uart->INTENSET = (UART_INTENSET_TXDRDY_Msk);
mbed_official 300:55638feb26a4 207 break;
mbed_official 85:e1a8e879a6a9 208 }
mbed_official 85:e1a8e879a6a9 209 NVIC_SetPriority(irq_n, 3);
mbed_official 85:e1a8e879a6a9 210 NVIC_EnableIRQ(irq_n);
mbed_official 300:55638feb26a4 211 } else { // disable
mbed_official 433:73d4f6083dd2 212 // maseked writes to INTENSET dont disable and masked writes to
mbed_official 433:73d4f6083dd2 213 // INTENCLR seemed to clear the entire register, not bits.
mbed_official 433:73d4f6083dd2 214 // Added INTEN to memory map and seems to allow set and clearing of specific bits as desired
mbed_official 85:e1a8e879a6a9 215 int all_disabled = 0;
mbed_official 85:e1a8e879a6a9 216 switch (irq) {
mbed_official 300:55638feb26a4 217 case RxIrq:
mbed_official 501:36015dec7d16 218 obj->uart->INTENCLR = (UART_INTENCLR_RXDRDY_Msk);
mbed_official 501:36015dec7d16 219 all_disabled = (obj->uart->INTENCLR & (UART_INTENCLR_TXDRDY_Msk)) == 0;
mbed_official 300:55638feb26a4 220 break;
mbed_official 300:55638feb26a4 221 case TxIrq:
mbed_official 501:36015dec7d16 222 obj->uart->INTENCLR = (UART_INTENCLR_TXDRDY_Msk);
mbed_official 501:36015dec7d16 223 all_disabled = (obj->uart->INTENCLR & (UART_INTENCLR_RXDRDY_Msk)) == 0;
mbed_official 300:55638feb26a4 224 break;
mbed_official 85:e1a8e879a6a9 225 }
mbed_official 300:55638feb26a4 226
mbed_official 300:55638feb26a4 227 if (all_disabled) {
mbed_official 85:e1a8e879a6a9 228 NVIC_DisableIRQ(irq_n);
mbed_official 85:e1a8e879a6a9 229 }
mbed_official 85:e1a8e879a6a9 230 }
mbed_official 85:e1a8e879a6a9 231 }
mbed_official 85:e1a8e879a6a9 232
mbed_official 85:e1a8e879a6a9 233 //******************************************************************************
mbed_official 85:e1a8e879a6a9 234 //* READ/WRITE
mbed_official 85:e1a8e879a6a9 235 //******************************************************************************
mbed_official 300:55638feb26a4 236 int serial_getc(serial_t *obj)
mbed_official 300:55638feb26a4 237 {
mbed_official 300:55638feb26a4 238 while (!serial_readable(obj)) {
mbed_official 300:55638feb26a4 239 }
mbed_official 300:55638feb26a4 240
mbed_official 85:e1a8e879a6a9 241 obj->uart->EVENTS_RXDRDY = 0;
mbed_official 300:55638feb26a4 242
mbed_official 85:e1a8e879a6a9 243 return (uint8_t)obj->uart->RXD;
mbed_official 85:e1a8e879a6a9 244 }
mbed_official 85:e1a8e879a6a9 245
mbed_official 300:55638feb26a4 246 void serial_putc(serial_t *obj, int c)
mbed_official 300:55638feb26a4 247 {
mbed_official 518:0334fb94f264 248 /* In interrupt mode, send character immediately. Otherwise, block until
mbed_official 518:0334fb94f264 249 UART is ready to receive next character before sending.
mbed_official 300:55638feb26a4 250
mbed_official 518:0334fb94f264 251 The TXDRDY flag is cleared in interrupt handler to ensure that it is
mbed_official 518:0334fb94f264 252 cleared even if there are no more characters to send.
mbed_official 518:0334fb94f264 253 */
mbed_official 518:0334fb94f264 254 if (NRF_UART0->INTENSET & UART_INTENSET_TXDRDY_Msk)
mbed_official 518:0334fb94f264 255 {
mbed_official 518:0334fb94f264 256 obj->uart->TXD = (uint8_t)c;
mbed_official 518:0334fb94f264 257 }
mbed_official 518:0334fb94f264 258 else
mbed_official 518:0334fb94f264 259 {
mbed_official 518:0334fb94f264 260 while (!serial_writable(obj)) {
mbed_official 518:0334fb94f264 261 }
mbed_official 518:0334fb94f264 262
mbed_official 518:0334fb94f264 263 obj->uart->EVENTS_TXDRDY = 0;
mbed_official 518:0334fb94f264 264 obj->uart->TXD = (uint8_t)c;
mbed_official 518:0334fb94f264 265 }
mbed_official 85:e1a8e879a6a9 266 }
mbed_official 85:e1a8e879a6a9 267
mbed_official 300:55638feb26a4 268 int serial_readable(serial_t *obj)
mbed_official 300:55638feb26a4 269 {
mbed_official 85:e1a8e879a6a9 270 return (obj->uart->EVENTS_RXDRDY == 1);
mbed_official 85:e1a8e879a6a9 271 }
mbed_official 85:e1a8e879a6a9 272
mbed_official 300:55638feb26a4 273 int serial_writable(serial_t *obj)
mbed_official 300:55638feb26a4 274 {
mbed_official 433:73d4f6083dd2 275 return (obj->uart->EVENTS_TXDRDY == 1);
mbed_official 85:e1a8e879a6a9 276 }
mbed_official 85:e1a8e879a6a9 277
mbed_official 300:55638feb26a4 278 void serial_break_set(serial_t *obj)
mbed_official 300:55638feb26a4 279 {
mbed_official 85:e1a8e879a6a9 280 obj->uart->TASKS_SUSPEND = 1;
mbed_official 85:e1a8e879a6a9 281 }
mbed_official 85:e1a8e879a6a9 282
mbed_official 300:55638feb26a4 283 void serial_break_clear(serial_t *obj)
mbed_official 300:55638feb26a4 284 {
mbed_official 85:e1a8e879a6a9 285 obj->uart->TASKS_STARTTX = 1;
mbed_official 85:e1a8e879a6a9 286 obj->uart->TASKS_STARTRX = 1;
mbed_official 85:e1a8e879a6a9 287 }
mbed_official 340:28d1f895c6fe 288
mbed_official 340:28d1f895c6fe 289 void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow)
mbed_official 340:28d1f895c6fe 290 {
mbed_official 340:28d1f895c6fe 291
mbed_official 340:28d1f895c6fe 292 if (type == FlowControlRTSCTS || type == FlowControlRTS) {
mbed_official 340:28d1f895c6fe 293 NRF_GPIO->DIR |= (1<<rxflow);
mbed_official 340:28d1f895c6fe 294 pin_mode(rxflow, PullUp);
mbed_official 340:28d1f895c6fe 295 obj->uart->PSELRTS = rxflow;
mbed_official 340:28d1f895c6fe 296
mbed_official 340:28d1f895c6fe 297 obj->uart->CONFIG |= 0x01; // Enable HWFC
mbed_official 340:28d1f895c6fe 298 }
mbed_official 340:28d1f895c6fe 299
mbed_official 340:28d1f895c6fe 300 if (type == FlowControlRTSCTS || type == FlowControlCTS) {
mbed_official 340:28d1f895c6fe 301 NRF_GPIO->DIR &= ~(1<<txflow);
mbed_official 340:28d1f895c6fe 302 pin_mode(txflow, PullUp);
mbed_official 340:28d1f895c6fe 303 obj->uart->PSELCTS = txflow;
mbed_official 340:28d1f895c6fe 304
mbed_official 340:28d1f895c6fe 305 obj->uart->CONFIG |= 0x01; // Enable HWFC;
mbed_official 340:28d1f895c6fe 306 }
mbed_official 340:28d1f895c6fe 307
mbed_official 340:28d1f895c6fe 308 if (type == FlowControlNone) {
mbed_official 340:28d1f895c6fe 309 obj->uart->PSELRTS = 0xFFFFFFFF; // Disable RTS
mbed_official 340:28d1f895c6fe 310 obj->uart->PSELCTS = 0xFFFFFFFF; // Disable CTS
mbed_official 340:28d1f895c6fe 311
mbed_official 340:28d1f895c6fe 312 obj->uart->CONFIG &= ~0x01; // Enable HWFC;
mbed_official 340:28d1f895c6fe 313 }
mbed_official 340:28d1f895c6fe 314 }
mbed_official 340:28d1f895c6fe 315
mbed_official 340:28d1f895c6fe 316 void serial_clear(serial_t *obj) {
mbed_official 340:28d1f895c6fe 317 }