20
20
21
21
22
22
#include <stdlib.h>
23
+ #include <string.h>
23
24
#include "cmsis.h"
24
25
#include "NUC472_442.h"
25
-
26
+ #include "us_ticker_api.h"
26
27
27
28
/*
28
29
* Get Random number generator.
@@ -37,10 +38,12 @@ void CRYPTO_IRQHandler()
37
38
}
38
39
}
39
40
40
- static void rng_get ( int32_t * p32ConversionData )
41
+ static void rng_get (unsigned char * pConversionData )
41
42
{
42
- int32_t i32ConversionData ;
43
- uint32_t au32PrngData [8 ];
43
+ uint32_t * p32ConversionData ;
44
+
45
+ p32ConversionData = (uint32_t * )pConversionData ;
46
+
44
47
/* Unlock protected registers */
45
48
SYS_UnlockReg ();
46
49
/* Enable IP clock */
@@ -53,19 +56,19 @@ static void rng_get( int32_t *p32ConversionData)
53
56
PRNG_ENABLE_INT ();
54
57
55
58
// PRNG_Open(PRNG_KEY_SIZE_64, 0, 0);
56
- PRNG_Open (PRNG_KEY_SIZE_256 , 1 , us_ticker_read ());
59
+ PRNG_Open (PRNG_KEY_SIZE_256 , 1 , us_ticker_read ());
57
60
PRNG_Start ();
58
61
while (!g_PRNG_done );
59
62
60
63
61
64
PRNG_Read (p32ConversionData );
62
65
63
- // printf(" 0x%08x 0x%08x 0x%08x 0x%08x\n\r", *p32ConversionData, *(p32ConversionData+1), *(p32ConversionData+2), *(p32ConversionData+3));
66
+ // printf(" 0x%08x 0x%08x 0x%08x 0x%08x\n\r", *p32ConversionData, *(p32ConversionData+1), *(p32ConversionData+2), *(p32ConversionData+3));
64
67
// printf(" 0x%08x 0x%08x 0x%08x 0x%08x\n\r", *(p32ConversionData+4), *(p32ConversionData+5), *(p32ConversionData+6), *(p32ConversionData+7));
65
68
66
69
PRNG_DISABLE_INT ();
67
70
NVIC_DisableIRQ (CRPT_IRQn );
68
- CLK_DisableModuleClock (CRPT_MODULE );
71
+ // CLK_DisableModuleClock(CRPT_MODULE);
69
72
70
73
}
71
74
0 commit comments