Merge pull request #8437 from NXPmicro/Fix_TRNG_HAL

MCUXpresso: Fix for the TRNG HAL driver
pull/8446/head
Cruz Monrreal 2018-10-16 16:19:49 -05:00 committed by GitHub
commit 00e3064f58
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 12 additions and 14 deletions

View File

@ -22,6 +22,8 @@
* Reference: "K66 Sub-Family Reference Manual, Rev. 2", chapter 38 * Reference: "K66 Sub-Family Reference Manual, Rev. 2", chapter 38
*/ */
#if defined(DEVICE_TRNG)
#include <stdlib.h> #include <stdlib.h>
#include "cmsis.h" #include "cmsis.h"
#include "fsl_common.h" #include "fsl_common.h"
@ -48,6 +50,7 @@ void trng_free(trng_t *obj)
*/ */
static void trng_get_byte(unsigned char *byte) static void trng_get_byte(unsigned char *byte)
{ {
*byte = 0;
size_t bit; size_t bit;
/* 34.5 Steps 3-4-5: poll SR and read from OR when ready */ /* 34.5 Steps 3-4-5: poll SR and read from OR when ready */
@ -62,7 +65,6 @@ int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_l
{ {
(void)obj; (void)obj;
size_t i; size_t i;
int ret;
/* Set "Interrupt Mask", "High Assurance" and "Go", /* Set "Interrupt Mask", "High Assurance" and "Go",
* unset "Clear interrupt" and "Sleep" */ * unset "Clear interrupt" and "Sleep" */
@ -81,3 +83,5 @@ int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_l
return 0; return 0;
} }
#endif

View File

@ -18,10 +18,6 @@
* *
*/ */
/*
* Reference: "K64 Sub-Family Reference Manual, Rev. 2", chapter 34
*/
#if defined(DEVICE_TRNG) #if defined(DEVICE_TRNG)
#include <stdlib.h> #include <stdlib.h>
@ -46,10 +42,11 @@ void trng_free(trng_t *obj)
/* /*
* Get one byte of entropy from the RNG, assuming it is up and running. * Get one byte of entropy from the RNG, assuming it is up and running.
* As recommended (34.1.1), get only one bit of each output. * As recommended, get only one bit of each output.
*/ */
static void trng_get_byte(unsigned char *byte) static void trng_get_byte(unsigned char *byte)
{ {
*byte = 0;
size_t bit; size_t bit;
/* 34.5 Steps 3-4-5: poll SR and read from OR when ready */ /* 34.5 Steps 3-4-5: poll SR and read from OR when ready */
@ -64,7 +61,6 @@ int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_l
{ {
(void)obj; (void)obj;
size_t i; size_t i;
int ret;
/* Set "Interrupt Mask", "High Assurance" and "Go", /* Set "Interrupt Mask", "High Assurance" and "Go",
* unset "Clear interrupt" and "Sleep" */ * unset "Clear interrupt" and "Sleep" */

View File

@ -46,6 +46,7 @@ void trng_free(trng_t *obj)
*/ */
static void trng_get_byte(unsigned char *byte) static void trng_get_byte(unsigned char *byte)
{ {
*byte = 0;
size_t bit; size_t bit;
/* 34.5 Steps 3-4-5: poll SR and read from OR when ready */ /* 34.5 Steps 3-4-5: poll SR and read from OR when ready */

View File

@ -18,10 +18,6 @@
* *
*/ */
/*
* Reference: "K64 Sub-Family Reference Manual, Rev. 2", chapter 34
*/
#if defined(DEVICE_TRNG) #if defined(DEVICE_TRNG)
#include <stdlib.h> #include <stdlib.h>
@ -46,10 +42,11 @@ void trng_free(trng_t *obj)
/* /*
* Get one byte of entropy from the RNG, assuming it is up and running. * Get one byte of entropy from the RNG, assuming it is up and running.
* As recommended (34.1.1), get only one bit of each output. * As recommended, get only one bit of each output.
*/ */
static void trng_get_byte(unsigned char *byte) static void trng_get_byte(unsigned char *byte)
{ {
*byte = 0;
size_t bit; size_t bit;
/* 34.5 Steps 3-4-5: poll SR and read from OR when ready */ /* 34.5 Steps 3-4-5: poll SR and read from OR when ready */