diff options
author | Dmitry Filimonchuk <dmitrystu@gmail.com> | 2020-07-29 17:05:52 +0300 |
---|---|---|
committer | Dmitry Filimonchuk <dmitrystu@gmail.com> | 2020-07-31 22:57:14 +0300 |
commit | 91dd4e8f852c01ee72dfefe659a159524369240e (patch) | |
tree | 777353d62db708d9cd948247a401cd83261183bc | |
parent | cf96c5828e77d63557121429734ddcc52066e190 (diff) |
hide driver functions
-rw-r--r-- | src/usbd_stm32f103_devfs.c | 26 | ||||
-rw-r--r-- | src/usbd_stm32f105_otgfs.c | 32 | ||||
-rw-r--r-- | src/usbd_stm32f429_otgfs.c | 32 | ||||
-rw-r--r-- | src/usbd_stm32f446_otgfs.c | 32 | ||||
-rw-r--r-- | src/usbd_stm32l052_devfs.c | 26 | ||||
-rw-r--r-- | src/usbd_stm32l100_devfs.c | 26 | ||||
-rw-r--r-- | src/usbd_stm32l433_devfs.c | 26 | ||||
-rw-r--r-- | src/usbd_stm32l476_otgfs.c | 32 |
8 files changed, 116 insertions, 116 deletions
diff --git a/src/usbd_stm32f103_devfs.c b/src/usbd_stm32f103_devfs.c index 56ab8ac..312a881 100644 --- a/src/usbd_stm32f103_devfs.c +++ b/src/usbd_stm32f103_devfs.c @@ -156,7 +156,7 @@ static uint16_t get_next_pma(uint16_t sz) { return (_result < (0x020 + sz)) ? 0 : (_result - sz); } -uint32_t getinfo(void) { +static uint32_t getinfo(void) { if (!(RCC->APB1ENR & RCC_APB1ENR_USBEN)) return STATUS_VAL(0); #if defined(USBD_DP_PORT) && defined(USBD_DP_PIN) if (USBD_DP_PORT->IDR & _BV(USBD_DP_PIN)) return STATUS_VAL(USBD_HW_ENABLED | USBD_HW_SPEED_FS); @@ -166,7 +166,7 @@ uint32_t getinfo(void) { #endif } -void ep_setstall(uint8_t ep, bool stall) { +static void ep_setstall(uint8_t ep, bool stall) { volatile uint16_t *reg = EPR(ep); /* ISOCHRONOUS endpoint can't be stalled or unstalled */ if (USB_EP_ISOCHRONOUS == (*reg & USB_EP_T_FIELD)) return; @@ -203,7 +203,7 @@ void ep_setstall(uint8_t ep, bool stall) { } } -bool ep_isstalled(uint8_t ep) { +static bool ep_isstalled(uint8_t ep) { if (ep & 0x80) { return (USB_EP_TX_STALL == (USB_EPTX_STAT & *EPR(ep))); } else { @@ -211,7 +211,7 @@ bool ep_isstalled(uint8_t ep) { } } -uint8_t connect(bool connect) { +static uint8_t connect(bool connect) { #if defined(USBD_DP_PORT) && defined(USBD_DP_PIN) && defined(STM32F3) uint32_t _t = USBD_DP_PORT->MODER & ~(0x03 << (2 * USBD_DP_PIN)); if (connect) { @@ -243,7 +243,7 @@ uint8_t connect(bool connect) { return usbd_lane_unk; } -void enable(bool enable) { +static void enable(bool enable) { if (enable) { set_gpiox(); RCC->APB1ENR |= RCC_APB1ENR_USBEN; @@ -262,11 +262,11 @@ void enable(bool enable) { } } -void setaddr (uint8_t addr) { +static void setaddr (uint8_t addr) { USB->DADDR = USB_DADDR_EF | addr; } -bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { +static bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { volatile uint16_t *reg = EPR(ep); pma_table *tbl = EPT(ep); /* epsize should be 16-bit aligned */ @@ -337,7 +337,7 @@ bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { return true; } -void ep_deconfig(uint8_t ep) { +static void ep_deconfig(uint8_t ep) { pma_table *ept = EPT(ep); *EPR(ep) &= ~USB_EPREG_MASK; ept->rx.addr = 0; @@ -366,7 +366,7 @@ static uint16_t pma_read (uint8_t *buf, uint16_t blen, pma_rec *rx) { return rxcnt; } -int32_t ep_read(uint8_t ep, void *buf, uint16_t blen) { +static int32_t ep_read(uint8_t ep, void *buf, uint16_t blen) { pma_table *tbl = EPT(ep); volatile uint16_t *reg = EPR(ep); switch (*reg & (USB_EPRX_STAT | USB_EP_T_FIELD | USB_EP_KIND)) { @@ -423,7 +423,7 @@ static void pma_write(const uint8_t *buf, uint16_t blen, pma_rec *tx) { } } -int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { +static int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { pma_table *tbl = EPT(ep); volatile uint16_t *reg = EPR(ep); switch (*reg & (USB_EPTX_STAT | USB_EP_T_FIELD | USB_EP_KIND)) { @@ -458,11 +458,11 @@ int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { return blen; } -uint16_t get_frame (void) { +static uint16_t get_frame (void) { return USB->FNR & USB_FNR_FN; } -void evt_poll(usbd_device *dev, usbd_evt_callback callback) { +static void evt_poll(usbd_device *dev, usbd_evt_callback callback) { uint8_t _ev, _ep; uint16_t _istr = USB->ISTR; _ep = _istr & USB_ISTR_EP_ID; @@ -515,7 +515,7 @@ static uint32_t fnv1a32_turn (uint32_t fnv, uint32_t data ) { return fnv; } -uint16_t get_serialno_desc(void *buffer) { +static uint16_t get_serialno_desc(void *buffer) { struct usb_string_descriptor *dsc = buffer; uint16_t *str = dsc->wString; uint32_t fnv = 2166136261; diff --git a/src/usbd_stm32f105_otgfs.c b/src/usbd_stm32f105_otgfs.c index 490f44c..54530da 100644 --- a/src/usbd_stm32f105_otgfs.c +++ b/src/usbd_stm32f105_otgfs.c @@ -30,9 +30,9 @@ #define STATUS_VAL(x) (USBD_HW_ADDRFST | (x)) -USB_OTG_GlobalTypeDef * const OTG = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_GLOBAL_BASE); -USB_OTG_DeviceTypeDef * const OTGD = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_DEVICE_BASE); -volatile uint32_t * const OTGPCTL = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_PCGCCTL_BASE); +static USB_OTG_GlobalTypeDef * const OTG = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_GLOBAL_BASE); +static USB_OTG_DeviceTypeDef * const OTGD = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_DEVICE_BASE); +static volatile uint32_t * const OTGPCTL = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_PCGCCTL_BASE); inline static uint32_t* EPFIFO(uint32_t ep) { @@ -58,13 +58,13 @@ inline static void Flush_TX(uint8_t ep) { _WBC(OTG->GRSTCTL, USB_OTG_GRSTCTL_TXFFLSH); } -uint32_t getinfo(void) { +static uint32_t getinfo(void) { if (!(RCC->AHBENR & RCC_AHBENR_OTGFSEN)) return STATUS_VAL(0); if (!(OTGD->DCTL & USB_OTG_DCTL_SDIS)) return STATUS_VAL(USBD_HW_ENABLED | USBD_HW_SPEED_FS); return STATUS_VAL(USBD_HW_ENABLED); } -void ep_setstall(uint8_t ep, bool stall) { +static void ep_setstall(uint8_t ep, bool stall) { if (ep & 0x80) { ep &= 0x7F; uint32_t _t = EPIN(ep)->DIEPCTL; @@ -91,7 +91,7 @@ void ep_setstall(uint8_t ep, bool stall) { } } -bool ep_isstalled(uint8_t ep) { +static bool ep_isstalled(uint8_t ep) { if (ep & 0x80) { ep &= 0x7F; return (EPIN(ep)->DIEPCTL & USB_OTG_DIEPCTL_STALL) ? true : false; @@ -100,7 +100,7 @@ bool ep_isstalled(uint8_t ep) { } } -void enable(bool enable) { +static void enable(bool enable) { if (enable) { /* enabling USB_OTG in RCC */ _BST(RCC->AHBENR, RCC_AHBENR_OTGFSEN); @@ -154,7 +154,7 @@ void enable(bool enable) { } } -uint8_t connect(bool connect) { +static uint8_t connect(bool connect) { if (connect) { /* The ST made a strange thing again. Really i dont'understand what is the reason to name signal as PWRDWN (Power down PHY) when it works as "Power up" */ @@ -167,7 +167,7 @@ uint8_t connect(bool connect) { return usbd_lane_unk; } -void setaddr (uint8_t addr) { +static void setaddr (uint8_t addr) { _BMD(OTGD->DCFG, USB_OTG_DCFG_DAD, addr << 4); } @@ -203,7 +203,7 @@ static bool set_tx_fifo(uint8_t ep, uint16_t epsize) { return true; } -bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { +static bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { if (ep == 0) { /* configuring control endpoint EP0 */ uint32_t mpsize; @@ -291,7 +291,7 @@ bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { return true; } -void ep_deconfig(uint8_t ep) { +static void ep_deconfig(uint8_t ep) { ep &= 0x7F; volatile USB_OTG_INEndpointTypeDef* epi = EPIN(ep); volatile USB_OTG_OUTEndpointTypeDef* epo = EPOUT(ep); @@ -320,7 +320,7 @@ void ep_deconfig(uint8_t ep) { epo->DOEPINT = 0xFF; } -int32_t ep_read(uint8_t ep, void* buf, uint16_t blen) { +static int32_t ep_read(uint8_t ep, void* buf, uint16_t blen) { uint32_t len, tmp; volatile uint32_t *fifo = EPFIFO(0); /* no data in RX FIFO */ @@ -341,7 +341,7 @@ int32_t ep_read(uint8_t ep, void* buf, uint16_t blen) { return (len < blen) ? len : blen; } -int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { +static int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { uint32_t len, tmp; ep &= 0x7F; volatile uint32_t* fifo = EPFIFO(ep); @@ -368,11 +368,11 @@ int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { return blen; } -uint16_t get_frame (void) { +static uint16_t get_frame (void) { return _FLD2VAL(USB_OTG_DSTS_FNSOF, OTGD->DSTS); } -void evt_poll(usbd_device *dev, usbd_evt_callback callback) { +static void evt_poll(usbd_device *dev, usbd_evt_callback callback) { uint32_t evt; uint32_t ep = 0; while (1) { @@ -449,7 +449,7 @@ static uint32_t fnv1a32_turn (uint32_t fnv, uint32_t data ) { return fnv; } -uint16_t get_serialno_desc(void *buffer) { +static uint16_t get_serialno_desc(void *buffer) { struct usb_string_descriptor *dsc = buffer; uint16_t *str = dsc->wString; uint32_t fnv = 2166136261; diff --git a/src/usbd_stm32f429_otgfs.c b/src/usbd_stm32f429_otgfs.c index c68c6c1..1633e04 100644 --- a/src/usbd_stm32f429_otgfs.c +++ b/src/usbd_stm32f429_otgfs.c @@ -29,9 +29,9 @@ #define STATUS_VAL(x) (USBD_HW_ADDRFST | (x)) -USB_OTG_GlobalTypeDef * const OTG = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_GLOBAL_BASE); -USB_OTG_DeviceTypeDef * const OTGD = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_DEVICE_BASE); -volatile uint32_t * const OTGPCTL = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_PCGCCTL_BASE); +static USB_OTG_GlobalTypeDef * const OTG = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_GLOBAL_BASE); +static USB_OTG_DeviceTypeDef * const OTGD = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_DEVICE_BASE); +static volatile uint32_t * const OTGPCTL = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_PCGCCTL_BASE); inline static uint32_t* EPFIFO(uint32_t ep) { @@ -57,13 +57,13 @@ inline static void Flush_TX(uint8_t ep) { _WBC(OTG->GRSTCTL, USB_OTG_GRSTCTL_TXFFLSH); } -uint32_t getinfo(void) { +static uint32_t getinfo(void) { if (!(RCC->AHB2ENR & RCC_AHB2ENR_OTGFSEN)) return STATUS_VAL(0); if (!(OTGD->DCTL & USB_OTG_DCTL_SDIS)) return STATUS_VAL(USBD_HW_ENABLED | USBD_HW_SPEED_FS); return STATUS_VAL(USBD_HW_ENABLED); } -void ep_setstall(uint8_t ep, bool stall) { +static void ep_setstall(uint8_t ep, bool stall) { if (ep & 0x80) { ep &= 0x7F; uint32_t _t = EPIN(ep)->DIEPCTL; @@ -90,7 +90,7 @@ void ep_setstall(uint8_t ep, bool stall) { } } -bool ep_isstalled(uint8_t ep) { +static bool ep_isstalled(uint8_t ep) { if (ep & 0x80) { ep &= 0x7F; return (EPIN(ep)->DIEPCTL & USB_OTG_DIEPCTL_STALL) ? true : false; @@ -99,7 +99,7 @@ bool ep_isstalled(uint8_t ep) { } } -void enable(bool enable) { +static void enable(bool enable) { if (enable) { /* enabling USB_OTG in RCC */ _BST(RCC->AHB2ENR, RCC_AHB2ENR_OTGFSEN); @@ -152,7 +152,7 @@ void enable(bool enable) { } } -uint8_t connect(bool connect) { +static uint8_t connect(bool connect) { if (connect) { /* The ST made a strange thing again. Really i dont'understand what is the reason to name signal as PWRDWN (Power down PHY) when it works as "Power up" */ @@ -165,7 +165,7 @@ uint8_t connect(bool connect) { return usbd_lane_unk; } -void setaddr (uint8_t addr) { +static void setaddr (uint8_t addr) { _BMD(OTGD->DCFG, USB_OTG_DCFG_DAD, addr << 4); } @@ -201,7 +201,7 @@ static bool set_tx_fifo(uint8_t ep, uint16_t epsize) { return true; } -bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { +static bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { if (ep == 0) { /* configureing control endpoint EP0 */ uint32_t mpsize; @@ -288,7 +288,7 @@ bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { return true; } -void ep_deconfig(uint8_t ep) { +static void ep_deconfig(uint8_t ep) { ep &= 0x7F; volatile USB_OTG_INEndpointTypeDef* epi = EPIN(ep); volatile USB_OTG_OUTEndpointTypeDef* epo = EPOUT(ep); @@ -317,7 +317,7 @@ void ep_deconfig(uint8_t ep) { epo->DOEPINT = 0xFF; } -int32_t ep_read(uint8_t ep, void* buf, uint16_t blen) { +static int32_t ep_read(uint8_t ep, void* buf, uint16_t blen) { uint32_t len, tmp; volatile uint32_t *fifo = EPFIFO(0); /* no data in RX FIFO */ @@ -338,7 +338,7 @@ int32_t ep_read(uint8_t ep, void* buf, uint16_t blen) { return (len < blen) ? len : blen; } -int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { +static int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { uint32_t len, tmp; ep &= 0x7F; volatile uint32_t* fifo = EPFIFO(ep); @@ -365,11 +365,11 @@ int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { return blen; } -uint16_t get_frame (void) { +static uint16_t get_frame (void) { return _FLD2VAL(USB_OTG_DSTS_FNSOF, OTGD->DSTS); } -void evt_poll(usbd_device *dev, usbd_evt_callback callback) { +static void evt_poll(usbd_device *dev, usbd_evt_callback callback) { uint32_t evt; uint32_t ep = 0; while (1) { @@ -446,7 +446,7 @@ static uint32_t fnv1a32_turn (uint32_t fnv, uint32_t data ) { return fnv; } -uint16_t get_serialno_desc(void *buffer) { +static uint16_t get_serialno_desc(void *buffer) { struct usb_string_descriptor *dsc = buffer; uint16_t *str = dsc->wString; uint32_t fnv = 2166136261; diff --git a/src/usbd_stm32f446_otgfs.c b/src/usbd_stm32f446_otgfs.c index 0ad389a..93cb2c3 100644 --- a/src/usbd_stm32f446_otgfs.c +++ b/src/usbd_stm32f446_otgfs.c @@ -29,9 +29,9 @@ #define STATUS_VAL(x) (USBD_HW_ADDRFST | (x)) -USB_OTG_GlobalTypeDef * const OTG = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_GLOBAL_BASE); -USB_OTG_DeviceTypeDef * const OTGD = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_DEVICE_BASE); -volatile uint32_t * const OTGPCTL = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_PCGCCTL_BASE); +static USB_OTG_GlobalTypeDef * const OTG = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_GLOBAL_BASE); +static USB_OTG_DeviceTypeDef * const OTGD = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_DEVICE_BASE); +static volatile uint32_t * const OTGPCTL = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_PCGCCTL_BASE); inline static uint32_t* EPFIFO(uint32_t ep) { @@ -57,13 +57,13 @@ inline static void Flush_TX(uint8_t ep) { _WBC(OTG->GRSTCTL, USB_OTG_GRSTCTL_TXFFLSH); } -uint32_t getinfo(void) { +static uint32_t getinfo(void) { if (!(RCC->AHB2ENR & RCC_AHB2ENR_OTGFSEN)) return STATUS_VAL(0); if (!(OTGD->DCTL & USB_OTG_DCTL_SDIS)) return STATUS_VAL(USBD_HW_ENABLED | USBD_HW_SPEED_FS); return STATUS_VAL(USBD_HW_ENABLED); } -void ep_setstall(uint8_t ep, bool stall) { +static void ep_setstall(uint8_t ep, bool stall) { if (ep & 0x80) { ep &= 0x7F; uint32_t _t = EPIN(ep)->DIEPCTL; @@ -90,7 +90,7 @@ void ep_setstall(uint8_t ep, bool stall) { } } -bool ep_isstalled(uint8_t ep) { +static bool ep_isstalled(uint8_t ep) { if (ep & 0x80) { ep &= 0x7F; return (EPIN(ep)->DIEPCTL & USB_OTG_DIEPCTL_STALL) ? true : false; @@ -99,7 +99,7 @@ bool ep_isstalled(uint8_t ep) { } } -void enable(bool enable) { +static void enable(bool enable) { if (enable) { /* enabling USB_OTG in RCC */ _BST(RCC->AHB2ENR, RCC_AHB2ENR_OTGFSEN); @@ -147,7 +147,7 @@ void enable(bool enable) { } } -uint8_t connect(bool connect) { +static uint8_t connect(bool connect) { if (connect) { _BCL(OTGD->DCTL, USB_OTG_DCTL_SDIS); } else { @@ -156,7 +156,7 @@ uint8_t connect(bool connect) { return usbd_lane_unk; } -void setaddr (uint8_t addr) { +static void setaddr (uint8_t addr) { _BMD(OTGD->DCFG, USB_OTG_DCFG_DAD, addr << 4); } @@ -192,7 +192,7 @@ static bool set_tx_fifo(uint8_t ep, uint16_t epsize) { return true; } -bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { +static bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { if (ep == 0) { /* configureing control endpoint EP0 */ uint32_t mpsize; @@ -279,7 +279,7 @@ bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { return true; } -void ep_deconfig(uint8_t ep) { +static void ep_deconfig(uint8_t ep) { ep &= 0x7F; volatile USB_OTG_INEndpointTypeDef* epi = EPIN(ep); volatile USB_OTG_OUTEndpointTypeDef* epo = EPOUT(ep); @@ -308,7 +308,7 @@ void ep_deconfig(uint8_t ep) { epo->DOEPINT = 0xFF; } -int32_t ep_read(uint8_t ep, void* buf, uint16_t blen) { +static int32_t ep_read(uint8_t ep, void* buf, uint16_t blen) { uint32_t len, tmp; ep &= 0x7F; volatile uint32_t *fifo = EPFIFO(0); @@ -331,7 +331,7 @@ int32_t ep_read(uint8_t ep, void* buf, uint16_t blen) { return (len < blen) ? len : blen; } -int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { +static int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { uint32_t len, tmp; ep &= 0x7F; volatile uint32_t* fifo = EPFIFO(ep); @@ -358,11 +358,11 @@ int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { return blen; } -uint16_t get_frame (void) { +static uint16_t get_frame (void) { return _FLD2VAL(USB_OTG_DSTS_FNSOF, OTGD->DSTS); } -void evt_poll(usbd_device *dev, usbd_evt_callback callback) { +static void evt_poll(usbd_device *dev, usbd_evt_callback callback) { uint32_t evt; uint32_t ep = 0; while (1) { @@ -431,7 +431,7 @@ static uint32_t fnv1a32_turn (uint32_t fnv, uint32_t data ) { return fnv; } -uint16_t get_serialno_desc(void *buffer) { +static uint16_t get_serialno_desc(void *buffer) { struct usb_string_descriptor *dsc = buffer; uint16_t *str = dsc->wString; uint32_t fnv = 2166136261; diff --git a/src/usbd_stm32l052_devfs.c b/src/usbd_stm32l052_devfs.c index 8b44339..e6b7f71 100644 --- a/src/usbd_stm32l052_devfs.c +++ b/src/usbd_stm32l052_devfs.c @@ -92,13 +92,13 @@ static uint16_t get_next_pma(uint16_t sz) { return (_result < (0x020 + sz)) ? 0 : (_result - sz); } -uint32_t getinfo(void) { +static uint32_t getinfo(void) { if (!(RCC->APB1ENR & RCC_APB1ENR_USBEN)) return STATUS_VAL(0); if (USB->BCDR & USB_BCDR_DPPU) return STATUS_VAL(USBD_HW_ENABLED | USBD_HW_SPEED_FS); return STATUS_VAL(USBD_HW_ENABLED); } -void ep_setstall(uint8_t ep, bool stall) { +static void ep_setstall(uint8_t ep, bool stall) { volatile uint16_t *reg = EPR(ep); /* ISOCHRONOUS endpoint can't be stalled or unstalled */ if (USB_EP_ISOCHRONOUS == (*reg & USB_EP_T_FIELD)) return; @@ -135,7 +135,7 @@ void ep_setstall(uint8_t ep, bool stall) { } } -bool ep_isstalled(uint8_t ep) { +static bool ep_isstalled(uint8_t ep) { if (ep & 0x80) { return (USB_EP_TX_STALL == (USB_EPTX_STAT & *EPR(ep))); } else { @@ -143,7 +143,7 @@ bool ep_isstalled(uint8_t ep) { } } -void enable(bool enable) { +static void enable(bool enable) { if (enable) { RCC->APB1ENR |= RCC_APB1ENR_USBEN; RCC->APB1RSTR |= RCC_APB1RSTR_USBRST; @@ -164,7 +164,7 @@ void enable(bool enable) { } } -uint8_t connect(bool connect) { +static uint8_t connect(bool connect) { uint8_t res; USB->BCDR = USB_BCDR_BCDEN | USB_BCDR_DCDEN; if (USB->BCDR & USB_BCDR_DCDET) { @@ -188,11 +188,11 @@ uint8_t connect(bool connect) { return res; } -void setaddr (uint8_t addr) { +static void setaddr (uint8_t addr) { USB->DADDR = USB_DADDR_EF | addr; } -bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { +static bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { volatile uint16_t *reg = EPR(ep); pma_table *tbl = EPT(ep); /* epsize should be 16-bit aligned */ @@ -263,7 +263,7 @@ bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { return true; } -void ep_deconfig(uint8_t ep) { +static void ep_deconfig(uint8_t ep) { pma_table *ept = EPT(ep); *EPR(ep) &= ~USB_EPREG_MASK; ept->rx.addr = 0; @@ -291,7 +291,7 @@ static uint16_t pma_read (uint8_t *buf, uint16_t blen, pma_rec *rx) { return rxcnt; } -int32_t ep_read(uint8_t ep, void *buf, uint16_t blen) { +static int32_t ep_read(uint8_t ep, void *buf, uint16_t blen) { pma_table *tbl = EPT(ep); volatile uint16_t *reg = EPR(ep); switch (*reg & (USB_EPRX_STAT | USB_EP_T_FIELD | USB_EP_KIND)) { @@ -347,7 +347,7 @@ static void pma_write(uint8_t *buf, uint16_t blen, pma_rec *tx) { } } -int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { +static int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { pma_table *tbl = EPT(ep); volatile uint16_t *reg = EPR(ep); switch (*reg & (USB_EPTX_STAT | USB_EP_T_FIELD | USB_EP_KIND)) { @@ -382,11 +382,11 @@ int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { return blen; } -uint16_t get_frame (void) { +static uint16_t get_frame (void) { return USB->FNR & USB_FNR_FN; } -void evt_poll(usbd_device *dev, usbd_evt_callback callback) { +static void evt_poll(usbd_device *dev, usbd_evt_callback callback) { uint8_t _ev, _ep; uint16_t _istr = USB->ISTR; _ep = _istr & USB_ISTR_EP_ID; @@ -438,7 +438,7 @@ static uint32_t fnv1a32_turn (uint32_t fnv, uint32_t data ) { return fnv; } -uint16_t get_serialno_desc(void *buffer) { +static uint16_t get_serialno_desc(void *buffer) { struct usb_string_descriptor *dsc = buffer; uint16_t *str = dsc->wString; uint32_t fnv = 2166136261; diff --git a/src/usbd_stm32l100_devfs.c b/src/usbd_stm32l100_devfs.c index 48611fb..c2c978f 100644 --- a/src/usbd_stm32l100_devfs.c +++ b/src/usbd_stm32l100_devfs.c @@ -93,13 +93,13 @@ static uint16_t get_next_pma(uint16_t sz) { return (_result < (0x020 + sz)) ? 0 : (_result - sz); } -uint32_t getinfo(void) { +static uint32_t getinfo(void) { if (!(RCC->APB1ENR & RCC_APB1ENR_USBEN)) return STATUS_VAL(0); if (SYSCFG->PMC & SYSCFG_PMC_USB_PU) return STATUS_VAL(USBD_HW_ENABLED | USBD_HW_SPEED_FS); return STATUS_VAL(USBD_HW_ENABLED); } -void ep_setstall(uint8_t ep, bool stall) { +static void ep_setstall(uint8_t ep, bool stall) { volatile uint16_t *reg = EPR(ep); /* ISOCHRONOUS endpoint can't be stalled or unstalled */ if (USB_EP_ISOCHRONOUS == (*reg & USB_EP_T_FIELD)) return; @@ -136,7 +136,7 @@ void ep_setstall(uint8_t ep, bool stall) { } } -bool ep_isstalled(uint8_t ep) { +static bool ep_isstalled(uint8_t ep) { if (ep & 0x80) { return (USB_EP_TX_STALL == (USB_EPTX_STAT & *EPR(ep))); } else { @@ -144,7 +144,7 @@ bool ep_isstalled(uint8_t ep) { } } -void enable(bool enable) { +static void enable(bool enable) { if (enable) { RCC->APB1ENR |= RCC_APB1ENR_USBEN; RCC->APB2ENR |= RCC_APB2ENR_SYSCFGEN; @@ -162,7 +162,7 @@ void enable(bool enable) { } } -uint8_t connect(bool connect) { +static uint8_t connect(bool connect) { if (connect) { SYSCFG->PMC |= SYSCFG_PMC_USB_PU; } else { @@ -171,12 +171,12 @@ uint8_t connect(bool connect) { return usbd_lane_unk; } -void setaddr (uint8_t addr) { +static void setaddr (uint8_t addr) { USB->DADDR = USB_DADDR_EF | addr; } -bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { +static bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { volatile uint16_t *reg = EPR(ep); pma_table *tbl = EPT(ep); /* epsize should be 16-bit aligned */ @@ -247,7 +247,7 @@ bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { return true; } -void ep_deconfig(uint8_t ep) { +static void ep_deconfig(uint8_t ep) { pma_table *ept = EPT(ep); *EPR(ep) &= ~USB_EPREG_MASK; ept->rx.addr = 0; @@ -275,7 +275,7 @@ static uint16_t pma_read (uint8_t *buf, uint16_t blen, pma_rec *rx) { return rxcnt; } -int32_t ep_read(uint8_t ep, void *buf, uint16_t blen) { +static int32_t ep_read(uint8_t ep, void *buf, uint16_t blen) { pma_table *tbl = EPT(ep); volatile uint16_t *reg = EPR(ep); switch (*reg & (USB_EPRX_STAT | USB_EP_T_FIELD | USB_EP_KIND)) { @@ -331,7 +331,7 @@ static void pma_write(const uint8_t *buf, uint16_t blen, pma_rec *tx) { } } -int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { +static int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { pma_table *tbl = EPT(ep); volatile uint16_t *reg = EPR(ep); switch (*reg & (USB_EPTX_STAT | USB_EP_T_FIELD | USB_EP_KIND)) { @@ -366,11 +366,11 @@ int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { return blen; } -uint16_t get_frame (void) { +static uint16_t get_frame (void) { return USB->FNR & USB_FNR_FN; } -void evt_poll(usbd_device *dev, usbd_evt_callback callback) { +static void evt_poll(usbd_device *dev, usbd_evt_callback callback) { uint8_t _ev, _ep; uint16_t _istr = USB->ISTR; _ep = _istr & USB_ISTR_EP_ID; @@ -423,7 +423,7 @@ static uint32_t fnv1a32_turn (uint32_t fnv, uint32_t data ) { return fnv; } -uint16_t get_serialno_desc(void *buffer) { +static uint16_t get_serialno_desc(void *buffer) { struct usb_string_descriptor *dsc = buffer; uint16_t *str = dsc->wString; uint32_t fnv = 2166136261; diff --git a/src/usbd_stm32l433_devfs.c b/src/usbd_stm32l433_devfs.c index 677e62a..538de90 100644 --- a/src/usbd_stm32l433_devfs.c +++ b/src/usbd_stm32l433_devfs.c @@ -97,13 +97,13 @@ static uint16_t get_next_pma(uint16_t sz) { return (_result < (0x020 + sz)) ? 0 : (_result - sz); } -uint32_t getinfo(void) { +static uint32_t getinfo(void) { if (!(RCC->APB1ENR1 & RCC_APB1ENR1_USBFSEN)) return STATUS_VAL(0); if (USB->BCDR & USB_BCDR_DPPU) return STATUS_VAL(USBD_HW_ENABLED | USBD_HW_SPEED_FS); return STATUS_VAL(USBD_HW_ENABLED); } -void ep_setstall(uint8_t ep, bool stall) { +static void ep_setstall(uint8_t ep, bool stall) { volatile uint16_t *reg = EPR(ep); /* ISOCHRONOUS endpoint can't be stalled or unstalled */ if (USB_EP_ISOCHRONOUS == (*reg & USB_EP_T_FIELD)) return; @@ -140,7 +140,7 @@ void ep_setstall(uint8_t ep, bool stall) { } } -bool ep_isstalled(uint8_t ep) { +static bool ep_isstalled(uint8_t ep) { if (ep & 0x80) { return (USB_EP_TX_STALL == (USB_EPTX_STAT & *EPR(ep))); } else { @@ -148,7 +148,7 @@ bool ep_isstalled(uint8_t ep) { } } -void enable(bool enable) { +static void enable(bool enable) { if (enable) { RCC->APB1ENR1 |= RCC_APB1ENR1_USBFSEN; RCC->APB1RSTR1 |= RCC_APB1RSTR1_USBFSRST; @@ -165,7 +165,7 @@ void enable(bool enable) { } } -uint8_t connect(bool connect) { +static uint8_t connect(bool connect) { uint8_t res; USB->BCDR = USB_BCDR_BCDEN | USB_BCDR_DCDEN; if (USB->BCDR & USB_BCDR_DCDET) { @@ -189,11 +189,11 @@ uint8_t connect(bool connect) { return res; } -void setaddr (uint8_t addr) { +static void setaddr (uint8_t addr) { USB->DADDR = USB_DADDR_EF | addr; } -bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { +static bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { volatile uint16_t *reg = EPR(ep); pma_table *tbl = EPT(ep); /* epsize should be 16-bit aligned */ @@ -264,7 +264,7 @@ bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { return true; } -void ep_deconfig(uint8_t ep) { +static void ep_deconfig(uint8_t ep) { pma_table *ept = EPT(ep); *EPR(ep) &= ~USB_EPREG_MASK; ept->rx.addr = 0; @@ -294,7 +294,7 @@ static uint16_t pma_read (uint8_t *buf, uint16_t blen, pma_rec *rx) { return rxcnt; } -int32_t ep_read(uint8_t ep, void *buf, uint16_t blen) { +static int32_t ep_read(uint8_t ep, void *buf, uint16_t blen) { pma_table *tbl = EPT(ep); volatile uint16_t *reg = EPR(ep); switch (*reg & (USB_EPRX_STAT | USB_EP_T_FIELD | USB_EP_KIND)) { @@ -348,7 +348,7 @@ static void pma_write(uint8_t *buf, uint16_t blen, pma_rec *tx) { if (blen) *pma = *buf; } -int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { +static int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { pma_table *tbl = EPT(ep); volatile uint16_t *reg = EPR(ep); switch (*reg & (USB_EPTX_STAT | USB_EP_T_FIELD | USB_EP_KIND)) { @@ -383,11 +383,11 @@ int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { return blen; } -uint16_t get_frame (void) { +static uint16_t get_frame (void) { return USB->FNR & USB_FNR_FN; } -void evt_poll(usbd_device *dev, usbd_evt_callback callback) { +static void evt_poll(usbd_device *dev, usbd_evt_callback callback) { uint8_t _ev, _ep; uint16_t _istr = USB->ISTR; _ep = _istr & USB_ISTR_EP_ID; @@ -439,7 +439,7 @@ static uint32_t fnv1a32_turn (uint32_t fnv, uint32_t data ) { return fnv; } -uint16_t get_serialno_desc(void *buffer) { +static uint16_t get_serialno_desc(void *buffer) { struct usb_string_descriptor *dsc = buffer; uint16_t *str = dsc->wString; uint32_t fnv = 2166136261; diff --git a/src/usbd_stm32l476_otgfs.c b/src/usbd_stm32l476_otgfs.c index 183d2f5..a0246b5 100644 --- a/src/usbd_stm32l476_otgfs.c +++ b/src/usbd_stm32l476_otgfs.c @@ -29,9 +29,9 @@ #define STATUS_VAL(x) (USBD_HW_BC | USBD_HW_ADDRFST | (x)) -USB_OTG_GlobalTypeDef * const OTG = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_GLOBAL_BASE); -USB_OTG_DeviceTypeDef * const OTGD = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_DEVICE_BASE); -volatile uint32_t * const OTGPCTL = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_PCGCCTL_BASE); +static USB_OTG_GlobalTypeDef * const OTG = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_GLOBAL_BASE); +static USB_OTG_DeviceTypeDef * const OTGD = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_DEVICE_BASE); +static volatile uint32_t * const OTGPCTL = (void*)(USB_OTG_FS_PERIPH_BASE + USB_OTG_PCGCCTL_BASE); inline static uint32_t* EPFIFO(uint32_t ep) { @@ -57,13 +57,13 @@ inline static void Flush_TX(uint8_t ep) { _WBC(OTG->GRSTCTL, USB_OTG_GRSTCTL_TXFFLSH); } -uint32_t getinfo(void) { +static uint32_t getinfo(void) { if (!(RCC->AHB2ENR & RCC_AHB2ENR_OTGFSEN)) return STATUS_VAL(0); if (!(OTGD->DCTL & USB_OTG_DCTL_SDIS)) return STATUS_VAL(USBD_HW_ENABLED | USBD_HW_SPEED_FS); return STATUS_VAL(USBD_HW_ENABLED); } -void ep_setstall(uint8_t ep, bool stall) { +static void ep_setstall(uint8_t ep, bool stall) { if (ep & 0x80) { ep &= 0x7F; uint32_t _t = EPIN(ep)->DIEPCTL; @@ -90,7 +90,7 @@ void ep_setstall(uint8_t ep, bool stall) { } } -bool ep_isstalled(uint8_t ep) { +static bool ep_isstalled(uint8_t ep) { if (ep & 0x80) { ep &= 0x7F; return (EPIN(ep)->DIEPCTL & USB_OTG_DIEPCTL_STALL) ? true : false; @@ -99,7 +99,7 @@ bool ep_isstalled(uint8_t ep) { } } -void enable(bool enable) { +static void enable(bool enable) { if (enable) { /* enabling USB_OTG in RCC */ _BST(RCC->AHB2ENR, RCC_AHB2ENR_OTGFSEN); @@ -155,7 +155,7 @@ void enable(bool enable) { } } -uint8_t connect(bool connect) { +static uint8_t connect(bool connect) { uint8_t res; #if defined(USBD_VBUS_DETECT) #define SET_GCCFG(x) OTG->GCCFG = USB_OTG_GCCFG_VBDEN | (x) @@ -189,7 +189,7 @@ uint8_t connect(bool connect) { return res; } -void setaddr (uint8_t addr) { +static void setaddr (uint8_t addr) { _BMD(OTGD->DCFG, USB_OTG_DCFG_DAD, addr << 4); } @@ -225,7 +225,7 @@ static bool set_tx_fifo(uint8_t ep, uint16_t epsize) { return true; } -bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { +static bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { if (ep == 0) { /* configureing control endpoint EP0 */ uint32_t mpsize; @@ -312,7 +312,7 @@ bool ep_config(uint8_t ep, uint8_t eptype, uint16_t epsize) { return true; } -void ep_deconfig(uint8_t ep) { +static void ep_deconfig(uint8_t ep) { ep &= 0x7F; volatile USB_OTG_INEndpointTypeDef* epi = EPIN(ep); volatile USB_OTG_OUTEndpointTypeDef* epo = EPOUT(ep); @@ -341,7 +341,7 @@ void ep_deconfig(uint8_t ep) { epo->DOEPINT = 0xFF; } -int32_t ep_read(uint8_t ep, void* buf, uint16_t blen) { +static int32_t ep_read(uint8_t ep, void* buf, uint16_t blen) { uint32_t len, tmp; ep &= 0x7F; volatile uint32_t *fifo = EPFIFO(0); @@ -364,7 +364,7 @@ int32_t ep_read(uint8_t ep, void* buf, uint16_t blen) { return (len < blen) ? len : blen; } -int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { +static int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { uint32_t len, tmp; ep &= 0x7F; volatile uint32_t* fifo = EPFIFO(ep); @@ -391,11 +391,11 @@ int32_t ep_write(uint8_t ep, void *buf, uint16_t blen) { return blen; } -uint16_t get_frame (void) { +static uint16_t get_frame (void) { return _FLD2VAL(USB_OTG_DSTS_FNSOF, OTGD->DSTS); } -void evt_poll(usbd_device *dev, usbd_evt_callback callback) { +static void evt_poll(usbd_device *dev, usbd_evt_callback callback) { uint32_t evt; uint32_t ep = 0; while (1) { @@ -464,7 +464,7 @@ static uint32_t fnv1a32_turn (uint32_t fnv, uint32_t data ) { return fnv; } -uint16_t get_serialno_desc(void *buffer) { +static uint16_t get_serialno_desc(void *buffer) { struct usb_string_descriptor *dsc = buffer; uint16_t *str = dsc->wString; uint32_t fnv = 2166136261; |