Skip to content

Commit

Permalink
Boards header updates (#1724)
Browse files Browse the repository at this point in the history
* Add script to automatically validate board header files

* Fix small automatically-found inconsistencies in various board header files

* Tweak and add board header file from abandoned PR #1174
  • Loading branch information
lurch authored Jun 21, 2024
1 parent 333974f commit 0e5cef3
Show file tree
Hide file tree
Showing 13 changed files with 370 additions and 22 deletions.
84 changes: 84 additions & 0 deletions src/boards/include/boards/0xcb_helios.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,84 @@
/*
* Copyright (c) 2020 Raspberry Pi (Trading) Ltd.
*
* SPDX-License-Identifier: BSD-3-Clause
*/

// -----------------------------------------------------
// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------
//
//------------------------------------------------------------------------------------------
// Board definition for the 0xCB Helios

#ifndef _BOARDS_0XCB_HELIOS_H
#define _BOARDS_0XCB_HELIOS_H

// For board detection
#define _0XCB_HELIOS

#ifndef PICO_DEFAULT_UART
#define PICO_DEFAULT_UART 0
#endif
#ifndef PICO_DEFAULT_UART_TX_PIN
#define PICO_DEFAULT_UART_TX_PIN 0
#endif
#ifndef PICO_DEFAULT_UART_RX_PIN
#define PICO_DEFAULT_UART_RX_PIN 1
#endif

// User LED and level shifted PIN
#ifndef PICO_DEFAULT_LED_PIN
#define PICO_DEFAULT_LED_PIN 17
#endif
#ifndef PICO_DEFAULT_WS2812_PIN
#define PICO_DEFAULT_WS2812_PIN 25
#endif

// --- I2C ---
#ifndef PICO_DEFAULT_I2C
#define PICO_DEFAULT_I2C 1
#endif
#ifndef PICO_DEFAULT_I2C_SDA_PIN
#define PICO_DEFAULT_I2C_SDA_PIN 2
#endif
#ifndef PICO_DEFAULT_I2C_SCL_PIN
#define PICO_DEFAULT_I2C_SCL_PIN 3
#endif

// --- SPI ---
#ifndef PICO_DEFAULT_SPI
#define PICO_DEFAULT_SPI 0
#endif
#ifndef PICO_DEFAULT_SPI_SCK_PIN
#define PICO_DEFAULT_SPI_SCK_PIN 22
#endif
#ifndef PICO_DEFAULT_SPI_TX_PIN
#define PICO_DEFAULT_SPI_TX_PIN 23
#endif
#ifndef PICO_DEFAULT_SPI_RX_PIN
#define PICO_DEFAULT_SPI_RX_PIN 20
#endif
#ifndef PICO_DEFAULT_SPI_CSN_PIN
#define PICO_DEFAULT_SPI_CSN_PIN 21
#endif

#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1

#ifndef PICO_FLASH_SPI_CLKDIV
#define PICO_FLASH_SPI_CLKDIV 2
#endif

// board has 16M onboard flash
#ifndef PICO_FLASH_SIZE_BYTES
#define PICO_FLASH_SIZE_BYTES (16 * 1024 * 1024)
#endif

// All boards have B1 RP2040

#ifndef PICO_RP2040_B0_SUPPORTED
#define PICO_RP2040_B0_SUPPORTED 0
#endif

#endif
6 changes: 3 additions & 3 deletions src/boards/include/boards/cytron_maker_pi_rp2040.h
Original file line number Diff line number Diff line change
Expand Up @@ -26,8 +26,8 @@
#define MAKER_PI_RP2040_M1B_PIN 9
#endif

#ifndef MAKER_PI_RP2040_M2B_PIN
#define MAKER_PI_RP2040_M2B_PIN 10
#ifndef MAKER_PI_RP2040_M2A_PIN
#define MAKER_PI_RP2040_M2A_PIN 10
#endif

#ifndef MAKER_PI_RP2040_M2B_PIN
Expand Down Expand Up @@ -186,4 +186,4 @@
#define PICO_RP2040_B0_SUPPORTED 0
#endif

#endif
#endif
2 changes: 1 addition & 1 deletion src/boards/include/boards/nullbits_bit_c_pro.h
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@

//------------- I2C -------------//
#ifndef PICO_DEFAULT_I2C
#define PICO_DEFAULT_I2C 0
#define PICO_DEFAULT_I2C 1
#endif

#ifndef PICO_DEFAULT_I2C_SDA_PIN
Expand Down
2 changes: 1 addition & 1 deletion src/boards/include/boards/pico_w.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,7 +9,7 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------

// This header may be included by other board headers as "boards/pico.h"
// This header may be included by other board headers as "boards/pico_w.h"

#ifndef _BOARDS_PICO_W_H
#define _BOARDS_PICO_W_H
Expand Down
2 changes: 1 addition & 1 deletion src/boards/include/boards/pimoroni_tiny2040_2mb.h
Original file line number Diff line number Diff line change
Expand Up @@ -13,8 +13,8 @@
#define _BOARDS_PIMORONI_TINY2040_2MB_H

// For board detection
#define PIMORONI_TINY2040
#define PIMORONI_TINY2040_2MB
#define PIMORONI_TINY2040

// --- BOARD SPECIFIC ---
#define TINY2040_LED_R_PIN 18
Expand Down
4 changes: 2 additions & 2 deletions src/boards/include/boards/pololu_3pi_2040_robot.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------

#ifndef _POLOLU_3PI_2040_ROBOT_H
#define _POLOLU_3PI_2040_ROBOT_H
#ifndef _BOARDS_POLOLU_3PI_2040_ROBOT_H
#define _BOARDS_POLOLU_3PI_2040_ROBOT_H

// For board detection
#define POLOLU_3PI_2040_ROBOT
Expand Down
4 changes: 2 additions & 2 deletions src/boards/include/boards/pololu_zumo_2040_robot.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,8 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------

#ifndef _POLOLU_ZUMO_2040_ROBOT_H
#define _POLOLU_ZUMO_2040_ROBOT_H
#ifndef _BOARDS_POLOLU_ZUMO_2040_ROBOT_H
#define _BOARDS_POLOLU_ZUMO_2040_ROBOT_H

// For board detection
#define POLOLU_ZUMO_2040_ROBOT
Expand Down
8 changes: 4 additions & 4 deletions src/boards/include/boards/weact_studio_rp2040_2mb.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------

// This header may be included by other board headers as "boards/weact_studio_rp2040_16mb.h"
// This header may be included by other board headers as "boards/weact_studio_rp2040_2mb.h"

#ifndef _BOARDS_WEACT_STUDIO_RP2040_16MB_H
#define _BOARDS_WEACT_STUDIO_RP2040_16MB_H
#ifndef _BOARDS_WEACT_STUDIO_RP2040_2MB_H
#define _BOARDS_WEACT_STUDIO_RP2040_2MB_H

// For board detection
#define WEACT_STUDIO_RP2040_16MB
#define WEACT_STUDIO_RP2040_2MB

// --- UART ---
#ifndef PICO_DEFAULT_UART
Expand Down
8 changes: 4 additions & 4 deletions src/boards/include/boards/weact_studio_rp2040_4mb.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------

// This header may be included by other board headers as "boards/weact_studio_rp2040_16mb.h"
// This header may be included by other board headers as "boards/weact_studio_rp2040_4mb.h"

#ifndef _BOARDS_WEACT_STUDIO_RP2040_16MB_H
#define _BOARDS_WEACT_STUDIO_RP2040_16MB_H
#ifndef _BOARDS_WEACT_STUDIO_RP2040_4MB_H
#define _BOARDS_WEACT_STUDIO_RP2040_4MB_H

// For board detection
#define WEACT_STUDIO_RP2040_16MB
#define WEACT_STUDIO_RP2040_4MB

// --- UART ---
#ifndef PICO_DEFAULT_UART
Expand Down
8 changes: 4 additions & 4 deletions src/boards/include/boards/weact_studio_rp2040_8mb.h
Original file line number Diff line number Diff line change
Expand Up @@ -9,13 +9,13 @@
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
// -----------------------------------------------------

// This header may be included by other board headers as "boards/weact_studio_rp2040_16mb.h"
// This header may be included by other board headers as "boards/weact_studio_rp2040_8mb.h"

#ifndef _BOARDS_WEACT_STUDIO_RP2040_16MB_H
#define _BOARDS_WEACT_STUDIO_RP2040_16MB_H
#ifndef _BOARDS_WEACT_STUDIO_RP2040_8MB_H
#define _BOARDS_WEACT_STUDIO_RP2040_8MB_H

// For board detection
#define WEACT_STUDIO_RP2040_16MB
#define WEACT_STUDIO_RP2040_8MB

// --- UART ---
#ifndef PICO_DEFAULT_UART
Expand Down
74 changes: 74 additions & 0 deletions src/rp2040/rp2040_interface_pins.json
Original file line number Diff line number Diff line change
@@ -0,0 +1,74 @@
{
"UART": {
"0": {
"TX": [0, 12, 16, 28],
"RX": [1, 13, 17, 29],
"CTS": [2, 14, 18],
"RTS": [3, 15, 19]
},
"1": {
"TX": [4, 8, 20, 24],
"RX": [5, 9, 21, 25],
"CTS": [6, 10, 22, 26],
"RTS": [7, 11, 23, 27]
}
},
"I2C": {
"0": {
"SDA": [0, 4, 8, 12, 16, 20, 24, 28],
"SCL": [1, 5, 9, 13, 17, 21, 25, 29]
},
"1": {
"SDA": [2, 6, 10, 14, 18, 22, 26],
"SCL": [3, 7, 11, 15, 19, 23, 27]
}
},
"SPI": {
"0": {
"RX": [0, 4, 16, 20],
"CSN": [1, 5, 17, 21],
"SCK": [2, 6, 18, 22],
"TX": [3, 7, 19, 23]
},
"1": {
"RX": [8, 12, 24, 28],
"CSN": [9, 13, 25, 29],
"SCK": [10, 14, 26],
"TX": [11, 15, 27]
}
},
"PWM": {
"0": {
"A": [0, 16],
"B": [1, 17]
},
"1": {
"A": [2, 18],
"B": [3, 19]
},
"2": {
"A": [4, 20],
"B": [5, 21]
},
"3": {
"A": [6, 22],
"B": [7, 23]
},
"4": {
"A": [8, 24],
"B": [9, 25]
},
"5": {
"A": [10, 26],
"B": [11, 27]
},
"6": {
"A": [12, 28],
"B": [13, 29]
},
"7": {
"A": [14],
"B": [15]
}
}
}
7 changes: 7 additions & 0 deletions tools/check_all_board_headers.sh
Original file line number Diff line number Diff line change
@@ -0,0 +1,7 @@
#!/bin/bash
for HEADER in src/boards/include/boards/*.h; do
tools/check_board_header.py $HEADER
if [[ $? -ne 0 ]]; then
break
fi
done
Loading

0 comments on commit 0e5cef3

Please sign in to comment.