Skip to content

Commit bc3559b

Browse files
committed
Add status LED support
Also I2C, SPI, and cyw43
1 parent 4697e80 commit bc3559b

File tree

20 files changed

+200
-71
lines changed

20 files changed

+200
-71
lines changed

src/boards/include/boards/rp2040_configurable.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
#define _BOARDS_RP2040_CONFIGURABLE_H
1616

1717
pico_board_cmake_set(PICO_PLATFORM, rp2040)
18+
pico_board_cmake_set(PICO_CYW43_SUPPORTED, 1)
1819

1920
// For board detection
20-
#define RASPBERRYPI_RP2040
21+
#define RASPBERRYPI_RP2040_CONFIGURABLE
2122

2223
// For post-compile configuration
2324
pico_board_cmake_set(PICO_SUPPORT_CONFIGURABLE_PINS, 1)

src/boards/include/boards/rp2350_configurable.h

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,9 +15,10 @@
1515
#define _BOARDS_RP2350_CONFIGURABLE_H
1616

1717
pico_board_cmake_set(PICO_PLATFORM, rp2350)
18+
pico_board_cmake_set(PICO_CYW43_SUPPORTED, 1)
1819

1920
// For board detection
20-
#define RASPBERRYPI_RP2350
21+
#define RASPBERRYPI_RP2350_CONFIGURABLE
2122

2223
// For post-compile configuration
2324
pico_board_cmake_set(PICO_SUPPORT_CONFIGURABLE_PINS, 1)

src/common/pico_configurable_pins/configurable_pins.c

