/******************************************************************************
 * @file     system.c
 * @brief    SYSTEM firmware functions.
 * @version  V4.0.0
 * @date     30-July-2026
 *
 * @note
 * Copyright (C) 2022 Spintrol Electronic Technology (Shanghai) Co., Ltd.. All rights reserved.
 *
 * @attention
 * THIS SOFTWARE JUST PROVIDES CUSTOMERS WITH CODING INFORMATION REGARDING
 * THEIR PRODUCTS, WHICH AIMS AT SAVING TIME FOR THEM. SPINTROL SHALL NOT BE
 * LIABLE FOR THE USE OF THE SOFTWARE. SPINTROL DOES NOT GUARANTEE THE
 * CORRECTNESS OF THIS SOFTWARE AND RESERVES THE RIGHT TO MODIFY THE SOFTWARE
 * WITHOUT NOTIFICATION.
 *
 ******************************************************************************/

#include "system.h"


#if defined(__CC_ARM)
    #pragma push
    #pragma O1
#endif




/******************************************************************************
 * @brief      Get Chip Unique ID
 *
 * @param[in]  none
 *
 * @return     none
 *
 ******************************************************************************/
#if defined(__ICCARM__)
#pragma optimize=low
#endif
uint64_t SYSTEM_GetUID(void)
{
    uint64_t u64ID;

    u64ID = SYSTEM->UID1.all;
    u64ID <<= 32;
    u64ID |= SYSTEM->UID0.all;

    return u64ID;
}




/******************************************************************************
 * @brief      Get Chip Random number
 *
 * @param[in]  none
 *
 * @return     none
 *
 ******************************************************************************/
#if defined(__ICCARM__)
#pragma optimize=low
#endif
uint64_t SYSTEM_GetRandomNum(void)
{
    uint64_t u64RandNum;

    u64RandNum = SYSTEM->RND1.all;
    u64RandNum <<= 32;
    u64RandNum |= SYSTEM->RND0.all;

    return u64RandNum;
}


#if defined(__CC_ARM)
    #pragma pop
#endif


/******************* Copyright (C) 2022 Spintrol Electronic Technology (Shanghai) Co., Ltd. ***** END OF FILE ****/
