Skip to content

Commit

Permalink
Merge pull request #21177 from dylad/pr/cpu/sam3/fix_hwrng_reg_access
Browse files Browse the repository at this point in the history
cpu/sam3: fix hwrng peripheral register access
  • Loading branch information
aabadie authored Jan 31, 2025
2 parents 529a1e4 + 6d641ff commit 500a0f3
Showing 1 changed file with 4 additions and 4 deletions.
8 changes: 4 additions & 4 deletions cpu/sam3/periph/hwrng.c
Original file line number Diff line number Diff line change
Expand Up @@ -39,9 +39,9 @@ void hwrng_read(void *buf, unsigned int num)
uint8_t *b = (uint8_t *)buf;

/* enable clock signal for TRNG module */
PMC->PMC_PCER1 |= PMC_PCER1_PID41;
PMC->PMC_PCER1 = PMC_PCER1_PID41;
/* enable the generation of random numbers */
TRNG->TRNG_CR |= (KEY | TRNG_CR_ENABLE);
TRNG->TRNG_CR = (KEY | TRNG_CR_ENABLE);

while (count < num) {
/* wait until new value is generated -> takes up to 84 cycles */
Expand All @@ -56,7 +56,7 @@ void hwrng_read(void *buf, unsigned int num)
}

/* disable the generation of random numbers */
TRNG->TRNG_CR &= ~(KEY | TRNG_CR_ENABLE);
TRNG->TRNG_CR = KEY;
/* disable clock signal for TRNG module */
PMC->PMC_PCER1 &= ~(PMC_PCER1_PID41);
PMC->PMC_PCDR1 = PMC_PCER1_PID41;
}

0 comments on commit 500a0f3

Please sign in to comment.