Interface: moteiv.tos.platform.msp430.adc.MSP430ADC12Single

interface MSP430ADC12Single

Commands
command result_t bind(MSP430ADC12Settings_t settings) Binds the interface instance to the values specified in settings.
command msp430ADCresult_t getData() Initiates one single conversion.
command msp430ADCresult_t getDataRepeat(uint16_t jiffies) Initiates conversions in repeat mode, ie.
command void pauseSampling() Pause current sampling.
command result_t reserve() Reserves the ADC for one single conversion.
command result_t reserveRepeat(uint16_t jiffies) Reserves the ADC for repeated conversions.
command void resumeSampling() Resume current sampling after it has been paused.
command msp430ADCresult_t startSampling(uint16_t jiffies) Start sampling the ADC.
command void stopSampling() Stop current sampling.
command result_t unreserve() Cancels the reservation made by reserve or reserveRepeat.

Events
event result_t dataReady(uint16_t data) Conversion result from call to getData or getDataRepeat is ready.

Commands - Details

bind

command result_t bind(MSP430ADC12Settings_t settings)

Binds the interface instance to the values specified in settings. This command must be called once before the first call to getData or getDataRepeat is made (a good spot is StdControl.init). It can also be used to change settings later on.

Returns:
FAIL if interface parameter is out of bounds or conversion in progress for this interface, SUCCESS otherwise

getData

command msp430ADCresult_t getData()

Initiates one single conversion. After the conversion is performed the event dataReady is signalled with the conversion result. If VREF was chosen as reference voltage in bind and the voltage generator has not yet reached a stable level, MSP430ADC12_DELAYED is returned and the conversion process starts as soon as VREF becomes stable (max. 17ms).

Returns:
MSP430ADC12_FAIL the adc is busy MSP430ADC12_SUCCESS successfully triggered conversion MSP430ADC12_DELAYED conversion starts as soon as VREF becomes stable.

getDataRepeat

command msp430ADCresult_t getDataRepeat(uint16_t jiffies)

Initiates conversions in repeat mode, ie. continuously. After each conversion is performed an event dataReady is signalled with the conversion result until the eventhandler returns FAIL. Successive conversions are performed as quickly as possible if jiffies equals zero. Otherwise jiffies define the time between successive conversions in terms of clock ticks of settings.clockSourceSAMPCON and input divider settings.clockDivSAMPCON specified in bind(). If VREF was chosen as reference voltage in bind and the voltage generator has not yet reached a stable level, MSP430ADC12_DELAYED is returned and the conversion process starts as soon as VREF becomes stable (max. 17ms).

Returns:
MSP430ADC12_FAIL the adc is busy MSP430ADC12_SUCCESS successfully triggered first conversion MSP430ADC12_DELAYED conversion starts as soon as VREF becomes stable.

pauseSampling

command void pauseSampling()

Pause current sampling. If sampling is in process, it is halted. To be used in conjunction with resumeSampling and the DMA controller. Does NOT release timer resource, so it should be used only when you expect to resume very soon. This command should be used to pause the ADC's current operation while the DMA is loaded with new settings. Do NOT use pauseSampling() without the DMA

reserve

command result_t reserve()

Reserves the ADC for one single conversion. If this call succeeds the next call to getData will also succeed and the corresponding conversion will then be started with a minimum latency. Until then all other commands will fail.

Returns:
SUCCESS reservation successful FAIL otherwise

reserveRepeat

command result_t reserveRepeat(uint16_t jiffies)

Reserves the ADC for repeated conversions. If this call succeeds the next call to getDataRepeat/code> will also succeed and the corresponding conversion will then be started with a minimum latency. Until then all other commands will fail.

Returns:
SUCCESS reservation successful FAIL otherwise

resumeSampling

command void resumeSampling()

Resume current sampling after it has been paused. Pause and resume are designed to be as lightweight as possible so that as few adc samples as possible (if any) are lost between a pause and resume. This command should resume sampling after giving the DMA controller a new buffer to store the results. Do NOT use resumeSampling() without the DMA

startSampling

command msp430ADCresult_t startSampling(uint16_t jiffies)

Start sampling the ADC. SMCLK is used for the sampling, so 1 jiffy = 1 us on msp430 platforms startSampling() should be used INSTEAD of getData() when the msp430 ADC is used in conjunction with the DMA (ie, no need for the ADC dataReady() events because the DMA will handle them instead) Do NOT use startSampling() without the DMA @ return MSP430ADC12_SUCCESS if sampling commences

stopSampling

command void stopSampling()

Stop current sampling. If sampling is in process, it is halted. To be used in conjunction with startSampling and the DMA controller Do NOT use stopSampling() without the DMA

unreserve

command result_t unreserve()

Cancels the reservation made by reserve or reserveRepeat.

Returns:
SUCCESS un-reservation successful FAIL no reservation active

Events - Details

dataReady

event result_t dataReady(uint16_t data)

Conversion result from call to getData or getDataRepeat is ready. In the first case the returned value is ignored, in the second it defines whether any further conversions will be made or not.

Parameters:
data - The conversion result. The lower 12 bits are the actual result and the upper 4 bits are zero.
Returns:
SUCCESS continues sampling in repeat mode FAIL stops further conversions in repeat mode