Skip to content

Commit 4a5d871

Browse files
committed
working on being able to share the SPI Bus
1 parent aa8b7de commit 4a5d871

File tree

7 files changed

+232
-30
lines changed

7 files changed

+232
-30
lines changed

.github/workflows/release.yml

Lines changed: 123 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,123 @@
1+
name: Release
2+
3+
on:
4+
release:
5+
types: [published]
6+
7+
jobs:
8+
macos-rel:
9+
runs-on: macos-latest
10+
steps:
11+
- uses: actions/checkout@v4
12+
13+
- uses: AButler/[email protected]
14+
with:
15+
files: "build/*"
16+
repo-token: ${{ secrets.GITHUB_TOKEN }}
17+
18+
- uses: actions/setup-python@v5
19+
with:
20+
python-version: '3.10'
21+
22+
- name: Install Dependencies
23+
run: brew install --force ninja
24+
25+
- name: Build macOS port
26+
run: python3 make.py macOS submodules clean mpy_cross DISPLAY=sdl_display INDEV=sdl_pointer
27+
28+
unix-rel:
29+
runs-on: ubuntu-latest
30+
steps:
31+
- uses: actions/checkout@v4
32+
33+
- uses: AButler/[email protected]
34+
with:
35+
files: "build/*"
36+
repo-token: ${{ secrets.GITHUB_TOKEN }}
37+
38+
- uses: actions/setup-python@v5
39+
with:
40+
python-version: '3.10'
41+
42+
- name: Install Deps
43+
run: sudo apt-get update && sudo apt-get install --assume-yes --allow-downgrades --allow-remove-essential --allow-change-held-packages build-essential pkg-config cmake ninja-build libffi-dev gnome-desktop-testing libasound2-dev libpulse-dev libaudio-dev libjack-dev libsndio-dev libx11-dev libxext-dev libxrandr-dev libxcursor-dev libxfixes-dev libxi-dev libxss-dev libxkbcommon-dev libdrm-dev libgbm-dev libgl1-mesa-dev libgles2-mesa-dev libegl1-mesa-dev libdbus-1-dev libibus-1.0-dev libudev-dev fcitx-libs-dev libpipewire-0.3-dev libwayland-dev libdecor-0-dev ccache
44+
- name: Build Unix port
45+
run: python3 make.py unix submodules clean mpy_cross DISPLAY=sdl_display INDEV=sdl_pointer
46+
47+
esp32-rel:
48+
runs-on: ubuntu-latest
49+
steps:
50+
- uses: actions/checkout@v4
51+
52+
- uses: AButler/[email protected]
53+
with:
54+
files: "build/*"
55+
repo-token: ${{ secrets.GITHUB_TOKEN }}
56+
57+
- uses: actions/setup-python@v5
58+
with:
59+
python-version: '3.10'
60+
61+
- name: ESP32_GENERIC-SPIRAM-4
62+
run: python3 make.py esp32 submodules clean mpy_cross BOARD=ESP32_GENERIC BOARD_VARIANT=SPIRAM --flash-size=4 DISPLAY=rgb_display DISPLAY=st7796 DISPLAY=st7789 DISPLAY=st7735 DISPLAY=ili9488 DISPLAY=ili9486 DISPLAY=ili9481 DISPLAY=ili9341 DISPLAY=ili9225 DISPLAY=ili9163 DISPLAY=gc9a01 INDEV=xpt2046 INDEV=gt911 INDEV=ft6x36 INDEV=ft6x06 INDEV=ft5x16 INDEV=ft5x06
63+
- name: ESP32_GENERIC-SPIRAM-8
64+
run: python3 make.py esp32 BOARD=ESP32_GENERIC BOARD_VARIANT=SPIRAM --flash-size=8 DISPLAY=rgb_display DISPLAY=st7796 DISPLAY=st7789 DISPLAY=st7735 DISPLAY=ili9488 DISPLAY=ili9486 DISPLAY=ili9481 DISPLAY=ili9341 DISPLAY=ili9225 DISPLAY=ili9163 DISPLAY=gc9a01 INDEV=xpt2046 INDEV=gt911 INDEV=ft6x36 INDEV=ft6x06 INDEV=ft5x16 INDEV=ft5x06
65+
- name: ESP32_GENERIC-SPIRAM-16
66+
run: python3 make.py esp32 BOARD=ESP32_GENERIC BOARD_VARIANT=SPIRAM --flash-size=16 DISPLAY=rgb_display DISPLAY=st7796 DISPLAY=st7789 DISPLAY=st7735 DISPLAY=ili9488 DISPLAY=ili9486 DISPLAY=ili9481 DISPLAY=ili9341 DISPLAY=ili9225 DISPLAY=ili9163 DISPLAY=gc9a01 INDEV=xpt2046 INDEV=gt911 INDEV=ft6x36 INDEV=ft6x06 INDEV=ft5x16 INDEV=ft5x06
67+
- name: ESP32_GENERIC_S2-SPIRAM-4
68+
run: python3 make.py esp32 BOARD=ESP32_GENERIC_S2 BOARD_VARIANT=SPIRAM --flash-size=4 DISPLAY=rgb_display DISPLAY=st7796 DISPLAY=st7789 DISPLAY=st7735 DISPLAY=ili9488 DISPLAY=ili9486 DISPLAY=ili9481 DISPLAY=ili9341 DISPLAY=ili9225 DISPLAY=ili9163 DISPLAY=gc9a01 INDEV=xpt2046 INDEV=gt911 INDEV=ft6x36 INDEV=ft6x06 INDEV=ft5x16 INDEV=ft5x06
69+
- name: ESP32_GENERIC_S3-SPIRAM-4
70+
run: python3 make.py esp32 BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM --flash-size=4 DISPLAY=rgb_display DISPLAY=st7796 DISPLAY=st7789 DISPLAY=st7735 DISPLAY=ili9488 DISPLAY=ili9486 DISPLAY=ili9481 DISPLAY=ili9341 DISPLAY=ili9225 DISPLAY=ili9163 DISPLAY=gc9a01 INDEV=xpt2046 INDEV=gt911 INDEV=ft6x36 INDEV=ft6x06 INDEV=ft5x16 INDEV=ft5x06
71+
- name: ESP32_GENERIC_S3-SPIRAM-8
72+
run: python3 make.py esp32 BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM --flash-size=8 DISPLAY=rgb_display DISPLAY=st7796 DISPLAY=st7789 DISPLAY=st7735 DISPLAY=ili9488 DISPLAY=ili9486 DISPLAY=ili9481 DISPLAY=ili9341 DISPLAY=ili9225 DISPLAY=ili9163 DISPLAY=gc9a01 INDEV=xpt2046 INDEV=gt911 INDEV=ft6x36 INDEV=ft6x06 INDEV=ft5x16 INDEV=ft5x06
73+
- name: ESP32_GENERIC_S3-SPIRAM_OCT-8
74+
run: python3 make.py esp32 BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT --flash-size=8 DISPLAY=rgb_display DISPLAY=st7796 DISPLAY=st7789 DISPLAY=st7735 DISPLAY=ili9488 DISPLAY=ili9486 DISPLAY=ili9481 DISPLAY=ili9341 DISPLAY=ili9225 DISPLAY=ili9163 DISPLAY=gc9a01 INDEV=xpt2046 INDEV=gt911 INDEV=ft6x36 INDEV=ft6x06 INDEV=ft5x16 INDEV=ft5x06
75+
- name: ESP32_GENERIC_S3-SPIRAM_OCT-16_OCTFLASH
76+
run: python3 make.py esp32 BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT --flash-size=16 --octal-flash DISPLAY=rgb_display DISPLAY=st7796 DISPLAY=st7789 DISPLAY=st7735 DISPLAY=ili9488 DISPLAY=ili9486 DISPLAY=ili9481 DISPLAY=ili9341 DISPLAY=ili9225 DISPLAY=ili9163 DISPLAY=gc9a01 INDEV=xpt2046 INDEV=gt911 INDEV=ft6x36 INDEV=ft6x06 INDEV=ft5x16 INDEV=ft5x06
77+
- name: ESP32_GENERIC_S3-SPIRAM_OCT-32_OCTFLASH
78+
run: python3 make.py esp32 BOARD=ESP32_GENERIC_S3 BOARD_VARIANT=SPIRAM_OCT --flash-size=32 --octal-flash DISPLAY=rgb_display DISPLAY=st7796 DISPLAY=st7789 DISPLAY=st7735 DISPLAY=ili9488 DISPLAY=ili9486 DISPLAY=ili9481 DISPLAY=ili9341 DISPLAY=ili9225 DISPLAY=ili9163 DISPLAY=gc9a01 INDEV=xpt2046 INDEV=gt911 INDEV=ft6x36 INDEV=ft6x06 INDEV=ft5x16 INDEV=ft5x06
79+
80+
rp2-rel:
81+
runs-on: ubuntu-latest
82+
steps:
83+
- uses: actions/checkout@v4
84+
85+
- uses: AButler/[email protected]
86+
with:
87+
files: "build/*"
88+
repo-token: ${{ secrets.GITHUB_TOKEN }}
89+
90+
- uses: carlosperate/[email protected]
91+
with:
92+
release: '9-2019-q4'
93+
94+
- uses: actions/setup-python@v5
95+
with:
96+
python-version: '3.10'
97+
98+
- name: Build Raspberry Pi PICO port
99+
run: python3 make.py rp2 submodules clean mpy_cross BOARD=RPI_PICO DISPLAY=st7796 DISPLAY=st7789 DISPLAY=st7735 DISPLAY=ili9488 DISPLAY=ili9486 DISPLAY=ili9481 DISPLAY=ili9341 DISPLAY=ili9225 DISPLAY=ili9163 DISPLAY=gc9a01 INDEV=xpt2046 INDEV=gt911 INDEV=ft6x36 INDEV=ft6x06 INDEV=ft5x16 INDEV=ft5x06
100+
101+
stm32-rel:
102+
runs-on: ubuntu-latest
103+
steps:
104+
- uses: actions/checkout@v4
105+
106+
- uses: AButler/[email protected]
107+
- with:
108+
files: "build/*"
109+
repo-token: ${{ secrets.GITHUB_TOKEN }}
110+
111+
- uses: carlosperate/[email protected]
112+
with:
113+
release: '9-2019-q4'
114+
115+
- uses: actions/setup-python@v5
116+
with:
117+
python-version: '3.10'
118+
119+
- name: STM32H7B3I_DK
120+
run: python3 make.py stm32 submodules clean mpy_cross BOARD=STM32H7B3I_DK DISPLAY=st7796 DISPLAY=st7789 DISPLAY=st7735 DISPLAY=ili9488 DISPLAY=ili9486 DISPLAY=ili9481 DISPLAY=ili9341 DISPLAY=ili9225 DISPLAY=ili9163 DISPLAY=gc9a01 INDEV=xpt2046 INDEV=gt911 INDEV=ft6x36 INDEV=ft6x06 INDEV=ft5x16 INDEV=ft5x06
121+
122+
- name: STM32H573I_DK
123+
run: python3 make.py stm32 submodules clean mpy_cross BOARD=STM32H573I_DK DISPLAY=st7796 DISPLAY=st7789 DISPLAY=st7735 DISPLAY=ili9488 DISPLAY=ili9486 DISPLAY=ili9481 DISPLAY=ili9341 DISPLAY=ili9225 DISPLAY=ili9163 DISPLAY=gc9a01 INDEV=xpt2046 INDEV=gt911 INDEV=ft6x36 INDEV=ft6x06 INDEV=ft5x16 INDEV=ft5x06

