collab/mm20
git clone https://git.julia.blue/collab/mm20
39a929c
pcb
1#include <stdbool.h> 2#include <stdint.h> 3//***************************************************************************** 4// 5// adc.h - ADC headers for using the ADC driver functions. 6// 7// Copyright (c) 2005-2017 Texas Instruments Incorporated. All rights reserved. 8// Software License Agreement 9// 10// Redistribution and use in source and binary forms, with or without 11// modification, are permitted provided that the following conditions 12// are met: 13// 14// Redistributions of source code must retain the above copyright 15// notice, this list of conditions and the following disclaimer. 16// 17// Redistributions in binary form must reproduce the above copyright 18// notice, this list of conditions and the following disclaimer in the 19// documentation and/or other materials provided with the 20// distribution. 21// 22// Neither the name of Texas Instruments Incorporated nor the names of 23// its contributors may be used to endorse or promote products derived 24// from this software without specific prior written permission. 25// 26// THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS 27// "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT 28// LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR 29// A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT 30// OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, 31// SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT 32// LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, 33// DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY 34// THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT 35// (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE 36// OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. 37// 38// This is part of revision 2.1.4.178 of the Tiva Peripheral Driver Library. 39// 40//***************************************************************************** 41 42#ifndef __DRIVERLIB_ADC_H__ 43#define __DRIVERLIB_ADC_H__ 44 45//***************************************************************************** 46// 47// If building with a C++ compiler, make all of the definitions in this header 48// have a C binding. 49// 50//***************************************************************************** 51#ifdef __cplusplus 52extern "C" 53{ 54#endif 55 56//***************************************************************************** 57// 58// Values that can be passed to ADCSequenceConfigure as the ui32Trigger 59// parameter. 60// 61//***************************************************************************** 62#define ADC_TRIGGER_PROCESSOR 0x00000000 // Processor event 63#define ADC_TRIGGER_COMP0 0x00000001 // Analog comparator 0 event 64#define ADC_TRIGGER_COMP1 0x00000002 // Analog comparator 1 event 65#define ADC_TRIGGER_COMP2 0x00000003 // Analog comparator 2 event 66#define ADC_TRIGGER_EXTERNAL 0x00000004 // External event 67#define ADC_TRIGGER_TIMER 0x00000005 // Timer event 68#define ADC_TRIGGER_PWM0 0x00000006 // PWM0 event 69#define ADC_TRIGGER_PWM1 0x00000007 // PWM1 event 70#define ADC_TRIGGER_PWM2 0x00000008 // PWM2 event 71#define ADC_TRIGGER_PWM3 0x00000009 // PWM3 event 72#define ADC_TRIGGER_NEVER 0x0000000E // Never Trigger 73#define ADC_TRIGGER_ALWAYS 0x0000000F // Always event 74#define ADC_TRIGGER_PWM_MOD0 0x00000000 // PWM triggers from PWM0 75#define ADC_TRIGGER_PWM_MOD1 0x00000010 // PWM triggers from PWM1 76 77//***************************************************************************** 78// 79// Values that can be passed to ADCSequenceStepConfigure as the ui32Config 80// parameter. 81// 82//***************************************************************************** 83#define ADC_CTL_TS 0x00000080 // Temperature sensor select 84#define ADC_CTL_IE 0x00000040 // Interrupt enable 85#define ADC_CTL_END 0x00000020 // Sequence end select 86#define ADC_CTL_D 0x00000010 // Differential select 87#define ADC_CTL_CH0 0x00000000 // Input channel 0 88#define ADC_CTL_CH1 0x00000001 // Input channel 1 89#define ADC_CTL_CH2 0x00000002 // Input channel 2 90#define ADC_CTL_CH3 0x00000003 // Input channel 3 91#define ADC_CTL_CH4 0x00000004 // Input channel 4 92#define ADC_CTL_CH5 0x00000005 // Input channel 5 93#define ADC_CTL_CH6 0x00000006 // Input channel 6 94#define ADC_CTL_CH7 0x00000007 // Input channel 7 95#define ADC_CTL_CH8 0x00000008 // Input channel 8 96#define ADC_CTL_CH9 0x00000009 // Input channel 9 97#define ADC_CTL_CH10 0x0000000A // Input channel 10 98#define ADC_CTL_CH11 0x0000000B // Input channel 11 99#define ADC_CTL_CH12 0x0000000C // Input channel 12 100#define ADC_CTL_CH13 0x0000000D // Input channel 13 101#define ADC_CTL_CH14 0x0000000E // Input channel 14 102#define ADC_CTL_CH15 0x0000000F // Input channel 15 103#define ADC_CTL_CH16 0x00000100 // Input channel 16 104#define ADC_CTL_CH17 0x00000101 // Input channel 17 105#define ADC_CTL_CH18 0x00000102 // Input channel 18 106#define ADC_CTL_CH19 0x00000103 // Input channel 19 107#define ADC_CTL_CH20 0x00000104 // Input channel 20 108#define ADC_CTL_CH21 0x00000105 // Input channel 21 109#define ADC_CTL_CH22 0x00000106 // Input channel 22 110#define ADC_CTL_CH23 0x00000107 // Input channel 23 111#define ADC_CTL_CMP0 0x00080000 // Select Comparator 0 112#define ADC_CTL_CMP1 0x00090000 // Select Comparator 1 113#define ADC_CTL_CMP2 0x000A0000 // Select Comparator 2 114#define ADC_CTL_CMP3 0x000B0000 // Select Comparator 3 115#define ADC_CTL_CMP4 0x000C0000 // Select Comparator 4 116#define ADC_CTL_CMP5 0x000D0000 // Select Comparator 5 117#define ADC_CTL_CMP6 0x000E0000 // Select Comparator 6 118#define ADC_CTL_CMP7 0x000F0000 // Select Comparator 7 119#define ADC_CTL_SHOLD_4 0x00000000 // Sample and hold 4 ADC clocks 120#define ADC_CTL_SHOLD_8 0x00200000 // Sample and hold 8 ADC clocks 121#define ADC_CTL_SHOLD_16 0x00400000 // Sample and hold 16 ADC clocks 122#define ADC_CTL_SHOLD_32 0x00600000 // Sample and hold 32 ADC clocks 123#define ADC_CTL_SHOLD_64 0x00800000 // Sample and hold 64 ADC clocks 124#define ADC_CTL_SHOLD_128 0x00A00000 // Sample and hold 128 ADC clocks 125#define ADC_CTL_SHOLD_256 0x00C00000 // Sample and hold 256 ADC clocks 126 127//***************************************************************************** 128// 129// Values that can be passed to ADCComparatorConfigure as part of the 130// ui32Config parameter. 131// 132//***************************************************************************** 133#define ADC_COMP_TRIG_NONE 0x00000000 // Trigger Disabled 134#define ADC_COMP_TRIG_LOW_ALWAYS \ 135 0x00001000 // Trigger Low Always 136#define ADC_COMP_TRIG_LOW_ONCE 0x00001100 // Trigger Low Once 137#define ADC_COMP_TRIG_LOW_HALWAYS \ 138 0x00001200 // Trigger Low Always (Hysteresis) 139#define ADC_COMP_TRIG_LOW_HONCE 0x00001300 // Trigger Low Once (Hysteresis) 140#define ADC_COMP_TRIG_MID_ALWAYS \ 141 0x00001400 // Trigger Mid Always 142#define ADC_COMP_TRIG_MID_ONCE 0x00001500 // Trigger Mid Once 143#define ADC_COMP_TRIG_HIGH_ALWAYS \ 144 0x00001C00 // Trigger High Always 145#define ADC_COMP_TRIG_HIGH_ONCE 0x00001D00 // Trigger High Once 146#define ADC_COMP_TRIG_HIGH_HALWAYS \ 147 0x00001E00 // Trigger High Always (Hysteresis) 148#define ADC_COMP_TRIG_HIGH_HONCE \ 149 0x00001F00 // Trigger High Once (Hysteresis) 150 151#define ADC_COMP_INT_NONE 0x00000000 // Interrupt Disabled 152#define ADC_COMP_INT_LOW_ALWAYS \ 153 0x00000010 // Interrupt Low Always 154#define ADC_COMP_INT_LOW_ONCE 0x00000011 // Interrupt Low Once 155#define ADC_COMP_INT_LOW_HALWAYS \ 156 0x00000012 // Interrupt Low Always 157// (Hysteresis) 158#define ADC_COMP_INT_LOW_HONCE 0x00000013 // Interrupt Low Once (Hysteresis) 159#define ADC_COMP_INT_MID_ALWAYS \ 160 0x00000014 // Interrupt Mid Always 161#define ADC_COMP_INT_MID_ONCE 0x00000015 // Interrupt Mid Once 162#define ADC_COMP_INT_HIGH_ALWAYS \ 163 0x0000001C // Interrupt High Always 164#define ADC_COMP_INT_HIGH_ONCE 0x0000001D // Interrupt High Once 165#define ADC_COMP_INT_HIGH_HALWAYS \ 166 0x0000001E // Interrupt High Always 167// (Hysteresis) 168#define ADC_COMP_INT_HIGH_HONCE \ 169 0x0000001F // Interrupt High Once (Hysteresis) 170 171//***************************************************************************** 172// 173// Values that can be used to modify the sequence number passed to 174// ADCProcessorTrigger in order to get cross-module synchronous processor 175// triggers. 176// 177//***************************************************************************** 178#define ADC_TRIGGER_WAIT 0x08000000 // Wait for the synchronous trigger 179#define ADC_TRIGGER_SIGNAL 0x80000000 // Signal the synchronous trigger 180 181//***************************************************************************** 182// 183// Values that can be passed to ADCPhaseDelaySet as the ui32Phase parameter and 184// returned from ADCPhaseDelayGet. 185// 186//***************************************************************************** 187#define ADC_PHASE_0 0x00000000 // 0 degrees 188#define ADC_PHASE_22_5 0x00000001 // 22.5 degrees 189#define ADC_PHASE_45 0x00000002 // 45 degrees 190#define ADC_PHASE_67_5 0x00000003 // 67.5 degrees 191#define ADC_PHASE_90 0x00000004 // 90 degrees 192#define ADC_PHASE_112_5 0x00000005 // 112.5 degrees 193#define ADC_PHASE_135 0x00000006 // 135 degrees 194#define ADC_PHASE_157_5 0x00000007 // 157.5 degrees 195#define ADC_PHASE_180 0x00000008 // 180 degrees 196#define ADC_PHASE_202_5 0x00000009 // 202.5 degrees 197#define ADC_PHASE_225 0x0000000A // 225 degrees 198#define ADC_PHASE_247_5 0x0000000B // 247.5 degrees 199#define ADC_PHASE_270 0x0000000C // 270 degrees 200#define ADC_PHASE_292_5 0x0000000D // 292.5 degrees 201#define ADC_PHASE_315 0x0000000E // 315 degrees 202#define ADC_PHASE_337_5 0x0000000F // 337.5 degrees 203 204//***************************************************************************** 205// 206// Values that can be passed to ADCReferenceSet as the ui32Ref parameter. 207// 208//***************************************************************************** 209#define ADC_REF_INT 0x00000000 // Internal reference 210#define ADC_REF_EXT_3V 0x00000001 // External 3V reference 211 212//***************************************************************************** 213// 214// Values that can be passed to ADCIntDisableEx(), ADCIntEnableEx(), 215// ADCIntClearEx() and ADCIntStatusEx(). 216// 217//***************************************************************************** 218#define ADC_INT_SS0 0x00000001 219#define ADC_INT_SS1 0x00000002 220#define ADC_INT_SS2 0x00000004 221#define ADC_INT_SS3 0x00000008 222#define ADC_INT_DMA_SS0 0x00000100 223#define ADC_INT_DMA_SS1 0x00000200 224#define ADC_INT_DMA_SS2 0x00000400 225#define ADC_INT_DMA_SS3 0x00000800 226#define ADC_INT_DCON_SS0 0x00010000 227#define ADC_INT_DCON_SS1 0x00020000 228#define ADC_INT_DCON_SS2 0x00040000 229#define ADC_INT_DCON_SS3 0x00080000 230 231//***************************************************************************** 232// 233// Values that can be passed to ADCClockConfigSet() and ADCClockConfigGet(). 234// 235//***************************************************************************** 236#define ADC_CLOCK_RATE_FULL 0x00000070 237#define ADC_CLOCK_RATE_HALF 0x00000050 238#define ADC_CLOCK_RATE_FOURTH 0x00000030 239#define ADC_CLOCK_RATE_EIGHTH 0x00000010 240#define ADC_CLOCK_SRC_PLL 0x00000000 241#define ADC_CLOCK_SRC_PIOSC 0x00000001 242#define ADC_CLOCK_SRC_ALTCLK 0x00000001 243#define ADC_CLOCK_SRC_MOSC 0x00000002 244 245//***************************************************************************** 246// 247// Prototypes for the APIs. 248// 249//***************************************************************************** 250extern void ADCIntRegister (uint32_t ui32Base ,uint32_t ui32SequenceNum , 251void (* pfnHandler )(void )); 252extern void ADCIntUnregister (uint32_t ui32Base ,uint32_t ui32SequenceNum ); 253extern void ADCIntDisable (uint32_t ui32Base ,uint32_t ui32SequenceNum ); 254extern void ADCIntEnable (uint32_t ui32Base ,uint32_t ui32SequenceNum ); 255extern uint32_t ADCIntStatus (uint32_t ui32Base ,uint32_t ui32SequenceNum , 256bool bMasked ); 257extern void ADCIntClear (uint32_t ui32Base ,uint32_t ui32SequenceNum ); 258extern void ADCSequenceEnable (uint32_t ui32Base ,uint32_t ui32SequenceNum ); 259extern void ADCSequenceDisable (uint32_t ui32Base ,uint32_t ui32SequenceNum ); 260extern void ADCSequenceConfigure (uint32_t ui32Base ,uint32_t ui32SequenceNum , 261uint32_t ui32Trigger ,uint32_t ui32Priority ); 262extern void ADCSequenceStepConfigure (uint32_t ui32Base , 263uint32_t ui32SequenceNum , 264uint32_t ui32Step ,uint32_t ui32Config ); 265extern int32_t ADCSequenceOverflow (uint32_t ui32Base , 266uint32_t ui32SequenceNum ); 267extern void ADCSequenceOverflowClear (uint32_t ui32Base , 268uint32_t ui32SequenceNum ); 269extern int32_t ADCSequenceUnderflow (uint32_t ui32Base , 270uint32_t ui32SequenceNum ); 271extern void ADCSequenceUnderflowClear (uint32_t ui32Base , 272uint32_t ui32SequenceNum ); 273extern int32_t ADCSequenceDataGet (uint32_t ui32Base ,uint32_t ui32SequenceNum , 274uint32_t * pui32Buffer ); 275extern void ADCProcessorTrigger (uint32_t ui32Base ,uint32_t ui32SequenceNum ); 276extern void ADCSoftwareOversampleConfigure (uint32_t ui32Base , 277uint32_t ui32SequenceNum , 278uint32_t ui32Factor ); 279extern void ADCSoftwareOversampleStepConfigure (uint32_t ui32Base , 280uint32_t ui32SequenceNum , 281uint32_t ui32Step , 282uint32_t ui32Config ); 283extern void ADCSoftwareOversampleDataGet (uint32_t ui32Base , 284uint32_t ui32SequenceNum , 285uint32_t * pui32Buffer , 286uint32_t ui32Count ); 287extern void ADCHardwareOversampleConfigure (uint32_t ui32Base , 288uint32_t ui32Factor ); 289extern void ADCClockConfigSet (uint32_t ui32Base ,uint32_t ui32Config , 290uint32_t ui32ClockDiv ); 291extern uint32_t ADCClockConfigGet (uint32_t ui32Base ,uint32_t * pui32ClockDiv ); 292 293extern void ADCComparatorConfigure (uint32_t ui32Base ,uint32_t ui32Comp , 294uint32_t ui32Config ); 295extern void ADCComparatorRegionSet (uint32_t ui32Base ,uint32_t ui32Comp , 296uint32_t ui32LowRef ,uint32_t ui32HighRef ); 297extern void ADCComparatorReset (uint32_t ui32Base ,uint32_t ui32Comp , 298bool bTrigger ,bool bInterrupt ); 299extern void ADCComparatorIntDisable (uint32_t ui32Base , 300uint32_t ui32SequenceNum ); 301extern void ADCComparatorIntEnable (uint32_t ui32Base , 302uint32_t ui32SequenceNum ); 303extern uint32_t ADCComparatorIntStatus (uint32_t ui32Base ); 304extern void ADCComparatorIntClear (uint32_t ui32Base ,uint32_t ui32Status ); 305extern void ADCIntDisableEx (uint32_t ui32Base ,uint32_t ui32IntFlags ); 306extern void ADCIntEnableEx (uint32_t ui32Base ,uint32_t ui32IntFlags ); 307extern uint32_t ADCIntStatusEx (uint32_t ui32Base ,bool bMasked ); 308extern void ADCIntClearEx (uint32_t ui32Base ,uint32_t ui32IntFlags ); 309extern void ADCSequenceDMAEnable (uint32_t ui32Base ,uint32_t ui32SequenceNum ); 310extern void ADCSequenceDMADisable (uint32_t ui32Base ,uint32_t ui32SequenceNum ); 311extern bool ADCBusy (uint32_t ui32Base ); 312extern void ADCReferenceSet (uint32_t ui32Base ,uint32_t ui32Ref ); 313extern uint32_t ADCReferenceGet (uint32_t ui32Base ); 314extern void ADCPhaseDelaySet (uint32_t ui32Base ,uint32_t ui32Phase ); 315extern uint32_t ADCPhaseDelayGet (uint32_t ui32Base ); 316extern void ADCSampleRateSet (uint32_t ui32Base ,uint32_t ui32ADCClock , 317uint32_t ui32Rate ); 318extern uint32_t ADCSampleRateGet (uint32_t ui32Base ); 319 320//***************************************************************************** 321// 322// Mark the end of the C bindings section for C++ compilers. 323// 324//***************************************************************************** 325#ifdef __cplusplus 326} 327#endif 328 329#endif // __DRIVERLIB_ADC_H__