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