Lines changed: 14 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -18,6 +18,9 @@ bi_decl(bi_ptr_global_int32(BINARY_INFO_TAG_CONFIGURABLE_PINS, BINARY_INFO_ID_CO
1818
bi_decl(bi_ptr_global_int32(BINARY_INFO_TAG_CONFIGURABLE_PINS, BINARY_INFO_ID_CONFIGURABLE_PINS, pico_default_uart_tx_pin, 0));
1919
bi_decl(bi_ptr_global_int32(BINARY_INFO_TAG_CONFIGURABLE_PINS, BINARY_INFO_ID_CONFIGURABLE_PINS, pico_default_uart_rx_pin, 1));
2020
bi_decl(bi_ptr_global_int32(BINARY_INFO_TAG_CONFIGURABLE_PINS, BINARY_INFO_ID_CONFIGURABLE_PINS, pico_default_led_pin, 25));
21+
bi_decl(bi_ptr_global_int32(BINARY_INFO_TAG_CONFIGURABLE_PINS, BINARY_INFO_ID_CONFIGURABLE_PINS, pico_default_led_pin_inverted, 0));
22+
bi_decl(bi_ptr_global_int32(BINARY_INFO_TAG_CONFIGURABLE_PINS, BINARY_INFO_ID_CONFIGURABLE_PINS, pico_default_ws2812_pin, -1));
23+
bi_decl(bi_ptr_global_int32(BINARY_INFO_TAG_CONFIGURABLE_PINS, BINARY_INFO_ID_CONFIGURABLE_PINS, pico_default_ws2812_power_pin, -1));
2124
bi_decl(bi_ptr_global_int32(BINARY_INFO_TAG_CONFIGURABLE_PINS, BINARY_INFO_ID_CONFIGURABLE_PINS, pico_default_i2c, 0));
2225
bi_decl(bi_ptr_global_int32(BINARY_INFO_TAG_CONFIGURABLE_PINS, BINARY_INFO_ID_CONFIGURABLE_PINS, pico_default_i2c_sda_pin, 4));
2326
bi_decl(bi_ptr_global_int32(BINARY_INFO_TAG_CONFIGURABLE_PINS, BINARY_INFO_ID_CONFIGURABLE_PINS, pico_default_i2c_scl_pin, 5));
@@ -30,4 +33,15 @@ bi_decl(bi_ptr_global_int32(BINARY_INFO_TAG_CONFIGURABLE_PINS, BINARY_INFO_ID_CO
3033
bi_decl(bi_ptr_global_int32(BINARY_INFO_TAG_CONFIGURABLE_PINS, BINARY_INFO_ID_CONFIGURABLE_PINS, pico_vbus_pin, 24));
3134
bi_decl(bi_ptr_global_int32(BINARY_INFO_TAG_CONFIGURABLE_PINS, BINARY_INFO_ID_CONFIGURABLE_PINS, pico_vsys_pin, 29));
3235

36+
bi_decl(bi_ptr_global_int32(BINARY_INFO_TAG_CONFIGURABLE_PINS, BINARY_INFO_ID_CONFIGURABLE_PINS, pico_cyw43_wl_reg_on_pin, 23));
37+
bi_decl(bi_ptr_global_int32(BINARY_INFO_TAG_CONFIGURABLE_PINS, BINARY_INFO_ID_CONFIGURABLE_PINS, pico_cyw43_wl_data_out_pin, 24));
38+
bi_decl(bi_ptr_global_int32(BINARY_INFO_TAG_CONFIGURABLE_PINS, BINARY_INFO_ID_CONFIGURABLE_PINS, pico_cyw43_wl_data_in_pin, 24));
39+
bi_decl(bi_ptr_global_int32(BINARY_INFO_TAG_CONFIGURABLE_PINS, BINARY_INFO_ID_CONFIGURABLE_PINS, pico_cyw43_wl_host_wake_pin, 24));
40+
bi_decl(bi_ptr_global_int32(BINARY_INFO_TAG_CONFIGURABLE_PINS, BINARY_INFO_ID_CONFIGURABLE_PINS, pico_cyw43_wl_clock_pin, 29));
41+
bi_decl(bi_ptr_global_int32(BINARY_INFO_TAG_CONFIGURABLE_PINS, BINARY_INFO_ID_CONFIGURABLE_PINS, pico_cyw43_wl_cs_pin, 25));
42+
43+
bi_decl(bi_ptr_global_int32(BINARY_INFO_TAG_CONFIGURABLE_PINS, BINARY_INFO_ID_CONFIGURABLE_PINS, pico_cyw43_wl_gpio_led_pin, -1));
44+
45+
bi_decl(bi_ptr_global_int32(BINARY_INFO_TAG_CONFIGURABLE_PINS, BINARY_INFO_ID_CONFIGURABLE_PINS, pico_colored_status_led_uses_wrgb, 0));
46+
3347
#endif

src/common/pico_configurable_pins/include/pico/configurable_pins.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -19,6 +19,12 @@ extern const int pico_default_uart_tx_pin;
1919
extern const int pico_default_uart_rx_pin;
2020
#define PICO_DEFAULT_LED_PIN pico_default_led_pin
2121
extern const int pico_default_led_pin;
22+
#define PICO_DEFAULT_LED_PIN_INVERTED pico_default_led_pin_inverted
23+
extern const int pico_default_led_pin_inverted;
24+
#define PICO_DEFAULT_WS2812_PIN pico_default_ws2812_pin
25+
extern const int pico_default_ws2812_pin;
26+
#define PICO_DEFAULT_WS2812_POWER_PIN pico_default_ws2812_power_pin
27+
extern const int pico_default_ws2812_power_pin;
2228
#define PICO_DEFAULT_I2C pico_default_i2c
2329
extern const int pico_default_i2c;
2430
#define PICO_DEFAULT_I2C_SDA_PIN pico_default_i2c_sda_pin
@@ -42,6 +48,25 @@ extern const int pico_vbus_pin;
4248
#define PICO_VSYS_PIN pico_vsys_pin
4349
extern const int pico_vsys_pin;
4450

51+
#define CYW43_DEFAULT_PIN_WL_REG_ON pico_cyw43_wl_reg_on_pin
52+
extern const int pico_cyw43_wl_reg_on_pin;
53+
#define CYW43_DEFAULT_PIN_WL_DATA_OUT pico_cyw43_wl_data_out_pin
54+
extern const int pico_cyw43_wl_data_out_pin;
55+
#define CYW43_DEFAULT_PIN_WL_DATA_IN pico_cyw43_wl_data_in_pin
56+
extern const int pico_cyw43_wl_data_in_pin;
57+
#define CYW43_DEFAULT_PIN_WL_HOST_WAKE pico_cyw43_wl_host_wake_pin
58+
extern const int pico_cyw43_wl_host_wake_pin;
59+
#define CYW43_DEFAULT_PIN_WL_CLOCK pico_cyw43_wl_clock_pin
60+
extern const int pico_cyw43_wl_clock_pin;
61+
#define CYW43_DEFAULT_PIN_WL_CS pico_cyw43_wl_cs_pin
62+
extern const int pico_cyw43_wl_cs_pin;
63+
64+
#define CYW43_WL_GPIO_LED_PIN pico_cyw43_wl_gpio_led_pin
65+
extern const int pico_cyw43_wl_gpio_led_pin;
66+
67+
#define PICO_COLORED_STATUS_LED_USES_WRGB pico_colored_status_led_uses_wrgb
68+
extern const int pico_colored_status_led_uses_wrgb;
69+
4570
#endif
4671

4772
#endif

src/rp2_common/hardware_i2c/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -10,6 +10,7 @@ cc_library(
1010
target_compatible_with = compatible_with_rp2(),
1111
deps = [
1212
"//src/common/pico_time",
13+
"//src/common/pico_configurable_pins",
1314
"//src/rp2_common:hardware_regs",
1415
"//src/rp2_common:hardware_structs",
1516
"//src/rp2_common:pico_platform",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
pico_simple_hardware_target(i2c)
2-
pico_mirrored_target_link_libraries(hardware_i2c INTERFACE pico_time hardware_resets hardware_clocks)
2+
pico_mirrored_target_link_libraries(hardware_i2c INTERFACE pico_time hardware_resets hardware_clocks pico_configurable_pins)

src/rp2_common/hardware_i2c/i2c.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -356,3 +356,16 @@ int i2c_read_burst_blocking(i2c_inst_t *i2c, uint8_t addr, uint8_t *dst, size_t
356356
i2c->restart_on_next = false;
357357
return rc;
358358
}
359+
360+
#if PICO_SUPPORT_CONFIGURABLE_PINS
361+
#include "pico/configurable_pins.h"
362+
i2c_inst_t *pico_get_default_i2c_instance(void) {
363+
if (pico_default_i2c == 0) {
364+
return i2c0;
365+
} else if (pico_default_i2c == 1) {
366+
return i2c1;
367+
} else {
368+
panic("Invalid I2C instance %d", pico_default_i2c);
369+
}
370+
}
371+
#endif

src/rp2_common/hardware_i2c/include/hardware/i2c.h

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -71,9 +71,15 @@ extern i2c_inst_t i2c1_inst;
7171
#define i2c0 (&i2c0_inst) ///< Identifier for I2C HW Block 0
7272
#define i2c1 (&i2c1_inst) ///< Identifier for I2C HW Block 1
7373

74-
#if !defined(PICO_DEFAULT_I2C_INSTANCE) && defined(PICO_DEFAULT_I2C)
74+
#if !defined(PICO_DEFAULT_I2C_INSTANCE)
75+
#if PICO_SUPPORT_CONFIGURABLE_PINS
76+
#include "pico/configurable_pins.h"
77+
i2c_inst_t *pico_get_default_i2c_instance(void);
78+
#define PICO_DEFAULT_I2C_INSTANCE() pico_get_default_i2c_instance()
79+
#elif defined(PICO_DEFAULT_I2C)
7580
#define PICO_DEFAULT_I2C_INSTANCE() (__CONCAT(i2c,PICO_DEFAULT_I2C))
7681
#endif
82+
#endif
7783

7884
/**
7985
* \def PICO_DEFAULT_I2C

src/rp2_common/hardware_spi/BUILD.bazel

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,7 @@ cc_library(
99
includes = ["include"],
1010
target_compatible_with = compatible_with_rp2(),
1111
deps = [
12+
"//src/common/pico_configurable_pins",
1213
"//src/rp2_common:hardware_regs",
1314
"//src/rp2_common:hardware_structs",
1415
"//src/rp2_common:pico_platform",
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
pico_simple_hardware_target(spi)
22

3-
pico_mirrored_target_link_libraries(hardware_spi INTERFACE hardware_resets hardware_clocks)
3+
pico_mirrored_target_link_libraries(hardware_spi INTERFACE hardware_resets hardware_clocks pico_configurable_pins)

0 commit comments

Comments
 (0)