SAMV71 Xplained Ultra Software Package 1.5

afe_dma.h

Go to the documentation of this file.
00001 /* ---------------------------------------------------------------------------- */
00002 /*                  Atmel Microcontroller Software Support                      */
00003 /*                       SAM Software Package License                           */
00004 /* ---------------------------------------------------------------------------- */
00005 /* Copyright (c) 2015, Atmel Corporation                                        */
00006 /*                                                                              */
00007 /* All rights reserved.                                                         */
00008 /*                                                                              */
00009 /* Redistribution and use in source and binary forms, with or without           */
00010 /* modification, are permitted provided that the following condition is met:    */
00011 /*                                                                              */
00012 /* - Redistributions of source code must retain the above copyright notice,     */
00013 /* this list of conditions and the disclaimer below.                            */
00014 /*                                                                              */
00015 /* Atmel's name may not be used to endorse or promote products derived from     */
00016 /* this software without specific prior written permission.                     */
00017 /*                                                                              */
00018 /* DISCLAIMER:  THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR   */
00019 /* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
00020 /* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE   */
00021 /* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT,      */
00022 /* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
00023 /* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA,  */
00024 /* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF    */
00025 /* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING         */
00026 /* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
00027 /* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                           */
00028 /* ---------------------------------------------------------------------------- */
00029 
00030 /**
00031  *  \file
00032  *
00033  *  \section Purpose
00034  *
00035  *  Interface for configuration the Analog-to-Digital Converter (AFEC) peripheral.
00036  *
00037  *  \section Usage
00038  *
00039  *  -# Configurate the pins for AFEC.
00040  *  -# Initialize the AFEC with AFEC_Initialize().
00041  *  -# Set AFEC clock and timing with AFEC_SetClock() and AFEC_SetTiming().
00042  *  -# Select the active channel using AFEC_EnableChannel().
00043  *  -# Start the conversion with AFEC_StartConversion().
00044  *  -# Wait the end of the conversion by polling status with AFEC_GetStatus().
00045  *  -# Finally, get the converted data using AFEC_GetConvertedData() or
00046  * AFEC_GetLastConvertedData().
00047  *
00048 */
00049 #ifndef _AFE_DMA_
00050 #define _AFE_DMA_
00051 
00052 /*----------------------------------------------------------------------------
00053  *        Headers
00054  *----------------------------------------------------------------------------*/
00055 
00056 #include "chip.h"
00057 
00058 
00059 /*----------------------------------------------------------------------------
00060  *        Types
00061  *----------------------------------------------------------------------------*/
00062 
00063 /** AFE transfer complete callback. */
00064 typedef void (*AfeCallback)(uint8_t, void *);
00065 
00066 /** \brief Spi Transfer Request prepared by the application upper layer.
00067  *
00068  * This structure is sent to the AFE_SendCommand function to start the transfer.
00069  * At the end of the transfer, the callback is invoked by the interrupt handler.
00070  */
00071 typedef struct {
00072     /** Pointer to the Rx data. */
00073     uint32_t *pRxBuff;
00074     /** Rx size in bytes. */
00075     uint16_t RxSize;
00076     /** Callback function invoked at the end of transfer. */
00077     AfeCallback callback;
00078     /** Callback arguments. */
00079     void *pArgument;
00080 } AfeCmd;
00081 
00082 
00083 /** Constant structure associated with AFE port. This structure prevents
00084     client applications to have access in the same time. */
00085 typedef struct {
00086     /** Pointer to AFE Hardware registers */
00087     Afec *pAfeHw;
00088     /** Current SpiCommand being processed */
00089     AfeCmd *pCurrentCommand;
00090     /** Pointer to DMA driver */
00091     sXdmad *pXdmad;
00092     /** AFEC Id as defined in the product datasheet */
00093     uint8_t afeId;
00094     /** Mutual exclusion semaphore. */
00095     volatile int8_t semaphore;
00096 } AfeDma;
00097 
00098 
00099 /*------------------------------------------------------------------------------
00100  *         Definitions
00101  *----------------------------------------------------------------------------*/
00102 #define AFE_OK          0
00103 #define AFE_ERROR       1
00104 #define AFE_ERROR_LOCK  2
00105 /*------------------------------------------------------------------------------
00106  *         Exported functions
00107  *----------------------------------------------------------------------------*/
00108 extern uint32_t Afe_ConfigureDma(AfeDma *pAfed ,
00109                                   Afec *pAfeHw ,
00110                                   uint8_t AfeId,
00111                                   sXdmad *pXdmad);
00112 extern uint32_t Afe_SendData(AfeDma *pAfed, AfeCmd *pCommand);
00113 
00114 
00115 #endif /* #ifndef _AFE_DMA_ */
00116 
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines