uMIDI
The swiss army knife for quick and easy developement of MIDI applications.
|
ADC configuration and service functions. More...
Go to the source code of this file.
Data Structures | |
struct | adc_conversion_config |
ADC conversion configuration. More... | |
struct | adc_config |
ADC configuration common to all conversions. More... | |
Macros | |
#define | ADC_RESOLUTION 12 |
ADC resolution in bits. More... | |
#define | ADC_SAMPLE_BUFFER_SIZE (1 << (8*sizeof(adc_accumulator) - ADC_RESOLUTION)) |
Size of the sample buffer for mean value computations. More... | |
Typedefs | |
typedef uint16_t | adc_accumulator |
Data type for ADC mean value computations. More... | |
Enumerations | |
enum | adc_conversion_mode { ADC_MODE_UNSIGNED = 0x0, ADC_MODE_SIGNED = 0x1 } |
ADC conversion mode. More... | |
enum | adc_channel { ADC_CHANNEL_0 = 0, ADC_CHANNEL_1 = 1, ADC_CHANNEL_2 = 2, ADC_CHANNEL_3 = 3 } |
ADC channel. More... | |
enum | adc_input { ADC_INPUT_0 = ADC_CH_MUXPOS_PIN0_gc, ADC_INPUT_1 = ADC_CH_MUXPOS_PIN1_gc, ADC_INPUT_2 = ADC_CH_MUXPOS_PIN2_gc, ADC_INPUT_3 = ADC_CH_MUXPOS_PIN3_gc, ADC_INPUT_4 = ADC_CH_MUXPOS_PIN4_gc, ADC_INPUT_5 = ADC_CH_MUXPOS_PIN5_gc, ADC_INPUT_6 = ADC_CH_MUXPOS_PIN6_gc, ADC_INPUT_7 = ADC_CH_MUXPOS_PIN7_gc } |
ADC input pin. More... | |
Functions | |
uint16_t | calibrate_adc_offset (enum adc_channel channel) |
Calibrates the ADC offset using the given channel. More... | |
void | disable_adc_interrupt (enum adc_channel channel) |
Disables the interrupt for an ADC channel. More... | |
void | enable_adc_interrupt (enum adc_channel channel) |
Enables the interrupt for an ADC channel. More... | |
void | init_adc_conversion (const struct adc_conversion_config *config) |
Sets up an ADC conversion. More... | |
void | init_adc_module (const struct adc_config *config) |
Initializes and calibrates the ADC. More... | |
void | set_adc_channel0_max_value (void) |
Defines the current ADC value as MIDI max value. More... | |
void | set_adc_channel0_min_value (void) |
Defines the current ADC value as MIDI min value. More... | |
void | set_adc_offset (uint16_t offset) |
Sets the ADC offset. More... | |
void | trigger_adc (enum adc_channel channel) |
Triggers a conversion for the given channel. More... | |
ADC configuration and service functions.
#define ADC_RESOLUTION 12 |
ADC resolution in bits.
#define ADC_SAMPLE_BUFFER_SIZE (1 << (8*sizeof(adc_accumulator) - ADC_RESOLUTION)) |
Size of the sample buffer for mean value computations.
typedef uint16_t adc_accumulator |
Data type for ADC mean value computations.
enum adc_channel |
ADC channel.
Channel 0 is reserved for MIDI values
Enumerator | |
---|---|
ADC_CHANNEL_0 | ADC channel 0. |
ADC_CHANNEL_1 | ADC channel 1. |
ADC_CHANNEL_2 | ADC channel 2. |
ADC_CHANNEL_3 | ADC channel 3. |
enum adc_conversion_mode |
enum adc_input |
uint16_t calibrate_adc_offset | ( | enum adc_channel | channel | ) |
Calibrates the ADC offset using the given channel.
channel | the ADC channel |
|
inline |
Disables the interrupt for an ADC channel.
channel | the ADC channel |
|
inline |
Enables the interrupt for an ADC channel.
channel | the ADC channel |
void init_adc_conversion | ( | const struct adc_conversion_config * | config | ) |
Sets up an ADC conversion.
Registers the callbacks, configures the input and performs a dummy-conversion. The GPIO pin is not configured here – this must be done through the GPIO module.
config | the ADC conversion configuration |
void init_adc_module | ( | const struct adc_config * | config | ) |
Initializes and calibrates the ADC.
Selects the voltage reference, sets the clock prescaler and conversion mode and calibrates the ADC
config | the shared ADC configuration |
void set_adc_channel0_max_value | ( | void | ) |
Defines the current ADC value as MIDI max value.
void set_adc_channel0_min_value | ( | void | ) |
Defines the current ADC value as MIDI min value.
void set_adc_offset | ( | uint16_t | offset | ) |
Sets the ADC offset.
offset | the offset |
void trigger_adc | ( | enum adc_channel | channel | ) |
Triggers a conversion for the given channel.
channel | the ADC channel |