7 * \copyright Copyright (c) 2013 Infineon Technologies AG. All rights reserved.
8 *
9 *
10 * IMPORTANT NOTICE
11 *
12 *
13 * Infineon Technologies AG (Infineon) is supplying this file for use
14 * exclusively with Infineon's microcontroller products. This file can be freely
15 * distributed within development tools that are supporting such microcontroller
16 * products.
17 *
18 * THIS SOFTWARE IS PROVIDED "AS IS". NO WARRANTIES, WHETHER EXPRESS, IMPLIED
19 * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
20 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
21 * INFINEON SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
22 * OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
23 *
24 * \defgroup IfxLld_Asclin_Asc_Usage How to use the ASCLIN ASC Interface driver?
25 * \ingroup IfxLld_Asclin
26 *
27 * The ASC interface driver provides a default ASCLIN configuration for asynchronous serial communication in 8bit mode, and a set of data transfer routines.
28 *
29 * Data transfers are buffered by the hardware based FIFOs, and in addition by software based FIFOs with a configurable size. Incoming and outgoing data is transfered in background from/to the ASCLIN peripheral by interrupt service handlers, which are part of this driver as well. This allows a nonblocking communication without stalling the thread(s) from where data is sent and received.
30 *
31 * In the following sections it will be described, how to integrate the driver into the application framework.
56 * As you can see above, the transfer buffers allocate not only memory for the data itself, but also for FIFO runtime variables. 8 bytes have to be added to ensure a proper circular buffer handling independent from the address to which the buffers have been located.
144 * The ASC driver provides simple to use transfer functions, which are blocking.
145 *
146 * This means: you can send as much data as you want without taking care for the fill state of the FIFO. If the FIFO is full, the blocking function will wait until the next byte has been transfered to ASCLIN before putting the new byte into the FIFO:
147 * \code
148 * // send 3 bytes
149 * IfxAsclin_Asc_blockingWrite(&asc, 0x01);
150 * IfxAsclin_Asc_blockingWrite(&asc, 0x02);
151 * IfxAsclin_Asc_blockingWrite(&asc, 0x03);
152 * \endcode
153 *
154 * A simple to use receive function is available as well. If no data is in the receive FIFO, it will wait until the next byte has been received:
155 * \code
156 * // receive a byte
157 * uint8 data = IfxAsclin_Asc_blockingRead(&asc);
163 * Streamed transfers are handled faster by the ASC driver and therefore they are recommended whenever a large bulk of data should be sent. Here an example:
322volatilebooleantxInProgress; /**< \brief Ongoing transfer. Will be set by IfxAsclin_Asc_initiateTransmission, and cleared by IfxAsclin_Asc_isrTransmit */
323volatilebooleanrxSwFifoOverflow; /**< \brief Will be set by IfxAsclin_Asc_isrReceive if the SW Fifo overflowed */
344void *txBuffer; /**< \brief The buffer parameter must point on a free memory location where the buffer object will be Initialised.
345 *
346 * The Size of this area must be at least equals to "txBufferSize + sizeof(Fifo) + 8". Not tacking this in account may result in unpredictable behavior.
347 *
348 * If set to NULL_PTR, the buffer will be allocated dynamically according to txBufferSize */
350void *rxBuffer; /**< \brief The buffer parameter must point on a free memory location where the buffer object will be Initialised.
351 *
352 * The Size of this area must be at least equals to "rxBufferSize + sizeof(Fifo) + 8". Not tacking this in account may result in unpredictable behavior.
353 *
354 * If set to NULL, the buffer will be allocated dynamically according to rxBufferSize */
355booleanloopBack; /**< \brief IOCR.LB, loop back mode selection, 0 for disable, 1 for enable */
441 * \param count Count of data which should be checked (in bytes)
442 * \param timeout in system timer ticks
443 * \return Returns TRUE if at least count bytes are available for read in the rx buffer, if not the Event is armed to be set when the buffer count is bigger or equal to the requested count.
449 * \param count Count of data which should be checked (in bytes)
450 * \param timeout in system timer ticks
451 * \return Returns TRUE if at least count bytes can be written to the tx buffer, if not the Event is armed to be set when the buffer free count is bigger or equal to the requested count