Add vendor request to retrieve buffer size.

This commit is contained in:
Martin Ling 2025-12-18 07:21:58 +00:00
parent 3517d0adfc
commit 9584416b49
4 changed files with 27 additions and 1 deletions

View file

@ -183,6 +183,7 @@ static usb_request_handler_fn vendor_request_handler[] = {
usb_vendor_request_test_rtc_osc,
usb_vendor_request_write_radio_reg,
usb_vendor_request_read_radio_reg,
usb_vendor_request_get_buffer_size,
};
static const uint32_t vendor_request_handler_count =

View file

@ -450,6 +450,28 @@ usb_request_status_t usb_vendor_request_set_rx_overrun_limit(
return USB_REQUEST_STATUS_OK;
}
usb_request_status_t usb_vendor_request_get_buffer_size(
usb_endpoint_t* const endpoint,
const usb_transfer_stage_t stage)
{
if (stage == USB_TRANSFER_STAGE_SETUP) {
uint32_t value = USB_SAMP_BUFFER_SIZE + USB_BULK_BUFFER_SIZE;
endpoint->buffer[0] = value & 0xff;
endpoint->buffer[1] = (value & 0xff00) >> 8;
endpoint->buffer[2] = (value & 0xff0000) >> 16;
endpoint->buffer[3] = (value & 0xff000000) >> 24;
usb_transfer_schedule_block(
endpoint->in,
&endpoint->buffer,
4,
NULL,
NULL);
usb_transfer_schedule_ack(endpoint->out);
return USB_REQUEST_STATUS_OK;
}
return USB_REQUEST_STATUS_OK;
}
void transceiver_start_dma(void* src, void* dest, size_t size)
{
dma_pending = size;

View file

@ -77,6 +77,9 @@ usb_request_status_t usb_vendor_request_set_tx_underrun_limit(
usb_request_status_t usb_vendor_request_set_rx_overrun_limit(
usb_endpoint_t* const endpoint,
const usb_transfer_stage_t stage);
usb_request_status_t usb_vendor_request_get_buffer_size(
usb_endpoint_t* const endpoint,
const usb_transfer_stage_t stage);
void request_transceiver_mode(transceiver_mode_t mode);
void transceiver_startup(transceiver_mode_t mode);

View file

@ -30,7 +30,7 @@
#define USB_VENDOR_ID (0x1D50)
#define USB_API_VERSION (0x0111)
#define USB_API_VERSION (0x0112)
#define USB_WORD(x) (x & 0xFF), ((x >> 8) & 0xFF)