Operating in USB Host Mode, I'm using the USB Audio class to read 16-bit, 16kHz PCM audio from a connected microphone.
The algorithm that processes the audio requires that the samples be in big-endian format; however, it appears that all USB data is transferred in little-endian.
I noticed that the USB Device Mode has an Endian Select field to switch between the two types, but I have not been able to find any mechanism for converting from little-endian to big-endian when reading USB audio in host mode.
Can anyone suggest a mechanism to accomplish this?
Solved! Go to Solution.
Hi,
I checked the USB OS Adapter has the ENDIANNESS definition at <usb_osa.h>:
/*! @brief Define big endian */
#define USB_BIG_ENDIAN (0U)
/*! @brief Define little endian */
#define USB_LITTLE_ENDIAN (1U)
/*! @brief Define current endian */
#define ENDIANNESS USB_LITTLE_ENDIAN
The OS adapter (OSA) is used to wrap the differences between RTOSes and enable a USB stack with the
same code base and behavior.
Note
OSA should not be used in the USB application. Therefore, from the USB application viewpoint, OSA is invisible.
If your application doesn't use RTOS, it need to software convert data from little endian to big endian.
best regards,
Mike
Hi,
I checked the USB OS Adapter has the ENDIANNESS definition at <usb_osa.h>:
/*! @brief Define big endian */
#define USB_BIG_ENDIAN (0U)
/*! @brief Define little endian */
#define USB_LITTLE_ENDIAN (1U)
/*! @brief Define current endian */
#define ENDIANNESS USB_LITTLE_ENDIAN
The OS adapter (OSA) is used to wrap the differences between RTOSes and enable a USB stack with the
same code base and behavior.
Note
OSA should not be used in the USB application. Therefore, from the USB application viewpoint, OSA is invisible.
If your application doesn't use RTOS, it need to software convert data from little endian to big endian.
best regards,
Mike