7 #ifndef __MSP430WARE_ADC_H__ 8 #define __MSP430WARE_ADC_H__ 10 #include "inc/hw_memmap.h" 12 #ifdef __MSP430_HAS_ADC__ 31 #define ADC_CLOCKSOURCE_ADCOSC (ADCSSEL_0) 32 #define ADC_CLOCKSOURCE_ACLK (ADCSSEL_1) 33 #define ADC_CLOCKSOURCE_SMCLK (ADCSSEL_2) 41 #define ADC_CLOCKDIVIDER_1 (ADCDIV_0 + ADCPDIV_0) 42 #define ADC_CLOCKDIVIDER_2 (ADCDIV_1 + ADCPDIV_0) 43 #define ADC_CLOCKDIVIDER_3 (ADCDIV_2 + ADCPDIV_0) 44 #define ADC_CLOCKDIVIDER_4 (ADCDIV_3 + ADCPDIV_0) 45 #define ADC_CLOCKDIVIDER_5 (ADCDIV_4 + ADCPDIV_0) 46 #define ADC_CLOCKDIVIDER_6 (ADCDIV_5 + ADCPDIV_0) 47 #define ADC_CLOCKDIVIDER_7 (ADCDIV_6 + ADCPDIV_0) 48 #define ADC_CLOCKDIVIDER_8 (ADCDIV_7 + ADCPDIV_0) 49 #define ADC_CLOCKDIVIDER_12 (ADCDIV_2 + ADCPDIV_1) 50 #define ADC_CLOCKDIVIDER_16 (ADCDIV_3 + ADCPDIV_1) 51 #define ADC_CLOCKDIVIDER_20 (ADCDIV_4 + ADCPDIV_1) 52 #define ADC_CLOCKDIVIDER_24 (ADCDIV_5 + ADCPDIV_1) 53 #define ADC_CLOCKDIVIDER_28 (ADCDIV_6 + ADCPDIV_1) 54 #define ADC_CLOCKDIVIDER_32 (ADCDIV_7 + ADCPDIV_1) 55 #define ADC_CLOCKDIVIDER_64 (ADCDIV_0 + ADCPDIV_2) 56 #define ADC_CLOCKDIVIDER_128 (ADCDIV_1 + ADCPDIV_2) 57 #define ADC_CLOCKDIVIDER_192 (ADCDIV_2 + ADCPDIV_2) 58 #define ADC_CLOCKDIVIDER_256 (ADCDIV_3 + ADCPDIV_2) 59 #define ADC_CLOCKDIVIDER_320 (ADCDIV_4 + ADCPDIV_2) 60 #define ADC_CLOCKDIVIDER_384 (ADCDIV_5 + ADCPDIV_2) 61 #define ADC_CLOCKDIVIDER_448 (ADCDIV_6 + ADCPDIV_2) 62 #define ADC_CLOCKDIVIDER_512 (ADCDIV_7 + ADCPDIV_2) 70 #define ADC_SAMPLEHOLDSOURCE_SC (ADCSHS_0) 71 #define ADC_SAMPLEHOLDSOURCE_1 (ADCSHS_1) 72 #define ADC_SAMPLEHOLDSOURCE_2 (ADCSHS_2) 73 #define ADC_SAMPLEHOLDSOURCE_3 (ADCSHS_3) 81 #define ADC_MULTIPLESAMPLESDISABLE (!(ADCMSC)) 82 #define ADC_MULTIPLESAMPLESENABLE (ADCMSC) 90 #define ADC_CYCLEHOLD_4_CYCLES (ADCSHT_0) 91 #define ADC_CYCLEHOLD_8_CYCLES (ADCSHT_1) 92 #define ADC_CYCLEHOLD_16_CYCLES (ADCSHT_2) 93 #define ADC_CYCLEHOLD_32_CYCLES (ADCSHT_3) 94 #define ADC_CYCLEHOLD_64_CYCLES (ADCSHT_4) 95 #define ADC_CYCLEHOLD_96_CYCLES (ADCSHT_5) 96 #define ADC_CYCLEHOLD_128_CYCLES (ADCSHT_6) 97 #define ADC_CYCLEHOLD_192_CYCLES (ADCSHT_7) 98 #define ADC_CYCLEHOLD_256_CYCLES (ADCSHT_8) 99 #define ADC_CYCLEHOLD_384_CYCLES (ADCSHT_9) 100 #define ADC_CYCLEHOLD_512_CYCLES (ADCSHT_10) 101 #define ADC_CYCLEHOLD_768_CYCLES (ADCSHT_11) 102 #define ADC_CYCLEHOLD_1024_CYCLES (ADCSHT_12) 110 #define ADC_INPUT_A0 (ADCINCH_0) 111 #define ADC_INPUT_A1 (ADCINCH_1) 112 #define ADC_INPUT_A2 (ADCINCH_2) 113 #define ADC_INPUT_A3 (ADCINCH_3) 114 #define ADC_INPUT_A4 (ADCINCH_4) 115 #define ADC_INPUT_A5 (ADCINCH_5) 116 #define ADC_INPUT_A6 (ADCINCH_6) 117 #define ADC_INPUT_A7 (ADCINCH_7) 118 #define ADC_INPUT_A8 (ADCINCH_8) 119 #define ADC_INPUT_A9 (ADCINCH_9) 120 #define ADC_INPUT_TEMPSENSOR (ADCINCH_12) 121 #define ADC_INPUT_REFVOLTAGE (ADCINCH_13) 122 #define ADC_INPUT_DVSS (ADCINCH_14) 123 #define ADC_INPUT_DVCC (ADCINCH_15) 132 #define ADC_VREFPOS_AVCC (!(ADCSREF0 + ADCSREF1)) 133 #define ADC_VREFPOS_INT (ADCSREF0) 134 #define ADC_VREFPOS_EXT_BUF (ADCSREF1) 135 #define ADC_VREFPOS_EXT_NOBUF (ADCSREF1 + ADCSREF0) 144 #define ADC_VREFNEG_AVSS (!(ADCSREF2)) 145 #define ADC_VREFNEG_EXT (ADCSREF2) 153 #define ADC_OVERFLOW_INTERRUPT (ADCOVIE) 154 #define ADC_TIMEOVERFLOW_INTERRUPT (ADCTOVIE) 155 #define ADC_ABOVETHRESHOLD_INTERRUPT (ADCHIIE) 156 #define ADC_BELOWTHRESHOLD_INTERRUPT (ADCLOIE) 157 #define ADC_INSIDEWINDOW_INTERRUPT (ADCINIE) 158 #define ADC_COMPLETED_INTERRUPT (ADCIE0) 166 #define ADC_OVERFLOW_INTERRUPT_FLAG (ADCOVIFG) 167 #define ADC_TIMEOVERFLOW_INTERRUPT_FLAG (ADCTOVIFG) 168 #define ADC_ABOVETHRESHOLD_INTERRUPT_FLAG (ADCHIIFG) 169 #define ADC_BELOWTHRESHOLD_INTERRUPT_FLAG (ADCLOIFG) 170 #define ADC_INSIDEWINDOW_INTERRUPT_FLAG (ADCINIFG) 171 #define ADC_COMPLETED_INTERRUPT_FLAG (ADCIFG0) 179 #define ADC_SINGLECHANNEL (ADCCONSEQ_0) 180 #define ADC_SEQOFCHANNELS (ADCCONSEQ_1) 181 #define ADC_REPEATED_SINGLECHANNEL (ADCCONSEQ_2) 182 #define ADC_REPEATED_SEQOFCHANNELS (ADCCONSEQ_3) 190 #define ADC_COMPLETECONVERSION false 191 #define ADC_PREEMPTCONVERSION true 199 #define ADC_RESOLUTION_8BIT (0x0000) 200 #define ADC_RESOLUTION_10BIT (0x0010) 201 #define ADC_RESOLUTION_12BIT (0x0020) 209 #define ADC_NONINVERTEDSIGNAL (!(ADCISSH)) 210 #define ADC_INVERTEDSIGNAL (ADCISSH) 218 #define ADC_UNSIGNED_BINARY (!(ADCDF)) 219 #define ADC_SIGNED_2SCOMPLEMENT (ADCDF) 227 #define ADC_MAXSAMPLINGRATE_200KSPS (!(ADCSR)) 228 #define ADC_MAXSAMPLINGRATE_50KSPS (ADCSR) 236 #define ADC_NOTBUSY (0x00) 237 #define ADC_BUSY (ADCBUSY) 311 extern void ADC_init(uint16_t baseAddress,
312 uint16_t sampleHoldSignalSourceSelect,
313 uint8_t clockSourceSelect,
314 uint16_t clockSourceDivider);
390 uint16_t clockCycleHoldCount,
391 uint16_t multipleSamplesEnabled);
463 uint8_t inputSourceSelect,
464 uint8_t positiveRefVoltageSourceSelect,
465 uint8_t negativeRefVoltageSourceSelect);
499 uint16_t interruptMask);
533 uint16_t interruptMask);
569 uint16_t interruptFlagMask);
603 uint8_t interruptFlagMask);
649 uint16_t conversionSequenceModeSelect);
723 uint16_t resolutionSelect);
749 uint16_t invertedSignal);
774 uint16_t readBackFormat);
797 uint16_t samplingRateSelect);
818 uint16_t highThreshold,
819 uint16_t lowThreshold);
849 extern uint8_t
ADC_isBusy(uint16_t baseAddress);
856 #define ADC_INPUT_VEREF_N ADC_INPUT_A0 857 #define ADC_INPUT_VEREF_P ADC_INPUT_A1 869 #endif // __MSP430WARE_ADC_H__ void ADC_clearInterrupt(uint16_t baseAddress, uint16_t interruptFlagMask)
Clears ADC10B selected interrupt flags.
Definition: adc.c:111
void ADC_setResolution(uint16_t baseAddress, uint16_t resolutionSelect)
Use to change the resolution of the converted data.
Definition: adc.c:154
void ADC_setDataReadBackFormat(uint16_t baseAddress, uint16_t readBackFormat)
Use to set the read-back format of the converted data.
Definition: adc.c:168
void ADC_disable(uint16_t baseAddress)
Disables the ADC block.
Definition: adc.c:47
void ADC_setReferenceBufferSamplingRate(uint16_t baseAddress, uint16_t samplingRateSelect)
Use to set the reference buffer's sampling rate.
Definition: adc.c:175
void ADC_setSampleHoldSignalInversion(uint16_t baseAddress, uint16_t invertedSignal)
Use to invert or un-invert the sample/hold signal.
Definition: adc.c:161
uint32_t ADC_getMemoryAddressForDMA(uint16_t baseAddress)
Returns the address of the memory buffer for the DMA module.
Definition: adc.c:190
void ADC_configureMemory(uint16_t baseAddress, uint8_t inputSourceSelect, uint8_t positiveRefVoltageSourceSelect, uint8_t negativeRefVoltageSourceSelect)
Configures the controls of the selected memory buffer.
Definition: adc.c:69
void ADC_startConversion(uint16_t baseAddress, uint16_t conversionSequenceModeSelect)
Enables/Starts an Analog-to-Digital Conversion.
Definition: adc.c:123
void ADC_setWindowComp(uint16_t baseAddress, uint16_t highThreshold, uint16_t lowThreshold)
Sets the high and low threshold for the window comparator feature.
Definition: adc.c:182
void ADC_enableInterrupt(uint16_t baseAddress, uint16_t interruptMask)
Enables selected ADC interrupt sources.
Definition: adc.c:99
void ADC_setupSamplingTimer(uint16_t baseAddress, uint16_t clockCycleHoldCount, uint16_t multipleSamplesEnabled)
Sets up and enables the Sampling Timer Pulse Mode.
Definition: adc.c:53
void ADC_init(uint16_t baseAddress, uint16_t sampleHoldSignalSourceSelect, uint8_t clockSourceSelect, uint16_t clockSourceDivider)
Initializes the ADC Module.
Definition: adc.c:21
int16_t ADC_getResults(uint16_t baseAddress)
Returns the raw contents of the specified memory buffer.
Definition: adc.c:149
uint8_t ADC_getInterruptStatus(uint16_t baseAddress, uint8_t interruptFlagMask)
Returns the status of the selected memory interrupt flags.
Definition: adc.c:117
void ADC_disableSamplingTimer(uint16_t baseAddress)
Disables Sampling Timer Pulse Mode.
Definition: adc.c:64
void ADC_disableConversions(uint16_t baseAddress, bool preempt)
Disables the ADC from converting any more signals.
Definition: adc.c:134
uint8_t ADC_isBusy(uint16_t baseAddress)
Returns the busy status of the ADC core.
Definition: adc.c:195
void ADC_enable(uint16_t baseAddress)
Enables the ADC block.
Definition: adc.c:41
void ADC_disableInterrupt(uint16_t baseAddress, uint16_t interruptMask)
Disables selected ADC interrupt sources.
Definition: adc.c:105