Skip to content

Commit 6da5515

Browse files
committed
HAL: add RGN API
Provides init, free and get numbers functions.
1 parent 4820c87 commit 6da5515

File tree

1 file changed

+67
-0
lines changed

1 file changed

+67
-0
lines changed

hal/hal/rng_api.h

Lines changed: 67 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,67 @@
1+
/* mbed Microcontroller Library
2+
* Copyright (c) 2016 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+
#ifndef MBED_RNG_API_H
17+
#define MBED_RNG_API_H
18+
19+
#include <stddef.h>
20+
#include "device.h"
21+
22+
#if DEVICE_RNG
23+
24+
/** RNG HAL structure. rng_s is declared in the target's HAL
25+
*/
26+
typedef struct rng_s rng_t;
27+
28+
#ifdef __cplusplus
29+
extern "C" {
30+
#endif
31+
32+
/**
33+
* \defgroup hal_rng RNG hal functions
34+
* @{
35+
*/
36+
37+
/** Initialize the RNG peripheral
38+
*
39+
* @param obj The RNG object
40+
*/
41+
void rng_init(rng_t *obj);
42+
43+
/** Deinitialize the RNG peripheral
44+
*
45+
* @param obj The RNG object
46+
*/
47+
void rng_free(rng_t *obj);
48+
49+
/** Get random data from RNG peripheral
50+
*
51+
* @param obj The RNG object
52+
* @param output The pointer to an output array
53+
* @param length The length of output data
54+
* @param output_length The length of generated data
55+
* @return 0 success, -1 fail
56+
*/
57+
int rng_get_numbers(rng_t *obj, uint8_t *output, size_t length, size_t *output_length);
58+
59+
/**@}*/
60+
61+
#ifdef __cplusplus
62+
}
63+
#endif
64+
65+
#endif
66+
67+
#endif

0 commit comments

Comments
 (0)