Microchip® Advanced Software Framework

device_audio_task.c File Reference
#include <stdio.h>
#include "usart.h"
#include "conf_usb.h"
#include "board.h"
#include "controller.h"
#include "usb_drv.h"
#include "usb_descriptors.h"
#include "usb_standard_request.h"
#include "device_audio_task.h"
#include "usb_stream_player.h"
#include "audio_example.h"
#include "et024006dhu.h"
#include "cycle_counter.h"
#include "debug.h"
#include "avr32_logo.h"

Data Structures

struct  microphone_st
 Holds the pointers on a ping-pong audio buffer. More...
 

Macros

#define FONT_HEIGHT   14
 
#define START_Y_DEMO_TEXT   33
 
#define TIMER_MMI   1000
 
#define TIMER_STARTUP   100
 

Functions

void adc_sample_sent_cb (void)
 
void adc_underflow_cb (void)
 
void device_audio_disable_microphone (void)
 
void device_audio_enable_microphone (void)
 
void device_audio_task (void)
 Entry point of the device Audio task management. More...
 
void device_audio_task_init (void)
 This function initializes the hardware/software resources required for device Audio task. More...
 
static void display_box (uint32_t x, uint32_t y, uint32_t size_x, uint32_t size_y, uint16_t color, uint16_t edge_color)
 This function displays a box on the LCD. More...
 
static void mmi_activity_display (bool init, uint32_t fifo_cnt)
 This function displays the a bargraph indicating the state of the audio buffers and the PPM deviation between the incoming USB audio sampling frequency and the output DAC sampling frequency. More...
 
static void mmi_display (void)
 This function displays the MMI interface and some static informations. More...
 
void usb_sof_action (void)
 usb_sof_action More...
 

Variables

uint8_t * __bss_start
 
uint8_t * _data
 
uint8_t * _edata
 
uint8_t * _estack
 
uint8_t * _stack
 
static bool b_microphone_pause =false
 Control the microphone autoreload interruption. More...
 
static bool b_microphone_started =false
 Indicate if the microphone background interrupt is started or not. More...
 
device_audio_task_data_tdevice_audio_task_data = NULL
 
uint8_t * end
 
static uint8_t mic_buf_id = 0
 Holds the current microphone id to be sent to the USB. More...
 
static uint8_t mic_frame_id = 0
 Holds the packet id that will make a perfect 44.1 KHz for the microphone output on the USB. More...
 
struct microphone_st microphone [2]
 
static uint32_t mmi_state =0
 
bool mute
 Public : (bit) mute mute is set to true when ACTIVE mute is set to false otherwise /. More...
 
void * sample_buffer1 [2]
 
static uint16_t sof_cnt
 
t_cpu_time timer
 
int16_t volume
 Public : (int16_t) volume volume represents the current volume of audio stream /. More...
 

#define FONT_HEIGHT   14
#define START_Y_DEMO_TEXT   33
#define TIMER_MMI   1000

Referenced by mmi_activity_display().

#define TIMER_STARTUP   100

Referenced by mmi_display().

void adc_underflow_cb ( void  )

References b_microphone_started.

void device_audio_disable_microphone ( void  )
void device_audio_enable_microphone ( void  )
void device_audio_task_init ( void  )

This function initializes the hardware/software resources required for device Audio task.

References b_microphone_pause, b_microphone_started, microphone_st::buffer, device_audio_task(), Is_usb_device, microphone, NULL, player_init(), microphone_st::size, sof_cnt, SPEAKER_FREQUENCY, Usb_enable_sof_interrupt, usb_stream_init(), and xTaskCreate.

Referenced by main().

static void display_box ( uint32_t  x,
uint32_t  y,
uint32_t  size_x,
uint32_t  size_y,
uint16_t  color,
uint16_t  edge_color 
)
static

This function displays a box on the LCD.

References et024006_DrawFilledRect(), et024006_DrawHorizLine(), and et024006_DrawVertLine().

Referenced by mmi_activity_display().

static void mmi_activity_display ( bool  init,
uint32_t  fifo_cnt 
)
static

This function displays the a bargraph indicating the state of the audio buffers and the PPM deviation between the incoming USB audio sampling frequency and the output DAC sampling frequency.

References BLACK, BLUE, BLUE_LEV, cpu_is_timeout(), cpu_ms_2_cy(), cpu_set_timeout(), display_box(), et024006_DrawFilledRect(), et024006_PrintString(), FCPU_HZ, FONT8x8, FONT_HEIGHT, get_heap_curr_used_size(), get_heap_free_size(), get_heap_total_used_size(), i, sprintf(), START_Y_DEMO_TEXT, TIMER_MMI, tmp, USB_STREAM_BUFFER_NUMBER, usb_stream_ppm_get(), and WHITE.

Referenced by device_audio_task(), and mmi_display().

uint8_t* __bss_start

Referenced by mmi_display().

uint8_t* _data

Referenced by mmi_display().

uint8_t* _edata

Referenced by mmi_display().

uint8_t* _estack

Referenced by mmi_display().

uint8_t* _stack
bool b_microphone_pause =false
static

Control the microphone autoreload interruption.

We need to sometimes prevent the IRL from reloading automatically in the case that you want to flush the entire codec. This may happen if you receive a SET_XXXXXX command from the USB.

Referenced by adc_sample_sent_cb(), device_audio_disable_microphone(), device_audio_enable_microphone(), and device_audio_task_init().

bool b_microphone_started =false
static

Indicate if the microphone background interrupt is started or not.

Referenced by adc_sample_sent_cb(), adc_underflow_cb(), device_audio_task(), and device_audio_task_init().

device_audio_task_data_t* device_audio_task_data = NULL
uint8_t mic_buf_id = 0
static

Holds the current microphone id to be sent to the USB.

Referenced by adc_sample_sent_cb(), and device_audio_task().

uint8_t mic_frame_id = 0
static

Holds the packet id that will make a perfect 44.1 KHz for the microphone output on the USB.

The packets are sent each ms. The packet size is an integer number of 16-bits sample. So, we can not 44.1 sample each ms. We will send most of the time 44 samples, than 45 samples.

Referenced by adc_sample_sent_cb(), and device_audio_task().

uint32_t mmi_state =0
static

Referenced by device_audio_task(), and mmi_display().

bool mute

Public : (bit) mute mute is set to true when ACTIVE mute is set to false otherwise /.

Referenced by adc_sample_sent_cb(), device_audio_task(), and ms3_dac_is_volume_muted().

void* sample_buffer1[2]
uint16_t sof_cnt
static