RTEMS: bsps/arm/atsam/include/libchip/include/afec.h Source File

| RTEMS 5.4-rc2

Loading...
Searching...
No Matches
afec.h
Go to the documentation of this file.
1/* ---------------------------------------------------------------------------- */
2/* Atmel Microcontroller Software Support */
3/* SAM Software Package License */
4/* ---------------------------------------------------------------------------- */
5/* Copyright (c) 2015, Atmel Corporation */
6/* */
7/* All rights reserved. */
8/* */
9/* Redistribution and use in source and binary forms, with or without */
10/* modification, are permitted provided that the following condition is met: */
11/* */
12/* - Redistributions of source code must retain the above copyright notice, */
13/* this list of conditions and the disclaimer below. */
14/* */
15/* Atmel's name may not be used to endorse or promote products derived from */
16/* this software without specific prior written permission. */
17/* */
18/* DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR */
19/* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF */
20/* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE */
21/* DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, */
22/* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT */
23/* LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, */
24/* OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF */
25/* LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING */
26/* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, */
27/* EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. */
28/* ---------------------------------------------------------------------------- */
29
49#ifndef _AFEC_
50#define _AFEC_
51
52/*----------------------------------------------------------------------------
53 * Headers
54 *----------------------------------------------------------------------------*/
55#include <assert.h>
56#include <stdint.h>
57
58/*------------------------------------------------------------------------------
59 * Definitions
60 *------------------------------------------------------------------------------*/
61
62/* -------- AFEC_MR : (AFEC Offset: 0x04) AFEC Mode Register -------- */
63#define AFEC_MR_SETTLING_Pos 20
64#define AFEC_MR_SETTLING_Msk (0x3u << AFEC_MR_SETTLING_Pos)
66#define AFEC_MR_SETTLING_AST3 (0x0u << 20)
68#define AFEC_MR_SETTLING_AST5 (0x1u << 20)
70#define AFEC_MR_SETTLING_AST9 (0x2u << 20)
72#define AFEC_MR_SETTLING_AST17 (0x3u << 20)
75/***************************** Single Trigger Mode ****************************/
76#define AFEC_EMR_STM_Pos 25
77#define AFEC_EMR_STM_Msk (0x1u << AFEC_EMR_STM_Pos)
79#define AFEC_EMR_STM_MULTI_TRIG (0x0u << 25)
82#define AFEC_EMR_STM_SINGLE_TRIG (0x1u << 25)
86/***************************** TAG of the AFEC_LDCR Register ******************/
87#define AFEC_EMR_TAG_Pos 24
88#define AFEC_EMR_TAG_Msk (0x1u << AFEC_EMR_TAG_Pos)
90#define AFEC_EMR_TAG_CHNB_ZERO (0x0u << 24)
93#define AFEC_EMR_TAG_APPENDS (0x1u << 24)
97/***************************** Compare All Channels ******************/
98#define AFEC_EMR_CMPALL_Pos 9
99#define AFEC_EMR_CMPALL_Msk (0x1u << AFEC_EMR_TAG_Pos)
101#define AFEC_EMR_CMPALL_ONE_CHANNEL_COMP (0x0u << 9)
104#define AFEC_EMR_CMPALL_ALL_CHANNELS_COMP (0x1u << 9)
107#define AFEC_ACR_PGA0_ON (0x1u << 2)
108#define AFEC_ACR_PGA1_ON (0x1u << 3)
109
110#ifdef __cplusplus
111extern "C" {
112#endif
113
114/*------------------------------------------------------------------------------
115 * Macros function of register access
116 *------------------------------------------------------------------------------*/
117
118#define AFEC_GetModeReg(pAFEC) ((pAFEC)->AFEC_MR)
119#define AFEC_SetModeReg(pAFEC, mode) ((pAFEC)->AFEC_MR = mode)
120
121#define AFEC_GetExtModeReg(pAFEC) ((pAFEC)->AFEC_EMR)
122#define AFEC_SetExtModeReg(pAFEC, mode) ((pAFEC)->AFEC_EMR = mode)
123
124#define AFEC_StartConversion(pAFEC) ((pAFEC)->AFEC_CR = AFEC_CR_START)
125
126#define AFEC_EnableChannel(pAFEC, dwChannel) {\
127 (pAFEC)->AFEC_CHER = (1 << (dwChannel));\
128 }
129
130#define AFEC_DisableChannel(pAFEC, dwChannel) {\
131 (pAFEC)->AFEC_CHDR = (1 << (dwChannel));\
132 }
133
134#define AFEC_EnableIt(pAFEC, dwMode) {\
135 (pAFEC)->AFEC_IER = (dwMode);\
136 }
137
138#define AFEC_DisableIt(pAFEC, dwMode) {\
139 (pAFEC)->AFEC_IDR = (dwMode);\
140 }
141
142#define AFEC_SetChannelGain(pAFEC,dwMode) {\
143 (pAFEC)->AFEC_CGR = dwMode;\
144 }
145
146#define AFEC_EnableDataReadyIt(pAFEC) ((pAFEC)->AFEC_IER = AFEC_IER_DRDY)
147
148#define AFEC_GetStatus(pAFEC) ((pAFEC)->AFEC_ISR)
149
150#define AFEC_GetCompareMode(pAFEC) (((pAFEC)->AFEC_EMR)& (AFEC_EMR_CMPMODE_Msk))
151
152#define AFEC_GetChannelStatus(pAFEC) ((pAFEC)->AFEC_CHSR)
153
154#define AFEC_GetInterruptMaskStatus(pAFEC) ((pAFEC)->AFEC_IMR)
155
156#define AFEC_GetLastConvertedData(pAFEC) ((pAFEC)->AFEC_LCDR)
157
158/*------------------------------------------------------------------------------
159 * Exported functions
160 *------------------------------------------------------------------------------*/
161extern void AFEC_Initialize(Afec *pAFEC, uint32_t dwId);
162extern uint32_t AFEC_SetClock(Afec *pAFEC, uint32_t dwPres, uint32_t dwMck);
163extern void AFEC_SetTiming(Afec *pAFEC, uint32_t dwStartup,
164 uint32_t dwTracking,
165 uint32_t dwSettling);
166extern void AFEC_SetTrigger(Afec *pAFEC, uint32_t dwTrgSel);
167extern void AFEC_SetAnalogChange(Afec *pAFE, uint8_t bEnDis);
168extern void AFEC_SetSleepMode(Afec *pAFEC, uint8_t bEnDis);
169extern void AFEC_SetFastWakeup(Afec *pAFEC, uint8_t bEnDis);
170extern void AFEC_SetSequenceMode(Afec *pAFEC, uint8_t bEnDis);
171extern void AFEC_SetSequence(Afec *pAFEC, uint32_t dwSEQ1, uint32_t dwSEQ2);
172extern void AFEC_SetSequenceByList(Afec *pAFEC, uint8_t ucChList[],
173 uint8_t ucNumCh);
174extern void AFEC_SetTagEnable(Afec *pAFEC, uint8_t bEnDis);
175extern void AFEC_SetCompareChannel(Afec *pAFEC, uint32_t dwChannel);
176extern void AFEC_SetCompareMode(Afec *pAFEC, uint32_t dwMode);
177extern void AFEC_SetComparisonWindow(Afec *pAFEC, uint32_t dwHi_Lo);
178extern uint8_t AFEC_CheckConfiguration(Afec *pAFEC, uint32_t dwMcK);
179extern uint32_t AFEC_GetConvertedData(Afec *pAFEC, uint32_t dwChannel);
180extern void AFEC_SetStartupTime(Afec *pAFEC, uint32_t dwUs);
181extern void AFEC_SetTrackingTime(Afec *pAFEC, uint32_t dwNs);
182extern void AFEC_SetAnalogOffset(Afec *pAFE, uint32_t dwChannel,
183 uint32_t aoffset);
184extern void AFEC_SetAnalogControl(Afec *pAFE, uint32_t control);
185#ifdef __cplusplus
186}
187#endif
188
189#endif /* #ifndef _AFEC_ */
190
AFEC_SetFastWakeup
void AFEC_SetFastWakeup(Afec *pAFEC, uint8_t bEnDis)
Enable/Disable fast wake up.
Definition: afec.c:197
AFEC_SetAnalogControl
void AFEC_SetAnalogControl(Afec *pAFE, uint32_t control)
Set analog offset to be used for channel CSEL.
Definition: afec.c:453
AFEC_SetClock
uint32_t AFEC_SetClock(Afec *pAFEC, uint32_t dwPres, uint32_t dwMck)
Set AFE clock.
Definition: afec.c:116
AFEC_SetTagEnable
void AFEC_SetTagEnable(Afec *pAFEC, uint8_t bEnDis)
Set "TAG" mode, show channel number in last data or not.
Definition: afec.c:290
AFEC_SetSequence
void AFEC_SetSequence(Afec *pAFEC, uint32_t dwSEQ1, uint32_t dwSEQ2)
Set channel sequence.
Definition: afec.c:231
AFEC_SetComparisonWindow
void AFEC_SetComparisonWindow(Afec *pAFEC, uint32_t dwHi_Lo)
Set comparison window.
Definition: afec.c:334
AFEC_SetTiming
void AFEC_SetTiming(Afec *pAFEC, uint32_t dwStartup, uint32_t dwTracking, uint32_t dwSettling)
Set AFE timing.
Definition: afec.c:141
AFEC_SetCompareChannel
void AFEC_SetCompareChannel(Afec *pAFEC, uint32_t dwChannel)
Set compare channel.
Definition: afec.c:304
AFEC_SetTrackingTime
void AFEC_SetTrackingTime(Afec *pAFEC, uint32_t dwNs)
Definition: afec.c:408
AFEC_GetConvertedData
uint32_t AFEC_GetConvertedData(Afec *pAFEC, uint32_t dwChannel)
Return the Channel Converted Data.
Definition: afec.c:345
AFEC_SetSleepMode
void AFEC_SetSleepMode(Afec *pAFEC, uint8_t bEnDis)
Enable/Disable sleep mode.
Definition: afec.c:183
AFEC_Initialize
void AFEC_Initialize(Afec *pAFEC, uint32_t dwId)
Initialize the AFE controller.
Definition: afec.c:94
AFEC_SetAnalogOffset
void AFEC_SetAnalogOffset(Afec *pAFE, uint32_t dwChannel, uint32_t aoffset)
Set analog offset to be used for channel CSEL.
Definition: afec.c:440
AFEC_SetSequenceByList
void AFEC_SetSequenceByList(Afec *pAFEC, uint8_t ucChList[], uint8_t ucNumCh)
Set channel sequence by given channel list.
Definition: afec.c:244
AFEC_SetCompareMode
void AFEC_SetCompareMode(Afec *pAFEC, uint32_t dwMode)
Set compare mode.
Definition: afec.c:322
AFEC_SetSequenceMode
void AFEC_SetSequenceMode(Afec *pAFEC, uint8_t bEnDis)
Enable/Disable sequence mode.
Definition: afec.c:211
AFEC_SetAnalogChange
void AFEC_SetAnalogChange(Afec *pAFE, uint8_t bEnDis)
Set analog change. IF enabled, it allows different analog settings for each channel,...
Definition: afec.c:276
AFEC_SetStartupTime
void AFEC_SetStartupTime(Afec *pAFEC, uint32_t dwUs)
Definition: afec.c:361
AFEC_SetTrigger
void AFEC_SetTrigger(Afec *pAFEC, uint32_t dwTrgSel)
Set AFE trigger.
Definition: afec.c:166
assert.h
Information for the Assert Handler.
Afec
Afec hardware registers.
Definition: component_afec.h:41
control
Definition: intercom.c:74