Interface: tos.chips.msp430.adc12.Msp430Adc12MultiChannel

interface Msp430Adc12MultiChannel

This interface provides access to the ADC12 on the level of HAL. It can be used to sample up to 16 (different) ADC channels. It separates between configuration and data collection: every time a client has been granted access to the ADC subsystem (via the Resource interface), it first has to configure the ADC. Afterwards the client may call getData() more than once without reconfiguring the ADC in between (if the client has not released the ADC via the Resource interface), i.e.

configure() -> ( getData() -> dataReady() )*

Author:
Jan Hauer

Commands
command error_t configure(msp430adc12_channel_config_t *config, adc12memctl_t *memctl, uint8_t numMemctl, uint16_t *buffer, uint16_t numSamples, uint16_t jiffies) Configures the ADC to perform conversion(s) on multiple channels.
command error_t getData() Starts sampling the adc channels using the configuration as specified by the last call to configure().

Events
event void dataReady(uint16_t *buffer, uint16_t numSamples) Conversion results are ready.

Commands - Details

configure

command error_t configure(msp430adc12_channel_config_t *config, adc12memctl_t *memctl, uint8_t numMemctl, uint16_t *buffer, uint16_t numSamples, uint16_t jiffies)

Configures the ADC to perform conversion(s) on multiple channels. Any previous configuration will be overwritten. If SUCCESS is returned calling getData() will start the conversion immediately and a dataReady() event will be signalled with the conversion result when the conversion has finished.

Parameters:
config - Main ADC12 configuration and configuration of the first channel
memctl - List of additional channels and respective reference voltages
numMemctl - Number of entries in the list
buffer - Buffer to store the conversion results, it must have numSamples entries. Results will be stored in the order the channels where specified.
numSamples - Total number of samples. Note: numSamples % (numMemctl+1) must be zero. For example, to sample every channel twice use numSamples = (numMemctl+1) * 2
jiffies - Sampling period in terms of clock ticks of "sampcon_ssel" and input divider "sampcon_id".
Returns:
SUCCESS means that the ADC was configured successfully and getData() can be called to start the conversion.

getData

command error_t getData()

Starts sampling the adc channels using the configuration as specified by the last call to configure().

Returns:
SUCCESS means that the conversion was started successfully and an event dataReady() will be signalled. Otherwise no event will be signalled.

Events - Details

dataReady

event void dataReady(uint16_t *buffer, uint16_t numSamples)

Conversion results are ready. Results are stored in the buffer in the order the channels where specified in the configure() command, i.e. every (numMemctl+1)-th entry maps to the same channel.

Parameters:
buffer - Conversion results (lower 12 bit are valid, respectively).
numSamples - Number of results stored in buffer