Skip to content

Commit af2f426

Browse files
Changes for pico2_w (#1816)
* Add board file for pico2_w This is a copy of pico2 with the definitions from pico_w added. Set PICO_BOARD=pico2_w * Simplify CYW43 PIO config cyw43_spi_init contains code to find a free PIO and state machine. This can all be replaced with pio_claim_free_sm_and_add_program_for_gpio_range * Make CYW43 gpio pins configurable at build time The CYW43 gpio pins are currently hardcoded. Give the defines better names and make them overrideable at build time. Note: CYW43_PIN_WL_REG_ON and CYW43_PIN_WL_HOST_WAKE are already used by the driver via cyw43_hal_* functions * Fix pio initialisation Need to make sure the pio can work with all the gpios * Add missing doxygen for cyw43_set_pio_clock_divisor * Support dynamic configuration of cyw43 gpio pins Add CYW43_PIN_WL_DYNAMIC that means cyw43 gpio pins can be changed at runtime. Then CYW43_PIN_WL_* calls cyw43_get_pin_wl to get the gpio out of the array. cyw43_set_pins_wl can be used to change the cyw43 gpio pins although care is needed when calling this? * Some fixes for cyw32 gpio > 32 * Allow CYW43 to be configured with cmake * Add default config of CYW43_WL_GPIO_COUNT to cyw43_configport.h * Fix some review comments Add some PICO_CMAKE_CONFIG Stop using gpio_*_mask64 functions
1 parent 6500c59 commit af2f426

File tree

6 files changed

+351
-85
lines changed

6 files changed

+351
-85
lines changed
Lines changed: 116 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,116 @@
1+
/*
2+
* Copyright (c) 2024 Raspberry Pi (Trading) Ltd.
3+
*
4+
* SPDX-License-Identifier: BSD-3-Clause
5+
*/
6+
7+
// -----------------------------------------------------
8+
// NOTE: THIS HEADER IS ALSO INCLUDED BY ASSEMBLER SO
9+
// SHOULD ONLY CONSIST OF PREPROCESSOR DIRECTIVES
10+
// -----------------------------------------------------
11+
12+
// This header may be included by other board headers as "boards/pico2_w.h"
13+
14+
// pico_cmake_set PICO_PLATFORM=rp2350
15+
// pico_cmake_set PICO_CYW43_SUPPORTED = 1
16+
17+
#ifndef _BOARDS_PICO2_W_H
18+
#define _BOARDS_PICO2_W_H
19+
20+
// For board detection
21+
#define RASPBERRYPI_PICO2_W
22+
23+
// --- RP2350 VARIANT ---
24+
#define PICO_RP2350A 1
25+
26+
// --- UART ---
27+
#ifndef PICO_DEFAULT_UART
28+
#define PICO_DEFAULT_UART 0
29+
#endif
30+
#ifndef PICO_DEFAULT_UART_TX_PIN
31+
#define PICO_DEFAULT_UART_TX_PIN 0
32+
#endif
33+
#ifndef PICO_DEFAULT_UART_RX_PIN
34+
#define PICO_DEFAULT_UART_RX_PIN 1
35+
#endif
36+
37+
// --- LED ---
38+
// no PICO_DEFAULT_LED_PIN - LED is on Wireless chip
39+
// no PICO_DEFAULT_WS2812_PIN
40+
41+
// --- I2C ---
42+
#ifndef PICO_DEFAULT_I2C
43+
#define PICO_DEFAULT_I2C 0
44+
#endif
45+
#ifndef PICO_DEFAULT_I2C_SDA_PIN
46+
#define PICO_DEFAULT_I2C_SDA_PIN 4
47+
#endif
48+
#ifndef PICO_DEFAULT_I2C_SCL_PIN
49+
#define PICO_DEFAULT_I2C_SCL_PIN 5
50+
#endif
51+
52+
// --- SPI ---
53+
#ifndef PICO_DEFAULT_SPI
54+
#define PICO_DEFAULT_SPI 0
55+
#endif
56+
#ifndef PICO_DEFAULT_SPI_SCK_PIN
57+
#define PICO_DEFAULT_SPI_SCK_PIN 18
58+
#endif
59+
#ifndef PICO_DEFAULT_SPI_TX_PIN
60+
#define PICO_DEFAULT_SPI_TX_PIN 19
61+
#endif
62+
#ifndef PICO_DEFAULT_SPI_RX_PIN
63+
#define PICO_DEFAULT_SPI_RX_PIN 16
64+
#endif
65+
#ifndef PICO_DEFAULT_SPI_CSN_PIN
66+
#define PICO_DEFAULT_SPI_CSN_PIN 17
67+
#endif
68+
69+
// --- FLASH ---
70+
71+
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
72+
73+
#ifndef PICO_FLASH_SPI_CLKDIV
74+
#define PICO_FLASH_SPI_CLKDIV 2
75+
#endif
76+
77+
// pico_cmake_set_default PICO_FLASH_SIZE_BYTES = (4 * 1024 * 1024)
78+
#ifndef PICO_FLASH_SIZE_BYTES
79+
#define PICO_FLASH_SIZE_BYTES (4 * 1024 * 1024)
80+
#endif
81+
// Drive high to force power supply into PWM mode (lower ripple on 3V3 at light loads)
82+
// note the SMSP mode pin is on WL_GPIO1
83+
84+
#ifndef CYW43_WL_GPIO_COUNT
85+
#define CYW43_WL_GPIO_COUNT 3
86+
#endif
87+
88+
#ifndef CYW43_WL_GPIO_LED_PIN
89+
#define CYW43_WL_GPIO_LED_PIN 0
90+
#endif
91+
92+
// If CYW43_WL_GPIO_VBUS_PIN is defined then a CYW43 GPIO has to be used to read VBUS.
93+
// This can be passed to cyw43_arch_gpio_get to determine if the device is battery powered.
94+
// PICO_VBUS_PIN and CYW43_WL_GPIO_VBUS_PIN should not both be defined.
95+
#ifndef CYW43_WL_GPIO_VBUS_PIN
96+
#define CYW43_WL_GPIO_VBUS_PIN 2
97+
#endif
98+
99+
// If CYW43_USES_VSYS_PIN is defined then CYW43 uses the VSYS GPIO (defined by PICO_VSYS_PIN) for other purposes.
100+
// If this is the case, to use the VSYS GPIO it's necessary to ensure CYW43 is not using it.
101+
// This can be achieved by wrapping the use of the VSYS GPIO in cyw43_thread_enter / cyw43_thread_exit.
102+
#ifndef CYW43_USES_VSYS_PIN
103+
#define CYW43_USES_VSYS_PIN 1
104+
#endif
105+
106+
// The GPIO Pin used to monitor VSYS. Typically you would use this with ADC.
107+
// There is an example in adc/read_vsys in pico-examples.
108+
#ifndef PICO_VSYS_PIN
109+
#define PICO_VSYS_PIN 29
110+
#endif
111+
112+
#ifndef PICO_RP2350_A2_SUPPORTED
113+
#define PICO_RP2350_A2_SUPPORTED 1
114+
#endif
115+
116+
#endif

src/boards/include/boards/pico_w.h

Lines changed: 0 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -86,14 +86,6 @@
8686
#define PICO_RP2040_B1_SUPPORTED 0
8787
#endif
8888

89-
#ifndef CYW43_PIN_WL_HOST_WAKE
90-
#define CYW43_PIN_WL_HOST_WAKE 24
91-
#endif
92-
93-
#ifndef CYW43_PIN_WL_REG_ON
94-
#define CYW43_PIN_WL_REG_ON 23
95-
#endif
96-
9789
#ifndef CYW43_WL_GPIO_COUNT
9890
#define CYW43_WL_GPIO_COUNT 3
9991
#endif

src/rp2_common/pico_cyw43_driver/CMakeLists.txt

Lines changed: 37 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,43 @@ if (EXISTS ${PICO_CYW43_DRIVER_PATH}/${CYW43_DRIVER_TEST_FILE})
5656
hardware_exception
5757
)
5858

