Initial commit
ESP32-S3 firmware acting as BMC for another board, controlling an ATX power supply and providing access to UART. Co-authored with GLM-5
This commit is contained in:
122
main/config.h
Normal file
122
main/config.h
Normal file
@@ -0,0 +1,122 @@
|
||||
#ifndef BMC_CONFIG_H
|
||||
#define BMC_CONFIG_H
|
||||
|
||||
#include "driver/gpio.h"
|
||||
#include "driver/uart.h"
|
||||
|
||||
// ============================================================================
|
||||
// Ethernet Configuration (W5500 SPI)
|
||||
// ============================================================================
|
||||
#define ETH_SPI_HOST SPI2_HOST
|
||||
#define ETH_SPI_MISO_GPIO GPIO_NUM_12
|
||||
#define ETH_SPI_MOSI_GPIO GPIO_NUM_11
|
||||
#define ETH_SPI_SCLK_GPIO GPIO_NUM_13
|
||||
#define ETH_SPI_CS_GPIO GPIO_NUM_14
|
||||
#define ETH_SPI_INT_GPIO GPIO_NUM_10
|
||||
#define ETH_SPI_RST_GPIO GPIO_NUM_9
|
||||
|
||||
// MAC address (can be customized)
|
||||
#define ETH_MAC_ADDR {0x02, 0x00, 0x00, 0x12, 0x34, 0x56}
|
||||
|
||||
// Network configuration (used if DHCP fails or is disabled)
|
||||
#define BMC_USE_DHCP 1
|
||||
#define BMC_STATIC_IP "192.168.1.100"
|
||||
#define BMC_NETMASK "255.255.255.0"
|
||||
#define BMC_GATEWAY "192.168.1.1"
|
||||
|
||||
// ============================================================================
|
||||
// UART Serial Configuration
|
||||
// ============================================================================
|
||||
#define BMC_UART_NUM UART_NUM_1
|
||||
#define BMC_UART_TX_GPIO GPIO_NUM_43
|
||||
#define BMC_UART_RX_GPIO GPIO_NUM_44
|
||||
#define BMC_UART_BAUD_RATE 115200
|
||||
#define BMC_UART_BUF_SIZE 2048
|
||||
#define BMC_UART_TASK_STACK 4096
|
||||
#define BMC_UART_TASK_PRIO 5
|
||||
|
||||
// ============================================================================
|
||||
// HTTP Server Configuration
|
||||
// ============================================================================
|
||||
#define BMC_HTTP_PORT 80
|
||||
#define BMC_HTTP_MAX_CONN 4
|
||||
#define BMC_HTTP_STACK_SIZE 8192
|
||||
|
||||
// ============================================================================
|
||||
// GPIO Configuration
|
||||
// ============================================================================
|
||||
|
||||
// Number of user-configurable GPIOs
|
||||
#define BMC_GPIO_COUNT 16
|
||||
|
||||
// GPIO pin definitions with names and default modes
|
||||
typedef struct {
|
||||
gpio_num_t pin;
|
||||
const char *name;
|
||||
gpio_mode_t mode;
|
||||
int default_value;
|
||||
bool inverted; // Active-low logic
|
||||
bool is_input_only; // Some pins are input-only
|
||||
} bmc_gpio_def_t;
|
||||
|
||||
// Predefined GPIO assignments
|
||||
#define BMC_GPIO_POWER_ON GPIO_NUM_4
|
||||
#define BMC_GPIO_POWER_OFF GPIO_NUM_5
|
||||
#define BMC_GPIO_RESET GPIO_NUM_6
|
||||
#define BMC_GPIO_STATUS_LED GPIO_NUM_7
|
||||
#define BMC_GPIO_PWR_GOOD GPIO_NUM_15
|
||||
#define BMC_GPIO_TEMP_ALERT GPIO_NUM_16
|
||||
#define BMC_GPIO_FAN_CTRL GPIO_NUM_17
|
||||
#define BMC_GPIO_USER_1 GPIO_NUM_18
|
||||
#define BMC_GPIO_USER_2 GPIO_NUM_21
|
||||
#define BMC_GPIO_USER_3 GPIO_NUM_35
|
||||
#define BMC_GPIO_USER_4 GPIO_NUM_36
|
||||
#define BMC_GPIO_USER_5 GPIO_NUM_37
|
||||
#define BMC_GPIO_USER_6 GPIO_NUM_38
|
||||
#define BMC_GPIO_USER_7 GPIO_NUM_47
|
||||
#define BMC_GPIO_USER_8 GPIO_NUM_48
|
||||
|
||||
// Default GPIO configuration table
|
||||
static const bmc_gpio_def_t bmc_gpio_defaults[BMC_GPIO_COUNT] = {
|
||||
// Power control outputs
|
||||
{ BMC_GPIO_POWER_ON, "POWER_ON", GPIO_MODE_OUTPUT, 0, false, false},
|
||||
{ BMC_GPIO_POWER_OFF, "POWER_OFF", GPIO_MODE_OUTPUT, 0, false, false},
|
||||
{ BMC_GPIO_RESET, "RESET", GPIO_MODE_OUTPUT, 0, true, false}, // Active-low reset
|
||||
{BMC_GPIO_STATUS_LED, "STATUS_LED", GPIO_MODE_OUTPUT, 0, false, false},
|
||||
|
||||
// Status inputs
|
||||
{ BMC_GPIO_PWR_GOOD, "PWR_GOOD", GPIO_MODE_INPUT, 0, false, false},
|
||||
{BMC_GPIO_TEMP_ALERT, "TEMP_ALERT", GPIO_MODE_INPUT, 0, true, false}, // Active-low alert
|
||||
|
||||
// PWM output
|
||||
{ BMC_GPIO_FAN_CTRL, "FAN_CTRL", GPIO_MODE_OUTPUT, 0, false, false},
|
||||
|
||||
// User-configurable GPIOs
|
||||
{ BMC_GPIO_USER_1, "USER_1", GPIO_MODE_INPUT, 0, false, false},
|
||||
{ BMC_GPIO_USER_2, "USER_2", GPIO_MODE_INPUT, 0, false, false},
|
||||
{ BMC_GPIO_USER_3, "USER_3", GPIO_MODE_INPUT, 0, false, false},
|
||||
{ BMC_GPIO_USER_4, "USER_4", GPIO_MODE_INPUT, 0, false, false},
|
||||
{ BMC_GPIO_USER_5, "USER_5", GPIO_MODE_INPUT, 0, false, true}, // Input-only on ESP32-S3
|
||||
{ BMC_GPIO_USER_6, "USER_6", GPIO_MODE_INPUT, 0, false, true}, // Input-only on ESP32-S3
|
||||
{ BMC_GPIO_USER_7, "USER_7", GPIO_MODE_INPUT, 0, false, true}, // Input-only on ESP32-S3
|
||||
{ BMC_GPIO_USER_8, "USER_8", GPIO_MODE_INPUT, 0, false, true}, // Input-only on ESP32-S3
|
||||
};
|
||||
|
||||
// ============================================================================
|
||||
// Power Control Timing
|
||||
// ============================================================================
|
||||
#define BMC_POWER_ON_PULSE_MS 100
|
||||
#define BMC_POWER_OFF_PULSE_MS 5000
|
||||
#define BMC_RESET_PULSE_MS 100
|
||||
#define BMC_POWER_GOOD_DELAY_MS 2000
|
||||
|
||||
// ============================================================================
|
||||
// Logging Tags
|
||||
// ============================================================================
|
||||
#define TAG_BMC "BMC"
|
||||
#define TAG_GPIO "GPIO"
|
||||
#define TAG_UART "UART"
|
||||
#define TAG_ETH "ETH"
|
||||
#define TAG_HTTP "HTTP"
|
||||
|
||||
#endif // BMC_CONFIG_H
|
||||
Reference in New Issue
Block a user