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

interface MSP430ADC12Multiple

Commands
command result_t bind(MSP430ADC12Settings_t settings) Binds the interface instance to the values specified in settings.
command msp430ADCresult_t getData(uint16_t *buf, uint16_t length, uint16_t jiffies) Initiates a series of, i.e.
command msp430ADCresult_t getDataRepeat(uint16_t *buf, uint8_t length, uint16_t jiffies) Initiates a sequence of conversions in repeat mode.
command void pauseSampling() Pause current sampling.
command result_t reserve(uint16_t *buf, uint16_t length, uint16_t jiffies) Reserves the ADC for one single conversion.
command result_t reserveRepeat(uint16_t *buf, uint16_t length, 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 uint16_t *dataReady(uint16_t *buf, uint16_t length) Conversion results from call to getData or getDataRepeat are 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(uint16_t *buf, uint16_t length, uint16_t jiffies)

Initiates a series of, i.e. multiple successive conversions. The size of a series must match and is only bounded by the size of the buffer. There is one event dataReady after the buffer is filled with conversion results. 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, ADC_QUEUED is returned and the conversion process starts as soon as VREF becomes stable (max. 17ms).

Parameters:
buf - Buffer to store the conversion results. Ignored if reserve was called successfully before, because then those settings are applicable.
length - The size of the buffer and number of conversions. Ignored if reserve was called successfully before, because then those settings are applicable.
jiffies - TimerA clock ticks between the single conversions of the series. Ignored if reserve was called successfully before, because then those settings are applicable.
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 *buf, uint8_t length, uint16_t jiffies)

Initiates a sequence of conversions in repeat mode. The size of a sequence is less or equal 16. The event dataReadyRepeat will be signalled after each sequence of conversions has finished. Successive conversions within the sequence 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, ADC_QUEUED is returned and the conversion process starts as soon as VREF becomes stable (max. 17ms). Repeat mode is stopped when the eventhandler dataReadyRepeat returns a nullpointer.

Parameters:
buf - Buffer to store the conversion results.
length - The size of the buffer and number of conversions, must be <= 16
Returns:
MSP430ADC12_FAIL the adc is busy MSP430ADC12_SUCCESS successfully triggered 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(uint16_t *buf, uint16_t length, uint16_t jiffies)

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 *buf, uint16_t length, 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 uint16_t *dataReady(uint16_t *buf, uint16_t length)

Conversion results from call to getData or getDataRepeat are ready. In the first case the returned value is ignored, in the second it points to the buffer where the next sequence of conversions is to be stored.

Parameters:
buf - Buffer address of conversion results, it is identical to the buf passed to getData or getDataRepeat. In each word the lower 12 bits are the actual result and the upper 4 bits are zero.
length - The size of the buffer and number of conversions, it is identical to the length passed to getData or getDataRepeat.
Returns:
Points to the buffer where to store the next sequence of conversions. The buffer must be of size length, it can, of course, be identical to buf (then the previous results will be overwritten). A return value of 0 (nullpointer) will stop repeat mode, so that no further conversions are performed.