Microchip® Advanced Software Framework

wm8731_example.c File Reference

WM8731 example for SAM.

#include <asf.h>
#include "xmodem.h"

Data Structures

struct  wav_header
 

Macros

#define BITS_BY_SLOT   (16)
 Bits per slot. More...
 
#define DMA_CH   0
 
#define MAX_WAV_SIZE   0x800000
 Maximum size in bytes of the WAV file. More...
 
#define RECORD_ADDRESS   (WAV_FILE_ADDRESS + MAX_WAV_SIZE)
 Address at which the recorded sample is stored. More...
 
#define SAMPLE_RATE   (48000)
 Wav feature. More...
 
#define SLOT_BY_FRAME   (2)
 Wav slot per frame. More...
 
#define WAV_CHUNKID   0x46464952
 
#define WAV_FORMAT   0x45564157
 
#define WAV_SUBCHUNKID   0x20746D66
 

Functions

static void configure_console (void)
 Configure the console UART. More...
 
static void display_menu (void)
 Displays the user menu on the DBGU. More...
 
static void display_wav_info (void)
 Display the information of the WAV file (sample rate, stereo/mono and frame size). More...
 
void DMAC_Handler (void)
 ISR for DMA interrupt. More...
 
static void init_dac (void)
 Initial the WM8731 to play back the sample WAV file. More...
 
static void init_dma (void)
 DMA driver configuration. More...
 
static void init_ssc (void)
 Initial the ssc interface. More...
 
static void init_twi_wm8731 (void)
 
int main (void)
 ssc_dma_audio Application entry point. More...
 
static void ssc_dma (void *p_buffer, uint16_t us_size)
 Start DMA sending data. More...
 
static void start_play_wav (uint32_t ul_wav_data_address, uint32_t ul_wav_size)
 Play a WAV file pre-loaded in PSRAM/SDRAM. More...
 
static void stop_play_wav (void)
 Stop the current playback (if any). More...
 

Variables

static uint8_t g_uc_is_wav_available = 0
 Indicates if there is wav data. More...
 
static uint8_t g_uc_is_wav_playing = 0
 Indicates if the WAV file is currently being played. More...
 
static uint32_t g_ul_remaining_bytes
 Number of samples that have not yet been transmitted. More...
 
static uint32_t g_ul_transmitted_bytes
 Number of samples which have already been transmitted. More...
 
static struct wav_headerp_wav_file
 Pointer to the playback WAV file header. More...
 

#define BITS_BY_SLOT   (16)

Bits per slot.

Referenced by init_ssc().

#define DMA_CH   0
#define MAX_WAV_SIZE   0x800000

Maximum size in bytes of the WAV file.

#define RECORD_ADDRESS   (WAV_FILE_ADDRESS + MAX_WAV_SIZE)

Address at which the recorded sample is stored.

#define SAMPLE_RATE   (48000)

Wav feature.

Referenced by init_ssc().

#define SLOT_BY_FRAME   (2)

Wav slot per frame.

#define WAV_CHUNKID   0x46464952

Referenced by main().

#define WAV_FORMAT   0x45564157

Referenced by main().

#define WAV_SUBCHUNKID   0x20746D66

static void configure_console ( void  )
static

Configure the console UART.

References uart_rs232_options::baudrate, stdio_serial_init(), and sysclk_enable_peripheral_clock().

Referenced by main().

static void display_menu ( void  )
static

Displays the user menu on the DBGU.

References g_uc_is_wav_available, and g_uc_is_wav_playing.

Referenced by DMAC_Handler(), and main().

void DMAC_Handler ( void  )
static void ssc_dma ( void *  p_buffer,
uint16_t  us_size 
)
static
static void start_play_wav ( uint32_t  ul_wav_data_address,
uint32_t  ul_wav_size 
)
static

Play a WAV file pre-loaded in PSRAM/SDRAM.

Parameters
ul_wav_data_addressThe address of the WAVE file.
ul_wav_sizeWave file size.

References wav_header::bits_per_sample, g_uc_is_wav_playing, g_ul_remaining_bytes, g_ul_transmitted_bytes, Min, and ssc_dma().

Referenced by main().

static void stop_play_wav ( void  )
static

Stop the current playback (if any).

References DMA_CH, dmac_channel_stop_transfer(), g_uc_is_wav_playing, and ssc_disable_tx().

Referenced by main().

uint8_t g_uc_is_wav_available = 0
static

Indicates if there is wav data.

Referenced by display_menu(), and main().

uint8_t g_uc_is_wav_playing = 0
static

Indicates if the WAV file is currently being played.

Referenced by display_menu(), DMAC_Handler(), main(), start_play_wav(), and stop_play_wav().

uint32_t g_ul_remaining_bytes
static

Number of samples that have not yet been transmitted.

Referenced by DMAC_Handler(), and start_play_wav().

uint32_t g_ul_transmitted_bytes
static

Number of samples which have already been transmitted.

Referenced by start_play_wav().

struct wav_header* p_wav_file
static
Initial value:
=
(struct wav_header *)WAV_FILE_ADDRESS
Definition: wm8731_example.c:128

Pointer to the playback WAV file header.