| 12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455 |
- #pragma once
- #ifndef BOARD_GPIO_PROFILE_H
- #define BOARD_GPIO_PROFILE_H
- #include <stddef.h>
- #include <stdint.h>
- #include "driver/gpio.h"
- /*
- * Capabilities are deliberately explicit. A GPIO is usable only when the
- * selected board profile lists it and grants the requested capabilities.
- */
- enum GpioPinCapability : uint8_t
- {
- GPIO_PIN_CAP_INPUT = 1U << 0,
- GPIO_PIN_CAP_OUTPUT = 1U << 1,
- GPIO_PIN_CAP_PULL_UP = 1U << 2,
- GPIO_PIN_CAP_PULL_DOWN = 1U << 3,
- GPIO_PIN_CAP_INTERRUPT = 1U << 4,
- GPIO_PIN_CAP_PWM = 1U << 5
- };
- struct GpioBoardPin
- {
- gpio_num_t gpio;
- uint8_t capabilities;
- const char *description;
- };
- struct GpioBoardProfile
- {
- const char *name;
- const GpioBoardPin *userPins;
- size_t userPinCount;
- const gpio_num_t *reservedPins;
- size_t reservedPinCount;
- gpio_num_t builtInFlashLedPin;
- uint8_t maxUserChannels;
- };
- static const uint8_t GPIO_MAX_USER_CHANNELS = 4U;
- /* Returns the profile selected at compile time for the complete board. */
- const GpioBoardProfile *gpioGetBoardProfile(void);
- /* Profile integrity and pin lookup helpers. */
- bool gpioBoardProfileIsValid(void);
- const GpioBoardPin *gpioBoardFindUserPin(gpio_num_t gpio);
- bool gpioBoardPinSupports(gpio_num_t gpio, uint8_t requiredCapabilities);
- bool gpioBoardIsReservedPin(gpio_num_t gpio);
- bool gpioBoardIsBuiltInFlashLed(gpio_num_t gpio);
- #endif // BOARD_GPIO_PROFILE_H
|