Skip to content

Commit 5853af7

Browse files
committed
MCUXpresso: Update LPC TRNG driver
Signed-off-by: Mahesh Mahadevan <[email protected]>
1 parent dd21e6d commit 5853af7

File tree

2 files changed

+47
-0
lines changed

2 files changed

+47
-0
lines changed
Lines changed: 47 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,47 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2018 ARM Limited
3+
*
4+
* Licensed under the Apache License, Version 2.0 (the "License");
5+
* you may not use this file except in compliance with the License.
6+
* You may obtain a copy of the License at
7+
*
8+
* http://www.apache.org/licenses/LICENSE-2.0
9+
*
10+
* Unless required by applicable law or agreed to in writing, software
11+
* distributed under the License is distributed on an "AS IS" BASIS,
12+
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
13+
* See the License for the specific language governing permissions and
14+
* limitations under the License.
15+
*/
16+
17+
#include "trng_api.h"
18+
19+
#if defined(DEVICE_TRNG)
20+
#include "fsl_rng.h"
21+
22+
void trng_init(trng_t *obj)
23+
{
24+
/* Init RNGA */
25+
RNG_Init(RNG);
26+
}
27+
28+
void trng_free(trng_t *obj)
29+
{
30+
RNG_Deinit(RNG);
31+
}
32+
33+
int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_length)
34+
{
35+
status_t status;
36+
37+
/* Get Random data*/
38+
status = RNG_GetRandomData(RNG, output, length);
39+
if (status == kStatus_Success) {
40+
*output_length = length;
41+
return 0;
42+
} else {
43+
return -1;
44+
}
45+
}
46+
47+
#endif

0 commit comments

Comments
 (0)