summaryrefslogtreecommitdiff
path: root/src/portable
diff options
context:
space:
mode:
authorNathan Conrad <[email protected]>2020-04-12 21:07:17 -0400
committerNathan Conrad <[email protected]>2020-04-12 21:27:27 -0400
commit0eeaccaf46c28444cc0830895559652cf5638c60 (patch)
tree2a31a54dd03a0ff7a413427e3cee6a9036bd85e4 /src/portable
parent2ff3f765db7e62201d0491093111b0d649446046 (diff)
Skeleton, and initial stm32fsdev implementation (that leaks memory)
Diffstat (limited to 'src/portable')
-rw-r--r--src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c37
1 files changed, 36 insertions, 1 deletions
diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
index f962a4bee..fa044e2d6 100644
--- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
@@ -69,7 +69,6 @@
* - Endpoint index is the ID of the endpoint
* - This means that priority is given to endpoints with lower ID numbers
* - Code is mixing up EP IX with EP ID. Everywhere.
- * - No way to close endpoints; Can a device be reconfigured without a reset?
* - Packet buffer memory is copied in the interrupt.
* - This is better for performance, but means interrupts are disabled for longer
* - DMA may be the best choice, but it could also be pushed to the USBD task.
@@ -623,6 +622,7 @@ bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc
if(dir == TUSB_DIR_IN)
{
+ // FIXME: use pma_alloc to allocate memory dynamically
*pcd_ep_tx_address_ptr(USB, epnum) = ep_buf_ptr;
pcd_set_ep_tx_cnt(USB, epnum, p_endpoint_desc->wMaxPacketSize.size);
pcd_clear_tx_dtog(USB, epnum);
@@ -630,6 +630,7 @@ bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc
}
else
{
+ // FIXME: use pma_alloc to allocate memory dynamically
*pcd_ep_rx_address_ptr(USB, epnum) = ep_buf_ptr;
pcd_set_ep_rx_cnt(USB, epnum, p_endpoint_desc->wMaxPacketSize.size);
pcd_clear_rx_dtog(USB, epnum);
@@ -642,6 +643,40 @@ bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc
return true;
}
+/**
+ * Close an endpoint.
+ *
+ * This function should be called with interrupts enabled, though
+ * this implementation should be valid with them disabled, too.
+ * This also clears transfers in progress, should there be any.
+ */
+void dcd_edpt_close (uint8_t rhport, uint8_t ep_addr)
+{
+ (void)rhport;
+ uint32_t const epnum = tu_edpt_number(ep_addr);
+ uint32_t const dir = tu_edpt_dir(ep_addr);
+
+#ifndef NDEBUG
+ TU_ASSERT(epnum < MAX_EP_COUNT, /**/);
+#endif
+
+ //uint16_t memptr;
+
+ if(dir == TUSB_DIR_IN)
+ {
+ pcd_set_ep_tx_status(USB,epnum,USB_EP_TX_DIS);
+ //memptr = *pcd_ep_tx_address_ptr(USB, epnum);
+ }
+ else
+ {
+ pcd_set_ep_rx_status(USB, epnum, USB_EP_RX_DIS);
+ //memptr = *pcd_ep_rx_address_ptr(USB, epnum);
+ }
+
+ // FIXME: Free memory
+ // pma_free(memptr);
+}
+
// Currently, single-buffered, and only 64 bytes at a time (max)
static void dcd_transmit_packet(xfer_ctl_t * xfer, uint16_t ep_ix)