Atmel Software Framework

examples/adpcm_wav_player/adpcm_example.c File Reference
#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 SWITCH_ENDIANNESS (   width,
  data 
)    (TPASTE2(Swap, width)(data))

Referenced by main().

#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_fmt
typedef struct A_PACKED s_wave_fmt_dvi
typedef struct A_PACKED s_wave_riff

static void dac_pwm_int_handler ( void  )
static

The PWM interrupt handler.

References dac_pwm_period, and get_sample.

Referenced by dac_pwm_init().

int fget_struct ( const char *  _data,
char *  _ptr,
int  size,
char *  _start_str 
)

References i, j, and MAX_SEARCH_LENGTH.

Referenced by main().

void print_fct ( char *  str)

This function is used by the debugging module. It permits to print a string through the USART.

Parameters
strThe input string to print.
Precondition
It as to be used after having initializing the USART module.

References EXAMPLE_USART, and usart_write_line().

void sys_cpu_48MHz ( void  )

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.