USBUART - IRQ

Dependents:   MPU9250AHRS_UBSUART-IRQ

Fork of MODSERIAL by Andy K

Committer:
AjK
Date:
Sun Nov 21 14:44:02 2010 +0000
Revision:
4:28de979b77cf
Parent:
3:0f10f536456e
Child:
6:c8f77fe1cc10
1.4

Who changed what in which revision?

UserRevisionLine numberNew contents of line
AjK 0:eb2522b41db8 1 /*
AjK 0:eb2522b41db8 2 Copyright (c) 2010 Andy Kirkham
AjK 0:eb2522b41db8 3
AjK 0:eb2522b41db8 4 Permission is hereby granted, free of charge, to any person obtaining a copy
AjK 0:eb2522b41db8 5 of this software and associated documentation files (the "Software"), to deal
AjK 0:eb2522b41db8 6 in the Software without restriction, including without limitation the rights
AjK 0:eb2522b41db8 7 to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
AjK 0:eb2522b41db8 8 copies of the Software, and to permit persons to whom the Software is
AjK 0:eb2522b41db8 9 furnished to do so, subject to the following conditions:
AjK 0:eb2522b41db8 10
AjK 0:eb2522b41db8 11 The above copyright notice and this permission notice shall be included in
AjK 0:eb2522b41db8 12 all copies or substantial portions of the Software.
AjK 0:eb2522b41db8 13
AjK 0:eb2522b41db8 14 THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
AjK 0:eb2522b41db8 15 IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
AjK 0:eb2522b41db8 16 FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AjK 0:eb2522b41db8 17 AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
AjK 0:eb2522b41db8 18 LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
AjK 0:eb2522b41db8 19 OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
AjK 0:eb2522b41db8 20 THE SOFTWARE.
AjK 0:eb2522b41db8 21 */
AjK 0:eb2522b41db8 22
AjK 0:eb2522b41db8 23 #ifndef MODSERIAL_H
AjK 0:eb2522b41db8 24 #define MODSERIAL_H
AjK 0:eb2522b41db8 25
AjK 0:eb2522b41db8 26 /** @defgroup API The MODSERIAL API */
AjK 0:eb2522b41db8 27 /** @defgroup MISC Misc MODSERIAL functions */
AjK 0:eb2522b41db8 28 /** @defgroup INTERNALS MODSERIAL Internals */
AjK 0:eb2522b41db8 29
AjK 0:eb2522b41db8 30 #ifndef MODSERIAL_DEFAULT_RX_BUFFER_SIZE
AjK 0:eb2522b41db8 31 #define MODSERIAL_DEFAULT_RX_BUFFER_SIZE 256
AjK 0:eb2522b41db8 32 #endif
AjK 0:eb2522b41db8 33
AjK 0:eb2522b41db8 34 #ifndef MODSERIAL_DEFAULT_TX_BUFFER_SIZE
AjK 0:eb2522b41db8 35 #define MODSERIAL_DEFAULT_TX_BUFFER_SIZE 256
AjK 0:eb2522b41db8 36 #endif
AjK 0:eb2522b41db8 37
AjK 0:eb2522b41db8 38 #include "mbed.h"
AjK 0:eb2522b41db8 39
AjK 0:eb2522b41db8 40 namespace AjK {
AjK 0:eb2522b41db8 41
AjK 0:eb2522b41db8 42 /**
AjK 0:eb2522b41db8 43 * @author Andy Kirkham
AjK 0:eb2522b41db8 44 * @see http://mbed.org/cookbook/MODSERIAL
AjK 0:eb2522b41db8 45 * @see http://mbed.org/handbook/Serial
AjK 0:eb2522b41db8 46 * @see example.cpp
AjK 0:eb2522b41db8 47 * @see API
AjK 0:eb2522b41db8 48 *
AjK 0:eb2522b41db8 49 * <b>MODSERIAL</b> extends the Mbed library <a href="/handbook/Serial">Serial</a> to provide fully buffered
AjK 0:eb2522b41db8 50 * TX and RX streams. Buffer length is fully customisable.
AjK 0:eb2522b41db8 51 *
AjK 0:eb2522b41db8 52 * Before using MODSERIAL users should be familar with Mbed's standard <a href="/handbook/Serial">Serial</a>
AjK 0:eb2522b41db8 53 * library object. MODSERIAL is a direct "drop in" replacement for <a href="/handbook/Serial">Serial</a>. Where
AjK 0:eb2522b41db8 54 * previously Serial was used, MODSERIAL can be used as adirect replacement instantly offering standard
AjK 0:eb2522b41db8 55 * TX and RX buffering. By default, both TX and RX buffers are 256 bytes in length.
AjK 0:eb2522b41db8 56 *
AjK 0:eb2522b41db8 57 * @image html /media/uploads/mbedofficial/serial_interfaces.png
AjK 0:eb2522b41db8 58 *
AjK 0:eb2522b41db8 59 * Standard example:
AjK 0:eb2522b41db8 60 * @code
AjK 0:eb2522b41db8 61 * #include "mbed.h"
AjK 0:eb2522b41db8 62 * #include "MODSERIAL.h"
AjK 0:eb2522b41db8 63 *
AjK 0:eb2522b41db8 64 * MODSERIAL pc(USBTX, USBRX); // tx, rx
AjK 0:eb2522b41db8 65 *
AjK 0:eb2522b41db8 66 * int main() {
AjK 0:eb2522b41db8 67 * pc.printf("Hello World!");
AjK 0:eb2522b41db8 68 * while(1) {
AjK 0:eb2522b41db8 69 * pc.putc(pc.getc() + 1);
AjK 0:eb2522b41db8 70 * }
AjK 0:eb2522b41db8 71 * }
AjK 0:eb2522b41db8 72 * @endcode
AjK 0:eb2522b41db8 73 *
AjK 0:eb2522b41db8 74 * Example with alternate buffer length:
AjK 0:eb2522b41db8 75 * @code
AjK 0:eb2522b41db8 76 * #include "mbed.h"
AjK 0:eb2522b41db8 77 * #include "MODSERIAL.h"
AjK 0:eb2522b41db8 78 *
AjK 0:eb2522b41db8 79 * // Make TX and RX buffers 512byes in length
AjK 0:eb2522b41db8 80 * MODSERIAL pc(USBTX, USBRX, 512); // tx, rx
AjK 0:eb2522b41db8 81 *
AjK 0:eb2522b41db8 82 * int main() {
AjK 0:eb2522b41db8 83 * pc.printf("Hello World!");
AjK 0:eb2522b41db8 84 * while(1) {
AjK 0:eb2522b41db8 85 * pc.putc(pc.getc() + 1);
AjK 0:eb2522b41db8 86 * }
AjK 0:eb2522b41db8 87 * }
AjK 0:eb2522b41db8 88 * @endcode
AjK 0:eb2522b41db8 89 *
AjK 0:eb2522b41db8 90 * Example with alternate buffer length:
AjK 0:eb2522b41db8 91 * @code
AjK 0:eb2522b41db8 92 * #include "mbed.h"
AjK 0:eb2522b41db8 93 * #include "MODSERIAL.h"
AjK 0:eb2522b41db8 94 *
AjK 0:eb2522b41db8 95 * // Make TX 1024bytes and RX 512byes in length
AjK 0:eb2522b41db8 96 * MODSERIAL pc(USBTX, USBRX, 1024, 512); // tx, rx
AjK 0:eb2522b41db8 97 *
AjK 0:eb2522b41db8 98 * int main() {
AjK 0:eb2522b41db8 99 * pc.printf("Hello World!");
AjK 0:eb2522b41db8 100 * while(1) {
AjK 0:eb2522b41db8 101 * pc.putc(pc.getc() + 1);
AjK 0:eb2522b41db8 102 * }
AjK 0:eb2522b41db8 103 * }
AjK 0:eb2522b41db8 104 * @endcode
AjK 0:eb2522b41db8 105 */
AjK 0:eb2522b41db8 106 class MODSERIAL : public Serial
AjK 0:eb2522b41db8 107 {
AjK 0:eb2522b41db8 108 public:
AjK 0:eb2522b41db8 109
AjK 0:eb2522b41db8 110 //! A copy of the Serial parity enum
AjK 0:eb2522b41db8 111 /** @see http://mbed.org/projects/libraries/api/mbed/trunk/Serial#Serial.format */
AjK 0:eb2522b41db8 112 enum Parity {
AjK 0:eb2522b41db8 113 None = 0
AjK 0:eb2522b41db8 114 , Odd
AjK 0:eb2522b41db8 115 , Even
AjK 0:eb2522b41db8 116 , Forced1
AjK 0:eb2522b41db8 117 , Forced0
AjK 0:eb2522b41db8 118 };
AjK 0:eb2522b41db8 119
AjK 0:eb2522b41db8 120 //! A copy of the Serial IrqType enum
AjK 0:eb2522b41db8 121 enum IrqType {
AjK 0:eb2522b41db8 122 RxIrq = 0
AjK 0:eb2522b41db8 123 , TxIrq
AjK 0:eb2522b41db8 124 , RxOvIrq
AjK 0:eb2522b41db8 125 , TxOvIrq
AjK 0:eb2522b41db8 126 , TxEmpty
AjK 0:eb2522b41db8 127 };
AjK 0:eb2522b41db8 128
AjK 0:eb2522b41db8 129 //! Non-blocking functions return code.
AjK 0:eb2522b41db8 130 enum Result {
AjK 0:eb2522b41db8 131 Ok = 0 /*!< Ok. */
AjK 0:eb2522b41db8 132 , NoMemory = -1 /*!< Memory allocation failed. */
AjK 0:eb2522b41db8 133 , NoChar = -1 /*!< No character in buffer. */
AjK 0:eb2522b41db8 134 , BufferOversize = -2 /*!< Oversized buffer. */
AjK 0:eb2522b41db8 135 };
AjK 0:eb2522b41db8 136
AjK 2:b936b4acbd92 137 //! DMA channels.
AjK 2:b936b4acbd92 138 enum dmaChannel {
AjK 2:b936b4acbd92 139 NotInUse = -1 /*!< DMA not in use */
AjK 3:0f10f536456e 140 , Channel0 = 0 /*!< Channel 0 */
AjK 2:b936b4acbd92 141 , Channel1 /*!< Channel 1 */
AjK 2:b936b4acbd92 142 , Channel2 /*!< Channel 2 */
AjK 2:b936b4acbd92 143 , Channel3 /*!< Channel 3 */
AjK 2:b936b4acbd92 144 , Channel4 /*!< Channel 4 */
AjK 2:b936b4acbd92 145 , Channel5 /*!< Channel 5 */
AjK 2:b936b4acbd92 146 , Channel6 /*!< Channel 6 */
AjK 2:b936b4acbd92 147 , Channel7 /*!< Channel 7 */
AjK 2:b936b4acbd92 148 };
AjK 2:b936b4acbd92 149
AjK 0:eb2522b41db8 150 /**
AjK 0:eb2522b41db8 151 * The MODSERIAL constructor is used to initialise the serial object.
AjK 0:eb2522b41db8 152 *
AjK 0:eb2522b41db8 153 * @param tx PinName of the TX pin.
AjK 0:eb2522b41db8 154 * @param rx PinName of the TX pin.
AjK 0:eb2522b41db8 155 * @param name An option name for RPC usage.
AjK 0:eb2522b41db8 156 */
AjK 0:eb2522b41db8 157 MODSERIAL(PinName tx, PinName rx, const char *name = NULL);
AjK 0:eb2522b41db8 158
AjK 0:eb2522b41db8 159 /**
AjK 0:eb2522b41db8 160 * The MODSERIAL constructor is used to initialise the serial object.
AjK 0:eb2522b41db8 161 *
AjK 0:eb2522b41db8 162 * @param tx PinName of the TX pin.
AjK 0:eb2522b41db8 163 * @param rx PinName of the TX pin.
AjK 0:eb2522b41db8 164 * @param bufferSize Integer of the TX and RX buffer sizes.
AjK 0:eb2522b41db8 165 * @param name An option name for RPC usage.
AjK 0:eb2522b41db8 166 */
AjK 0:eb2522b41db8 167 MODSERIAL(PinName tx, PinName rx, int bufferSize, const char *name = NULL);
AjK 0:eb2522b41db8 168
AjK 0:eb2522b41db8 169 /**
AjK 0:eb2522b41db8 170 * The MODSERIAL constructor is used to initialise the serial object.
AjK 0:eb2522b41db8 171 *
AjK 0:eb2522b41db8 172 * @param tx PinName of the TX pin.
AjK 0:eb2522b41db8 173 * @param rx PinName of the TX pin.
AjK 0:eb2522b41db8 174 * @param txBufferSize Integer of the TX buffer sizes.
AjK 0:eb2522b41db8 175 * @param rxBufferSize Integer of the RX buffer sizes.
AjK 0:eb2522b41db8 176 * @param name An option name for RPC usage.
AjK 0:eb2522b41db8 177 */
AjK 0:eb2522b41db8 178 MODSERIAL(PinName tx, PinName rx, int txBufferSize, int rxBufferSize, const char *name = NULL);
AjK 0:eb2522b41db8 179
AjK 0:eb2522b41db8 180 virtual ~MODSERIAL();
AjK 0:eb2522b41db8 181
AjK 0:eb2522b41db8 182 /**
AjK 0:eb2522b41db8 183 * Function: attach
AjK 0:eb2522b41db8 184 *
AjK 0:eb2522b41db8 185 * The Mbed standard <a href="/handbook/Serial">Serial</a> library object allows an interrupt callback
AjK 0:eb2522b41db8 186 * to be made when a byte is received by the TX or RX UART hardware. MODSERIAL traps these interrupts
AjK 1:b7e435fbfe8e 187 * to enable it's buffering system. However, after the byte has been received/sent under interrupt control,
AjK 0:eb2522b41db8 188 * MODSERIAL can callback a user function as a notification of the interrupt. Note, user code should not
AjK 1:b7e435fbfe8e 189 * directly interact with the Uart hardware, MODSERIAL does that, instead, MODSERIAL API functions should
AjK 0:eb2522b41db8 190 * be used.
AjK 0:eb2522b41db8 191 *
AjK 0:eb2522b41db8 192 * <b>Note</b>, a character is written out then, if there is room in the TX FIFO and the TX buffer is empty,
AjK 0:eb2522b41db8 193 * putc() will put the character directly into THR (the output holding register). If the TX FIFO is full and
AjK 0:eb2522b41db8 194 * cannot accept the character, it is placed into the TX output buffer. The TX interrupts are then enabled
AjK 1:b7e435fbfe8e 195 * so that when the TX FIFO empties, the TX buffer is then transferred to the THR FIFO. The TxIrq will ONLY
AjK 0:eb2522b41db8 196 * be activated when this transfer of a character from BUFFER to THR FIFO takes place. If your character
AjK 0:eb2522b41db8 197 * throughput is not high bandwidth, then the 16 byte TX FIFO may be enough and the TX output buffer may
AjK 0:eb2522b41db8 198 * never come into play.
AjK 0:eb2522b41db8 199 *
AjK 0:eb2522b41db8 200 * @code
AjK 0:eb2522b41db8 201 * #include "mbed.h"
AjK 0:eb2522b41db8 202 * #include "MODSERIAL.h"
AjK 0:eb2522b41db8 203 *
AjK 0:eb2522b41db8 204 * DigitalOut led1(LED1);
AjK 0:eb2522b41db8 205 * DigitalOut led2(LED2);
AjK 0:eb2522b41db8 206 * DigitalOut led3(LED3);
AjK 0:eb2522b41db8 207 *
AjK 0:eb2522b41db8 208 * // To test, connect p9 to p10 as a loopback.
AjK 0:eb2522b41db8 209 * MODSERIAL pc(p9, p10);
AjK 0:eb2522b41db8 210 *
AjK 0:eb2522b41db8 211 * // This function is called when a character goes into the TX buffer.
AjK 0:eb2522b41db8 212 * void txCallback(void) {
AjK 0:eb2522b41db8 213 * led2 = !led2;
AjK 0:eb2522b41db8 214 * }
AjK 0:eb2522b41db8 215 *
AjK 0:eb2522b41db8 216 * // This function is called when a character goes into the RX buffer.
AjK 0:eb2522b41db8 217 * void rxCallback(void) {
AjK 0:eb2522b41db8 218 * led3 = !led3;
AjK 0:eb2522b41db8 219 * }
AjK 0:eb2522b41db8 220 *
AjK 0:eb2522b41db8 221 * int main() {
AjK 0:eb2522b41db8 222 * pc.baud(115200);
AjK 0:eb2522b41db8 223 * pc.attach(&txCallback, MODSERIAL::TxIrq);
AjK 0:eb2522b41db8 224 * pc.attach(&rxCallback, MODSERIAL::RxIrq);
AjK 0:eb2522b41db8 225 *
AjK 0:eb2522b41db8 226 * while(1) {
AjK 0:eb2522b41db8 227 * led1 = !led1;
AjK 0:eb2522b41db8 228 * wait(0.5);
AjK 0:eb2522b41db8 229 * pc.putc('A');
AjK 0:eb2522b41db8 230 * wait(0.5);
AjK 0:eb2522b41db8 231 * }
AjK 0:eb2522b41db8 232 * ]
AjK 0:eb2522b41db8 233 * @endcode
AjK 0:eb2522b41db8 234 *
AjK 0:eb2522b41db8 235 * @ingroup API
AjK 0:eb2522b41db8 236 * @param fptr A pointer to a void function, or 0 to set as none
AjK 0:eb2522b41db8 237 * @param type Which serial interrupt to attach the member function to (Seriall::RxIrq for receive, TxIrq for transmit buffer empty)
AjK 0:eb2522b41db8 238 */
AjK 0:eb2522b41db8 239 void attach(void (*fptr)(void), IrqType type = RxIrq) { _isr[type].attach(fptr); }
AjK 0:eb2522b41db8 240
AjK 0:eb2522b41db8 241 /**
AjK 0:eb2522b41db8 242 * Function: attach
AjK 0:eb2522b41db8 243 *
AjK 0:eb2522b41db8 244 * The Mbed standard <a href="/handbook/Serial">Serial</a> library object allows an interrupt callback
AjK 0:eb2522b41db8 245 * to be made when a byte is received by the TX or RX UART hardware. MODSERIAL traps these interrupts
AjK 1:b7e435fbfe8e 246 * to enable it's buffering system. However, after the byte has been received/sent under interrupt control,
AjK 0:eb2522b41db8 247 * MODSERIAL can callback a user function as a notification of the interrupt. Note, user code should not
AjK 1:b7e435fbfe8e 248 * directly interact with the Uart hardware, MODSERIAL does that, instead, MODSERIAL API functions should
AjK 0:eb2522b41db8 249 * be used.
AjK 0:eb2522b41db8 250 *
AjK 0:eb2522b41db8 251 * <b>Note</b>, a character is written out then, if there is room in the TX FIFO and the TX buffer is empty,
AjK 0:eb2522b41db8 252 * putc() will put the character directly into THR (the output holding register). If the TX FIFO is full and
AjK 0:eb2522b41db8 253 * cannot accept the character, it is placed into the TX output buffer. The TX interrupts are then enabled
AjK 1:b7e435fbfe8e 254 * so that when the TX FIFO empties, the TX buffer is then transferred to the THR FIFO. The TxIrq will ONLY
AjK 0:eb2522b41db8 255 * be activated when this transfer of a character from BUFFER to THR FIFO takes place. If your character
AjK 0:eb2522b41db8 256 * throughput is not high bandwidth, then the 16 byte TX FIFO may be enough and the TX output buffer may
AjK 0:eb2522b41db8 257 * never come into play.
AjK 0:eb2522b41db8 258 *
AjK 0:eb2522b41db8 259 * @code
AjK 0:eb2522b41db8 260 * #include "mbed.h"
AjK 0:eb2522b41db8 261 * #include "MODSERIAL.h"
AjK 0:eb2522b41db8 262 *
AjK 0:eb2522b41db8 263 * DigitalOut led1(LED1);
AjK 0:eb2522b41db8 264 * DigitalOut led2(LED2);
AjK 0:eb2522b41db8 265 * DigitalOut led3(LED3);
AjK 0:eb2522b41db8 266 *
AjK 0:eb2522b41db8 267 * // To test, connect p9 to p10 as a loopback.
AjK 0:eb2522b41db8 268 * MODSERIAL pc(p9, p10);
AjK 0:eb2522b41db8 269 *
AjK 0:eb2522b41db8 270 * class Foo {
AjK 0:eb2522b41db8 271 * public:
AjK 0:eb2522b41db8 272 * // This method is called when a character goes into the TX buffer.
AjK 0:eb2522b41db8 273 * void txCallback(void) { led2 = !led2; }
AjK 0:eb2522b41db8 274 *
AjK 0:eb2522b41db8 275 * // This method is called when a character goes into the RX buffer.
AjK 0:eb2522b41db8 276 * void rxCallback(void) { led3 = !led3; }
AjK 0:eb2522b41db8 277 * };
AjK 0:eb2522b41db8 278 *
AjK 0:eb2522b41db8 279 * Foo foo;
AjK 0:eb2522b41db8 280 *
AjK 0:eb2522b41db8 281 * int main() {
AjK 0:eb2522b41db8 282 * pc.baud(115200);
AjK 0:eb2522b41db8 283 * pc.attach(&foo, &Foo::txCallback, MODSERIAL::TxIrq);
AjK 0:eb2522b41db8 284 * pc.attach(&foo, &Foo::rxCallback, MODSERIAL::RxIrq);
AjK 0:eb2522b41db8 285 *
AjK 0:eb2522b41db8 286 * while(1) {
AjK 0:eb2522b41db8 287 * led1 = !led1;
AjK 0:eb2522b41db8 288 * wait(0.5);
AjK 0:eb2522b41db8 289 * pc.putc('A');
AjK 0:eb2522b41db8 290 * wait(0.5);
AjK 0:eb2522b41db8 291 * }
AjK 0:eb2522b41db8 292 * ]
AjK 0:eb2522b41db8 293 * @endcode
AjK 0:eb2522b41db8 294 *
AjK 0:eb2522b41db8 295 * @ingroup API
AjK 0:eb2522b41db8 296 * @param tptr A pointer to the object to call the member function on
AjK 0:eb2522b41db8 297 * @param mptr A pointer to the member function to be called
AjK 0:eb2522b41db8 298 * @param type Which serial interrupt to attach the member function to (Seriall::RxIrq for receive, TxIrq for transmit buffer empty)
AjK 0:eb2522b41db8 299 */
AjK 0:eb2522b41db8 300 template<typename T>
AjK 0:eb2522b41db8 301 void attach(T* tptr, void (T::*mptr)(void), IrqType type = RxIrq) {
AjK 0:eb2522b41db8 302 if((mptr != NULL) && (tptr != NULL)) {
AjK 0:eb2522b41db8 303 _isr[type].attach(tptr, mptr);
AjK 0:eb2522b41db8 304 }
AjK 0:eb2522b41db8 305 }
AjK 0:eb2522b41db8 306
AjK 0:eb2522b41db8 307 /**
AjK 0:eb2522b41db8 308 * @see attach
AjK 0:eb2522b41db8 309 * @ingroup API
AjK 0:eb2522b41db8 310 */
AjK 0:eb2522b41db8 311 void connect(void (*fptr)(void), IrqType type = RxIrq) { _isr[RxIrq].attach(fptr); }
AjK 0:eb2522b41db8 312
AjK 0:eb2522b41db8 313 /**
AjK 0:eb2522b41db8 314 * @see attach
AjK 0:eb2522b41db8 315 * @ingroup API
AjK 0:eb2522b41db8 316 */
AjK 0:eb2522b41db8 317 template<typename T>
AjK 0:eb2522b41db8 318 void connect(T* tptr, void (T::*mptr)(void), IrqType type = RxIrq) {
AjK 0:eb2522b41db8 319 if((mptr != NULL) && (tptr != NULL)) {
AjK 0:eb2522b41db8 320 _isr[type].attach(tptr, mptr);
AjK 0:eb2522b41db8 321 }
AjK 0:eb2522b41db8 322 }
AjK 0:eb2522b41db8 323
AjK 0:eb2522b41db8 324 /**
AjK 0:eb2522b41db8 325 * Function: writeable
AjK 0:eb2522b41db8 326 *
AjK 0:eb2522b41db8 327 * Determine if there is space available to write a byte
AjK 0:eb2522b41db8 328 *
AjK 0:eb2522b41db8 329 * @ingroup API
AjK 0:eb2522b41db8 330 * @return 1 if there is space to write a character, else 0
AjK 0:eb2522b41db8 331 */
AjK 0:eb2522b41db8 332 int writeable() { return txBufferFull() ? 0 : 1; }
AjK 0:eb2522b41db8 333
AjK 0:eb2522b41db8 334 /**
AjK 0:eb2522b41db8 335 * Function: readable
AjK 0:eb2522b41db8 336 *
AjK 0:eb2522b41db8 337 * Determine if there is a byte available to read
AjK 0:eb2522b41db8 338 *
AjK 0:eb2522b41db8 339 * @ingroup API
AjK 0:eb2522b41db8 340 * @return 1 if there is a character available to read, else 0
AjK 0:eb2522b41db8 341 */
AjK 0:eb2522b41db8 342 int readable() { return rxBufferEmpty() ? 0 : 1; }
AjK 0:eb2522b41db8 343
AjK 0:eb2522b41db8 344 /**
AjK 0:eb2522b41db8 345 * Function: txBufferSane
AjK 0:eb2522b41db8 346 *
AjK 0:eb2522b41db8 347 * Determine if the TX buffer has been initialized.
AjK 0:eb2522b41db8 348 *
AjK 0:eb2522b41db8 349 * @ingroup API
AjK 0:eb2522b41db8 350 * @return true if the buffer is initialized, else false
AjK 0:eb2522b41db8 351 */
AjK 0:eb2522b41db8 352 bool txBufferSane(void) { return buffer[TxIrq] != (char *)NULL ? true : false; }
AjK 0:eb2522b41db8 353
AjK 0:eb2522b41db8 354 /**
AjK 0:eb2522b41db8 355 * Function: rxBufferSane
AjK 0:eb2522b41db8 356 *
AjK 0:eb2522b41db8 357 * Determine if the RX buffer has been initialized.
AjK 0:eb2522b41db8 358 *
AjK 0:eb2522b41db8 359 * @ingroup API
AjK 0:eb2522b41db8 360 * @return true if the buffer is initialized, else false
AjK 0:eb2522b41db8 361 */
AjK 0:eb2522b41db8 362 bool rxBufferSane(void) { return buffer[TxIrq] != (char *)NULL ? true : false; }
AjK 0:eb2522b41db8 363
AjK 0:eb2522b41db8 364 /**
AjK 0:eb2522b41db8 365 * Function: txBufferGetCount
AjK 0:eb2522b41db8 366 *
AjK 0:eb2522b41db8 367 * Returns how many bytes are in the TX buffer
AjK 0:eb2522b41db8 368 *
AjK 0:eb2522b41db8 369 * @ingroup API
AjK 0:eb2522b41db8 370 * @return The number of bytes in the TX buffer
AjK 0:eb2522b41db8 371 */
AjK 0:eb2522b41db8 372 int txBufferGetCount(void) { return buffer_count[TxIrq]; }
AjK 0:eb2522b41db8 373
AjK 0:eb2522b41db8 374 /**
AjK 0:eb2522b41db8 375 * Function: rxBufferGetCount
AjK 0:eb2522b41db8 376 *
AjK 0:eb2522b41db8 377 * Returns how many bytes are in the RX buffer
AjK 0:eb2522b41db8 378 *
AjK 0:eb2522b41db8 379 * @ingroup API
AjK 0:eb2522b41db8 380 * @return The number of bytes in the RX buffer
AjK 0:eb2522b41db8 381 */
AjK 0:eb2522b41db8 382 int rxBufferGetCount(void) { return buffer_count[RxIrq]; }
AjK 0:eb2522b41db8 383
AjK 0:eb2522b41db8 384 /**
AjK 0:eb2522b41db8 385 * Function: txBufferGetSize
AjK 0:eb2522b41db8 386 *
AjK 0:eb2522b41db8 387 * Returns the current size of the TX buffer
AjK 0:eb2522b41db8 388 *
AjK 0:eb2522b41db8 389 * @ingroup API
AjK 0:eb2522b41db8 390 * @return The length iof the TX buffer in bytes
AjK 0:eb2522b41db8 391 */
AjK 0:eb2522b41db8 392 int txBufferGetSize(int size) { return buffer_size[TxIrq]; }
AjK 0:eb2522b41db8 393
AjK 0:eb2522b41db8 394 /**
AjK 0:eb2522b41db8 395 * Function: rxBufferGetSize
AjK 0:eb2522b41db8 396 *
AjK 0:eb2522b41db8 397 * Returns the current size of the RX buffer
AjK 0:eb2522b41db8 398 *
AjK 0:eb2522b41db8 399 * @ingroup API
AjK 0:eb2522b41db8 400 * @return The length iof the RX buffer in bytes
AjK 0:eb2522b41db8 401 */
AjK 0:eb2522b41db8 402 int rxBufferGetSize(int size) { return buffer_size[RxIrq]; }
AjK 0:eb2522b41db8 403
AjK 0:eb2522b41db8 404 /**
AjK 0:eb2522b41db8 405 * Function: txBufferFull
AjK 0:eb2522b41db8 406 *
AjK 0:eb2522b41db8 407 * Is the TX buffer full?
AjK 0:eb2522b41db8 408 *
AjK 0:eb2522b41db8 409 * @ingroup API
AjK 0:eb2522b41db8 410 * @return true if the TX buffer is full, otherwise false
AjK 0:eb2522b41db8 411 */
AjK 0:eb2522b41db8 412 bool txBufferFull(void);
AjK 0:eb2522b41db8 413
AjK 0:eb2522b41db8 414 /**
AjK 0:eb2522b41db8 415 * Function: rxBufferFull
AjK 0:eb2522b41db8 416 *
AjK 0:eb2522b41db8 417 * Is the RX buffer full?
AjK 0:eb2522b41db8 418 *
AjK 0:eb2522b41db8 419 * @ingroup API
AjK 0:eb2522b41db8 420 * @return true if the RX buffer is full, otherwise false
AjK 0:eb2522b41db8 421 */
AjK 0:eb2522b41db8 422 bool rxBufferFull(void);
AjK 0:eb2522b41db8 423
AjK 0:eb2522b41db8 424 /**
AjK 0:eb2522b41db8 425 * Function: txBufferEmpty
AjK 0:eb2522b41db8 426 *
AjK 0:eb2522b41db8 427 * Is the TX buffer empty?
AjK 0:eb2522b41db8 428 *
AjK 0:eb2522b41db8 429 * @ingroup API
AjK 0:eb2522b41db8 430 * @return true if the TX buffer is empty, otherwise false
AjK 0:eb2522b41db8 431 */
AjK 0:eb2522b41db8 432 bool txBufferEmpty(void);
AjK 0:eb2522b41db8 433
AjK 0:eb2522b41db8 434 /**
AjK 0:eb2522b41db8 435 * Function: rxBufferEmpty
AjK 0:eb2522b41db8 436 *
AjK 0:eb2522b41db8 437 * Is the RX buffer empty?
AjK 0:eb2522b41db8 438 *
AjK 0:eb2522b41db8 439 * @ingroup API
AjK 0:eb2522b41db8 440 * @return true if the RX buffer is empty, otherwise false
AjK 0:eb2522b41db8 441 */
AjK 0:eb2522b41db8 442 bool rxBufferEmpty(void);
AjK 0:eb2522b41db8 443
AjK 0:eb2522b41db8 444 /**
AjK 0:eb2522b41db8 445 * Function: txBufferSetSize
AjK 0:eb2522b41db8 446 *
AjK 0:eb2522b41db8 447 * Change the TX buffer size.
AjK 0:eb2522b41db8 448 *
AjK 0:eb2522b41db8 449 * @see Result
AjK 0:eb2522b41db8 450 * @ingroup API
AjK 0:eb2522b41db8 451 * @param size The new TX buffer size in bytes.
AjK 0:eb2522b41db8 452 * @param m Perform a memory sanity check. Errs the Mbed if memory alloc fails.
AjK 0:eb2522b41db8 453 * @return Result Ok on success.
AjK 0:eb2522b41db8 454 */
AjK 0:eb2522b41db8 455 int txBufferSetSize(int size, bool m) { return resizeBuffer(size, TxIrq, m); }
AjK 0:eb2522b41db8 456
AjK 0:eb2522b41db8 457 /**
AjK 0:eb2522b41db8 458 * Function: rxBufferSetSize
AjK 0:eb2522b41db8 459 *
AjK 0:eb2522b41db8 460 * Change the RX buffer size.
AjK 0:eb2522b41db8 461 *
AjK 0:eb2522b41db8 462 * @see Result
AjK 0:eb2522b41db8 463 * @ingroup API
AjK 0:eb2522b41db8 464 * @param size The new RX buffer size in bytes.
AjK 0:eb2522b41db8 465 * @param m Perform a memory sanity check. Errs the Mbed if memory alloc fails.
AjK 0:eb2522b41db8 466 * @return Result Ok on success.
AjK 0:eb2522b41db8 467 */
AjK 0:eb2522b41db8 468 int rxBufferSetSize(int size, bool m) { return resizeBuffer(size, RxIrq, m); }
AjK 0:eb2522b41db8 469
AjK 0:eb2522b41db8 470 /**
AjK 0:eb2522b41db8 471 * Function: txBufferSetSize
AjK 0:eb2522b41db8 472 *
AjK 0:eb2522b41db8 473 * Change the TX buffer size.
AjK 0:eb2522b41db8 474 * Always performs a memory sanity check, halting the Mbed on failure.
AjK 0:eb2522b41db8 475 *
AjK 0:eb2522b41db8 476 * @see Result
AjK 0:eb2522b41db8 477 * @ingroup API
AjK 0:eb2522b41db8 478 * @param size The new TX buffer size in bytes.
AjK 0:eb2522b41db8 479 * @return Result Ok on success.
AjK 0:eb2522b41db8 480 */
AjK 0:eb2522b41db8 481 int txBufferSetSize(int size) { return resizeBuffer(size, TxIrq, true); }
AjK 0:eb2522b41db8 482
AjK 0:eb2522b41db8 483 /**
AjK 0:eb2522b41db8 484 * Function: rxBufferSetSize
AjK 0:eb2522b41db8 485 *
AjK 0:eb2522b41db8 486 * Change the RX buffer size.
AjK 0:eb2522b41db8 487 * Always performs a memory sanity check, halting the Mbed on failure.
AjK 0:eb2522b41db8 488 *
AjK 0:eb2522b41db8 489 * @see Result
AjK 0:eb2522b41db8 490 * @ingroup API
AjK 0:eb2522b41db8 491 * @param size The new RX buffer size in bytes.
AjK 0:eb2522b41db8 492 * @return Result Ok on success.
AjK 0:eb2522b41db8 493 */
AjK 0:eb2522b41db8 494 int rxBufferSetSize(int size) { return resizeBuffer(size, RxIrq, true); }
AjK 0:eb2522b41db8 495
AjK 0:eb2522b41db8 496 /**
AjK 0:eb2522b41db8 497 * Function: txBufferFlush
AjK 0:eb2522b41db8 498 *
AjK 0:eb2522b41db8 499 * Remove all bytes from the TX buffer.
AjK 0:eb2522b41db8 500 * @ingroup API
AjK 0:eb2522b41db8 501 */
AjK 0:eb2522b41db8 502 void txBufferFlush(void) { flushBuffer(TxIrq); }
AjK 0:eb2522b41db8 503
AjK 0:eb2522b41db8 504 /**
AjK 0:eb2522b41db8 505 * Function: rxBufferFlush
AjK 0:eb2522b41db8 506 *
AjK 0:eb2522b41db8 507 * Remove all bytes from the RX buffer.
AjK 0:eb2522b41db8 508 * @ingroup API
AjK 0:eb2522b41db8 509 */
AjK 0:eb2522b41db8 510 void rxBufferFlush(void) { flushBuffer(RxIrq); }
AjK 0:eb2522b41db8 511
AjK 0:eb2522b41db8 512 /**
AjK 3:0f10f536456e 513 * Function: dmaSend
AjK 3:0f10f536456e 514 *
AjK 3:0f10f536456e 515 * Remove all bytes from the RX buffer.
AjK 3:0f10f536456e 516 * @ingroup API
AjK 3:0f10f536456e 517 */
AjK 3:0f10f536456e 518 int dmaSend(char *buffer, int length, dmaChannel q = Channel7);
AjK 3:0f10f536456e 519
AjK 3:0f10f536456e 520 /**
AjK 0:eb2522b41db8 521 * Function: getcNb
AjK 0:eb2522b41db8 522 *
AjK 0:eb2522b41db8 523 * Like getc() but is non-blocking. If no bytes are in the RX buffer this
AjK 0:eb2522b41db8 524 * function returns Result::NoChar (-1)
AjK 0:eb2522b41db8 525 *
AjK 0:eb2522b41db8 526 * @ingroup API
AjK 0:eb2522b41db8 527 * @return A byte from the RX buffer or Result::NoChar (-1) if bufer empty.
AjK 0:eb2522b41db8 528 */
AjK 0:eb2522b41db8 529 int getcNb() { return __getc(false); }
AjK 0:eb2522b41db8 530
AjK 0:eb2522b41db8 531 /**
AjK 0:eb2522b41db8 532 * Function: getc
AjK 0:eb2522b41db8 533 *
AjK 0:eb2522b41db8 534 * Overloaded version of Serial::getc()
AjK 0:eb2522b41db8 535 *
AjK 0:eb2522b41db8 536 * This function blocks (if the RX buffer is empty the function will wait for a
AjK 0:eb2522b41db8 537 * character to arrive and then return that character).
AjK 0:eb2522b41db8 538 *
AjK 0:eb2522b41db8 539 * @ingroup API
AjK 0:eb2522b41db8 540 * @return A byte from the RX buffer
AjK 0:eb2522b41db8 541 */
AjK 0:eb2522b41db8 542 int getc() { return __getc(true); }
AjK 0:eb2522b41db8 543
AjK 0:eb2522b41db8 544 /**
AjK 0:eb2522b41db8 545 * Function: txGetLastChar
AjK 0:eb2522b41db8 546 *
AjK 1:b7e435fbfe8e 547 * Rteurn the last byte to pass through the TX interrupt handler.
AjK 0:eb2522b41db8 548 *
AjK 0:eb2522b41db8 549 * @ingroup MISC
AjK 0:eb2522b41db8 550 * @return The byte
AjK 0:eb2522b41db8 551 */
AjK 0:eb2522b41db8 552 char txGetLastChar(void) { return txc; }
AjK 0:eb2522b41db8 553
AjK 0:eb2522b41db8 554 /**
AjK 0:eb2522b41db8 555 * Function: rxGetLastChar
AjK 0:eb2522b41db8 556 *
AjK 0:eb2522b41db8 557 * Return the last byte to pass through the RX interrupt handler.
AjK 0:eb2522b41db8 558 *
AjK 0:eb2522b41db8 559 * @ingroup MISC
AjK 0:eb2522b41db8 560 * @return The byte
AjK 0:eb2522b41db8 561 */
AjK 0:eb2522b41db8 562 char rxGetLastChar(void) { return rxc; }
AjK 0:eb2522b41db8 563
AjK 0:eb2522b41db8 564 /**
AjK 0:eb2522b41db8 565 * Function: txIsBusy
AjK 0:eb2522b41db8 566 *
AjK 1:b7e435fbfe8e 567 * If the Uart is still actively sending characters this
AjK 0:eb2522b41db8 568 * function will return true.
AjK 0:eb2522b41db8 569 *
AjK 0:eb2522b41db8 570 * @ingroup API
AjK 0:eb2522b41db8 571 * @return bool
AjK 0:eb2522b41db8 572 */
AjK 2:b936b4acbd92 573 bool txIsBusy(void);
AjK 0:eb2522b41db8 574
AjK 0:eb2522b41db8 575 #if 0 // Inhereted from Serial/Stream, for documentation only
AjK 0:eb2522b41db8 576 /**
AjK 0:eb2522b41db8 577 * Function: putc
AjK 0:eb2522b41db8 578 *
AjK 0:eb2522b41db8 579 * Write a character
AjK 0:eb2522b41db8 580 * Inhereted from Serial/Stream
AjK 0:eb2522b41db8 581 *
AjK 0:eb2522b41db8 582 * @see http://mbed.org/projects/libraries/api/mbed/trunk/Serial#Serial.putc
AjK 0:eb2522b41db8 583 * @ingroup API
AjK 0:eb2522b41db8 584 * @param c The character to write to the serial port
AjK 0:eb2522b41db8 585 */
AjK 0:eb2522b41db8 586 int putc(int c);
AjK 0:eb2522b41db8 587 #endif
AjK 0:eb2522b41db8 588
AjK 0:eb2522b41db8 589 #if 0 // Inhereted from Serial/Stream, for documentation only
AjK 0:eb2522b41db8 590 /**
AjK 0:eb2522b41db8 591 * Function: printf
AjK 0:eb2522b41db8 592 *
AjK 0:eb2522b41db8 593 * Write a formated string
AjK 0:eb2522b41db8 594 * Inhereted from Serial/Stream
AjK 0:eb2522b41db8 595 *
AjK 0:eb2522b41db8 596 * @see http://mbed.org/projects/libraries/api/mbed/trunk/Serial#Serial.printf
AjK 0:eb2522b41db8 597 * @ingroup API
AjK 0:eb2522b41db8 598 * @param format A printf-style format string, followed by the variables to use in formating the string.
AjK 0:eb2522b41db8 599 */
AjK 0:eb2522b41db8 600 int printf(const char* format, ...);
AjK 0:eb2522b41db8 601 #endif
AjK 0:eb2522b41db8 602
AjK 0:eb2522b41db8 603 #if 0 // Inhereted from Serial/Stream, for documentation only
AjK 0:eb2522b41db8 604 /**
AjK 0:eb2522b41db8 605 * Function: scanf
AjK 0:eb2522b41db8 606 *
AjK 0:eb2522b41db8 607 * Read a formated string
AjK 0:eb2522b41db8 608 * Inhereted from Serial/Stream
AjK 0:eb2522b41db8 609 *
AjK 0:eb2522b41db8 610 * @see http://mbed.org/projects/libraries/api/mbed/trunk/Serial#Serial.scanf
AjK 0:eb2522b41db8 611 * @ingroup API
AjK 0:eb2522b41db8 612 * @param format - A scanf-style format string, followed by the pointers to variables to store the results.
AjK 0:eb2522b41db8 613 */
AjK 0:eb2522b41db8 614 int scanf(const char* format, ...);
AjK 0:eb2522b41db8 615 #endif
AjK 4:28de979b77cf 616
AjK 0:eb2522b41db8 617 protected:
AjK 0:eb2522b41db8 618
AjK 0:eb2522b41db8 619 /**
AjK 0:eb2522b41db8 620 * A pointer to the UART peripheral base address being used.
AjK 0:eb2522b41db8 621 * @ingroup INTERNALS
AjK 0:eb2522b41db8 622 */
AjK 0:eb2522b41db8 623 void *_base;
AjK 0:eb2522b41db8 624
AjK 0:eb2522b41db8 625 /**
AjK 0:eb2522b41db8 626 * The last byte to pass through the TX IRQ handler.
AjK 0:eb2522b41db8 627 * @ingroup INTERNALS
AjK 0:eb2522b41db8 628 */
AjK 0:eb2522b41db8 629 volatile char txc;
AjK 0:eb2522b41db8 630
AjK 0:eb2522b41db8 631 /**
AjK 0:eb2522b41db8 632 * The last byte to pass through the RX IRQ handler.
AjK 0:eb2522b41db8 633 * @ingroup INTERNALS
AjK 0:eb2522b41db8 634 */
AjK 0:eb2522b41db8 635 volatile char rxc;
AjK 0:eb2522b41db8 636
AjK 0:eb2522b41db8 637 /**
AjK 1:b7e435fbfe8e 638 * Pointers to the TX and RX buffers.
AjK 0:eb2522b41db8 639 * @ingroup INTERNALS
AjK 0:eb2522b41db8 640 */
AjK 0:eb2522b41db8 641 volatile char *buffer[2];
AjK 0:eb2522b41db8 642
AjK 0:eb2522b41db8 643 /**
AjK 0:eb2522b41db8 644 * Buffer in pointers.
AjK 0:eb2522b41db8 645 * @ingroup INTERNALS
AjK 0:eb2522b41db8 646 */
AjK 0:eb2522b41db8 647 volatile int buffer_in[2];
AjK 0:eb2522b41db8 648
AjK 0:eb2522b41db8 649 /**
AjK 0:eb2522b41db8 650 * Buffer out pointers.
AjK 0:eb2522b41db8 651 * @ingroup INTERNALS
AjK 0:eb2522b41db8 652 */
AjK 0:eb2522b41db8 653 volatile int buffer_out[2];
AjK 0:eb2522b41db8 654
AjK 0:eb2522b41db8 655 /**
AjK 0:eb2522b41db8 656 * Buffer lengths.
AjK 0:eb2522b41db8 657 * @ingroup INTERNALS
AjK 0:eb2522b41db8 658 */
AjK 0:eb2522b41db8 659 volatile int buffer_size[2];
AjK 0:eb2522b41db8 660
AjK 0:eb2522b41db8 661 /**
AjK 0:eb2522b41db8 662 * Buffer content counters.
AjK 0:eb2522b41db8 663 * @ingroup INTERNALS
AjK 0:eb2522b41db8 664 */
AjK 0:eb2522b41db8 665 volatile int buffer_count[2];
AjK 0:eb2522b41db8 666
AjK 0:eb2522b41db8 667 /**
AjK 0:eb2522b41db8 668 * Buffer overflow.
AjK 0:eb2522b41db8 669 * @ingroup INTERNALS
AjK 0:eb2522b41db8 670 */
AjK 0:eb2522b41db8 671 volatile int buffer_overflow[2];
AjK 0:eb2522b41db8 672
AjK 0:eb2522b41db8 673 /**
AjK 0:eb2522b41db8 674 * Callback system.
AjK 0:eb2522b41db8 675 * @ingroup INTERNALS
AjK 0:eb2522b41db8 676 */
AjK 0:eb2522b41db8 677 FunctionPointer _isr[5];
AjK 0:eb2522b41db8 678
AjK 0:eb2522b41db8 679 /**
AjK 0:eb2522b41db8 680 * TX Interrupt Service Routine.
AjK 0:eb2522b41db8 681 * @ingroup INTERNALS
AjK 0:eb2522b41db8 682 */
AjK 0:eb2522b41db8 683 void isr_tx(void);
AjK 0:eb2522b41db8 684
AjK 0:eb2522b41db8 685 /**
AjK 0:eb2522b41db8 686 * RX Interrupt Service Routine.
AjK 0:eb2522b41db8 687 * @ingroup INTERNALS
AjK 0:eb2522b41db8 688 */
AjK 0:eb2522b41db8 689 void isr_rx(void);
AjK 0:eb2522b41db8 690
AjK 0:eb2522b41db8 691 /**
AjK 0:eb2522b41db8 692 * Disable the interrupts for this Uart.
AjK 0:eb2522b41db8 693 * @ingroup INTERNALS
AjK 0:eb2522b41db8 694 */
AjK 0:eb2522b41db8 695 void disableIrq(void);
AjK 0:eb2522b41db8 696
AjK 0:eb2522b41db8 697 /**
AjK 0:eb2522b41db8 698 * Enable the interrupts for this Uart.
AjK 0:eb2522b41db8 699 * @ingroup INTERNALS
AjK 0:eb2522b41db8 700 */
AjK 0:eb2522b41db8 701 void enableIrq(void);
AjK 0:eb2522b41db8 702
AjK 0:eb2522b41db8 703 /**
AjK 0:eb2522b41db8 704 * Get a character from the RX buffer
AjK 0:eb2522b41db8 705 * @ingroup INTERNALS
AjK 0:eb2522b41db8 706 * @param bool True to block (wait for input)
AjK 0:eb2522b41db8 707 * @return A byte from the buffer.
AjK 0:eb2522b41db8 708 */
AjK 0:eb2522b41db8 709 int __getc(bool);
AjK 0:eb2522b41db8 710
AjK 0:eb2522b41db8 711 /**
AjK 0:eb2522b41db8 712 * Put a character from the TX buffer
AjK 0:eb2522b41db8 713 * @ingroup INTERNALS
AjK 1:b7e435fbfe8e 714 * @param bool True to block (wait for space in the TX buffer if full)
AjK 0:eb2522b41db8 715 * @return 0 on success
AjK 0:eb2522b41db8 716 */
AjK 0:eb2522b41db8 717 int __putc(int c, bool);
AjK 0:eb2522b41db8 718
AjK 0:eb2522b41db8 719 /**
AjK 0:eb2522b41db8 720 * Function: _putc
AjK 0:eb2522b41db8 721 * Overloaded virtual function.
AjK 0:eb2522b41db8 722 */
AjK 0:eb2522b41db8 723 virtual int _putc(int c) { return __putc(c, true); }
AjK 0:eb2522b41db8 724
AjK 0:eb2522b41db8 725 /**
AjK 0:eb2522b41db8 726 * Function: _getc
AjK 0:eb2522b41db8 727 * Overloaded virtual function.
AjK 0:eb2522b41db8 728 */
AjK 0:eb2522b41db8 729 virtual int _getc() { return __getc(true); }
AjK 2:b936b4acbd92 730
AjK 0:eb2522b41db8 731 /**
AjK 0:eb2522b41db8 732 * Function: init
AjK 0:eb2522b41db8 733 * Initialize the MODSERIAL object
AjK 0:eb2522b41db8 734 * @ingroup INTERNALS
AjK 0:eb2522b41db8 735 */
AjK 0:eb2522b41db8 736 void init(int txSize, int rxSize);
AjK 0:eb2522b41db8 737
AjK 0:eb2522b41db8 738 /**
AjK 0:eb2522b41db8 739 * Function: flushBuffer
AjK 0:eb2522b41db8 740 * @ingroup INTERNALS
AjK 0:eb2522b41db8 741 */
AjK 0:eb2522b41db8 742 void flushBuffer(IrqType type);
AjK 0:eb2522b41db8 743
AjK 0:eb2522b41db8 744 /**
AjK 0:eb2522b41db8 745 * Function: resizeBuffer
AjK 0:eb2522b41db8 746 * @ingroup INTERNALS
AjK 0:eb2522b41db8 747 */
AjK 0:eb2522b41db8 748 int resizeBuffer(int size, IrqType type = RxIrq, bool memory_check = true);
AjK 0:eb2522b41db8 749
AjK 0:eb2522b41db8 750 /**
AjK 0:eb2522b41db8 751 * Function: downSizeBuffer
AjK 0:eb2522b41db8 752 * @ingroup INTERNALS
AjK 0:eb2522b41db8 753 */
AjK 0:eb2522b41db8 754 int downSizeBuffer(int size, IrqType type, bool memory_check);
AjK 0:eb2522b41db8 755
AjK 0:eb2522b41db8 756 /**
AjK 0:eb2522b41db8 757 * Function: upSizeBuffer
AjK 0:eb2522b41db8 758 * @ingroup INTERNALS
AjK 0:eb2522b41db8 759 */
AjK 0:eb2522b41db8 760 int upSizeBuffer(int size, IrqType type, bool memory_check);
AjK 3:0f10f536456e 761
AjK 0:eb2522b41db8 762 };
AjK 0:eb2522b41db8 763
AjK 0:eb2522b41db8 764 }; // namespace AjK ends
AjK 0:eb2522b41db8 765
AjK 0:eb2522b41db8 766 using namespace AjK;
AjK 0:eb2522b41db8 767
AjK 0:eb2522b41db8 768 #endif