usb_specific_request.h File Reference


Detailed Description

Processing of USB device specific enumeration requests.

This file contains the specific request decoding for enumeration process.

Author:
Atmel Corporation: http://www.atmel.com
Support and FAQ: http://support.atmel.no/

Definition in file usb_specific_request.h.

#include "conf_usb.h"

Go to the source code of this file.

Defines

#define USB_HID_REPORT_DESC_KBD   39
 Usb HID Report Descriptor Keyboard.

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.
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.
void audio_speaker_set_sample_freq (void)
void audio_speaker_set_volume (void)
void usb_user_endpoint_init (U8)
 This function configures the endpoints of the device application.
Bool usb_user_get_descriptor (U8, U8)
 This function returns the size and the pointer on a user information structure.
U8 usb_user_interface_get (U16 wInterface)
void usb_user_interface_reset (U16 wInterface, U8 alternate_setting)
Bool usb_user_read_request (U8, U8)
 This function is called by the standard USB read request function when the USB request is not supported.

Variables

const
S_usb_user_configuration_descriptor 
usb_conf_desc
const S_usb_device_descriptor usb_dev_desc
const U8 usb_hid_report_descriptor_kbd [USB_HID_REPORT_DESC_KBD]
const S_usb_language_id usb_user_language_id
const
S_usb_manufacturer_string_descriptor 
usb_user_manufacturer_string_descriptor
const
S_usb_product_string_descriptor 
usb_user_product_string_descriptor
const S_usb_serial_number usb_user_serial_number


Define Documentation

#define USB_HID_REPORT_DESC_KBD   39

Usb HID Report Descriptor Keyboard.

Definition at line 74 of file usb_specific_request.h.


Function Documentation

void audio_micro_get_mute ( void   ) 

Definition at line 722 of file usb_specific_request.c.

References b_micro_mute, and TASKS_SCHEDULE.

Referenced by usb_user_read_request().

00723 {
00724    Usb_reset_endpoint_fifo_access(EP_CONTROL);
00725    Usb_write_endpoint_data(EP_CONTROL, 8, b_micro_mute);
00726    Usb_ack_control_in_ready_send();
00727    while(!Is_usb_control_out_received()) // send a ZLP
00728    {
00729      TASKS_SCHEDULE();
00730    }
00731    Usb_ack_control_out_received_free();
00732 }

void audio_micro_get_vol_cur ( void   ) 

Definition at line 749 of file usb_specific_request.c.

References s16_micro_volume, and TASKS_SCHEDULE.

Referenced by usb_user_read_request().

00750 {
00751    Usb_reset_endpoint_fifo_access(EP_CONTROL);
00752    Usb_write_endpoint_data(EP_CONTROL, 8, LSB(s16_micro_volume));
00753    Usb_write_endpoint_data(EP_CONTROL, 8, MSB(s16_micro_volume));
00754    Usb_ack_control_in_ready_send();
00755    while(!Is_usb_control_out_received()) // send a ZLP
00756    {
00757      TASKS_SCHEDULE();
00758    }
00759    Usb_ack_control_out_received_free();
00760 }

void audio_micro_get_vol_max ( void   ) 

Definition at line 772 of file usb_specific_request.c.

References MICRO_VOL_MAX, and TASKS_SCHEDULE.

Referenced by usb_user_read_request().

00773 {
00774    Usb_reset_endpoint_fifo_access(EP_CONTROL);
00775    Usb_write_endpoint_data(EP_CONTROL, 16, Usb_format_mcu_to_usb_data(16, MICRO_VOL_MAX));
00776    Usb_ack_control_in_ready_send();
00777    while(!Is_usb_control_out_received()) // send a ZLP
00778    {
00779      TASKS_SCHEDULE();
00780    }
00781    Usb_ack_control_out_received_free();
00782 }

void audio_micro_get_vol_min ( void   ) 

Definition at line 761 of file usb_specific_request.c.

References MICRO_VOL_MIN, and TASKS_SCHEDULE.

Referenced by usb_user_read_request().

