| #define DMABUFATTR __attribute__ ((section(".dmabuffers"), aligned (4))) | #define DMABUFATTR __attribute__ ((section(".dmabuffers"), aligned (4))) | ||||
| uint16_t usb_audio_receive_buffer[AUDIO_RX_SIZE/2] DMABUFATTR; | uint16_t usb_audio_receive_buffer[AUDIO_RX_SIZE/2] DMABUFATTR; | ||||
| uint32_t usb_audio_sync_feedback DMABUFATTR; | uint32_t usb_audio_sync_feedback DMABUFATTR; | ||||
| uint8_t usb_audio_receive_setting=0; | |||||
| static uint32_t feedback_accumulator = 185042824; | static uint32_t feedback_accumulator = 185042824; | ||||
| uint16_t usb_audio_transmit_buffer[AUDIO_TX_SIZE/2] DMABUFATTR; | uint16_t usb_audio_transmit_buffer[AUDIO_TX_SIZE/2] DMABUFATTR; | ||||
| uint8_t usb_audio_transmit_setting=0; | |||||
| void AudioOutputUSB::begin(void) | void AudioOutputUSB::begin(void) | ||||
| { | { | ||||
| left = receiveReadOnly(0); // input 0 = left channel | left = receiveReadOnly(0); // input 0 = left channel | ||||
| right = receiveReadOnly(1); // input 1 = right channel | right = receiveReadOnly(1); // input 1 = right channel | ||||
| if (usb_audio_transmit_setting == 0) { | |||||
| if (left) release(left); | |||||
| if (right) release(right); | |||||
| if (outgoing_count) { | |||||
| if (left_1st) release(left_1st); | |||||
| if (left_2nd) release(left_2nd); | |||||
| if (right_1st) release(right_1st); | |||||
| if (right_2nd) release(right_2nd); | |||||
| outgoing_count = 0; | |||||
| offset_1st = 0; | |||||
| } | |||||
| return; | |||||
| } | |||||
| if (left == NULL) { | if (left == NULL) { | ||||
| if (right == NULL) return; | if (right == NULL) return; | ||||
| right->ref_count++; | right->ref_count++; |
| extern void usb_audio_receive_callback(unsigned int len); | extern void usb_audio_receive_callback(unsigned int len); | ||||
| extern unsigned int usb_audio_transmit_callback(void); | extern unsigned int usb_audio_transmit_callback(void); | ||||
| extern uint32_t usb_audio_sync_feedback; | extern uint32_t usb_audio_sync_feedback; | ||||
| extern uint8_t usb_audio_receive_setting; | |||||
| extern uint8_t usb_audio_transmit_setting; | |||||
| #ifdef __cplusplus | #ifdef __cplusplus | ||||
| } | } | ||||
| #if defined(AUDIO_INTERFACE) | #if defined(AUDIO_INTERFACE) | ||||
| case 0x0B01: // SET_INTERFACE (alternate setting) | case 0x0B01: // SET_INTERFACE (alternate setting) | ||||
| if (setup.wIndex == AUDIO_INTERFACE+1) { | if (setup.wIndex == AUDIO_INTERFACE+1) { | ||||
| //audio_tx_alternate_setting = setup.wValue; | |||||
| usb_audio_transmit_setting = setup.wValue; | |||||
| } else if (setup.wIndex == AUDIO_INTERFACE+2) { | } else if (setup.wIndex == AUDIO_INTERFACE+2) { | ||||
| //audio_rx_alternate_setting = setup.wValue; | |||||
| usb_audio_receive_setting = setup.wValue; | |||||
| } else { | } else { | ||||
| endpoint0_stall(); | endpoint0_stall(); | ||||
| return; | return; | ||||
| datalen = 1; | datalen = 1; | ||||
| data = reply_buffer; | data = reply_buffer; | ||||
| if (setup.wIndex == AUDIO_INTERFACE+1) { | if (setup.wIndex == AUDIO_INTERFACE+1) { | ||||
| reply_buffer[0] = 0; | |||||
| //reply_buffer[0] = audio_tx_alternate_setting; | |||||
| reply_buffer[0] = usb_audio_transmit_setting; | |||||
| } else if (setup.wIndex == AUDIO_INTERFACE+2) { | } else if (setup.wIndex == AUDIO_INTERFACE+2) { | ||||
| reply_buffer[0] = 0; | |||||
| //reply_buffer[0] = audio_rx_alternate_setting; | |||||
| reply_buffer[0] = usb_audio_receive_setting; | |||||
| } else { | } else { | ||||
| endpoint0_stall(); | endpoint0_stall(); | ||||
| return; | return; |
| extern uint16_t usb_audio_receive_buffer[]; | extern uint16_t usb_audio_receive_buffer[]; | ||||
| extern uint16_t usb_audio_transmit_buffer[]; | extern uint16_t usb_audio_transmit_buffer[]; | ||||
| extern uint32_t usb_audio_sync_feedback; | extern uint32_t usb_audio_sync_feedback; | ||||
| extern uint8_t usb_audio_receive_setting; | |||||
| extern uint8_t usb_audio_transmit_setting; | |||||
| extern void usb_audio_receive_callback(unsigned int len); | extern void usb_audio_receive_callback(unsigned int len); | ||||
| extern unsigned int usb_audio_transmit_callback(void); | extern unsigned int usb_audio_transmit_callback(void); | ||||
| #endif | #endif |