Skip to content

Commit 318fdef

Browse files
committed
gpio works. fix repl bugs.
1 parent d8265ee commit 318fdef

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

43 files changed

+1598
-609
lines changed

ports/xt804/Makefile

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,6 @@ MICROPY_ROM_TEXT_COMPRESSION ?= 1
4545
MICROPY_PY_USSL = 1
4646
MICROPY_SSL_AXTLS = 1
4747

48-
4948
AXTLS_DEFS_EXTRA = -Dabort=abort_ -DRT_MAX_PLAIN_LENGTH=1024 -DRT_EXTRA=4096
5049
BTREE_DEFS_EXTRA = -DDEFPSIZE=1024 -DMINCACHE=3
5150

@@ -115,6 +114,10 @@ LD_MAP_OPTION = -Wl,--ckmap=$(BUILD)/firmware.map
115114
LD_LIB_OPTION = -Wl,--start-group -Wl,--end-group
116115
LD_DEFAULT_OPTIONS = $(ExtraLinkOption) $(LD_MAP_OPTION) $(TargetLDOption) -nostartfiles -Wl,--gc-sections -T"$(SDKPath)/ld/$(TargetBoard)/gcc_csky.ld" $(LD_LIB_OPTION)
117116

117+
ifeq ($(prod),)
118+
CC_DEFAULT_OPTIONS +=-DDEBUG
119+
endif
120+
118121
DFU = $(TOP)/tools/dfu.py
119122
PYDFU = $(TOP)/tools/pydfu.py
120123

@@ -205,6 +208,7 @@ EXTMOD_SRC_C +=extmod/machine_pwm.c
205208
EXTMOD_SRC_C +=extmod/machine_signal.c
206209
EXTMOD_SRC_C +=extmod/machine_spi.c
207210
EXTMOD_SRC_C +=extmod/virtpin.c
211+
EXTMOD_SRC_C +=extmod/utime_mphal.c
208212

209213

210214

ports/xt804/boards/W806/include/pins_def.h

Lines changed: 0 additions & 185 deletions
This file was deleted.
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
import gc
22

