Go to the documentation of this file.
32 #define TRACE_LEVEL CRYPTO_TRACE_LEVEL
42 #if (PIC32CZ_CRYPTO_TRNG_SUPPORT == ENABLED)
52 #if defined(__PIC32CZ2051CA70064__) || defined(__PIC32CZ2051CA70100__) || \
53 defined(__PIC32CZ2051CA70144__)
55 PMC_REGS->PMC_PCER1 = (1U << (ID_TRNG - 32));
57 TRNG_REGS->TRNG_CR = TRNG_CR_KEY_PASSWD | TRNG_CR_ENABLE_Msk;
60 MCLK_REGS->MCLK_CLKMSK[TRNG_MCLK_ID_APB / 32] |= (1U << (TRNG_MCLK_ID_APB % 32));
62 TRNG_REGS->TRNG_CTRLA |= TRNG_CTRLA_ENABLE_Msk;
88 for(i = 0; i <
length; i++)
93 #if defined(__PIC32CZ2051CA70064__) || defined(__PIC32CZ2051CA70100__) || \
94 defined(__PIC32CZ2051CA70144__)
96 while((TRNG_REGS->TRNG_ISR & TRNG_ISR_DATRDY_Msk) == 0)
101 value = TRNG_REGS->TRNG_ODATA;
104 while((TRNG_REGS->TRNG_INTFLAG & TRNG_INTFLAG_DATARDY_Msk) == 0)
109 value = TRNG_REGS->TRNG_DATA;
OsMutex pic32czCryptoMutex
error_t trngGetRandomData(uint8_t *data, size_t length)
Get random data from the TRNG module.
General definitions for cryptographic algorithms.
error_t trngInit(void)
TRNG module initialization.
PIC32CZ hardware cryptographic accelerator.
void osAcquireMutex(OsMutex *mutex)
Acquire ownership of the specified mutex object.
void osReleaseMutex(OsMutex *mutex)
Release ownership of the specified mutex object.
PIC32CZ true random number generator.