You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

usb_audio.h 1.5KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758
  1. #ifndef USBaudio_h_
  2. #define USBaudio_h_
  3. #include "usb_desc.h"
  4. #ifdef AUDIO_INTERFACE
  5. #ifdef __cplusplus
  6. extern "C" {
  7. #endif
  8. extern uint16_t usb_audio_receive_buffer[];
  9. extern uint16_t usb_audio_transmit_buffer[];
  10. extern void usb_audio_receive_callback(unsigned int len);
  11. extern unsigned int usb_audio_transmit_callback(void);
  12. extern uint32_t usb_audio_sync_feedback;
  13. extern uint8_t usb_audio_receive_setting;
  14. extern uint8_t usb_audio_transmit_setting;
  15. #ifdef __cplusplus
  16. }
  17. #include "AudioStream.h"
  18. class AudioInputUSB : public AudioStream
  19. {
  20. public:
  21. AudioInputUSB(void) : AudioStream(0, NULL) { begin(); }
  22. virtual void update(void);
  23. void begin(void);
  24. friend void usb_audio_receive_callback(unsigned int len);
  25. private:
  26. static bool update_responsibility;
  27. static audio_block_t *incoming_left;
  28. static audio_block_t *incoming_right;
  29. static audio_block_t *ready_left;
  30. static audio_block_t *ready_right;
  31. static uint16_t incoming_count;
  32. static uint8_t receive_flag;
  33. };
  34. class AudioOutputUSB : public AudioStream
  35. {
  36. public:
  37. AudioOutputUSB(void) : AudioStream(2, inputQueueArray) { begin(); }
  38. virtual void update(void);
  39. void begin(void);
  40. friend unsigned int usb_audio_transmit_callback(void);
  41. private:
  42. static bool update_responsibility;
  43. static audio_block_t *left_1st;
  44. static audio_block_t *left_2nd;
  45. static audio_block_t *right_1st;
  46. static audio_block_t *right_2nd;
  47. static uint16_t offset_1st;
  48. audio_block_t *inputQueueArray[2];
  49. };
  50. #endif // __cplusplus
  51. #endif // AUDIO_INTERFACE
  52. #endif // USBaudio_h_