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