00762 {
00763    Usb_reset_endpoint_fifo_access(EP_CONTROL);
00764    Usb_write_endpoint_data(EP_CONTROL, 16, Usb_format_mcu_to_usb_data(16, MICRO_VOL_MIN));
00765    Usb_ack_control_in_ready_send();
00766    while(!Is_usb_control_out_received()) // send a ZLP
00767    {
00768      TASKS_SCHEDULE();
00769    }
00770    Usb_ack_control_out_received_free();
00771 }

void audio_micro_get_vol_res ( void   ) 

Definition at line 783 of file usb_specific_request.c.

References MICRO_VOL_RES, and TASKS_SCHEDULE.

Referenced by usb_user_read_request().

00784 {
00785    Usb_reset_endpoint_fifo_access(EP_CONTROL);
00786    Usb_write_endpoint_data(EP_CONTROL, 16, Usb_format_mcu_to_usb_data(16, MICRO_VOL_RES));
00787    Usb_ack_control_in_ready_send();
00788    while(!Is_usb_control_out_received()) // send a ZLP
00789    {
00790      TASKS_SCHEDULE();
00791    }
00792    Usb_ack_control_out_received_free();
00793 }

void audio_micro_set_mute ( void   ) 

Micro control.

Definition at line 707 of file usb_specific_request.c.

References b_micro_mute, and TASKS_SCHEDULE.

Referenced by usb_user_read_request().

00708 {
00709    while(!Is_usb_control_out_received())
00710    {
00711      TASKS_SCHEDULE();
00712    }
00713    Usb_reset_endpoint_fifo_access(EP_CONTROL);
00714    b_micro_mute=Usb_read_endpoint_data(EP_CONTROL, 8);
00715    Usb_ack_control_out_received_free();
00716    Usb_ack_control_in_ready_send();  // send a ZLP
00717    while (!Is_usb_control_in_ready())
00718    {
00719      TASKS_SCHEDULE();
00720    }
00721 }

void audio_micro_set_volume ( void   ) 

Definition at line 733 of file usb_specific_request.c.

References s16_micro_volume, and TASKS_SCHEDULE.

Referenced by usb_user_read_request().

00734 {
00735    while(!Is_usb_control_out_received())
00736    {
00737      TASKS_SCHEDULE();
00738    }
00739    Usb_reset_endpoint_fifo_access(EP_CONTROL);
00740    LSB(s16_micro_volume)=Usb_read_endpoint_data(EP_CONTROL, 8);
00741    MSB(s16_micro_volume)=Usb_read_endpoint_data(EP_CONTROL, 8);
00742    Usb_ack_control_out_received_free();
00743    Usb_ack_control_in_ready_send();  // send a ZLP
00744    while (!Is_usb_control_in_ready())
00745    {
00746      TASKS_SCHEDULE();
00747    }
00748 }

void audio_speaker_get_mute ( void   ) 

Definition at line 587 of file usb_specific_request.c.

References b_speaker_mute, and TASKS_SCHEDULE.

Referenced by usb_user_read_request().

00588 {
00589    Usb_reset_endpoint_fifo_access(EP_CONTROL);
00590    Usb_write_endpoint_data(EP_CONTROL, 8, b_speaker_mute);
00591    Usb_ack_control_in_ready_send();
00592    while(!Is_usb_control_out_received()) // send a ZLP
00593    {
00594      TASKS_SCHEDULE();
00595    }
00596    Usb_ack_control_out_received_free();
00597 }

void audio_speaker_get_vol_cur ( void   ) 

Definition at line 660 of file usb_specific_request.c.

References s16_usb_speaker_volume, and TASKS_SCHEDULE.

Referenced by usb_user_read_request().

00661 {
00662    Usb_reset_endpoint_fifo_access(EP_CONTROL);
00663    Usb_write_endpoint_data(EP_CONTROL, 16, Usb_format_mcu_to_usb_data(16, s16_usb_speaker_volume));
00664    Usb_ack_control_in_ready_send();
00665    while(!Is_usb_control_out_received()) // send a ZLP
00666    {
00667      TASKS_SCHEDULE();
00668    }
00669    Usb_ack_control_out_received_free();
00670 }

