4 Replies Latest reply on Aug 5, 2020 12:58 AM by EktaN_26

    Should I use custom code or callback in USBFS?

    JoBr_1593366

      For example, in USBFS_DispatchAUDIOClassRqst there's a custom code section:

      /* `#START AUDIO_READ_REQUESTS` Place other request handler here */
      
      /* `#END` */
      
      
      

       

      and then an optional callback:

       

      #ifdef USBFS_DISPATCH_AUDIO_CLASS_AUDIO_READ_REQUESTS_CALLBACK    
          USBFS_DispatchAUDIOClass_AUDIO_READ_REQUESTS_Callback();
      #endif /* (USBFS_DISPATCH_AUDIO_CLASS_AUDIO_READ_REQUESTS_CALLBACK) */
      

       

      These are both for implementing custom audio class request handlers, right?  Why choose one solution over the other? 

       

      Also, why are there no options to modify the code for USBFS_GET_MIN, USBFS_GET_MAX, USBFS_GET_RES, etc?  To make custom code for these we either need to edit the USB component (which makes it harder to upgrade) or replace the entire class handler using USBFS_EXTERN_CLS?  It would be good if every request handler in the component could be replaced/modified in user code.

        • 1. Re: Should I use custom code or callback in USBFS?
          EktaN_26

          Hello JoBr_1593366

           

          Yes, both the callback functions as well as the custom code section can be used for adding custom code in case of USB. This depends upon the application that you want to create. In case you want to process something before entering the ISR for the interrupt triggered you can use Entry callback, in case you want to do some processing after the ISR is executed use the exit callback function and if you want to execute some task within the ISR use the custom code section.

           

          It is also possible to use both the options at the same time.

           

          Regarding the USBFS_GET_MIN, USBFS_GET_MAX, USBFS_GET_RES macros can you please let me know where are these macros used in your project?

           

          Best Regards

          Ekta

          • 2. Re: Should I use custom code or callback in USBFS?
            JoBr_1593366

            Regarding the USBFS_GET_MIN, USBFS_GET_MAX, USBFS_GET_RES macros can you please let me know where are these macros used in your project?

            They are located in USBFS_audio.c but are not customizable.

             

            Do you mean what do we use them for?  They need to be customized if you want to handle multiple Feature Units, such as having different ranges for input and output controls, implementing Mixer Units, etc.

            • 3. Re: Should I use custom code or callback in USBFS?
              LePo_1062026

              JoBr,

              My personal preferences is to use the callbacks over the direct insertion in the component code.  If the callback can be used in your case, it is easier to maintain especially if the component up-revs or you chose to back-rev.

               

              Len

              • 4. Re: Should I use custom code or callback in USBFS?
                EktaN_26

                Hello JoBr_1593366,

                 

                By default the values of the macros USBFS_GET_MIN, USBFS_GET_MAX, USBFS_GET_RES are Audio Class-Specific Request Codes mentioned in the Universal Serial Bus Device Class Definition for Audio Devices (see page 101): https://usb.org/sites/default/files/audio10.pdf

                Can you please let me know if you have added the Mixer Unit Item in the Audio descriptor and made proper configuration for it?

                 

                 

                 

                Please refer to the page 41 of the USB Audio class devices document mentioned above which contains details regarding the Mixer Unit Descriptor.

                 

                Best Regards

                Ekta