Skip to content

Commit 3dbb546

Browse files
committed
working on being able to share the SPI Bus
1 parent ab47514 commit 3dbb546

File tree

16 files changed

+1087
-229
lines changed

16 files changed

+1087
-229
lines changed

builder/esp32.py

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -317,7 +317,6 @@ def parse_args(extra_args, lv_cflags, brd):
317317
else:
318318
lv_cflags = '-DLV_KCONFIG_IGNORE=1'
319319

320-
321320
return extra_args, lv_cflags, board
322321

323322

@@ -335,9 +334,9 @@ def parse_args(extra_args, lv_cflags, brd):
335334
SCRIPT_DIR = ''
336335

337336

338-
def build_commands(_, extra_args, script_path, lv_cflags, ___):
337+
def build_commands(_, extra_args, script_dir, lv_cflags, ___):
339338
global SCRIPT_DIR
340-
SCRIPT_DIR = script_path
339+
SCRIPT_DIR = script_dir
341340

342341
clean_cmd.extend(esp_cmd[:])
343342
clean_cmd[1] = 'clean'
@@ -352,7 +351,8 @@ def build_commands(_, extra_args, script_path, lv_cflags, ___):
352351
f'LV_CFLAGS="{lv_cflags}"',
353352
f'LV_PORT=esp32',
354353
f'BOARD={board}',
355-
'USER_C_MODULES=../../../../../ext_mod/micropython.cmake'
354+
'USER_C_MODULES=../../../../../ext_mod/micropython.cmake',
355+
f'"CFLAGS_EXTRA=-I{script_dir}/micropy_updates/common"'
356356
])
357357

358358
esp_cmd.extend(extra_args)

builder/macOS.py

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -80,8 +80,8 @@ def build_commands(_, extra_args, script_dir, lv_cflags, board):
8080
'-Wno-unused-function '
8181
'-Wno-double-promotion '
8282
'-Wno-unused-command-line-argument '
83-
'-Wno-missing-field-initializers"'
84-
# 'export LDFLAGS="-L/opt/homebrew/opt/libffi/lib"
83+
'-Wno-missing-field-initializers'
84+
f'-I{script_dir}/micropy_updates/common"'
8585
# 'export CPPFLAGS="-I/opt/homebrew/opt/libffi/include"'
8686
)
8787
])

builder/nrf.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def build_commands(_, extra_args, script_dir, lv_cflags, board):
4848

4949
compile_cmd.extend(nrf_cmd[:])
5050
compile_cmd.pop(1)
51+
compile_cmd.append(f'"CFLAGS_EXTRA=-I{script_dir}/micropy_updates/common"')
5152

5253
submodules_cmd.extend(nrf_cmd[:])
5354
submodules_cmd[1] = 'submodules'

builder/renesas.py

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,7 @@ def build_commands(_, extra_args, script_dir, lv_cflags, board):
4848

4949
compile_cmd.extend(renesas_cmd[:])
5050
compile_cmd.pop(1)
51+
compile_cmd.append(f'"CFLAGS_EXTRA=-I{script_dir}/micropy_updates/common"')
5152

5253
submodules_cmd.extend(renesas_cmd[:])
5354
submodules_cmd[1] = 'submodules'

builder/rp2.py

Lines changed: 12 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -50,7 +50,7 @@ def parse_args(extra_args, lv_cflags, board):
5050
submodules_cmd = []
5151

5252

53-
def build_commands(_, extra_args, __, lv_cflags, board):
53+
def build_commands(_, extra_args, script_path, lv_cflags, board):
5454
rp2_cmd.extend(extra_args)
5555

5656
if lv_cflags:
@@ -71,6 +71,7 @@ def build_commands(_, extra_args, __, lv_cflags, board):
7171

7272
compile_cmd.extend(rp2_cmd[:])
7373
compile_cmd.pop(1)
74+
compile_cmd.append(f'"CFLAGS_EXTRA=-I{script_path}/micropy_updates/common"')
7475

7576
submodules_cmd.extend(rp2_cmd[:])
7677
submodules_cmd[1] = 'submodules'
@@ -119,6 +120,16 @@ def submodules():
119120

