Skip to content

Commit 3745c39

Browse files
iabdalkaderdpgeorge
authored andcommitted
rp2: Add support for Nina-W10 WiFi/BT module.
This commit integrates the Nina-W10 driver as an optional component in the rp2 port.
1 parent 43079aa commit 3745c39

File tree

2 files changed

+44
-2
lines changed

2 files changed

+44
-2
lines changed

ports/rp2/CMakeLists.txt

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -166,6 +166,7 @@ if(MICROPY_PY_BLUETOOTH)
166166
list(APPEND MICROPY_SOURCE_PORT mpbthciport.c)
167167
target_compile_definitions(${MICROPY_TARGET} PRIVATE
168168
MICROPY_PY_BLUETOOTH=1
169+
MICROPY_PY_BLUETOOTH_USE_SYNC_EVENTS=1
169170
MICROPY_PY_BLUETOOTH_ENABLE_CENTRAL_MODE=1
170171
MICROPY_PY_BLUETOOTH_ENABLE_PAIRING_BONDING=1
171172
MICROPY_PY_BLUETOOTH_ENABLE_L2CAP_CHANNELS=1
@@ -188,6 +189,31 @@ if(MICROPY_BLUETOOTH_NIMBLE)
188189
list(APPEND MICROPY_INC_CORE ${NIMBLE_INCLUDE})
189190
endif()
190191

192+
if (MICROPY_PY_NETWORK_NINAW10)
193+
target_compile_definitions(${MICROPY_TARGET} PRIVATE
194+
MICROPY_PY_NETWORK_NINAW10=1
195+
)
196+
197+
target_include_directories(${MICROPY_TARGET} PRIVATE
198+
${MICROPY_DIR}/drivers/ninaw10/
199+
)
200+
201+
# Enable NINA-W10 WiFi and Bluetooth drivers.
202+
list(APPEND MICROPY_SOURCE_DRIVERS
203+
${MICROPY_DIR}/drivers/ninaw10/nina_bt_hci.c
204+
${MICROPY_DIR}/drivers/ninaw10/nina_wifi_drv.c
205+
${MICROPY_DIR}/drivers/ninaw10/nina_wifi_bsp.c
206+
)
207+
208+
list(APPEND MICROPY_SOURCE_EXTMOD
209+
${MICROPY_DIR}/extmod/network_ninaw10.c
210+
)
211+
212+
list(APPEND MICROPY_SOURCE_QSTR
213+
${MICROPY_DIR}/extmod/network_ninaw10.c
214+
)
215+
endif()
216+
191217
# Define mpy-cross flags and frozen manifest
192218
set(MICROPY_CROSS_FLAGS -march=armv7m)
193219
if (NOT MICROPY_FROZEN_MANIFEST)

ports/rp2/mpconfigport.h

Lines changed: 18 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -154,6 +154,20 @@ struct _mp_bluetooth_nimble_malloc_t;
154154
#define MICROPY_PORT_ROOT_POINTER_BLUETOOTH_NIMBLE
155155
#endif
156156

157+
#if MICROPY_PY_NETWORK_NINAW10
158+
// This Network interface requires the extended socket state.
159+
#ifndef MICROPY_PY_USOCKET_EXTENDED_STATE
160+
#define MICROPY_PY_USOCKET_EXTENDED_STATE (1)
161+
#endif
162+
// It also requires an additional root pointer for the SPI object.
163+
#define MICROPY_PORT_ROOT_POINTER_NINAW10 struct _machine_spi_obj_t *mp_wifi_spi;
164+
extern const struct _mod_network_nic_type_t mod_network_nic_type_nina;
165+
#define MICROPY_HW_NIC_NINAW10 { MP_ROM_QSTR(MP_QSTR_WLAN), MP_ROM_PTR(&mod_network_nic_type_nina) },
166+
#else
167+
#define MICROPY_HW_NIC_NINAW10
168+
#define MICROPY_PORT_ROOT_POINTER_NINAW10
169+
#endif
170+
157171
#define MICROPY_PORT_BUILTIN_MODULES \
158172
{ MP_OBJ_NEW_QSTR(MP_QSTR_machine), (mp_obj_t)&mp_module_machine }, \
159173
{ MP_OBJ_NEW_QSTR(MP_QSTR__onewire), (mp_obj_t)&mp_module_onewire }, \
@@ -163,12 +177,13 @@ struct _mp_bluetooth_nimble_malloc_t;
163177
SOCKET_BUILTIN_MODULE \
164178
NETWORK_BUILTIN_MODULE \
165179

180+
#define MICROPY_PORT_NETWORK_INTERFACES \
181+
MICROPY_HW_NIC_NINAW10 \
182+
166183
#ifndef MICROPY_BOARD_ROOT_POINTERS
167184
#define MICROPY_BOARD_ROOT_POINTERS
168185
#endif
169186

170-
#define MICROPY_PORT_NETWORK_INTERFACES \
171-
172187
#define MICROPY_PORT_ROOT_POINTERS \
173188
const char *readline_hist[8]; \
174189
void *machine_pin_irq_obj[30]; \
@@ -179,6 +194,7 @@ struct _mp_bluetooth_nimble_malloc_t;
179194
void *machine_i2s_obj[2]; \
180195
NETWORK_ROOT_POINTERS \
181196
MICROPY_BOARD_ROOT_POINTERS \
197+
MICROPY_PORT_ROOT_POINTER_NINAW10 \
182198
MICROPY_PORT_ROOT_POINTER_BLUETOOTH \
183199
MICROPY_PORT_ROOT_POINTER_BLUETOOTH_NIMBLE \
184200

0 commit comments

Comments
 (0)