Board Configuration
note
We're looking to move away from compile time configuration, in favor of runtime configuration.
There are two simple options for building GP2040-CE for your board. You can either edit an existing board definition, or create your own. Several example configurations are located in the repository configs folder. This document will outline setting up a new build configuration.
Board Configuration Folder
Each subfolder in configs
contains a separate board configuration, which consists of the following:
Name | Required? | Description |
---|---|---|
BoardConfig.h | Yes | The configuration file used when building GP2040-CE for a specific controller/board. Contains initial GPIO pin mappings, LED configuration, etc. |
README.md | Yes | Provides information related to this board configuration. Required for pull requests of new board configurations. Must contain the Main Pin Mapping Configuration. Suggested to also contain a link to your repository and a picture. |
assets/ | No | Folder for containing assets included in the README.md . Not required for the build process. |
<boardname.h> | No | Board definition file, named after the board itself, used by the Pico SDK for configuring board specific SDK features. Pico Example |
BoardConfig.h
The following board options are required in the BoardConfig.h
file:
Name | Description |
---|---|
BOARD_CONFIG_LABEL | Name of your board. |
GPIO_PIN_X | The GPIO pin for the action you want. Replace the X with GPIO pin number and then assign to actions with GpioAction:: |
Create configs/NewBoard/BoardConfig.h
and add your pin configuration and options. An example, bare minimum, BoardConfig.h
file:
// BoardConfig.h
#ifndef PICO_BOARD_CONFIG_H_
#define PICO_BOARD_CONFIG_H_
#include "enums.pb.h"
#include "class/hid/hid.h"
#define BOARD_CONFIG_LABEL "New Board"
// Main pin mapping Configuration
// // GP2040 | Xinput | Switch | PS3/4/5 | Dinput | Arcade |
#define GPIO_PIN_19 GpioAction::BUTTON_PRESS_UP // UP | UP | UP | UP | UP | UP |
#define GPIO_PIN_18 GpioAction::BUTTON_PRESS_DOWN // DOWN | DOWN | DOWN | DOWN | DOWN | DOWN |
#define GPIO_PIN_17 GpioAction::BUTTON_PRESS_RIGHT // RIGHT | RIGHT | RIGHT | RIGHT | RIGHT | RIGHT |
#define GPIO_PIN_16 GpioAction::BUTTON_PRESS_LEFT // LEFT | LEFT | LEFT | LEFT | LEFT | LEFT |
#define GPIO_PIN_08 GpioAction::BUTTON_PRESS_B1 // B1 | A | B | Cross | 2 | K1 |
#define GPIO_PIN_07 GpioAction::BUTTON_PRESS_B2 // B2 | B | A | Circle | 3 | K2 |
#define GPIO_PIN_06 GpioAction::BUTTON_PRESS_R2 // R2 | RT | ZR | R2 | 8 | K3 |
#define GPIO_PIN_05 GpioAction::BUTTON_PRESS_L2 // L2 | LT | ZL | L2 | 7 | K4 |
#define GPIO_PIN_12 GpioAction::BUTTON_PRESS_B3 // B3 | X | Y | Square | 1 | P1 |
#define GPIO_PIN_11 GpioAction::BUTTON_PRESS_B4 // B4 | Y | X | Triangle | 4 | P2 |
#define GPIO_PIN_10 GpioAction::BUTTON_PRESS_R1 // R1 | RB | R | R1 | 6 | P3 |
#define GPIO_PIN_09 GpioAction::BUTTON_PRESS_L1 // L1 | LB | L | L1 | 5 | P4 |
#define GPIO_PIN_15 GpioAction::BUTTON_PRESS_S1 // S1 | Back | Minus | Select | 9 | Coin |
#define GPIO_PIN_13 GpioAction::BUTTON_PRESS_S2 // S2 | Start | Plus | Start | 10 | Start |
#define GPIO_PIN_21 GpioAction::BUTTON_PRESS_L3 // L3 | LS | LS | L3 | 11 | LS |
#define GPIO_PIN_22 GpioAction::BUTTON_PRESS_R3 // R3 | RS | RS | R3 | 12 | RS |
#define GPIO_PIN_14 GpioAction::BUTTON_PRESS_A1 // A1 | Guide | Home | PS | 13 | ~ |
#define GPIO_PIN_20 GpioAction::BUTTON_PRESS_A2 // A2 | ~ | Capture | ~ | 14 | ~ |
#endif