diff options
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) {} +}; |