Skip to content

Commit 3fd7f89

Browse files
Algot Axelzonkartben
authored andcommitted
drivers: usb: stm32: add support for incomplete isochronous in transfer
Implement the HAL callback function `HAL_PCD_ISOINIncompleteCallback` in which the endpoint write semaphore is given back, thus allowing subsequent writes to the endpoint after an isochronous transfer has been incompleted (not read by the host). This approach was chosen because it is similar to what is done in the already implemented HAL callback `HAL_PCD_DataInStageCallback` which also gives the write semaphore back but also calls the endpoint callback function. The reason for not also calling the endpoint callback function is because I do not see any appropriate cb_status (`enum usb_dc_ep_cb_status_code`) to pass. If passing `USB_DC_EP_DATA_IN` is okay even though "In transaction done on this EP" is not completely true, then this should also be added. This has been tested by setting up an isochronous endpoint, writing to it, and verify that `HAL_PCD_DataInStageCallback` is called and subsequent writes are possible. Signed-off-by: Algot Axelzon <[email protected]>
1 parent 0c6a367 commit 3fd7f89

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

drivers/usb/device/usb_dc_stm32.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1277,6 +1277,19 @@ void HAL_PCD_DataInStageCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
12771277
}
12781278
}
12791279

1280+
void HAL_PCD_ISOINIncompleteCallback(PCD_HandleTypeDef *hpcd, uint8_t epnum)
1281+
{
1282+
uint8_t ep_idx = USB_EP_GET_IDX(epnum);
1283+
uint8_t ep = ep_idx | USB_EP_DIR_IN;
1284+
struct usb_dc_stm32_ep_state *ep_state = usb_dc_stm32_get_ep_state(ep);
1285+
1286+
LOG_DBG("epnum 0x%02x", epnum);
1287+
1288+
__ASSERT(ep_state, "No corresponding ep_state for ep");
1289+
1290+
k_sem_give(&ep_state->write_sem);
1291+
}
1292+
12801293
#if (defined(USB) || defined(USB_DRD_FS)) && DT_INST_NODE_HAS_PROP(0, disconnect_gpios)
12811294
void HAL_PCDEx_SetConnectionState(PCD_HandleTypeDef *hpcd, uint8_t state)
12821295
{

0 commit comments

Comments
 (0)