120121

121122
def compile(): # NOQA
123+
import shutil
124+
125+
src_path = 'micropy_updates/rp2'
126+
dst_path = 'lib/micropython/ports/rp2'
127+
128+
for file in os.listdir(src_path):
129+
src_file = os.path.join(src_path, file)
130+
dst_file = os.path.join(dst_path, file)
131+
shutil.copyfile(src_file, dst_file)
132+
122133
if 'PICO_SDK_PATH' not in os.environ:
123134
os.environ['PICO_SDK_PATH'] = (
124135
f'{os.getcwd()}/lib/micropython/lib/pico-sdk'

builder/stm32.py

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -49,6 +49,7 @@ def build_commands(_, extra_args, script_dir, lv_cflags, board):
4949

5050
compile_cmd.extend(stm32_cmd[:])
5151
compile_cmd.pop(1)
52+
compile_cmd.append(f'"CFLAGS_EXTRA=-I{script_dir}/micropy_updates/common"')
5253

5354
submodules_cmd.extend(stm32_cmd[:])
5455
submodules_cmd[1] = 'submodules'
@@ -94,6 +95,16 @@ def submodules():
9495

9596

9697
def compile(): # NOQA
98+
import shutil
99+
100+
src_path = 'micropy_updates/stm32'
101+
dst_path = 'lib/micropython/ports/stm32'
102+
103+
for file in os.listdir(src_path):
104+
src_file = os.path.join(src_path, file)
105+
dst_file = os.path.join(dst_path, file)
106+
shutil.copyfile(src_file, dst_file)
107+
97108
return_code, _ = spawn(compile_cmd, cmpl=True)
98109
if return_code != 0:
99110
sys.exit(return_code)

builder/unix.py

Lines changed: 2 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -72,11 +72,9 @@ def build_commands(_, extra_args, script_dir, lv_cflags, board):
7272
f'LV_CFLAGS="{lv_cflags}"',
7373
f'LV_PORT=unix',
7474
f'USER_C_MODULES="{script_dir}/ext_mod"',
75-
(
76-
'"CFLAGS_EXTRA='
77-
'-Wno-missing-field-initializers"'
78-
)
75+
f'"CFLAGS_EXTRA=-Wno-missing-field-initializers -I{script_dir}/micropy_updates/common"'
7976
])
77+
8078
unix_cmd.extend(extra_args)
8179

8280
clean_cmd.extend(unix_cmd[:])

ext_mod/lcd_bus/common_include/spi_bus.h

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@
33

44
//local_includes
55
#include "modlcd_bus.h"
6+
#include "mp_spi_common.h"
67
#include "mphalport.h"
78

89
// micropython includes
@@ -32,7 +33,6 @@
3233

3334
void (*send_cmd)(mp_lcd_spi_bus_obj_t *self, int lcd_cmd);
3435
void (*send_param)(mp_lcd_spi_bus_obj_t *self, void *param, size_t param_size);
35-
3636
};
3737

3838
#else
@@ -43,13 +43,10 @@
4343
#include "extmod/machine_spi.h"
4444
#endif
4545

46-
4746
typedef struct _lcd_panel_io_spi_config_t {
48-
mp_hal_pin_obj_t cs_gpio_num;
49-
mp_hal_pin_obj_t dc_gpio_num;
47+
mp_obj_t cs_gpio;
48+
mp_hal_pin_obj_t dc_gpio;
5049
void (*spi_transfer)(mp_obj_base_t *obj, size_t len, const uint8_t *src, uint8_t *dest);
51-
int lcd_cmd_bits;
52-
int lcd_param_bits;
5350
struct {
5451
unsigned int dc_low_on_data: 1;
5552
unsigned int lsb_first: 1;
@@ -89,6 +86,9 @@
8986
void (*send_param)(mp_lcd_spi_bus_obj_t *self, void *param, size_t param_size);
9087

9188
int host;
89+
machine_hw_spi_obj_t *spi_bus;
90+
uint8_t firstbit;
91+
uint32_t freq;
9292
};
9393

9494
#endif

0 commit comments

Comments
 (0)