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)
command error_t getData()
Events
event void dataReady(uint16_t *buffer, uint16_t numSamples)
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)
- 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()
- 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)
- Parameters:
-
buffer - Conversion results (lower 12 bit are valid, respectively).
-
numSamples - Number of results stored in buffer