Skip to content

Commit 7aa13ed

Browse files
committed
Restructure: Move Wiznet PIO SPI code to new wiznet module
1 parent a5864a1 commit 7aa13ed

File tree

16 files changed

+82
-47
lines changed

16 files changed

+82
-47
lines changed

data/nvm.toml

ports/raspberrypi/Makefile

Lines changed: 15 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -83,13 +83,13 @@ SRC_CYW43 :=
8383
SRC_LWIP :=
8484
endif
8585

86-
ifeq ($(CIRCUITPY_WIZNET_PIO_SPI), 1)
87-
INC_WIZNET_PIO_SPI := \
88-
-isystem wiznet_pio_spi \
89-
90-
SRC_WIZNET_PIO_SPI := \
91-
wiznet_pio_spi/wizchip_pio_spi.c \
86+
ifeq ($(CIRCUITPY_WIZNET), 1)
87+
INC_WIZNET := \
88+
-isystem common-hal/wiznet \
9289

90+
SRC_WIZNET := \
91+
common-hal/wiznet/wizchip_pio_spi.c \
92+
9393
WIZNET_PIOASM = $(BUILD)/pioasm/pioasm/pioasm
9494
.PHONY: pioasmBuild
9595
pioasmBuild: $(WIZNET_PIOASM)
@@ -98,15 +98,15 @@ $(WIZNET_PIOASM):
9898
$(Q)cmake -S pioasm -B $(BUILD)/pioasm
9999
$(MAKE) -C $(BUILD)/pioasm pioasmBuild
100100

101-
$(BUILD)/wizchip_pio_spi.pio.h: wiznet_pio_spi/wizchip_pio_spi.pio $(WIZNET_PIOASM)
101+
$(BUILD)/wizchip_pio_spi.pio.h: common-hal/wiznet/wizchip_pio_spi.pio $(WIZNET_PIOASM)
102102
$(Q)$(WIZNET_PIOASM) -o c-sdk $< $@
103-
$(BUILD)/wiznet_pio_spi/wizchip_pio_spi.o: $(BUILD)/wizchip_pio_spi.pio.h
103+
$(BUILD)/common-hal/wiznet/wizchip_pio_spi.o: $(BUILD)/wizchip_pio_spi.pio.h
104104

105105
$(BUILD)/genhdr/qstr.i.last: $(BUILD)/wizchip_pio_spi.pio.h
106106

107107
else
108-
INC_WIZNET_PIO_SPI :=
109-
SRC_WIZNET_PIO_SPI :=
108+
INC_WIZNET :=
109+
SRC_WIZNET :=
110110

111111
endif
112112

@@ -182,7 +182,6 @@ INC += \
182182
-isystem sdk/src/rp2_common/pico_time_adapter/include/ \
183183
-isystem sdk/src/rp2_common/pico_unique_id/include/ \
184184
$(INC_CYW43) \
185-
$(INC_WIZNET_PIO_SPI) \
186185
-Isdk_config \
187186
-I../../lib/tinyusb/src \
188187
-I../../supervisor/shared/usb \
@@ -560,6 +559,10 @@ SRC_C += \
560559
bindings/rp2pio/__init__.c \
561560
common-hal/rp2pio/StateMachine.c \
562561
common-hal/rp2pio/__init__.c \
562+
bindings/wiznet/PIO_SPI.c \
563+
bindings/wiznet/__init__.c \
564+
common-hal/wiznet/PIO_SPI.c \
565+
common-hal/wiznet/__init__.c \
563566
audio_dma.c \
564567
background.c \
565568
peripherals/pins.c \
@@ -569,7 +572,7 @@ SRC_C += \
569572
mphalport.c \
570573
$(SRC_CYW43) \
571574
$(SRC_LWIP) \
572-
$(SRC_WIZNET_PIO_SPI) \
575+
$(SRC_WIZNET) \
573576

574577

575578
ifeq ($(CIRCUITPY_USB_HOST), 1)

shared-bindings/busio/WIZNET_PIO_SPI.c renamed to ports/raspberrypi/bindings/wiznet/PIO_SPI.c

Lines changed: 11 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -11,7 +11,7 @@
1111
#include <string.h>
1212

