Atmel Software Framework

examples/adpcm_streaming/adpcm_example.c File Reference
#include <avr32/io.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 "pdca.h"

Macros

#define BUFFER_SIZE   2048
 The size of the buffer. More...
 
#define CP_PBA_SPEED   48000000
 The clock frequency. More...
 
#define DAC_PWM_FREQUENCY   (CP_PBA_SPEED >> 8)
 
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   2
 
#define DAC_PWM_CHANNEL_LSB_PIN
 
#define DAC_PWM_CHANNEL_MSB   3
 
#define DAC_PWM_CHANNEL_MSB_PIN
 

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...
 
void init_pdca ()
 
void init_usart ()
 this function initializes the USART module at 115200 bauds More...
 
int main (int argc, char *argv[])
 The main function. More...
 
static void pdca_interrupt_handler (void)
 
void print_fct (char *str)
 This function is used by the debugging module. It permits to print a string through the USART. More...
 
void set_new_dac_buffer (char *_next_buffer)
 Read the next block. More...
 
void sys_cpu_48MHz (void)
 To set the clock frequency to 48MHz. More...
 

Variables

int block_size
 The size of a block. More...
 
A_ALIGNED char buffer [BUFFER_SIZE]
 The main buffer. More...
 
int cur_i_buffer = 0
 The offset of the current writing buffer. More...
 
int cur_i_read_buffer = 0
 The offset of the current reading buffer. More...
 
int dac_pwm_period
 
int dac_pwm_periods_per_sample
 
int fill_activ = 0
 A flag to tell if the buffer is currently filled or not. More...
 
volatile int get_new_block = 0
 A flag to tell if we need to get a new block from the USART. More...
 
volatile int get_sample = 0
 A flag to tell if we need to play a new sample with the DAC. More...
 
int nb_buffers
 The number of buffers. More...
 
char * pbuffer_r
 A pointer on the current reading block. More...
 
char * pbuffer_w
 A pointer on the current writing block. More...
 
int pdca_channel_usart = 0
 In the example we will use the pdca channel 0. There is 17 possible pdca channel in AT32UC3A0512. 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 BUFFER_SIZE   2048

The size of the buffer.

Referenced by main(), and pdca_interrupt_handler().

#define CP_PBA_SPEED   48000000
#define DAC_PWM_CHANNEL_LSB   2

Referenced by dac_pwm_init(), and main().

#define DAC_PWM_CHANNEL_LSB_PIN

Referenced by dac_pwm_init().

#define DAC_PWM_CHANNEL_MSB   3

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 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().

void dac_pwm_init ( )
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 main ( int  argc,
char *  argv[] 
)
static void pdca_interrupt_handler ( void  )
static
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 set_new_dac_buffer ( char *  _next_buffer)

Read the next block.

References cur_i_read_buffer, pbuffer_r, predicted_value, and step_index.

Referenced by main().

void sys_cpu_48MHz ( void  )

int block_size
int cur_i_buffer = 0

The offset of the current writing buffer.

Referenced by main().

int cur_i_read_buffer = 0

The offset of the current reading buffer.

Referenced by main(), and set_new_dac_buffer().

int dac_pwm_period

Referenced by dac_pwm_int_handler(), and main().

int dac_pwm_periods_per_sample

Referenced by main().

int fill_activ = 0

A flag to tell if the buffer is currently filled or not.

Referenced by main(), and pdca_interrupt_handler().

volatile int get_new_block = 0

A flag to tell if we need to get a new block from the USART.

Referenced by main(), and pdca_interrupt_handler().

volatile int get_sample = 0

A flag to tell if we need to play a new sample with the DAC.

Referenced by dac_pwm_int_handler(), and main().

int nb_buffers

The number of buffers.

char* pbuffer_r

A pointer on the current reading block.

Referenced by main(), pdca_usart_interrupt_handler(), and set_new_dac_buffer().

char* pbuffer_w

A pointer on the current writing block.

Referenced by main(), pdca_adc_interrupt_handler(), and pdca_interrupt_handler().

int pdca_channel_usart = 0

In the example we will use the pdca channel 0. There is 17 possible pdca channel in AT32UC3A0512.

Referenced by init_pdca(), main(), and pdca_interrupt_handler().

A_ALIGNED short predicted_value

Predicted value for the adpcm decoder.

Referenced by dsp_adpcm_ima_decode(), dsp_adpcm_ima_encode(), main(), and set_new_dac_buffer().

A_ALIGNED short step_index