#include "rng.h"
#include "at32f403a_407.h"
#include "stdio.h"
#include <stdlib.h> 


#define DEVICE_ID_ADDR1 0x1FFFF7E8


//
void RNG_Init(void)
{
    uint32_t   id[3] = {0};
    uint32_t   uid_one_word;
  
    // get uid
    id[0] = *(int*)DEVICE_ID_ADDR1;
    id[2] = *(int*)(DEVICE_ID_ADDR1+8);
    uid_one_word = id[0]&0x7fffffff+((id[2]&(~0x7fffffff))<<16);
    
    srand(uid_one_word);
}


//
uint32_t GetRandomNumber(void) 
{
    return rand();
}