builder/esp32.py

Lines changed: 15 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -901,13 +901,24 @@ def compile(): # NOQA
901901

902902
build_name = f'build-{board}'
903903

904+
os.remove('build/lvgl_header.h')
905+
906+
for f in os.listdir('build'):
907+
if f.startswith('lvgl'):
908+
continue
909+
910+
os.remove(os.path.join('build', f))
911+
904912
if board_variant:
905913
build_name += f'-{board_variant}'
906914

907-
build_bin_file = os.path.abspath(
908-
f'lib/micropython/ports/esp32/{build_name}'
909-
)
910-
build_bin_file = os.path.join(build_bin_file, f'{build_name}.bin')
915+
build_bin_file = f'build/lvgl_micropy_{build_name[6:]}-{flash_size}'
916+
if oct_flash:
917+
build_bin_file += '_OCTFLASH'
918+
919+
build_bin_file += '.bin'
920+
build_bin_file = os.path.abspath(build_bin_file)
921+
911922
cmd = f'{python_path} {esp_tool_path} {out_cmd}'
912923
cmd = cmd.replace('write_flash', f'merge_bin -o {build_bin_file}')
913924
cmd = cmd.replace('--flash_freq 80m ', '')

builder/macOS.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -244,6 +244,22 @@ def compile(): # NOQA
244244
if return_code != 0:
245245
sys.exit(return_code)
246246

