/M480BSP/master/Library/StdDriver/inc/fmc.h
/**
* @brief Read company ID
* @param None
* @return The company ID (32-bit)
* @Details The company ID of Nuvoton is fixed to be 0xDA
*/
__STATIC_INLINE uint32_t FMC_ReadCID(void)
{
FMC->ISPCMD = FMC_ISPCMD_READ_CID; /* Set ISP Command Code */
FMC->ISPADDR = 0x0u; /* Must keep 0x0 when read CID */
FMC->ISPTRG = FMC_ISPTRG_ISPGO_Msk; /* Trigger to start ISP procedure */
#if ISBEN
__ISB();
#endif /* To make sure ISP/CPU be Synchronized */
while(FMC->ISPTRG & FMC_ISPTRG_ISPGO_Msk) {} /* Waiting for ISP Done */
return FMC->ISPDAT;
}
/**
* @brief Read product ID
* @param None
* @return The product ID (32-bit)
* @details This function is used to read product ID.
*/
__STATIC_INLINE uint32_t FMC_ReadPID(void)
{
FMC->ISPCMD = FMC_ISPCMD_READ_DID; /* Set ISP Command Code */
FMC->ISPADDR = 0x04u; /* Must keep 0x4 when read PID */
FMC->ISPTRG = FMC_ISPTRG_ISPGO_Msk; /* Trigger to start ISP procedure */
#if ISBEN
__ISB();
#endif /* To make sure ISP/CPU be Synchronized */
while(FMC->ISPTRG & FMC_ISPTRG_ISPGO_Msk) {} /* Waiting for ISP Done */
return FMC->ISPDAT;
}
/**
* @brief Read Unique ID
* @param[in] u8Index UID index. 0 = UID[31:0], 1 = UID[63:32], 2 = UID[95:64]
* @return The 32-bit unique ID data of specified UID index.
* @details To read out 96-bit Unique ID.
*/
__STATIC_INLINE uint32_t FMC_ReadUID(uint8_t u8Index)
{
FMC->ISPCMD = FMC_ISPCMD_READ_UID;
FMC->ISPADDR = ((uint32_t)u8Index << 2u);
FMC->ISPDAT = 0u;
FMC->ISPTRG = 0x1u;
#if ISBEN
__ISB();
#endif
while(FMC->ISPTRG) {}
return FMC->ISPDAT;
}
|