A class to communicate a USB dac (send:only 48kHz,16bit,2ch , receive:only 48kHz,16bit,1ch). Need "USBHost_AddIso" library.
Dependents: USBHostDac_Audio_in_out
Fork of USBHostDac by
Diff: USBHostDac.h
- Revision:
- 1:9ff4cba6524d
- Parent:
- 0:3a3146f89bcc
- Child:
- 2:4afe26b3d48b
--- a/USBHostDac.h Wed Apr 01 10:29:31 2015 +0000 +++ b/USBHostDac.h Wed Sep 30 06:04:31 2015 +0000 @@ -30,6 +30,8 @@ #define USBDAC_DATA_SIZE (192 * 8) +#define USBDAC_ + /** * A class to communicate a USB dac (only 48kHz,16bit,2ch) */ @@ -41,6 +43,11 @@ */ USBHostDac(); + /** Destructor + * + */ + virtual ~USBHostDac(); + /** * Try to connect a audio device * @@ -66,6 +73,16 @@ */ uint32_t send(uint8_t* buf, uint32_t len, bool flush = true); + /** + * Data receive + * + * @param buf pointer on a buffer which will be read + * @param len length of the transfer + * + * @returns the number of bytes read is returned + */ + uint32_t receive(uint8_t* buf, uint32_t len); + protected: //From IUSBEnumerator virtual void setVidPid(uint16_t vid, uint16_t pid); @@ -73,6 +90,17 @@ virtual bool useEndpoint(uint8_t intf_nb, ENDPOINT_TYPE type, ENDPOINT_DIRECTION dir); //Must return true if the endpoint will be used private: + typedef struct { + IsochronousEp* m_isoEp; + uint16_t wMaxPacketSize; + uint8_t bEndpointAddress; + uint8_t bInterfaceNumber; + uint8_t bAlternateSetting; + uint8_t* p_rest_data; + uint32_t rest_data_index; + uint32_t rest_data_size; + } iso_if_t; + USBHost * host; USBDeviceConnected * dev; @@ -81,18 +109,13 @@ int audio_intf; int audio_intf_cnt; - IsochronousEp* m_isoEp; - uint16_t wMaxPacketSize; - uint8_t bEndpointAddress; - uint8_t bInterfaceNumber; - uint8_t bAlternateSetting; - uint8_t* p_rest_data; - uint32_t rest_data_index; + iso_if_t iso_send; + iso_if_t iso_recv; void init(); void onDisconnect(); bool chkAudioStreaming(); USB_TYPE setInterface(uint16_t alt, uint16_t index); - void setSamplingRate(uint32_t sampling_rate); + void setSamplingRate(uint8_t endpoint_adder, uint32_t sampling_rate); }; #endif