59+
if (CYW43_DEFAULT_PIN_WL_REG_ON)
60+
# PICO_CMAKE_CONFIG: CYW43_DEFAULT_PIN_WL_REG_ON, gpio pin to power up the cyw43 chip, type=int, default=23, group=pico_cyw43_driver
61+
target_compile_definitions(cyw43_driver_picow INTERFACE CYW43_DEFAULT_PIN_WL_REG_ON=${CYW43_DEFAULT_PIN_WL_REG_ON})
62+
endif()
63+
if (CYW43_DEFAULT_PIN_WL_DATA_OUT)
64+
# PICO_CMAKE_CONFIG: CYW43_DEFAULT_PIN_WL_DATA_OUT, gpio pin for spi data out to the cyw43 chip, type=int, default=24, group=pico_cyw43_driver
65+
target_compile_definitions(cyw43_driver_picow INTERFACE CYW43_DEFAULT_PIN_WL_DATA_OUT=${CYW43_DEFAULT_PIN_WL_DATA_OUT})
66+
endif()
67+
if (CYW43_DEFAULT_PIN_WL_DATA_IN)
68+
# PICO_CMAKE_CONFIG: CYW43_DEFAULT_PIN_WL_DATA_IN, gpio pin for spi data in from the cyw43 chip, type=int, default=24, group=pico_cyw43_driver
69+
target_compile_definitions(cyw43_driver_picow INTERFACE CYW43_DEFAULT_PIN_WL_DATA_IN=${CYW43_DEFAULT_PIN_WL_DATA_IN})
70+
endif()
71+
if (CYW43_DEFAULT_PIN_WL_HOST_WAKE)
72+
# PICO_CMAKE_CONFIG: CYW43_DEFAULT_PIN_WL_HOST_WAKE, gpio (irq) pin for the irq line from the cyw43 chip, type=int, default=24, group=pico_cyw43_driver
73+
target_compile_definitions(cyw43_driver_picow INTERFACE CYW43_DEFAULT_PIN_WL_HOST_WAKE=${CYW43_DEFAULT_PIN_WL_HOST_WAKE})
74+
endif()
75+
if (CYW43_DEFAULT_PIN_WL_CLOCK)
76+
# PICO_CMAKE_CONFIG: CYW43_DEFAULT_PIN_WL_HOST_WAKE, gpio pin for the spi clock line to the cyw43 chip, type=int, default=29, group=pico_cyw43_driver
77+
target_compile_definitions(cyw43_driver_picow INTERFACE CYW43_DEFAULT_PIN_WL_CLOCK=${CYW43_DEFAULT_PIN_WL_CLOCK})
78+
endif()
79+
if (CYW43_DEFAULT_PIN_WL_CS)
80+
# PICO_CMAKE_CONFIG: CYW43_DEFAULT_PIN_WL_CS, gpio pin for the spi chip select to the cyw43 chip, type=int, default=25, group=pico_cyw43_driver
81+
target_compile_definitions(cyw43_driver_picow INTERFACE CYW43_DEFAULT_PIN_WL_CS=${CYW43_DEFAULT_PIN_WL_CS})
82+
endif()
83+
if (CYW43_PIO_CLOCK_DIV_INT)
84+
# PICO_CMAKE_CONFIG: CYW43_PIO_CLOCK_DIV_INT, integer component of pio clock divider used for cyw43 comms, type=int, default=2, group=pico_cyw43_driver
85+
target_compile_definitions(cyw43_driver_picow INTERFACE CYW43_PIO_CLOCK_DIV_INT=${CYW43_PIO_CLOCK_DIV_INT})
86+
endif()
87+
if (CYW43_PIO_CLOCK_DIV_FRAC)
88+
# PICO_CMAKE_CONFIG: CYW43_PIO_CLOCK_DIV_FRAC, fractional component of pio clock divider used for cyw43 comms, type=int, default=0, group=pico_cyw43_driver
89+
target_compile_definitions(cyw43_driver_picow INTERFACE CYW43_PIO_CLOCK_DIV_FRAC=${CYW43_PIO_CLOCK_DIV_FRAC})
90+
endif()
91+
if (CYW43_PIO_CLOCK_DIV_DYNAMIC)
92+
# PICO_CMAKE_CONFIG: CYW43_PIO_CLOCK_DIV_DYNAMIC, flag used to enable dynamic pio clock divider API, type=bool, default=false, group=pico_cyw43_driver
93+
target_compile_definitions(cyw43_driver_picow INTERFACE CYW43_PIO_CLOCK_DIV_DYNAMIC=${CYW43_PIO_CLOCK_DIV_DYNAMIC})
94+
endif()
95+
5996
# Note: This is used by MP, so check for issues when making changes
6097
# e.g. Don't add new depenedences
6198
pico_add_library(pico_btstack_hci_transport_cyw43 NOFLAG)

0 commit comments

Comments
 (0)