usb_specific_request.c 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.c.

#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"

Go to the source code of this file.

Data Structures

struct  st_audio_cmd

Defines

#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.
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)
st_audio_cmd check_audio_control_request (U16 wValue)
 Checks if the audio control request is a Feature Unit Control request for the good feature unit and channel.
static void hid_get_descriptor (U8 size_of_report, const U8 *p_usb_hid_report)
 This function manages the HID Get_Descriptor request.
static void usb_hid_get_idle (U8 u8_report_id)
 This function manages hid get idle request.
static void usb_hid_set_idle (U8 u8_report_id, U8 u8_duration)
static void usb_hid_set_report_ouput (void)
 This function manages hit set report request.
void usb_user_endpoint_init (U8 conf_nb)
 This function configures the endpoints of the device application.
Bool usb_user_get_descriptor (U8 type, U8 string)
 This function returns the size and the pointer on a user information structure.
Bool usb_user_read_request (U8 bmRequestType, U8 bmRequest)
 This function is called by the standard USB read request function when the USB request is not supported.
static S16 volume_usb_to_appli (S16 usb_volume)
 This function converts the volume from the USB world to the application world.

Variables

Bool b_micro_mute
 Mute control of micro TRUE when ACTIVE, FALSE otherwise.
Bool b_speaker_mute
 Mute control of speaker TRUE when ACTIVE, FALSE otherwise.
U16 data_to_transfer
U8 g_u8_report_rate = 0
 This function manages hid set idle request.
const void * pbuffer
S16 s16_micro_volume
 Represents the current volume of audio stream micro No effet in this demo.
S16 s16_speaker_volume = (SPEAKER_VOL_MIN + SPEAKER_VOL_MAX)/2
 Represents the current volume of audio stream speaker.
S16 s16_usb_speaker_volume = (USB_SPEAKER_VOL_MIN + USB_SPEAKER_VOL_MAX)/2
 Represents a copy of the USB volume.


Define Documentation

#define TARGET_MICRO   2

Definition at line 73 of file usb_specific_request.c.

Referenced by check_audio_control_request(), and usb_user_read_request().

#define TARGET_SPEAKER   1

Definition at line 72 of file usb_specific_request.c.

Referenced by check_audio_control_request(), and usb_user_read_request().

#define TARGET_UNDEFINED   0

Definition at line 71 of file usb_specific_request.c.

Referenced by check_audio_control_request().

 
#define TASKS_SCHEDULE (  )     device_audio_task()


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 }

st_audio_cmd check_audio_control_request ( U16  wValue  ) 

Checks if the audio control request is a Feature Unit Control request for the good feature unit and channel.

Returns:
the target audio and the Control Selector from request

Definition at line 520 of file usb_specific_request.c.

References AC_INTERFACE_NB, st_audio_cmd::cs, MICRO_FEATURE_UNIT_ID, SPEAKER_FEATURE_UNIT_ID, st_audio_cmd::target, TARGET_MICRO, TARGET_SPEAKER, and TARGET_UNDEFINED.

Referenced by usb_user_read_request().

00521 {
00522    st_audio_cmd cmd;
00523    U16 wIndex;
00524    U16 length;
00525 
00526    LSB(wIndex)=Usb_read_endpoint_data(EP_CONTROL, 8);
00527    MSB(wIndex)=Usb_read_endpoint_data(EP_CONTROL, 8);
00528    LSB(length)=Usb_read_endpoint_data(EP_CONTROL, 8);
00529    MSB(length)=Usb_read_endpoint_data(EP_CONTROL, 8);
00530    Usb_ack_setup_received_free();
00531 
00532    cmd.target = TARGET_UNDEFINED;
00533    cmd.cs     = AUDIO_FU_CONTROL_CS_UNDEFINED;
00534 
00535    // Note: The wValue field interpretation is qualified by the value in the wIndex field.
00536    // Check target of the command
00537    if( LSB(wIndex) == AC_INTERFACE_NB)
00538    {
00539       // The request is for the Feature Unit Control then
00540       // MSB(wIndex) = Feature Unit ID, LSB(wValue) = Channel Number (CN), MSB(wValue) = Control Selector (CS)
00541       cmd.cs = MSB(wValue);
00542 
00543       if( (MSB(wIndex) == SPEAKER_FEATURE_UNIT_ID)
00544       &&  (LSB(wValue) == 0) )
00545       {
00546          // for Master Channel of speaker
00547          cmd.target = TARGET_SPEAKER;
00548 
00549       }
00550       if( (MSB(wIndex) == MICRO_FEATURE_UNIT_ID)
00551       &&  (LSB(wValue) == 0) )
00552       {
00553          // for Master Channel of micro
00554          cmd.target = TARGET_MICRO;
00555       }
00556    }
00557    return cmd;
00558 }

