WISP ERT (Client)  1.0.0
The WISP Extended Runtime (WISP side)
adc.h File Reference
#include <stdint.h>
#include <msp430.h>

Go to the source code of this file.

Enumerations

enum  ADC_referenceSelect { ADC_reference_1_2V = REFVSEL_0, ADC_reference_2_0V = REFVSEL_1, ADC_reference_2_5V = REFVSEL_2 }
 
enum  ADC_precisionSelect { ADC_precision_8bit = ADC12RES__8BIT, ADC_precision_10bit = ADC12RES__10BIT, ADC_precision_12bit = ADC12RES__12BIT }
 
enum  ADC_inputSelect {
  ADC_input_temperature, ADC_input_A0 = ADC12INCH_0, ADC_input_A1 = ADC12INCH_1, ADC_input_A2 = ADC12INCH_2,
  ADC_input_A3 = ADC12INCH_3, ADC_input_A4 = ADC12INCH_4, ADC_input_A5 = ADC12INCH_5, ADC_input_A6 = ADC12INCH_6,
  ADC_input_A7 = ADC12INCH_7, ADC_input_A8 = ADC12INCH_8, ADC_input_A9 = ADC12INCH_9, ADC_input_A10 = ADC12INCH_10,
  ADC_input_A11 = ADC12INCH_11, ADC_input_A12 = ADC12INCH_12, ADC_input_A13 = ADC12INCH_13, ADC_input_A14 = ADC12INCH_14,
  ADC_input_A15 = ADC12INCH_15, ADC_input_A16 = ADC12INCH_16, ADC_input_A17 = ADC12INCH_17, ADC_input_A18 = ADC12INCH_18,
  ADC_input_A19 = ADC12INCH_19, ADC_input_A20 = ADC12INCH_20, ADC_input_A21 = ADC12INCH_21, ADC_input_A22 = ADC12INCH_22,
  ADC_input_A23 = ADC12INCH_23, ADC_input_A24 = ADC12INCH_24, ADC_input_A25 = ADC12INCH_25, ADC_input_A26 = ADC12INCH_26,
  ADC_input_A27 = ADC12INCH_27, ADC_input_A28 = ADC12INCH_28, ADC_input_A29 = ADC12INCH_29, ADC_input_A30 = ADC12INCH_30,
  ADC_input_A31 = ADC12INCH_31
}
 

Functions

void ADC_init (void)
 
void ADC_initCustom (ADC_referenceSelect, ADC_precisionSelect, ADC_inputSelect)
 
uint16_t ADC_read (void)
 
void ADC_asyncRead (void(*)(uint16_t))
 
uint16_t ADC_critRead (void)
 
uint16_t ADC_rawCorrection (uint16_t)
 
uint16_t ADC_rawToVoltage (uint16_t)
 
int16_t ADC_rawToTemperature (uint16_t)
 
uint8_t ADC_isBusy (void)
 
uint8_t ADC_isReady (void)
 
void ADC_enable (void)
 
void ADC_disable (void)
 
void ADC_enableConversion (void)
 
void ADC_disableConversion (void)
 
void ADC_enableInterrupts (void)
 
void ADC_disableInterrupts (void)
 
void ADC_setReference (ADC_referenceSelect)
 
ADC_referenceSelect ADC_getReference (void)
 
void ADC_setPrecision (ADC_precisionSelect)
 
ADC_precisionSelect ADC_getPrecision (void)
 
void ADC_setInputChannel (ADC_inputSelect)
 
ADC_inputSelect ADC_getInputChannel (void)
 
void ADC_setSampleHold (void)
 

Enumeration Type Documentation

◆ ADC_inputSelect

ADC input channel, for now only external analog inputs

Enumerator
ADC_input_temperature 
ADC_input_A0 
ADC_input_A1 
ADC_input_A2 
ADC_input_A3 
ADC_input_A4 
ADC_input_A5 
ADC_input_A6 
ADC_input_A7 
ADC_input_A8 
ADC_input_A9 
ADC_input_A10 
ADC_input_A11 
ADC_input_A12 
ADC_input_A13 
ADC_input_A14 
ADC_input_A15 
ADC_input_A16 
ADC_input_A17 
ADC_input_A18 
ADC_input_A19 
ADC_input_A20 
ADC_input_A21 
ADC_input_A22 
ADC_input_A23 
ADC_input_A24 
ADC_input_A25 
ADC_input_A26 
ADC_input_A27 
ADC_input_A28 
ADC_input_A29 
ADC_input_A30 
ADC_input_A31 

◆ ADC_precisionSelect

