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