static void hid_get_descriptor ( U8  size_of_report,
const U8 *  p_usb_hid_report 
) [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

Definition at line 864 of file usb_specific_request.c.

References data_to_transfer, EP_CONTROL_LENGTH, and pbuffer.

Referenced by usb_user_read_request().

00865 {
00866   Bool  zlp;
00867   U16   wIndex;
00868   U16   wLength;
00869 
00870   zlp = FALSE;                                              /* no zero length packet */
00871 
00872   data_to_transfer = size_of_report;
00873   pbuffer          = p_usb_hid_report;
00874 
00875   wIndex = Usb_read_endpoint_data(EP_CONTROL, 16);
00876   wIndex = usb_format_usb_to_mcu_data(16, wIndex);
00877   wLength = Usb_read_endpoint_data(EP_CONTROL, 16);
00878   wLength = usb_format_usb_to_mcu_data(16, wLength);
00879   Usb_ack_setup_received_free();                          
00880 
00881   if (wLength > data_to_transfer)
00882   {
00883     zlp = !(data_to_transfer % EP_CONTROL_LENGTH);  
00884   }
00885   else
00886   {
00887     data_to_transfer = wLength; 
00888   }
00889 
00890   Usb_ack_nak_out(EP_CONTROL);
00891 
00892   while (data_to_transfer && (!Is_usb_nak_out(EP_CONTROL)))
00893   {
00894     while( !Is_usb_control_in_ready() && !Is_usb_nak_out(EP_CONTROL) );
00895 
00896     if( Is_usb_nak_out(EP_CONTROL) )
00897        break;    // don't clear the flag now, it will be cleared after
00898 
00899     Usb_reset_endpoint_fifo_access(EP_CONTROL);
00900     data_to_transfer = usb_write_ep_txpacket(EP_CONTROL, pbuffer,
00901                                              data_to_transfer, &pbuffer);
00902     if( Is_usb_nak_out(EP_CONTROL) )
00903        break;
00904     else
00905        Usb_ack_control_in_ready_send();  
00906   }
00907 
00908   if ( zlp && (!Is_usb_nak_out(EP_CONTROL)) )
00909   {
00910     while (!Is_usb_control_in_ready());
00911     Usb_ack_control_in_ready_send();
00912   }
00913 
00914   while (!(Is_usb_nak_out(EP_CONTROL)));
00915   Usb_ack_nak_out(EP_CONTROL);
00916   while (!Is_usb_control_out_received());
00917   Usb_ack_control_out_received_free();
00918 }

static void usb_hid_get_idle ( U8  u8_report_id  )  [static]

This function manages hid get idle request.

Parameters:
u8_report_id 0 the idle rate applies to all input reports, else only applies to the Report ID

Definition at line 840 of file usb_specific_request.c.

References g_u8_report_rate, and INTERFACE_NB_KBD.

Referenced by usb_user_read_request().

00841 {
00842    U16 wLength;
00843    U16 wInterface;
00844 
00845    // Get interface number to put in idle mode
00846    wInterface=usb_format_usb_to_mcu_data(16, Usb_read_endpoint_data(EP_CONTROL, 16));
00847    wLength   =usb_format_usb_to_mcu_data(16, Usb_read_endpoint_data(EP_CONTROL, 16));
00848    Usb_ack_setup_received_free();
00849    
00850    if( (wLength != 0) && (wInterface == INTERFACE_NB_KBD) )
00851    {
00852       Usb_reset_endpoint_fifo_access(EP_CONTROL);
00853       Usb_write_endpoint_data(EP_CONTROL, 8, g_u8_report_rate);
00854       Usb_ack_control_in_ready_send();
00855    }
00856    
00857    while (!Is_usb_control_out_received());
00858    Usb_ack_control_out_received_free();
00859 }

static void usb_hid_set_idle ( U8  u8_report_id,
U8  u8_duration 
) [static]

Definition at line 820 of file usb_specific_request.c.

References g_u8_report_rate, and INTERFACE_NB_KBD.

Referenced by usb_user_read_request().

00821 {
00822    U16 wInterface;
00823    
00824    // Get interface number to put in idle mode
00825    wInterface=usb_format_usb_to_mcu_data(16, Usb_read_endpoint_data(EP_CONTROL, 16));
00826    Usb_ack_setup_received_free();
00827   
00828    if( wInterface == INTERFACE_NB_KBD )
00829      g_u8_report_rate = u8_duration;
00830    
00831    Usb_ack_control_in_ready_send();
00832    while (!Is_usb_control_in_ready());
00833 }

static void usb_hid_set_report_ouput ( void   )  [static]

This function manages hit set report request.

Definition at line 798 of file usb_specific_request.c.

Referenced by usb_user_read_request().

00799 {
00800    //Usb_ack_receive_setup();
00801    Usb_ack_setup_received_free();
00802    //Usb_send_control_in();
00803    Usb_ack_control_in_ready_send();
00804 
00805    //while(!Is_usb_receive_out());
00806    while (!Is_usb_control_out_received());
00807    //Usb_ack_receive_out();
00808    Usb_ack_control_out_received_free();
00809    //Usb_send_control_in();
00810    Usb_ack_control_in_ready_send();
00811 }

static S16 volume_usb_to_appli ( S16  usb_volume  )  [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]

Definition at line 923 of file usb_specific_request.c.

References SPEAKER_VOL_MAX, SPEAKER_VOL_MIN, USB_SPEAKER_VOL_MAX, USB_SPEAKER_VOL_MIN, and volume.

Referenced by audio_speaker_set_volume().

00924 {
00925   S16 volume;
00926   if( usb_volume==-32768 )
00927   {
00928     volume=SPEAKER_VOL_MIN;
00929   }
00930   else
00931   {
00932     volume= (((S32)usb_volume-USB_SPEAKER_VOL_MIN)*(SPEAKER_VOL_MAX-SPEAKER_VOL_MIN)/(USB_SPEAKER_VOL_MAX-USB_SPEAKER_VOL_MIN))+SPEAKER_VOL_MIN;
00933   }
00934 
00935   return volume;
00936 }


Variable Documentation

Mute control of micro TRUE when ACTIVE, FALSE otherwise.

Definition at line 97 of file usb_specific_request.c.

Referenced by audio_micro_get_mute(), and audio_micro_set_mute().

Mute control of speaker TRUE when ACTIVE, FALSE otherwise.

Definition at line 83 of file usb_specific_request.c.

Referenced by audio_speaker_get_mute(), and audio_speaker_set_mute().

This function manages hid set idle request.

Parameters:
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

Definition at line 819 of file usb_specific_request.c.

Referenced by usb_hid_get_idle(), and usb_hid_set_idle().

const void* pbuffer

Represents the current volume of audio stream micro No effet in this demo.

Definition at line 102 of file usb_specific_request.c.

Referenced by audio_micro_get_vol_cur(), and audio_micro_set_volume().

S16 s16_speaker_volume = (SPEAKER_VOL_MIN + SPEAKER_VOL_MAX)/2

Represents the current volume of audio stream speaker.

Definition at line 86 of file usb_specific_request.c.

Referenced by audio_speaker_set_mute(), and audio_speaker_set_volume().

S16 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 inprecision.

Definition at line 92 of file usb_specific_request.c.

Referenced by audio_speaker_get_vol_cur(), and audio_speaker_set_volume().


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