2023-01-16 21:09:24 +01:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
|
|
|
|
#pragma once
|
|
|
|
|
|
|
|
|
|
#include <Arduino.h>
|
2023-01-16 22:26:35 +01:00
|
|
|
#include <ETH.h>
|
2023-03-14 18:45:39 +01:00
|
|
|
#include <stdint.h>
|
2023-01-16 21:09:24 +01:00
|
|
|
|
|
|
|
|
#define PINMAPPING_FILENAME "/pin_mapping.json"
|
2023-04-03 21:10:12 +02:00
|
|
|
#define PINMAPPING_LED_COUNT 2
|
2023-01-16 21:09:24 +01:00
|
|
|
|
|
|
|
|
#define MAPPING_NAME_STRLEN 31
|
|
|
|
|
|
|
|
|
|
struct PinMapping_t {
|
|
|
|
|
char name[MAPPING_NAME_STRLEN + 1];
|
2024-10-04 01:15:24 +02:00
|
|
|
|
2025-02-07 23:49:15 +01:00
|
|
|
gpio_num_t nrf24_miso;
|
|
|
|
|
gpio_num_t nrf24_mosi;
|
|
|
|
|
gpio_num_t nrf24_clk;
|
|
|
|
|
gpio_num_t nrf24_irq;
|
|
|
|
|
gpio_num_t nrf24_en;
|
|
|
|
|
gpio_num_t nrf24_cs;
|
2023-03-08 20:12:22 +01:00
|
|
|
|
2025-02-07 23:52:00 +01:00
|
|
|
gpio_num_t cmt_clk;
|
|
|
|
|
gpio_num_t cmt_cs;
|
|
|
|
|
gpio_num_t cmt_fcs;
|
|
|
|
|
gpio_num_t cmt_gpio2;
|
|
|
|
|
gpio_num_t cmt_gpio3;
|
|
|
|
|
gpio_num_t cmt_sdio;
|
2023-03-08 20:12:22 +01:00
|
|
|
|
2025-02-07 23:54:07 +01:00
|
|
|
gpio_num_t w5500_mosi;
|
|
|
|
|
gpio_num_t w5500_miso;
|
|
|
|
|
gpio_num_t w5500_sclk;
|
|
|
|
|
gpio_num_t w5500_cs;
|
|
|
|
|
gpio_num_t w5500_int;
|
|
|
|
|
gpio_num_t w5500_rst;
|
2023-07-21 16:57:00 +02:00
|
|
|
|
2024-10-04 01:15:24 +02:00
|
|
|
#if CONFIG_ETH_USE_ESP32_EMAC
|
2023-01-16 22:26:35 +01:00
|
|
|
int8_t eth_phy_addr;
|
|
|
|
|
bool eth_enabled;
|
2025-02-08 00:30:48 +01:00
|
|
|
gpio_num_t eth_power;
|
|
|
|
|
gpio_num_t eth_mdc;
|
|
|
|
|
gpio_num_t eth_mdio;
|
2023-01-16 22:26:35 +01:00
|
|
|
eth_phy_type_t eth_type;
|
|
|
|
|
eth_clock_mode_t eth_clk_mode;
|
2024-10-04 01:15:24 +02:00
|
|
|
#endif
|
|
|
|
|
|
2023-01-19 20:50:57 +01:00
|
|
|
uint8_t display_type;
|
2025-02-08 00:56:22 +01:00
|
|
|
gpio_num_t display_data;
|
|
|
|
|
gpio_num_t display_clk;
|
|
|
|
|
gpio_num_t display_cs;
|
|
|
|
|
gpio_num_t display_reset;
|
2024-10-04 01:15:24 +02:00
|
|
|
|
2025-02-07 23:41:01 +01:00
|
|
|
gpio_num_t led[PINMAPPING_LED_COUNT];
|
2023-01-16 21:09:24 +01:00
|
|
|
};
|
|
|
|
|
|
|
|
|
|
class PinMappingClass {
|
|
|
|
|
public:
|
|
|
|
|
PinMappingClass();
|
|
|
|
|
bool init(const String& deviceMapping);
|
|
|
|
|
PinMapping_t& get();
|
|
|
|
|
|
2024-12-14 13:07:31 +01:00
|
|
|
bool isMappingSelected() const { return _mappingSelected; }
|
|
|
|
|
|
2023-12-12 01:30:40 +01:00
|
|
|
bool isValidNrf24Config() const;
|
|
|
|
|
bool isValidCmt2300Config() const;
|
2023-07-21 16:57:00 +02:00
|
|
|
bool isValidW5500Config() const;
|
2024-10-04 01:15:24 +02:00
|
|
|
#if CONFIG_ETH_USE_ESP32_EMAC
|
2023-12-12 01:30:40 +01:00
|
|
|
bool isValidEthConfig() const;
|
2024-10-04 01:15:24 +02:00
|
|
|
#endif
|
2023-01-16 21:09:24 +01:00
|
|
|
|
|
|
|
|
private:
|
|
|
|
|
PinMapping_t _pinMapping;
|
2024-12-14 13:07:31 +01:00
|
|
|
|
|
|
|
|
bool _mappingSelected = false;
|
2023-01-16 21:09:24 +01:00
|
|
|
};
|
|
|
|
|
|
2023-07-21 16:57:00 +02:00
|
|
|
extern PinMappingClass PinMapping;
|