1313
#include "shared-bindings/microcontroller/Pin.h"
14-
#include "shared-bindings/busio/WIZNET_PIO_SPI.h"
14+
#include "bindings/wiznet/PIO_SPI.h"
1515
#include "shared-bindings/util.h"
1616

1717
#include "shared/runtime/buffer_helper.h"
@@ -26,8 +26,8 @@
2626

2727

2828
static mp_obj_t wiznet_pio_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
29-
#if CIRCUITPY_WIZNET_PIO_SPI
30-
wiznet_pio_spi_obj_t *self = mp_obj_malloc(wiznet_pio_spi_obj_t, &busio_wiznet_pio_spi_type);
29+
#if CIRCUITPY_WIZNET
30+
wiznet_pio_spi_obj_t *self = mp_obj_malloc(wiznet_pio_spi_obj_t, &wiznet_pio_spi_type);
3131
enum { ARG_clock, ARG_MOSI, ARG_MISO, ARG_half_duplex };
3232
static const mp_arg_t allowed_args[] = {
3333
{ MP_QSTR_clock, MP_ARG_REQUIRED | MP_ARG_OBJ },
@@ -50,10 +50,10 @@ static mp_obj_t wiznet_pio_spi_make_new(const mp_obj_type_t *type, size_t n_args
5050
return MP_OBJ_FROM_PTR(self);
5151
#else
5252
mp_raise_NotImplementedError(NULL);
53-
#endif // CIRCUITPY_WIZNET_PIO_SPI
53+
#endif // CIRCUITPY_WIZNET
5454
}
5555

56-
#if CIRCUITPY_WIZNET_PIO_SPI
56+
#if CIRCUITPY_WIZNET
5757

5858
// TODO: def deinit
5959

@@ -266,10 +266,10 @@ static mp_obj_t wiznet_pio_spi_write_readinto(size_t n_args, const mp_obj_t *pos
266266
}
267267
MP_DEFINE_CONST_FUN_OBJ_KW(wiznet_pio_spi_write_readinto_obj, 1, wiznet_pio_spi_write_readinto);
268268

269-
#endif // CIRCUITPY_WIZNET_PIO_SPI
269+
#endif // CIRCUITPY_WIZNET
270270

271271
static const mp_rom_map_elem_t wiznet_pio_spi_locals_dict_table[] = {
272-
#if CIRCUITPY_WIZNET_PIO_SPI
272+
#if CIRCUITPY_WIZNET
273273
{ MP_ROM_QSTR(MP_QSTR_deinit), MP_ROM_PTR(&wiznet_pio_spi_deinit_obj) },
274274
{ MP_ROM_QSTR(MP_QSTR___enter__), MP_ROM_PTR(&default___enter___obj) },
275275
{ MP_ROM_QSTR(MP_QSTR___exit__), MP_ROM_PTR(&default___exit___obj) },
@@ -282,18 +282,18 @@ static const mp_rom_map_elem_t wiznet_pio_spi_locals_dict_table[] = {
282282
{ MP_ROM_QSTR(MP_QSTR_write), MP_ROM_PTR(&wiznet_pio_spi_write_obj) },
283283
{ MP_ROM_QSTR(MP_QSTR_write_readinto), MP_ROM_PTR(&wiznet_pio_spi_write_readinto_obj) },
284284

285-
#endif // CIRCUITPY_WIZNET_PIO_SPI
285+
#endif // CIRCUITPY_WIZNET
286286
};
287287
static MP_DEFINE_CONST_DICT(wiznet_pio_spi_locals_dict, wiznet_pio_spi_locals_dict_table);
288288

289289
MP_DEFINE_CONST_OBJ_TYPE(
290-
busio_wiznet_pio_spi_type,
291-
MP_QSTR_WIZNET_PIO_SPI,
290+
wiznet_pio_spi_type,
291+
MP_QSTR_PIO_SPI,
292292
MP_TYPE_FLAG_NONE,
293293
make_new, wiznet_pio_spi_make_new,
294294
locals_dict, &wiznet_pio_spi_locals_dict
295295
);
296296

297297
wiznet_pio_spi_obj_t *validate_obj_is_wiznet_pio_spi_bus(mp_obj_t obj, qstr arg_name) {
298-
return mp_arg_validate_type(obj, &busio_wiznet_pio_spi_type, arg_name);
298+
return mp_arg_validate_type(obj, &wiznet_pio_spi_type, arg_name);
299299
}

shared-bindings/busio/WIZNET_PIO_SPI.h renamed to ports/raspberrypi/bindings/wiznet/PIO_SPI.h

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -9,10 +9,10 @@
99
#include "py/obj.h"
1010

1111
#include "common-hal/microcontroller/Pin.h"
12-
#include "common-hal/busio/WIZNET_PIO_SPI.h"
12+
#include "common-hal/wiznet/PIO_SPI.h"
1313

1414
// Type object used in Python. Should be shared between ports.
15-
extern const mp_obj_type_t busio_wiznet_pio_spi_type;
15+
extern const mp_obj_type_t wiznet_pio_spi_type;
1616

1717
// Construct an underlying SPI object.
1818
extern void common_hal_wiznet_pio_spi_construct(wiznet_pio_spi_obj_t *self,
Lines changed: 29 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,29 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2016 Scott Shawcroft for Adafruit Industries
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#include <stdint.h>
8+
9+
#include "py/obj.h"
10+
#include "py/runtime.h"
11+
12+
#include "shared-bindings/microcontroller/Pin.h"
13+
#include "bindings/wiznet/PIO_SPI.h"
14+
15+
#include "py/runtime.h"
16+
17+
static const mp_rom_map_elem_t wiznet_module_globals_table[] = {
18+
{ MP_ROM_QSTR(MP_QSTR___name__), MP_ROM_QSTR(MP_QSTR_wiznet) },
19+
{ MP_ROM_QSTR(MP_QSTR_PIO_SPI), MP_ROM_PTR(&wiznet_pio_spi_type) },
20+
};
21+
22+
static MP_DEFINE_CONST_DICT(wiznet_module_globals, wiznet_module_globals_table);
23+
24+
const mp_obj_module_t wiznet_module = {
25+
.base = { &mp_type_module },
26+
.globals = (mp_obj_dict_t *)&wiznet_module_globals,
27+
};
28+
29+
MP_REGISTER_MODULE(MP_QSTR_wiznet, wiznet_module);
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2016 Scott Shawcroft
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
#pragma once

ports/raspberrypi/boards/wiznet_w55rp20_evb_pico/mpconfigboard.mk

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -6,9 +6,9 @@ USB_MANUFACTURER = "WIZnet"
66
CHIP_VARIANT = RP2040
77
CHIP_FAMILY = rp2
88

9-
EXTERNAL_FLASH_DEVICES = "W25Q16JVxQ"
9+
EXTERNAL_FLASH_DEVICES = "PY25Q16HB"
1010

11-
CIRCUITPY_WIZNET_PIO_SPI = 1
11+
CIRCUITPY_WIZNET = 1
1212
CIRCUITPY__EVE = 1
1313
CIRCUITPY_SSL = 1
1414
CIRCUITPY_USB_HOST = 0

ports/raspberrypi/common-hal/busio/WIZNET_PIO_SPI.c renamed to ports/raspberrypi/common-hal/wiznet/PIO_SPI.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
//
55
// SPDX-License-Identifier: MIT
66

7-
#include "shared-bindings/busio/WIZNET_PIO_SPI.h"
7+
#include "bindings/wiznet/PIO_SPI.h"
88

99
#include "shared/runtime/interrupt_char.h"
1010
#include "py/mperrno.h"
@@ -19,7 +19,7 @@
1919
#include "hardware/pio.h"
2020
#include "hardware/clocks.h"
2121

22-
#include "wiznet_pio_spi/wizchip_pio_spi.h"
22+
#include "wizchip_pio_spi.h"
2323

2424
#define NO_INSTANCE 0xff
2525

File renamed without changes.
Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,7 @@
1+
// This file is part of the CircuitPython project: https://circuitpython.org
2+
//
3+
// SPDX-FileCopyrightText: Copyright (c) 2024 Adafruit Industries LLC
4+
//
5+
// SPDX-License-Identifier: MIT
6+
7+
// No wiznet module functions.

0 commit comments

Comments
 (0)