Skip to content

Commit e33623a

Browse files
committed
Merge branch 'pico2_w_changes' into sfe_rp2350_beta_05
2 parents 406bccc + 2172c8f commit e33623a

34 files changed

+561
-114
lines changed

extmod/modbluetooth.c

Lines changed: 17 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -257,11 +257,24 @@ MP_DEFINE_CONST_OBJ_TYPE(
257257
// Bluetooth object: General
258258
// ----------------------------------------------------------------------------
259259

260+
// Allow the port to add extra parameters
261+
#ifdef MICROPY_PY_BLUETOOTH_OBJ_INIT_ARGS
262+
#define EXTRA_ARGS MICROPY_PY_BLUETOOTH_OBJ_INIT_ARGS
263+
#else
264+
#define EXTRA_ARGS
265+
#endif
266+
267+
MP_WEAK void bluetooth_ble_obj_init(mp_arg_val_t *args) {
268+
}
269+
260270
static mp_obj_t bluetooth_ble_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
261-
(void)type;
262-
(void)n_args;
263-
(void)n_kw;
264-
(void)all_args;
271+
const mp_arg_t allowed_args[] = {
272+
EXTRA_ARGS
273+
};
274+
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
275+
mp_arg_parse_all_kw_array(n_args, n_kw, all_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
276+
bluetooth_ble_obj_init(args);
277+
265278
if (MP_STATE_VM(bluetooth) == MP_OBJ_NULL) {
266279
mp_obj_bluetooth_ble_t *o = m_new0(mp_obj_bluetooth_ble_t, 1);
267280
o->base.type = &mp_type_bluetooth_ble;

extmod/network_cyw43.c

Lines changed: 24 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -93,14 +93,35 @@ static void network_cyw43_print(const mp_print_t *print, mp_obj_t self_in, mp_pr
9393
);
9494
}
9595

96-
static mp_obj_t network_cyw43_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *args) {
97-
mp_arg_check_num(n_args, n_kw, 0, 1, false);
98-
if (n_args == 0 || mp_obj_get_int(args[0]) == MOD_NETWORK_STA_IF) {
96+
// Allow the port to add extra parameters
97+
#ifdef MICROPY_PY_NETWORK_CYW43_OBJ_INIT_ARGS
98+
#define EXTRA_ARGS MICROPY_PY_NETWORK_CYW43_OBJ_INIT_ARGS
99+
#else
100+
#define EXTRA_ARGS
101+
#endif
102+
103+
MP_WEAK void network_cyw43_obj_init(mp_arg_val_t *args) {
104+
}
105+
106+
static mp_obj_t network_cyw43_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
107+
enum { ARG_interface, ARG_last };
108+
const mp_arg_t allowed_args[] = {
109+
{ MP_QSTR_interface, MP_ARG_INT, {.u_int = MOD_NETWORK_STA_IF} },
110+
EXTRA_ARGS
111+
};
112+
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
113+
mp_map_t kw_args;
114+
mp_map_init_fixed_table(&kw_args, n_kw, all_args + n_args);
115+
mp_arg_parse_all(n_args, all_args, &kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
116+
117+
network_cyw43_obj_init(args + ARG_last);
118+
if (args[ARG_interface].u_int == MOD_NETWORK_STA_IF) {
99119
return MP_OBJ_FROM_PTR(&network_cyw43_wl_sta);
100120
} else {
101121
return MP_OBJ_FROM_PTR(&network_cyw43_wl_ap);
102122
}
103123
}
124+
#undef EXTRA_ARGS
104125

105126
static mp_obj_t network_cyw43_send_ethernet(mp_obj_t self_in, mp_obj_t buf_in) {
106127
network_cyw43_obj_t *self = MP_OBJ_TO_PTR(self_in);

lib/pico-sdk

Submodule pico-sdk updated 265 files

ports/rp2/CMakeLists.txt

Lines changed: 15 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -195,7 +195,14 @@ set(MICROPY_SOURCE_QSTR
195195
${CMAKE_BINARY_DIR}/pins_${MICROPY_BOARD}.c
196196
)
197197

198+
if (MICROPY_PY_NETWORK_CYW43)
199+
list(APPEND MICROPY_SOURCE_QSTR
200+
${MICROPY_PORT_DIR}/rp2_init_cyw43.c
201+
)
202+
endif()
203+
198204
set(PICO_SDK_COMPONENTS
205+
boot_bootrom_headers
199206
hardware_adc
200207
hardware_base
201208
hardware_boot_lock
@@ -222,6 +229,7 @@ set(PICO_SDK_COMPONENTS
222229
pico_base_headers
223230
pico_binary_info
224231
pico_bootrom
232+
pico_flash
225233
pico_multicore
226234
pico_platform
227235
pico_platform_compiler
@@ -401,11 +409,11 @@ if (MICROPY_PY_NETWORK_CYW43)
401409

402410
list(APPEND MICROPY_SOURCE_PORT
403411
machine_pin_cyw43.c
412+
rp2_init_cyw43.c
404413
)
405414

406415
target_link_libraries(${MICROPY_TARGET}
407416
cyw43_driver_picow
408-
cmsis_core
409417
)
410418
target_include_directories(${MICROPY_TARGET} PRIVATE
411419
${MICROPY_DIR}/lib/cyw43-driver/
@@ -631,8 +639,12 @@ if(NOT PICO_NUM_EXT_GPIOS)
631639
set(PICO_NUM_EXT_GPIOS 10)
632640
endif()
633641

634-
if(EXISTS "${MICROPY_BOARD_DIR}/pins.csv")
635-
set(GEN_PINS_BOARD_CSV "${MICROPY_BOARD_DIR}/pins.csv")
642+
if (NOT PICO_PINS_CSV_NAME)
643+
set(PICO_PINS_CSV_NAME pins.csv)
644+
endif()
645+
646+
if(EXISTS "${MICROPY_BOARD_DIR}/${PICO_PINS_CSV_NAME}")
647+
set(GEN_PINS_BOARD_CSV "${MICROPY_BOARD_DIR}/${PICO_PINS_CSV_NAME}")
636648
set(GEN_PINS_CSV_ARG --board-csv "${GEN_PINS_BOARD_CSV}")
637649
endif()
638650

ports/rp2/Makefile

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -30,26 +30,26 @@ endif
3030

3131
$(VERBOSE)MAKESILENT = -s
3232

33-
CMAKE_ARGS += -DMICROPY_BOARD=$(BOARD) -DMICROPY_BOARD_DIR="$(abspath $(BOARD_DIR))"
33+
override CMAKE_ARGS += -DMICROPY_BOARD=$(BOARD) -DMICROPY_BOARD_DIR="$(abspath $(BOARD_DIR))"
3434

3535
ifdef USER_C_MODULES
36-
CMAKE_ARGS += -DUSER_C_MODULES=${USER_C_MODULES}
36+
override CMAKE_ARGS += -DUSER_C_MODULES=${USER_C_MODULES}
3737
endif
3838

3939
ifneq ($(FROZEN_MANIFEST),)
40-
CMAKE_ARGS += -DMICROPY_FROZEN_MANIFEST=${FROZEN_MANIFEST}
40+
override CMAKE_ARGS += -DMICROPY_FROZEN_MANIFEST=${FROZEN_MANIFEST}
4141
endif
4242

4343
ifeq ($(DEBUG),1)
44-
CMAKE_ARGS += -DCMAKE_BUILD_TYPE=Debug
44+
override CMAKE_ARGS += -DCMAKE_BUILD_TYPE=Debug
4545
endif
4646

4747
ifdef BOARD_VARIANT
48-
CMAKE_ARGS += -DMICROPY_BOARD_VARIANT=$(BOARD_VARIANT)
48+
override CMAKE_ARGS += -DMICROPY_BOARD_VARIANT=$(BOARD_VARIANT)
4949
endif
5050

5151
ifdef MICROPY_PREVIEW_VERSION_2
52-
CMAKE_ARGS += -DMICROPY_PREVIEW_VERSION_2=1
52+
override CMAKE_ARGS += -DMICROPY_PREVIEW_VERSION_2=1
5353
endif
5454

5555
HELP_BUILD_ERROR ?= "See \033[1;31mhttps://github.com/micropython/micropython/wiki/Build-Troubleshooting\033[0m"

ports/rp2/boards/RPI_PICO/manifest.py

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file is only used if cyw43 is enabled
2+
include("$(PORT_DIR)/boards/manifest.py")
3+
4+
require("bundle-networking")
5+
6+
# Bluetooth
7+
require("aioble")
Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,9 @@
11
# cmake file for Raspberry Pi Pico
22
set(PICO_BOARD "pico")
33
set(PICO_PLATFORM "rp2040")
4+
5+
if (PICO_CYW43_SUPPORTED)
6+
include(enable_cyw43.cmake)
7+
set(MICROPY_FROZEN_MANIFEST ${MICROPY_BOARD_DIR}/manifest.py)
8+
set(PICO_PINS_CSV_NAME pins_cyw43.csv)
9+
endif()
Lines changed: 23 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,26 @@
11
// Board and hardware specific configuration
22
#define MICROPY_HW_BOARD_NAME "Raspberry Pi Pico"
3+
4+
#if MICROPY_PY_NETWORK_CYW43
5+
#include "enable_cyw43.h"
6+
7+
// Enable the ability to pass cyw43 pins into WiFi, Bluetooth and Pin constructors
8+
#define CYW43_PIN_WL_DYNAMIC 1
9+
#define CYW43_PIO_CLOCK_DIV_DYNAMIC 1
10+
11+
// Set the default pins to gpios 2-5
12+
#define CYW43_DEFAULT_PIN_WL_REG_ON 2
13+
#define CYW43_DEFAULT_PIN_WL_CS 3
14+
#define CYW43_DEFAULT_PIN_WL_DATA_OUT 4
15+
#define CYW43_DEFAULT_PIN_WL_DATA_IN 4
16+
#define CYW43_DEFAULT_PIN_WL_HOST_WAKE 4
17+
#define CYW43_DEFAULT_PIN_WL_CLOCK 5
18+
19+
// Default pio clock
20+
#define CYW43_PIO_CLOCK_DIV_INT 3
21+
22+
// we have to reduce the flash storage if cyw43 is enabled or else the firmware gets overwritten
23+
#define MICROPY_HW_FLASH_STORAGE_BYTES (848 * 1024)
24+
#else
325
#define MICROPY_HW_FLASH_STORAGE_BYTES (1408 * 1024)
26+
#endif
Lines changed: 31 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,31 @@
1+
GP0,GPIO0
2+
GP1,GPIO1
3+
GP2,GPIO2
4+
GP3,GPIO3
5+
GP4,GPIO4
6+
GP5,GPIO5
7+
GP6,GPIO6
8+
GP7,GPIO7
9+
GP8,GPIO8
10+
GP9,GPIO9
11+
GP10,GPIO10
12+
GP11,GPIO11
13+
GP12,GPIO12
14+
GP13,GPIO13
15+
GP14,GPIO14
16+
GP15,GPIO15
17+
GP16,GPIO16
18+
GP17,GPIO17
19+
GP18,GPIO18
20+
GP19,GPIO19
21+
GP20,GPIO20
22+
GP21,GPIO21
23+
GP22,GPIO22
24+
GP25,GPIO25
25+
GP26,GPIO26
26+
GP27,GPIO27
27+
GP28,GPIO28
28+
LED,GPIO25
29+
WL_GPIO0,EXT_GPIO0
30+
WL_GPIO1,EXT_GPIO1
31+
WL_GPIO2,EXT_GPIO2
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
# This file is only used if cyw43 is enabled
2+
include("$(PORT_DIR)/boards/manifest.py")
3+
4+
require("bundle-networking")
5+
6+
# Bluetooth
7+
require("aioble")

0 commit comments

Comments
 (0)