projects
/
bertos.git
/ blobdiff
commit
grep
author
committer
pickaxe
?
search:
re
summary
|
shortlog
|
log
|
commit
|
commitdiff
|
tree
raw
|
inline
| side by side
STM32: USB: endpoint buffer must be 4-bytes aligned
[bertos.git]
/
bertos
/
cpu
/
cortex-m3
/
drv
/
usb_stm32.c
diff --git
a/bertos/cpu/cortex-m3/drv/usb_stm32.c
b/bertos/cpu/cortex-m3/drv/usb_stm32.c
index a47237e9b51c2e1f2ec10428634ee411a13da91a..752b8e2d35868d5ff845944690ecaeabac87c8c1 100644
(file)
--- a/
bertos/cpu/cortex-m3/drv/usb_stm32.c
+++ b/
bertos/cpu/cortex-m3/drv/usb_stm32.c
@@
-84,7
+84,7
@@
struct stm32_usb
static struct stm32_usb *usb = (struct stm32_usb *)USB_BASE_ADDR;
/* Endpoint descriptors: used for handling requests to use with endpoints */
static struct stm32_usb *usb = (struct stm32_usb *)USB_BASE_ADDR;
/* Endpoint descriptors: used for handling requests to use with endpoints */
-static stm32_
usb_ep_t
ep_cnfg[ENP_MAX_NUMB];
+static stm32_
UsbEp
ep_cnfg[ENP_MAX_NUMB];
/* USB EP0 control descriptor */
static const UsbEndpointDesc USB_CtrlEpDescr0 =
/* USB EP0 control descriptor */
static const UsbEndpointDesc USB_CtrlEpDescr0 =
@@
-137,14
+137,14
@@
static stm32_udc_t udc;
static UsbDevice *usb_dev;
/* USB packet memory management: list of allocated chunks */
static UsbDevice *usb_dev;
/* USB packet memory management: list of allocated chunks */
-static
pack_mem_slot_
t *mem_use;
+static
stm32_UsbMemSlo
t *mem_use;
/* USB packet memory management: memory buffer metadata */
#define EP_MAX_SLOTS 16
/* USB packet memory management: memory buffer metadata */
#define EP_MAX_SLOTS 16
-static
pack_mem_slot_
t memory_buffer[EP_MAX_SLOTS];
+static
stm32_UsbMemSlo
t memory_buffer[EP_MAX_SLOTS];
/* Allocate a free block of the packet memory */
/* Allocate a free block of the packet memory */
-static
pack_mem_slot_
t *usb_malloc(void)
+static
stm32_UsbMemSlo
t *usb_malloc(void)
{
unsigned int i;
{
unsigned int i;
@@
-155,7
+155,7
@@
static pack_mem_slot_t *usb_malloc(void)
}
/* Release a block of the packet memory */
}
/* Release a block of the packet memory */
-static void usb_free(
pack_mem_slot_
t *pPntr)
+static void usb_free(
stm32_UsbMemSlo
t *pPntr)
{
pPntr->Size = 0;
}
{
pPntr->Size = 0;
}
@@
-164,7
+164,7
@@
static void usb_free(pack_mem_slot_t *pPntr)
static bool usb_alloc_buffer(uint16_t *pOffset, uint32_t *size,
int EndPoint)
{
static bool usb_alloc_buffer(uint16_t *pOffset, uint32_t *size,
int EndPoint)
{
-
pack_mem_slot_
t *mem = mem_use,
+
stm32_UsbMemSlo
t *mem = mem_use,
*memNext, *mem_useNew;
uint32_t max_size = *size;
*memNext, *mem_useNew;
uint32_t max_size = *size;
@@
-226,7
+226,7
@@
static bool usb_alloc_buffer(uint16_t *pOffset, uint32_t *size,
/* Release a chunk of the packet memory (inside a block) */
static void usb_free_buffer(int EndPoint)
{
/* Release a chunk of the packet memory (inside a block) */
static void usb_free_buffer(int EndPoint)
{
-
pack_mem_slot_
t *mem, *memPrev = NULL;
+
stm32_UsbMemSlo
t *mem, *memPrev = NULL;
mem = mem_use;
while (mem != NULL)
mem = mem_use;
while (mem != NULL)
@@
-293,7
+293,7
@@
static int usb_ep_logical_to_hw(uint8_t ep_addr)
}
/* Set EP address */
}
/* Set EP address */
-static void
EpCtrlSet_EA
(reg32_t *reg, uint32_t val)
+static void
ep_ctrl_set_ea
(reg32_t *reg, uint32_t val)
{
val &= 0x0f;
val |= *reg & 0x0700;
{
val &= 0x0f;
val |= *reg & 0x0700;
@@
-302,13
+302,13
@@
static void EpCtrlSet_EA(reg32_t *reg, uint32_t val)
}
/* Get EP IN status */
}
/* Get EP IN status */
-static uint32_t
EpCtrlGet_STAT_TX
(reg32_t *reg)
+static uint32_t
ep_ctrl_get_stat_tx
(reg32_t *reg)
{
return (*reg & (0x3UL << 4)) >> 4;
}
/* Set EP IN state */
{
return (*reg & (0x3UL << 4)) >> 4;
}
/* Set EP IN state */
-static void
EpCtrlSet_STAT_TX(reg32_t *reg, ep_state_t
val)
+static void
ep_ctrl_set_stat_tx(reg32_t *reg, stm32_UsbEpState
val)
{
uint32_t state;
int i;
{
uint32_t state;
int i;
@@
-319,7
+319,7
@@
static void EpCtrlSet_STAT_TX(reg32_t *reg, ep_state_t val)
*/
for (i = 0; i < 2; i++)
{
*/
for (i = 0; i < 2; i++)
{
- if (
EpCtrlGet_STAT_TX
(reg) == val)
+ if (
ep_ctrl_get_stat_tx
(reg) == val)
return;
state = val;
state <<= 4;
return;
state = val;
state <<= 4;
@@
-332,7
+332,7
@@
static void EpCtrlSet_STAT_TX(reg32_t *reg, ep_state_t val)
}
/* Set EP DTOG_TX bit (IN) */
}
/* Set EP DTOG_TX bit (IN) */
-static void
EpCtrlSet_DTOG_TX
(reg32_t *reg, uint32_t val)
+static void
ep_ctrl_set_dtog_tx
(reg32_t *reg, uint32_t val)
{
val = val ? (*reg ^ (1UL << 6)) : *reg;
/* Clear the toggle bits without DTOG_TX (6) */
{
val = val ? (*reg ^ (1UL << 6)) : *reg;
/* Clear the toggle bits without DTOG_TX (6) */
@@
-342,7
+342,7
@@
static void EpCtrlSet_DTOG_TX(reg32_t *reg, uint32_t val)
}
/* Clear EP CTR_TX bit (IN) */
}
/* Clear EP CTR_TX bit (IN) */
-static void
EpCtrlClr_CTR_TX
(reg32_t *reg)
+static void
ep_ctrl_clr_ctr_tx
(reg32_t *reg)
{
uint32_t val = *reg;
{
uint32_t val = *reg;
@@
-353,7
+353,7
@@
static void EpCtrlClr_CTR_TX(reg32_t *reg)
}
/* Clear EP CTR_RX bit (OUT) */
}
/* Clear EP CTR_RX bit (OUT) */
-static void
EpCtrlClr_CTR_RX
(reg32_t *reg)
+static void
ep_ctrl_clr_ctr_rx
(reg32_t *reg)
{
uint32_t val = *reg;
val &= ~(USB_CTRL_TOGGLE_MASK | 1UL << 15);
{
uint32_t val = *reg;
val &= ~(USB_CTRL_TOGGLE_MASK | 1UL << 15);
@@
-363,7
+363,7
@@
static void EpCtrlClr_CTR_RX(reg32_t *reg)
}
/* Set EP KIND bit */
}
/* Set EP KIND bit */
-static void
EpCtrlSet_EP_KIND
(reg32_t *reg, uint32_t val)
+static void
ep_ctrl_set_ep_kind
(reg32_t *reg, uint32_t val)
{
val = val ? (1UL << 8) : 0;
val |= *reg & ~(USB_CTRL_TOGGLE_MASK | (1UL << 8));
{
val = val ? (1UL << 8) : 0;
val |= *reg & ~(USB_CTRL_TOGGLE_MASK | (1UL << 8));
@@
-372,7
+372,7
@@
static void EpCtrlSet_EP_KIND(reg32_t *reg, uint32_t val)
}
/* Set EP type */
}
/* Set EP type */
-static int
EpCtrlSet_EP_TYPE
(reg32_t *reg, uint8_t val)
+static int
ep_ctrl_set_ep_type
(reg32_t *reg, uint8_t val)
{
uint32_t type;
{
uint32_t type;
@@
-391,14
+391,14
@@
static int EpCtrlSet_EP_TYPE(reg32_t *reg, uint8_t val)
}
/* Get EP STAT_RX (OUT) */
}
/* Get EP STAT_RX (OUT) */
-static uint32_t
EpCtrlGet_STAT_RX
(reg32_t *reg)
+static uint32_t
ep_ctrl_get_stat_rx
(reg32_t *reg)
{
uint32_t val = *reg & (0x3UL << 12);
return val >> 12;
}
/* Set EP STAT_RX (OUT) */
{
uint32_t val = *reg & (0x3UL << 12);
return val >> 12;
}
/* Set EP STAT_RX (OUT) */
-static void
EpCtrlSet_STAT_RX(reg32_t *reg, ep_state_t
val)
+static void
ep_ctrl_set_stat_rx(reg32_t *reg, stm32_UsbEpState
val)
{
uint32_t state;
int i;
{
uint32_t state;
int i;
@@
-409,7
+409,7
@@
static void EpCtrlSet_STAT_RX(reg32_t *reg, ep_state_t val)
*/
for (i = 0; i < 2; i++)
{
*/
for (i = 0; i < 2; i++)
{
- if (
EpCtrlGet_STAT_RX
(reg) == val)
+ if (
ep_ctrl_get_stat_rx
(reg) == val)
return;
state = val;
state <<= 12;
return;
state = val;
state <<= 12;
@@
-422,7
+422,7
@@
static void EpCtrlSet_STAT_RX(reg32_t *reg, ep_state_t val)
}
/* Set DTOG_RX bit */
}
/* Set DTOG_RX bit */
-static void
EpCtrlSet_DTOG_RX
(reg32_t *reg, uint32_t val)
+static void
ep_ctrl_set_dtog_rx
(reg32_t *reg, uint32_t val)
{
val = val ? (*reg ^ (1UL << 14)) : *reg;
/* Clear the toggle bits without DTOG_RX (14) */
{
val = val ? (*reg ^ (1UL << 14)) : *reg;
/* Clear the toggle bits without DTOG_RX (14) */
@@
-432,7
+432,7
@@
static void EpCtrlSet_DTOG_RX(reg32_t *reg, uint32_t val)
}
/* Get EP SETUP bit */
}
/* Get EP SETUP bit */
-static uint32_t
EpCtrlGet_SETUP
(reg32_t *reg)
+static uint32_t
ep_ctrl_get_setup
(reg32_t *reg)
{
uint32_t val = *reg & (1UL << 11);
return val ? 1 : 0;
{
uint32_t val = *reg & (1UL << 11);
return val ? 1 : 0;
@@
-443,8
+443,7
@@
static void __usb_ep_io(int EP)
{
ssize_t Count, CountHold, Offset;
uint32_t *pDst, *pSrc, Data;
{
ssize_t Count, CountHold, Offset;
uint32_t *pDst, *pSrc, Data;
- bool CurrentBuffer;
- stm32_usb_ep_t *epd = &ep_cnfg[EP];
+ stm32_UsbEp *epd = &ep_cnfg[EP];
if (UNLIKELY(epd->hw == NULL))
{
if (UNLIKELY(epd->hw == NULL))
{
@@
-480,15
+479,14
@@
static void __usb_ep_io(int EP)
epd->flags |= STM32_USB_EP_ZERO_PACKET;
Offset = epd->offset;
epd->offset += Count;
epd->flags |= STM32_USB_EP_ZERO_PACKET;
Offset = epd->offset;
epd->offset += Count;
- CurrentBuffer = true;
switch (epd->type)
{
case USB_ENDPOINT_XFER_CONTROL:
case USB_ENDPOINT_XFER_INT:
switch (epd->type)
{
case USB_ENDPOINT_XFER_CONTROL:
case USB_ENDPOINT_XFER_INT:
- pDst = (uint32_t *)
addr2usbmem(ReadEpDTB_AddrTx(EP >> 1
));
+ pDst = (uint32_t *)
USB_MEM_ADDR(EP_DTB_READ(EP >> 1, ADDR_TX_OFFSET
));
break;
case USB_ENDPOINT_XFER_BULK:
break;
case USB_ENDPOINT_XFER_BULK:
- pDst = (uint32_t *)
addr2usbmem(ReadEpDTB_AddrTx(EP >> 1
));
+ pDst = (uint32_t *)
USB_MEM_ADDR(EP_DTB_READ(EP >> 1, ADDR_TX_OFFSET
));
break;
case USB_ENDPOINT_XFER_ISOC:
LOG_ERR("%s: isochronous transfer not supported\n",
break;
case USB_ENDPOINT_XFER_ISOC:
LOG_ERR("%s: isochronous transfer not supported\n",
@@
-511,12
+509,8
@@
static void __usb_ep_io(int EP)
*pDst++ = Data;
}
*pDst++ = Data;
}
- if (CurrentBuffer)
- WriteEpDTB_CountTx(EP >> 1, CountHold);
- else
- WriteEpDTB_CountRx(EP >> 1, CountHold);
-
- EpCtrlSet_STAT_TX(epd->hw, EP_VALID);
+ EP_DTB_WRITE(EP >> 1, COUNT_TX_OFFSET, CountHold);
+ ep_ctrl_set_stat_tx(epd->hw, EP_VALID);
--ep_cnfg[EP].avail_data;
Count = epd->size - epd->offset;
--ep_cnfg[EP].avail_data;
Count = epd->size - epd->offset;
@@
-540,15
+534,15
@@
static void __usb_ep_io(int EP)
case USB_ENDPOINT_XFER_CONTROL:
case USB_ENDPOINT_XFER_INT:
/* Get received bytes number */
case USB_ENDPOINT_XFER_CONTROL:
case USB_ENDPOINT_XFER_INT:
/* Get received bytes number */
- Count =
ReadEpDTB_CountRx(EP >> 1
) & 0x3FF;
+ Count =
EP_DTB_READ(EP >> 1, COUNT_RX_OFFSET
) & 0x3FF;
/* Get address of the USB packet buffer for corresponding EP */
/* Get address of the USB packet buffer for corresponding EP */
- pSrc = (uint32_t *)
addr2usbmem(ReadEpDTB_AddrRx(EP >> 1
));
+ pSrc = (uint32_t *)
USB_MEM_ADDR(EP_DTB_READ(EP >> 1, ADDR_RX_OFFSET
));
break;
case USB_ENDPOINT_XFER_BULK:
/* Get received bytes number */
break;
case USB_ENDPOINT_XFER_BULK:
/* Get received bytes number */
- Count =
ReadEpDTB_CountRx(EP >> 1
) & 0x3FF;
+ Count =
EP_DTB_READ(EP >> 1, COUNT_RX_OFFSET
) & 0x3FF;
/* Get address of the USB packet buffer for corresponding EP */
/* Get address of the USB packet buffer for corresponding EP */
- pSrc = (uint32_t *)
addr2usbmem(ReadEpDTB_AddrRx(EP >> 1
));
+ pSrc = (uint32_t *)
USB_MEM_ADDR(EP_DTB_READ(EP >> 1, ADDR_RX_OFFSET
));
break;
case USB_ENDPOINT_XFER_ISOC:
LOG_ERR("%s: isochronous transfer not supported\n",
break;
case USB_ENDPOINT_XFER_ISOC:
LOG_ERR("%s: isochronous transfer not supported\n",
@@
-589,7
+583,7
@@
static void __usb_ep_io(int EP)
}
}
}
}
-
EpCtrlSet_STAT_RX
(epd->hw, EP_VALID);
+
ep_ctrl_set_stat_rx
(epd->hw, EP_VALID);
--ep_cnfg[EP].avail_data;
--ep_cnfg[EP].avail_data;
@@
-631,7
+625,7
@@
static size_t usb_size(size_t size, size_t host_size)
#define USB_EP_IO(__EP, __op, __buf, __size, __complete) \
({ \
cpu_flags_t flags; \
#define USB_EP_IO(__EP, __op, __buf, __size, __complete) \
({ \
cpu_flags_t flags; \
- stm32_
usb_io_status_t ret;
\
+ stm32_
UsbIoStatus ret;
\
\
/* Fill EP descriptor */ \
IRQ_SAVE_DISABLE(flags); \
\
/* Fill EP descriptor */ \
IRQ_SAVE_DISABLE(flags); \
@@
-674,7
+668,7
@@
out: \
})
/* Configure and endponint and perform a read operation */
})
/* Configure and endponint and perform a read operation */
-static stm32_
usb_io_status_t
+static stm32_
UsbIoStatus
__usb_ep_read(int ep, void *buffer, ssize_t size, void (*complete)(int))
{
if (UNLIKELY(ep >= ENP_MAX_NUMB))
__usb_ep_read(int ep, void *buffer, ssize_t size, void (*complete)(int))
{
if (UNLIKELY(ep >= ENP_MAX_NUMB))
@@
-687,7
+681,7
@@
__usb_ep_read(int ep, void *buffer, ssize_t size, void (*complete)(int))
}
/* Configure and endponint and perform a write operation */
}
/* Configure and endponint and perform a write operation */
-static stm32_
usb_io_status_t
+static stm32_
UsbIoStatus
__usb_ep_write(int ep, const void *buffer, ssize_t size, void (*complete)(int))
{
if (UNLIKELY(ep >= ENP_MAX_NUMB))
__usb_ep_write(int ep, const void *buffer, ssize_t size, void (*complete)(int))
{
if (UNLIKELY(ep >= ENP_MAX_NUMB))
@@
-701,21
+695,21
@@
__usb_ep_write(int ep, const void *buffer, ssize_t size, void (*complete)(int))
static void usb_ep_low_level_config(int ep, uint16_t offset, uint16_t size)
{
static void usb_ep_low_level_config(int ep, uint16_t offset, uint16_t size)
{
- stm32_
usb_ep_t
*epc = &ep_cnfg[ep];
+ stm32_
UsbEp
*epc = &ep_cnfg[ep];
/* IN EP */
if (ep & 0x01)
{
/* Disable EP */
/* IN EP */
if (ep & 0x01)
{
/* Disable EP */
-
EpCtrlSet_STAT_TX
(epc->hw, EP_DISABLED);
+
ep_ctrl_set_stat_tx
(epc->hw, EP_DISABLED);
/* Clear Tx toggle */
/* Clear Tx toggle */
-
EpCtrlSet_DTOG_TX
(epc->hw, 0);
+
ep_ctrl_set_dtog_tx
(epc->hw, 0);
/* Clear Correct Transfer for transmission flag */
/* Clear Correct Transfer for transmission flag */
-
EpCtrlClr_CTR_TX
(epc->hw);
+
ep_ctrl_clr_ctr_tx
(epc->hw);
/* Update EP description table */
/* Update EP description table */
-
WriteEpDTB_AddrTx(ep >> 1
, offset);
-
WriteEpDTB_CountTx(ep >> 1
, 0);
+
EP_DTB_WRITE(ep >> 1, ADDR_TX_OFFSET
, offset);
+
EP_DTB_WRITE(ep >> 1, COUNT_TX_OFFSET
, 0);
}
/* OUT EP */
else
}
/* OUT EP */
else
@@
-723,19
+717,19
@@
static void usb_ep_low_level_config(int ep, uint16_t offset, uint16_t size)
uint16_t rx_count = 0;
/* Disable EP */
uint16_t rx_count = 0;
/* Disable EP */
-
EpCtrlSet_STAT_RX
(epc->hw, EP_DISABLED);
+
ep_ctrl_set_stat_rx
(epc->hw, EP_DISABLED);
/* Clear Rx toggle */
/* Clear Rx toggle */
-
EpCtrlSet_DTOG_RX
(epc->hw, 0);
+
ep_ctrl_set_dtog_rx
(epc->hw, 0);
/* Clear Correct Transfer for reception flag */
/* Clear Correct Transfer for reception flag */
-
EpCtrlClr_CTR_RX
(epc->hw);
+
ep_ctrl_clr_ctr_rx
(epc->hw);
/* Descriptor block size field */
rx_count |= (size > 62) << 15;
/* Descriptor number of blocks field */
rx_count |= (((size > 62) ? (size >> 5) - 1 : size >> 1) &
0x1f) << 10;
/* Update EP description table */
/* Descriptor block size field */
rx_count |= (size > 62) << 15;
/* Descriptor number of blocks field */
rx_count |= (((size > 62) ? (size >> 5) - 1 : size >> 1) &
0x1f) << 10;
/* Update EP description table */
-
WriteEpDTB_AddrRx(ep >> 1
, offset);
-
WriteEpDTB_CountRx(ep >> 1
, rx_count);
+
EP_DTB_WRITE(ep >> 1, ADDR_RX_OFFSET
, offset);
+
EP_DTB_WRITE(ep >> 1, COUNT_RX_OFFSET
, rx_count);
}
}
}
}
@@
-743,7
+737,7
@@
static void usb_ep_low_level_config(int ep, uint16_t offset, uint16_t size)
static int usb_ep_configure(const UsbEndpointDesc *epd, bool enable)
{
int EP;
static int usb_ep_configure(const UsbEndpointDesc *epd, bool enable)
{
int EP;
- stm32_
usb_ep_t
*ep_hw;
+ stm32_
UsbEp
*ep_hw;
reg32_t *hw;
uint16_t Offset;
uint32_t size;
reg32_t *hw;
uint16_t Offset;
uint32_t size;
@@
-779,7
+773,7
@@
static int usb_ep_configure(const UsbEndpointDesc *epd, bool enable)
hw += EP >> 1;
/* Set Ep Address */
hw += EP >> 1;
/* Set Ep Address */
-
EpCtrlSet_EA
(hw, EP >> 1);
+
ep_ctrl_set_ea
(hw, EP >> 1);
ep_hw->hw = hw;
LOG_INFO("%s: EP%d-%s configured\n",
__func__, EP >> 1, EP & 1 ? "IN" : "OUT");
ep_hw->hw = hw;
LOG_INFO("%s: EP%d-%s configured\n",
__func__, EP >> 1, EP & 1 ? "IN" : "OUT");
@@
-792,18
+786,18
@@
static int usb_ep_configure(const UsbEndpointDesc *epd, bool enable)
{
case USB_ENDPOINT_XFER_CONTROL:
LOG_INFO("EP%d: CONTROL IN\n", EP >> 1);
{
case USB_ENDPOINT_XFER_CONTROL:
LOG_INFO("EP%d: CONTROL IN\n", EP >> 1);
-
EpCtrlSet_EP_TYPE
(hw, EP_CTRL);
-
EpCtrlSet_EP_KIND
(hw, 0);
+
ep_ctrl_set_ep_type
(hw, EP_CTRL);
+
ep_ctrl_set_ep_kind
(hw, 0);
break;
case USB_ENDPOINT_XFER_INT:
LOG_INFO("EP%d: INTERRUPT IN\n", EP >> 1);
break;
case USB_ENDPOINT_XFER_INT:
LOG_INFO("EP%d: INTERRUPT IN\n", EP >> 1);
-
EpCtrlSet_EP_TYPE
(hw, EP_INTERRUPT);
-
EpCtrlSet_EP_KIND
(hw, 0);
+
ep_ctrl_set_ep_type
(hw, EP_INTERRUPT);
+
ep_ctrl_set_ep_kind
(hw, 0);
break;
case USB_ENDPOINT_XFER_BULK:
LOG_INFO("EP%d: BULK IN\n", EP >> 1);
break;
case USB_ENDPOINT_XFER_BULK:
LOG_INFO("EP%d: BULK IN\n", EP >> 1);
-
EpCtrlSet_EP_TYPE
(hw, EP_BULK);
-
EpCtrlSet_EP_KIND
(hw, 0);
+
ep_ctrl_set_ep_type
(hw, EP_BULK);
+
ep_ctrl_set_ep_kind
(hw, 0);
break;
case USB_ENDPOINT_XFER_ISOC:
LOG_ERR("EP%d: ISOCHRONOUS IN: not supported\n", EP >> 1);
break;
case USB_ENDPOINT_XFER_ISOC:
LOG_ERR("EP%d: ISOCHRONOUS IN: not supported\n", EP >> 1);
@@
-815,14
+809,14
@@
static int usb_ep_configure(const UsbEndpointDesc *epd, bool enable)
if (EP & 0x01)
{
/* Enable EP */
if (EP & 0x01)
{
/* Enable EP */
-
EpCtrlSet_STAT_TX
(hw, EP_NAK);
+
ep_ctrl_set_stat_tx
(hw, EP_NAK);
/* Clear Correct Transfer for transmission flag */
/* Clear Correct Transfer for transmission flag */
-
EpCtrlClr_CTR_TX
(hw);
+
ep_ctrl_clr_ctr_tx
(hw);
}
else
{
/* Enable EP */
}
else
{
/* Enable EP */
-
EpCtrlSet_STAT_RX
(hw, EP_VALID);
+
ep_ctrl_set_stat_rx
(hw, EP_VALID);
}
}
else if (ep_cnfg[EP].hw)
}
}
else if (ep_cnfg[EP].hw)
@@
-834,17
+828,17
@@
static int usb_ep_configure(const UsbEndpointDesc *epd, bool enable)
if (EP & 0x01)
{
/* Disable IN EP */
if (EP & 0x01)
{
/* Disable IN EP */
-
EpCtrlSet_STAT_TX
(hw, EP_DISABLED);
+
ep_ctrl_set_stat_tx
(hw, EP_DISABLED);
/* Clear Correct Transfer for reception flag */
/* Clear Correct Transfer for reception flag */
-
EpCtrlClr_CTR_TX
(hw);
+
ep_ctrl_clr_ctr_tx
(hw);
}
/* OUT EP */
else
{
/* Disable OUT EP */
}
/* OUT EP */
else
{
/* Disable OUT EP */
-
EpCtrlSet_STAT_RX
(hw, EP_DISABLED);
+
ep_ctrl_set_stat_rx
(hw, EP_DISABLED);
/* Clear Correct Transfer for reception flag */
/* Clear Correct Transfer for reception flag */
-
EpCtrlClr_CTR_RX
(hw);
+
ep_ctrl_clr_ctr_rx
(hw);
}
/* Release buffer */
usb_free_buffer(EP);
}
/* Release buffer */
usb_free_buffer(EP);
@@
-854,20
+848,20
@@
static int usb_ep_configure(const UsbEndpointDesc *epd, bool enable)
}
/* Get EP stall/unstall */
}
/* Get EP stall/unstall */
-static int
USB_GetStallEP
(int EP, bool *pStall)
+static int
usb_ep_get_stall
(int EP, bool *pStall)
{
if (ep_cnfg[EP].hw == NULL)
return -USB_NODEV_ERROR;
*pStall = (EP & 0x01) ?
{
if (ep_cnfg[EP].hw == NULL)
return -USB_NODEV_ERROR;
*pStall = (EP & 0x01) ?
- (
EpCtrlGet_STAT_TX
(ep_cnfg[EP].hw) == EP_STALL): /* IN EP */
- (
EpCtrlGet_STAT_RX
(ep_cnfg[EP].hw) == EP_STALL); /* OUT EP */
+ (
ep_ctrl_get_stat_tx
(ep_cnfg[EP].hw) == EP_STALL): /* IN EP */
+ (
ep_ctrl_get_stat_rx
(ep_cnfg[EP].hw) == EP_STALL); /* OUT EP */
return USB_OK;
}
/* Set EP stall/unstall */
return USB_OK;
}
/* Set EP stall/unstall */
-static int
USB_SetStallEP
(int EP, bool Stall)
+static int
usb_ep_set_stall
(int EP, bool Stall)
{
if (ep_cnfg[EP].hw == NULL)
return -USB_NODEV_ERROR;
{
if (ep_cnfg[EP].hw == NULL)
return -USB_NODEV_ERROR;
@@
-878,13
+872,13
@@
static int USB_SetStallEP(int EP, bool Stall)
if (EP & 0x01)
{
/* IN EP */
if (EP & 0x01)
{
/* IN EP */
-
EpCtrlSet_STAT_TX
(ep_cnfg[EP].hw, EP_STALL);
+
ep_ctrl_set_stat_tx
(ep_cnfg[EP].hw, EP_STALL);
ep_cnfg[EP].avail_data = 1;
}
else
{
/* OUT EP */
ep_cnfg[EP].avail_data = 1;
}
else
{
/* OUT EP */
-
EpCtrlSet_STAT_RX
(ep_cnfg[EP].hw, EP_STALL);
+
ep_ctrl_set_stat_rx
(ep_cnfg[EP].hw, EP_STALL);
ep_cnfg[EP].avail_data = 0;
}
}
ep_cnfg[EP].avail_data = 0;
}
}
@@
-896,31
+890,31
@@
static int USB_SetStallEP(int EP, bool Stall)
/* IN EP */
ep_cnfg[EP].avail_data = 1;
/* reset Data Toggle bit */
/* IN EP */
ep_cnfg[EP].avail_data = 1;
/* reset Data Toggle bit */
-
EpCtrlSet_DTOG_TX
(ep_cnfg[EP].hw, 0);
-
EpCtrlSet_STAT_TX
(ep_cnfg[EP].hw, EP_NAK);
+
ep_ctrl_set_dtog_tx
(ep_cnfg[EP].hw, 0);
+
ep_ctrl_set_stat_tx
(ep_cnfg[EP].hw, EP_NAK);
}
else
{
/* OUT EP */
ep_cnfg[EP].avail_data = 0;
/* reset Data Toggle bit */
}
else
{
/* OUT EP */
ep_cnfg[EP].avail_data = 0;
/* reset Data Toggle bit */
-
EpCtrlSet_DTOG_RX
(ep_cnfg[EP].hw, 0);
-
EpCtrlSet_STAT_RX
(ep_cnfg[EP].hw, EP_VALID);
+
ep_ctrl_set_dtog_rx
(ep_cnfg[EP].hw, 0);
+
ep_ctrl_set_stat_rx
(ep_cnfg[EP].hw, EP_VALID);
}
}
return USB_OK;
}
/* Stall both directions of the control EP */
}
}
return USB_OK;
}
/* Stall both directions of the control EP */
-static void
USB_StallCtrlEP
(void)
+static void
usb_ep_set_stall_ctrl
(void)
{
ep_cnfg[CTRL_ENP_IN].avail_data = 1;
ep_cnfg[CTRL_ENP_IN].status = STALLED;
ep_cnfg[CTRL_ENP_OUT].avail_data = 0;
ep_cnfg[CTRL_ENP_OUT].status = STALLED;
{
ep_cnfg[CTRL_ENP_IN].avail_data = 1;
ep_cnfg[CTRL_ENP_IN].status = STALLED;
ep_cnfg[CTRL_ENP_OUT].avail_data = 0;
ep_cnfg[CTRL_ENP_OUT].status = STALLED;
-
USB_SetStallEP
(CTRL_ENP_IN, true);
-
USB_SetStallEP
(CTRL_ENP_OUT, true);
+
usb_ep_set_stall
(CTRL_ENP_IN, true);
+
usb_ep_set_stall
(CTRL_ENP_OUT, true);
}
/*
}
/*
@@
-1033,7
+1027,7
@@
static void usb_set_device_state(int state)
}
/* Setup packet: set address status phase end handler */
}
/* Setup packet: set address status phase end handler */
-static void
USB_AddStatusEndHandler
(UNUSED_ARG(int, EP))
+static void
usb_add_status_handler_end
(UNUSED_ARG(int, EP))
{
uint16_t w_value;
{
uint16_t w_value;
@@
-1051,34
+1045,34
@@
static void USB_AddStatusEndHandler(UNUSED_ARG(int, EP))
}
/* Prepare status phase */
}
/* Prepare status phase */
-static void
USB_StatusP
hase(bool in)
+static void
usb_status_p
hase(bool in)
{
if (in)
__usb_ep_write(CTRL_ENP_IN, NULL, 0, NULL);
}
/* Setup packet: status phase end handler */
{
if (in)
__usb_ep_write(CTRL_ENP_IN, NULL, 0, NULL);
}
/* Setup packet: status phase end handler */
-static void
USB_StatusEndHandler
(UNUSED_ARG(int, EP))
+static void
usb_status_handler_end
(UNUSED_ARG(int, EP))
{
__usb_ep_write(CTRL_ENP_IN, NULL, -1, NULL);
__usb_ep_read(CTRL_ENP_OUT, NULL, -1, NULL);
}
/* Address status handler */
{
__usb_ep_write(CTRL_ENP_IN, NULL, -1, NULL);
__usb_ep_read(CTRL_ENP_OUT, NULL, -1, NULL);
}
/* Address status handler */
-static void
USB_StatusH
andler(UNUSED_ARG(int, EP))
+static void
usb_status_h
andler(UNUSED_ARG(int, EP))
{
if (setup_packet.mRequestType & USB_DIR_IN)
{
{
if (setup_packet.mRequestType & USB_DIR_IN)
{
-
USB_StatusP
hase(false);
- ep_cnfg[CTRL_ENP_OUT].complete =
USB_StatusEndHandler
;
+
usb_status_p
hase(false);
+ ep_cnfg[CTRL_ENP_OUT].complete =
usb_status_handler_end
;
}
else
{
}
else
{
-
USB_StatusP
hase(true);
+
usb_status_p
hase(true);
ep_cnfg[CTRL_ENP_IN].complete =
(setup_packet.bRequest == USB_REQ_SET_ADDRESS) ?
ep_cnfg[CTRL_ENP_IN].complete =
(setup_packet.bRequest == USB_REQ_SET_ADDRESS) ?
-
USB_AddStatusEndHandler
:
-
USB_StatusEndHandler
;
+
usb_add_status_handler_end
:
+
usb_status_handler_end
;
}
}
}
}
@@
-1102,15
+1096,21
@@
ssize_t usb_endpointRead(int ep, void *buffer, ssize_t size)
{
int ep_num = usb_ep_logical_to_hw(ep);
{
int ep_num = usb_ep_logical_to_hw(ep);
+ if (UNLIKELY((size_t)buffer & 0x03))
+ {
+ LOG_ERR("unaligned buffer @ %p\n", buffer);
+ ASSERT(0);
+ }
+
/* Non-blocking read for EP0 */
if (ep_num == CTRL_ENP_OUT)
{
size = usb_size(size, usb_le16_to_cpu(setup_packet.wLength));
if (!size)
/* Non-blocking read for EP0 */
if (ep_num == CTRL_ENP_OUT)
{
size = usb_size(size, usb_le16_to_cpu(setup_packet.wLength));
if (!size)
-
USB_StatusH
andler(ep_num);
+
usb_status_h
andler(ep_num);
else
__usb_ep_read(ep_num, buffer, size,
else
__usb_ep_read(ep_num, buffer, size,
-
USB_StatusH
andler);
+
usb_status_h
andler);
return size;
}
if (UNLIKELY(!size))
return size;
}
if (UNLIKELY(!size))
@@
-1147,15
+1147,21
@@
ssize_t usb_endpointWrite(int ep, const void *buffer, ssize_t size)
{
int ep_num = usb_ep_logical_to_hw(ep);
{
int ep_num = usb_ep_logical_to_hw(ep);
+ if (UNLIKELY((size_t)buffer & 0x03))
+ {
+ LOG_ERR("unaligned buffer @ %p\n", buffer);
+ ASSERT(0);
+ }
+
/* Non-blocking write for EP0 */
if (ep_num == CTRL_ENP_IN)
{
size = usb_size(size, usb_le16_to_cpu(setup_packet.wLength));
if (!size)
/* Non-blocking write for EP0 */
if (ep_num == CTRL_ENP_IN)
{
size = usb_size(size, usb_le16_to_cpu(setup_packet.wLength));
if (!size)
-
USB_StatusH
andler(ep_num);
+
usb_status_h
andler(ep_num);
else
__usb_ep_write(ep_num, buffer, size,
else
__usb_ep_write(ep_num, buffer, size,
-
USB_StatusH
andler);
+
usb_status_h
andler);
return size;
}
if (UNLIKELY(!size))
return size;
}
if (UNLIKELY(!size))
@@
-1176,7
+1182,7
@@
ssize_t usb_endpointWrite(int ep, const void *buffer, ssize_t size)
static uint32_t InData;
/* Get device status */
static uint32_t InData;
/* Get device status */
-static int
UsbDevS
tatus(uint16_t index)
+static int
usb_send_device_s
tatus(uint16_t index)
{
if (index)
return -USB_NODEV_ERROR;
{
if (index)
return -USB_NODEV_ERROR;
@@
-1184,36
+1190,36
@@
static int UsbDevStatus(uint16_t index)
InData = ((uint32_t)udc.feature) & 0xff;
__usb_ep_write(CTRL_ENP_IN,
(uint8_t *)&InData, sizeof(uint16_t),
InData = ((uint32_t)udc.feature) & 0xff;
__usb_ep_write(CTRL_ENP_IN,
(uint8_t *)&InData, sizeof(uint16_t),
-
USB_StatusH
andler);
+
usb_status_h
andler);
return 0;
}
/* Get interface status */
return 0;
}
/* Get interface status */
-static int
UsbInterfaceS
tatus(UNUSED_ARG(uint16_t, index))
+static int
usb_send_interface_s
tatus(UNUSED_ARG(uint16_t, index))
{
InData = 0;
__usb_ep_write(CTRL_ENP_IN,
(uint8_t *)&InData, sizeof(uint16_t),
{
InData = 0;
__usb_ep_write(CTRL_ENP_IN,
(uint8_t *)&InData, sizeof(uint16_t),
-
USB_StatusH
andler);
+
usb_status_h
andler);
return 0;
}
/* Get endpoint status */
return 0;
}
/* Get endpoint status */
-static int
UsbEpS
tatus(uint16_t index)
+static int
usb_send_ep_s
tatus(uint16_t index)
{
if ((index & 0x7F) > 16)
return -USB_NODEV_ERROR;
InData = 0;
{
if ((index & 0x7F) > 16)
return -USB_NODEV_ERROR;
InData = 0;
-
USB_GetStallEP
(usb_ep_logical_to_hw(index), (bool *)&InData);
+
usb_ep_get_stall
(usb_ep_logical_to_hw(index), (bool *)&InData);
__usb_ep_write(CTRL_ENP_IN,
(uint8_t *)&InData, sizeof(uint16_t),
__usb_ep_write(CTRL_ENP_IN,
(uint8_t *)&InData, sizeof(uint16_t),
-
USB_StatusH
andler);
+
usb_status_h
andler);
return 0;
}
/* USB setup packet: GET_STATUS request handler */
return 0;
}
/* USB setup packet: GET_STATUS request handler */
-static void
USB_GetStatusH
andler(void)
+static void
usb_get_status_h
andler(void)
{
uint16_t w_value = usb_le16_to_cpu(setup_packet.wValue);
uint16_t w_index = usb_le16_to_cpu(setup_packet.wIndex);
{
uint16_t w_value = usb_le16_to_cpu(setup_packet.wValue);
uint16_t w_index = usb_le16_to_cpu(setup_packet.wIndex);
@@
-1253,7
+1259,7
@@
static void USB_GetStatusHandler(void)
switch (setup_packet.mRequestType & USB_RECIP_MASK)
{
case USB_RECIP_DEVICE:
switch (setup_packet.mRequestType & USB_RECIP_MASK)
{
case USB_RECIP_DEVICE:
- if (
UsbDevS
tatus(w_index) < 0)
+ if (
usb_send_device_s
tatus(w_index) < 0)
{
LOG_WARN("%s: GET_STATUS: invalid UsbRecipientDevice\n",
__func__);
{
LOG_WARN("%s: GET_STATUS: invalid UsbRecipientDevice\n",
__func__);
@@
-1264,7
+1270,7
@@
static void USB_GetStatusHandler(void)
__func__, setup_packet.mRequestType);
break;
case USB_RECIP_INTERFACE:
__func__, setup_packet.mRequestType);
break;
case USB_RECIP_INTERFACE:
- if (
UsbInterfaceS
tatus(w_index) < 0)
+ if (
usb_send_interface_s
tatus(w_index) < 0)
{
LOG_WARN("%s: GET_STATUS: invalid UsbRecipientInterface\n",
__func__);
{
LOG_WARN("%s: GET_STATUS: invalid UsbRecipientInterface\n",
__func__);
@@
-1275,7
+1281,7
@@
static void USB_GetStatusHandler(void)
__func__, setup_packet.mRequestType);
break;
case USB_RECIP_ENDPOINT:
__func__, setup_packet.mRequestType);
break;
case USB_RECIP_ENDPOINT:
- if (
UsbEpS
tatus(w_index) < 0)
+ if (
usb_send_ep_s
tatus(w_index) < 0)
{
LOG_WARN("%s: GET_STATUS: invalid UsbRecipientEndpoint\n",
__func__);
{
LOG_WARN("%s: GET_STATUS: invalid UsbRecipientEndpoint\n",
__func__);
@@
-1302,12
+1308,19
@@
static int usb_get_device_descriptor(int id)
__usb_ep_write(CTRL_ENP_IN, (const uint8_t *)usb_dev->device,
usb_size(usb_dev->device->bLength,
usb_le16_to_cpu(setup_packet.wLength)),
__usb_ep_write(CTRL_ENP_IN, (const uint8_t *)usb_dev->device,
usb_size(usb_dev->device->bLength,
usb_le16_to_cpu(setup_packet.wLength)),
-
USB_StatusH
andler);
+
usb_status_h
andler);
return 0;
}
return 0;
}
+/*
+ * TODO: refactor this part to remove this temporary buffer.
+ *
+ * It would be better to define all the USB descriptors in the right order and
+ * send them as a contiguous buffer directly from the flash / rodata memory.
+ */
#define USB_BUFSIZE (128)
static uint8_t usb_cfg_buffer[USB_BUFSIZE];
#define USB_BUFSIZE (128)
static uint8_t usb_cfg_buffer[USB_BUFSIZE];
+STATIC_ASSERT(USB_BUFSIZE < (1 << (sizeof(uint16_t) * 8)));
static int usb_get_configuration_descriptor(int id)
{
static int usb_get_configuration_descriptor(int id)
{
@@
-1332,12
+1345,12
@@
static int usb_get_configuration_descriptor(int id)
}
}
((UsbConfigDesc *)usb_cfg_buffer)->wTotalLength =
}
}
((UsbConfigDesc *)usb_cfg_buffer)->wTotalLength =
-
usb_cpu_to_le16(p - usb_cfg_buffer
);
+
usb_cpu_to_le16((uint16_t)(p - usb_cfg_buffer)
);
__usb_ep_write(CTRL_ENP_IN,
usb_cfg_buffer,
usb_size(p - usb_cfg_buffer,
usb_le16_to_cpu(setup_packet.wLength)),
__usb_ep_write(CTRL_ENP_IN,
usb_cfg_buffer,
usb_size(p - usb_cfg_buffer,
usb_le16_to_cpu(setup_packet.wLength)),
-
USB_StatusH
andler);
+
usb_status_h
andler);
return 0;
}
return 0;
}
@@
-1378,11
+1391,11
@@
static int usb_get_string_descriptor(unsigned int id)
lang_str,
usb_size(lang_str->bLength,
usb_le16_to_cpu(setup_packet.wLength)),
lang_str,
usb_size(lang_str->bLength,
usb_le16_to_cpu(setup_packet.wLength)),
-
USB_StatusH
andler);
+
usb_status_h
andler);
return 0;
}
return 0;
}
-static void
UsbGetD
escriptor(void)
+static void
usb_get_d
escriptor(void)
{
uint16_t w_value_lo = usb_le16_to_cpu(setup_packet.wValue) & 0x00ff;
uint16_t w_value_hi = (usb_le16_to_cpu(setup_packet.wValue) & 0xff00) >> 8;
{
uint16_t w_value_lo = usb_le16_to_cpu(setup_packet.wValue) & 0x00ff;
uint16_t w_value_hi = (usb_le16_to_cpu(setup_packet.wValue) & 0xff00) >> 8;
@@
-1434,14
+1447,14
@@
static void usb_event_handler(UsbDevice *dev)
}
/* USB setup packet: GET_DESCRIPTOR handler */
}
/* USB setup packet: GET_DESCRIPTOR handler */
-static void
UBS_GetDescriptorH
andler(void)
+static void
usb_get_descriptor_h
andler(void)
{
LOG_INFO("%s: GET_DESCRIPTOR: RECIP = %d\n",
__func__,
setup_packet.mRequestType & USB_RECIP_MASK);
if ((setup_packet.mRequestType & USB_RECIP_MASK) ==
USB_RECIP_DEVICE)
{
LOG_INFO("%s: GET_DESCRIPTOR: RECIP = %d\n",
__func__,
setup_packet.mRequestType & USB_RECIP_MASK);
if ((setup_packet.mRequestType & USB_RECIP_MASK) ==
USB_RECIP_DEVICE)
-
UsbGetD
escriptor();
+
usb_get_d
escriptor();
/* Getting descriptor for a device is a standard request */
else if ((setup_packet.mRequestType & USB_DIR_MASK) == USB_DIR_IN)
usb_event_handler(usb_dev);
/* Getting descriptor for a device is a standard request */
else if ((setup_packet.mRequestType & USB_DIR_MASK) == USB_DIR_IN)
usb_event_handler(usb_dev);
@@
-1450,7
+1463,7
@@
static void UBS_GetDescriptorHandler(void)
}
/* USB setup packet: SET_ADDRESS handler */
}
/* USB setup packet: SET_ADDRESS handler */
-static void
USB_SetAddressH
andler(void)
+static void
usb_set_address_h
andler(void)
{
uint16_t w_value = usb_le16_to_cpu(setup_packet.wValue);
uint16_t w_index = usb_le16_to_cpu(setup_packet.wIndex);
{
uint16_t w_value = usb_le16_to_cpu(setup_packet.wValue);
uint16_t w_index = usb_le16_to_cpu(setup_packet.wIndex);
@@
-1462,13
+1475,13
@@
static void USB_SetAddressHandler(void)
((setup_packet.mRequestType & USB_RECIP_MASK) ==
USB_RECIP_DEVICE) &&
(w_index == 0) && (w_length == 0) && (w_value < 128))
((setup_packet.mRequestType & USB_RECIP_MASK) ==
USB_RECIP_DEVICE) &&
(w_index == 0) && (w_length == 0) && (w_value < 128))
-
USB_StatusH
andler(CTRL_ENP_IN);
+
usb_status_h
andler(CTRL_ENP_IN);
else
ep_cnfg[CTRL_ENP_OUT].status = STALLED;
}
/* USB setup packet: GET_CONFIGURATION handler */
else
ep_cnfg[CTRL_ENP_OUT].status = STALLED;
}
/* USB setup packet: GET_CONFIGURATION handler */
-static void
USB_GetConfigurationH
andler(void)
+static void
usb_get_config_h
andler(void)
{
uint16_t w_value = usb_le16_to_cpu(setup_packet.wValue);
uint16_t w_index = usb_le16_to_cpu(setup_packet.wIndex);
{
uint16_t w_value = usb_le16_to_cpu(setup_packet.wValue);
uint16_t w_index = usb_le16_to_cpu(setup_packet.wIndex);
@@
-1478,7
+1491,7
@@
static void USB_GetConfigurationHandler(void)
(w_value == 0) && (w_index == 0) && (w_value == 1))
{
InData = udc.cfg_id;
(w_value == 0) && (w_index == 0) && (w_value == 1))
{
InData = udc.cfg_id;
- __usb_ep_write(CTRL_ENP_IN, (uint8_t *)&InData, 1,
USB_StatusH
andler);
+ __usb_ep_write(CTRL_ENP_IN, (uint8_t *)&InData, 1,
usb_status_h
andler);
}
else
ep_cnfg[CTRL_ENP_OUT].status = STALLED;
}
else
ep_cnfg[CTRL_ENP_OUT].status = STALLED;
@@
-1502,15
+1515,15
@@
static const UsbConfigDesc *usb_find_configuration(int num)
return NULL;
}
return NULL;
}
-static int
UsbSetConfigurationState(uint32_t Configuration
)
+static int
usb_set_config_state(uint32_t conf
)
{
const UsbConfigDesc *pCnfg;
unsigned int i;
{
const UsbConfigDesc *pCnfg;
unsigned int i;
- if (
Configuration
)
+ if (
conf
)
{
/* Find configuration descriptor */
{
/* Find configuration descriptor */
- pCnfg = usb_find_configuration(
Configuration
);
+ pCnfg = usb_find_configuration(
conf
);
if (pCnfg == NULL)
return -USB_NODEV_ERROR;
if (pCnfg == NULL)
return -USB_NODEV_ERROR;
@@
-1520,7
+1533,7
@@
static int UsbSetConfigurationState(uint32_t Configuration)
udc.cfg = pCnfg;
/* Set Interface and Alternative Setting */
udc.cfg = pCnfg;
/* Set Interface and Alternative Setting */
- udc.cfg_id =
Configuration
;
+ udc.cfg_id =
conf
;
/* Set self-powered state */
if (pCnfg->bmAttributes & USB_CONFIG_ATT_SELFPOWER)
udc.feature |= STM32_UDC_FEATURE_SELFPOWERED;
/* Set self-powered state */
if (pCnfg->bmAttributes & USB_CONFIG_ATT_SELFPOWER)
udc.feature |= STM32_UDC_FEATURE_SELFPOWERED;
@@
-1542,7
+1555,7
@@
static int UsbSetConfigurationState(uint32_t Configuration)
}
/* USB setup packet: SET_CONFIGURATION handler */
}
/* USB setup packet: SET_CONFIGURATION handler */
-static void
USB_SetConfigurationH
andler(void)
+static void
usb_set_config_h
andler(void)
{
uint16_t w_value = usb_le16_to_cpu(setup_packet.wValue);
uint16_t w_index = usb_le16_to_cpu(setup_packet.wIndex);
{
uint16_t w_value = usb_le16_to_cpu(setup_packet.wValue);
uint16_t w_index = usb_le16_to_cpu(setup_packet.wIndex);
@@
-1552,19
+1565,19
@@
static void USB_SetConfigurationHandler(void)
__func__, w_value);
if ((udc.state >= USB_STATE_ADDRESS) &&
(w_index == 0) && (w_length == 0) &&
__func__, w_value);
if ((udc.state >= USB_STATE_ADDRESS) &&
(w_index == 0) && (w_length == 0) &&
- (
UsbSetConfigurationS
tate(w_value & 0xff) == 0))
-
USB_StatusH
andler(CTRL_ENP_OUT);
+ (
usb_set_config_s
tate(w_value & 0xff) == 0))
+
usb_status_h
andler(CTRL_ENP_OUT);
else
ep_cnfg[CTRL_ENP_OUT].status = STALLED;
}
/* USB setup packet: standard request handler */
else
ep_cnfg[CTRL_ENP_OUT].status = STALLED;
}
/* USB setup packet: standard request handler */
-static void
USB_StandardRequestH
andler(void)
+static void
usb_standard_request_h
andler(void)
{
switch (setup_packet.bRequest)
{
case USB_REQ_GET_STATUS:
{
switch (setup_packet.bRequest)
{
case USB_REQ_GET_STATUS:
-
USB_GetStatusH
andler();
+
usb_get_status_h
andler();
break;
case USB_REQ_CLEAR_FEATURE:
LOG_INFO("%s: bRequest=%d (CLEAR_FEATURE)\n",
break;
case USB_REQ_CLEAR_FEATURE:
LOG_INFO("%s: bRequest=%d (CLEAR_FEATURE)\n",
@@
-1575,20
+1588,20
@@
static void USB_StandardRequestHandler(void)
__func__, setup_packet.bRequest);
break;
case USB_REQ_SET_ADDRESS:
__func__, setup_packet.bRequest);
break;
case USB_REQ_SET_ADDRESS:
-
USB_SetAddressH
andler();
+
usb_set_address_h
andler();
break;
case USB_REQ_GET_DESCRIPTOR:
break;
case USB_REQ_GET_DESCRIPTOR:
-
UBS_GetDescriptorH
andler();
+
usb_get_descriptor_h
andler();
break;
case USB_REQ_SET_DESCRIPTOR:
LOG_INFO("%s: bRequest=%d (SET_DESCRIPTOR)\n",
__func__, setup_packet.bRequest);
break;
case USB_REQ_GET_CONFIGURATION:
break;
case USB_REQ_SET_DESCRIPTOR:
LOG_INFO("%s: bRequest=%d (SET_DESCRIPTOR)\n",
__func__, setup_packet.bRequest);
break;
case USB_REQ_GET_CONFIGURATION:
-
USB_GetConfigurationH
andler();
+
usb_get_config_h
andler();
break;
case USB_REQ_SET_CONFIGURATION:
break;
case USB_REQ_SET_CONFIGURATION:
-
USB_SetConfigurationH
andler();
+
usb_set_config_h
andler();
break;
case USB_REQ_GET_INTERFACE:
LOG_INFO("%s: bRequest=%d (GET_INTERFACE)\n",
break;
case USB_REQ_GET_INTERFACE:
LOG_INFO("%s: bRequest=%d (GET_INTERFACE)\n",
@@
-1611,7
+1624,7
@@
static void USB_StandardRequestHandler(void)
}
/* USB setup packet handler */
}
/* USB setup packet handler */
-static void
USB_SetupH
andler(void)
+static void
usb_setup_h
andler(void)
{
switch (setup_packet.mRequestType & USB_TYPE_MASK)
{
{
switch (setup_packet.mRequestType & USB_TYPE_MASK)
{
@@
-1619,7
+1632,7
@@
static void USB_SetupHandler(void)
case USB_TYPE_STANDARD:
LOG_INFO("%s: bmRequestType=%02x (Standard)\n",
__func__, setup_packet.mRequestType);
case USB_TYPE_STANDARD:
LOG_INFO("%s: bmRequestType=%02x (Standard)\n",
__func__, setup_packet.mRequestType);
-
USB_StandardRequestH
andler();
+
usb_standard_request_h
andler();
break;
/* Class */
case USB_TYPE_CLASS:
break;
/* Class */
case USB_TYPE_CLASS:
@@
-1700,13
+1713,13
@@
static void usb_isr_correct_transfer(stm32_usb_irq_status_t interrupt)
ASSERT(ep_cnfg[EP].hw);
/* IN EP */
if (EP & 0x01)
ASSERT(ep_cnfg[EP].hw);
/* IN EP */
if (EP & 0x01)
-
EpCtrlClr_CTR_TX
(ep_cnfg[EP].hw);
+
ep_ctrl_clr_ctr_tx
(ep_cnfg[EP].hw);
else
else
-
EpCtrlClr_CTR_RX
(ep_cnfg[EP].hw);
+
ep_ctrl_clr_ctr_rx
(ep_cnfg[EP].hw);
if (EP == CTRL_ENP_OUT)
{
/* Determinate type of packet (only for control EP) */
if (EP == CTRL_ENP_OUT)
{
/* Determinate type of packet (only for control EP) */
- bool SetupPacket =
EpCtrlGet_SETUP
(ep_cnfg[CTRL_ENP_OUT].hw);
+ bool SetupPacket =
ep_ctrl_get_setup
(ep_cnfg[CTRL_ENP_OUT].hw);
if (SetupPacket)
{
if (SetupPacket)
{
@@
-1718,10
+1731,10
@@
static void usb_isr_correct_transfer(stm32_usb_irq_status_t interrupt)
/* reset EP IO ctrl */
if (setup_packet.mRequestType & USB_DIR_IN)
/* reset EP IO ctrl */
if (setup_packet.mRequestType & USB_DIR_IN)
-
USB_StatusH
andler(CTRL_ENP_OUT);
-
USB_SetupH
andler();
+
usb_status_h
andler(CTRL_ENP_OUT);
+
usb_setup_h
andler();
if (ep_cnfg[CTRL_ENP_OUT].status == STALLED)
if (ep_cnfg[CTRL_ENP_OUT].status == STALLED)
-
USB_StallCtrlEP
();
+
usb_ep_set_stall_ctrl
();
}
else
{
}
else
{