ChibiOS 21.11.4
hal_trng.h
Go to the documentation of this file.
1/*
2 ChibiOS - Copyright (C) 2006..2018 Giovanni Di Sirio
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/**
18 * @file hal_trng.h
19 * @brief TRNG Driver macros and structures.
20 *
21 * @addtogroup TRNG
22 * @{
23 */
24
25#ifndef HAL_TRNG_H
26#define HAL_TRNG_H
27
28#if (HAL_USE_TRNG == TRUE) || defined(__DOXYGEN__)
29
30/*===========================================================================*/
31/* Driver constants. */
32/*===========================================================================*/
33
34/*===========================================================================*/
35/* Driver pre-compile time settings. */
36/*===========================================================================*/
37
38/*===========================================================================*/
39/* Derived constants and error checks. */
40/*===========================================================================*/
41
42/*===========================================================================*/
43/* Driver data structures and types. */
44/*===========================================================================*/
45
46/**
47 * @brief Driver state machine possible states.
48 */
49typedef enum {
50 TRNG_UNINIT = 0, /**< Not initialized. */
51 TRNG_STOP = 1, /**< Stopped. */
52 TRNG_READY = 2, /**< Ready. */
53 TRNG_RUNNING = 3 /**< Generating random number. */
55
56/**
57 * @brief Type of a structure representing a TRNG driver.
58 */
60
61/**
62 * @brief Driver configuration structure.
63 * @note It could be empty on some architectures.
64 */
66
67/* Including the low level driver header, it exports information required
68 for completing types.*/
69#include "hal_trng_lld.h"
70
71/**
72 * @brief Driver configuration structure.
73 */
75 /* End of the mandatory fields.*/
77};
78
79/**
80 * @brief Structure representing a TRNG driver.
81 */
83 /**
84 * @brief Driver state.
85 */
87 /**
88 * @brief Current configuration data.
89 */
91#if defined(TRNG_DRIVER_EXT_FIELDS)
92 TRNG_DRIVER_EXT_FIELDS
93#endif
94 /* End of the mandatory fields.*/
96};
97
98/*===========================================================================*/
99/* Driver macros. */
100/*===========================================================================*/
101
102/*===========================================================================*/
103/* External declarations. */
104/*===========================================================================*/
105
106#ifdef __cplusplus
107extern "C" {
108#endif
109 void trngInit(void);
110 void trngObjectInit(TRNGDriver *trngp);
111 msg_t trngStart(TRNGDriver *trngp, const TRNGConfig *config);
112 void trngStop(TRNGDriver *trngp);
113 bool trngGenerate(TRNGDriver *trngp, size_t size, uint8_t *out);
114#ifdef __cplusplus
115}
116#endif
117
118#endif /* HAL_USE_TRNG == TRUE */
119
120#endif /* HAL_TRNG_H */
121
122/** @} */
#define trng_lld_config_fields
Low level fields of the TRNG configuration structure.
void trngInit(void)
TRNG Driver initialization.
Definition hal_trng.c:56
msg_t trngStart(TRNGDriver *trngp, const TRNGConfig *config)
Configures and activates the TRNG peripheral.
Definition hal_trng.c:84
void trngStop(TRNGDriver *trngp)
Deactivates the TRNG peripheral.
Definition hal_trng.c:121
void trngObjectInit(TRNGDriver *trngp)
Initializes the standard part of a TRNGDriver structure.
Definition hal_trng.c:68
struct hal_trng_driver TRNGDriver
Type of a structure representing a TRNG driver.
Definition hal_trng.h:59
bool trngGenerate(TRNGDriver *trngp, size_t size, uint8_t *out)
True random numbers generator.
Definition hal_trng.c:151
struct hal_trng_config TRNGConfig
Driver configuration structure.
Definition hal_trng.h:65
#define trng_lld_driver_fields
Low level fields of the TRNG driver structure.
trngstate_t
Driver state machine possible states.
Definition hal_trng.h:49
@ TRNG_READY
Definition hal_trng.h:52
@ TRNG_UNINIT
Definition hal_trng.h:50
@ TRNG_STOP
Definition hal_trng.h:51
@ TRNG_RUNNING
Definition hal_trng.h:53
int32_t msg_t
Definition chearly.h:88
PLATFORM TRNG subsystem low level driver header.
USBOutEndpointState out
OUT EP0 state.
Definition hal_usb_lld.c:61
Driver configuration structure.
Definition hal_trng.h:74
Structure representing a TRNG driver.
Definition hal_trng.h:82
trngstate_t state
Driver state.
Definition hal_trng.h:86
const TRNGConfig * config
Current configuration data.
Definition hal_trng.h:90