Interface: tos.chips.msp430.adc12.Msp430Adc12SingleChannel
interface Msp430Adc12SingleChannel
This interface provides access to the ADC12 on the level of HAL. It can be
used to sample a single adc channel once or repeatedly (one event is
signalled per conversion result) or perform multiple conversions for a
single channel once or repeatedly (one event is signalled per multiple
conversion results). It cannot be used to sample different adc channels with
a single command (use the Msp430Adc12MultiChannel interface instead).
Sampling a channel requires calling a sequence of two commands, configureX()
and getData(), where X is either 'Single', 'SingleRepeat', 'Multiple' or
'MultipleRepeat'. Conversion results will be signalled by the
dataReadySingle() or dataReadyMultiple() event, depending on the previous
configuration, i.e. there are four possible sequences:
configureSingle() -> ( getData() -> singleDataReady() )*
configureSingleRepeat() -> ( getData() -> singleDataReady() )*
configureMultiple() -> ( getData() -> multipleDataReady() )*
configureMultipleRepeat() -> getData() -> multipleDataReady()
where configureX() and getData() are commands called by the client and
singleDataReady() and multipleDataReady() are events signalled back to the
client by the adc subsystem. Note that a configuration is valid until the
client reconfigures or releases the ADC (using the Resource interface),
except for configureMultipleRepeat(), which is only valid for a single call
to getData(). This means that after a successful configuration with, for
example, configureSingle() 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).
- Author:
-
Jan Hauer
Commands
command error_t configureMultiple(msp430adc12_channel_config_t *config, uint16_t *buffer, uint16_t numSamples, uint16_t jiffies)
command error_t configureMultipleRepeat(msp430adc12_channel_config_t *config, uint16_t *buffer, uint8_t numSamples, uint16_t jiffies)
command error_t configureSingle(msp430adc12_channel_config_t *config)
command error_t configureSingleRepeat(msp430adc12_channel_config_t *config, uint16_t jiffies)
command error_t getData()
Events
event uint16_t *multipleDataReady(uint16_t *buffer, uint16_t numSamples)
event error_t singleDataReady(uint16_t data)
Commands - Details
configureMultiple
command error_t configureMultiple(msp430adc12_channel_config_t *config, uint16_t *buffer, uint16_t numSamples, uint16_t jiffies)
- Parameters:
-
config - ADC12 configuration data.
-
jiffies - Sampling period in terms of clock ticks of "sampcon_ssel"
and input divider "sampcon_id".
-
buffer - The user-allocated buffer in which the conversion results
will be stored. It must have at least numSamples entries,
i.e. it must have a size of at least numSamples * 2 byte.
-
numSamples - Number of adc samples
- Returns:
-
SUCCESS means that the ADC was configured successfully and
getData() can be called to start with the first conversion.
configureMultipleRepeat
command error_t configureMultipleRepeat(msp430adc12_channel_config_t *config, uint16_t *buffer, uint8_t numSamples, uint16_t jiffies)
- Parameters:
-
config - ADC12 configuration data.
-
jiffies - Sampling period in terms of clock ticks of "sampcon_ssel"
and input divider "sampcon_id".
-
buffer - The user-allocated buffer in which the conversion results
will be stored. It must have at least numSamples entries,
i.e. it must have a size of at least numSamples * 2 byte.
-
numSamples - Number of adc samples to take, 0 <
numSamples <= 16
- Returns:
-
SUCCESS means that the ADC was configured successfully and
getData() can be called to start with the first conversion.
configureSingle
command error_t configureSingle(msp430adc12_channel_config_t *config)
- Parameters:
-
config - ADC12 configuration data.
- Returns:
-
SUCCESS means that the ADC was configured successfully and
getData() can be called to start the conversion.
configureSingleRepeat
command error_t configureSingleRepeat(msp430adc12_channel_config_t *config, uint16_t jiffies)
- Parameters:
-
config - ADC12 configuration data.
-
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 with the first conversion.
getData
command error_t getData()
- Returns:
-
SUCCESS means that the conversion was started successfully and an
event singleDataReady() or multipleDataReady() will be signalled
(depending on the previous configuration). Otherwise no such event will be
signalled.
Events - Details
multipleDataReady
event uint16_t *multipleDataReady(uint16_t *buffer, uint16_t numSamples)
- Parameters:
-
buffer - Conversion results (lower 12 bit are valid, respectively).
-
numSamples - Number of samples stored in buffer
- Returns:
-
A null pointer stops a repeated conversion mode. Any non-zero value is
interpreted as the next buffer, which must have at least
numSamples entries. The return value is ignored if the ADC
was configured with configureMultiple().
singleDataReady
event error_t singleDataReady(uint16_t data)
- Parameters:
-
data - Conversion result (lower 12 bit).
- Returns:
-
If this event is signalled as response to a call to
configureSingleRepeat() then SUCCESS results in
another sampling and FAIL stops the repeated sampling.
Otherwise the return value is ignored.