diff options
author | Vegard Storheil Eriksen <zyp@jvnv.net> | 2023-05-01 00:50:55 +0200 |
---|---|---|
committer | Vegard Storheil Eriksen <zyp@jvnv.net> | 2023-05-01 00:50:55 +0200 |
commit | d381db5b1f6a7d7897056adb84ea24f18f2dd0b8 (patch) | |
tree | 411568025c0aa101bd3241416ce192ae9c2a9ab1 /usb/stm32_usb_def.h | |
parent | 3eb114c680a63274948700c653dfc263d182171a (diff) |
usb: Update code for stm32_usb and add support for v3.
Diffstat (limited to 'usb/stm32_usb_def.h')
-rw-r--r-- | usb/stm32_usb_def.h | 71 |
1 files changed, 71 insertions, 0 deletions
diff --git a/usb/stm32_usb_def.h b/usb/stm32_usb_def.h new file mode 100644 index 0000000..5fdd2ff --- /dev/null +++ b/usb/stm32_usb_def.h @@ -0,0 +1,71 @@ +#pragma once + +#include <mmio/mmio.h> + +struct STM32_USB_reg_v1_t { + volatile uint32_t EPR[16]; + volatile uint32_t CNTR; + volatile uint32_t ISTR; + volatile uint32_t FNR; + volatile uint32_t DADDR; + volatile uint32_t BTABLE; + + struct bufd_t { + volatile uint32_t ADDR_TX; + volatile uint32_t COUNT_TX; + volatile uint32_t ADDR_RX; + volatile uint32_t COUNT_RX; + }; + + using buf_t = volatile uint32_t; +}; + +struct STM32_USB_reg_v2_t { + volatile uint32_t EPR[16]; + volatile uint32_t CNTR; + volatile uint32_t ISTR; + volatile uint32_t FNR; + volatile uint32_t DADDR; + volatile uint32_t BTABLE; + volatile uint32_t LPMCSR; + volatile uint32_t BCDR; + + struct bufd_t { + volatile uint16_t ADDR_TX; + volatile uint16_t COUNT_TX; + volatile uint16_t ADDR_RX; + volatile uint16_t COUNT_RX; + }; + + using buf_t = volatile uint16_t; +}; + +struct STM32_USB_reg_v3_t { + volatile uint32_t EPR[16]; + volatile uint32_t CNTR; + volatile uint32_t ISTR; + volatile uint32_t FNR; + volatile uint32_t DADDR; + uint32_t _reserved; + volatile uint32_t LPMCSR; + volatile uint32_t BCDR; + + struct bufd_t { + volatile uint32_t TXRXBD; + volatile uint32_t RXTXBD; + }; + + using buf_t = volatile uint32_t; +}; + +template <typename T> +class STM32_USB_t : public mmio_ptr<T> { + public: + mmio_ptr<typename T::bufd_t> bufd; + mmio_ptr<typename T::buf_t> buf; + + constexpr STM32_USB_t(uint32_t reg_addr, uint32_t buf_addr) : + mmio_ptr<T>(reg_addr), + bufd(buf_addr), + buf(buf_addr) {} +}; |