1 |
|
---|
2 | /** \addtogroup hal */
|
---|
3 | /** @{*/
|
---|
4 | /* mbed Microcontroller Library
|
---|
5 | * Copyright (c) 2016 ARM Limited
|
---|
6 | *
|
---|
7 | * Licensed under the Apache License, Version 2.0 (the "License");
|
---|
8 | * you may not use this file except in compliance with the License.
|
---|
9 | * You may obtain a copy of the License at
|
---|
10 | *
|
---|
11 | * http://www.apache.org/licenses/LICENSE-2.0
|
---|
12 | *
|
---|
13 | * Unless required by applicable law or agreed to in writing, software
|
---|
14 | * distributed under the License is distributed on an "AS IS" BASIS,
|
---|
15 | * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
---|
16 | * See the License for the specific language governing permissions and
|
---|
17 | * limitations under the License.
|
---|
18 | */
|
---|
19 | #ifndef MBED_TRNG_API_H
|
---|
20 | #define MBED_TRNG_API_H
|
---|
21 |
|
---|
22 | #include <stddef.h>
|
---|
23 | #include "device.h"
|
---|
24 |
|
---|
25 | #if DEVICE_TRNG
|
---|
26 |
|
---|
27 | /** TRNG HAL structure. trng_s is declared in the target's HAL
|
---|
28 | */
|
---|
29 | typedef struct trng_s trng_t;
|
---|
30 |
|
---|
31 | #ifdef __cplusplus
|
---|
32 | extern "C" {
|
---|
33 | #endif
|
---|
34 |
|
---|
35 | /**
|
---|
36 | * \defgroup hal_trng TRNG hal functions
|
---|
37 | * @{
|
---|
38 | */
|
---|
39 |
|
---|
40 | /** Initialize the TRNG peripheral
|
---|
41 | *
|
---|
42 | * @param obj The TRNG object
|
---|
43 | */
|
---|
44 | void trng_init(trng_t *obj);
|
---|
45 |
|
---|
46 | /** Deinitialize the TRNG peripheral
|
---|
47 | *
|
---|
48 | * @param obj The TRNG object
|
---|
49 | */
|
---|
50 | void trng_free(trng_t *obj);
|
---|
51 |
|
---|
52 | /** Get random data from TRNG peripheral
|
---|
53 | *
|
---|
54 | * @param obj The TRNG object
|
---|
55 | * @param output The pointer to an output array
|
---|
56 | * @param length The size of output data, to avoid buffer overwrite
|
---|
57 | * @param output_length The length of generated data
|
---|
58 | * @return 0 success, -1 fail
|
---|
59 | */
|
---|
60 | int trng_get_bytes(trng_t *obj, uint8_t *output, size_t length, size_t *output_length);
|
---|
61 |
|
---|
62 | /**@}*/
|
---|
63 |
|
---|
64 | #ifdef __cplusplus
|
---|
65 | }
|
---|
66 | #endif
|
---|
67 |
|
---|
68 | #endif
|
---|
69 |
|
---|
70 | #endif
|
---|
71 |
|
---|
72 | /** @}*/
|
---|