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 
9 #pragma once
10 
36 #ifdef __cplusplus
37 extern "C" {
38 #endif
39 
40 #include <inttypes.h>
41 #include <stddef.h>
42 
43 #include "periph/adc.h"
44 
52 #if IS_ACTIVE(CONFIG_ENTROPY_SOURCE_ADC_RES_6BIT)
53 #define CONFIG_ENTROPY_SOURCE_ADC_RES ADC_RES_6BIT
54 #elif IS_ACTIVE(CONFIG_ENTROPY_SOURCE_ADC_RES_8BIT)
55 #define CONFIG_ENTROPY_SOURCE_ADC_RES ADC_RES_8BIT
56 #elif IS_ACTIVE(CONFIG_ENTROPY_SOURCE_ADC_RES_10BIT)
57 #define CONFIG_ENTROPY_SOURCE_ADC_RES ADC_RES_10BIT
58 #elif IS_ACTIVE(CONFIG_ENTROPY_SOURCE_ADC_RES_12BIT)
59 #define CONFIG_ENTROPY_SOURCE_ADC_RES ADC_RES_12BIT
60 #elif IS_ACTIVE(CONFIG_ENTROPY_SOURCE_ADC_RES_14BIT)
61 #define CONFIG_ENTROPY_SOURCE_ADC_RES ADC_RES_14BIT
62 #elif IS_ACTIVE(CONFIG_ENTROPY_SOURCE_ADC_RES_16BIT)
63 #define CONFIG_ENTROPY_SOURCE_ADC_RES ADC_RES_16BIT
64 #endif
65 #ifndef CONFIG_ENTROPY_SOURCE_ADC_RES
66 #define CONFIG_ENTROPY_SOURCE_ADC_RES ADC_RES_10BIT
67 #endif
68 
77 #ifdef CONFIG_ENTROPY_SOURCE_ADC_LINE_NUM
78 #define CONFIG_ENTROPY_SOURCE_ADC_LINE ADC_LINE(CONFIG_ENTROPY_SOURCE_ADC_LINE_NUM)
79 #else
80 #define CONFIG_ENTROPY_SOURCE_ADC_LINE ADC_LINE(0)
81 #endif
82 
96 #if !defined(CONFIG_KCONFIG_USEMODULE_ENTROPY_SOURCE_ADC_NOISE) || defined(DOXYGEN)
97 #ifndef CONFIG_ENTROPY_SOURCE_ADC_HMIN
98 #define CONFIG_ENTROPY_SOURCE_ADC_HMIN (0)
102 #endif /* !CONFIG_ENTROPY_SOURCE_ADC_HMIN */
103 
104 #ifndef CONFIG_ENTROPY_SOURCE_ADC_HEALTH_TEST
105 #define CONFIG_ENTROPY_SOURCE_ADC_HEALTH_TEST 0
108 #endif
109 #ifndef CONFIG_ENTROPY_SOURCE_ADC_COND
110 #define CONFIG_ENTROPY_SOURCE_ADC_COND 0
113 #endif
114 #endif /* !CONFIG_KCONFIG_USEMODULE_ENTROPY_SOURCE_ADC_NOISE || DOXYGEN */
115 
116 /* Throw warning if H_min has not been re-configured */
117 #if !CONFIG_ENTROPY_SOURCE_ADC_HMIN
118 #warning The min. provided entropy must be set before using this module
119 #endif
129 
139 int entropy_source_adc_get(uint8_t *buf, size_t len);
140 
147 static inline uint32_t entropy_source_adc_entropy_per_sample(void)
148 {
150 }
151 
152 #ifdef __cplusplus
153 }
154 #endif
155 
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:147
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:98
Adds include for missing inttype definitions.