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 USART driver, transfer data through DMA.
\r
37 #ifndef _USART_DMA_H_
\r
38 #define _USART_DMA_H_
\r
40 /*----------------------------------------------------------------------------
\r
42 *----------------------------------------------------------------------------*/
\r
46 /*----------------------------------------------------------------------------
\r
48 *----------------------------------------------------------------------------*/
\r
50 /** An unspecified error has occured.*/
\r
51 #define USARTD_ERROR 1
\r
53 /** USART driver is currently in use.*/
\r
54 #define USARTD_ERROR_LOCK 2
\r
61 /*----------------------------------------------------------------------------
\r
63 *----------------------------------------------------------------------------*/
\r
65 /** USART transfer complete callback. */
\r
66 typedef void (*UsartdCallback)( uint8_t, void* ) ;
\r
68 /** \brief usart Transfer Request prepared by the application upper layer.
\r
70 * This structure is sent to the USART_Send or USART_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 UsartdCallback callback;
\r
83 /** Callback arguments. */
\r
85 /** flag to indicate the current transfer. */
\r
86 volatile uint8_t Done;
\r
89 /** Constant structure associated with USART port. This structure prevents
\r
90 client applications to have access in the same time. */
\r
93 /** Pointer to USART Hardware registers */
\r
95 /** Current Usart Rx channel */
\r
96 UsartChannel *pRxChannel ;
\r
97 /** Current Usart Tx channel */
\r
98 UsartChannel *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 USARTD_Configure( UsartDma *pUsartd ,
\r
112 uint32_t UsartMode,
\r
116 extern uint32_t USARTD_EnableTxChannels( UsartDma *pUsartd, UsartChannel *pTxCh);
\r
118 extern uint32_t USARTD_EnableRxChannels( UsartDma *pUsartd, UsartChannel *pRxCh);
\r
120 extern uint32_t USARTD_SendData( UsartDma* pUsartd ) ;
\r
122 extern uint32_t USARTD_RcvData( UsartDma *pUsartd);
\r
128 #endif /* #ifndef _USART_DMA_ */
\r