📄 drvfmc.c
字号:
/* Description: */
/* Disable APROM update function. */
/* */
/* Note1: Only NuMicro NUC1x0xxxCx Series (Ex. NUC140VE3CN) support this function. */
/* */
/* Note2: */
/* Please make sure that Register Write-Protection Function has been disabled before using */
/* this function to disable AP update function. */
/* User can check the status of Register Write-Protection Function */
/* with DrvSYS_IsProtectedRegLocked(). */
/*---------------------------------------------------------------------------------------------------------*/
void DrvFMC_DisableAPUpdate(void)
{
FMC->ISPCON.APUEN = 0;
}
/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvFMC_EnablePowerSaving */
/* */
/* Parameters: */
/* None */
/* */
/* Returns: */
/* None */
/* */
/* Description: */
/* Enable flash power saving function */
/* */
/* Note: */
/* Please make sure that Register Write-Protection Function has been disabled before using */
/* this function to enable flash power saving function. */
/* User can check the status of Register Write-Protection Function */
/* with DrvSYS_IsProtectedRegLocked(). */
/*---------------------------------------------------------------------------------------------------------*/
void DrvFMC_EnablePowerSaving(void)
{
FMC->FATCON.FPSEN = 1;
}
/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvFMC_DisablePowerSaving */
/* */
/* Parameters: */
/* None */
/* */
/* Returns: */
/* None */
/* */
/* Description: */
/* Disable flash power saving function */
/* */
/* Note: */
/* Please make sure that Register Write-Protection Function has been disabled before using */
/* this function to disable flash power saving function. */
/* User can check the status of Register Write-Protection Function */
/* with DrvSYS_IsProtectedRegLocked(). */
/*---------------------------------------------------------------------------------------------------------*/
void DrvFMC_DisablePowerSaving(void)
{
FMC->FATCON.FPSEN = 0;
}
/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvFMC_EnableLowFreqOptMode */
/* */
/* Parameters: */
/* None */
/* */
/* Returns: */
/* None */
/* */
/* Description: */
/* Enable flash access low frequency optimization mode. It can improve flash access */
/* performance when CPU runs at low frequency. */
/* */
/* Note1: Only NuMicro NUC1x0xxxCx Series (Ex. NUC140VE3CN) and Low Density Series support */
/* this function. */
/* Note2: Set this bit only when HCLK <= 25MHz. */
/* If HCLK > 25MHz, CPU will fetch wrong code and cause fail result. */
/* Note3: */
/* Please make sure that Register Write-Protection Function has been disabled before using */
/* this function to enable flash access low frequency optimization mode. */
/* User can check the status of Register Write-Protection Function */
/* with DrvSYS_IsProtectedRegLocked(). */
/*---------------------------------------------------------------------------------------------------------*/
void DrvFMC_EnableLowFreqOptMode(void)
{
FMC->FATCON.LFOM = 1;
}
/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvFMC_DisableLowFreqOptMode */
/* */
/* Parameters: */
/* None */
/* */
/* Returns: */
/* None */
/* */
/* Description: */
/* Disable flash access low frequency optimization mode. */
/* */
/* Note1: Only NuMicro NUC1x0xxxCx Series (Ex. NUC140VE3CN) and Low Density Series support */
/* this function. */
/* Note2: */
/* Please make sure that Register Write-Protection Function has been disabled before using */
/* this function to disable flash access low frequency optimization mode. */
/* User can check the status of Register Write-Protection Function */
/* with DrvSYS_IsProtectedRegLocked(). */
/*---------------------------------------------------------------------------------------------------------*/
void DrvFMC_DisableLowFreqOptMode(void)
{
FMC->FATCON.LFOM = 0;
}
/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvFMC_ReadDataFlashBaseAddr */
/* */
/* Parameters: */
/* None */
/* */
/* Returns: */
/* Data Flash base address */
/* */
/* Description: */
/* Read Data Flash base address */
/*---------------------------------------------------------------------------------------------------------*/
uint32_t DrvFMC_ReadDataFlashBaseAddr(void)
{
return FMC->DFBADR;
}
/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvFMC_WriteConfig */
/* */
/* Parameters: */
/* u32data0 - [in] Config0 data */
/* u32data1 - [in] Config1 data */
/* */
/* */
/* Returns: */
/* 0 Success */
/* <0 Failed when illegal condition occurs */
/* */
/* Description: */
/* Erase Config and write data into Config0 and Config1 */
/* The corresponding functions in Config0 & Config1 are listed in FMC section of TRM */
/* */
/* Note: */
/* Please make sure that Register Write-Protection Function has been disabled before using */
/* this function. */
/* User can check the status of Register Write-Protection Function */
/* with DrvSYS_IsProtectedRegLocked(). */
/*---------------------------------------------------------------------------------------------------------*/
int32_t DrvFMC_WriteConfig(uint32_t u32data0, uint32_t u32data1)
{
if ( DrvFMC_Erase(CONFIG0) != E_SUCCESS )
return E_DRVFMC_ERR_ISP_FAIL;
if ( DrvFMC_Write(CONFIG0, u32data0) != E_SUCCESS )
return E_DRVFMC_ERR_ISP_FAIL;
return DrvFMC_Write(CONFIG1, u32data1);
}
/*---------------------------------------------------------------------------------------------------------*/
/* Function: DrvFMC_GetVersion */
/* */
/* Parameters: */
/* None */
/* */
/* Returns: */
/* The DrvFMC version number */
/* */
/* Description: */
/* This function is used to get the DrvFMC version number */
/*---------------------------------------------------------------------------------------------------------*/
uint32_t DrvFMC_GetVersion(void)
{
return DRVFMC_VERSION_NUM;
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -