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