Skip to content

Commit e2fef54

Browse files
authored
Merge pull request #11188 from NXPmicro/MXRT_TRNG
MIMXRT1050_EVK: Add TRNG support
2 parents 5904614 + 43b4c0a commit e2fef54

File tree

2 files changed

+51
-1
lines changed

2 files changed

+51
-1
lines changed
Lines changed: 49 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,49 @@
1+
/*
2+
*
3+
* Copyright (C) 2006-2015, ARM Limited, All Rights Reserved
4+
* SPDX-License-Identifier: Apache-2.0
5+
*
6+
* Licensed under the Apache License, Version 2.0 (the "License"); you may
7+
* not use this file except in compliance with the License.
8+
* You may obtain a copy of the License at
9+
*
10+
* http://www.apache.org/licenses/LICENSE-2.0
11+
*
12+
* Unless required by applicable law or agreed to in writing, software
13+
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
14+
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
15+
* See the License for the specific language governing permissions and
16+
* limitations under the License.
17+
*
18+
*/
19+
20+
#include <stdlib.h>
21+
#include "cmsis.h"
22+
#include "fsl_trng.h"
23+
#include "trng_api.h"
24+
25+
void trng_init(trng_t *obj)
26+
{
27+
(void)obj;
28+
trng_config_t trngConfig;
29+
TRNG_GetDefaultConfig(&trngConfig);
30+
TRNG_Init(TRNG, &trngConfig);
31+
}
32+
33+
void trng_free(trng_t *obj)
34+
{
35+
(void)obj;
36+
TRNG_Deinit(TRNG);
37+
}
38+
39+
int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_length)
40+
{
41+
(void)obj;
42+
43+
if(TRNG_GetRandomData(TRNG, output, length) != kStatus_Success) {
44+
return -1;
45+
}
46+
*output_length = length;
47+
48+
return 0;
49+
}

targets/targets.json

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1955,7 +1955,8 @@
19551955
"SERIAL",
19561956
"SPI",
19571957
"SPISLAVE",
1958-
"STDIO_MESSAGES"
1958+
"STDIO_MESSAGES",
1959+
"TRNG"
19591960
],
19601961
"release_versions": ["2", "5"],
19611962
"features": ["LWIP"],

0 commit comments

Comments
 (0)