CDC Badge OS
Firmware for the CDC Badge v1.0 hardware security key
Loading...
Searching...
No Matches
PluginGpioPolicy.h
Go to the documentation of this file.
1
11
12
#pragma once
13
14
#include <cstddef>
15
#include <cstdint>
16
17
namespace
cdc::plugin_manager::gpio_policy
{
18
19
inline
constexpr
uint8_t
BLOCKED
[] = {
20
0,
// FLASH_BTN (boot strapping + power button)
21
1,
// EXP_IRQ (IO expander interrupt)
22
8,
// EPD_LED (e-paper backlight)
23
10,
// TR01_CS (TROPIC01 chip select)
24
11,
// SPI_MISO (shared SPI bus)
25
12,
// SPI_SCLK
26
13,
// SPI_MOSI
27
17,
// I2C0_SDA (charger + IO expander bus)
28
18,
// I2C0_SCL
29
19,
// USB D-
30
20,
// USB D+
31
21,
// CHG_DSEL (charger detection select)
32
26, 27, 28, 29, 30, 31, 32,
// PSRAM/flash (not exposed via GPIO peripheral)
33
33, 34, 35, 36, 37,
// Octal PSRAM data lines SPIIO4-7 + DQS (CONFIG_SPIRAM_MODE_OCT)
34
39,
// CHG_IRQ
35
41,
// EPD_CS
36
42,
// EPD_BUSY
37
45,
// EPD_DC
38
46,
// EPD_RST
39
47,
// I2C1_SDA (expansion bus - reachable via host_i2c_*, not as raw GPIO)
40
48,
// I2C1_SCL
41
};
42
43
inline
constexpr
uint8_t
ALLOWED
[] = {
44
2,
// Grove SIG0 (also RPi header)
45
3,
// Grove SIG1 (also RPi header; ESP32-S3 strapping pin - boot mode)
46
4,
// Header (ADC1_CH3)
47
5,
// Header (ADC1_CH4)
48
6,
// Header (ADC1_CH5)
49
7,
// Header (ADC1_CH6)
50
9,
// Header
51
14,
// Header (ADC2)
52
15,
// SAO GPIO1
53
16,
// SAO GPIO2
54
38,
// Header
55
40,
// Header (JTAG TDO - safe unless USB-JTAG-Serial debugger is active)
56
43,
// Header (UART0 TX - safe once serial console moves to CDC-only)
57
44,
// Header (UART0 RX)
58
};
59
60
inline
constexpr
size_t
BLOCKED_COUNT
=
sizeof
(
BLOCKED
) /
sizeof
(
BLOCKED
[0]);
61
inline
constexpr
size_t
ALLOWED_COUNT
=
sizeof
(
ALLOWED
) /
sizeof
(
ALLOWED
[0]);
62
63
inline
bool
isBlocked
(uint8_t pin)
64
{
65
for
(
size_t
i = 0; i <
BLOCKED_COUNT
; ++i) {
66
if
(
BLOCKED
[i] == pin)
return
true
;
67
}
68
return
false
;
69
}
70
71
inline
bool
isAllowed
(uint8_t pin)
72
{
73
if
(
isBlocked
(pin))
return
false
;
74
for
(
size_t
i = 0; i <
ALLOWED_COUNT
; ++i) {
75
if
(
ALLOWED
[i] == pin)
return
true
;
76
}
77
return
false
;
78
}
79
80
}
// namespace cdc::plugin_manager::gpio_policy
cdc::plugin_manager::gpio_policy
Definition
PluginGpioPolicy.h:17
cdc::plugin_manager::gpio_policy::isAllowed
bool isAllowed(uint8_t pin)
Definition
PluginGpioPolicy.h:71
cdc::plugin_manager::gpio_policy::isBlocked
bool isBlocked(uint8_t pin)
Definition
PluginGpioPolicy.h:63
cdc::plugin_manager::gpio_policy::ALLOWED_COUNT
constexpr size_t ALLOWED_COUNT
Definition
PluginGpioPolicy.h:61
cdc::plugin_manager::gpio_policy::ALLOWED
constexpr uint8_t ALLOWED[]
Definition
PluginGpioPolicy.h:43
cdc::plugin_manager::gpio_policy::BLOCKED
constexpr uint8_t BLOCKED[]
Definition
PluginGpioPolicy.h:19
cdc::plugin_manager::gpio_policy::BLOCKED_COUNT
constexpr size_t BLOCKED_COUNT
Definition
PluginGpioPolicy.h:60
components
plugin_manager
include
plugin_manager
PluginGpioPolicy.h
Generated by
1.16.1