void audio_speaker_get_vol_max ( void   ) 

Definition at line 682 of file usb_specific_request.c.

References TASKS_SCHEDULE, and USB_SPEAKER_VOL_MAX.

Referenced by usb_user_read_request().

00683 {
00684    Usb_reset_endpoint_fifo_access(EP_CONTROL);
00685    Usb_write_endpoint_data(EP_CONTROL, 16, Usb_format_mcu_to_usb_data(16, USB_SPEAKER_VOL_MAX));
00686    Usb_ack_control_in_ready_send();
00687    while(!Is_usb_control_out_received()) // send a ZLP
00688    {
00689      TASKS_SCHEDULE();
00690    }
00691    Usb_ack_control_out_received_free();
00692 }

void audio_speaker_get_vol_min ( void   ) 

Definition at line 671 of file usb_specific_request.c.

References TASKS_SCHEDULE, and USB_SPEAKER_VOL_MIN.

Referenced by usb_user_read_request().

00672 {
00673    Usb_reset_endpoint_fifo_access(EP_CONTROL);
00674    Usb_write_endpoint_data(EP_CONTROL, 16, Usb_format_mcu_to_usb_data(16, USB_SPEAKER_VOL_MIN));
00675    Usb_ack_control_in_ready_send();
00676    while(!Is_usb_control_out_received()) // send a ZLP
00677    {
00678      TASKS_SCHEDULE();
00679    }
00680    Usb_ack_control_out_received_free();
00681 }

void audio_speaker_get_vol_res ( void   ) 

Definition at line 693 of file usb_specific_request.c.

References TASKS_SCHEDULE, and USB_SPEAKER_VOL_RES.

Referenced by usb_user_read_request().

00694 {
00695    Usb_reset_endpoint_fifo_access(EP_CONTROL);
00696    Usb_write_endpoint_data(EP_CONTROL, 16, Usb_format_mcu_to_usb_data(16, USB_SPEAKER_VOL_RES));
00697    Usb_ack_control_in_ready_send();
00698    while(!Is_usb_control_out_received()) // send a ZLP
00699    {
00700      TASKS_SCHEDULE();
00701    }
00702    Usb_ack_control_out_received_free();
00703 }

void audio_speaker_set_mute ( void   ) 

Speaker control.

Definition at line 561 of file usb_specific_request.c.

References b_speaker_mute, s16_speaker_volume, SPEAKER_VOL_MIN, and TASKS_SCHEDULE.

Referenced by usb_user_read_request().

00562 {
00563    while(!Is_usb_control_out_received())
00564    {
00565      TASKS_SCHEDULE();
00566    }
00567    Usb_reset_endpoint_fifo_access(EP_CONTROL);
00568    b_speaker_mute=Usb_read_endpoint_data(EP_CONTROL, 8);
00569    audio_mixer_mute_audio(b_speaker_mute);
00570 
00571    if( b_speaker_mute )
00572    {
00573      audio_mixer_dacs_set_volume_direct((U8)SPEAKER_VOL_MIN);
00574    }
00575    else
00576    {
00577      audio_mixer_dacs_set_volume_direct(s16_speaker_volume);
00578    }
00579 
00580    Usb_ack_control_out_received_free();
00581    Usb_ack_control_in_ready_send();  // send a ZLP
00582    while (!Is_usb_control_in_ready())
00583    {
00584      TASKS_SCHEDULE();
00585    }
00586 }

void audio_speaker_set_sample_freq ( void   ) 

Definition at line 598 of file usb_specific_request.c.

References device_audio_disable_microphone(), device_audio_enable_microphone(), and TASKS_SCHEDULE.

Referenced by usb_user_read_request().

