flatUSB/driver/stm32/common_defs.h
Epagris 685fa77bda - function separation done
- a load of CMake modification
2024-11-16 18:15:13 +01:00

48 lines
1.4 KiB
C

#ifndef CORE_USB_USB_COMMON_DEFS
#define CORE_USB_USB_COMMON_DEFS
#include <flatUSB_config.h>
// Select appropriate headers
#if defined(STM32H745xx) || defined(STM32H743xx) || defined(STM32H723xx)
#include <stm32h7xx.h>
#include <stm32h7xx_hal.h>
#define USB_STM32H7
// ------------
#elif defined(STM32F407xx) || defined(STM32F401xC)
#include <stm32f4xx.h>
#include <stm32f4xx_hal.h>
#define USB_STM32F4
#endif
#define USB_LINESPEED_FULL_SPEED (0b11)
#define USB_LINESPEED_FULL_SPEED_ULPI (0b01)
#define USB_LINESPEED_HIGH_SPEED_ULPI (0b00)
#define USBD ((USB_OTG_DeviceTypeDef *) (((uint32_t)(USBG)) + ((uint32_t)(USB_OTG_DEVICE_BASE))))
#define USBINEP ((USB_OTG_INEndpointTypeDef *) (((uint32_t)(USBG)) + ((uint32_t)(USB_OTG_IN_ENDPOINT_BASE))))
#define USBOUTEP ((USB_OTG_OUTEndpointTypeDef *) (((uint32_t)(USBG)) + ((uint32_t)(USB_OTG_OUT_ENDPOINT_BASE))))
#define USBFIFO(ep) ((uint32_t *)(((uint32_t)(USBG)) + USB_OTG_FIFO_BASE + (USB_OTG_FIFO_SIZE) * (ep)))
#define USBPCGCCTL ((uint32_t *)(((uint32_t)(USBG)) + USB_OTG_PCGCCTL_BASE))
// Set TOCAL and TRDT values (see Ref. Man.)
#if defined(USB_STM32H7) /*|| defined(USB_HIGH_SPEED)*/
#define TOCAL_VALUE (0x00)
#define TRDT_VALUE (0x05)
#elif defined(USB_STM32F4)
#if !defined(USB_HIGH_SPEED)
#define TOCAL_VALUE (0x07)
#define TRDT_VALUE (0x06)
#else
#define TOCAL_VALUE (0x07)
#define TRDT_VALUE (0x09)
#endif
#endif
#endif /* CORE_USB_USB_COMMON_DEFS */