1 /* ----------------------------------------------------------------------------
\r
2 * ATMEL Microcontroller Software Support
\r
3 * ----------------------------------------------------------------------------
\r
4 * Copyright (c) 2009, Atmel Corporation
\r
6 * All rights reserved.
\r
8 * Redistribution and use in source and binary forms, with or without
\r
9 * modification, are permitted provided that the following conditions are met:
\r
11 * - Redistributions of source code must retain the above copyright notice,
\r
12 * this list of conditions and the disclaimer below.
\r
14 * Atmel's name may not be used to endorse or promote products derived from
\r
15 * this software without specific prior written permission.
\r
17 * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR
\r
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF
\r
19 * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE
\r
20 * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,
\r
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT
\r
22 * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,
\r
23 * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF
\r
24 * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
\r
25 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE,
\r
26 * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
\r
27 * ----------------------------------------------------------------------------
\r
33 * Implementation of UART driver, transfer data through DMA.
\r
40 /*----------------------------------------------------------------------------
\r
42 *----------------------------------------------------------------------------*/
\r
46 /*----------------------------------------------------------------------------
\r
48 *----------------------------------------------------------------------------*/
\r
50 /** An unspecified error has occured.*/
\r
51 #define UARTD_ERROR 1
\r
53 /** UART driver is currently in use.*/
\r
54 #define UARTD_ERROR_LOCK 2
\r
61 /*----------------------------------------------------------------------------
\r
63 *----------------------------------------------------------------------------*/
\r
65 /** UART transfer complete callback. */
\r
66 typedef void (*UartdCallback)( uint8_t, void* ) ;
\r
68 /** \brief usart Transfer Request prepared by the application upper layer.
\r
70 * This structure is sent to the UART_Send or UART_Rcv to start the transfer.
\r
71 * At the end of the transfer, the callback is invoked by the interrupt handler.
\r
75 /** Pointer to the Buffer. */
\r
77 /** Buff size in bytes. */
\r
79 /** Dma channel num. */
\r
81 /** Callback function invoked at the end of transfer. */
\r
82 UartdCallback callback;
\r
83 /** Callback arguments. */
\r
85 /** flag to indicate the current transfer. */
\r
86 volatile uint8_t sempaphore;
\r
89 /** Constant structure associated with UART port. This structure prevents
\r
90 client applications to have access in the same time. */
\r
93 /** Pointer to UART Hardware registers */
\r
95 /** Current Uart Rx channel */
\r
96 UartChannel *pRxChannel ;
\r
97 /** Current Uart Tx channel */
\r
98 UartChannel *pTxChannel ;
\r
99 /** Pointer to DMA driver */
\r
101 /** USART Id as defined in the product datasheet */
\r
105 /*----------------------------------------------------------------------------
\r
106 * Exported functions
\r
107 *----------------------------------------------------------------------------*/
\r
109 extern uint32_t UARTD_Configure( UartDma *pUartd ,
\r
115 extern uint32_t UARTD_EnableTxChannels( UartDma *pUartd, UartChannel *pTxCh);
\r
117 extern uint32_t UARTD_EnableRxChannels( UartDma *pUartd, UartChannel *pRxCh);
\r
119 extern uint32_t UARTD_SendData( UartDma* pUartd ) ;
\r
121 extern uint32_t UARTD_RcvData( UartDma *pUartd);
\r
127 #endif /* #ifndef _UART_DMA_ */
\r