Skip to content

Commit 5e9a5e8

Browse files
committed
Add Pico W and lwIP support
1 parent 77c04e4 commit 5e9a5e8

File tree

36 files changed

+2915
-13
lines changed

36 files changed

+2915
-13
lines changed

.gitmodules

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
[submodule "tinyusb"]
22
path = lib/tinyusb
33
url = https://github.com/hathach/tinyusb.git
4+
[submodule "lib/cyw43-driver"]
5+
path = lib/cyw43-driver
6+
url = https://github.com/georgerobotics/cyw43-driver.git
7+
[submodule "lib/lwip"]
8+
path = lib/lwip
9+
url = https://github.com/lwip-tcpip/lwip.git

README.md

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -110,6 +110,24 @@ instructions for other platforms, and just in general, we recommend you see [Ras
110110
111111
```
112112
113+
* Or by cloning the SDK locally, but without copying `pico_sdk_import.cmake`:
114+
1. `git clone` this Raspberry Pi Pico SDK repository
115+
2. Setup a `CMakeLists.txt` like:
116+
117+
```cmake
118+
cmake_minimum_required(VERSION 3.13)
119+
120+
# initialize the SDK directly
121+
include(/path/to/pico-sdk/pico_sdk_init.cmake)
122+
123+
project(my_project)
124+
125+
# initialize the Raspberry Pi Pico SDK
126+
pico_sdk_init()
127+
128+
# rest of your project
129+
130+
```
113131
1. Write your code (see [pico-examples](https://github.com/raspberrypi/pico-examples) or the [Raspberry Pi Pico C/C++ SDK](https://rptl.io/pico-c-sdk) documentation for more information)
114132
115133
About the simplest you can do is a single source file (e.g. hello_world.c)

docs/Doxyfile.in

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -60,4 +60,5 @@ PREDEFINED = __not_in_flash_func(x) \
6060
__time_critical_func(x) \
6161
__not_in_flash(x)= \
6262
__no_inline_not_in_flash(x)= \
63-
__attribute__(x)=
63+
__attribute__(x)= \
64+
DOXYGEN_GENERATION=

docs/index.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -56,6 +56,13 @@
5656
* \defgroup tinyusb_host tinyusb_host
5757
* @}
5858
*
59+
* \defgroup networking Networking Libraries
60+
* Functions for implementing networking
61+
* @{
62+
* \defgroup pico_lwip pico_lwip
63+
* \defgroup pico_cyw43_arch pico_cyw43_arch
64+
* @}
65+
*
5966
* \defgroup runtime Runtime Infrastructure
6067
* Libraries that are used to provide efficient implementation of certain
6168
* language level and C library functions, as well as CMake INTERFACE libraries

lib/cyw43-driver

Submodule cyw43-driver added at 195dfcc

lib/lwip

Submodule lwip added at 239918c

src/boards/include/boards/pico_w.h

Lines changed: 102 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,102 @@
1+
/*
2+
* Copyright (c) 2022 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/pico.h"
13+
14+
#ifndef _BOARDS_PICO_W_H
15+
#define _BOARDS_PICO_W_H
16+
17+
// For board detection
18+
#define RASPBERRYPI_PICO_W
19+
20+
// --- UART ---
21+
#ifndef PICO_DEFAULT_UART
22+
#define PICO_DEFAULT_UART 0
23+
#endif
24+
#ifndef PICO_DEFAULT_UART_TX_PIN
25+
#define PICO_DEFAULT_UART_TX_PIN 0
26+
#endif
27+
#ifndef PICO_DEFAULT_UART_RX_PIN
28+
#define PICO_DEFAULT_UART_RX_PIN 1
29+
#endif
30+
31+
// --- LED ---
32+
// no PICO_DEFAULT_LED_PIN - LED is on Wireless chip
33+
// no PICO_DEFAULT_WS2812_PIN
34+
35+
// --- I2C ---
36+
#ifndef PICO_DEFAULT_I2C
37+
#define PICO_DEFAULT_I2C 0
38+
#endif
39+
#ifndef PICO_DEFAULT_I2C_SDA_PIN
40+
#define PICO_DEFAULT_I2C_SDA_PIN 4
41+
#endif
42+
#ifndef PICO_DEFAULT_I2C_SCL_PIN
43+
#define PICO_DEFAULT_I2C_SCL_PIN 5
44+
#endif
45+
46+
// --- SPI ---
47+
#ifndef PICO_DEFAULT_SPI
48+
#define PICO_DEFAULT_SPI 0
49+
#endif
50+
#ifndef PICO_DEFAULT_SPI_SCK_PIN
51+
#define PICO_DEFAULT_SPI_SCK_PIN 18
52+
#endif
53+
#ifndef PICO_DEFAULT_SPI_TX_PIN
54+
#define PICO_DEFAULT_SPI_TX_PIN 19
55+
#endif
56+
#ifndef PICO_DEFAULT_SPI_RX_PIN
57+
#define PICO_DEFAULT_SPI_RX_PIN 16
58+
#endif
59+
#ifndef PICO_DEFAULT_SPI_CSN_PIN
60+
#define PICO_DEFAULT_SPI_CSN_PIN 17
61+
#endif
62+
63+
// --- FLASH ---
64+
65+
#define PICO_BOOT_STAGE2_CHOOSE_W25Q080 1
66+
67+
#ifndef PICO_FLASH_SPI_CLKDIV
68+
#define PICO_FLASH_SPI_CLKDIV 2
69+
#endif
70+
71+
#ifndef PICO_FLASH_SIZE_BYTES
72+
#define PICO_FLASH_SIZE_BYTES (2 * 1024 * 1024)
73+
#endif
74+
75+
// note the SMSP mode pin is on WL_GPIO1
76+
// #define PICO_SMPS_MODE_PIN
77+
78+
#ifndef PICO_RP2040_B0_SUPPORTED
79+
#define PICO_RP2040_B0_SUPPORTED 0
80+
#endif
81+
82+
#ifndef PICO_RP2040_B1_SUPPORTED
83+
#define PICO_RP2040_B1_SUPPORTED 0
84+
#endif
85+
86+
#ifndef CYW43_PIN_WL_HOST_WAKE
87+
#define CYW43_PIN_WL_HOST_WAKE 24
88+
#endif
89+
90+
#ifndef CYW43_PIN_WL_REG_ON
91+
#define CYW43_PIN_WL_REG_ON 23
92+
#endif
93+
94+
#ifndef CYW43_WL_GPIO_COUNT
95+
#define CYW43_WL_GPIO_COUNT 3
96+
#endif
97+
98+
#ifndef CYW43_WL_GPIO_LED_PIN
99+
#define CYW43_WL_GPIO_LED_PIN 0
100+
#endif
101+
102+
#endif

src/boards/pico_w.cmake

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,2 @@
1+
set(PICO_CYW43_SUPPORTED "1" CACHE INTERNAL "Try to add support for PICO_CYW43")
2+
include(${CMAKE_CURRENT_LIST_DIR}/generic_board.cmake)

src/common/pico_base/include/pico/error.h

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -10,14 +10,18 @@
1010
#ifndef __ASSEMBLER__
1111

1212
/*!
13-
* Common return codes from pico_sdk methods that return a status
13+
* \brief Common return codes from pico_sdk methods that return a status
14+
* \ingroup pico_base
1415
*/
15-
enum {
16+
enum pico_error_codes {
1617
PICO_OK = 0,
1718
PICO_ERROR_NONE = 0,
1819
PICO_ERROR_TIMEOUT = -1,
1920
PICO_ERROR_GENERIC = -2,
2021
PICO_ERROR_NO_DATA = -3,
22+
PICO_ERROR_NOT_PERMITTED = -4,
23+
PICO_ERROR_INVALID_ARG = -5,
24+
PICO_ERROR_IO = -6,
2125
};
2226

2327
#endif // !__ASSEMBLER__

src/rp2_common/CMakeLists.txt

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -58,6 +58,10 @@ if (NOT PICO_BARE_METAL)
5858
pico_add_subdirectory(tinyusb)
5959
pico_add_subdirectory(pico_stdio_usb)
6060

61+
pico_add_subdirectory(cyw43_driver)
62+
pico_add_subdirectory(pico_lwip)
63+
pico_add_subdirectory(pico_cyw43_arch)
64+
6165
pico_add_subdirectory(pico_stdlib)
6266

6367
pico_add_subdirectory(pico_cxx_options)

0 commit comments

Comments
 (0)