Embedded package update
This commit is contained in:
parent
46a5748e75
commit
411b895bf7
54 changed files with 3660 additions and 1918 deletions
|
@ -232,7 +232,6 @@
|
|||
*/
|
||||
static uint32_t UTILS_GetPLLOutputFrequency(uint32_t PLL_InputFrequency,
|
||||
LL_UTILS_PLLInitTypeDef *UTILS_PLLInitStruct);
|
||||
static ErrorStatus UTILS_SetFlashLatency(uint32_t HCLK_Frequency);
|
||||
static ErrorStatus UTILS_EnablePLLAndSwitchSystem(uint32_t SYSCLK_Frequency, LL_UTILS_ClkInitTypeDef *UTILS_ClkInitStruct);
|
||||
static ErrorStatus UTILS_PLL_IsBusy(void);
|
||||
/**
|
||||
|
@ -328,6 +327,144 @@ void LL_SetSystemCoreClock(uint32_t HCLKFrequency)
|
|||
SystemCoreClock = HCLKFrequency;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Update number of Flash wait states in line with new frequency and current
|
||||
voltage range.
|
||||
* @note This Function support ONLY devices with supply voltage (voltage range) between 2.7V and 3.6V
|
||||
* @param HCLK_Frequency HCLK frequency
|
||||
* @retval An ErrorStatus enumeration value:
|
||||
* - SUCCESS: Latency has been modified
|
||||
* - ERROR: Latency cannot be modified
|
||||
*/
|
||||
ErrorStatus LL_SetFlashLatency(uint32_t HCLK_Frequency)
|
||||
{
|
||||
uint32_t timeout;
|
||||
uint32_t getlatency;
|
||||
uint32_t latency = LL_FLASH_LATENCY_0; /* default value 0WS */
|
||||
ErrorStatus status = SUCCESS;
|
||||
|
||||
|
||||
/* Frequency cannot be equal to 0 */
|
||||
if(HCLK_Frequency == 0U)
|
||||
{
|
||||
status = ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(LL_PWR_GetRegulVoltageScaling() == LL_PWR_REGU_VOLTAGE_SCALE1)
|
||||
{
|
||||
#if defined (UTILS_SCALE1_LATENCY5_FREQ)
|
||||
if((HCLK_Frequency > UTILS_SCALE1_LATENCY5_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_5;
|
||||
}
|
||||
#endif /*UTILS_SCALE1_LATENCY5_FREQ */
|
||||
#if defined (UTILS_SCALE1_LATENCY4_FREQ)
|
||||
if((HCLK_Frequency > UTILS_SCALE1_LATENCY4_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_4;
|
||||
}
|
||||
#endif /* UTILS_SCALE1_LATENCY4_FREQ */
|
||||
#if defined (UTILS_SCALE1_LATENCY3_FREQ)
|
||||
if((HCLK_Frequency > UTILS_SCALE1_LATENCY3_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_3;
|
||||
}
|
||||
#endif /* UTILS_SCALE1_LATENCY3_FREQ */
|
||||
#if defined (UTILS_SCALE1_LATENCY2_FREQ)
|
||||
if((HCLK_Frequency > UTILS_SCALE1_LATENCY2_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((HCLK_Frequency > UTILS_SCALE1_LATENCY1_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_1;
|
||||
}
|
||||
}
|
||||
#endif /* UTILS_SCALE1_LATENCY2_FREQ */
|
||||
}
|
||||
if(LL_PWR_GetRegulVoltageScaling() == LL_PWR_REGU_VOLTAGE_SCALE2)
|
||||
{
|
||||
#if defined (UTILS_SCALE2_LATENCY5_FREQ)
|
||||
if((HCLK_Frequency > UTILS_SCALE2_LATENCY5_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_5;
|
||||
}
|
||||
#endif /*UTILS_SCALE1_LATENCY5_FREQ */
|
||||
#if defined (UTILS_SCALE2_LATENCY4_FREQ)
|
||||
if((HCLK_Frequency > UTILS_SCALE2_LATENCY4_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_4;
|
||||
}
|
||||
#endif /*UTILS_SCALE1_LATENCY4_FREQ */
|
||||
#if defined (UTILS_SCALE2_LATENCY3_FREQ)
|
||||
if((HCLK_Frequency > UTILS_SCALE2_LATENCY3_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_3;
|
||||
}
|
||||
#endif /*UTILS_SCALE1_LATENCY3_FREQ */
|
||||
if((HCLK_Frequency > UTILS_SCALE2_LATENCY2_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((HCLK_Frequency > UTILS_SCALE2_LATENCY1_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#if defined (LL_PWR_REGU_VOLTAGE_SCALE3)
|
||||
if(LL_PWR_GetRegulVoltageScaling() == LL_PWR_REGU_VOLTAGE_SCALE3)
|
||||
{
|
||||
#if defined (UTILS_SCALE3_LATENCY3_FREQ)
|
||||
if((HCLK_Frequency > UTILS_SCALE3_LATENCY3_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_3;
|
||||
}
|
||||
#endif /*UTILS_SCALE1_LATENCY3_FREQ */
|
||||
#if defined (UTILS_SCALE3_LATENCY2_FREQ)
|
||||
if((HCLK_Frequency > UTILS_SCALE3_LATENCY2_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((HCLK_Frequency > UTILS_SCALE3_LATENCY1_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /*UTILS_SCALE1_LATENCY2_FREQ */
|
||||
#endif /* LL_PWR_REGU_VOLTAGE_SCALE3 */
|
||||
|
||||
LL_FLASH_SetLatency(latency);
|
||||
/* Check that the new number of wait states is taken into account to access the Flash
|
||||
memory by reading the FLASH_ACR register */
|
||||
timeout = 2;
|
||||
do
|
||||
{
|
||||
/* Wait for Flash latency to be updated */
|
||||
getlatency = LL_FLASH_GetLatency();
|
||||
timeout--;
|
||||
} while ((getlatency != latency) && (timeout > 0));
|
||||
|
||||
if(getlatency != latency)
|
||||
{
|
||||
status = ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
status = SUCCESS;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief This function configures system clock at maximum frequency with HSI as clock source of the PLL
|
||||
* @note The application need to ensure that PLL is disabled.
|
||||
|
@ -465,131 +602,6 @@ ErrorStatus LL_PLL_ConfigSystemClock_HSE(uint32_t HSEFrequency, uint32_t HSEBypa
|
|||
/** @addtogroup UTILS_LL_Private_Functions
|
||||
* @{
|
||||
*/
|
||||
/**
|
||||
* @brief Update number of Flash wait states in line with new frequency and current
|
||||
voltage range.
|
||||
* @note This Function support ONLY devices with supply voltage (voltage range) between 2.7V and 3.6V
|
||||
* @param HCLK_Frequency HCLK frequency
|
||||
* @retval An ErrorStatus enumeration value:
|
||||
* - SUCCESS: Latency has been modified
|
||||
* - ERROR: Latency cannot be modified
|
||||
*/
|
||||
static ErrorStatus UTILS_SetFlashLatency(uint32_t HCLK_Frequency)
|
||||
{
|
||||
ErrorStatus status = SUCCESS;
|
||||
|
||||
uint32_t latency = LL_FLASH_LATENCY_0; /* default value 0WS */
|
||||
|
||||
/* Frequency cannot be equal to 0 */
|
||||
if(HCLK_Frequency == 0U)
|
||||
{
|
||||
status = ERROR;
|
||||
}
|
||||
else
|
||||
{
|
||||
if(LL_PWR_GetRegulVoltageScaling() == LL_PWR_REGU_VOLTAGE_SCALE1)
|
||||
{
|
||||
#if defined (UTILS_SCALE1_LATENCY5_FREQ)
|
||||
if((HCLK_Frequency > UTILS_SCALE1_LATENCY5_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_5;
|
||||
}
|
||||
#endif /*UTILS_SCALE1_LATENCY5_FREQ */
|
||||
#if defined (UTILS_SCALE1_LATENCY4_FREQ)
|
||||
if((HCLK_Frequency > UTILS_SCALE1_LATENCY4_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_4;
|
||||
}
|
||||
#endif /* UTILS_SCALE1_LATENCY4_FREQ */
|
||||
#if defined (UTILS_SCALE1_LATENCY3_FREQ)
|
||||
if((HCLK_Frequency > UTILS_SCALE1_LATENCY3_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_3;
|
||||
}
|
||||
#endif /* UTILS_SCALE1_LATENCY3_FREQ */
|
||||
#if defined (UTILS_SCALE1_LATENCY2_FREQ)
|
||||
if((HCLK_Frequency > UTILS_SCALE1_LATENCY2_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((HCLK_Frequency > UTILS_SCALE1_LATENCY1_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_1;
|
||||
}
|
||||
}
|
||||
#endif /* UTILS_SCALE1_LATENCY2_FREQ */
|
||||
}
|
||||
if(LL_PWR_GetRegulVoltageScaling() == LL_PWR_REGU_VOLTAGE_SCALE2)
|
||||
{
|
||||
#if defined (UTILS_SCALE2_LATENCY5_FREQ)
|
||||
if((HCLK_Frequency > UTILS_SCALE2_LATENCY5_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_5;
|
||||
}
|
||||
#endif /*UTILS_SCALE1_LATENCY5_FREQ */
|
||||
#if defined (UTILS_SCALE2_LATENCY4_FREQ)
|
||||
if((HCLK_Frequency > UTILS_SCALE2_LATENCY4_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_4;
|
||||
}
|
||||
#endif /*UTILS_SCALE1_LATENCY4_FREQ */
|
||||
#if defined (UTILS_SCALE2_LATENCY3_FREQ)
|
||||
if((HCLK_Frequency > UTILS_SCALE2_LATENCY3_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_3;
|
||||
}
|
||||
#endif /*UTILS_SCALE1_LATENCY3_FREQ */
|
||||
if((HCLK_Frequency > UTILS_SCALE2_LATENCY2_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((HCLK_Frequency > UTILS_SCALE2_LATENCY1_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#if defined (LL_PWR_REGU_VOLTAGE_SCALE3)
|
||||
if(LL_PWR_GetRegulVoltageScaling() == LL_PWR_REGU_VOLTAGE_SCALE3)
|
||||
{
|
||||
#if defined (UTILS_SCALE3_LATENCY3_FREQ)
|
||||
if((HCLK_Frequency > UTILS_SCALE3_LATENCY3_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_3;
|
||||
}
|
||||
#endif /*UTILS_SCALE1_LATENCY3_FREQ */
|
||||
#if defined (UTILS_SCALE3_LATENCY2_FREQ)
|
||||
if((HCLK_Frequency > UTILS_SCALE3_LATENCY2_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_2;
|
||||
}
|
||||
else
|
||||
{
|
||||
if((HCLK_Frequency > UTILS_SCALE3_LATENCY1_FREQ)&&(latency == LL_FLASH_LATENCY_0))
|
||||
{
|
||||
latency = LL_FLASH_LATENCY_1;
|
||||
}
|
||||
}
|
||||
}
|
||||
#endif /*UTILS_SCALE1_LATENCY2_FREQ */
|
||||
#endif /* LL_PWR_REGU_VOLTAGE_SCALE3 */
|
||||
|
||||
LL_FLASH_SetLatency(latency);
|
||||
|
||||
/* Check that the new number of wait states is taken into account to access the Flash
|
||||
memory by reading the FLASH_ACR register */
|
||||
if(LL_FLASH_GetLatency() != latency)
|
||||
{
|
||||
status = ERROR;
|
||||
}
|
||||
}
|
||||
return status;
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Function to check that PLL can be modified
|
||||
* @param PLL_InputFrequency PLL input frequency (in Hz)
|
||||
|
@ -683,7 +695,7 @@ static ErrorStatus UTILS_EnablePLLAndSwitchSystem(uint32_t SYSCLK_Frequency, LL_
|
|||
if(SystemCoreClock < hclk_frequency)
|
||||
{
|
||||
/* Set FLASH latency to highest latency */
|
||||
status = UTILS_SetFlashLatency(hclk_frequency);
|
||||
status = LL_SetFlashLatency(hclk_frequency);
|
||||
}
|
||||
|
||||
/* Update system clock configuration */
|
||||
|
@ -713,7 +725,7 @@ static ErrorStatus UTILS_EnablePLLAndSwitchSystem(uint32_t SYSCLK_Frequency, LL_
|
|||
if(SystemCoreClock > hclk_frequency)
|
||||
{
|
||||
/* Set FLASH latency to lowest latency */
|
||||
status = UTILS_SetFlashLatency(hclk_frequency);
|
||||
status = LL_SetFlashLatency(hclk_frequency);
|
||||
}
|
||||
|
||||
/* Update SystemCoreClock variable */
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue