need to be able to explicitly indicate Vddusb is valid in order to use the OTFS block in this chip; done via PWR CR2 bit USV.
This commit is contained in:
parent
3970c98daf
commit
d2b78eddec
@ -138,7 +138,7 @@ bool stm32l4_pwr_enablebkp(bool writable)
|
||||
uint16_t regval;
|
||||
bool waswritable;
|
||||
|
||||
/* Get the current state of the STM32 PWR control register */
|
||||
/* Get the current state of the STM32L4 PWR control register 1 */
|
||||
|
||||
regval = stm32l4_pwr_getreg(STM32L4_PWR_CR1_OFFSET);
|
||||
waswritable = ((regval & PWR_CR1_DBP) != 0);
|
||||
@ -166,3 +166,49 @@ bool stm32l4_pwr_enablebkp(bool writable)
|
||||
|
||||
return waswritable;
|
||||
}
|
||||
|
||||
/************************************************************************************
|
||||
* Name: stm32l4_pwr_enableusv
|
||||
*
|
||||
* Description:
|
||||
* Enables or disables the USB Supply Valid monitoring. Setting this bit is
|
||||
* mandatory to use the USB OTG FS peripheral.
|
||||
*
|
||||
* Input Parameters:
|
||||
* set - True: Vddusb is valid; False: Vddusb is not present. Logical and electrical
|
||||
* isolation is applied to ignore this supply.
|
||||
*
|
||||
* Returned Value:
|
||||
* True: The bit was previously set.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
bool stm32l4_pwr_enableusv(bool set)
|
||||
{
|
||||
uint16_t regval;
|
||||
bool wasset;
|
||||
|
||||
/* Get the current state of the STM32L4 PWR control register 2 */
|
||||
|
||||
regval = stm32l4_pwr_getreg(STM32L4_PWR_CR2_OFFSET);
|
||||
wasset = ((regval & PWR_CR2_USV) != 0);
|
||||
|
||||
/* Enable or disable the ability to write */
|
||||
|
||||
if (wasset && !set)
|
||||
{
|
||||
/* Disable the Vddusb monitoring */
|
||||
|
||||
regval &= ~PWR_CR2_USV;
|
||||
stm32l4_pwr_putreg(STM32L4_PWR_CR2_OFFSET, regval);
|
||||
}
|
||||
else if (!wasset && set)
|
||||
{
|
||||
/* Enable the Vddusb monitoring */
|
||||
|
||||
regval |= PWR_CR2_USV;
|
||||
stm32l4_pwr_putreg(STM32L4_PWR_CR2_OFFSET, regval);
|
||||
}
|
||||
|
||||
return wasset;
|
||||
}
|
||||
|
@ -101,6 +101,24 @@ bool stm32l4_pwr_enableclk(bool enable);
|
||||
|
||||
bool stm32l4_pwr_enablebkp(bool writable);
|
||||
|
||||
/************************************************************************************
|
||||
* Name: stm32l4_pwr_enableusv
|
||||
*
|
||||
* Description:
|
||||
* Enables or disables the USB Supply Valid monitoring. Setting this bit is
|
||||
* mandatory to use the USB OTG FS peripheral.
|
||||
*
|
||||
* Input Parameters:
|
||||
* set - True: Vddusb is valid; False: Vddusb is not present. Logical and electrical
|
||||
* isolation is applied to ignore this supply.
|
||||
*
|
||||
* Returned Value:
|
||||
* True: The bit was previously set.
|
||||
*
|
||||
************************************************************************************/
|
||||
|
||||
bool stm32l4_pwr_enableusv(bool set);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
Loading…
Reference in New Issue
Block a user