adc_noise.h
Go to the documentation of this file.
1 /*
2  * Copyright (C) 2020 HAW Hamburg
3  *
4  * This file is subject to the terms and conditions of the GNU Lesser
5  * General Public License v2.1. See the file LICENSE in the top level
6  * directory for more details.
7  */
8 
34 #ifndef ENTROPY_SOURCE_ADC_NOISE_H
35 #define ENTROPY_SOURCE_ADC_NOISE_H
36 
37 #ifdef __cplusplus
38 extern "C" {
39 #endif
40 
41 #include <inttypes.h>
42 #include <stddef.h>
43 
44 #include "periph/adc.h"
45 
53 #if IS_ACTIVE(CONFIG_ENTROPY_SOURCE_ADC_RES_6BIT)
54 #define CONFIG_ENTROPY_SOURCE_ADC_RES ADC_RES_6BIT
55 #elif IS_ACTIVE(CONFIG_ENTROPY_SOURCE_ADC_RES_8BIT)
56 #define CONFIG_ENTROPY_SOURCE_ADC_RES ADC_RES_8BIT
57 #elif IS_ACTIVE(CONFIG_ENTROPY_SOURCE_ADC_RES_10BIT)
58 #define CONFIG_ENTROPY_SOURCE_ADC_RES ADC_RES_10BIT
59 #elif IS_ACTIVE(CONFIG_ENTROPY_SOURCE_ADC_RES_12BIT)
60 #define CONFIG_ENTROPY_SOURCE_ADC_RES ADC_RES_12BIT
61 #elif IS_ACTIVE(CONFIG_ENTROPY_SOURCE_ADC_RES_14BIT)
62 #define CONFIG_ENTROPY_SOURCE_ADC_RES ADC_RES_14BIT
63 #elif IS_ACTIVE(CONFIG_ENTROPY_SOURCE_ADC_RES_16BIT)
64 #define CONFIG_ENTROPY_SOURCE_ADC_RES ADC_RES_16BIT
65 #endif
66 #ifndef CONFIG_ENTROPY_SOURCE_ADC_RES
67 #define CONFIG_ENTROPY_SOURCE_ADC_RES ADC_RES_10BIT
68 #endif
69 
78 #ifdef CONFIG_ENTROPY_SOURCE_ADC_LINE_NUM
79 #define CONFIG_ENTROPY_SOURCE_ADC_LINE ADC_LINE(CONFIG_ENTROPY_SOURCE_ADC_LINE_NUM)
80 #else
81 #define CONFIG_ENTROPY_SOURCE_ADC_LINE ADC_LINE(0)
82 #endif
83 
97 #if !defined(CONFIG_KCONFIG_USEMODULE_ENTROPY_SOURCE_ADC_NOISE) || defined(DOXYGEN)
98 #ifndef CONFIG_ENTROPY_SOURCE_ADC_HMIN
99 #define CONFIG_ENTROPY_SOURCE_ADC_HMIN (0)
103 #endif /* !CONFIG_ENTROPY_SOURCE_ADC_HMIN */
104 
105 #ifndef CONFIG_ENTROPY_SOURCE_ADC_HEALTH_TEST
106 #define CONFIG_ENTROPY_SOURCE_ADC_HEALTH_TEST 0
109 #endif
110 #ifndef CONFIG_ENTROPY_SOURCE_ADC_COND
111 #define CONFIG_ENTROPY_SOURCE_ADC_COND 0
114 #endif
115 #endif /* !CONFIG_KCONFIG_USEMODULE_ENTROPY_SOURCE_ADC_NOISE || DOXYGEN */
116 
117 /* Throw warning if H_min has not been re-configured */
118 #if !CONFIG_ENTROPY_SOURCE_ADC_HMIN
119 #warning The min. provided entropy must be set before using this module
120 #endif
130 
140 int entropy_source_adc_get(uint8_t *buf, size_t len);
141 
148 static inline uint32_t entropy_source_adc_entropy_per_sample(void)
149 {
151 }
152 
153 #ifdef __cplusplus
154 }
155 #endif
156 
157 #endif /* ENTROPY_SOURCE_ADC_NOISE_H */
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:148
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:99
Adds include for missing inttype definitions.