2022-11-24 09:13 PM
Hi,
We are using STM32H750XB MCU with the STULPI01A, external High-speed USB ULPI transceiver.
Is there a way to access STULPI01A registers from firmware running on the MCU ?
rgds,
kc Wong
2023-01-03 05:12 PM
#define USB_OTG_GPVNDCTL_REGWR (0x1U << 22)
#define USB_OTG_GPVNDCTL_NEWREGREQ (0x1U << 25)
#define USB_OTG_GPVNDCTL_VSTSDONE (0x1U << 27)
#define USB_OTG_GPVNDCTL_OFFSET 0x34U
#define USBx_GPVNDCTL *(__IO uint32_t *)((uint32_t)USBx_BASE +
USB_OTG_GPVNDCTL_OFFSET)
/**
* @brief USB_ulpi_phy_ReadReg
* @param USBx Selected device
* @param USB PHY register address
* @param data buffer to store register value
* @retval HAL status
*/
HAL_StatusTypeDef USB_ulpi_phy_ReadReg(USB_OTG_GlobalTypeDef *USBx, uint8_t
phyaddr, uint32_t *RegData)
{
uint32_t USBx_BASE = (uint32_t)USBx;
__IO uint32_t count = 0U;
USBx_GPVNDCTL = (phyaddr << 16) | USB_OTG_GPVNDCTL_NEWREGREQ;
do
{
count++;
if (count > 200000U)
{
return HAL_TIMEOUT;
}
} while ((USBx_GPVNDCTL & USB_OTG_GPVNDCTL_VSTSDONE) !=
USB_OTG_GPVNDCTL_VSTSDONE);
*RegData = USBx_GPVNDCTL & 0xFFU;
return HAL_OK;
}
/**
* @brief USB_ulpi_phy_WriteReg
* @param USBx Selected device
* @param USB PHY register address
* @param register data
* @retval HAL status
*/
HAL_StatusTypeDef USB_ulpi_phy_WriteReg(USB_OTG_GlobalTypeDef *USBx, uint8_t
phyaddr, uint32_t RegData)
{
uint32_t USBx_BASE = (uint32_t)USBx;
__IO uint32_t count = 0U;
USBx_GPVNDCTL = (phyaddr << 16) |
USB_OTG_GPVNDCTL_NEWREGREQ |
USB_OTG_GPVNDCTL_REGWR |
(RegData & 0xFFU);
do
{
count++;
if (count > 200000U)
{
return HAL_TIMEOUT;
}
} while ((USBx_GPVNDCTL & USB_OTG_GPVNDCTL_VSTSDONE) !=
USB_OTG_GPVNDCTL_VSTSDONE);
return HAL_OK;
}