3-
#gc.threshold((gc.mem_free() + gc.mem_alloc()) // 4)
3+
gc.threshold((gc.mem_free() + gc.mem_alloc()) // 4)
Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,18 @@
1+
2+
3+
class _internal_led:
4+
def __init__(self, pin):
5+
from machine import Pin
6+
self.pin = Pin(pin, Pin.OUT, value=1)
7+
8+
def on(self):
9+
self.pin.off()
10+
11+
def off(self):
12+
self.pin.on()
13+
14+
led0 = _internal_led('B0')
15+
led1 = _internal_led('B1')
16+
led2 = _internal_led('B2')
17+
18+

ports/xt804/modules/flashbdev.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
from esp32 import Partition
1+
from xt804 import Partition
22

33
bdev = Partition.find(Partition.TYPE_DATA, label="vfs")
44
bdev = bdev[0] if bdev else None

ports/xt804/modules/port_diag.py

Lines changed: 6 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,13 +1,14 @@
1-
import esp
1+
import xt804
22
import uctypes
33
import network
44
import lwip
55

66

77
def main():
88

9+
'''
910
ROM = uctypes.bytearray_at(0x40200000, 16)
10-
fid = esp.flash_id()
11+
fid = xt804.flash_id()
1112
1213
print("FlashROM:")
1314
print("Flash ID: %x (Vendor: %x Device: %x)" % (fid, fid & 0xFF, fid & 0xFF00 | fid >> 16))
@@ -21,7 +22,7 @@ def main():
2122
% (ROM[3], SZ_MAP.get(ROM[3] >> 4, "?"), FREQ_MAP.get(ROM[3] & 0xF))
2223
)
2324
print("Firmware checksum:")
24-
print(esp.check_fw())
25+
print(xt804.check_fw())
2526
2627
print("\nNetworking:")
2728
print("STA ifconfig:", network.WLAN(network.STA_IF).ifconfig())
@@ -30,9 +31,9 @@ def main():
3031
for i, comm in enumerate(
3132
("1,2 TX", "4 Mngmt TX(len: 0x41-0x100)", "5 Mngmt TX (len: 0-0x40)", "7", "8 RX")
3233
):
33-
print("%d: %d (%s)" % (i, esp.esf_free_bufs(i), comm))
34+
print("%d: %d (%s)" % (i, xt804.esf_free_bufs(i), comm))
3435
print("lwIP PCBs:")
3536
lwip.print_pcbs()
36-
37+
'''
3738

3839
main()

ports/xt804/mpconfigport.h

Lines changed: 16 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ typedef uint8_t __uint8_t;
8484
#define MICROPY_VFS (1)
8585
#define MICROPY_VFS_FAT (1)
8686
#define MICROPY_VFS_POSIX_FILE (0)
87-
87+
#define MICROPY_PY_SYS_PLATFORM "mpy-xt804"
8888

8989
// control over Python builtins
9090
#define MICROPY_PY_FUNCTION_ATTRS (1)
@@ -118,6 +118,7 @@ typedef uint8_t __uint8_t;
118118
#define MICROPY_PY_BUILTINS_INPUT (1)
119119
#define MICROPY_PY_BUILTINS_MIN_MAX (1)
120120
#define MICROPY_PY_BUILTINS_POW3 (1)
121+
#define MICROPY_PY_BUILTINS_FLOAT (1)
121122
#define MICROPY_PY_BUILTINS_HELP (1)
122123
#define MICROPY_PY_BUILTINS_HELP_TEXT xt804_help_text
123124
#define MICROPY_PY_BUILTINS_HELP_MODULES (1)
@@ -157,10 +158,12 @@ typedef uint8_t __uint8_t;
157158
#define MICROPY_PY_MACHINE (1)
158159
#define MICROPY_PY_MACHINE_BITSTREAM (1)
159160

161+
160162
///#define MICROPY_PY_THREAD (1)
161163
///#define MICROPY_PY_THREAD_GIL (1)
162164
///#define MICROPY_PY_THREAD_GIL_VM_DIVISOR (32)
163165

166+
164167
// fatfs configuration
165168
#define MICROPY_FATFS_ENABLE_LFN (1)
166169
#define MICROPY_FATFS_RPATH (2)
@@ -169,6 +172,9 @@ typedef uint8_t __uint8_t;
169172
#define mp_type_fileio mp_type_vfs_fat_fileio
170173
#define mp_type_textio mp_type_vfs_fat_textio
171174

175+
#ifndef MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE
176+
#define MICROPY_HW_ENABLE_INTERNAL_FLASH_STORAGE (1)
177+
#endif
172178

173179
#if 0
174180
// extra built in names to add to the global namespace
@@ -210,9 +216,16 @@ extern const struct _mp_obj_module_t mp_module_time;
210216

211217
#endif
212218

219+
extern const struct _mp_obj_module_t utime_module;
220+
extern const struct _mp_obj_module_t uos_module;;
213221
extern const struct _mp_obj_module_t mp_module_machine;
222+
extern const struct _mp_obj_module_t xt804_module;
214223
#define MICROPY_PORT_BUILTIN_MODULES \
224+
{ MP_ROM_QSTR(MP_QSTR_utime), (mp_obj_t)&utime_module }, \
225+
{ MP_ROM_QSTR(MP_QSTR_uos), MP_ROM_PTR(&uos_module) }, \
226+
{ MP_ROM_QSTR(MP_QSTR_xt804), MP_ROM_PTR(&xt804_module) }, \
215227
{ MP_ROM_QSTR(MP_QSTR_umachine), MP_ROM_PTR(&mp_module_machine) }, \
228+
216229

217230

218231
// use vfs's functions for import stat and builtin open
@@ -235,13 +248,14 @@ extern const struct _mp_obj_module_t mp_module_machine;
235248
#define MICROPY_THREAD_YIELD()
236249

237250

238-
#define MICROPY_MPHALPORT_H "xt804_mphal.h"
251+
#define MICROPY_MPHALPORT_H "mphalport.h"
239252

240253

241254
//----------------------------------------------------------
242255
#define MP_STATE_PORT MP_STATE_VM
243256
#define MICROPY_PORT_ROOT_POINTERS \
244257
const char *readline_hist[8]; \
258+
mp_obj_t machine_pin_irq_handler[44]; \
245259
\
246260
/*mp_obj_t pyb_hid_report_desc; */\
247261
\

0 commit comments

Comments
 (0)