1 /* ----------------------------------------------------------------------------
\r
2 * SAM Software Package License
\r
3 * ----------------------------------------------------------------------------
\r
4 * Copyright (c) 2014, 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
34 * Interface for configuration the Analog-to-Digital Converter (DACC) peripheral.
\r
38 * -# Configurate the pins for DACC
\r
39 * -# Initialize the DACC with DACC_Initialize().
\r
40 * -# Select the active channel using DACC_EnableChannel()
\r
41 * -# Start the conversion with DACC_StartConversion()
\r
42 * -# Wait the end of the conversion by polling status with DACC_GetStatus()
\r
43 * -# Finally, get the converted data using DACC_GetConvertedData()
\r
49 /*----------------------------------------------------------------------------
\r
51 *----------------------------------------------------------------------------*/
\r
63 /*----------------------------------------------------------------------------
\r
65 *----------------------------------------------------------------------------*/
\r
67 /** DAC transfer complete callback. */
\r
68 typedef void (*DacCallback)( uint8_t, void* ) ;
\r
70 /** \brief Dac Transfer Request prepared by the application upper layer.
\r
72 * This structure is sent to the DAC_SendCommand function to start the transfer.
\r
73 * At the end of the transfer, the callback is invoked by the interrupt handler.
\r
77 /** Pointer to the Tx data. */
\r
79 /** Tx size in bytes. */
\r
81 /** Tx loop back. */
\r
84 uint8_t dacChannel;
\r
85 /** Callback function invoked at the end of transfer. */
\r
86 DacCallback callback;
\r
87 /** Callback arguments. */
\r
92 /** Constant structure associated with DAC port. This structure prevents
\r
93 client applications to have access in the same time. */
\r
96 /** Pointer to DAC Hardware registers */
\r
98 /** Current SpiCommand being processed */
\r
99 DacCmd *pCurrentCommand ;
\r
100 /** Pointer to DMA driver */
\r
102 /** DACC Id as defined in the product datasheet */
\r
104 /** Mutual exclusion semaphore. */
\r
105 volatile int8_t semaphore ;
\r
109 /*------------------------------------------------------------------------------
\r
111 *------------------------------------------------------------------------------*/
\r
113 #define DAC_ERROR 1
\r
114 #define DAC_ERROR_LOCK 2
\r
116 #define DACC_CHANNEL_0 0
\r
117 #define DACC_CHANNEL_1 1
\r
119 /*------------------------------------------------------------------------------
\r
120 * Exported functions
\r
121 *------------------------------------------------------------------------------*/
\r
122 extern uint32_t Dac_ConfigureDma( DacDma *pDacd ,
\r
126 extern uint32_t Dac_SendData( DacDma *pDacd, DacCmd *pCommand);
\r
129 /*------------------------------------------------------------------------------
\r
130 * Macros function of register access
\r
131 *------------------------------------------------------------------------------*/
\r
132 #define DACC_SoftReset(pDACC) ((pDACC)->DACC_CR = DACC_CR_SWRST)
\r
133 #define DACC_CfgModeReg(pDACC, mode) { (pDACC)->DACC_MR = (mode); }
\r
134 #define DACC_GetModeReg(pDACC) ((pDACC)->DACC_MR)
\r
135 #define DACC_CfgTrigger(pDACC, mode) { (pDACC)->DACC_TRIGR = (mode); }
\r
137 #define DACC_EnableChannel(pDACC, channel) {(pDACC)->DACC_CHER = (1 << (channel));}
\r
138 #define DACC_DisableChannel(pDACC, channel) {(pDACC)->DACC_CHDR = (1 << (channel));}
\r
140 #define DACC_EnableIt(pDACC, mode) {(pDACC)->DACC_IER = (mode);}
\r
141 #define DACC_DisableIt(pDACC, mode) {(pDACC)->DACC_IDR = (mode);}
\r
142 #define DACC_GetStatus(pDACC) ((pDACC)->DACC_ISR)
\r
143 #define DACC_GetChannelStatus(pDACC) ((pDACC)->DACC_CHSR)
\r
144 #define DACC_GetInterruptMaskStatus(pDACC) ((pDACC)->DACC_IMR)
\r
151 #endif /* #ifndef _DAC_DMA_ */
\r