Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
hal/serial_api.h@1:8a094db1347f, 2020-11-09 (annotated)
- Committer:
- elijahsj
- Date:
- Mon Nov 09 00:02:47 2020 -0500
- Revision:
- 1:8a094db1347f
test
Who changed what in which revision?
| User | Revision | Line number | New contents of line | 
|---|---|---|---|
| elijahsj | 1:8a094db1347f | 1 | |
| elijahsj | 1:8a094db1347f | 2 | /** \addtogroup hal */ | 
| elijahsj | 1:8a094db1347f | 3 | /** @{*/ | 
| elijahsj | 1:8a094db1347f | 4 | /* mbed Microcontroller Library | 
| elijahsj | 1:8a094db1347f | 5 | * Copyright (c) 2006-2013 ARM Limited | 
| elijahsj | 1:8a094db1347f | 6 | * | 
| elijahsj | 1:8a094db1347f | 7 | * Licensed under the Apache License, Version 2.0 (the "License"); | 
| elijahsj | 1:8a094db1347f | 8 | * you may not use this file except in compliance with the License. | 
| elijahsj | 1:8a094db1347f | 9 | * You may obtain a copy of the License at | 
| elijahsj | 1:8a094db1347f | 10 | * | 
| elijahsj | 1:8a094db1347f | 11 | * http://www.apache.org/licenses/LICENSE-2.0 | 
| elijahsj | 1:8a094db1347f | 12 | * | 
| elijahsj | 1:8a094db1347f | 13 | * Unless required by applicable law or agreed to in writing, software | 
| elijahsj | 1:8a094db1347f | 14 | * distributed under the License is distributed on an "AS IS" BASIS, | 
| elijahsj | 1:8a094db1347f | 15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. | 
| elijahsj | 1:8a094db1347f | 16 | * See the License for the specific language governing permissions and | 
| elijahsj | 1:8a094db1347f | 17 | * limitations under the License. | 
| elijahsj | 1:8a094db1347f | 18 | */ | 
| elijahsj | 1:8a094db1347f | 19 | #ifndef MBED_SERIAL_API_H | 
| elijahsj | 1:8a094db1347f | 20 | #define MBED_SERIAL_API_H | 
| elijahsj | 1:8a094db1347f | 21 | |
| elijahsj | 1:8a094db1347f | 22 | #include "device.h" | 
| elijahsj | 1:8a094db1347f | 23 | #include "hal/buffer.h" | 
| elijahsj | 1:8a094db1347f | 24 | #include "hal/dma_api.h" | 
| elijahsj | 1:8a094db1347f | 25 | |
| elijahsj | 1:8a094db1347f | 26 | #if DEVICE_SERIAL | 
| elijahsj | 1:8a094db1347f | 27 | |
| elijahsj | 1:8a094db1347f | 28 | #define SERIAL_EVENT_TX_SHIFT (2) | 
| elijahsj | 1:8a094db1347f | 29 | #define SERIAL_EVENT_RX_SHIFT (8) | 
| elijahsj | 1:8a094db1347f | 30 | |
| elijahsj | 1:8a094db1347f | 31 | #define SERIAL_EVENT_TX_MASK (0x00FC) | 
| elijahsj | 1:8a094db1347f | 32 | #define SERIAL_EVENT_RX_MASK (0x3F00) | 
| elijahsj | 1:8a094db1347f | 33 | |
| elijahsj | 1:8a094db1347f | 34 | #define SERIAL_EVENT_ERROR (1 << 1) | 
| elijahsj | 1:8a094db1347f | 35 | |
| elijahsj | 1:8a094db1347f | 36 | /** | 
| elijahsj | 1:8a094db1347f | 37 | * @defgroup SerialTXEvents Serial TX Events Macros | 
| elijahsj | 1:8a094db1347f | 38 | * | 
| elijahsj | 1:8a094db1347f | 39 | * @{ | 
| elijahsj | 1:8a094db1347f | 40 | */ | 
| elijahsj | 1:8a094db1347f | 41 | #define SERIAL_EVENT_TX_COMPLETE (1 << (SERIAL_EVENT_TX_SHIFT + 0)) | 
| elijahsj | 1:8a094db1347f | 42 | #define SERIAL_EVENT_TX_ALL (SERIAL_EVENT_TX_COMPLETE) | 
| elijahsj | 1:8a094db1347f | 43 | /**@}*/ | 
| elijahsj | 1:8a094db1347f | 44 | |
| elijahsj | 1:8a094db1347f | 45 | /** | 
| elijahsj | 1:8a094db1347f | 46 | * @defgroup SerialRXEvents Serial RX Events Macros | 
| elijahsj | 1:8a094db1347f | 47 | * | 
| elijahsj | 1:8a094db1347f | 48 | * @{ | 
| elijahsj | 1:8a094db1347f | 49 | */ | 
| elijahsj | 1:8a094db1347f | 50 | #define SERIAL_EVENT_RX_COMPLETE (1 << (SERIAL_EVENT_RX_SHIFT + 0)) | 
| elijahsj | 1:8a094db1347f | 51 | #define SERIAL_EVENT_RX_OVERRUN_ERROR (1 << (SERIAL_EVENT_RX_SHIFT + 1)) | 
| elijahsj | 1:8a094db1347f | 52 | #define SERIAL_EVENT_RX_FRAMING_ERROR (1 << (SERIAL_EVENT_RX_SHIFT + 2)) | 
| elijahsj | 1:8a094db1347f | 53 | #define SERIAL_EVENT_RX_PARITY_ERROR (1 << (SERIAL_EVENT_RX_SHIFT + 3)) | 
| elijahsj | 1:8a094db1347f | 54 | #define SERIAL_EVENT_RX_OVERFLOW (1 << (SERIAL_EVENT_RX_SHIFT + 4)) | 
| elijahsj | 1:8a094db1347f | 55 | #define SERIAL_EVENT_RX_CHARACTER_MATCH (1 << (SERIAL_EVENT_RX_SHIFT + 5)) | 
| elijahsj | 1:8a094db1347f | 56 | #define SERIAL_EVENT_RX_ALL (SERIAL_EVENT_RX_OVERFLOW | SERIAL_EVENT_RX_PARITY_ERROR | \ | 
| elijahsj | 1:8a094db1347f | 57 | SERIAL_EVENT_RX_FRAMING_ERROR | SERIAL_EVENT_RX_OVERRUN_ERROR | \ | 
| elijahsj | 1:8a094db1347f | 58 | SERIAL_EVENT_RX_COMPLETE | SERIAL_EVENT_RX_CHARACTER_MATCH) | 
| elijahsj | 1:8a094db1347f | 59 | /**@}*/ | 
| elijahsj | 1:8a094db1347f | 60 | |
| elijahsj | 1:8a094db1347f | 61 | #define SERIAL_RESERVED_CHAR_MATCH (255) | 
| elijahsj | 1:8a094db1347f | 62 | |
| elijahsj | 1:8a094db1347f | 63 | typedef enum { | 
| elijahsj | 1:8a094db1347f | 64 | ParityNone = 0, | 
| elijahsj | 1:8a094db1347f | 65 | ParityOdd = 1, | 
| elijahsj | 1:8a094db1347f | 66 | ParityEven = 2, | 
| elijahsj | 1:8a094db1347f | 67 | ParityForced1 = 3, | 
| elijahsj | 1:8a094db1347f | 68 | ParityForced0 = 4 | 
| elijahsj | 1:8a094db1347f | 69 | } SerialParity; | 
| elijahsj | 1:8a094db1347f | 70 | |
| elijahsj | 1:8a094db1347f | 71 | typedef enum { | 
| elijahsj | 1:8a094db1347f | 72 | RxIrq, | 
| elijahsj | 1:8a094db1347f | 73 | TxIrq | 
| elijahsj | 1:8a094db1347f | 74 | } SerialIrq; | 
| elijahsj | 1:8a094db1347f | 75 | |
| elijahsj | 1:8a094db1347f | 76 | typedef enum { | 
| elijahsj | 1:8a094db1347f | 77 | FlowControlNone, | 
| elijahsj | 1:8a094db1347f | 78 | FlowControlRTS, | 
| elijahsj | 1:8a094db1347f | 79 | FlowControlCTS, | 
| elijahsj | 1:8a094db1347f | 80 | FlowControlRTSCTS | 
| elijahsj | 1:8a094db1347f | 81 | } FlowControl; | 
| elijahsj | 1:8a094db1347f | 82 | |
| elijahsj | 1:8a094db1347f | 83 | typedef void (*uart_irq_handler)(uint32_t id, SerialIrq event); | 
| elijahsj | 1:8a094db1347f | 84 | |
| elijahsj | 1:8a094db1347f | 85 | #if DEVICE_SERIAL_ASYNCH | 
| elijahsj | 1:8a094db1347f | 86 | /** Asynch serial HAL structure | 
| elijahsj | 1:8a094db1347f | 87 | */ | 
| elijahsj | 1:8a094db1347f | 88 | typedef struct { | 
| elijahsj | 1:8a094db1347f | 89 | struct serial_s serial; /**< Target specific serial structure */ | 
| elijahsj | 1:8a094db1347f | 90 | struct buffer_s tx_buff; /**< TX buffer */ | 
| elijahsj | 1:8a094db1347f | 91 | struct buffer_s rx_buff; /**< RX buffer */ | 
| elijahsj | 1:8a094db1347f | 92 | uint8_t char_match; /**< Character to be matched */ | 
| elijahsj | 1:8a094db1347f | 93 | uint8_t char_found; /**< State of the matched character */ | 
| elijahsj | 1:8a094db1347f | 94 | } serial_t; | 
| elijahsj | 1:8a094db1347f | 95 | |
| elijahsj | 1:8a094db1347f | 96 | #else | 
| elijahsj | 1:8a094db1347f | 97 | /** Non-asynch serial HAL structure | 
| elijahsj | 1:8a094db1347f | 98 | */ | 
| elijahsj | 1:8a094db1347f | 99 | typedef struct serial_s serial_t; | 
| elijahsj | 1:8a094db1347f | 100 | |
| elijahsj | 1:8a094db1347f | 101 | #endif | 
| elijahsj | 1:8a094db1347f | 102 | |
| elijahsj | 1:8a094db1347f | 103 | #ifdef __cplusplus | 
| elijahsj | 1:8a094db1347f | 104 | extern "C" { | 
| elijahsj | 1:8a094db1347f | 105 | #endif | 
| elijahsj | 1:8a094db1347f | 106 | |
| elijahsj | 1:8a094db1347f | 107 | /** | 
| elijahsj | 1:8a094db1347f | 108 | * \defgroup hal_GeneralSerial Serial Configuration Functions | 
| elijahsj | 1:8a094db1347f | 109 | * @{ | 
| elijahsj | 1:8a094db1347f | 110 | */ | 
| elijahsj | 1:8a094db1347f | 111 | |
| elijahsj | 1:8a094db1347f | 112 | /** Initialize the serial peripheral. It sets the default parameters for serial | 
| elijahsj | 1:8a094db1347f | 113 | * peripheral, and configures its specifieds pins. | 
| elijahsj | 1:8a094db1347f | 114 | * | 
| elijahsj | 1:8a094db1347f | 115 | * @param obj The serial object | 
| elijahsj | 1:8a094db1347f | 116 | * @param tx The TX pin name | 
| elijahsj | 1:8a094db1347f | 117 | * @param rx The RX pin name | 
| elijahsj | 1:8a094db1347f | 118 | */ | 
| elijahsj | 1:8a094db1347f | 119 | void serial_init(serial_t *obj, PinName tx, PinName rx); | 
| elijahsj | 1:8a094db1347f | 120 | |
| elijahsj | 1:8a094db1347f | 121 | /** Release the serial peripheral, not currently invoked. It requires further | 
| elijahsj | 1:8a094db1347f | 122 | * resource management. | 
| elijahsj | 1:8a094db1347f | 123 | * | 
| elijahsj | 1:8a094db1347f | 124 | * @param obj The serial object | 
| elijahsj | 1:8a094db1347f | 125 | */ | 
| elijahsj | 1:8a094db1347f | 126 | void serial_free(serial_t *obj); | 
| elijahsj | 1:8a094db1347f | 127 | |
| elijahsj | 1:8a094db1347f | 128 | /** Configure the baud rate | 
| elijahsj | 1:8a094db1347f | 129 | * | 
| elijahsj | 1:8a094db1347f | 130 | * @param obj The serial object | 
| elijahsj | 1:8a094db1347f | 131 | * @param baudrate The baud rate to be configured | 
| elijahsj | 1:8a094db1347f | 132 | */ | 
| elijahsj | 1:8a094db1347f | 133 | void serial_baud(serial_t *obj, int baudrate); | 
| elijahsj | 1:8a094db1347f | 134 | |
| elijahsj | 1:8a094db1347f | 135 | /** Configure the format. Set the number of bits, parity and the number of stop bits | 
| elijahsj | 1:8a094db1347f | 136 | * | 
| elijahsj | 1:8a094db1347f | 137 | * @param obj The serial object | 
| elijahsj | 1:8a094db1347f | 138 | * @param data_bits The number of data bits | 
| elijahsj | 1:8a094db1347f | 139 | * @param parity The parity | 
| elijahsj | 1:8a094db1347f | 140 | * @param stop_bits The number of stop bits | 
| elijahsj | 1:8a094db1347f | 141 | */ | 
| elijahsj | 1:8a094db1347f | 142 | void serial_format(serial_t *obj, int data_bits, SerialParity parity, int stop_bits); | 
| elijahsj | 1:8a094db1347f | 143 | |
| elijahsj | 1:8a094db1347f | 144 | /** The serial interrupt handler registration | 
| elijahsj | 1:8a094db1347f | 145 | * | 
| elijahsj | 1:8a094db1347f | 146 | * @param obj The serial object | 
| elijahsj | 1:8a094db1347f | 147 | * @param handler The interrupt handler which will be invoked when the interrupt fires | 
| elijahsj | 1:8a094db1347f | 148 | * @param id The SerialBase object | 
| elijahsj | 1:8a094db1347f | 149 | */ | 
| elijahsj | 1:8a094db1347f | 150 | void serial_irq_handler(serial_t *obj, uart_irq_handler handler, uint32_t id); | 
| elijahsj | 1:8a094db1347f | 151 | |
| elijahsj | 1:8a094db1347f | 152 | /** Configure serial interrupt. This function is used for word-approach | 
| elijahsj | 1:8a094db1347f | 153 | * | 
| elijahsj | 1:8a094db1347f | 154 | * @param obj The serial object | 
| elijahsj | 1:8a094db1347f | 155 | * @param irq The serial IRQ type (RX or TX) | 
| elijahsj | 1:8a094db1347f | 156 | * @param enable Set to non-zero to enable events, or zero to disable them | 
| elijahsj | 1:8a094db1347f | 157 | */ | 
| elijahsj | 1:8a094db1347f | 158 | void serial_irq_set(serial_t *obj, SerialIrq irq, uint32_t enable); | 
| elijahsj | 1:8a094db1347f | 159 | |
| elijahsj | 1:8a094db1347f | 160 | /** Get character. This is a blocking call, waiting for a character | 
| elijahsj | 1:8a094db1347f | 161 | * | 
| elijahsj | 1:8a094db1347f | 162 | * @param obj The serial object | 
| elijahsj | 1:8a094db1347f | 163 | */ | 
| elijahsj | 1:8a094db1347f | 164 | int serial_getc(serial_t *obj); | 
| elijahsj | 1:8a094db1347f | 165 | |
| elijahsj | 1:8a094db1347f | 166 | /** Send a character. This is a blocking call, waiting for a peripheral to be available | 
| elijahsj | 1:8a094db1347f | 167 | * for writing | 
| elijahsj | 1:8a094db1347f | 168 | * | 
| elijahsj | 1:8a094db1347f | 169 | * @param obj The serial object | 
| elijahsj | 1:8a094db1347f | 170 | * @param c The character to be sent | 
| elijahsj | 1:8a094db1347f | 171 | */ | 
| elijahsj | 1:8a094db1347f | 172 | void serial_putc(serial_t *obj, int c); | 
| elijahsj | 1:8a094db1347f | 173 | |
| elijahsj | 1:8a094db1347f | 174 | /** Check if the serial peripheral is readable | 
| elijahsj | 1:8a094db1347f | 175 | * | 
| elijahsj | 1:8a094db1347f | 176 | * @param obj The serial object | 
| elijahsj | 1:8a094db1347f | 177 | * @return Non-zero value if a character can be read, 0 if nothing to read | 
| elijahsj | 1:8a094db1347f | 178 | */ | 
| elijahsj | 1:8a094db1347f | 179 | int serial_readable(serial_t *obj); | 
| elijahsj | 1:8a094db1347f | 180 | |
| elijahsj | 1:8a094db1347f | 181 | /** Check if the serial peripheral is writable | 
| elijahsj | 1:8a094db1347f | 182 | * | 
| elijahsj | 1:8a094db1347f | 183 | * @param obj The serial object | 
| elijahsj | 1:8a094db1347f | 184 | * @return Non-zero value if a character can be written, 0 otherwise. | 
| elijahsj | 1:8a094db1347f | 185 | */ | 
| elijahsj | 1:8a094db1347f | 186 | int serial_writable(serial_t *obj); | 
| elijahsj | 1:8a094db1347f | 187 | |
| elijahsj | 1:8a094db1347f | 188 | /** Clear the serial peripheral | 
| elijahsj | 1:8a094db1347f | 189 | * | 
| elijahsj | 1:8a094db1347f | 190 | * @param obj The serial object | 
| elijahsj | 1:8a094db1347f | 191 | */ | 
| elijahsj | 1:8a094db1347f | 192 | void serial_clear(serial_t *obj); | 
| elijahsj | 1:8a094db1347f | 193 | |
| elijahsj | 1:8a094db1347f | 194 | /** Set the break | 
| elijahsj | 1:8a094db1347f | 195 | * | 
| elijahsj | 1:8a094db1347f | 196 | * @param obj The serial object | 
| elijahsj | 1:8a094db1347f | 197 | */ | 
| elijahsj | 1:8a094db1347f | 198 | void serial_break_set(serial_t *obj); | 
| elijahsj | 1:8a094db1347f | 199 | |
| elijahsj | 1:8a094db1347f | 200 | /** Clear the break | 
| elijahsj | 1:8a094db1347f | 201 | * | 
| elijahsj | 1:8a094db1347f | 202 | * @param obj The serial object | 
| elijahsj | 1:8a094db1347f | 203 | */ | 
| elijahsj | 1:8a094db1347f | 204 | void serial_break_clear(serial_t *obj); | 
| elijahsj | 1:8a094db1347f | 205 | |
| elijahsj | 1:8a094db1347f | 206 | /** Configure the TX pin for UART function. | 
| elijahsj | 1:8a094db1347f | 207 | * | 
| elijahsj | 1:8a094db1347f | 208 | * @param tx The pin name used for TX | 
| elijahsj | 1:8a094db1347f | 209 | */ | 
| elijahsj | 1:8a094db1347f | 210 | void serial_pinout_tx(PinName tx); | 
| elijahsj | 1:8a094db1347f | 211 | |
| elijahsj | 1:8a094db1347f | 212 | /** Configure the serial for the flow control. It sets flow control in the hardware | 
| elijahsj | 1:8a094db1347f | 213 | * if a serial peripheral supports it, otherwise software emulation is used. | 
| elijahsj | 1:8a094db1347f | 214 | * | 
| elijahsj | 1:8a094db1347f | 215 | * @param obj The serial object | 
| elijahsj | 1:8a094db1347f | 216 | * @param type The type of the flow control. Look at the available FlowControl types. | 
| elijahsj | 1:8a094db1347f | 217 | * @param rxflow The TX pin name | 
| elijahsj | 1:8a094db1347f | 218 | * @param txflow The RX pin name | 
| elijahsj | 1:8a094db1347f | 219 | */ | 
| elijahsj | 1:8a094db1347f | 220 | void serial_set_flow_control(serial_t *obj, FlowControl type, PinName rxflow, PinName txflow); | 
| elijahsj | 1:8a094db1347f | 221 | |
| elijahsj | 1:8a094db1347f | 222 | #if DEVICE_SERIAL_ASYNCH | 
| elijahsj | 1:8a094db1347f | 223 | |
| elijahsj | 1:8a094db1347f | 224 | /**@}*/ | 
| elijahsj | 1:8a094db1347f | 225 | |
| elijahsj | 1:8a094db1347f | 226 | /** | 
| elijahsj | 1:8a094db1347f | 227 | * \defgroup hal_AsynchSerial Asynchronous Serial Hardware Abstraction Layer | 
| elijahsj | 1:8a094db1347f | 228 | * @{ | 
| elijahsj | 1:8a094db1347f | 229 | */ | 
| elijahsj | 1:8a094db1347f | 230 | |
| elijahsj | 1:8a094db1347f | 231 | /** Begin asynchronous TX transfer. The used buffer is specified in the serial object, | 
| elijahsj | 1:8a094db1347f | 232 | * tx_buff | 
| elijahsj | 1:8a094db1347f | 233 | * | 
| elijahsj | 1:8a094db1347f | 234 | * @param obj The serial object | 
| elijahsj | 1:8a094db1347f | 235 | * @param tx The transmit buffer | 
| elijahsj | 1:8a094db1347f | 236 | * @param tx_length The number of bytes to transmit | 
| elijahsj | 1:8a094db1347f | 237 | * @param tx_width Deprecated argument | 
| elijahsj | 1:8a094db1347f | 238 | * @param handler The serial handler | 
| elijahsj | 1:8a094db1347f | 239 | * @param event The logical OR of events to be registered | 
| elijahsj | 1:8a094db1347f | 240 | * @param hint A suggestion for how to use DMA with this transfer | 
| elijahsj | 1:8a094db1347f | 241 | * @return Returns number of data transfered, otherwise returns 0 | 
| elijahsj | 1:8a094db1347f | 242 | */ | 
| elijahsj | 1:8a094db1347f | 243 | int serial_tx_asynch(serial_t *obj, const void *tx, size_t tx_length, uint8_t tx_width, uint32_t handler, uint32_t event, DMAUsage hint); | 
| elijahsj | 1:8a094db1347f | 244 | |
| elijahsj | 1:8a094db1347f | 245 | /** Begin asynchronous RX transfer (enable interrupt for data collecting) | 
| elijahsj | 1:8a094db1347f | 246 | * The used buffer is specified in the serial object - rx_buff | 
| elijahsj | 1:8a094db1347f | 247 | * | 
| elijahsj | 1:8a094db1347f | 248 | * @param obj The serial object | 
| elijahsj | 1:8a094db1347f | 249 | * @param rx The receive buffer | 
| elijahsj | 1:8a094db1347f | 250 | * @param rx_length The number of bytes to receive | 
| elijahsj | 1:8a094db1347f | 251 | * @param rx_width Deprecated argument | 
| elijahsj | 1:8a094db1347f | 252 | * @param handler The serial handler | 
| elijahsj | 1:8a094db1347f | 253 | * @param event The logical OR of events to be registered | 
| elijahsj | 1:8a094db1347f | 254 | * @param handler The serial handler | 
| elijahsj | 1:8a094db1347f | 255 | * @param char_match A character in range 0-254 to be matched | 
| elijahsj | 1:8a094db1347f | 256 | * @param hint A suggestion for how to use DMA with this transfer | 
| elijahsj | 1:8a094db1347f | 257 | */ | 
| elijahsj | 1:8a094db1347f | 258 | void serial_rx_asynch(serial_t *obj, void *rx, size_t rx_length, uint8_t rx_width, uint32_t handler, uint32_t event, uint8_t char_match, DMAUsage hint); | 
| elijahsj | 1:8a094db1347f | 259 | |
| elijahsj | 1:8a094db1347f | 260 | /** Attempts to determine if the serial peripheral is already in use for TX | 
| elijahsj | 1:8a094db1347f | 261 | * | 
| elijahsj | 1:8a094db1347f | 262 | * @param obj The serial object | 
| elijahsj | 1:8a094db1347f | 263 | * @return Non-zero if the RX transaction is ongoing, 0 otherwise | 
| elijahsj | 1:8a094db1347f | 264 | */ | 
| elijahsj | 1:8a094db1347f | 265 | uint8_t serial_tx_active(serial_t *obj); | 
| elijahsj | 1:8a094db1347f | 266 | |
| elijahsj | 1:8a094db1347f | 267 | /** Attempts to determine if the serial peripheral is already in use for RX | 
| elijahsj | 1:8a094db1347f | 268 | * | 
| elijahsj | 1:8a094db1347f | 269 | * @param obj The serial object | 
| elijahsj | 1:8a094db1347f | 270 | * @return Non-zero if the RX transaction is ongoing, 0 otherwise | 
| elijahsj | 1:8a094db1347f | 271 | */ | 
| elijahsj | 1:8a094db1347f | 272 | uint8_t serial_rx_active(serial_t *obj); | 
| elijahsj | 1:8a094db1347f | 273 | |
| elijahsj | 1:8a094db1347f | 274 | /** The asynchronous TX and RX handler. | 
| elijahsj | 1:8a094db1347f | 275 | * | 
| elijahsj | 1:8a094db1347f | 276 | * @param obj The serial object | 
| elijahsj | 1:8a094db1347f | 277 | * @return Returns event flags if an RX transfer termination condition was met; otherwise returns 0 | 
| elijahsj | 1:8a094db1347f | 278 | */ | 
| elijahsj | 1:8a094db1347f | 279 | int serial_irq_handler_asynch(serial_t *obj); | 
| elijahsj | 1:8a094db1347f | 280 | |
| elijahsj | 1:8a094db1347f | 281 | /** Abort the ongoing TX transaction. It disables the enabled interupt for TX and | 
| elijahsj | 1:8a094db1347f | 282 | * flushes the TX hardware buffer if TX FIFO is used | 
| elijahsj | 1:8a094db1347f | 283 | * | 
| elijahsj | 1:8a094db1347f | 284 | * @param obj The serial object | 
| elijahsj | 1:8a094db1347f | 285 | */ | 
| elijahsj | 1:8a094db1347f | 286 | void serial_tx_abort_asynch(serial_t *obj); | 
| elijahsj | 1:8a094db1347f | 287 | |
| elijahsj | 1:8a094db1347f | 288 | /** Abort the ongoing RX transaction. It disables the enabled interrupt for RX and | 
| elijahsj | 1:8a094db1347f | 289 | * flushes the RX hardware buffer if RX FIFO is used | 
| elijahsj | 1:8a094db1347f | 290 | * | 
| elijahsj | 1:8a094db1347f | 291 | * @param obj The serial object | 
| elijahsj | 1:8a094db1347f | 292 | */ | 
| elijahsj | 1:8a094db1347f | 293 | void serial_rx_abort_asynch(serial_t *obj); | 
| elijahsj | 1:8a094db1347f | 294 | |
| elijahsj | 1:8a094db1347f | 295 | /**@}*/ | 
| elijahsj | 1:8a094db1347f | 296 | |
| elijahsj | 1:8a094db1347f | 297 | #endif | 
| elijahsj | 1:8a094db1347f | 298 | |
| elijahsj | 1:8a094db1347f | 299 | #ifdef __cplusplus | 
| elijahsj | 1:8a094db1347f | 300 | } | 
| elijahsj | 1:8a094db1347f | 301 | #endif | 
| elijahsj | 1:8a094db1347f | 302 | |
| elijahsj | 1:8a094db1347f | 303 | #endif | 
| elijahsj | 1:8a094db1347f | 304 | |
| elijahsj | 1:8a094db1347f | 305 | #endif | 
| elijahsj | 1:8a094db1347f | 306 | |
| elijahsj | 1:8a094db1347f | 307 | /** @}*/ |