summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorSimon Kueppers <[email protected]>2022-10-27 18:51:16 +0200
committerMengsk <[email protected]>2022-12-29 12:13:56 +0100
commit510720b396eaa610e6ae688d5f46198de4aaee29 (patch)
treec1f35e2a5cf58e697503135178d17e5120eb7fe9 /src
parent9a8439087864e2c1e19412fb5ce329cf720f5005 (diff)
Renamed pcd_set_ep_rx_cnt because it actually sets the maximum buffer size
Diffstat (limited to 'src')
-rw-r--r--src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c16
-rw-r--r--src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h10
2 files changed, 17 insertions, 9 deletions
diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
index 736150fcd..9ec8ef592 100644
--- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
+++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev.c
@@ -557,9 +557,9 @@ static void dcd_ep_ctr_rx_handler(uint32_t wIstr)
{
uint32_t remaining = (uint32_t)xfer->total_len - (uint32_t)xfer->queued_len;
if(remaining >= xfer->max_packet_size) {
- pcd_set_ep_rx_cnt(USB, EPindex,xfer->max_packet_size);
+ pcd_set_ep_rx_bufsize(USB, EPindex,xfer->max_packet_size);
} else {
- pcd_set_ep_rx_cnt(USB, EPindex,remaining);
+ pcd_set_ep_rx_bufsize(USB, EPindex,remaining);
}
pcd_set_ep_rx_status(USB, EPindex, USB_EP_RX_VALID);
}
@@ -571,7 +571,7 @@ static void dcd_ep_ctr_rx_handler(uint32_t wIstr)
if(EPindex == 0u)
{
// Always be prepared for a status packet...
- pcd_set_ep_rx_cnt(USB, EPindex, CFG_TUD_ENDPOINT0_SIZE);
+ pcd_set_ep_rx_bufsize(USB, EPindex, CFG_TUD_ENDPOINT0_SIZE);
pcd_clear_rx_ep_ctr(USB, EPindex);
}
}
@@ -828,7 +828,7 @@ bool dcd_edpt_open (uint8_t rhport, tusb_desc_endpoint_t const * p_endpoint_desc
#endif
{
*pcd_ep_rx_address_ptr(USB, epnum) = pma_addr;
- pcd_set_ep_rx_cnt(USB, epnum, buffer_size);
+ pcd_set_ep_rx_bufsize(USB, epnum, buffer_size);
pcd_clear_rx_dtog(USB, epnum);
}
@@ -939,9 +939,9 @@ bool dcd_edpt_xfer (uint8_t rhport, uint8_t ep_addr, uint8_t * buffer, uint16_t
if(total_bytes > xfer->max_packet_size)
{
- pcd_set_ep_rx_cnt(USB,epnum,xfer->max_packet_size);
+ pcd_set_ep_rx_bufsize(USB,epnum,xfer->max_packet_size);
} else {
- pcd_set_ep_rx_cnt(USB,epnum,total_bytes);
+ pcd_set_ep_rx_bufsize(USB,epnum,total_bytes);
}
pcd_set_ep_rx_status(USB, epnum, USB_EP_RX_VALID);
}
@@ -969,9 +969,9 @@ bool dcd_edpt_xfer_fifo (uint8_t rhport, uint8_t ep_addr, tu_fifo_t * ff, uint16
{
if(total_bytes > xfer->max_packet_size)
{
- pcd_set_ep_rx_cnt(USB,epnum,xfer->max_packet_size);
+ pcd_set_ep_rx_bufsize(USB,epnum,xfer->max_packet_size);
} else {
- pcd_set_ep_rx_cnt(USB,epnum,total_bytes);
+ pcd_set_ep_rx_bufsize(USB,epnum,total_bytes);
}
pcd_set_ep_rx_status(USB, epnum, USB_EP_RX_VALID);
}
diff --git a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h
index 17726e521..3130953b4 100644
--- a/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h
+++ b/src/portable/st/stm32_fsdev/dcd_stm32_fsdev_pvt_st.h
@@ -276,12 +276,20 @@ static inline __IO uint16_t* pcd_ep_rx_cnt_ptr(USB_TypeDef * USBx, uint32_t bEpN
static inline void pcd_set_ep_tx_cnt(USB_TypeDef * USBx, uint32_t bEpNum, uint32_t wCount)
{
- *pcd_ep_tx_cnt_ptr(USBx, bEpNum) = (uint16_t)wCount;
+ __IO uint16_t * reg = pcd_ep_tx_cnt_ptr(USBx, bEpNum);
+ *reg = (uint16_t) (*reg & (uint16_t) ~0x3FFU) | (wCount & 0x3FFU);
}
static inline void pcd_set_ep_rx_cnt(USB_TypeDef * USBx, uint32_t bEpNum, uint32_t wCount)
{
+ __IO uint16_t * reg = pcd_ep_rx_cnt_ptr(USBx, bEpNum);
+ *reg = (uint16_t) (*reg & (uint16_t) ~0x3FFU) | (wCount & 0x3FFU);
+}
+
+static inline void pcd_set_ep_rx_bufsize(USB_TypeDef * USBx, uint32_t bEpNum, uint32_t wCount)
+{
__IO uint16_t *pdwReg = pcd_ep_rx_cnt_ptr((USBx),(bEpNum));
+ wCount = pcd_aligned_buffer_size(wCount);
pcd_set_ep_cnt_rx_reg(pdwReg, wCount);
}