From 207281a869e04229c275cd2a3c447456c77309f2 Mon Sep 17 00:00:00 2001 From: Manuel Odendahl Date: Mon, 26 Nov 2012 17:20:27 +0100 Subject: Add double buffering routines Signed-off-by: Manuel Odendahl --- libmaple/usb/stm32f1/usb_reg_map.c | 20 ++++++++++++++++++++ 1 file changed, 20 insertions(+) (limited to 'libmaple/usb/stm32f1/usb_reg_map.c') 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; -- cgit v1.2.3 From 916df2bc55c63188adc0dad9946535ba7f3e4cda Mon Sep 17 00:00:00 2001 From: Manuel Odendahl Date: Thu, 17 Jan 2013 20:49:25 +0100 Subject: Refactor setting a USB EP rx count Signed-off-by: Manuel Odendahl --- libmaple/usb/stm32f1/usb_reg_map.c | 25 +++++++------------------ 1 file changed, 7 insertions(+), 18 deletions(-) (limited to 'libmaple/usb/stm32f1/usb_reg_map.c') diff --git a/libmaple/usb/stm32f1/usb_reg_map.c b/libmaple/usb/stm32f1/usb_reg_map.c index fbfca86..71bbe0d 100644 --- a/libmaple/usb/stm32f1/usb_reg_map.c +++ b/libmaple/usb/stm32f1/usb_reg_map.c @@ -58,8 +58,7 @@ 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); +static void usb_set_ep_rx_count_common(uint32 *rxc, uint16 count) { uint16 nblocks; if (count > 62) { /* use 32-byte memory block size */ @@ -78,22 +77,12 @@ void usb_set_ep_rx_buf0_count(uint8 ep, uint16 count) { } } +void usb_set_ep_rx_buf0_count(uint8 ep, uint16 count) { + uint32 *rxc = usb_ep_tx_count_ptr(ep); + usb_set_ep_rx_count_common(rxc, count); +} + void usb_set_ep_rx_count(uint8 ep, uint16 count) { uint32 *rxc = usb_ep_rx_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; - } + usb_set_ep_rx_count_common(rxc, count); } -- cgit v1.2.3 From 24465f8e1779a9da54d03c5600da323bcdfab556 Mon Sep 17 00:00:00 2001 From: Manuel Odendahl Date: Thu, 17 Jan 2013 21:09:07 +0100 Subject: Rename misleading ptr function Signed-off-by: Manuel Odendahl --- libmaple/usb/stm32f1/usb_reg_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libmaple/usb/stm32f1/usb_reg_map.c') diff --git a/libmaple/usb/stm32f1/usb_reg_map.c b/libmaple/usb/stm32f1/usb_reg_map.c index 71bbe0d..71dfa22 100644 --- a/libmaple/usb/stm32f1/usb_reg_map.c +++ b/libmaple/usb/stm32f1/usb_reg_map.c @@ -78,7 +78,7 @@ static void usb_set_ep_rx_count_common(uint32 *rxc, uint16 count) { } void usb_set_ep_rx_buf0_count(uint8 ep, uint16 count) { - uint32 *rxc = usb_ep_tx_count_ptr(ep); + uint32 *rxc = usb_ep_rx_buf0_ptr(ep); usb_set_ep_rx_count_common(rxc, count); } -- cgit v1.2.3 From 0676b01a984b999fed54f906373078ba48b50b6f Mon Sep 17 00:00:00 2001 From: Marti Bolivar Date: Thu, 17 Jan 2013 17:48:13 -0500 Subject: usb_reg_map.c: Fix incorrect function name call. Signed-off-by: Marti Bolivar --- libmaple/usb/stm32f1/usb_reg_map.c | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'libmaple/usb/stm32f1/usb_reg_map.c') diff --git a/libmaple/usb/stm32f1/usb_reg_map.c b/libmaple/usb/stm32f1/usb_reg_map.c index 71dfa22..ea60cb3 100644 --- a/libmaple/usb/stm32f1/usb_reg_map.c +++ b/libmaple/usb/stm32f1/usb_reg_map.c @@ -78,7 +78,7 @@ static void usb_set_ep_rx_count_common(uint32 *rxc, uint16 count) { } void usb_set_ep_rx_buf0_count(uint8 ep, uint16 count) { - uint32 *rxc = usb_ep_rx_buf0_ptr(ep); + uint32 *rxc = usb_ep_rx_buf0_count_ptr(ep); usb_set_ep_rx_count_common(rxc, count); } -- cgit v1.2.3