]> git.sur5r.net Git - freertos/blob - FreeRTOS/Demo/CORTEX_M7_SAMV71_Xplained/libchip_samv7/include/afe_dma.h
Update version number ready for V8.2.1 release.
[freertos] / FreeRTOS / Demo / CORTEX_M7_SAMV71_Xplained / libchip_samv7 / include / afe_dma.h
1 /* ----------------------------------------------------------------------------\r
2  *         SAM Software Package License\r
3  * ----------------------------------------------------------------------------\r
4  * Copyright (c) 2014, 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  *  \section Purpose\r
34  *\r
35  *  Interface for configuration the Analog-to-Digital Converter (AFEC) peripheral.\r
36  *\r
37  *  \section Usage\r
38  *\r
39  *  -# Configurate the pins for AFEC.\r
40  *  -# Initialize the AFEC with AFEC_Initialize().\r
41  *  -# Set AFEC clock and timing with AFEC_SetClock() and AFEC_SetTiming().\r
42  *  -# Select the active channel using AFEC_EnableChannel().\r
43  *  -# Start the conversion with AFEC_StartConversion().\r
44  *  -# Wait the end of the conversion by polling status with AFEC_GetStatus().\r
45  *  -# Finally, get the converted data using AFEC_GetConvertedData() or AFEC_GetLastConvertedData().\r
46  *\r
47 */\r
48 #ifndef _AFE_DMA_\r
49 #define _AFE_DMA_\r
50 \r
51 /*----------------------------------------------------------------------------\r
52  *        Headers\r
53  *----------------------------------------------------------------------------*/\r
54 \r
55 #include "chip.h"\r
56 \r
57 \r
58 /*----------------------------------------------------------------------------\r
59  *        Types\r
60  *----------------------------------------------------------------------------*/\r
61 \r
62 /** AFE transfer complete callback. */\r
63 typedef void (*AfeCallback)( uint8_t, void* ) ;\r
64 \r
65 /** \brief Spi Transfer Request prepared by the application upper layer.\r
66  *\r
67  * This structure is sent to the AFE_SendCommand function to start the transfer.\r
68  * At the end of the transfer, the callback is invoked by the interrupt handler.\r
69  */\r
70 typedef struct\r
71 {\r
72     /** Pointer to the Rx data. */\r
73     uint32_t *pRxBuff;\r
74     /** Rx size in bytes. */\r
75     uint16_t RxSize;\r
76     /** Callback function invoked at the end of transfer. */\r
77     AfeCallback callback;\r
78     /** Callback arguments. */\r
79     void *pArgument;\r
80 } AfeCmd ;\r
81 \r
82 \r
83 /** Constant structure associated with AFE port. This structure prevents\r
84     client applications to have access in the same time. */\r
85 typedef struct \r
86 {\r
87     /** Pointer to AFE Hardware registers */\r
88     Afec* pAfeHw ;\r
89     /** Current SpiCommand being processed */\r
90     AfeCmd *pCurrentCommand ;\r
91     /** Pointer to DMA driver */\r
92     sXdmad* pXdmad;\r
93     /** AFEC Id as defined in the product datasheet */\r
94     uint8_t afeId ;\r
95     /** Mutual exclusion semaphore. */\r
96     volatile int8_t semaphore ;\r
97 } AfeDma;\r
98 \r
99 \r
100 /*------------------------------------------------------------------------------\r
101  *         Definitions\r
102  *------------------------------------------------------------------------------*/\r
103 #define AFE_OK          0\r
104 #define AFE_ERROR       1\r
105 #define AFE_ERROR_LOCK  2\r
106 /*------------------------------------------------------------------------------\r
107  *         Exported functions\r
108  *------------------------------------------------------------------------------*/\r
109 extern uint32_t Afe_ConfigureDma( AfeDma *pAfed ,\r
110                            Afec *pAfeHw ,\r
111                            uint8_t AfeId,\r
112                            sXdmad *pXdmad );\r
113 extern uint32_t Afe_SendData( AfeDma *pAfed, AfeCmd *pCommand);\r
114 \r
115 \r
116 #endif /* #ifndef _AFE_DMA_ */\r
117 \r