adc_noise.h
Go to the documentation of this file.
1 /*
2  * SPDX-FileCopyrightText: 2020 HAW Hamburg
3  * SPDX-License-Identifier: LGPL-2.1-only
4  */
5 
6 #pragma once
7 
33 #ifdef __cplusplus
34 extern "C" {
35 #endif
36 
37 #include <inttypes.h>
38 #include <stddef.h>
39 
40 #include "periph/adc.h"
41 
49 #if IS_ACTIVE(CONFIG_ENTROPY_SOURCE_ADC_RES_6BIT)
50 #define CONFIG_ENTROPY_SOURCE_ADC_RES ADC_RES_6BIT
51 #elif IS_ACTIVE(CONFIG_ENTROPY_SOURCE_ADC_RES_8BIT)
52 #define CONFIG_ENTROPY_SOURCE_ADC_RES ADC_RES_8BIT
53 #elif IS_ACTIVE(CONFIG_ENTROPY_SOURCE_ADC_RES_10BIT)
54 #define CONFIG_ENTROPY_SOURCE_ADC_RES ADC_RES_10BIT
55 #elif IS_ACTIVE(CONFIG_ENTROPY_SOURCE_ADC_RES_12BIT)
56 #define CONFIG_ENTROPY_SOURCE_ADC_RES ADC_RES_12BIT
57 #elif IS_ACTIVE(CONFIG_ENTROPY_SOURCE_ADC_RES_14BIT)
58 #define CONFIG_ENTROPY_SOURCE_ADC_RES ADC_RES_14BIT
59 #elif IS_ACTIVE(CONFIG_ENTROPY_SOURCE_ADC_RES_16BIT)
60 #define CONFIG_ENTROPY_SOURCE_ADC_RES ADC_RES_16BIT
61 #endif
62 #ifndef CONFIG_ENTROPY_SOURCE_ADC_RES
63 #define CONFIG_ENTROPY_SOURCE_ADC_RES ADC_RES_10BIT
64 #endif
65 
74 #ifdef CONFIG_ENTROPY_SOURCE_ADC_LINE_NUM
75 #define CONFIG_ENTROPY_SOURCE_ADC_LINE ADC_LINE(CONFIG_ENTROPY_SOURCE_ADC_LINE_NUM)
76 #else
77 #define CONFIG_ENTROPY_SOURCE_ADC_LINE ADC_LINE(0)
78 #endif
79 
93 #if !defined(CONFIG_KCONFIG_USEMODULE_ENTROPY_SOURCE_ADC_NOISE) || defined(DOXYGEN)
94 #ifndef CONFIG_ENTROPY_SOURCE_ADC_HMIN
95 #define CONFIG_ENTROPY_SOURCE_ADC_HMIN (0)
99 #endif /* !CONFIG_ENTROPY_SOURCE_ADC_HMIN */
100 
101 #ifndef CONFIG_ENTROPY_SOURCE_ADC_HEALTH_TEST
102 #define CONFIG_ENTROPY_SOURCE_ADC_HEALTH_TEST 0
105 #endif
106 #ifndef CONFIG_ENTROPY_SOURCE_ADC_COND
107 #define CONFIG_ENTROPY_SOURCE_ADC_COND 0
110 #endif
111 #endif /* !CONFIG_KCONFIG_USEMODULE_ENTROPY_SOURCE_ADC_NOISE || DOXYGEN */
112 
113 /* Throw warning if H_min has not been re-configured */
114 #if !CONFIG_ENTROPY_SOURCE_ADC_HMIN
115 #warning The min. provided entropy must be set before using this module
116 #endif
126 
136 int entropy_source_adc_get(uint8_t *buf, size_t len);
137 
144 static inline uint32_t entropy_source_adc_entropy_per_sample(void)
145 {
147 }
148 
149 #ifdef __cplusplus
150 }
151 #endif
152 
Low-level ADC peripheral driver interface definitions.
static uint32_t entropy_source_adc_entropy_per_sample(void)
Static entropy per sample value for this source [bit/sample * 2^16].
Definition: adc_noise.h:144
int entropy_source_adc_init(void)
Initialize ADC and test structures, if tests are enabled.
int entropy_source_adc_get(uint8_t *buf, size_t len)
Generates bytes from ADC noise.
#define CONFIG_ENTROPY_SOURCE_ADC_HMIN
ADC estimated entropy per sample [2^16 * bit/sample].
Definition: adc_noise.h:95
Adds include for missing inttype definitions.