#include "conf_audio_mixer.h"
#include "conf_audio_player.h"
#include "conf_usb.h"
#include "usb_drv.h"
#include "usb_descriptors.h"
#include "usb_standard_request.h"
#include "usb_specific_request.h"
#include "usart.h"
#include "audio_example.h"
#include "usb_stream_player.h"
#include "device_audio_task.h"
#include "hid.h"
Data Structures | |
struct | st_audio_cmd |
Macros | |
#define | TARGET_MICRO 2 |
#define | TARGET_SPEAKER 1 |
#define | TARGET_UNDEFINED 0 |
#define | TASKS_SCHEDULE() device_audio_task() |
Functions | |
void | audio_micro_get_mute (void) |
void | audio_micro_get_vol_cur (void) |
void | audio_micro_get_vol_max (void) |
void | audio_micro_get_vol_min (void) |
void | audio_micro_get_vol_res (void) |
void | audio_micro_set_mute (void) |
Micro control. More... | |
void | audio_micro_set_volume (void) |
void | audio_speaker_get_mute (void) |
void | audio_speaker_get_vol_cur (void) |
void | audio_speaker_get_vol_max (void) |
void | audio_speaker_get_vol_min (void) |
void | audio_speaker_get_vol_res (void) |
void | audio_speaker_set_mute (void) |
Speaker control. More... | |
void | audio_speaker_set_sample_freq (void) |
void | audio_speaker_set_volume (void) |
st_audio_cmd | check_audio_control_request (uint16_t wValue) |
Checks if the audio control request is a Feature Unit Control request for the good feature unit and channel. More... | |
static void | hid_get_descriptor (uint8_t size_of_report, const uint8_t *p_usb_hid_report) |
This function manages the HID Get_Descriptor request. More... | |
static void | usb_hid_get_idle (uint8_t u8_report_id) |
This function manages hid get idle request. More... | |
static void | usb_hid_set_idle (uint8_t u8_report_id, uint8_t u8_duration) |
static void | usb_hid_set_report_ouput (void) |
This function manages hit set report request. More... | |
void | usb_user_endpoint_init (uint8_t conf_nb) |
This function configures the endpoints of the device application. More... | |
bool | usb_user_get_descriptor (uint8_t type, uint8_t string) |
This function returns the size and the pointer on a user information structure. More... | |
bool | usb_user_read_request (uint8_t bmRequestType, uint8_t bmRequest) |
This function is called by the standard USB read request function when the USB request is not supported. More... | |
static int16_t | volume_usb_to_appli (int16_t usb_volume) |
This function converts the volume from the USB world to the application world. More... | |
Variables | |
bool | b_micro_mute |
Mute control of micro true when ACTIVE, false otherwise. More... | |
bool | b_speaker_mute |
Mute control of speaker true when ACTIVE, false otherwise. More... | |
uint16_t | data_to_transfer |
uint8_t | g_u8_report_rate =0 |
This function manages hid set idle request. More... | |
const void * | pbuffer |
int16_t | s16_micro_volume |
Represents the current volume of audio stream micro No effect in this demo. More... | |
int16_t | s16_speaker_volume = (SPEAKER_VOL_MIN + SPEAKER_VOL_MAX)/2 |
Represents the current volume of audio stream speaker. More... | |
int16_t | s16_usb_speaker_volume = (USB_SPEAKER_VOL_MIN + USB_SPEAKER_VOL_MAX)/2 |
Represents a copy of the USB volume. More... | |
#define TARGET_MICRO 2 |
Referenced by check_audio_control_request(), and usb_user_read_request().
#define TARGET_SPEAKER 1 |
Referenced by check_audio_control_request(), and usb_user_read_request().
#define TARGET_UNDEFINED 0 |
Referenced by check_audio_control_request().
#define TASKS_SCHEDULE | ( | ) | device_audio_task() |
Referenced by audio_micro_get_mute(), audio_micro_get_vol_cur(), audio_micro_get_vol_max(), audio_micro_get_vol_min(), audio_micro_get_vol_res(), audio_micro_set_mute(), audio_micro_set_volume(), audio_speaker_get_mute(), audio_speaker_get_vol_cur(), audio_speaker_get_vol_max(), audio_speaker_get_vol_min(), audio_speaker_get_vol_res(), audio_speaker_set_mute(), audio_speaker_set_sample_freq(), and audio_speaker_set_volume().
void audio_micro_get_mute | ( | void | ) |
void audio_micro_get_vol_cur | ( | void | ) |
void audio_micro_get_vol_max | ( | void | ) |
void audio_micro_get_vol_min | ( | void | ) |
void audio_micro_get_vol_res | ( | void | ) |
void audio_micro_set_mute | ( | void | ) |
Micro control.
References b_micro_mute, EP_CONTROL, Is_usb_control_in_ready, Is_usb_control_out_received, TASKS_SCHEDULE, Usb_ack_control_in_ready_send, Usb_ack_control_out_received_free, Usb_read_endpoint_data, and Usb_reset_endpoint_fifo_access.
Referenced by usb_user_read_request().
void audio_micro_set_volume | ( | void | ) |
void audio_speaker_get_mute | ( | void | ) |
void audio_speaker_get_vol_cur | ( | void | ) |
void audio_speaker_get_vol_max | ( | void | ) |
void audio_speaker_get_vol_min | ( | void | ) |
void audio_speaker_get_vol_res | ( | void | ) |
void audio_speaker_set_mute | ( | void | ) |
Speaker control.
References audio_mixer_dacs_set_volume_direct(), audio_mixer_mute_audio, b_speaker_mute, EP_CONTROL, Is_usb_control_in_ready, Is_usb_control_out_received, s16_speaker_volume, SPEAKER_VOL_MIN, TASKS_SCHEDULE, Usb_ack_control_in_ready_send, Usb_ack_control_out_received_free, Usb_read_endpoint_data, and Usb_reset_endpoint_fifo_access.
Referenced by usb_user_read_request().
void audio_speaker_set_sample_freq | ( | void | ) |
References audio_mixer_dacs_flush_direct(), device_audio_disable_microphone(), device_audio_enable_microphone(), EP_CONTROL, Is_usb_control_in_ready, Is_usb_control_out_received, LSB0, LSB1, LSB2, TASKS_SCHEDULE, Usb_ack_control_in_ready_send, Usb_ack_control_out_received_free, Usb_ack_setup_received_free, Usb_read_endpoint_data, Usb_reset_endpoint_fifo_access, and usb_stream_init().
Referenced by usb_user_read_request().
void audio_speaker_set_volume | ( | void | ) |
References audio_mixer_dacs_set_volume_direct(), EP_CONTROL, Is_usb_control_in_ready, Is_usb_control_out_received, LSB, max, min, MSB, s16_speaker_volume, s16_usb_speaker_volume, SPEAKER_VOL_MAX, SPEAKER_VOL_MIN, TASKS_SCHEDULE, Usb_ack_control_in_ready_send, Usb_ack_control_out_received_free, Usb_read_endpoint_data, Usb_reset_endpoint_fifo_access, and volume_usb_to_appli().
Referenced by usb_user_read_request().
st_audio_cmd check_audio_control_request | ( | uint16_t | wValue | ) |
Checks if the audio control request is a Feature Unit Control request for the good feature unit and channel.
References AC_INTERFACE_NB, AUDIO_FU_CONTROL_CS_UNDEFINED, st_audio_cmd::cs, EP_CONTROL, LSB, MICRO_FEATURE_UNIT_ID, MSB, SPEAKER_FEATURE_UNIT_ID, st_audio_cmd::target, TARGET_MICRO, TARGET_SPEAKER, TARGET_UNDEFINED, Usb_ack_setup_received_free, and Usb_read_endpoint_data.
Referenced by usb_user_read_request().
|
static |
This function manages the HID Get_Descriptor request.
< clear the setup received flag
< zero length packet condition
< send only requested number of data bytes
< Send data until necessary
References data_to_transfer, EP_CONTROL, EP_CONTROL_LENGTH, Is_usb_control_in_ready, Is_usb_control_out_received, Is_usb_nak_out, pbuffer, Usb_ack_control_in_ready_send, Usb_ack_control_out_received_free, Usb_ack_nak_out, Usb_ack_setup_received_free, usb_format_usb_to_mcu_data, Usb_read_endpoint_data, Usb_reset_endpoint_fifo_access, and usb_write_ep_txpacket().
Referenced by usb_user_read_request().
|
static |
This function manages hid get idle request.
u8_report_id | 0 the idle rate applies to all input reports, else only applies to the Report ID |
References EP_CONTROL, g_u8_report_rate, INTERFACE_NB_KBD, Is_usb_control_out_received, Usb_ack_control_in_ready_send, Usb_ack_control_out_received_free, Usb_ack_setup_received_free, usb_format_usb_to_mcu_data, Usb_read_endpoint_data, Usb_reset_endpoint_fifo_access, and Usb_write_endpoint_data.
Referenced by usb_user_read_request().
|
static |
|
static |
This function manages hit set report request.
References Is_usb_control_out_received, Usb_ack_control_in_ready_send, Usb_ack_control_out_received_free, and Usb_ack_setup_received_free.
Referenced by usb_user_read_request().
|
static |
This function converts the volume from the USB world to the application world.
[USB_SPEAKER_VOL_MIN; USB_SPEAKER_VOL_MAX] => [SPEAKER_VOL_MIN; SPEAKER_VOL_MAX]
References SPEAKER_VOL_MAX, SPEAKER_VOL_MIN, USB_SPEAKER_VOL_MAX, USB_SPEAKER_VOL_MIN, and volume.
Referenced by audio_speaker_set_volume().
bool b_micro_mute |
Mute control of micro true when ACTIVE, false otherwise.
Referenced by audio_micro_get_mute(), and audio_micro_set_mute().
bool b_speaker_mute |
Mute control of speaker true when ACTIVE, false otherwise.
Referenced by audio_speaker_get_mute(), and audio_speaker_set_mute().
uint16_t data_to_transfer |
Referenced by hid_get_descriptor(), usb_get_descriptor(), usb_set_interface(), and usb_user_get_descriptor().
uint8_t g_u8_report_rate =0 |
This function manages hid set idle request.
Duration | When the upper byte of wValue is 0 (zero), the duration is indefinite else from 0.004 to 1.020 seconds |
Report | ID 0 the idle rate applies to all input reports, else only applies to the Report ID |
Referenced by usb_hid_get_idle(), and usb_hid_set_idle().
const void* pbuffer |
Referenced by hid_get_descriptor(), usb_get_descriptor(), usb_set_interface(), and usb_user_get_descriptor().
int16_t s16_micro_volume |
Represents the current volume of audio stream micro No effect in this demo.
Referenced by audio_micro_get_vol_cur(), and audio_micro_set_volume().
int16_t s16_speaker_volume = (SPEAKER_VOL_MIN + SPEAKER_VOL_MAX)/2 |
Represents the current volume of audio stream speaker.
Referenced by audio_speaker_set_mute(), and audio_speaker_set_volume().
int16_t s16_usb_speaker_volume = (USB_SPEAKER_VOL_MIN + USB_SPEAKER_VOL_MAX)/2 |
Represents a copy of the USB volume.
The USB volume has a range [USB_SPEAKER_VOL_MIN; USB_SPEAKER_VOL_MAX] and must be converted to the volume of the DAC used. We keep back a copy of the last USB volume since Windows ask for the current volume and a double conversion USB -> appli -> USB may lead to imprecision.
Referenced by audio_speaker_get_vol_cur(), and audio_speaker_set_volume().