00599 {
00600    U32 sample_freq=0;
00601    Usb_ack_setup_received_free();
00602    while(!Is_usb_control_out_received())
00603    {
00604      TASKS_SCHEDULE();
00605    }
00606    Usb_reset_endpoint_fifo_access(EP_CONTROL);
00607    LSB0(sample_freq)=Usb_read_endpoint_data(EP_CONTROL, 8);
00608    LSB1(sample_freq)=Usb_read_endpoint_data(EP_CONTROL, 8);
00609    LSB2(sample_freq)=Usb_read_endpoint_data(EP_CONTROL, 8);
00610    Usb_ack_control_out_received_free();
00611    Usb_ack_control_in_ready_send();  // send a ZLP
00612    while (!Is_usb_control_in_ready())
00613    {
00614      TASKS_SCHEDULE();
00615    }
00616 
00617 #if (defined BOARD) && (BOARD==EVK1105) && (defined DEFAULT_DACS) && (DEFAULT_DACS==AUDIO_MIXER_DAC_AIC23B)
00618    // Disable microphone callback interrupt in order for the flush to not be blocked.
00619    // TODO: audio_mixer_dacs_flush_direct flushs Rx and Tw part of the DAC.
00620    //       Should we separate them? Here, we want to flash the output only.
00621    device_audio_disable_microphone();
00622 #endif
00623    audio_mixer_dacs_flush_direct(FALSE);
00624    usb_stream_init(
00625      sample_freq
00626    , 2
00627    , 16
00628    , FALSE
00629    );
00630 #if (defined BOARD) && (BOARD==EVK1105) && (defined DEFAULT_DACS) && (DEFAULT_DACS==AUDIO_MIXER_DAC_AIC23B)
00631    // Enable microphone call back interrupts.
00632    device_audio_enable_microphone();
00633 #endif
00634 }

void audio_speaker_set_volume ( void   ) 

Definition at line 635 of file usb_specific_request.c.

References s16_speaker_volume, s16_usb_speaker_volume, SPEAKER_VOL_MAX, SPEAKER_VOL_MIN, TASKS_SCHEDULE, and volume_usb_to_appli().

Referenced by usb_user_read_request().

00636 {
00637    while(!Is_usb_control_out_received())
00638    {
00639      TASKS_SCHEDULE();
00640    }
00641    Usb_reset_endpoint_fifo_access(EP_CONTROL);
00642    LSB(s16_usb_speaker_volume)=Usb_read_endpoint_data(EP_CONTROL, 8);
00643    MSB(s16_usb_speaker_volume)=Usb_read_endpoint_data(EP_CONTROL, 8);
00644 
00645    // Convert USB range volume into the volume range of the application.
00646    s16_speaker_volume = volume_usb_to_appli(s16_usb_speaker_volume) ;
00647 
00648    Usb_ack_control_out_received_free();
00649    Usb_ack_control_in_ready_send();  // send a ZLP
00650 
00651    // Ensures good limits of the parameter
00652    s16_speaker_volume = min( s16_speaker_volume, SPEAKER_VOL_MAX);
00653    s16_speaker_volume = max( s16_speaker_volume, SPEAKER_VOL_MIN);
00654    audio_mixer_dacs_set_volume_direct(s16_speaker_volume);
00655    while (!Is_usb_control_in_ready())
00656    {
00657      TASKS_SCHEDULE();
00658    }
00659 }


Variable Documentation

Definition at line 90 of file usb_descriptors.c.

Referenced by usb_user_read_request().

Definition at line 70 of file usb_descriptors.c.

const U8 usb_hid_report_descriptor_kbd[USB_HID_REPORT_DESC_KBD]

Definition at line 413 of file usb_descriptors.c.

Referenced by usb_user_read_request().

Definition at line 378 of file usb_descriptors.c.

Referenced by usb_user_get_descriptor().

Definition at line 387 of file usb_descriptors.c.

Referenced by usb_user_get_descriptor().

Definition at line 396 of file usb_descriptors.c.

Referenced by usb_user_get_descriptor().

Definition at line 405 of file usb_descriptors.c.

Referenced by usb_user_get_descriptor().


Generated on Fri Feb 19 02:32:12 2010 for AVR32 - USB AUDIO Example by  doxygen 1.5.5