aboutsummaryrefslogtreecommitdiffstats
path: root/libmaple/usb/stm32f1/usb_reg_map.c
diff options
context:
space:
mode:
authorManuel Odendahl <wesen@ruinwesen.com>2012-11-26 17:20:27 +0100
committerManuel Odendahl <wesen@ruinwesen.com>2013-01-17 20:51:58 +0100
commit207281a869e04229c275cd2a3c447456c77309f2 (patch)
tree074efb90fee9257b5c8b4e8c68364ff0678d40bf /libmaple/usb/stm32f1/usb_reg_map.c
parentbe005eb7acc1fa08aa92b47d905e5a8ec38f5d6e (diff)
downloadlibrambutan-207281a869e04229c275cd2a3c447456c77309f2.tar.gz
librambutan-207281a869e04229c275cd2a3c447456c77309f2.zip
Add double buffering routines
Signed-off-by: Manuel Odendahl <wesen@ruinwesen.com>
Diffstat (limited to 'libmaple/usb/stm32f1/usb_reg_map.c')
-rw-r--r--libmaple/usb/stm32f1/usb_reg_map.c20
1 files changed, 20 insertions, 0 deletions
diff --git a/libmaple/usb/stm32f1/usb_reg_map.c b/libmaple/usb/stm32f1/usb_reg_map.c
index 75562e1..fbfca86 100644
--- a/libmaple/usb/stm32f1/usb_reg_map.c
+++ b/libmaple/usb/stm32f1/usb_reg_map.c
@@ -58,6 +58,26 @@ void usb_copy_from_pma(uint8 *buf, uint16 len, uint16 pma_offset) {
}
}
+void usb_set_ep_rx_buf0_count(uint8 ep, uint16 count) {
+ uint32 *rxc = usb_ep_tx_count_ptr(ep);
+ uint16 nblocks;
+ if (count > 62) {
+ /* use 32-byte memory block size */
+ nblocks = count >> 5;
+ if ((count & 0x1F) == 0) {
+ nblocks--;
+ }
+ *rxc = (nblocks << 10) | 0x8000;
+ } else {
+ /* use 2-byte memory block size */
+ nblocks = count >> 1;
+ if ((count & 0x1) != 0) {
+ nblocks++;
+ }
+ *rxc = nblocks << 10;
+ }
+}
+
void usb_set_ep_rx_count(uint8 ep, uint16 count) {
uint32 *rxc = usb_ep_rx_count_ptr(ep);
uint16 nblocks;