247+
os.remove('build/lvgl_header.h')
248+
249+
for f in os.listdir('build'):
250+
if f.startswith('lvgl'):
251+
continue
252+
253+
os.remove(os.path.join('build', f))
254+
255+
import shutil
256+
257+
src = f'lib/micropython/ports/unix/build-{variant}/micropython'
258+
dst = f'build/lvgl_micropy_macos'
259+
shutil.copyfile(src, dst)
260+
261+
print(f'compiled binary is {os.path.abspath(dst)}')
262+
247263

248264
def mpy_cross():
249265
_cmd = [

builder/rp2.py

Lines changed: 26 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -7,10 +7,14 @@
77

88

99
board_variant = None
10+
board = None
1011

1112

12-
def parse_args(extra_args, lv_cflags, board):
13+
def parse_args(extra_args, lv_cflags, brd):
1314
global board_variant
15+
global board
16+
17+
board = brd
1418

1519
if board == 'WEACTSTUDIO':
1620
rp2_argParser = ArgumentParser(prefix_chars='-B')
@@ -138,6 +142,27 @@ def compile(): # NOQA
138142
if return_code != 0:
139143
sys.exit(return_code)
140144

145+
os.remove('build/lvgl_header.h')
146+
147+
for f in os.listdir('build'):
148+
if f.startswith('lvgl'):
149+
continue
150+
151+
os.remove(os.path.join('build', f))
152+
153+
import shutil
154+
155+
if board_variant:
156+
src = f'lib/micropython/ports/rp2/build-{board}_{board_variant}/firmware.uf2'
157+
dst = f'build/lvgl_micropy_{board}_{board_variant}.uf2'
158+
else:
159+
src = f'lib/micropython/ports/rp2/build-{board}_{board_variant}/firmware.uf2'
160+
dst = f'build/lvgl_micropy_{board}.uf2'
161+
162+
shutil.copyfile(src, dst)
163+
164+
print(f'compiled binary is {os.path.abspath(dst)}')
165+
141166

142167
def mpy_cross():
143168
return_code, _ = spawn(mpy_cross_cmd)

builder/stm32.py

Lines changed: 27 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,8 +4,13 @@
44
from . import generate_manifest
55
from . import update_mphalport
66

7+
board = None
8+
board_variant = None
9+
10+
def parse_args(extra_args, lv_cflags, brd):
11+
global board
12+
board = brd
713

8-
def parse_args(extra_args, lv_cflags, board):
914
return extra_args, lv_cflags, board
1015

1116

@@ -108,6 +113,27 @@ def compile(): # NOQA
108113
if return_code != 0:
109114
sys.exit(return_code)
110115

116+
os.remove('build/lvgl_header.h')
117+
118+
for f in os.listdir('build'):
119+
if f.startswith('lvgl'):
120+
continue
121+
122+
os.remove(os.path.join('build', f))
123+
124+
import shutil
125+
126+
if board_variant:
127+
src = f'lib/micropython/ports/stm32/build-{board}_{board_variant}/firmware.dfu'
128+
dst = f'build/lvgl_micropy_{board}_{board_variant}.dfu'
129+
else:
130+
src = f'lib/micropython/ports/stm32/build-{board}_{board_variant}/firmware.dfu'
131+
dst = f'build/lvgl_micropy_{board}.dfu'
132+
133+
shutil.copyfile(src, dst)
134+
135+
print(f'compiled binary is {os.path.abspath(dst)}')
136+
111137

112138
def mpy_cross():
113139
return_code, _ = spawn(mpy_cross_cmd)

builder/unix.py

Lines changed: 16 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -237,6 +237,22 @@ def compile(): # NOQA
237237
if return_code != 0:
238238
sys.exit(return_code)
239239

240+
os.remove('build/lvgl_header.h')
241+
242+
for f in os.listdir('build'):
243+
if f.startswith('lvgl'):
244+
continue
245+
246+
os.remove(os.path.join('build', f))
247+
248+
import shutil
249+
250+
src = f'lib/micropython/ports/unix/build-{variant}/micropython'
251+
dst = f'build/lvgl_micropy_unix'
252+
shutil.copyfile(src, dst)
253+
254+
print(f'compiled binary is {os.path.abspath(dst)}')
255+
240256

241257
def mpy_cross():
242258
_cmd = [

micropy_updates/rp2/machine_spi.c

Lines changed: 9 additions & 24 deletions
Original file line numberDiff line numberDiff line change
@@ -33,6 +33,8 @@
3333
#include "hardware/spi.h"
3434
#include "hardware/dma.h"
3535

36+
#define SPI_UNUSED(x) ((void)x)
37+
3638
#define DEFAULT_SPI_BAUDRATE (1000000)
3739
#define DEFAULT_SPI_POLARITY (0)
3840
#define DEFAULT_SPI_PHASE (0)
@@ -129,23 +131,17 @@ static machine_hw_spi_bus_obj_t machine_spi_bus_obj[] = {
129131
mp_obj_new_int_from_uint(MICROPY_HW_SPI0_SCK),
130132
mp_obj_new_int_from_uint(MICROPY_HW_SPI0_MOSI),
131133
mp_obj_new_int_from_uint(MICROPY_HW_SPI0_MISO),
132-
0, 0, (void *)spi0
134+
0, 0, (const void *)spi0
133135
},
134136
{
135137
1,
136138
mp_obj_new_int_from_uint(MICROPY_HW_SPI1_SCK),
137139
mp_obj_new_int_from_uint(MICROPY_HW_SPI1_MOSI),
138140
mp_obj_new_int_from_uint(MICROPY_HW_SPI1_MISO),
139-
0, 0, (void *)spi1
141+
0, 0, (const void *)spi1
140142
},
141143
};
142144

143-
static void machine_spi_print(const mp_print_t *print, mp_obj_t self_in, mp_print_kind_t kind) {
144-
machine_spi_obj_t *self = MP_OBJ_TO_PTR(self_in);
145-
mp_printf(print, "SPI(%u, baudrate=%u, polarity=%u, phase=%u, bits=%u, sck=%u, mosi=%u, miso=%u)",
146-
self->spi_bus->spi_id, self->baudrate, self->spi_bus->polarity, self->spi_bus->phase, self->bits,
147-
self->spi_bus->sck, self->spi_bus->mosi, self->spi_bus->miso);
148-
}
149145

150146
mp_obj_t machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n_kw, const mp_obj_t *all_args) {
151147
enum { ARG_id, ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits, ARG_firstbit, ARG_cs, ARG_sck, ARG_mosi, ARG_miso };
@@ -242,21 +238,13 @@ mp_obj_t machine_spi_make_new(const mp_obj_type_t *type, size_t n_args, size_t n
242238
}
243239

244240
static void machine_spi_init(mp_obj_base_t *self_in, size_t n_args, const mp_obj_t *pos_args, mp_map_t *kw_args) {
245-
enum { ARG_baudrate, ARG_polarity, ARG_phase, ARG_bits, ARG_firstbit };
246-
static const mp_arg_t allowed_args[] = {
247-
{ MP_QSTR_baudrate, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = -1} },
248-
{ MP_QSTR_polarity, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = -1} },
249-
{ MP_QSTR_phase, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = -1} },
250-
{ MP_QSTR_bits, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = -1} },
251-
{ MP_QSTR_firstbit, MP_ARG_KW_ONLY | MP_ARG_INT, {.u_int = -1} },
252-
};
253-
254-
// Parse the arguments.
255-
machine_spi_obj_t *self = (machine_spi_obj_t *)self_in;
256-
mp_arg_val_t args[MP_ARRAY_SIZE(allowed_args)];
257-
mp_arg_parse_all(n_args, pos_args, kw_args, MP_ARRAY_SIZE(allowed_args), allowed_args, args);
241+
SPI_UNUSED(self_in);
242+
SPI_UNUSED(n_args);
243+
SPI_UNUSED(pos_args);
244+
SPI_UNUSED(kw_args);
258245
}
259246

247+
260248
static void machine_spi_deinit(mp_obj_base_t *self_in)
261249
{
262250
machine_hw_spi_obj_t *self = (machine_hw_spi_obj_t *)self_in;
@@ -289,8 +277,6 @@ static void machine_spi_transfer(mp_obj_base_t *self_in, size_t len, const uint8
289277

290278
self->spi_bus->state = MP_SPI_STATE_SENDING;
291279

292-
spi_init(, self->baudrate);
293-
294280
spi_inst_t *const spi_inst = (spi_inst_t *const)self->spi_bus->user_data;
295281

296282
spi_set_baudrate(spi_inst, self->baudrate);
@@ -392,7 +378,6 @@ MP_DEFINE_CONST_OBJ_TYPE(
392378
MP_QSTR_SPI,
393379
MP_TYPE_FLAG_NONE,
394380
make_new, machine_spi_make_new,
395-
print, machine_spi_print,
396381
protocol, &machine_spi_p,
397382
buffer, machine_spi_get_buffer,
398383
locals_dict, &mp_machine_spi_locals_dict

0 commit comments

Comments
 (0)