How config files are structured
A typical hardware target consists of two files:- A header file (
.h) that defines all pin assignments, ADC indexes, hardware property flags, and electrical limits. - A source file (
.c) that implementshw_init_gpio()and any hardware-specific initialization.
hw_<name>_core.h / hw_<name>_core.c pair and have thin revision headers that select the revision before including the core:
Required defines
The following defines are required in every hardware header. The build will fail with a descriptive error if they are missing.Identity
Hardware property flags
Declare which gate driver and current measurement topology the board uses:Gate control macros
ADC configuration
Define the number of ADC conversions per cycle and map each channel to its signal:Voltage divider and current scaling
Temperature sensing
Hardware limits
Limits define the allowable range for configuration parameters. They are enforced in VESC Tool and at runtime.Peripheral pins
Define the peripheral assignments for UART, I2C, SPI, hall/encoder, and servo decoding. Seehwconf/example/hw_example_core.h for the full set of required peripheral pin defines.
Source file
The.c file must implement hw_init_gpio(). This function configures GPIO pads and initializes the gate driver at startup:
HW_HAS_DRV8301, HW_HAS_DRV8320S, etc.) requires calling its own _init() function at the end of hw_init_gpio().
Using the example config as a template
Thehwconf/example/ directory contains a complete reference implementation:
1
Copy the example files
Copy all three source files to a new directory inside
hwconf/:2
Update include guards and names
Replace every occurrence of
HW_EXAMPLE with HW_MYBOARD and hw_example with hw_myboard in all three files.3
Set HW_NAME
In the core header, set
HW_NAME to a unique string for your board:4
Adjust pin assignments
Update all GPIO, ADC, UART, SPI, I2C, and encoder pin definitions to match your schematic.
5
Set electrical limits
Update the
HW_LIM_* defines to match your hardware’s rated voltage, current, and temperature ranges.6
Build with fw_custom
Build the firmware without adding your board to the main Makefile:The built binary appears at
build/custom/custom.bin.Registering the target in the build system
To have your board appear as a named target (for examplefw_myboard), place the header file in a location where the Makefile can discover it. The Makefile scans all hwconf/**/*.h files (excluding *_core.h) to generate targets:
hwconf/myboard/hw_myboard.h automatically produces the target myboard, letting you use:
