update(demo): add macro for caculating feedback value
This commit is contained in:
@@ -862,7 +862,7 @@ struct audio_cs_ep_ep_general_descriptor {
|
||||
0x05, /* bmAttributes */ \
|
||||
WBVAL(wMaxPacketSize), /* wMaxPacketSize */ \
|
||||
bInterval, /* bInterval : one packet per frame */ \
|
||||
bInterval, /* bRefresh */ \
|
||||
0x00, /* bRefresh */ \
|
||||
bFeedbackEndpointAddress, /* bSynchAddress */ \
|
||||
0x07, /* bLength */ \
|
||||
AUDIO_ENDPOINT_DESCRIPTOR_TYPE, /* bDescriptorType */ \
|
||||
@@ -874,10 +874,10 @@ struct audio_cs_ep_ep_general_descriptor {
|
||||
0x09, /* bLength */ \
|
||||
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
|
||||
bFeedbackEndpointAddress, /* bFeedbackEndpointAddress Revise Dir to bEndpointAddress */ \
|
||||
0x11, /* bmAttributes: TransferType=Isochronous SyncType=None EndpointType=Feedback */ \
|
||||
0x15, /* bmAttributes: TransferType=Isochronous SyncType=Asynchronous EndpointType=Feedback */ \
|
||||
WBVAL(4), /* XXXX wMaxPacketSize in Bytes */ \
|
||||
bInterval, /* bInterval */ \
|
||||
0x00, /* bRefresh */ \
|
||||
0x03, /* bRefresh, 8ms */ \
|
||||
0x00 /* bSynchAddress */
|
||||
|
||||
#define AUDIO_AS_DESCRIPTOR_INIT_LEN(n) (0x09 + 0x09 + 0x07 + 0x08 + 3 * n + 0x09 + 0x07)
|
||||
@@ -1325,7 +1325,7 @@ struct audio_v2_control_range3_param_block {
|
||||
0x07, /* bLength */ \
|
||||
USB_DESCRIPTOR_TYPE_ENDPOINT, /* bDescriptorType */ \
|
||||
bFeedbackEndpointAddress, /* bFeedbackEndpointAddress Revise Dir to bEndpointAddress */ \
|
||||
0x11, /* bmAttributes: TransferType=Isochronous SyncType=None EndpointType=Feedback */ \
|
||||
0x15, /* bmAttributes: TransferType=Isochronous SyncType=Asynchronous EndpointType=Feedback */ \
|
||||
WBVAL(4), /* XXXX wMaxPacketSize in Bytes */ \
|
||||
bInterval /* bInterval */
|
||||
|
||||
@@ -1340,4 +1340,19 @@ struct audio_v2_control_range3_param_block {
|
||||
#define AUDIO_SAMPLE_FREQ_4B(frq) (uint8_t)(frq), (uint8_t)((frq >> 8)), \
|
||||
(uint8_t)((frq >> 16)), (uint8_t)((frq >> 24))
|
||||
|
||||
/* format 10.14 */
|
||||
#define AUDIO_UPDATE_FEEDBACK_DATA_FS(buf, freq) \
|
||||
uint32_t value = ((freq / 1000) << 14) | ((freq % 1000) << 4); \
|
||||
buf[0] = ((value >> 0U) & 0xFFU); \
|
||||
buf[1] = ((value >> 8U) & 0xFFU); \
|
||||
buf[2] = ((value >> 16U) & 0xFFU)
|
||||
|
||||
/* format 16.16 */
|
||||
#define AUDIO_UPDATE_FEEDBACK_DATA_HS(buf, freq) \
|
||||
uint32_t value = ((freq / 1000) << 13) | ((freq % 1000) << 3); \
|
||||
buf[0] = ((value >> 0U) & 0xFFU); \
|
||||
buf[1] = ((value >> 8U) & 0xFFU); \
|
||||
buf[2] = ((value >> 16U) & 0xFFU); \
|
||||
buf[3] = ((value >> 24U) & 0xFFU)
|
||||
|
||||
#endif /* USB_AUDIO_H */
|
||||
|
||||
@@ -211,6 +211,7 @@ void usbd_audio_open(uint8_t busid, uint8_t intf)
|
||||
rx_flag = 1;
|
||||
/* setup first out ep read transfer */
|
||||
usbd_ep_start_read(busid, AUDIO_OUT_EP, read_buffer, AUDIO_OUT_PACKET);
|
||||
AUDIO_UPDATE_FEEDBACK_DATA_FS(s_speaker_feedback_buffer, AUDIO_SPEAKER_FREQ); /* uac1 can only use 10.14 */
|
||||
usbd_ep_start_write(busid, AUDIO_OUT_FEEDBACK_EP, s_speaker_feedback_buffer, FEEDBACK_ENDP_PACKET_SIZE);
|
||||
printf("OPEN1\r\n");
|
||||
} else {
|
||||
@@ -248,6 +249,7 @@ void usbd_audio_in_callback(uint8_t busid, uint8_t ep, uint32_t nbytes)
|
||||
void usbd_audio_iso_out_feedback_callback(uint8_t busid, uint8_t ep, uint32_t nbytes)
|
||||
{
|
||||
USB_LOG_RAW("actual feedback len:%d\r\n", nbytes);
|
||||
AUDIO_UPDATE_FEEDBACK_DATA_FS(s_speaker_feedback_buffer, AUDIO_SPEAKER_FREQ);
|
||||
usbd_ep_start_write(busid, AUDIO_OUT_FEEDBACK_EP, s_speaker_feedback_buffer, FEEDBACK_ENDP_PACKET_SIZE);
|
||||
}
|
||||
#endif
|
||||
|
||||
@@ -232,6 +232,11 @@ void usbd_audio_open(uint8_t busid, uint8_t intf)
|
||||
rx_flag = 1;
|
||||
/* setup first out ep read transfer */
|
||||
usbd_ep_start_read(busid, AUDIO_OUT_EP, read_buffer, AUDIO_OUT_PACKET);
|
||||
#ifdef CONFIG_USB_HS
|
||||
AUDIO_UPDATE_FEEDBACK_DATA_HS(s_speaker_feedback_buffer, AUDIO_FREQ);
|
||||
#else
|
||||
AUDIO_UPDATE_FEEDBACK_DATA_FS(s_speaker_feedback_buffer, AUDIO_FREQ);
|
||||
#endif
|
||||
usbd_ep_start_write(busid, AUDIO_OUT_FEEDBACK_EP, s_speaker_feedback_buffer, FEEDBACK_ENDP_PACKET_SIZE);
|
||||
USB_LOG_RAW("OPEN\r\n");
|
||||
}
|
||||
@@ -259,6 +264,11 @@ void usbd_audio_iso_out_callback(uint8_t busid, uint8_t ep, uint32_t nbytes)
|
||||
void usbd_audio_iso_out_feedback_callback(uint8_t busid, uint8_t ep, uint32_t nbytes)
|
||||
{
|
||||
USB_LOG_RAW("actual feedback len:%d\r\n", nbytes);
|
||||
#ifdef CONFIG_USB_HS
|
||||
AUDIO_UPDATE_FEEDBACK_DATA_HS(s_speaker_feedback_buffer, AUDIO_FREQ);
|
||||
#else
|
||||
AUDIO_UPDATE_FEEDBACK_DATA_FS(s_speaker_feedback_buffer, AUDIO_FREQ);
|
||||
#endif
|
||||
usbd_ep_start_write(busid, AUDIO_OUT_FEEDBACK_EP, s_speaker_feedback_buffer, FEEDBACK_ENDP_PACKET_SIZE);
|
||||
}
|
||||
#endif
|
||||
|
||||
Reference in New Issue
Block a user