#include <avr32/io.h>
#include <stdio.h>
#include "compiler.h"
#include "board.h"
#include "dsp.h"
#include "pm.h"
#include "gpio.h"
#include "usart.h"
#include "intc.h"
#include "pwm.h"
#include "flashc.h"
#include "preprocessor.h"
#include "ima_dvi_adpcm_wav.h"
Data Structures | |
struct | A_PACKED |
struct | A_PACKED |
struct | A_PACKED |
struct | A_PACKED |
struct | A_PACKED |
Macros | |
#define | BYTE unsigned char |
#define | CP_PBA_SPEED 48000000 |
The clock frequency. More... | |
#define | DAC_PWM_FREQUENCY (CP_PBA_SPEED >> 8) |
#define | DWORD unsigned long |
#define | MAX_SEARCH_LENGTH 256 |
#define | SWITCH_ENDIANNESS(width, data) (TPASTE2(Swap, width)(data)) |
#define | WAVE_FORMAT_DVI_ADPCM 0x0011 |
#define | WORD unsigned short |
USART Settings | |
#define | EXAMPLE_USART (&AVR32_USART1) |
#define | EXAMPLE_USART_RX_PIN AVR32_USART1_RXD_0_0_PIN |
#define | EXAMPLE_USART_RX_FUNCTION AVR32_USART1_RXD_0_0_FUNCTION |
#define | EXAMPLE_USART_TX_PIN AVR32_USART1_TXD_0_0_PIN |
#define | EXAMPLE_USART_TX_FUNCTION AVR32_USART1_TXD_0_0_FUNCTION |
#define | DAC_PWM_CHANNEL_LSB 1 |
#define | DAC_PWM_CHANNEL_LSB_PIN |
#define | DAC_PWM_CHANNEL_MSB 0 |
#define | DAC_PWM_CHANNEL_MSB_PIN |
Typedefs | |
typedef struct A_PACKED | s_wave_data |
typedef struct A_PACKED | s_wave_dvi_block_header |
typedef struct A_PACKED | s_wave_fmt |
typedef struct A_PACKED | s_wave_fmt_dvi |
typedef struct A_PACKED | s_wave_riff |
Functions | |
void | dac_pwm_init () |
Initialize the PWM to make it works as a DAC. More... | |
static void | dac_pwm_int_handler (void) |
The PWM interrupt handler. More... | |
int | fget_struct (const char *_data, char *_ptr, int size, char *_start_str) |
void | init_usart () |
this function initializes the USART module at 115200 bauds More... | |
int | main (int argc, char *argv[]) |
The main function. More... | |
void | print_fct (char *str) |
This function is used by the debugging module. It permits to print a string through the USART. More... | |
void | sys_cpu_48MHz (void) |
To set the clock frequency to 48MHz. More... | |
Variables | |
int | cur_i_read_buffer = 0 |
The offset of the current reading buffer. More... | |
volatile int | dac_pwm_period |
int | dac_pwm_periods_per_sample |
volatile int | get_sample = 0 |
A flag to tell if we need to play a new sample with the DAC. More... | |
A_ALIGNED short | predicted_value |
Predicted value for the adpcm decoder. More... | |
A_ALIGNED short | step_index |
Step index for the adpcm decoder. More... | |
#define BYTE unsigned char |
#define CP_PBA_SPEED 48000000 |
The clock frequency.
#define DAC_PWM_CHANNEL_LSB 1 |
Referenced by dac_pwm_init(), and main().
#define DAC_PWM_CHANNEL_LSB_PIN |
Referenced by dac_pwm_init().
#define DAC_PWM_CHANNEL_MSB 0 |
Referenced by dac_pwm_init(), and main().
#define DAC_PWM_CHANNEL_MSB_PIN |
Referenced by dac_pwm_init().
#define DAC_PWM_FREQUENCY (CP_PBA_SPEED >> 8) |
Referenced by main().
#define DWORD unsigned long |
#define EXAMPLE_USART (&AVR32_USART1) |
Referenced by init_usart(), main(), and print_fct().
#define EXAMPLE_USART_RX_FUNCTION AVR32_USART1_RXD_0_0_FUNCTION |
Referenced by init_usart().
#define EXAMPLE_USART_RX_PIN AVR32_USART1_RXD_0_0_PIN |
Referenced by init_usart().
#define EXAMPLE_USART_TX_FUNCTION AVR32_USART1_TXD_0_0_FUNCTION |
Referenced by init_usart().
#define EXAMPLE_USART_TX_PIN AVR32_USART1_TXD_0_0_PIN |
Referenced by init_usart().
#define MAX_SEARCH_LENGTH 256 |
Referenced by fget_struct().
#define WAVE_FORMAT_DVI_ADPCM 0x0011 |
Referenced by main().
#define WORD unsigned short |
typedef struct A_PACKED s_wave_data |
typedef struct A_PACKED s_wave_dvi_block_header |
typedef struct A_PACKED s_wave_fmt |
typedef struct A_PACKED s_wave_fmt_dvi |
typedef struct A_PACKED s_wave_riff |
void dac_pwm_init | ( | ) |
Initialize the PWM to make it works as a DAC.
References ATPASTE4, DAC_PWM_CHANNEL_LSB, DAC_PWM_CHANNEL_LSB_PIN, DAC_PWM_CHANNEL_MSB, DAC_PWM_CHANNEL_MSB_PIN, dac_pwm_int_handler(), gpio_enable_module(), and INTC_register_interrupt().
|
static |
int fget_struct | ( | const char * | _data, |
char * | _ptr, | ||
int | size, | ||
char * | _start_str | ||
) |
References i, j, and MAX_SEARCH_LENGTH.
Referenced by main().
void init_usart | ( | ) |
this function initializes the USART module at 115200 bauds
References usart_options_t::baudrate, EXAMPLE_USART, EXAMPLE_USART_RX_FUNCTION, EXAMPLE_USART_RX_PIN, EXAMPLE_USART_TX_FUNCTION, EXAMPLE_USART_TX_PIN, FOSC0, gpio_enable_module(), USART_1_STOPBIT, usart_init_rs232(), USART_NO_PARITY, and USART_NORMAL_CHMODE.
int main | ( | int | argc, |
char * | argv[] | ||
) |
The main function.
References A_PACKED::avg_bytes_per_sec, A_PACKED::bits_per_sample, A_PACKED::block_align, c, A_PACKED::chunk_size, A_PACKED::compression_code, cur_i_read_buffer, DAC_PWM_CHANNEL_LSB, DAC_PWM_CHANNEL_MSB, DAC_PWM_FREQUENCY, dac_pwm_init(), dac_pwm_period, dac_pwm_periods_per_sample, Disable_global_interrupt, dsp_adpcm_ima_decode_nibble(), Enable_global_interrupt, EXAMPLE_USART, A_PACKED::extra_bytes, fget_struct(), flashc_set_wait_state(), A_PACKED::fmt, get_sample, i, init_usart(), INTC_init_interrupts(), A_PACKED::isamp0, j, length, A_PACKED::nb_channels, predicted_value, A_PACKED::sample_rate, A_PACKED::samples_per_block, sound_data, sprintf(), step_index, A_PACKED::step_table_index, SWITCH_ENDIANNESS, sys_cpu_48MHz(), usart_write_line(), and WAVE_FORMAT_DVI_ADPCM.
void print_fct | ( | char * | str | ) |
This function is used by the debugging module. It permits to print a string through the USART.
str | The input string to print. |
References EXAMPLE_USART, and usart_write_line().
void sys_cpu_48MHz | ( | void | ) |
To set the clock frequency to 48MHz.
References FOSC0, OSC0_STARTUP, pm_cksel(), pm_pll_enable(), pm_pll_set_option(), pm_pll_setup(), pm_switch_to_clock(), pm_switch_to_osc0(), pm_wait_for_pll0_locked(), and TRUE.
int cur_i_read_buffer = 0 |
The offset of the current reading buffer.
volatile int dac_pwm_period |
int dac_pwm_periods_per_sample |
volatile int get_sample = 0 |
A flag to tell if we need to play a new sample with the DAC.
A_ALIGNED short predicted_value |
Predicted value for the adpcm decoder.
A_ALIGNED short step_index |
Step index for the adpcm decoder.