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