]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M7_SAMV71_Xplained_IAR_Keil/libchip_samv7/include/uart_dma.h
Final V8.2.1 release ready for tagging:
[freertos] / FreeRTOS / Demo / CORTEX_M7_SAMV71_Xplained_IAR_Keil / libchip_samv7 / include / uart_dma.h
1 /* ----------------------------------------------------------------------------\r
2  *         ATMEL Microcontroller Software Support\r
3  * ----------------------------------------------------------------------------\r
4  * Copyright (c) 2009, Atmel Corporation\r
5  *\r
6  * All rights reserved.\r
7  *\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
10  *\r
11  * - Redistributions of source code must retain the above copyright notice,\r
12  * this list of conditions and the disclaimer below.\r
13  *\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
16  *\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
28  */\r
29 \r
30 /**\r
31  * \file\r
32  *\r
33  * Implementation of UART driver, transfer data through DMA.\r
34  *\r
35  */\r
36 \r
37 #ifndef _UART_DMA_\r
38 #define _UART_DMA_\r
39 \r
40 /*----------------------------------------------------------------------------\r
41  *        Headers\r
42  *----------------------------------------------------------------------------*/\r
43 \r
44 #include "chip.h"\r
45 \r
46 /*----------------------------------------------------------------------------\r
47  *        Definitions\r
48  *----------------------------------------------------------------------------*/\r
49 \r
50 /** An unspecified error has occured.*/\r
51 #define UARTD_ERROR          1\r
52 \r
53 /** UART driver is currently in use.*/\r
54 #define UARTD_ERROR_LOCK     2\r
55 \r
56 \r
57 #ifdef __cplusplus\r
58  extern "C" {\r
59 #endif\r
60 \r
61 /*----------------------------------------------------------------------------\r
62  *        Types\r
63  *----------------------------------------------------------------------------*/\r
64 \r
65 /** UART transfer complete callback. */\r
66 typedef void (*UartdCallback)( uint8_t, void* ) ;\r
67 \r
68 /** \brief usart Transfer Request prepared by the application upper layer.\r
69  *\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
72  */\r
73 typedef struct\r
74 {\r
75     /** Pointer to the Buffer. */\r
76     uint8_t *pBuff;\r
77     /** Buff size in bytes. */\r
78     uint8_t BuffSize;\r
79     /** Dma channel num. */\r
80     uint32_t ChNum;\r
81     /** Callback function invoked at the end of transfer. */\r
82     UartdCallback callback;\r
83     /** Callback arguments. */\r
84     void *pArgument;\r
85    /** flag to indicate the current transfer. */\r
86     volatile uint8_t sempaphore;\r
87 } UartChannel ;\r
88 \r
89 /** Constant structure associated with UART port. This structure prevents\r
90     client applications to have access in the same time. */\r
91 typedef struct \r
92 {\r
93     /** Pointer to UART Hardware registers */\r
94     Uart* pUartHw ;\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
100     sXdmad* pXdmad;\r
101     /** USART Id as defined in the product datasheet */\r
102     uint8_t uartId ;\r
103 } UartDma;\r
104 \r
105 /*----------------------------------------------------------------------------\r
106  *        Exported functions\r
107  *----------------------------------------------------------------------------*/\r
108 \r
109 extern uint32_t UARTD_Configure( UartDma *pUartd ,\r
110                                  Uart *pUartHw ,\r
111                                  uint8_t uartId,\r
112                                  uint32_t UartMode,\r
113                                  sXdmad *pXdmad );\r
114 \r
115 extern uint32_t UARTD_EnableTxChannels( UartDma *pUartd, UartChannel *pTxCh);\r
116 \r
117 extern uint32_t UARTD_EnableRxChannels( UartDma *pUartd, UartChannel *pRxCh);\r
118 \r
119 extern uint32_t UARTD_SendData( UartDma* pUartd ) ;\r
120 \r
121 extern uint32_t UARTD_RcvData( UartDma *pUartd);\r
122 \r
123 #ifdef __cplusplus\r
124 }\r
125 #endif\r
126 \r
127 #endif /* #ifndef _UART_DMA_ */\r