#include <stddef.h>
#include "compiler.h"
#include "pwm_dac.h"
#include <avr32/io.h>
#include "intc.h"
#include "gpio.h"
#include "audio.h"
Functions | |
void | pwm_dac_decrease_volume (void) |
Decreases the output volume of the DAC. More... | |
void | pwm_dac_flush (void) |
Flushes the sample buffer being output to the DAC. More... | |
static __inline__ size_t | pwm_dac_get_log2_aligned_byte_size (size_t bit_size) |
Returns the logarithm to base 2 of the aligned byte size required to store the bit_size bit size saturated to the range [|8, 32|]. More... | |
static int16_t | pwm_dac_get_sample_16_bits (void) |
Generates a 16-bit sample from a sample stored in 16 bits. More... | |
static int16_t | pwm_dac_get_sample_32_bits (void) |
Generates a 16-bit sample from a sample stored in 32 bits. More... | |
static int16_t | pwm_dac_get_sample_8_bits (void) |
Generates a 16-bit sample from a sample stored in 8 bits. More... | |
uint8_t | pwm_dac_get_volume (void) |
Return the current volume. More... | |
void | pwm_dac_increase_volume (void) |
Increases the output volume of the DAC. More... | |
bool | pwm_dac_is_volume_boosted (void) |
Returns the state of the boost mode of the DAC. More... | |
bool | pwm_dac_is_volume_muted (void) |
Returns the state of the mute mode of the DAC. More... | |
void | pwm_dac_mute (bool mute) |
Mute audio if mute set to true. More... | |
bool | pwm_dac_output (void *sample_buffer, size_t sample_length) |
Outputs a sample buffer to the DAC. More... | |
static __inline__ void | pwm_dac_output_sample (int16_t sample) |
Outputs a sample to the DAC. More... | |
static void | pwm_dac_pwm_int_handler (void) |
PWM interrupt handler managing the DAC. More... | |
void | pwm_dac_set_volume (uint8_t volume) |
Set the current volume. More... | |
void | pwm_dac_setup (uint32_t sample_rate_hz, uint8_t num_channels, uint8_t bits_per_sample, bool swap_channels, void(*callback)(uint32_t arg), uint32_t callback_opt, uint32_t pba_hz) |
Sets the DAC up with new settings. More... | |
void | pwm_dac_start (uint32_t sample_rate_hz, uint8_t num_channels, uint8_t bits_per_sample, bool swap_channels, void(*callback)(uint32_t arg), uint32_t callback_opt, uint32_t pba_hz) |
Starts the DAC. More... | |
void | pwm_dac_stop (void) |
Stops the DAC. More... | |
Variables | |
static int16_t(*const | PWM_DAC_GET_SAMPLE [])(void) |
Table of pointers to the functions generating 16-bit samples from stored samples. More... | |
struct { | |
uint8_t bits_per_sample | |
void(* callback )(uint32_t arg) | |
uint32_t callback_opt | |
bool flushing | |
int16_t(* get_sample )(void) | |
uint8_t num_channels | |
volatile UnionPtr reload_sample_buffer | |
volatile size_t reload_sample_length | |
volatile UnionPtr sample_buffer | |
volatile size_t sample_length | |
bool swap_channels | |
uint8_t volume_shift | |
} | pwm_dac_output_params |
Output parameters. More... | |
static const gpio_map_t | PWM_DAC_PWM_GPIO_MAP |
Map of the PWM pins used by the PWM DAC. More... | |
|
static |
Returns the logarithm to base 2 of the aligned byte size required to store the bit_size bit size saturated to the range [|8, 32|].
Referenced by pwm_dac_output(), and pwm_dac_setup().
|
static |
Generates a 16-bit sample from a sample stored in 16 bits.
References pwm_dac_output_params.
|
static |
Generates a 16-bit sample from a sample stored in 32 bits.
References pwm_dac_output_params.
|
static |
Generates a 16-bit sample from a sample stored in 8 bits.
References pwm_dac_output_params.
|
static |
Outputs a sample to the DAC.
References PWM_DAC_PWM_CHANNEL_LSB, and PWM_DAC_PWM_CHANNEL_MSB.
Referenced by pwm_dac_flush(), pwm_dac_pwm_int_handler(), and pwm_dac_start().
|
static |
PWM interrupt handler managing the DAC.
References AUDIO_DAC_OUT_OF_SAMPLE_CB, AUDIO_DAC_RELOAD_CB, pwm_dac_output_params, pwm_dac_output_sample(), PWM_DAC_PWM_CHANNEL_LSB, and PWM_DAC_PWM_CHANNEL_MSB.
Referenced by pwm_dac_start().
uint8_t bits_per_sample |
void(* callback)(uint32_t arg) |
uint32_t callback_opt |
bool flushing |
int16_t(* get_sample)(void) |
uint8_t num_channels |
|
static |
Table of pointers to the functions generating 16-bit samples from stored samples.
Referenced by pwm_dac_setup().
struct { ... } pwm_dac_output_params |
Output parameters.
Referenced by pwm_dac_decrease_volume(), pwm_dac_flush(), pwm_dac_get_sample_16_bits(), pwm_dac_get_sample_32_bits(), pwm_dac_get_sample_8_bits(), pwm_dac_get_volume(), pwm_dac_increase_volume(), pwm_dac_output(), pwm_dac_pwm_int_handler(), pwm_dac_set_volume(), pwm_dac_setup(), and pwm_dac_stop().
|
static |
Map of the PWM pins used by the PWM DAC.
volatile UnionPtr reload_sample_buffer |
volatile size_t reload_sample_length |
volatile UnionPtr sample_buffer |
Referenced by aic23b_dac_output(), buff_player_malloc(), buff_player_put_pcm_buf(), and pwm_dac_output().
volatile size_t sample_length |
Referenced by buff_player_malloc(), buff_player_put_pcm_buf(), and pwm_dac_output().
bool swap_channels |
uint8_t volume_shift |