Skip to content

Commit

Permalink
usb/dwc: Further implementation cleanup to fix integer conversions is…
Browse files Browse the repository at this point in the history
…sues
  • Loading branch information
dragonmux committed Aug 11, 2024
1 parent 2dc5c7f commit 5d960d2
Showing 1 changed file with 5 additions and 7 deletions.
12 changes: 5 additions & 7 deletions lib/usb/usb_dwc_common.c
Original file line number Diff line number Diff line change
Expand Up @@ -177,19 +177,17 @@ void dwc_ep_stall_set(usbd_device *usbd_dev, uint8_t addr, uint8_t stall)
uint8_t dwc_ep_stall_get(usbd_device *usbd_dev, uint8_t addr)
{
/* Return non-zero if STALL set. */
if (addr & 0x80) {
return (REBASE(OTG_DIEPCTL(addr & 0x7f)) &
OTG_DIEPCTL0_STALL) ? 1 : 0;
if (addr & 0x80U) {
return (REBASE(OTG_DIEPCTL(addr & 0x7fU)) & OTG_DIEPCTL0_STALL) ? 1U : 0U;
} else {
return (REBASE(OTG_DOEPCTL(addr)) &
OTG_DOEPCTL0_STALL) ? 1 : 0;
return (REBASE(OTG_DOEPCTL(addr)) & OTG_DOEPCTL0_STALL) ? 1U : 0U;
}
}

void dwc_ep_nak_set(usbd_device *usbd_dev, uint8_t addr, uint8_t nak)
{
/* It does not make sense to force NAK on IN endpoints. */
if (addr & 0x80) {
if (addr & 0x80U) {
return;
}

Expand Down Expand Up @@ -217,7 +215,7 @@ uint16_t dwc_ep_write_packet(usbd_device *usbd_dev, uint8_t addr,
REBASE(OTG_DIEPTSIZ(addr)) = OTG_DIEPSIZ0_PKTCNT | (len & OTG_DIEPSIZ0_XFRSIZ_MASK);
REBASE(OTG_DIEPCTL(addr)) |= OTG_DIEPCTL0_EPENA | OTG_DIEPCTL0_CNAK;

const uint8_t *buf8 = buf;
const uint8_t *const buf8 = buf;
/* Figure out where to copy the data to */
volatile uint32_t *const fifo = (volatile uint32_t *)(usbd_dev->driver->base_address + OTG_FIFO(addr));
/* Copy the data into the FIFO for this endpoint */
Expand Down

0 comments on commit 5d960d2

Please sign in to comment.