ADC precision (see user guide 25.3.3)

Enumerator
ADC_precision_8bit 
ADC_precision_10bit 
ADC_precision_12bit 

◆ ADC_referenceSelect

ADC reference voltage selection (see user guide 24.2.2.2 and 25.2.3)

Enumerator
ADC_reference_1_2V 
ADC_reference_2_0V 
ADC_reference_2_5V 

Function Documentation

◆ ADC_asyncRead()

void ADC_asyncRead ( void(*)(uint16_t)  callback)

Asynchronously read ADC. Do not block, call callback when done.

Parameters
callbackfunction to be called after conversion finishes

◆ ADC_critRead()

uint16_t ADC_critRead ( void  )

Critical ADC read. Does block, does not use interrupts.

◆ ADC_disable()

void ADC_disable ( void  )

Disable the ADC12_B peripheral.

◆ ADC_disableConversion()

void ADC_disableConversion ( void  )

Disable ADC conversions.

◆ ADC_disableInterrupts()

void ADC_disableInterrupts ( void  )

Disable all ADC interrupts.

◆ ADC_enable()

void ADC_enable ( void  )

Enable the ADC12_B peripheral.

◆ ADC_enableConversion()

void ADC_enableConversion ( void  )

Enable ADC conversions.

◆ ADC_enableInterrupts()

void ADC_enableInterrupts ( void  )

Enable ADC interrupts.

◆ ADC_getInputChannel()

ADC_inputSelect ADC_getInputChannel ( void  )

Get currently set input channel.

◆ ADC_getPrecision()

ADC_precisionSelect ADC_getPrecision ( void  )

Get currently set conversion precision.

◆ ADC_getReference()

ADC_referenceSelect ADC_getReference ( void  )

Get currently set voltage reference.

◆ ADC_init()

void ADC_init ( void  )

Configure the ADC12_B module in single channel single measurement mode and prepare for measurement.

◆ ADC_initCustom()

void ADC_initCustom ( ADC_referenceSelect  reference,
ADC_precisionSelect  precision,
ADC_inputSelect  channel 
)

Configure the ADC12_B module in single channel single measurement mode and prepare for measurement.

Parameters
referencevoltage reference source
precisionADC measurement precision
channelADC input channel

◆ ADC_isBusy()

uint8_t ADC_isBusy ( void  )

Return true if ADC module is in the middle of a conversion, false if not.

◆ ADC_isReady()

uint8_t ADC_isReady ( void  )

Return false if ADC module is in the middle of a conversion, true if not.

◆ ADC_rawCorrection()

uint16_t ADC_rawCorrection ( uint16_t  raw)

Correct RAW ADC reading according to calibration procedure

See user guide 1.14.3.2

Parameters
rawRAW ADC value
Returns
corrected RAW ADC value

◆ ADC_rawToTemperature()

int16_t ADC_rawToTemperature ( uint16_t  raw)

Convert RAW ADC reading to milli degree Celcius.

Parameters
rawRAW ADC value
Returns
temperature in milli degree Celcius (e.g. 1 ~ .001C)

◆ ADC_rawToVoltage()

uint16_t ADC_rawToVoltage ( uint16_t  raw)

Convert RAW ADC reading to MilliVolts.

Based on formula (see user guide 25.2.1): Nadc = 4096 * ( (Vin + .5LSB) - Vr- ) / ( Vr+ - Vr- ) where LSB = ( Vr+ - Vr- ) / 4096

Formula converted to: Vin = (Nadc * ( Vr+ - Vr- ) ) / 4096 + Vr- - .5LSB where LSB = ( Vr+ - Vr- ) / 4096

Parameters
rawRAW ADC value
Returns
voltage in milli Volts (e.g. 1 ~ .001V)

◆ ADC_read()

uint16_t ADC_read ( void  )

Synchronously read ADC. Does block.

◆ ADC_setInputChannel()

void ADC_setInputChannel ( ADC_inputSelect  channel)

Set ADC input channel and single channel-single conversion mode.

Possible channels: analog input pins A0-A31 and internal temperature sensor.

Parameters
channelthe wanted channel.

◆ ADC_setPrecision()

void ADC_setPrecision ( ADC_precisionSelect  precision)

Set ADC conversion precision.

Parameters
precisionthe wanted precision.

◆ ADC_setReference()

void ADC_setReference ( ADC_referenceSelect  reference)

Set voltage reference and make the ADC to use it.

Parameters
referencethe wanted reference voltage.

◆ ADC_setSampleHold()

void ADC_setSampleHold ( void  )

Set ADC to sample and hold pulse mode.