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