mirror of
https://github.com/micropython/micropython.git
synced 2026-01-03 02:30:14 +01:00
Compare commits
184 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
|
|
4dea24e105 | ||
|
|
4892e4c5fc | ||
|
|
9a56912ad1 | ||
|
|
0e3f29cc99 | ||
|
|
a8aa1998ce | ||
|
|
44e6e348d6 | ||
|
|
39a8deb95f | ||
|
|
9f10d3fb63 | ||
|
|
4120f32292 | ||
|
|
b3be4710aa | ||
|
|
b56c635d64 | ||
|
|
3d6240ba1b | ||
|
|
3c4c069802 | ||
|
|
b64e0575fd | ||
|
|
9aaccd4735 | ||
|
|
1818da2ef3 | ||
|
|
8ee43e24f3 | ||
|
|
c3280d83e7 | ||
|
|
ede1f547e7 | ||
|
|
295ea12411 | ||
|
|
72bd172b30 | ||
|
|
3ba61656bd | ||
|
|
2ae7ced721 | ||
|
|
acb743da64 | ||
|
|
83229d3ffe | ||
|
|
54df549b5f | ||
|
|
b5b1f2c527 | ||
|
|
f148727b78 | ||
|
|
d4dba88236 | ||
|
|
f5c554dfe3 | ||
|
|
593faf14c4 | ||
|
|
db0a5aed39 | ||
|
|
efc4da4be9 | ||
|
|
426f326d35 | ||
|
|
9142179f81 | ||
|
|
7080e9632c | ||
|
|
00960133c2 | ||
|
|
f3308daa6f | ||
|
|
994ff738c8 | ||
|
|
a24eafacc9 | ||
|
|
2c83894257 | ||
|
|
cbd9ae5256 | ||
|
|
e4404fbef0 | ||
|
|
65971f5160 | ||
|
|
79c4ec1102 | ||
|
|
f8bc3f6964 | ||
|
|
3862ef9a9f | ||
|
|
ec314c951d | ||
|
|
16d42368a6 | ||
|
|
908f5159cf | ||
|
|
5be60d6929 | ||
|
|
863d4cd862 | ||
|
|
0d6116d86b | ||
|
|
0aff87b808 | ||
|
|
27dafa5ed5 | ||
|
|
d8557834c0 | ||
|
|
a01f6c9ae7 | ||
|
|
66fd3e4a7b | ||
|
|
3a6b3d230c | ||
|
|
94f9330d3e | ||
|
|
6d1eabfeaa | ||
|
|
432e8275a9 | ||
|
|
d8c834c95d | ||
|
|
c8e9c0d89a | ||
|
|
713ea1800d | ||
|
|
3a3db4dcf0 | ||
|
|
9b7f583b0c | ||
|
|
f882d53fcd | ||
|
|
772f0b4159 | ||
|
|
3c7e1b80ac | ||
|
|
3551368424 | ||
|
|
73ff0687f2 | ||
|
|
b1dbbd32eb | ||
|
|
1b9d161f94 | ||
|
|
549c79d11e | ||
|
|
746b752b8e | ||
|
|
1f92ffb5b7 | ||
|
|
723d598d32 | ||
|
|
40274fec9c | ||
|
|
50f56227c6 | ||
|
|
c27e5c4b0b | ||
|
|
748509a93c | ||
|
|
34472302d6 | ||
|
|
6e68a68d18 | ||
|
|
57e00ef262 | ||
|
|
7f3c0d1ea8 | ||
|
|
41b688e25f | ||
|
|
89f2ddd2d0 | ||
|
|
b7ca945877 | ||
|
|
e6dccaf18e | ||
|
|
ae58035573 | ||
|
|
8b8d189bc0 | ||
|
|
8f7ff854b0 | ||
|
|
8bfa11b138 | ||
|
|
8cee03b118 | ||
|
|
1673e19cb9 | ||
|
|
af3e45419c | ||
|
|
53ea2b5ce2 | ||
|
|
074d713bfb | ||
|
|
a9f3030371 | ||
|
|
98fb0bf68a | ||
|
|
040f6f6711 | ||
|
|
1bfa6ae6e4 | ||
|
|
dde0c204e7 | ||
|
|
c76fe77f42 | ||
|
|
35e7d9c0f1 | ||
|
|
06f70973f7 | ||
|
|
32b3549cce | ||
|
|
056cb288d9 | ||
|
|
f67d06194f | ||
|
|
d0601b0a1f | ||
|
|
aeadf7607d | ||
|
|
aee704ebe1 | ||
|
|
7cce2f664c | ||
|
|
000a12783c | ||
|
|
4deb4936d5 | ||
|
|
0ec51441de | ||
|
|
731f359292 | ||
|
|
0bd3f3291d | ||
|
|
2b080cf599 | ||
|
|
f705cb5f7a | ||
|
|
24b03561bd | ||
|
|
bd9f850e85 | ||
|
|
d6201fc4b7 | ||
|
|
165734522e | ||
|
|
3833d3846d | ||
|
|
43efb46328 | ||
|
|
c6bc5b69c2 | ||
|
|
3819634469 | ||
|
|
b83d0b35e9 | ||
|
|
823a961ecc | ||
|
|
3510499a9e | ||
|
|
17c649da3d | ||
|
|
6f70283909 | ||
|
|
98b6d35c4f | ||
|
|
9b12bc788f | ||
|
|
19b671c5cd | ||
|
|
f4decdc4a3 | ||
|
|
eb099b9893 | ||
|
|
4a9eac20b9 | ||
|
|
6a09e7d7ae | ||
|
|
04fa999cfe | ||
|
|
ebd9f550e8 | ||
|
|
5699fc9d0e | ||
|
|
a2e0d92eeb | ||
|
|
f3b1a933fc | ||
|
|
a0fb7a76cd | ||
|
|
20f85feecc | ||
|
|
404dae80a9 | ||
|
|
9011815d86 | ||
|
|
858ed6d2f7 | ||
|
|
fa87e90cfa | ||
|
|
76217064ac | ||
|
|
a13d22f921 | ||
|
|
1950295735 | ||
|
|
e0d7740a22 | ||
|
|
f3e46d0c52 | ||
|
|
12fab63928 | ||
|
|
dc93f25bb8 | ||
|
|
393d0c1679 | ||
|
|
79f404a287 | ||
|
|
8e8aac89a5 | ||
|
|
c773053f58 | ||
|
|
a654914de4 | ||
|
|
359a8aa760 | ||
|
|
a3a33db409 | ||
|
|
ca9eb81d0b | ||
|
|
1c55310bcc | ||
|
|
b7ab70c71c | ||
|
|
cf6daa0966 | ||
|
|
4a9c60cdfb | ||
|
|
81a1e17238 | ||
|
|
0dbd928cee | ||
|
|
9a334d41e3 | ||
|
|
805c6534f8 | ||
|
|
22cb7cd953 | ||
|
|
91f2168dd5 | ||
|
|
ee7bebc94f | ||
|
|
4efed58df1 | ||
|
|
0212dc65b7 | ||
|
|
9ebd4dabf2 | ||
|
|
9273cca432 | ||
|
|
126373ac70 | ||
|
|
e954604ae0 |
3
.gitmodules
vendored
3
.gitmodules
vendored
@@ -5,3 +5,6 @@
|
||||
[submodule "lib/libffi"]
|
||||
path = lib/libffi
|
||||
url = https://github.com/atgreen/libffi
|
||||
[submodule "lib/lwip"]
|
||||
path = lib/lwip
|
||||
url = http://git.savannah.gnu.org/r/lwip.git
|
||||
|
||||
18
README.md
18
README.md
@@ -98,7 +98,7 @@ External dependencies
|
||||
---------------------
|
||||
|
||||
Building Unix version requires some dependencies installed. For
|
||||
Debian/Ubuntu/Mint derivative Linux distros, install `build-essentials`
|
||||
Debian/Ubuntu/Mint derivative Linux distros, install `build-essential`
|
||||
(includes toolchain and make), `libffi-dev`, and `pkg-config` packages.
|
||||
|
||||
Other dependencies can be built together with MicroPython. Oftentimes,
|
||||
@@ -151,19 +151,3 @@ correct permissions. Try then:
|
||||
|
||||
$ sudo dfu-util -a 0 -d 0483:df11 -D build-PYBV10/firmware.dfu
|
||||
|
||||
Building the documentation locally
|
||||
----------------------------------
|
||||
|
||||
Install Sphinx, and optionally (for the RTD-styling), sphinx_rtd_theme,
|
||||
preferably in a virtualenv:
|
||||
|
||||
pip install sphinx
|
||||
pip install sphinx_rtd_theme
|
||||
|
||||
In `micropython/docs`, build the docs:
|
||||
|
||||
make MICROPY_PORT=<port_name> BUILDDIR=<port_name>/build html
|
||||
|
||||
Where `<port_name>` can be `unix`, `pyboard`, `wipy` or `esp8266`.
|
||||
|
||||
You'll find the index page at `micropython/docs/<port_name>/build/html/index.html`.
|
||||
|
||||
@@ -42,7 +42,7 @@ all: $(BUILD)/firmware.elf
|
||||
|
||||
$(BUILD)/firmware.elf: $(OBJ)
|
||||
$(ECHO) "LINK $@"
|
||||
$(Q)$(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
|
||||
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||
$(Q)$(SIZE) $@
|
||||
|
||||
include ../py/mkrules.mk
|
||||
|
||||
1
bare-arm/mphalport.h
Normal file
1
bare-arm/mphalport.h
Normal file
@@ -0,0 +1 @@
|
||||
// empty file
|
||||
@@ -73,15 +73,15 @@ not 100% sure of it.
|
||||
|
||||
## Upgrading the firmware Over The Air:
|
||||
|
||||
OTA software updates can be performed through the FTP server. After building a new MCUIMG.BIN in release mode, upload it to:
|
||||
OTA software updates can be performed through the FTP server. After building a new **mcuimg.bin** in release mode, upload it to:
|
||||
`/flash/sys/mcuimg.bin` it will take around 6s (The TI simplelink file system is quite slow because every file is mirrored for
|
||||
safety). You won't see the file being stored inside `/flash/sys/` because it's actually saved bypassing FatFS, but rest assured that
|
||||
the file was successfully transferred, and it has been signed with a MD5 checksum to verify its integrity.
|
||||
Now, reset the MCU by pressing the switch on the board, or by typing:
|
||||
|
||||
```python
|
||||
import pyb
|
||||
pyb.reset()
|
||||
import machine
|
||||
machine.reset()
|
||||
```
|
||||
|
||||
### Note regarding FileZilla:
|
||||
|
||||
@@ -151,6 +151,8 @@ APP_LIB_SRC_C = $(addprefix lib/,\
|
||||
mp-readline/readline.c \
|
||||
netutils/netutils.c \
|
||||
timeutils/timeutils.c \
|
||||
utils/pyexec.c \
|
||||
utils/printf.c \
|
||||
)
|
||||
|
||||
APP_STM_SRC_C = $(addprefix stmhal/,\
|
||||
@@ -161,8 +163,6 @@ APP_STM_SRC_C = $(addprefix stmhal/,\
|
||||
irq.c \
|
||||
lexerfatfs.c \
|
||||
moduselect.c \
|
||||
printf.c \
|
||||
pyexec.c \
|
||||
pybstdio.c \
|
||||
)
|
||||
|
||||
@@ -239,7 +239,7 @@ $(BUILD)/application.bin: $(BUILD)/application.axf
|
||||
|
||||
$(BUILD)/mcuimg.bin: $(BUILD)/application.bin
|
||||
$(ECHO) "Create $@"
|
||||
$(Q)$(SHELL) $(APP_SIGN) $(BOARD) $(BTYPE)
|
||||
$(Q)$(SHELL) $(APP_SIGN) $(BUILD)
|
||||
|
||||
MAKE_PINS = boards/make-pins.py
|
||||
BOARD_PINS = boards/$(BOARD)/pins.csv
|
||||
|
||||
@@ -1,19 +1,20 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: appsign.sh *board type* *build type*"
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage: appsign.sh *build dir*"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BOARD=$1
|
||||
BTYPE=$2
|
||||
|
||||
# Build location
|
||||
# Based on build type and board type
|
||||
BUILD=build/${BOARD}/${BTYPE}
|
||||
BUILD=$1
|
||||
|
||||
# Generate the MD5 hash
|
||||
# md5 on Darwin, md5sum on Unix
|
||||
if [ `uname -s` = "Darwin" ]; then
|
||||
echo -n `md5 -q $BUILD/application.bin` > __md5hash.bin
|
||||
else
|
||||
echo -n `md5sum --binary $BUILD/application.bin | awk '{ print $1 }'` > __md5hash.bin
|
||||
fi
|
||||
|
||||
# Concatenate it with the application binary
|
||||
cat $BUILD/application.bin __md5hash.bin > $BUILD/mcuimg.bin
|
||||
|
||||
@@ -1,19 +1,17 @@
|
||||
#!/bin/bash
|
||||
|
||||
if [ "$#" -ne 2 ]; then
|
||||
echo "Usage: bootgen.sh *board type* *build type*"
|
||||
if [ "$#" -ne 1 ]; then
|
||||
echo "Usage: bootgen.sh *build dir*"
|
||||
exit 1
|
||||
fi
|
||||
|
||||
BOARD=$1
|
||||
BTYPE=$2
|
||||
BUILD=$1
|
||||
|
||||
# Re-locator Path
|
||||
RELOCATOR=bootmgr/relocator
|
||||
|
||||
# Boot Manager Path
|
||||
# First parameter passed is the board type
|
||||
BOOTMGR=bootmgr/build/${BOARD}/${BTYPE}
|
||||
# Build location
|
||||
BOOTMGR=${BUILD}
|
||||
|
||||
# Check for re-locator binary
|
||||
if [ ! -f $RELOCATOR/relocator.bin ]; then
|
||||
|
||||
@@ -65,16 +65,13 @@ BOOT_PY_SRC_C = $(addprefix py/,\
|
||||
mpprint.c \
|
||||
)
|
||||
|
||||
BOOT_STM_SRC_C = $(addprefix stmhal/,\
|
||||
printf.c \
|
||||
)
|
||||
|
||||
BOOT_LIB_SRC_C = $(addprefix lib/,\
|
||||
libc/string0.c \
|
||||
utils/printf.c \
|
||||
)
|
||||
|
||||
OBJ = $(addprefix $(BUILD)/, $(BOOT_HAL_SRC_C:.c=.o) $(BOOT_SL_SRC_C:.c=.o) $(BOOT_CC3100_SRC_C:.c=.o) $(BOOT_UTIL_SRC_C:.c=.o) $(BOOT_MISC_SRC_C:.c=.o))
|
||||
OBJ += $(addprefix $(BUILD)/, $(BOOT_MAIN_SRC_C:.c=.o) $(BOOT_MAIN_SRC_S:.s=.o) $(BOOT_PY_SRC_C:.c=.o) $(BOOT_STM_SRC_C:.c=.o))
|
||||
OBJ += $(addprefix $(BUILD)/, $(BOOT_MAIN_SRC_C:.c=.o) $(BOOT_MAIN_SRC_S:.s=.o) $(BOOT_PY_SRC_C:.c=.o))
|
||||
OBJ += $(addprefix $(BUILD)/, $(BOOT_LIB_SRC_C:.c=.o))
|
||||
|
||||
# Add the linker script
|
||||
@@ -124,7 +121,7 @@ $(BUILD)/bootmgr.bin: $(BUILD)/bootmgr.axf
|
||||
|
||||
$(BUILD)/bootloader.bin: $(BUILD)/bootmgr.bin
|
||||
$(ECHO) "Create $@"
|
||||
$(Q)$(SHELL) $(BOOT_GEN) $(BOARD) $(BTYPE)
|
||||
$(Q)$(SHELL) $(BOOT_GEN) $(BUILD)
|
||||
|
||||
# Create an empty "qstrdefs.generated.h" needed by py/mkrules.mk
|
||||
$(HEADER_BUILD)/qstrdefs.generated.h: | $(HEADER_BUILD)
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "std.h"
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "hw_ints.h"
|
||||
#include "hw_types.h"
|
||||
#include "hw_gpio.h"
|
||||
@@ -39,7 +38,6 @@
|
||||
#include "hw_common_reg.h"
|
||||
#include "pin.h"
|
||||
#include "gpio.h"
|
||||
#include "rom.h"
|
||||
#include "rom_map.h"
|
||||
#include "prcm.h"
|
||||
#include "simplelink.h"
|
||||
|
||||
@@ -12,7 +12,8 @@
|
||||
#include "py/mpconfig.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/obj.h"
|
||||
#include "diskio.h" /* FatFs lower layer API */
|
||||
#include "lib/fatfs/ff.h"
|
||||
#include "lib/fatfs/diskio.h" /* FatFs lower layer API */
|
||||
#include "sflash_diskio.h" /* Serial flash disk IO API */
|
||||
#include "sd_diskio.h" /* SDCARD disk IO API */
|
||||
#include "inc/hw_types.h"
|
||||
@@ -22,7 +23,6 @@
|
||||
#include "prcm.h"
|
||||
#include "pybrtc.h"
|
||||
#include "timeutils.h"
|
||||
#include "ff.h"
|
||||
#include "pybsd.h"
|
||||
#include "moduos.h"
|
||||
|
||||
@@ -35,7 +35,7 @@ DSTATUS disk_status (
|
||||
BYTE pdrv /* Physical drive nmuber to identify the drive */
|
||||
)
|
||||
{
|
||||
if (pdrv == FLASH) {
|
||||
if (pdrv == PD_FLASH) {
|
||||
return sflash_disk_status();
|
||||
} else {
|
||||
os_fs_mount_t *mount_obj;
|
||||
@@ -57,7 +57,7 @@ DSTATUS disk_initialize (
|
||||
BYTE pdrv /* Physical drive nmuber to identify the drive */
|
||||
)
|
||||
{
|
||||
if (pdrv == FLASH) {
|
||||
if (pdrv == PD_FLASH) {
|
||||
if (RES_OK != sflash_disk_init()) {
|
||||
return STA_NOINIT;
|
||||
}
|
||||
@@ -84,7 +84,7 @@ DRESULT disk_read (
|
||||
UINT count /* Number of sectors to read */
|
||||
)
|
||||
{
|
||||
if (pdrv == FLASH) {
|
||||
if (pdrv == PD_FLASH) {
|
||||
return sflash_disk_read(buff, sector, count);
|
||||
} else {
|
||||
os_fs_mount_t *mount_obj;
|
||||
@@ -115,7 +115,7 @@ DRESULT disk_write (
|
||||
UINT count /* Number of sectors to write */
|
||||
)
|
||||
{
|
||||
if (pdrv == FLASH) {
|
||||
if (pdrv == PD_FLASH) {
|
||||
return sflash_disk_write(buff, sector, count);
|
||||
} else {
|
||||
os_fs_mount_t *mount_obj;
|
||||
@@ -147,7 +147,7 @@ DRESULT disk_ioctl (
|
||||
void *buff /* Buffer to send/receive control data */
|
||||
)
|
||||
{
|
||||
if (pdrv == FLASH) {
|
||||
if (pdrv == PD_FLASH) {
|
||||
switch (cmd) {
|
||||
case CTRL_SYNC:
|
||||
return sflash_disk_flush();
|
||||
|
||||
@@ -1,64 +0,0 @@
|
||||
/*-----------------------------------------------------------------------/
|
||||
/ Low level disk interface modlue include file (C)ChaN, 2014 /
|
||||
/-----------------------------------------------------------------------*/
|
||||
|
||||
#ifndef _DISKIO_DEFINED
|
||||
#define _DISKIO_DEFINED
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#define _USE_WRITE 1 /* 1: Enable disk_write function */
|
||||
#define _USE_IOCTL 1 /* 1: Enable disk_ioctl fucntion */
|
||||
|
||||
#include "integer.h"
|
||||
|
||||
|
||||
/* Status of Disk Functions */
|
||||
typedef BYTE DSTATUS;
|
||||
|
||||
/* Results of Disk Functions */
|
||||
typedef enum {
|
||||
RES_OK = 0, /* 0: Successful */
|
||||
RES_ERROR, /* 1: R/W Error */
|
||||
RES_WRPRT, /* 2: Write Protected */
|
||||
RES_NOTRDY, /* 3: Not Ready */
|
||||
RES_PARERR /* 4: Invalid Parameter */
|
||||
} DRESULT;
|
||||
|
||||
|
||||
/*---------------------------------------*/
|
||||
/* Prototypes for disk control functions */
|
||||
|
||||
|
||||
DSTATUS disk_initialize (BYTE pdrv);
|
||||
DSTATUS disk_status (BYTE pdrv);
|
||||
DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
|
||||
DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
|
||||
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
|
||||
|
||||
/* Definitions of physical drive number for each drive */
|
||||
#define FLASH 0 /* Map FLASH drive to drive number 0 */
|
||||
|
||||
/* Disk Status Bits (DSTATUS) */
|
||||
|
||||
#define STA_NOINIT 0x01 /* Drive not initialized */
|
||||
#define STA_NODISK 0x02 /* No medium in the drive */
|
||||
#define STA_PROTECT 0x04 /* Write protected */
|
||||
|
||||
|
||||
/* Command code for disk_ioctrl fucntion */
|
||||
|
||||
/* Generic command (Used by FatFs) */
|
||||
#define CTRL_SYNC 0 /* Complete pending write process (needed at _FS_READONLY == 0) */
|
||||
#define GET_SECTOR_COUNT 1 /* Get media size (needed at _USE_MKFS == 1) */
|
||||
#define GET_SECTOR_SIZE 2 /* Get sector size (needed at _MAX_SS != _MIN_SS) */
|
||||
#define GET_BLOCK_SIZE 3 /* Get erase block size (needed at _USE_MKFS == 1) */
|
||||
#define CTRL_TRIM 4 /* Inform device that the data on the block of sectors is no longer used (needed at _USE_TRIM == 1) */
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif
|
||||
@@ -38,11 +38,10 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/mphal.h"
|
||||
#include "hw_types.h"
|
||||
#include "hw_memmap.h"
|
||||
#include "hw_ints.h"
|
||||
#include "rom.h"
|
||||
#include "rom_map.h"
|
||||
#include "diskio.h"
|
||||
#include "sd_diskio.h"
|
||||
@@ -187,7 +186,7 @@ static unsigned int CardSelect (DiskInfo_t *sDiskInfo) {
|
||||
}
|
||||
|
||||
// Delay 250ms for the card to become ready
|
||||
HAL_Delay (250);
|
||||
mp_hal_delay_ms(250);
|
||||
|
||||
return ulRet;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,6 @@
|
||||
#include "std.h"
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/obj.h"
|
||||
#include "simplelink.h"
|
||||
#include "diskio.h"
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "py/mpstate.h"
|
||||
#include "ff.h"
|
||||
#include "ffconf.h"
|
||||
#include "diskio.h"
|
||||
#include "lib/fatfs/ff.h"
|
||||
#include "lib/fatfs/ffconf.h"
|
||||
#include "lib/fatfs/diskio.h"
|
||||
#include "moduos.h"
|
||||
|
||||
#if _FS_RPATH
|
||||
@@ -65,7 +65,7 @@ int ff_get_ldnumber (const TCHAR **path) {
|
||||
}
|
||||
|
||||
if (check_path(path, "/flash", 6)) {
|
||||
return FLASH;
|
||||
return PD_FLASH;
|
||||
}
|
||||
else {
|
||||
for (mp_uint_t i = 0; i < MP_STATE_PORT(mount_obj_list).len; i++) {
|
||||
@@ -80,7 +80,7 @@ int ff_get_ldnumber (const TCHAR **path) {
|
||||
}
|
||||
|
||||
void ff_get_volname(BYTE vol, TCHAR **dest) {
|
||||
if (vol == FLASH) {
|
||||
if (vol == PD_FLASH) {
|
||||
memcpy(*dest, "/flash", 6);
|
||||
*dest += 6;
|
||||
} else {
|
||||
|
||||
@@ -1,300 +0,0 @@
|
||||
/*
|
||||
* This file is part of the Micro Python project, http://micropython.org/
|
||||
*
|
||||
* Original file from:
|
||||
* FatFs - FAT file system module configuration file R0.10c (C)ChaN, 2014
|
||||
*
|
||||
* The MIT License (MIT)
|
||||
*
|
||||
* Copyright (c) 2013, 2014 Damien P. George
|
||||
* Copyright (c) 2015 Daniel Campora
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy
|
||||
* of this software and associated documentation files (the "Software"), to deal
|
||||
* in the Software without restriction, including without limitation the rights
|
||||
* to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
||||
* copies of the Software, and to permit persons to whom the Software is
|
||||
* furnished to do so, subject to the following conditions:
|
||||
*
|
||||
* The above copyright notice and this permission notice shall be included in
|
||||
* all copies or substantial portions of the Software.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
||||
* IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
||||
* FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
||||
* AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
||||
* LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
||||
* OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN
|
||||
* THE SOFTWARE.
|
||||
*/
|
||||
|
||||
#ifndef _FFCONF
|
||||
#define _FFCONF 32020 /* Revision ID */
|
||||
|
||||
#include <stdint.h>
|
||||
#include "py/mpconfig.h"
|
||||
#include "FreeRTOS.h"
|
||||
#include "task.h"
|
||||
#include "semphr.h"
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Functions and Buffer Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _FS_TINY 1
|
||||
/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
|
||||
/ At the tiny configuration, size of the file object (FIL) is reduced _MAX_SS
|
||||
/ bytes. Instead of private sector buffer eliminated from the file object,
|
||||
/ common sector buffer in the file system object (FATFS) is used for the file
|
||||
/ data transfer. */
|
||||
|
||||
|
||||
#define _FS_READONLY 0
|
||||
/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
|
||||
/ Read-only configuration removes writing API functions, f_write(), f_sync(),
|
||||
/ f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
|
||||
/ and optional writing functions as well. */
|
||||
|
||||
|
||||
#define _FS_MINIMIZE 0
|
||||
/* This option defines minimization level to remove some API functions.
|
||||
/
|
||||
/ 0: All basic functions are enabled.
|
||||
/ 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_chmod(), f_utime(),
|
||||
/ f_truncate() and f_rename() function are removed.
|
||||
/ 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
|
||||
/ 3: f_lseek() function is removed in addition to 2. */
|
||||
|
||||
|
||||
#define _USE_STRFUNC 0
|
||||
/* This option switches string functions, f_gets(), f_putc(), f_puts() and
|
||||
/ f_printf().
|
||||
/
|
||||
/ 0: Disable string functions.
|
||||
/ 1: Enable without LF-CRLF conversion.
|
||||
/ 2: Enable with LF-CRLF conversion. */
|
||||
|
||||
|
||||
#define _USE_FIND 0
|
||||
/* This option switches filtered directory read feature and related functions,
|
||||
/ f_findfirst() and f_findnext(). (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define _USE_MKFS 1
|
||||
/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define _USE_FASTSEEK 0
|
||||
/* This option switches fast seek feature. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define _USE_LABEL 0
|
||||
/* This option switches volume label functions, f_getlabel() and f_setlabel().
|
||||
/ (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define _USE_FORWARD 0
|
||||
/* This option switches f_forward() function. (0:Disable or 1:Enable)
|
||||
/ To enable it, also _FS_TINY need to be set to 1. */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Locale and Namespace Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _CODE_PAGE (MICROPY_LFN_CODE_PAGE)
|
||||
/* This option specifies the OEM code page to be used on the target system.
|
||||
/ Incorrect setting of the code page can cause a file open failure.
|
||||
/
|
||||
/ 1 - ASCII (No extended character. Non-LFN cfg. only)
|
||||
/ 437 - U.S.
|
||||
/ 720 - Arabic
|
||||
/ 737 - Greek
|
||||
/ 775 - Baltic
|
||||
/ 850 - Multilingual Latin 1
|
||||
/ 852 - Latin 2
|
||||
/ 855 - Cyrillic
|
||||
/ 857 - Turkish
|
||||
/ 858 - Multilingual Latin 1 + Euro
|
||||
/ 862 - Hebrew
|
||||
/ 866 - Russian
|
||||
/ 874 - Thai
|
||||
/ 932 - Japanese Shift_JIS (DBCS)
|
||||
/ 936 - Simplified Chinese GBK (DBCS)
|
||||
/ 949 - Korean (DBCS)
|
||||
/ 950 - Traditional Chinese Big5 (DBCS)
|
||||
*/
|
||||
|
||||
|
||||
#define _USE_LFN (MICROPY_ENABLE_LFN)
|
||||
#define _MAX_LFN (MICROPY_ALLOC_PATH_MAX)
|
||||
/* The _USE_LFN option switches the LFN feature.
|
||||
/
|
||||
/ 0: Disable LFN feature. _MAX_LFN has no effect.
|
||||
/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
|
||||
/ 2: Enable LFN with dynamic working buffer on the STACK.
|
||||
/ 3: Enable LFN with dynamic working buffer on the HEAP.
|
||||
/
|
||||
/ When enable the LFN feature, Unicode handling functions (option/unicode.c) must
|
||||
/ be added to the project. The LFN working buffer occupies (_MAX_LFN + 1) * 2 bytes.
|
||||
/ When use stack for the working buffer, take care on stack overflow. When use heap
|
||||
/ memory for the working buffer, memory management functions, ff_memalloc() and
|
||||
/ ff_memfree(), must be added to the project. */
|
||||
|
||||
|
||||
#define _LFN_UNICODE 0
|
||||
/* This option switches character encoding on the API. (0:ANSI/OEM or 1:Unicode)
|
||||
/ To use Unicode string for the path name, enable LFN feature and set _LFN_UNICODE
|
||||
/ to 1. This option also affects behavior of string I/O functions. */
|
||||
|
||||
|
||||
#define _STRF_ENCODE 3
|
||||
/* When _LFN_UNICODE is 1, this option selects the character encoding on the file to
|
||||
/ be read/written via string I/O functions, f_gets(), f_putc(), f_puts and f_printf().
|
||||
/
|
||||
/ 0: ANSI/OEM
|
||||
/ 1: UTF-16LE
|
||||
/ 2: UTF-16BE
|
||||
/ 3: UTF-8
|
||||
/
|
||||
/ When _LFN_UNICODE is 0, this option has no effect. */
|
||||
|
||||
|
||||
#define _FS_RPATH 2
|
||||
/* This option configures relative path feature.
|
||||
/
|
||||
/ 0: Disable relative path feature and remove related functions.
|
||||
/ 1: Enable relative path feature. f_chdir() and f_chdrive() are available.
|
||||
/ 2: f_getcwd() function is available in addition to 1.
|
||||
/
|
||||
/ Note that directory items read via f_readdir() are affected by this option. */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Drive/Volume Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _VOLUMES 2
|
||||
/* Number of volumes (logical drives) to be used. */
|
||||
|
||||
|
||||
#define _STR_VOLUME_ID 0
|
||||
#define _VOLUME_STRS "RAM","NAND","CF","SD1","SD2","USB1","USB2","USB3"
|
||||
/* _STR_VOLUME_ID option switches string volume ID feature.
|
||||
/ When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive
|
||||
/ number in the path name. _VOLUME_STRS defines the drive ID strings for each
|
||||
/ logical drives. Number of items must be equal to _VOLUMES. Valid characters for
|
||||
/ the drive ID strings are: A-Z and 0-9. */
|
||||
|
||||
|
||||
#define _MULTI_PARTITION 0
|
||||
/* This option switches multi-partition feature. By default (0), each logical drive
|
||||
/ number is bound to the same physical drive number and only an FAT volume found on
|
||||
/ the physical drive will be mounted. When multi-partition feature is enabled (1),
|
||||
/ each logical drive number is bound to arbitrary physical drive and partition
|
||||
/ listed in the VolToPart[]. Also f_fdisk() funciton will be available. */
|
||||
|
||||
|
||||
#define _MIN_SS 512
|
||||
#define _MAX_SS 512
|
||||
/* These options configure the range of sector size to be supported. (512, 1024,
|
||||
/ 2048 or 4096) Always set both 512 for most systems, all type of memory cards and
|
||||
/ harddisk. But a larger value may be required for on-board flash memory and some
|
||||
/ type of optical media. When _MAX_SS is larger than _MIN_SS, FatFs is configured
|
||||
/ to variable sector size and GET_SECTOR_SIZE command must be implemented to the
|
||||
/ disk_ioctl() function. */
|
||||
|
||||
|
||||
#define _USE_TRIM 0
|
||||
/* This option switches ATA-TRIM feature. (0:Disable or 1:Enable)
|
||||
/ To enable Trim feature, also CTRL_TRIM command should be implemented to the
|
||||
/ disk_ioctl() function. */
|
||||
|
||||
|
||||
#define _FS_NOFSINFO 0
|
||||
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
|
||||
/ option, and f_getfree() function at first time after volume mount will force
|
||||
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
|
||||
/
|
||||
/ bit0=0: Use free cluster count in the FSINFO if available.
|
||||
/ bit0=1: Do not trust free cluster count in the FSINFO.
|
||||
/ bit1=0: Use last allocated cluster number in the FSINFO if available.
|
||||
/ bit1=1: Do not trust last allocated cluster number in the FSINFO.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ System Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _FS_NORTC 0
|
||||
#define _NORTC_MON 2
|
||||
#define _NORTC_MDAY 1
|
||||
#define _NORTC_YEAR 2015
|
||||
/* The _FS_NORTC option switches timestamp feature. If the system does not have
|
||||
/ an RTC function or valid timestamp is not needed, set _FS_NORTC to 1 to disable
|
||||
/ the timestamp feature. All objects modified by FatFs will have a fixed timestamp
|
||||
/ defined by _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR.
|
||||
/ When timestamp feature is enabled (_FS_NORTC == 0), get_fattime() function need
|
||||
/ to be added to the project to read current time form RTC. _NORTC_MON,
|
||||
/ _NORTC_MDAY and _NORTC_YEAR have no effect.
|
||||
/ These options have no effect at read-only configuration (_FS_READONLY == 1). */
|
||||
|
||||
|
||||
#define _FS_LOCK 2
|
||||
/* The _FS_LOCK option switches file lock feature to control duplicated file open
|
||||
/ and illegal operation to open objects. This option must be 0 when _FS_READONLY
|
||||
/ is 1.
|
||||
/
|
||||
/ 0: Disable file lock feature. To avoid volume corruption, application program
|
||||
/ should avoid illegal open, remove and rename to the open objects.
|
||||
/ >0: Enable file lock feature. The value defines how many files/sub-directories
|
||||
/ can be opened simultaneously under file lock control. Note that the file
|
||||
/ lock feature is independent of re-entrancy. */
|
||||
|
||||
|
||||
#define _FS_REENTRANT 1
|
||||
#define _FS_TIMEOUT 2500 // milliseconds
|
||||
#define _SYNC_t SemaphoreHandle_t
|
||||
/* The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs
|
||||
/ module itself. Note that regardless of this option, file access to different
|
||||
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
|
||||
/ and f_fdisk() function, are always not re-entrant. Only file/directory access
|
||||
/ to the same volume is under control of this feature.
|
||||
/
|
||||
/ 0: Disable re-entrancy. _FS_TIMEOUT and _SYNC_t have no effect.
|
||||
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
|
||||
/ ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
|
||||
/ function, must be added to the project. Samples are available in
|
||||
/ option/syscall.c.
|
||||
/
|
||||
/ The _FS_TIMEOUT defines timeout period in unit of time tick.
|
||||
/ The _SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
|
||||
/ SemaphoreHandle_t and etc.. */
|
||||
|
||||
|
||||
#define _WORD_ACCESS 0
|
||||
/* The _WORD_ACCESS option is an only platform dependent option. It defines
|
||||
/ which access method is used to the word data on the FAT volume.
|
||||
/
|
||||
/ 0: Byte-by-byte access. Always compatible with all platforms.
|
||||
/ 1: Word access. Do not choose this unless under both the following conditions.
|
||||
/
|
||||
/ * Address misaligned memory access is always allowed to ALL instructions.
|
||||
/ * Byte order on the memory is little-endian.
|
||||
/
|
||||
/ If it is the case, _WORD_ACCESS can also be set to 1 to reduce code size.
|
||||
/ Following table shows allowable settings of some processor types.
|
||||
/
|
||||
/ ARM7TDMI 0 ColdFire 0 V850E 0
|
||||
/ Cortex-M3 0 Z80 0/1 V850ES 0/1
|
||||
/ Cortex-M0 0 x86 0/1 TLCS-870 0/1
|
||||
/ AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1
|
||||
/ AVR32 0 RL78 0 R32C 0
|
||||
/ PIC18 0/1 SH-2 0 M16C 0/1
|
||||
/ PIC24 0 H8S 0 MSP430 0
|
||||
/ PIC32 0 H8/300H 0 8051 0/1
|
||||
*/
|
||||
|
||||
#endif // _FFCONF
|
||||
@@ -29,7 +29,6 @@
|
||||
#include "std.h"
|
||||
|
||||
#include "py/mpstate.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/obj.h"
|
||||
#include "inc/hw_types.h"
|
||||
#include "inc/hw_ints.h"
|
||||
@@ -248,7 +247,7 @@ void ftp_run (void) {
|
||||
ftp_wait_for_enabled();
|
||||
break;
|
||||
case E_FTP_STE_START:
|
||||
if (wlan_is_connected() && ftp_create_listening_socket(&ftp_data.lc_sd, FTP_CMD_PORT, FTP_CMD_CLIENTS_MAX)) {
|
||||
if (wlan_is_connected() && ftp_create_listening_socket(&ftp_data.lc_sd, FTP_CMD_PORT, FTP_CMD_CLIENTS_MAX - 1)) {
|
||||
ftp_data.state = E_FTP_STE_READY;
|
||||
}
|
||||
break;
|
||||
@@ -612,7 +611,7 @@ static void ftp_process_cmd (void) {
|
||||
|
||||
ftp_data.closechild = false;
|
||||
// also use the reply buffer to receive new commands
|
||||
if (E_FTP_RESULT_OK == (result = ftp_recv_non_blocking(ftp_data.c_sd, ftp_cmd_buffer, FTP_BUFFER_SIZE, &len))) {
|
||||
if (E_FTP_RESULT_OK == (result = ftp_recv_non_blocking(ftp_data.c_sd, ftp_cmd_buffer, FTP_MAX_PARAM_SIZE + FTP_CMD_SIZE_MAX, &len))) {
|
||||
// bufptr is moved as commands are being popped
|
||||
ftp_cmd_index_t cmd = ftp_pop_command(&bufptr);
|
||||
if (!ftp_data.loggin.passvalid && (cmd != E_FTP_CMD_USER && cmd != E_FTP_CMD_PASS && cmd != E_FTP_CMD_QUIT)) {
|
||||
@@ -707,7 +706,7 @@ static void ftp_process_cmd (void) {
|
||||
ftp_data.substate = E_FTP_STE_SUB_DISCONNECTED;
|
||||
bool socketcreated = true;
|
||||
if (ftp_data.ld_sd < 0) {
|
||||
socketcreated = ftp_create_listening_socket(&ftp_data.ld_sd, FTP_PASIVE_DATA_PORT, FTP_DATA_CLIENTS_MAX);
|
||||
socketcreated = ftp_create_listening_socket(&ftp_data.ld_sd, FTP_PASIVE_DATA_PORT, FTP_DATA_CLIENTS_MAX - 1);
|
||||
}
|
||||
if (socketcreated) {
|
||||
uint32_t ip;
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/obj.h"
|
||||
#include "simplelink.h"
|
||||
#include "flc.h"
|
||||
|
||||
@@ -34,7 +34,7 @@
|
||||
|
||||
|
||||
#include "py/mpstate.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/mphal.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/objstr.h"
|
||||
#include "inc/hw_types.h"
|
||||
@@ -104,11 +104,11 @@ void HAL_IncrementTick(void) {
|
||||
HAL_tickCount++;
|
||||
}
|
||||
|
||||
uint32_t HAL_GetTick(void) {
|
||||
mp_uint_t mp_hal_ticks_ms(void) {
|
||||
return HAL_tickCount;
|
||||
}
|
||||
|
||||
void HAL_Delay(uint32_t delay) {
|
||||
void mp_hal_delay_ms(mp_uint_t delay) {
|
||||
// only if we are not within interrupt context and interrupts are enabled
|
||||
if ((HAL_NVIC_INT_CTRL_REG & HAL_VECTACTIVE_MASK) == 0 && query_irq() == IRQ_STATE_ENABLED) {
|
||||
#ifdef USE_FREERTOS
|
||||
@@ -140,7 +140,7 @@ void mp_hal_stdout_tx_str(const char *str) {
|
||||
mp_hal_stdout_tx_strn(str, strlen(str));
|
||||
}
|
||||
|
||||
void mp_hal_stdout_tx_strn(const char *str, uint32_t len) {
|
||||
void mp_hal_stdout_tx_strn(const char *str, size_t len) {
|
||||
if (MP_STATE_PORT(os_term_dup_obj)) {
|
||||
if (MP_OBJ_IS_TYPE(MP_STATE_PORT(os_term_dup_obj)->stream_o, &pyb_uart_type)) {
|
||||
uart_tx_strn(MP_STATE_PORT(os_term_dup_obj)->stream_o, str, len);
|
||||
@@ -153,7 +153,7 @@ void mp_hal_stdout_tx_strn(const char *str, uint32_t len) {
|
||||
telnet_tx_strn(str, len);
|
||||
}
|
||||
|
||||
void mp_hal_stdout_tx_strn_cooked (const char *str, uint32_t len) {
|
||||
void mp_hal_stdout_tx_strn_cooked (const char *str, size_t len) {
|
||||
int32_t nslen = 0;
|
||||
const char *_str = str;
|
||||
|
||||
@@ -193,7 +193,7 @@ int mp_hal_stdin_rx_chr(void) {
|
||||
}
|
||||
}
|
||||
}
|
||||
HAL_Delay(1);
|
||||
mp_hal_delay_ms(1);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -62,14 +62,7 @@
|
||||
extern void HAL_SystemInit (void);
|
||||
extern void HAL_SystemDeInit (void);
|
||||
extern void HAL_IncrementTick(void);
|
||||
extern uint32_t HAL_GetTick(void);
|
||||
extern void HAL_Delay(uint32_t delay);
|
||||
extern NORETURN void mp_hal_raise(int errno);
|
||||
extern void mp_hal_set_interrupt_char (int c);
|
||||
|
||||
int mp_hal_stdin_rx_chr(void);
|
||||
void mp_hal_stdout_tx_str(const char *str);
|
||||
void mp_hal_stdout_tx_strn(const char *str, uint32_t len);
|
||||
void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len);
|
||||
|
||||
#endif /* CC3200_LAUNCHXL_HAL_CC3200_HAL_H_ */
|
||||
|
||||
@@ -782,15 +782,9 @@ SPIConfigSetExpClk(unsigned long ulBase,unsigned long ulSPIClk,
|
||||
}
|
||||
|
||||
//
|
||||
// Mask the configurations and set clock divider granularity
|
||||
// to 1 cycle
|
||||
// set clock divider granularity to 1 cycle
|
||||
//
|
||||
ulRegData = (ulRegData & (~(MCSPI_CH0CONF_WL_M |
|
||||
MCSPI_CH0CONF_EPOL |
|
||||
MCSPI_CH0CONF_POL |
|
||||
MCSPI_CH0CONF_PHA |
|
||||
MCSPI_CH0CONF_TURBO ) |
|
||||
MCSPI_CH0CONF_CLKG));
|
||||
ulRegData |= MCSPI_CH0CONF_CLKG;
|
||||
|
||||
//
|
||||
// Get the divider value
|
||||
@@ -798,7 +792,7 @@ SPIConfigSetExpClk(unsigned long ulBase,unsigned long ulSPIClk,
|
||||
ulDivider = ((ulSPIClk/ulBitRate) - 1);
|
||||
|
||||
//
|
||||
// The least significant four bits of the divider is used fo configure
|
||||
// The least significant four bits of the divider is used to configure
|
||||
// CLKD in MCSPI_CHCONF next eight least significant bits are used to
|
||||
// configure the EXTCLK in MCSPI_CHCTRL
|
||||
//
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <ctype.h>
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/mphal.h"
|
||||
#include "mptask.h"
|
||||
#include "simplelink.h"
|
||||
#include "pybwdt.h"
|
||||
|
||||
@@ -29,7 +29,7 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/mphal.h"
|
||||
#include "py/obj.h"
|
||||
#include "inc/hw_memmap.h"
|
||||
#include "pybuart.h"
|
||||
|
||||
@@ -30,9 +30,9 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/mphal.h"
|
||||
#include "hw_ints.h"
|
||||
#include "hw_types.h"
|
||||
#include "hw_gpio.h"
|
||||
@@ -45,7 +45,6 @@
|
||||
#include "pybpin.h"
|
||||
#include "pins.h"
|
||||
#endif
|
||||
#include "rom.h"
|
||||
#include "rom_map.h"
|
||||
#include "prcm.h"
|
||||
#include "pybuart.h"
|
||||
@@ -151,12 +150,12 @@ void mperror_heartbeat_signal (void) {
|
||||
mperror_heart_beat.do_disable = false;
|
||||
} else if (mperror_heart_beat.enabled) {
|
||||
if (!mperror_heart_beat.beating) {
|
||||
if ((mperror_heart_beat.on_time = HAL_GetTick()) - mperror_heart_beat.off_time > MPERROR_HEARTBEAT_OFF_MS) {
|
||||
if ((mperror_heart_beat.on_time = mp_hal_ticks_ms()) - mperror_heart_beat.off_time > MPERROR_HEARTBEAT_OFF_MS) {
|
||||
MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, MICROPY_SYS_LED_PORT_PIN);
|
||||
mperror_heart_beat.beating = true;
|
||||
}
|
||||
} else {
|
||||
if ((mperror_heart_beat.off_time = HAL_GetTick()) - mperror_heart_beat.on_time > MPERROR_HEARTBEAT_ON_MS) {
|
||||
if ((mperror_heart_beat.off_time = mp_hal_ticks_ms()) - mperror_heart_beat.on_time > MPERROR_HEARTBEAT_ON_MS) {
|
||||
MAP_GPIOPinWrite(MICROPY_SYS_LED_PORT, MICROPY_SYS_LED_PORT_PIN, 0);
|
||||
mperror_heart_beat.beating = false;
|
||||
}
|
||||
|
||||
@@ -27,7 +27,6 @@
|
||||
#include "std.h"
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/gc.h"
|
||||
|
||||
@@ -26,8 +26,8 @@
|
||||
*/
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/obj.h"
|
||||
#include "py/mphal.h"
|
||||
#include "mpsystick.h"
|
||||
#include "systick.h"
|
||||
#include "inc/hw_types.h"
|
||||
@@ -40,12 +40,12 @@
|
||||
|
||||
|
||||
bool sys_tick_has_passed(uint32_t start_tick, uint32_t delay_ms) {
|
||||
return HAL_GetTick() - start_tick >= delay_ms;
|
||||
return mp_hal_ticks_ms() - start_tick >= delay_ms;
|
||||
}
|
||||
|
||||
// waits until at least delay_ms milliseconds have passed from the sampling of
|
||||
// startTick. Handles overflow properly. Assumes stc was taken from
|
||||
// HAL_GetTick() some time before calling this function.
|
||||
// mp_hal_ticks_ms() some time before calling this function.
|
||||
void sys_tick_wait_at_least(uint32_t start_tick, uint32_t delay_ms) {
|
||||
#ifdef USE_FREERTOS
|
||||
vTaskDelay (delay_ms / portTICK_PERIOD_MS);
|
||||
@@ -58,11 +58,11 @@ void sys_tick_wait_at_least(uint32_t start_tick, uint32_t delay_ms) {
|
||||
|
||||
// The SysTick timer counts down at HAL_FCPU_HZ, so we can use that knowledge
|
||||
// to grab a microsecond counter.
|
||||
// We assume that HAL_GetTick returns milliseconds.
|
||||
// We assume that mp_hal_ticks_ms returns milliseconds.
|
||||
uint32_t sys_tick_get_microseconds(void) {
|
||||
mp_uint_t irq_state = disable_irq();
|
||||
uint32_t counter = SysTickValueGet();
|
||||
uint32_t milliseconds = HAL_GetTick();
|
||||
uint32_t milliseconds = mp_hal_ticks_ms();
|
||||
enable_irq(irq_state);
|
||||
|
||||
uint32_t load = SysTickPeriodGet();
|
||||
|
||||
@@ -30,7 +30,7 @@
|
||||
|
||||
#include "py/mpstate.h"
|
||||
#include "py/runtime.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/mphal.h"
|
||||
#include "irq.h"
|
||||
#include "inc/hw_types.h"
|
||||
#include "inc/hw_gpio.h"
|
||||
@@ -39,7 +39,6 @@
|
||||
#include "inc/hw_uart.h"
|
||||
#include "rom_map.h"
|
||||
#include "prcm.h"
|
||||
#include "pyexec.h"
|
||||
#include "pybuart.h"
|
||||
#include "pybpin.h"
|
||||
#include "pybrtc.h"
|
||||
|
||||
@@ -28,10 +28,10 @@
|
||||
#include <std.h>
|
||||
|
||||
#include "py/mpstate.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/obj.h"
|
||||
#include "py/nlr.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/mphal.h"
|
||||
#include "modnetwork.h"
|
||||
#include "mpexception.h"
|
||||
#include "serverstask.h"
|
||||
|
||||
@@ -26,7 +26,6 @@
|
||||
*/
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/nlr.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/binary.h"
|
||||
|
||||
@@ -62,6 +62,14 @@
|
||||
STATIC uint32_t os_num_mounted_devices;
|
||||
STATIC os_term_dup_obj_t os_term_dup_obj;
|
||||
|
||||
/******************************************************************************
|
||||
DECLARE PRIVATE FUNCTIONS
|
||||
******************************************************************************/
|
||||
STATIC void unmount (os_fs_mount_t *mount_obj);
|
||||
STATIC bool path_equal(const char *path, const char *path_canonical);
|
||||
STATIC void append_dir_item (mp_obj_t dirlist, const char *item, bool string);
|
||||
STATIC void mount (mp_obj_t device, const char *path, uint pathlen, bool readonly);
|
||||
|
||||
/******************************************************************************
|
||||
DEFINE PUBLIC FUNCTIONS
|
||||
******************************************************************************/
|
||||
@@ -102,6 +110,13 @@ os_fs_mount_t *osmount_find_by_device (mp_obj_t device) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
void osmount_unmount_all (void) {
|
||||
for (mp_uint_t i = 0; i < MP_STATE_PORT(mount_obj_list).len; i++) {
|
||||
os_fs_mount_t *mount_obj = ((os_fs_mount_t *)(MP_STATE_PORT(mount_obj_list).items[i]));
|
||||
unmount(mount_obj);
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
DEFINE PRIVATE FUNCTIONS
|
||||
******************************************************************************/
|
||||
@@ -188,19 +203,11 @@ STATIC void mount (mp_obj_t device, const char *path, uint pathlen, bool readonl
|
||||
os_num_mounted_devices++;
|
||||
}
|
||||
|
||||
STATIC void unmount (const char *path) {
|
||||
if (FR_OK != f_mount (NULL, path, 1)) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_os_operation_failed));
|
||||
}
|
||||
|
||||
// remove from the list after the actual unmount
|
||||
os_fs_mount_t *mount_obj;
|
||||
if ((mount_obj = osmount_find_by_path(path))) {
|
||||
mp_obj_list_remove(&MP_STATE_PORT(mount_obj_list), mount_obj);
|
||||
os_num_mounted_devices--;
|
||||
} else {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
|
||||
}
|
||||
STATIC void unmount (os_fs_mount_t *mount_obj) {
|
||||
// remove it from the list and then call FatFs
|
||||
f_mount (NULL, mount_obj->path, 1);
|
||||
mp_obj_list_remove(&MP_STATE_PORT(mount_obj_list), mount_obj);
|
||||
os_num_mounted_devices--;
|
||||
}
|
||||
|
||||
/******************************************************************************/
|
||||
@@ -487,7 +494,12 @@ STATIC mp_obj_t os_unmount(mp_obj_t path_o) {
|
||||
}
|
||||
|
||||
// now unmount it
|
||||
unmount (path);
|
||||
os_fs_mount_t *mount_obj;
|
||||
if ((mount_obj = osmount_find_by_path(path))) {
|
||||
unmount (mount_obj);
|
||||
} else {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
|
||||
}
|
||||
|
||||
return mp_const_none;
|
||||
}
|
||||
@@ -495,6 +507,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(os_unmount_obj, os_unmount);
|
||||
|
||||
STATIC mp_obj_t os_mkfs(mp_obj_t device) {
|
||||
const char *path = "/__mkfs__mnt__";
|
||||
os_fs_mount_t *mount_obj = NULL;
|
||||
bool unmt = false;
|
||||
FRESULT res;
|
||||
|
||||
@@ -505,29 +518,26 @@ STATIC mp_obj_t os_mkfs(mp_obj_t device) {
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_OSError, mpexception_value_invalid_arguments));
|
||||
}
|
||||
} else {
|
||||
// mount it and unmount it briefly
|
||||
unmt = true;
|
||||
// mount it briefly
|
||||
mount(device, path, strlen(path), false);
|
||||
unmt = true;
|
||||
}
|
||||
|
||||
byte sfd = 0;
|
||||
if (!memcmp(path, "/flash", strlen("/flash"))) {
|
||||
sfd = 1;
|
||||
} else {
|
||||
os_fs_mount_t *mount_obj;
|
||||
if ((mount_obj = osmount_find_by_path(path))) {
|
||||
if (mount_obj->device != (mp_obj_t)&pybsd_obj &&
|
||||
mp_obj_get_int(mp_call_method_n_kw(0, 0, mount_obj->count)) < 2048) {
|
||||
sfd = 1;
|
||||
}
|
||||
} else if ((mount_obj = osmount_find_by_path(path))) {
|
||||
if (mount_obj->device != (mp_obj_t)&pybsd_obj &&
|
||||
mp_obj_get_int(mp_call_method_n_kw(0, 0, mount_obj->count)) < 2048) {
|
||||
sfd = 1;
|
||||
}
|
||||
}
|
||||
|
||||
// now format the device
|
||||
res = f_mkfs(path, sfd, 0);
|
||||
|
||||
if (unmt) {
|
||||
unmount (path);
|
||||
if (unmt && mount_obj) {
|
||||
unmount (mount_obj);
|
||||
}
|
||||
|
||||
if (res != FR_OK) {
|
||||
|
||||
@@ -57,5 +57,6 @@ typedef struct _os_term_dup_obj_t {
|
||||
void moduos_init0 (void);
|
||||
os_fs_mount_t *osmount_find_by_path (const char *path);
|
||||
os_fs_mount_t *osmount_find_by_volume (uint8_t vol);
|
||||
void osmount_unmount_all (void);
|
||||
|
||||
#endif // MODUOS_H_
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
|
||||
#include "simplelink.h"
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/obj.h"
|
||||
#include "py/objstr.h"
|
||||
#include "py/runtime.h"
|
||||
@@ -157,6 +156,8 @@ STATIC mp_obj_t socket_make_new(mp_obj_t type_in, mp_uint_t n_args, mp_uint_t n_
|
||||
if (wlan_socket_socket(s, &_errno) != 0) {
|
||||
nlr_raise(mp_obj_new_exception_arg1(&mp_type_OSError, MP_OBJ_NEW_SMALL_INT(-_errno)));
|
||||
}
|
||||
// add the socket to the list
|
||||
modusocket_socket_add(s->sock_base.sd, true);
|
||||
return s;
|
||||
}
|
||||
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
|
||||
#include "simplelink.h"
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/obj.h"
|
||||
#include "py/objstr.h"
|
||||
#include "py/runtime.h"
|
||||
@@ -104,6 +103,10 @@ STATIC mp_obj_t mod_ssl_wrap_socket(mp_uint_t n_args, const mp_obj_t *pos_args,
|
||||
|
||||
_i16 sd = ((mod_network_socket_obj_t *)args[0].u_obj)->sock_base.sd;
|
||||
_i16 _errno;
|
||||
_u8 method = SL_SO_SEC_METHOD_TLSV1;
|
||||
if ((_errno = sl_SetSockOpt(sd, SL_SOL_SOCKET, SL_SO_SECMETHOD, &method, sizeof(method))) < 0) {
|
||||
goto socket_error;
|
||||
}
|
||||
if (keyfile && (_errno = sl_SetSockOpt(sd, SL_SOL_SOCKET, SL_SO_SECURE_FILES_PRIVATE_KEY_FILE_NAME, keyfile, strlen(keyfile))) < 0) {
|
||||
goto socket_error;
|
||||
}
|
||||
|
||||
@@ -29,10 +29,10 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/nlr.h"
|
||||
#include "py/obj.h"
|
||||
#include "py/smallint.h"
|
||||
#include "py/mphal.h"
|
||||
#include "timeutils.h"
|
||||
#include "inc/hw_types.h"
|
||||
#include "inc/hw_ints.h"
|
||||
@@ -125,7 +125,7 @@ MP_DEFINE_CONST_FUN_OBJ_0(time_time_obj, time_time);
|
||||
STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) {
|
||||
int32_t sleep_s = mp_obj_get_int(seconds_o);
|
||||
if (sleep_s > 0) {
|
||||
HAL_Delay(sleep_s * 1000);
|
||||
mp_hal_delay_ms(sleep_s * 1000);
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
@@ -134,7 +134,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(time_sleep_obj, time_sleep);
|
||||
STATIC mp_obj_t time_sleep_ms (mp_obj_t ms_in) {
|
||||
mp_int_t ms = mp_obj_get_int(ms_in);
|
||||
if (ms > 0) {
|
||||
HAL_Delay(ms);
|
||||
mp_hal_delay_ms(ms);
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
@@ -151,7 +151,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(time_sleep_us_obj, time_sleep_us);
|
||||
|
||||
STATIC mp_obj_t time_ticks_ms(void) {
|
||||
// We want to "cast" the 32 bit unsigned into a 30-bit small-int
|
||||
return MP_OBJ_NEW_SMALL_INT(HAL_GetTick() & MP_SMALL_INT_POSITIVE_MASK);
|
||||
return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_ms() & MP_SMALL_INT_POSITIVE_MASK);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(time_ticks_ms_obj, time_ticks_ms);
|
||||
|
||||
|
||||
@@ -1,5 +1,4 @@
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "mperror.h"
|
||||
|
||||
@@ -30,10 +30,10 @@
|
||||
|
||||
#include "simplelink.h"
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/obj.h"
|
||||
#include "py/objstr.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/mphal.h"
|
||||
#include "inc/hw_types.h"
|
||||
#include "inc/hw_ints.h"
|
||||
#include "inc/hw_memmap.h"
|
||||
@@ -110,7 +110,6 @@ typedef enum{
|
||||
#define MODWLAN_SL_SCAN_DISABLE 0
|
||||
#define MODWLAN_SL_MAX_NETWORKS 20
|
||||
|
||||
#define MODWLAN_TIMEOUT_MS 5000
|
||||
#define MODWLAN_MAX_NETWORKS 20
|
||||
#define MODWLAN_SCAN_PERIOD_S 3600 // 1 hour
|
||||
#define MODWLAN_WAIT_FOR_SCAN_MS 1050
|
||||
@@ -691,7 +690,7 @@ STATIC void wlan_sl_disconnect (void) {
|
||||
// other return-codes
|
||||
if (0 == sl_WlanDisconnect()) {
|
||||
while (IS_CONNECTED(wlan_obj.status)) {
|
||||
HAL_Delay(MODWLAN_CONNECTION_WAIT_MS);
|
||||
mp_hal_delay_ms(MODWLAN_CONNECTION_WAIT_MS);
|
||||
wlan_update();
|
||||
}
|
||||
}
|
||||
@@ -711,7 +710,7 @@ STATIC modwlan_Status_t wlan_do_connect (const char* ssid, uint32_t ssid_len, co
|
||||
// wait for the WLAN Event
|
||||
uint32_t waitForConnectionMs = 0;
|
||||
while (timeout && !IS_CONNECTED(wlan_obj.status)) {
|
||||
HAL_Delay(MODWLAN_CONNECTION_WAIT_MS);
|
||||
mp_hal_delay_ms(MODWLAN_CONNECTION_WAIT_MS);
|
||||
waitForConnectionMs += MODWLAN_CONNECTION_WAIT_MS;
|
||||
if (timeout > 0 && waitForConnectionMs > timeout) {
|
||||
return MODWLAN_ERROR_TIMEOUT;
|
||||
@@ -875,7 +874,7 @@ STATIC mp_obj_t wlan_scan(mp_obj_t self_in) {
|
||||
ASSERT_ON_ERROR(sl_WlanPolicySet(SL_POLICY_SCAN , MODWLAN_SL_SCAN_ENABLE, (_u8 *)&scanSeconds, sizeof(scanSeconds)));
|
||||
|
||||
// wait for the scan to complete
|
||||
HAL_Delay (MODWLAN_WAIT_FOR_SCAN_MS);
|
||||
mp_hal_delay_ms(MODWLAN_WAIT_FOR_SCAN_MS);
|
||||
|
||||
do {
|
||||
if (sl_WlanGetNetworkList(_index++, 1, &wlanEntry) <= 0) {
|
||||
@@ -1187,6 +1186,9 @@ STATIC mp_obj_t wlan_irq (mp_uint_t n_args, const mp_obj_t *pos_args, mp_map_t *
|
||||
mp_obj_t _irq = mp_irq_new (self, args[2].u_obj, &wlan_irq_methods);
|
||||
self->irq_obj = _irq;
|
||||
|
||||
// enable the irq just before leaving
|
||||
wlan_lpds_irq_enable(self);
|
||||
|
||||
return _irq;
|
||||
|
||||
invalid_args:
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/nlr.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/binary.h"
|
||||
|
||||
@@ -29,8 +29,8 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "py/mpstate.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/runtime.h"
|
||||
#include "py/mphal.h"
|
||||
#include "bufhelper.h"
|
||||
#include "inc/hw_types.h"
|
||||
#include "inc/hw_i2c.h"
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/gc.h"
|
||||
@@ -73,6 +72,7 @@ STATIC void pin_validate_mode (uint mode);
|
||||
STATIC void pin_validate_pull (uint pull);
|
||||
STATIC void pin_validate_drive (uint strength);
|
||||
STATIC void pin_validate_af(const pin_obj_t* pin, int8_t idx, uint8_t *fn, uint8_t *unit, uint8_t *type);
|
||||
STATIC uint8_t pin_get_value(const pin_obj_t* self);
|
||||
STATIC void GPIOA0IntHandler (void);
|
||||
STATIC void GPIOA1IntHandler (void);
|
||||
STATIC void GPIOA2IntHandler (void);
|
||||
@@ -289,16 +289,14 @@ STATIC void pin_obj_configure (const pin_obj_t *self) {
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
// configure the direction
|
||||
MAP_GPIODirModeSet(self->port, self->bit, direction);
|
||||
// set the pin value
|
||||
if (self->value) {
|
||||
MAP_GPIOPinWrite(self->port, self->bit, self->bit);
|
||||
} else {
|
||||
MAP_GPIOPinWrite(self->port, self->bit, 0);
|
||||
}
|
||||
|
||||
// configure the direction
|
||||
MAP_GPIODirModeSet(self->port, self->bit, direction);
|
||||
}
|
||||
// now set the alternate function
|
||||
MAP_PinModeSet (self->pin_num, self->af);
|
||||
@@ -456,6 +454,29 @@ STATIC void pin_validate_af(const pin_obj_t* pin, int8_t idx, uint8_t *fn, uint8
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, mpexception_value_invalid_arguments));
|
||||
}
|
||||
|
||||
STATIC uint8_t pin_get_value (const pin_obj_t* self) {
|
||||
uint32_t value;
|
||||
bool setdir = false;
|
||||
if (self->mode == PIN_TYPE_OD || self->mode == GPIO_DIR_MODE_ALT_OD) {
|
||||
setdir = true;
|
||||
// configure the direction to IN for a moment in order to read the pin value
|
||||
MAP_GPIODirModeSet(self->port, self->bit, GPIO_DIR_MODE_IN);
|
||||
}
|
||||
// now get the value
|
||||
value = MAP_GPIOPinRead(self->port, self->bit);
|
||||
if (setdir) {
|
||||
// set the direction back to output
|
||||
MAP_GPIODirModeSet(self->port, self->bit, GPIO_DIR_MODE_OUT);
|
||||
if (self->value) {
|
||||
MAP_GPIOPinWrite(self->port, self->bit, self->bit);
|
||||
} else {
|
||||
MAP_GPIOPinWrite(self->port, self->bit, 0);
|
||||
}
|
||||
}
|
||||
// return it
|
||||
return value ? 1 : 0;
|
||||
}
|
||||
|
||||
STATIC void GPIOA0IntHandler (void) {
|
||||
EXTI_Handler(GPIOA0_BASE);
|
||||
}
|
||||
@@ -648,8 +669,8 @@ MP_DEFINE_CONST_FUN_OBJ_KW(pin_init_obj, 1, pin_obj_init);
|
||||
STATIC mp_obj_t pin_value(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
pin_obj_t *self = args[0];
|
||||
if (n_args == 1) {
|
||||
// get the pin value
|
||||
return MP_OBJ_NEW_SMALL_INT(MAP_GPIOPinRead(self->port, self->bit) ? 1 : 0);
|
||||
// get the value
|
||||
return MP_OBJ_NEW_SMALL_INT(pin_get_value(self));
|
||||
} else {
|
||||
// set the pin value
|
||||
if (mp_obj_is_true(args[1])) {
|
||||
|
||||
@@ -28,7 +28,6 @@
|
||||
#include <std.h>
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "inc/hw_types.h"
|
||||
|
||||
@@ -25,7 +25,6 @@
|
||||
*/
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "inc/hw_types.h"
|
||||
|
||||
@@ -28,8 +28,8 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "py/mpstate.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/runtime.h"
|
||||
#include "py/mphal.h"
|
||||
#include "inc/hw_types.h"
|
||||
#include "inc/hw_ints.h"
|
||||
#include "inc/hw_nvic.h"
|
||||
@@ -247,7 +247,7 @@ void pyb_sleep_sleep (void) {
|
||||
if (pybsleep_data.rtc_obj->irq_enabled && (pybsleep_data.rtc_obj->pwrmode & PYB_PWR_MODE_LPDS)) {
|
||||
if (!setup_timer_lpds_wake()) {
|
||||
// lpds entering is not possible, wait for the forced interrupt and return
|
||||
HAL_Delay (FAILED_SLEEP_DELAY_MS);
|
||||
mp_hal_delay_ms(FAILED_SLEEP_DELAY_MS);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
@@ -280,7 +280,7 @@ void pyb_sleep_deepsleep (void) {
|
||||
if (pybsleep_data.rtc_obj->irq_enabled && (pybsleep_data.rtc_obj->pwrmode & PYB_PWR_MODE_HIBERNATE)) {
|
||||
if (!setup_timer_hibernate_wake()) {
|
||||
// hibernating is not possible, wait for the forced interrupt and return
|
||||
HAL_Delay (FAILED_SLEEP_DELAY_MS);
|
||||
mp_hal_delay_ms(FAILED_SLEEP_DELAY_MS);
|
||||
return;
|
||||
}
|
||||
} else {
|
||||
|
||||
@@ -29,7 +29,6 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "py/mpstate.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/runtime.h"
|
||||
#include "bufhelper.h"
|
||||
#include "inc/hw_types.h"
|
||||
|
||||
@@ -30,11 +30,11 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/obj.h"
|
||||
#include "py/nlr.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/gc.h"
|
||||
#include "py/mphal.h"
|
||||
#include "inc/hw_types.h"
|
||||
#include "inc/hw_ints.h"
|
||||
#include "inc/hw_memmap.h"
|
||||
|
||||
@@ -31,11 +31,11 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/objlist.h"
|
||||
#include "py/stream.h"
|
||||
#include "py/mphal.h"
|
||||
#include "inc/hw_types.h"
|
||||
#include "inc/hw_ints.h"
|
||||
#include "inc/hw_memmap.h"
|
||||
|
||||
@@ -27,9 +27,9 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/mphal.h"
|
||||
#include "inc/hw_types.h"
|
||||
#include "inc/hw_gpio.h"
|
||||
#include "inc/hw_ints.h"
|
||||
|
||||
@@ -30,6 +30,11 @@
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
#ifndef BOOTLOADER
|
||||
#include "FreeRTOS.h"
|
||||
#include "semphr.h"
|
||||
#endif
|
||||
|
||||
// options to control how Micro Python is built
|
||||
|
||||
#define MICROPY_ALLOC_PATH_MAX (128)
|
||||
@@ -56,14 +61,16 @@
|
||||
#endif
|
||||
#define MICROPY_QSTR_BYTES_IN_HASH (1)
|
||||
|
||||
/* Enable FatFS LFNs
|
||||
0: Disable LFN feature.
|
||||
1: Enable LFN with static working buffer on the BSS. Always NOT reentrant.
|
||||
2: Enable LFN with dynamic working buffer on the STACK.
|
||||
3: Enable LFN with dynamic working buffer on the HEAP.
|
||||
*/
|
||||
#define MICROPY_ENABLE_LFN (2)
|
||||
#define MICROPY_LFN_CODE_PAGE (437) // 1=SFN/ANSI 437=LFN/U.S.(OEM)
|
||||
// fatfs configuration used in ffconf.h
|
||||
#define MICROPY_FATFS_ENABLE_LFN (2)
|
||||
#define MICROPY_FATFS_MAX_LFN (MICROPY_ALLOC_PATH_MAX)
|
||||
#define MICROPY_FATFS_LFN_CODE_PAGE (437) // 1=SFN/ANSI 437=LFN/U.S.(OEM)
|
||||
#define MICROPY_FATFS_RPATH (2)
|
||||
#define MICROPY_FATFS_VOLUMES (2)
|
||||
#define MICROPY_FATFS_REENTRANT (1)
|
||||
#define MICROPY_FATFS_TIMEOUT (2500)
|
||||
#define MICROPY_FATFS_SYNC_T SemaphoreHandle_t
|
||||
|
||||
#define MICROPY_STREAMS_NON_BLOCK (1)
|
||||
#define MICROPY_MODULE_WEAK_LINKS (1)
|
||||
#define MICROPY_CAN_OVERRIDE_BUILTINS (1)
|
||||
@@ -180,7 +187,6 @@ typedef void *machine_ptr_t; // must be of pointer size
|
||||
typedef const void *machine_const_ptr_t; // must be of pointer size
|
||||
typedef long mp_off_t;
|
||||
|
||||
void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len);
|
||||
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
|
||||
|
||||
#define MICROPY_BEGIN_ATOMIC_SECTION() disable_irq()
|
||||
@@ -204,7 +210,7 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len);
|
||||
// Include board specific configuration
|
||||
#include "mpconfigboard.h"
|
||||
|
||||
#define MICROPY_HAL_H "cc3200_hal.h"
|
||||
#define MICROPY_MPHALPORT_H "cc3200_hal.h"
|
||||
#define MICROPY_PORT_HAS_TELNET (1)
|
||||
#define MICROPY_PORT_HAS_FTP (1)
|
||||
#define MICROPY_PY_SYS_PLATFORM "WiPy"
|
||||
|
||||
@@ -28,10 +28,10 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include "py/gc.h"
|
||||
#include "py/mphal.h"
|
||||
#include "inc/hw_memmap.h"
|
||||
#include "inc/hw_types.h"
|
||||
#include "inc/hw_ints.h"
|
||||
@@ -43,7 +43,7 @@
|
||||
#include "pybuart.h"
|
||||
#include "pybpin.h"
|
||||
#include "pybrtc.h"
|
||||
#include "pyexec.h"
|
||||
#include "lib/utils/pyexec.h"
|
||||
#include "gccollect.h"
|
||||
#include "gchelper.h"
|
||||
#include "readline.h"
|
||||
@@ -235,8 +235,11 @@ soft_reset_exit:
|
||||
// clean-up the user socket space
|
||||
modusocket_close_all_user_sockets();
|
||||
|
||||
// unmount all user file systems
|
||||
osmount_unmount_all();
|
||||
|
||||
// wait for pending transactions to complete
|
||||
HAL_Delay(20);
|
||||
mp_hal_delay_ms(20);
|
||||
|
||||
goto soft_reset;
|
||||
}
|
||||
|
||||
@@ -228,6 +228,10 @@ Q(register)
|
||||
Q(unregister)
|
||||
Q(modify)
|
||||
Q(poll)
|
||||
Q(POLLIN)
|
||||
Q(POLLOUT)
|
||||
Q(POLLERR)
|
||||
Q(POLLHUP)
|
||||
|
||||
// for socket class
|
||||
Q(socket)
|
||||
|
||||
@@ -28,9 +28,9 @@
|
||||
#include <string.h>
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/misc.h"
|
||||
#include "py/nlr.h"
|
||||
#include "py/mphal.h"
|
||||
#include "serverstask.h"
|
||||
#include "simplelink.h"
|
||||
#include "debug.h"
|
||||
@@ -131,21 +131,21 @@ void TASK_Servers (void *pvParameters) {
|
||||
|
||||
// move to the next cycle
|
||||
cycle = cycle ? false : true;
|
||||
HAL_Delay(SERVERS_CYCLE_TIME_MS);
|
||||
mp_hal_delay_ms(SERVERS_CYCLE_TIME_MS);
|
||||
}
|
||||
}
|
||||
|
||||
void servers_start (void) {
|
||||
servers_data.do_enable = true;
|
||||
HAL_Delay (SERVERS_CYCLE_TIME_MS * 3);
|
||||
mp_hal_delay_ms(SERVERS_CYCLE_TIME_MS * 3);
|
||||
}
|
||||
|
||||
void servers_stop (void) {
|
||||
servers_data.do_disable = true;
|
||||
do {
|
||||
HAL_Delay (SERVERS_CYCLE_TIME_MS);
|
||||
mp_hal_delay_ms(SERVERS_CYCLE_TIME_MS);
|
||||
} while (servers_are_enabled());
|
||||
HAL_Delay (SERVERS_CYCLE_TIME_MS * 3);
|
||||
mp_hal_delay_ms(SERVERS_CYCLE_TIME_MS * 3);
|
||||
}
|
||||
|
||||
void servers_reset (void) {
|
||||
@@ -158,7 +158,7 @@ bool servers_are_enabled (void) {
|
||||
|
||||
void server_sleep_sockets (void) {
|
||||
sleep_sockets = true;
|
||||
HAL_Delay (SERVERS_CYCLE_TIME_MS + 1);
|
||||
mp_hal_delay_ms(SERVERS_CYCLE_TIME_MS + 1);
|
||||
}
|
||||
|
||||
void servers_close_socket (int16_t *sd) {
|
||||
|
||||
@@ -44,9 +44,7 @@
|
||||
#include "task.h"
|
||||
#include "semphr.h"
|
||||
#include "portmacro.h"
|
||||
#include <osi.h>
|
||||
|
||||
#include "rom.h"
|
||||
#include "osi.h"
|
||||
#include "rom_map.h"
|
||||
#include "inc/hw_types.h"
|
||||
#include "interrupt.h"
|
||||
|
||||
@@ -27,8 +27,8 @@
|
||||
#include <stdint.h>
|
||||
|
||||
#include "py/mpconfig.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/obj.h"
|
||||
#include "py/mphal.h"
|
||||
#include "telnet.h"
|
||||
#include "simplelink.h"
|
||||
#include "modnetwork.h"
|
||||
@@ -451,9 +451,13 @@ static void telnet_parse_input (uint8_t *str, int16_t *len) {
|
||||
(*len)--;
|
||||
_str++;
|
||||
}
|
||||
else {
|
||||
else if (*_str > 0) {
|
||||
*str++ = *_str++;
|
||||
}
|
||||
else {
|
||||
_str++;
|
||||
*len -= 1;
|
||||
}
|
||||
}
|
||||
else {
|
||||
// in case we have received an incomplete telnet option, unlikely, but possible
|
||||
@@ -477,7 +481,7 @@ static bool telnet_send_with_retries (int16_t sd, const void *pBuf, int16_t len)
|
||||
return false;
|
||||
}
|
||||
// start with the default delay and increment it on each retry
|
||||
HAL_Delay (delay++);
|
||||
mp_hal_delay_ms(delay++);
|
||||
} while (++retries <= TELNET_TX_RETRIES_MAX);
|
||||
}
|
||||
return false;
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "py/gc.h"
|
||||
#include "gccollect.h"
|
||||
#include "gchelper.h"
|
||||
#include MICROPY_HAL_H
|
||||
|
||||
/******************************************************************************
|
||||
DECLARE PRIVATE DATA
|
||||
|
||||
@@ -27,6 +27,6 @@
|
||||
#ifndef VERSION_H_
|
||||
#define VERSION_H_
|
||||
|
||||
#define WIPY_SW_VERSION_NUMBER "1.1.0"
|
||||
#define WIPY_SW_VERSION_NUMBER "1.1.1"
|
||||
|
||||
#endif /* VERSION_H_ */
|
||||
|
||||
28
docs/README.md
Normal file
28
docs/README.md
Normal file
@@ -0,0 +1,28 @@
|
||||
MicroPython Documentation
|
||||
=========================
|
||||
|
||||
The MicroPython documentation can be found at:
|
||||
http://docs.micropython.org/en/latest/
|
||||
|
||||
The documentation you see there is generated from the files in the docs tree:
|
||||
https://github.com/micropython/micropython/tree/master/docs
|
||||
|
||||
Building the documentation locally
|
||||
----------------------------------
|
||||
|
||||
If you're making changes to the documentation, you may want to build the
|
||||
documentation locally so that you can preview your changes.
|
||||
|
||||
Install Sphinx, and optionally (for the RTD-styling), sphinx_rtd_theme,
|
||||
preferably in a virtualenv:
|
||||
|
||||
pip install sphinx
|
||||
pip install sphinx_rtd_theme
|
||||
|
||||
In `micropython/docs`, build the docs:
|
||||
|
||||
make MICROPY_PORT=<port_name> BUILDDIR=build/<port_name> html
|
||||
|
||||
Where `<port_name>` can be `unix`, `pyboard`, `wipy` or `esp8266`.
|
||||
|
||||
You'll find the index page at `micropython/docs/build/<port_name>/html/index.html`.
|
||||
@@ -60,7 +60,7 @@ copyright = '2014, Damien P. George'
|
||||
# The short X.Y version.
|
||||
version = '1.5'
|
||||
# The full version, including alpha/beta/rc tags.
|
||||
release = '1.5'
|
||||
release = '1.5.1'
|
||||
|
||||
# The language for content autogenerated by Sphinx. Refer to documentation
|
||||
# for a list of supported languages.
|
||||
|
||||
@@ -17,6 +17,19 @@ The following standard Python libraries are built in to MicroPython.
|
||||
For additional libraries, please download them from the `micropython-lib repository
|
||||
<https://github.com/micropython/micropython-lib>`_.
|
||||
|
||||
.. only:: port_unix
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
cmath.rst
|
||||
gc.rst
|
||||
math.rst
|
||||
os.rst
|
||||
struct.rst
|
||||
sys.rst
|
||||
time.rst
|
||||
|
||||
.. only:: port_pyboard
|
||||
|
||||
.. toctree::
|
||||
@@ -50,13 +63,15 @@ the philosophy of MicroPython. They provide the core functionality of that
|
||||
module and are intended to be a drop-in replacement for the standard Python
|
||||
library.
|
||||
|
||||
The modules are available by their u-name, and also by their non-u-name. The
|
||||
non-u-name can be overridden by a file of that name in your package path.
|
||||
For example, ``import json`` will first search for a file ``json.py`` or
|
||||
directory ``json`` and load that package if it is found. If nothing is found,
|
||||
it will fallback to loading the built-in ``ujson`` module.
|
||||
.. only:: not port_unix
|
||||
|
||||
.. only:: port_pyboard
|
||||
The modules are available by their u-name, and also by their non-u-name. The
|
||||
non-u-name can be overridden by a file of that name in your package path.
|
||||
For example, ``import json`` will first search for a file ``json.py`` or
|
||||
directory ``json`` and load that package if it is found. If nothing is found,
|
||||
it will fallback to loading the built-in ``ujson`` module.
|
||||
|
||||
.. only:: port_pyboard or port_unix
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
@@ -9,8 +9,8 @@ and time.
|
||||
Example usage::
|
||||
|
||||
rtc = machine.RTC()
|
||||
rtc.datetime((2014, 5, 1, 4, 13, 0, 0, 0))
|
||||
print(rtc.datetime())
|
||||
rtc.init((2014, 5, 1, 4, 13, 0, 0, 0))
|
||||
print(rtc.now())
|
||||
|
||||
|
||||
Constructors
|
||||
@@ -23,7 +23,7 @@ Constructors
|
||||
Methods
|
||||
-------
|
||||
|
||||
.. method:: rtc.init(id, datetime)
|
||||
.. method:: rtc.init(datetime)
|
||||
|
||||
Initialise the RTC. Datetime is a tuple of the form:
|
||||
|
||||
|
||||
@@ -98,33 +98,34 @@ Methods
|
||||
|
||||
Read characters. If ``nbytes`` is specified then read at most that many bytes.
|
||||
|
||||
Return value: a bytes object containing the bytes read in. Returns ``b''``
|
||||
Return value: a bytes object containing the bytes read in. Returns ``None``
|
||||
on timeout.
|
||||
|
||||
.. method:: uart.readall()
|
||||
|
||||
Read as much data as possible.
|
||||
|
||||
Return value: a bytes object.
|
||||
Return value: a bytes object or ``None`` on timeout.
|
||||
|
||||
.. method:: uart.readinto(buf[, nbytes])
|
||||
|
||||
Read bytes into the ``buf``. If ``nbytes`` is specified then read at most
|
||||
that many bytes. Otherwise, read at most ``len(buf)`` bytes.
|
||||
|
||||
Return value: number of bytes read and stored into ``buf``.
|
||||
Return value: number of bytes read and stored into ``buf`` or ``None`` on
|
||||
timeout.
|
||||
|
||||
.. method:: uart.readline()
|
||||
|
||||
Read a line, ending in a newline character.
|
||||
|
||||
Return value: the line read.
|
||||
Return value: the line read or ``None`` on timeout.
|
||||
|
||||
.. method:: uart.write(buf)
|
||||
|
||||
Write the buffer of bytes to the bus.
|
||||
|
||||
Return value: number of bytes written.
|
||||
Return value: number of bytes written or ``None`` on timeout.
|
||||
|
||||
.. method:: uart.sendbreak()
|
||||
|
||||
|
||||
@@ -63,7 +63,7 @@ For example::
|
||||
|
||||
.. method:: server.isrunning()
|
||||
|
||||
Returns ``True`` is the server is running, ``False`` otherwise.
|
||||
Returns ``True`` if the server is running, ``False`` otherwise.
|
||||
|
||||
.. only:: port_pyboard
|
||||
|
||||
@@ -299,7 +299,7 @@ For example::
|
||||
class WLAN
|
||||
==========
|
||||
|
||||
This class provides a driver for WiFi network processor in the WiPy. Example usage::
|
||||
This class provides a driver for the WiFi network processor in the WiPy. Example usage::
|
||||
|
||||
import network
|
||||
import time
|
||||
@@ -357,7 +357,7 @@ For example::
|
||||
# configure as an station
|
||||
wlan.init(mode=WLAN.STA)
|
||||
|
||||
.. method:: wlan.connect(ssid, \*, auth=None, bssid=None, timeout=5000)
|
||||
.. method:: wlan.connect(ssid, \*, auth=None, bssid=None, timeout=None)
|
||||
|
||||
Connect to a wifi access point using the given SSID, and other security
|
||||
parameters.
|
||||
@@ -365,7 +365,7 @@ For example::
|
||||
- ``auth`` is a tuple with (sec, key). Security can be ``None``, ``WLAN.WEP``,
|
||||
``WLAN.WPA`` or ``WLAN.WPA2``. The key is a string with the network password.
|
||||
If ``sec`` is ``WLAN.WEP`` the key must be a string representing hexadecimal
|
||||
values (e.g. 'ABC1DE45BF'). Only needed when mode is ``WLAN.AP``
|
||||
values (e.g. 'ABC1DE45BF').
|
||||
- ``bssid`` is the MAC address of the AP to connect to. Useful when there are several
|
||||
APs with the same ssid.
|
||||
- ``timeout`` is the maximum time in milliseconds to wait for the connection to succeed.
|
||||
|
||||
@@ -119,14 +119,14 @@ Methods
|
||||
*Note:* for 9 bit characters each character takes two bytes, ``nbytes`` must
|
||||
be even, and the number of characters is ``nbytes/2``.
|
||||
|
||||
Return value: a bytes object containing the bytes read in. Returns ``b''``
|
||||
Return value: a bytes object containing the bytes read in. Returns ``None``
|
||||
on timeout.
|
||||
|
||||
.. method:: uart.readall()
|
||||
|
||||
Read as much data as possible.
|
||||
|
||||
Return value: a bytes object.
|
||||
Return value: a bytes object or ``None`` on timeout.
|
||||
|
||||
.. method:: uart.readchar()
|
||||
|
||||
@@ -139,13 +139,14 @@ Methods
|
||||
Read bytes into the ``buf``. If ``nbytes`` is specified then read at most
|
||||
that many bytes. Otherwise, read at most ``len(buf)`` bytes.
|
||||
|
||||
Return value: number of bytes read and stored into ``buf``.
|
||||
Return value: number of bytes read and stored into ``buf`` or ``None`` on
|
||||
timeout.
|
||||
|
||||
.. method:: uart.readline()
|
||||
|
||||
Read a line, ending in a newline character.
|
||||
|
||||
Return value: the line read.
|
||||
Return value: the line read or ``None`` on timeout.
|
||||
|
||||
.. method:: uart.write(buf)
|
||||
|
||||
@@ -156,7 +157,7 @@ Methods
|
||||
bytes are used for each character (little endian), and ``buf`` must contain
|
||||
an even number of bytes.
|
||||
|
||||
Return value: number of bytes written.
|
||||
Return value: number of bytes written or ``None`` on timeout.
|
||||
|
||||
.. method:: uart.sendbreak()
|
||||
|
||||
|
||||
@@ -43,12 +43,14 @@ Methods
|
||||
|
||||
Read at most ``nbytes`` from the serial device and return them as a
|
||||
bytes object. If ``nbytes`` is not specified then the method acts as
|
||||
``readall()``.
|
||||
``readall()``. USB_VCP stream implicitly works in non-blocking mode,
|
||||
so if no pending data available, this method will return immediately
|
||||
with ``None`` value.
|
||||
|
||||
.. method:: usb_vcp.readall()
|
||||
|
||||
Read all available bytes from the serial device and return them as
|
||||
a bytes object.
|
||||
a bytes object, or ``None`` if no pending data available.
|
||||
|
||||
.. method:: usb_vcp.readinto(buf, [maxlen])
|
||||
|
||||
@@ -57,14 +59,15 @@ Methods
|
||||
If ``maxlen`` is given and then at most ``min(maxlen, len(buf))`` bytes
|
||||
are read.
|
||||
|
||||
Returns the number of bytes read and stored into ``buf``.
|
||||
Returns the number of bytes read and stored into ``buf`` or ``None``
|
||||
if no pending data available.
|
||||
|
||||
.. method:: usb_vcp.readline()
|
||||
|
||||
Read a whole line from the serial device.
|
||||
|
||||
Returns a bytes object containing the data, including the trailing
|
||||
newline character.
|
||||
newline character or ``None`` if no pending data available.
|
||||
|
||||
.. method:: usb_vcp.readlines()
|
||||
|
||||
|
||||
@@ -38,8 +38,14 @@ Methods
|
||||
|
||||
.. method:: poll.register(obj[, eventmask])
|
||||
|
||||
Register ``obj`` for polling. ``eventmask`` is 1 for read, 2 for
|
||||
write, 3 for read-write.
|
||||
Register ``obj`` for polling. ``eventmask`` is logical OR of:
|
||||
|
||||
* ``select.POLLIN`` - data available for reading
|
||||
* ``select.POLLOUT`` - more data can be written
|
||||
* ``select.POLLERR`` - error occurred
|
||||
* ``select.POLLHUP`` - end of stream/connection termination detected
|
||||
|
||||
``eventmask`` defaults to ``select.POLLIN | select.POLLOUT``.
|
||||
|
||||
.. method:: poll.unregister(obj)
|
||||
|
||||
@@ -52,6 +58,10 @@ Methods
|
||||
.. method:: poll.poll([timeout])
|
||||
|
||||
Wait for at least one of the registered objects to become ready. Returns
|
||||
list of ready objects, or empty list on timeout.
|
||||
list of (``obj``, ``event``, ...) tuples, ``event`` element specifies
|
||||
which events happened with a stream and is a combination of `select.POLL*`
|
||||
constants described above. There may be other elements in tuple, depending
|
||||
on platform and version, so don't assume that its size is 2. In case of
|
||||
timeout, an empty list is returned.
|
||||
|
||||
Timeout is in milliseconds.
|
||||
|
||||
@@ -46,6 +46,8 @@ Functions
|
||||
ss = ssl.wrap_socket(s, cert_reqs=ssl.CERT_REQUIRED, ca_certs='/flash/cert/ca.pem')
|
||||
ss.connect(socket.getaddrinfo('cloud.blynk.cc', 8441)[0][4])
|
||||
|
||||
SSL sockets inherit all methods and from the standard sockets, see the :mod:`usocket` module.
|
||||
|
||||
Exceptions
|
||||
----------
|
||||
|
||||
|
||||
@@ -9,6 +9,11 @@ documentation at
|
||||
Differences to standard Python as well as additional features of
|
||||
MicroPython are described in the sections here.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
repl.rst
|
||||
|
||||
.. only:: port_pyboard
|
||||
|
||||
.. toctree::
|
||||
|
||||
211
docs/reference/repl.rst
Normal file
211
docs/reference/repl.rst
Normal file
@@ -0,0 +1,211 @@
|
||||
The MicroPython Interactive Interpreter Mode (aka REPL)
|
||||
=======================================================
|
||||
|
||||
This section covers some characteristics of the MicroPython Interactive
|
||||
Interpreter Mode. A commonly used term for this is REPL (read-eval-print-loop)
|
||||
which will be used to refer to this interactive prompt.
|
||||
|
||||
Auto-indent
|
||||
-----------
|
||||
|
||||
When typing python statements which end in a colon (for example if, for, while)
|
||||
then the prompt will change to three dots (...) and the cursor will be indented
|
||||
by 4 spaces. When you press return, the next line will continue at the same
|
||||
level of indentation for regular statements or an additional level of indentation
|
||||
where appropriate. If you press the backspace key then it will undo one
|
||||
level of indentation.
|
||||
|
||||
If your cursor is all the way back at the beginning, pressing RETURN will then
|
||||
execute the code that you've entered. The following shows what you'd see
|
||||
after entering a for statement (the underscore shows where the cursor winds up):
|
||||
|
||||
>>> for i in range(3):
|
||||
... _
|
||||
|
||||
If you then enter an if statement, an additional level of indentation will be
|
||||
provided:
|
||||
|
||||
>>> for i in range(30):
|
||||
... if i > 3:
|
||||
... _
|
||||
|
||||
Now enter ``break`` followed by RETURN and press BACKSPACE:
|
||||
|
||||
>>> for i in range(30):
|
||||
... if i > 3:
|
||||
... break
|
||||
... _
|
||||
|
||||
Finally type ``print(i)``, press RETURN, press BACKSPACE and press RETURN again:
|
||||
|
||||
>>> for i in range(30):
|
||||
... if i > 3:
|
||||
... break
|
||||
... print(i)
|
||||
...
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
>>>
|
||||
|
||||
Auto-indent won't be applied if the previous two lines were all spaces. This
|
||||
means that you can finish entering a compound statment by pressing RETURN
|
||||
twice, and then a third press will finish and execute.
|
||||
|
||||
Auto-completion
|
||||
---------------
|
||||
|
||||
While typing a command at the REPL, if the line typed so far corresponds to
|
||||
the beginning of the name of something, then pressing TAB will show
|
||||
possible things that could be entered. For example type ``m`` and press TAB
|
||||
and it should expand to ``machine``. Enter a dot ``.`` and press TAB again. You
|
||||
should see something like:
|
||||
|
||||
>>> machine.
|
||||
__name__ info unique_id reset
|
||||
bootloader freq rng idle
|
||||
sleep deepsleep disable_irq enable_irq
|
||||
Pin
|
||||
|
||||
The word will be expanded as much as possible until multiple possibilities exist.
|
||||
For example, type ``machine.Pin.AF3`` and press TAB and it will expand to
|
||||
``machine.Pin.AF3_TIM``. Pressing TAB a second time will show the possible
|
||||
expansions:
|
||||
|
||||
>>> machine.Pin.AF3_TIM
|
||||
AF3_TIM10 AF3_TIM11 AF3_TIM8 AF3_TIM9
|
||||
>>> machine.Pin.AF3_TIM
|
||||
|
||||
Interrupting a running program
|
||||
------------------------------
|
||||
|
||||
You can interupt a running program by pressing Ctrl-C. This will raise a KeyboardInterrupt
|
||||
which will bring you back to the REPL, providing your program doesn't intercept the
|
||||
KeyboardInterrupt exception.
|
||||
|
||||
For example:
|
||||
|
||||
>>> for i in range(1000000):
|
||||
... print(i)
|
||||
...
|
||||
0
|
||||
1
|
||||
2
|
||||
3
|
||||
...
|
||||
6466
|
||||
6467
|
||||
6468
|
||||
Traceback (most recent call last):
|
||||
File "<stdin>", line 2, in <module>
|
||||
KeyboardInterrupt:
|
||||
>>>
|
||||
|
||||
Paste Mode
|
||||
----------
|
||||
|
||||
If you want to paste some code into your terminal window, the auto-indent feature
|
||||
will mess things up. For example, if you had the following python code: ::
|
||||
|
||||
def foo():
|
||||
print('This is a test to show paste mode')
|
||||
print('Here is a second line')
|
||||
foo()
|
||||
|
||||
and you try to paste this into the normal REPL, then you will see something like
|
||||
this:
|
||||
|
||||
>>> def foo():
|
||||
... print('This is a test to show paste mode')
|
||||
... print('Here is a second line')
|
||||
... foo()
|
||||
...
|
||||
Traceback (most recent call last):
|
||||
File "<stdin>", line 3
|
||||
IndentationError: unexpected indent
|
||||
|
||||
If you press Ctrl-E, then you will enter paste mode, which essentially turns off
|
||||
the auto-indent feature, and changes the prompt from ``>>>`` to ``===``. For example:
|
||||
|
||||
>>>
|
||||
paste mode; Ctrl-C to cancel, Ctrl-D to finish
|
||||
=== def foo():
|
||||
=== print('This is a test to show paste mode')
|
||||
=== print('Here is a second line')
|
||||
=== foo()
|
||||
===
|
||||
This is a test to show paste mode
|
||||
Here is a second line
|
||||
>>>
|
||||
|
||||
Paste Mode allows blank lines to be pasted. The pasted text is compiled as if
|
||||
it were a file. Pressing Ctrl-D exits paste mode and initiates the compilation.
|
||||
|
||||
Soft Reset
|
||||
----------
|
||||
|
||||
A soft reset will reset the python interpreter, but tries not to reset the
|
||||
method by which you're connected to the MicroPython board (USB-serial, or Wifi).
|
||||
|
||||
You can perform a soft reset from the REPL by pressing Ctrl-D, or from your python
|
||||
code by executing: ::
|
||||
|
||||
raise SystemExit
|
||||
|
||||
For example, if you reset your MicroPython board, and you execute a dir()
|
||||
command, you'd see something like this:
|
||||
|
||||
>>> dir()
|
||||
['__name__', 'pyb']
|
||||
|
||||
Now create some variables and repeat the dir() command:
|
||||
|
||||
>>> i = 1
|
||||
>>> j = 23
|
||||
>>> x = 'abc'
|
||||
>>> dir()
|
||||
['j', 'x', '__name__', 'pyb', 'i']
|
||||
>>>
|
||||
|
||||
Now if you enter Ctrl-D, and repeat the dir() command, you'll see that your
|
||||
variables no longer exist:
|
||||
|
||||
.. code-block:: python
|
||||
|
||||
PYB: sync filesystems
|
||||
PYB: soft reboot
|
||||
MicroPython v1.5-51-g6f70283-dirty on 2015-10-30; PYBv1.0 with STM32F405RG
|
||||
Type "help()" for more information.
|
||||
>>> dir()
|
||||
['__name__', 'pyb']
|
||||
>>>
|
||||
|
||||
The special variable _ (underscore)
|
||||
-----------------------------------
|
||||
|
||||
When you use the REPL, you may perfom computations and see the results.
|
||||
MicroPython stores the results of the previous statment in the variable _ (underscore).
|
||||
So you can use the underscore to save the result in a variable. For example:
|
||||
|
||||
>>> 1 + 2 + 3 + 4 + 5
|
||||
15
|
||||
>>> x = _
|
||||
>>> x
|
||||
15
|
||||
>>>
|
||||
|
||||
Raw Mode
|
||||
--------
|
||||
|
||||
Raw mode is not something that a person would normally use. It is intended for
|
||||
programmatic use. It essentially behaves like paste mode with echo turned off.
|
||||
|
||||
Raw mode is entered using Ctrl-A. You then send your python code, followed by
|
||||
a Ctrl-D. The Ctrl-D will be acknowledged by 'OK' and then the python code will
|
||||
be compiled and executed. Any output (or errors) will be sent back. Entering
|
||||
Ctrl-B will leave raw mode and return the the regular (aka friendly) REPL.
|
||||
|
||||
The ``tools/pyboard.py`` program uses the raw REPL to execute python files on the
|
||||
MicroPython board.
|
||||
|
||||
8
docs/unix_contents.rst
Normal file
8
docs/unix_contents.rst
Normal file
@@ -0,0 +1,8 @@
|
||||
MicroPython documentation contents
|
||||
==================================
|
||||
|
||||
.. toctree::
|
||||
|
||||
library/index.rst
|
||||
reference/index.rst
|
||||
license.rst
|
||||
15
docs/unix_index.rst
Normal file
15
docs/unix_index.rst
Normal file
@@ -0,0 +1,15 @@
|
||||
MicroPython documentation and references
|
||||
========================================
|
||||
|
||||
.. toctree::
|
||||
|
||||
library/index.rst
|
||||
license.rst
|
||||
unix_contents.rst
|
||||
|
||||
Indices and tables
|
||||
==================
|
||||
|
||||
* :ref:`genindex`
|
||||
* :ref:`modindex`
|
||||
* :ref:`search`
|
||||
@@ -37,12 +37,14 @@ Telnet REPL
|
||||
-----------
|
||||
|
||||
Linux stock telnet works like a charm (also on OSX), but other tools like putty
|
||||
work quite too. The default credentials are: **user:** ``micro``, **password:** ``python``.
|
||||
work quite well too. The default credentials are: **user:** ``micro``, **password:** ``python``.
|
||||
See :ref:`network.server <network.server>` for info on how to change the defaults.
|
||||
For instance, on a linux shell (when connected to the WiPy in AP mode)::
|
||||
|
||||
$ telnet 192.168.1.1
|
||||
|
||||
.. _wipy_filesystem:
|
||||
|
||||
Local file system and FTP access
|
||||
--------------------------------
|
||||
|
||||
@@ -96,10 +98,15 @@ the WiPy by pressing the switch on the board, or by typing::
|
||||
>>> import machine
|
||||
>>> machine.reset()
|
||||
|
||||
Software updates can be found in: https://github.com/wipy/wipy/releases
|
||||
Software updates can be found in: https://github.com/wipy/wipy/releases (**Binaries.zip**).
|
||||
It's always recommended to update to the latest software, but make sure to
|
||||
read the **release notes** before.
|
||||
|
||||
.. note::
|
||||
|
||||
The ``bootloader.bin`` found inside ``Binaries.zip`` is there only for reference, it's not
|
||||
needed for the Over The Air update.
|
||||
|
||||
In order to check your software version, do::
|
||||
|
||||
>>> import os
|
||||
@@ -108,6 +115,7 @@ In order to check your software version, do::
|
||||
If the version number is lower than the latest release found in
|
||||
`the releases <https://github.com/wipy/wipy/releases>`_, go ahead and update your WiPy!
|
||||
|
||||
|
||||
.. _wipy_boot_modes:
|
||||
|
||||
Boot modes and safe boot
|
||||
@@ -140,10 +148,10 @@ and the WiPy will proceed to boot. The firmware selection mechanism is as follow
|
||||
| | firmware is selected | | user update selected | | firmware is selected |
|
||||
+-------------------------+-------------------------+----------------------------+
|
||||
|
||||
In any if the above 3 scenarios, safe boot mode is entered, meaning that
|
||||
On all of the above 3 scenarios, safe boot mode is entered, meaning that
|
||||
the execution of both ``boot.py`` and ``main.py`` is skipped. This is
|
||||
useful to recover from crash situations caused by the user scripts. The selection
|
||||
made during safe boot is not persistent, meaning that after the next normal reset,
|
||||
made during safe boot is not persistent, therefore after the next normal reset
|
||||
the latest firmware will run again.
|
||||
|
||||
The heartbeat LED
|
||||
@@ -157,7 +165,7 @@ alive. This can be overridden through the :mod:`wipy` module::
|
||||
|
||||
There are currently 2 kinds of errors that you might see:
|
||||
|
||||
1. If the heartbeat LED flashes quickly, then a Python script(eg ``main.py``)
|
||||
1. If the heartbeat LED flashes quickly, then a Python script (eg ``main.py``)
|
||||
has an error. Use the REPL to debug it.
|
||||
2. If the heartbeat LED stays on, then there was a hard fault, you cannot
|
||||
recover from this, the only way out is to press the reset switch.
|
||||
|
||||
@@ -18,7 +18,7 @@ See the :mod:`machine` module::
|
||||
machine.freq() # get the CPU frequency
|
||||
machine.unique_id() # return the 6-byte unique id of the board (the WiPy's MAC address)
|
||||
|
||||
machine.idle() # average curernt decreases to (~12mA), any interrupts wakes it up
|
||||
machine.idle() # average current decreases to (~12mA), any interrupts wake it up
|
||||
machine.sleep() # everything except for WLAN is powered down (~950uA avg. current)
|
||||
# wakes from Pin, RTC or WLAN
|
||||
machine.deepsleep() # deepest sleep mode, MCU starts from reset. Wakes from Pin and RTC.
|
||||
@@ -184,16 +184,16 @@ See :ref:`network.WLAN <network.WLAN>` and :mod:`machine`. ::
|
||||
from network import WLAN
|
||||
|
||||
# configure the WLAN subsystem in station mode (the default is AP)
|
||||
wifi = WLAN(mode=WLAN.STA)
|
||||
wlan = WLAN(mode=WLAN.STA)
|
||||
# go for fixed IP settings
|
||||
wifi.ifconfig(config=('192.168.0.107', '255.255.255.0', '192.168.0.1', '8.8.8.8'))
|
||||
wifi.scan() # scan for available netrworks
|
||||
wifi.connect(ssid='mynetwork', auth=(WLAN.WPA2, 'mynetworkkey'))
|
||||
while not wifi.isconnected():
|
||||
wlan.ifconfig(config=('192.168.0.107', '255.255.255.0', '192.168.0.1', '8.8.8.8'))
|
||||
wlan.scan() # scan for available networks
|
||||
wlan.connect(ssid='mynetwork', auth=(WLAN.WPA2, 'mynetworkkey'))
|
||||
while not wlan.isconnected():
|
||||
pass
|
||||
print(wifi.ifconfig())
|
||||
print(wlan.ifconfig())
|
||||
# enable wake on WLAN
|
||||
wifi.irq(wake=machine.SLEEP)
|
||||
wlan.irq(trigger=WLAN.ANY_EVENT, wake=machine.SLEEP)
|
||||
# go to sleep
|
||||
machine.sleep()
|
||||
# now, connect to the FTP or the Telnet server and the WiPy will wake-up
|
||||
@@ -205,7 +205,7 @@ See :ref:`network.server <network.server>` ::
|
||||
|
||||
from network import server
|
||||
|
||||
# init with new user, pass word and seconds timeout
|
||||
# init with new user, password and seconds timeout
|
||||
server = server.init(login=('user', 'password'), timeout=60)
|
||||
server.timeout(300) # change the timeout
|
||||
server.timeout() # get the timeout
|
||||
|
||||
@@ -11,7 +11,7 @@ the WiPy. Before anything else, make sure that your WiPy is running
|
||||
the latest software, check :ref:`OTA How-To <wipy_firmware_upgrade>` for instructions.
|
||||
|
||||
1. Get the `Blynk library <https://github.com/wipy/wipy/blob/master/lib/blynk/BlynkLib.py>`_ and put it in ``/flash/lib/`` via FTP.
|
||||
2. Get the `Blynk examples <https://github.com/wipy/wipy/tree/master/examples/blynk>`_ edit the network settings, and afterwards
|
||||
2. Get the `Blynk examples <https://github.com/wipy/wipy/tree/master/examples/blynk>`_, edit the network settings, and afterwards
|
||||
upload them to ``/flash/lib/`` via FTP as well.
|
||||
3. Follow the instructions on each example to setup the Blynk dashboard on your smartphone or tablet.
|
||||
4. Give it a try, for instance::
|
||||
|
||||
@@ -4,7 +4,7 @@ WiPy tutorials and examples
|
||||
===========================
|
||||
|
||||
Before starting, make sure that you are running the latest firmware,
|
||||
for instrucctions see :ref:`OTA How-To <wipy_firmware_upgrade>`.
|
||||
for instructions see :ref:`OTA How-To <wipy_firmware_upgrade>`.
|
||||
|
||||
.. toctree::
|
||||
:maxdepth: 1
|
||||
|
||||
@@ -17,7 +17,7 @@ Because the WiPy/expansion board does not have a housing it needs a bit of care:
|
||||
If you experience a lot of static electricity in your area (eg dry and cold
|
||||
climates), take extra care not to shock the WiPy. If your WiPy came
|
||||
in a ESD bag, then this bag is the best way to store and carry the
|
||||
pyboard as it will protect it agains static discharges.
|
||||
WiPy as it will protect it agains static discharges.
|
||||
|
||||
As long as you take care of the hardware, you should be okay. It's almost
|
||||
impossible to break the software on the WiPy, so feel free to play around
|
||||
@@ -29,8 +29,8 @@ Plugging into the expansion board and powering on
|
||||
-------------------------------------------------
|
||||
|
||||
The expansion board can power the WiPy via USB. The WiPy comes with a sticker
|
||||
on top of the RF shield tha labels all pins, and this should match the label
|
||||
numbers on the expansion board headers. When pluggin it in, the WiPy antenna
|
||||
on top of the RF shield that labels all pins, and this should match the label
|
||||
numbers on the expansion board headers. When plugging it in, the WiPy antenna
|
||||
will end up on top of the SD card connector of the expansion board. A video
|
||||
showing how to do this can be found `here <https://www.youtube.com/watch?v=47D9MZ9zFQw>`_.
|
||||
|
||||
@@ -46,7 +46,7 @@ Powering by an external power source
|
||||
The WiPy can be powered by a battery or other external power source.
|
||||
|
||||
**Be sure to connect the positive lead of the power supply to VIN, and
|
||||
ground to GND. There is no polarity protection on the pyboard so you
|
||||
ground to GND. There is no polarity protection on the WiPy so you
|
||||
must be careful when connecting anything to VIN.**
|
||||
|
||||
- When powering via ``VIN``:
|
||||
@@ -55,10 +55,10 @@ must be careful when connecting anything to VIN.**
|
||||
|
||||
- When powering via ``3V3``:
|
||||
|
||||
**The input volatge must be exactly 3V3, ripple free and from a supply capable
|
||||
**The input voltage must be exactly 3V3, ripple free and from a supply capable
|
||||
of sourcing at least 300mA of current**
|
||||
|
||||
Performing firmware upgrades
|
||||
----------------------------
|
||||
|
||||
For detalied instructions see :ref:`OTA How-To <wipy_firmware_upgrade>`.
|
||||
For detailed instructions see :ref:`OTA How-To <wipy_firmware_upgrade>`.
|
||||
|
||||
@@ -6,15 +6,17 @@ interactive MicroPython prompt that you can access on the WiPy. Using
|
||||
the REPL is by far the easiest way to test out your code and run commands.
|
||||
You can use the REPL in addition to writing scripts in ``main.py``.
|
||||
|
||||
.. _wipy_uart:
|
||||
|
||||
To use the REPL, you must connect to the WiPy either via :ref:`telnet <wipy_telnet>`,
|
||||
or with a USB to serial converter wired to the one the two UARTs on the
|
||||
WiPy. To enable REPL duplication on UART0 (the one accesible via the expansion board)
|
||||
or with a USB to serial converter wired to one of the two UARTs on the
|
||||
WiPy. To enable REPL duplication on UART0 (the one accessible via the expansion board)
|
||||
do::
|
||||
|
||||
>>> from machine import UART
|
||||
>>> import os
|
||||
>>> uart = UART(0, 115200)
|
||||
>>> o.dupterm(uart)
|
||||
>>> os.dupterm(uart)
|
||||
|
||||
Place this piece of code inside your `boot.py` so that it's done automatically after
|
||||
reset.
|
||||
@@ -22,23 +24,9 @@ reset.
|
||||
Windows
|
||||
-------
|
||||
|
||||
You need to install the pyboard driver to use the serial USB device.
|
||||
The driver is on the pyboard's USB flash drive, and is called ``pybcdc.inf``.
|
||||
|
||||
To install this driver you need to go to Device Manager
|
||||
for your computer, find the pyboard in the list of devices (it should have
|
||||
a warning sign next to it because it's not working yet), right click on
|
||||
the pyboard device, select Properties, then Install Driver. You need to
|
||||
then select the option to find the driver manually (don't use Windows auto update),
|
||||
navigate to the pyboard's USB drive, and select that. It should then install.
|
||||
After installing, go back to the Device Manager to find the installed pyboard,
|
||||
and see which COM port it is (eg COM4).
|
||||
More comprehensive instructions can be found in the
|
||||
`Guide for pyboard on Windows (PDF) <http://micropython.org/resources/Micro-Python-Windows-setup.pdf>`_.
|
||||
Please consult this guide if you are having problems installing the driver.
|
||||
|
||||
The best option is to download the free program PuTTY:
|
||||
`putty.exe <http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html>`_.
|
||||
First you need to install the FTDI drivers for the expansion board's USB to serial
|
||||
converter. Then you need a terminal software. The best option is to download the
|
||||
free program PuTTY: `putty.exe <http://www.chiark.greenend.org.uk/~sgtatham/putty/download.html>`_.
|
||||
|
||||
**In order to get to the telnet REPL:**
|
||||
|
||||
@@ -96,10 +84,10 @@ MicroPython prompt, i.e. ``>>>``. Let's make sure it is working with the obliga
|
||||
|
||||
In the above, you should not type in the ``>>>`` characters. They are there to
|
||||
indicate that you should type the text after it at the prompt. In the end, once
|
||||
you have entered the text ``print("hello pyboard!")`` and pressed Enter, the output
|
||||
you have entered the text ``print("hello WiPy!")`` and pressed Enter, the output
|
||||
on your screen should look like it does above.
|
||||
|
||||
If you already know some python you can now try some basic commands here.
|
||||
If you already know some Python you can now try some basic commands here.
|
||||
|
||||
If any of this is not working you can try either a hard reset or a soft reset;
|
||||
see below.
|
||||
|
||||
@@ -43,7 +43,7 @@ Factory reset the filesystem
|
||||
----------------------------
|
||||
|
||||
If you WiPy's filesystem gets corrupted (very unlikely, but possible), you
|
||||
can format it very easily byt doing::
|
||||
can format it very easily by doing::
|
||||
|
||||
>>> import os
|
||||
>>> os.mkfs('/flash')
|
||||
|
||||
@@ -13,6 +13,15 @@ You can check the current mode (which is always ``WLAN.AP`` after power up)::
|
||||
|
||||
>>> wlan.mode()
|
||||
|
||||
.. warning::
|
||||
When you change the WLAN mode following the instructions below, your WLAN
|
||||
connection to the WiPy will be broken. This means you will not be able
|
||||
to run these commands interactively over the WLAN.
|
||||
|
||||
There are two ways around this::
|
||||
1. put this setup code into your :ref:`boot.py file<wipy_filesystem>` so that it gets executed automatically after reset.
|
||||
2. :ref:`duplicate the REPL on UART <wipy_uart>`, so that you can run commands via USB.
|
||||
|
||||
Connecting to your home router
|
||||
------------------------------
|
||||
|
||||
@@ -22,6 +31,7 @@ it as a station::
|
||||
from network import WLAN
|
||||
wlan = WLAN(mode=WLAN.STA)
|
||||
|
||||
|
||||
Now you can proceed to scan for networks::
|
||||
|
||||
nets = wlan.scan()
|
||||
@@ -31,14 +41,14 @@ Now you can proceed to scan for networks::
|
||||
wlan.connect(net.ssid, auth=(net.sec, 'mywifikey'), timeout=5000)
|
||||
while not wlan.isconnected():
|
||||
machine.idle() # save power while waiting
|
||||
print('WLAN connection succeeded!)
|
||||
print('WLAN connection succeeded!')
|
||||
break
|
||||
|
||||
Assigning a static IP address when booting
|
||||
------------------------------------------
|
||||
|
||||
If you want your WiPy to connect to your home router while after boot-up, and with a fixed
|
||||
IP address so that you can access it via telnet or FTP, use the following script::
|
||||
If you want your WiPy to connect to your home router after boot-up, and with a fixed
|
||||
IP address so that you can access it via telnet or FTP, use the following script as /flash/boot.py::
|
||||
|
||||
import machine
|
||||
from network import WLAN
|
||||
@@ -50,10 +60,10 @@ IP address so that you can access it via telnet or FTP, use the following script
|
||||
wlan.ifconfig(config=('192.168.178.107', '255.255.255.0', '192.168.178.1', '8.8.8.8'))
|
||||
|
||||
if not wlan.isconnected():
|
||||
wlan.connect(net.ssid, auth=(net.sec, 'mywifikey'), timeout=5000)
|
||||
# change the line below to match your network ssid, security and password
|
||||
wlan.connect('mywifi', auth=(WLAN.WPA2, 'mywifikey'), timeout=5000)
|
||||
while not wlan.isconnected():
|
||||
machine.idle() # save power while waiting
|
||||
break
|
||||
|
||||
.. note::
|
||||
|
||||
|
||||
@@ -67,8 +67,6 @@ SRC_C = \
|
||||
$(BUILD)/frozen.c \
|
||||
|
||||
STM_SRC_C = $(addprefix stmhal/,\
|
||||
printf.c \
|
||||
pyexec.c \
|
||||
pybstdio.c \
|
||||
)
|
||||
|
||||
@@ -77,6 +75,8 @@ LIB_SRC_C = $(addprefix lib/,\
|
||||
mp-readline/readline.c \
|
||||
netutils/netutils.c \
|
||||
timeutils/timeutils.c \
|
||||
utils/pyexec.c \
|
||||
utils/printf.c \
|
||||
)
|
||||
|
||||
SRC_S = \
|
||||
@@ -124,7 +124,7 @@ $(BUILD)/firmware-combined.bin: $(BUILD)/firmware.elf
|
||||
|
||||
$(BUILD)/firmware.elf: $(OBJ)
|
||||
$(ECHO) "LINK $@"
|
||||
$(Q)$(LD) $(LDFLAGS) -o $@ $(OBJ) $(LIBS)
|
||||
$(Q)$(LD) $(LDFLAGS) -o $@ $^ $(LIBS)
|
||||
$(Q)$(SIZE) $@
|
||||
|
||||
#MAKE_PINS = boards/make-pins.py
|
||||
|
||||
@@ -46,7 +46,7 @@ void mp_hal_feed_watchdog(void) {
|
||||
//wdt_feed(); // might also work
|
||||
}
|
||||
|
||||
void mp_hal_udelay(uint32_t us) {
|
||||
void mp_hal_delay_us(uint32_t us) {
|
||||
ets_delay_us(us);
|
||||
}
|
||||
|
||||
@@ -56,7 +56,7 @@ int mp_hal_stdin_rx_chr(void) {
|
||||
if (c != -1) {
|
||||
return c;
|
||||
}
|
||||
mp_hal_udelay(1);
|
||||
mp_hal_delay_us(1);
|
||||
mp_hal_feed_watchdog();
|
||||
}
|
||||
}
|
||||
@@ -82,12 +82,12 @@ void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len) {
|
||||
}
|
||||
}
|
||||
|
||||
uint32_t HAL_GetTick(void) {
|
||||
uint32_t mp_hal_ticks_ms(void) {
|
||||
return system_get_time() / 1000;
|
||||
}
|
||||
|
||||
void HAL_Delay(uint32_t Delay) {
|
||||
mp_hal_udelay(Delay * 1000);
|
||||
void mp_hal_delay_ms(uint32_t delay) {
|
||||
mp_hal_delay_us(delay * 1000);
|
||||
}
|
||||
|
||||
void mp_hal_set_interrupt_char(int c) {
|
||||
|
||||
@@ -32,14 +32,8 @@ void ets_isr_mask(unsigned);
|
||||
|
||||
void mp_hal_init(void);
|
||||
void mp_hal_feed_watchdog(void);
|
||||
void mp_hal_udelay(uint32_t);
|
||||
int mp_hal_stdin_rx_chr(void);
|
||||
void mp_hal_stdout_tx_str(const char *str);
|
||||
void mp_hal_stdout_tx_strn(const char *str, uint32_t len);
|
||||
void mp_hal_stdout_tx_strn_cooked(const char *str, uint32_t len);
|
||||
|
||||
uint32_t HAL_GetTick(void);
|
||||
void HAL_Delay(uint32_t Delay);
|
||||
void mp_hal_delay_us(uint32_t);
|
||||
void mp_hal_set_interrupt_char(int c);
|
||||
uint32_t mp_hal_get_cpu_freq(void);
|
||||
|
||||
|
||||
@@ -33,10 +33,10 @@
|
||||
#include "py/runtime.h"
|
||||
#include "py/stackctrl.h"
|
||||
#include "py/frozenmod.h"
|
||||
#include "py/mphal.h"
|
||||
#include "py/gc.h"
|
||||
#include "pyexec.h"
|
||||
#include "lib/utils/pyexec.h"
|
||||
#include "gccollect.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "user_interface.h"
|
||||
|
||||
STATIC char heap[16384];
|
||||
@@ -56,7 +56,7 @@ STATIC void mp_reset(void) {
|
||||
|
||||
void soft_reset(void) {
|
||||
mp_hal_stdout_tx_str("PYB: soft reset\r\n");
|
||||
mp_hal_udelay(10000); // allow UART to flush output
|
||||
mp_hal_delay_us(10000); // allow UART to flush output
|
||||
mp_reset();
|
||||
pyexec_event_repl_init();
|
||||
}
|
||||
|
||||
@@ -32,7 +32,6 @@
|
||||
#include "py/obj.h"
|
||||
#include "py/gc.h"
|
||||
#include "py/runtime.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "netutils.h"
|
||||
#include "queue.h"
|
||||
#include "user_interface.h"
|
||||
|
||||
@@ -29,9 +29,8 @@
|
||||
#include "py/nlr.h"
|
||||
#include "py/obj.h"
|
||||
#include "py/gc.h"
|
||||
#include "py/mphal.h"
|
||||
#include "gccollect.h"
|
||||
#include "pyexec.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "user_interface.h"
|
||||
#include "modpyb.h"
|
||||
|
||||
@@ -102,13 +101,13 @@ STATIC mp_obj_t pyb_sync(void) {
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(pyb_sync_obj, pyb_sync);
|
||||
|
||||
STATIC mp_obj_t pyb_millis(void) {
|
||||
return MP_OBJ_NEW_SMALL_INT(HAL_GetTick());
|
||||
return MP_OBJ_NEW_SMALL_INT(mp_hal_ticks_ms());
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_0(pyb_millis_obj, pyb_millis);
|
||||
|
||||
STATIC mp_obj_t pyb_elapsed_millis(mp_obj_t start) {
|
||||
uint32_t startMillis = mp_obj_get_int(start);
|
||||
uint32_t currMillis = HAL_GetTick();
|
||||
uint32_t currMillis = mp_hal_ticks_ms();
|
||||
return MP_OBJ_NEW_SMALL_INT((currMillis - startMillis) & 0x3fffffff);
|
||||
}
|
||||
STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_elapsed_millis_obj, pyb_elapsed_millis);
|
||||
@@ -128,7 +127,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_elapsed_micros_obj, pyb_elapsed_micros);
|
||||
STATIC mp_obj_t pyb_delay(mp_obj_t ms_in) {
|
||||
mp_int_t ms = mp_obj_get_int(ms_in);
|
||||
if (ms >= 0) {
|
||||
HAL_Delay(ms);
|
||||
mp_hal_delay_ms(ms);
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
@@ -137,7 +136,7 @@ STATIC MP_DEFINE_CONST_FUN_OBJ_1(pyb_delay_obj, pyb_delay);
|
||||
STATIC mp_obj_t pyb_udelay(mp_obj_t usec_in) {
|
||||
mp_int_t usec = mp_obj_get_int(usec_in);
|
||||
if (usec >= 0) {
|
||||
mp_hal_udelay(usec);
|
||||
mp_hal_delay_us(usec);
|
||||
}
|
||||
return mp_const_none;
|
||||
}
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "py/nlr.h"
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "user_interface.h"
|
||||
|
||||
const mp_obj_type_t pyb_adc_type;
|
||||
|
||||
@@ -30,7 +30,6 @@
|
||||
#include "py/nlr.h"
|
||||
#include "py/obj.h"
|
||||
#include "py/runtime.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "timeutils.h"
|
||||
#include "user_interface.h"
|
||||
#include "modpyb.h"
|
||||
|
||||
@@ -32,7 +32,7 @@
|
||||
#include "py/obj.h"
|
||||
#include "py/gc.h"
|
||||
#include "py/runtime.h"
|
||||
#include MICROPY_HAL_H
|
||||
#include "py/mphal.h"
|
||||
#include "modpyb.h"
|
||||
#include "modpybrtc.h"
|
||||
#include "timeutils.h"
|
||||
@@ -101,7 +101,7 @@ MP_DEFINE_CONST_FUN_OBJ_1(time_mktime_obj, time_mktime);
|
||||
/// \function sleep(seconds)
|
||||
/// Sleep for the given number of seconds.
|
||||
STATIC mp_obj_t time_sleep(mp_obj_t seconds_o) {
|
||||
HAL_Delay(1000 * mp_obj_get_int(seconds_o));
|
||||
mp_hal_delay_ms(1000 * mp_obj_get_int(seconds_o));
|
||||
return mp_const_none;
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_1(time_sleep_obj, time_sleep);
|
||||
|
||||
@@ -54,7 +54,6 @@ typedef void *machine_ptr_t; // must be of pointer size
|
||||
typedef const void *machine_const_ptr_t; // must be of pointer size
|
||||
typedef long mp_off_t;
|
||||
|
||||
void mp_hal_stdout_tx_strn_cooked(const char *str, mp_uint_t len);
|
||||
#define MP_PLAT_PRINT_STRN(str, len) mp_hal_stdout_tx_strn_cooked(str, len)
|
||||
|
||||
// extra built in names to add to the global namespace
|
||||
@@ -94,7 +93,7 @@ extern const struct _mp_obj_module_t uos_module;
|
||||
|
||||
// board specifics
|
||||
|
||||
#define MICROPY_HAL_H "esp_mphal.h"
|
||||
#define MICROPY_MPHALPORT_H "esp_mphal.h"
|
||||
#define MICROPY_HW_BOARD_NAME "ESP module"
|
||||
#define MICROPY_HW_MCU_NAME "ESP8266"
|
||||
#define MICROPY_PY_SYS_PLATFORM "ESP8266"
|
||||
|
||||
@@ -207,7 +207,7 @@ void ICACHE_FLASH_ATTR uart_reattach() {
|
||||
// Task-based UART interface
|
||||
|
||||
#include "py/obj.h"
|
||||
#include "stmhal/pyexec.h"
|
||||
#include "lib/utils/pyexec.h"
|
||||
|
||||
void soft_reset(void);
|
||||
|
||||
|
||||
33
examples/accel_i2c.py
Normal file
33
examples/accel_i2c.py
Normal file
@@ -0,0 +1,33 @@
|
||||
# This is an example on how to access accelerometer on
|
||||
# PyBoard directly using I2C bus. As such, it's more
|
||||
# intended to be an I2C example, rather than accelerometer
|
||||
# example. For the latter, using pyb.Accel class is
|
||||
# much easier.
|
||||
|
||||
import pyb
|
||||
import time
|
||||
|
||||
# Accelerometer needs to be powered on first. Even
|
||||
# though signal is called "AVDD", and there's separate
|
||||
# "DVDD", without AVDD, it won't event talk on I2C bus.
|
||||
accel_pwr = pyb.Pin("MMA_AVDD")
|
||||
accel_pwr.value(1)
|
||||
|
||||
i2c = pyb.I2C(1)
|
||||
addrs = i2c.scan()
|
||||
print("Scanning devices:", [hex(x) for x in addrs])
|
||||
if 0x4c not in addrs:
|
||||
print("Accelerometer is not detected")
|
||||
|
||||
ACCEL_ADDR = 0x4c
|
||||
ACCEL_AXIS_X_REG = 0
|
||||
ACCEL_MODE_REG = 7
|
||||
|
||||
# Now activate measurements
|
||||
i2c.mem_write(b"\x01", ACCEL_ADDR, ACCEL_MODE_REG)
|
||||
|
||||
print("Try to move accelerometer and watch the values")
|
||||
while True:
|
||||
val = i2c.mem_read(1, ACCEL_ADDR, ACCEL_AXIS_X_REG)
|
||||
print(val[0])
|
||||
time.sleep(1)
|
||||
41
extmod/lwip-include/arch/cc.h
Normal file
41
extmod/lwip-include/arch/cc.h
Normal file
@@ -0,0 +1,41 @@
|
||||
#ifndef __CC_H__
|
||||
#define __CC_H__
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
// Generate lwip's internal types from stdint
|
||||
|
||||
typedef uint8_t u8_t;
|
||||
typedef int8_t s8_t;
|
||||
typedef uint16_t u16_t;
|
||||
typedef int16_t s16_t;
|
||||
typedef uint32_t u32_t;
|
||||
typedef int32_t s32_t;
|
||||
|
||||
typedef u32_t mem_ptr_t;
|
||||
|
||||
#define U16_F "hu"
|
||||
#define S16_F "hd"
|
||||
#define X16_F "hx"
|
||||
#define U32_F "u"
|
||||
#define S32_F "d"
|
||||
#define X32_F "x"
|
||||
|
||||
#define X8_F "02x"
|
||||
#define SZT_F "u"
|
||||
|
||||
#define BYTE_ORDER LITTLE_ENDIAN
|
||||
|
||||
#define LWIP_CHKSUM_ALGORITHM 2
|
||||
|
||||
#include <assert.h>
|
||||
#define LWIP_PLATFORM_DIAG(x)
|
||||
#define LWIP_PLATFORM_ASSERT(x) { assert(1); }
|
||||
|
||||
//#define PACK_STRUCT_FIELD(x) x __attribute__((packed))
|
||||
#define PACK_STRUCT_FIELD(x) x
|
||||
#define PACK_STRUCT_STRUCT __attribute__((packed))
|
||||
#define PACK_STRUCT_BEGIN
|
||||
#define PACK_STRUCT_END
|
||||
|
||||
#endif /* __ARCH_CC_H__ */
|
||||
7
extmod/lwip-include/arch/perf.h
Normal file
7
extmod/lwip-include/arch/perf.h
Normal file
@@ -0,0 +1,7 @@
|
||||
#ifndef __PERF_H__
|
||||
#define __PERF_H__
|
||||
|
||||
#define PERF_START /* null definition */
|
||||
#define PERF_STOP(x) /* null definition */
|
||||
|
||||
#endif /* __PERF_H__ */
|
||||
36
extmod/lwip-include/lwipopts.h
Normal file
36
extmod/lwip-include/lwipopts.h
Normal file
@@ -0,0 +1,36 @@
|
||||
#ifndef __LWIPOPTS_H__
|
||||
#define __LWIPOPTS_H__
|
||||
|
||||
#include <py/mpconfig.h>
|
||||
#include <py/misc.h>
|
||||
#include <py/mphal.h>
|
||||
|
||||
// We're running without an OS for this port. We don't provide any services except light protection.
|
||||
#define NO_SYS 1
|
||||
|
||||
#define SYS_LIGHTWEIGHT_PROT 1
|
||||
#include <stdint.h>
|
||||
typedef uint32_t sys_prot_t;
|
||||
|
||||
#define TCP_LISTEN_BACKLOG 1
|
||||
|
||||
// We'll put these into a proper ifdef once somebody implements an ethernet driver
|
||||
#define LWIP_ARP 0
|
||||
#define LWIP_ETHERNET 0
|
||||
|
||||
#define LWIP_DNS 1
|
||||
|
||||
#define LWIP_NETCONN 0
|
||||
#define LWIP_SOCKET 0
|
||||
|
||||
#ifdef MICROPY_PY_LWIP_SLIP
|
||||
#define LWIP_HAVE_SLIPIF 1
|
||||
#endif
|
||||
|
||||
// For now, we can simply define this as a macro for the timer code. But this function isn't
|
||||
// universal and other ports will need to do something else. It may be necessary to move
|
||||
// things like this into a port-provided header file.
|
||||
#define sys_now mp_hal_ticks_ms
|
||||
|
||||
#endif
|
||||
|
||||
1004
extmod/modlwip.c
Normal file
1004
extmod/modlwip.c
Normal file
File diff suppressed because it is too large
Load Diff
@@ -329,6 +329,7 @@ STATIC mp_obj_t get_aligned(uint val_type, void *p, mp_int_t index) {
|
||||
case INT32:
|
||||
return mp_obj_new_int(((int32_t*)p)[index]);
|
||||
case UINT64:
|
||||
return mp_obj_new_int_from_ull(((uint64_t*)p)[index]);
|
||||
case INT64:
|
||||
return mp_obj_new_int_from_ll(((int64_t*)p)[index]);
|
||||
#if MICROPY_PY_BUILTINS_FLOAT
|
||||
@@ -556,6 +557,18 @@ STATIC mp_obj_t uctypes_struct_subscr(mp_obj_t self_in, mp_obj_t index_in, mp_ob
|
||||
}
|
||||
}
|
||||
|
||||
STATIC mp_int_t uctypes_get_buffer(mp_obj_t self_in, mp_buffer_info_t *bufinfo, mp_uint_t flags) {
|
||||
(void)flags;
|
||||
mp_obj_uctypes_struct_t *self = self_in;
|
||||
mp_uint_t max_field_size = 0;
|
||||
mp_uint_t size = uctypes_struct_size(self->desc, &max_field_size);
|
||||
|
||||
bufinfo->buf = self->addr;
|
||||
bufinfo->len = size;
|
||||
bufinfo->typecode = BYTEARRAY_TYPECODE;
|
||||
return 0;
|
||||
}
|
||||
|
||||
/// \function addressof()
|
||||
/// Return address of object's data (applies to object providing buffer
|
||||
/// interface).
|
||||
@@ -592,6 +605,7 @@ STATIC const mp_obj_type_t uctypes_struct_type = {
|
||||
.make_new = uctypes_struct_make_new,
|
||||
.attr = uctypes_struct_attr,
|
||||
.subscr = uctypes_struct_subscr,
|
||||
.buffer_p = { .get_buffer = uctypes_get_buffer },
|
||||
};
|
||||
|
||||
STATIC const mp_map_elem_t mp_module_uctypes_globals_table[] = {
|
||||
|
||||
@@ -115,17 +115,17 @@ STATIC mp_obj_t re_exec(bool is_anchored, uint n_args, const mp_obj_t *args) {
|
||||
return match;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t re_match(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t re_match(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
return re_exec(true, n_args, args);
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(re_match_obj, 2, 4, re_match);
|
||||
|
||||
STATIC mp_obj_t re_search(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t re_search(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
return re_exec(false, n_args, args);
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(re_search_obj, 2, 4, re_search);
|
||||
|
||||
STATIC mp_obj_t re_split(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t re_split(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
mp_obj_re_t *self = args[0];
|
||||
Subject subj;
|
||||
mp_uint_t len;
|
||||
@@ -182,9 +182,12 @@ STATIC const mp_obj_type_t re_type = {
|
||||
.locals_dict = (mp_obj_t)&re_locals_dict,
|
||||
};
|
||||
|
||||
STATIC mp_obj_t mod_re_compile(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t mod_re_compile(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
const char *re_str = mp_obj_str_get_str(args[0]);
|
||||
int size = re1_5_sizecode(re_str);
|
||||
if (size == -1) {
|
||||
goto error;
|
||||
}
|
||||
mp_obj_re_t *o = m_new_obj_var(mp_obj_re_t, char, size);
|
||||
o->base.type = &re_type;
|
||||
int flags = 0;
|
||||
@@ -193,6 +196,7 @@ STATIC mp_obj_t mod_re_compile(uint n_args, const mp_obj_t *args) {
|
||||
}
|
||||
int error = re1_5_compilecode(&o->re, re_str);
|
||||
if (error != 0) {
|
||||
error:
|
||||
nlr_raise(mp_obj_new_exception_msg(&mp_type_ValueError, "Error in regex"));
|
||||
}
|
||||
if (flags & FLAG_DEBUG) {
|
||||
@@ -211,12 +215,12 @@ STATIC mp_obj_t mod_re_exec(bool is_anchored, uint n_args, const mp_obj_t *args)
|
||||
return match;
|
||||
}
|
||||
|
||||
STATIC mp_obj_t mod_re_match(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t mod_re_match(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
return mod_re_exec(true, n_args, args);
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_re_match_obj, 2, 4, mod_re_match);
|
||||
|
||||
STATIC mp_obj_t mod_re_search(uint n_args, const mp_obj_t *args) {
|
||||
STATIC mp_obj_t mod_re_search(mp_uint_t n_args, const mp_obj_t *args) {
|
||||
return mod_re_exec(false, n_args, args);
|
||||
}
|
||||
MP_DEFINE_CONST_FUN_OBJ_VAR_BETWEEN(mod_re_search_obj, 2, 4, mod_re_search);
|
||||
|
||||
@@ -4,203 +4,175 @@
|
||||
|
||||
#include "re1.5.h"
|
||||
|
||||
static void insert_code(char *code, int at, int num, int *pc)
|
||||
{
|
||||
memmove(code + at + num, code + at, *pc - at);
|
||||
*pc += num;
|
||||
}
|
||||
|
||||
#define INSERT_CODE(at, num, pc) \
|
||||
((code ? memmove(code + at + num, code + at, pc - at) : (void)0), pc += num)
|
||||
#define REL(at, to) (to - at - 2)
|
||||
#define EMIT(at, byte) (code ? (code[at] = byte) : (void)(at))
|
||||
#define PC (prog->bytelen)
|
||||
|
||||
int re1_5_sizecode(const char *re)
|
||||
static const char *_compilecode(const char *re, ByteProg *prog, int sizecode)
|
||||
{
|
||||
int pc = 5 + NON_ANCHORED_PREFIX; // Save 0, Save 1, Match; more bytes for "search" (vs "match") prefix code
|
||||
|
||||
for (; *re; re++) {
|
||||
switch (*re) {
|
||||
case '\\':
|
||||
re++;
|
||||
default:
|
||||
pc += 2;
|
||||
break;
|
||||
case '+':
|
||||
// Skip entire "+?"
|
||||
if (re[1] == '?')
|
||||
re++;
|
||||
case '?':
|
||||
pc += 2;
|
||||
break;
|
||||
case '.':
|
||||
case '^':
|
||||
case '$':
|
||||
pc++;
|
||||
break;
|
||||
case '*':
|
||||
// Skip entire "*?"
|
||||
if (re[1] == '?')
|
||||
re++;
|
||||
case '|':
|
||||
case '(':
|
||||
pc += 4;
|
||||
break;
|
||||
case ')':
|
||||
break;
|
||||
case '[': {
|
||||
pc += 2;
|
||||
re++;
|
||||
if (*re == '^') re++;
|
||||
while (*re != ']') {
|
||||
if (!*re) return -1;
|
||||
if (re[1] == '-') {
|
||||
re += 2;
|
||||
}
|
||||
pc += 2;
|
||||
re++;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return pc;
|
||||
}
|
||||
|
||||
#define EMIT(at, byte) code[at] = byte
|
||||
|
||||
static const char *_compilecode(const char *re, ByteProg *prog)
|
||||
{
|
||||
char *code = prog->insts;
|
||||
int pc = prog->bytelen;
|
||||
int start = pc;
|
||||
int term = pc;
|
||||
char *code = sizecode ? NULL : prog->insts;
|
||||
int start = PC;
|
||||
int term = PC;
|
||||
int alt_label = 0;
|
||||
|
||||
for (; *re && *re != ')'; re++) {
|
||||
switch (*re) {
|
||||
case '\\':
|
||||
re++;
|
||||
if (!*re) return NULL; // Trailing backslash
|
||||
if ((*re | 0x20) == 'd' || (*re | 0x20) == 's' || (*re | 0x20) == 'w') {
|
||||
term = pc;
|
||||
EMIT(pc++, NamedClass);
|
||||
EMIT(pc++, *re);
|
||||
term = PC;
|
||||
EMIT(PC++, NamedClass);
|
||||
EMIT(PC++, *re);
|
||||
prog->len++;
|
||||
break;
|
||||
}
|
||||
default:
|
||||
term = pc;
|
||||
EMIT(pc++, Char);
|
||||
EMIT(pc++, *re);
|
||||
term = PC;
|
||||
EMIT(PC++, Char);
|
||||
EMIT(PC++, *re);
|
||||
prog->len++;
|
||||
break;
|
||||
case '.':
|
||||
term = pc;
|
||||
EMIT(pc++, Any);
|
||||
term = PC;
|
||||
EMIT(PC++, Any);
|
||||
prog->len++;
|
||||
break;
|
||||
case '[': {
|
||||
int cnt;
|
||||
term = pc;
|
||||
term = PC;
|
||||
re++;
|
||||
if (*re == '^') {
|
||||
EMIT(pc++, ClassNot);
|
||||
EMIT(PC++, ClassNot);
|
||||
re++;
|
||||
} else {
|
||||
EMIT(pc++, Class);
|
||||
EMIT(PC++, Class);
|
||||
}
|
||||
pc++; // Skip # of pair byte
|
||||
PC++; // Skip # of pair byte
|
||||
prog->len++;
|
||||
for (cnt = 0; *re != ']'; re++, cnt++) {
|
||||
if (!*re) return NULL;
|
||||
EMIT(pc++, *re);
|
||||
EMIT(PC++, *re);
|
||||
if (re[1] == '-') {
|
||||
re += 2;
|
||||
}
|
||||
EMIT(pc++, *re);
|
||||
EMIT(PC++, *re);
|
||||
}
|
||||
EMIT(term + 1, cnt);
|
||||
break;
|
||||
}
|
||||
case '(': {
|
||||
term = pc;
|
||||
int sub = ++prog->sub;
|
||||
term = PC;
|
||||
int sub = 0;
|
||||
int capture = re[1] != '?' || re[2] != ':';
|
||||
|
||||
EMIT(pc++, Save);
|
||||
EMIT(pc++, 2 * sub);
|
||||
prog->len++;
|
||||
if (capture) {
|
||||
sub = ++prog->sub;
|
||||
EMIT(PC++, Save);
|
||||
EMIT(PC++, 2 * sub);
|
||||
prog->len++;
|
||||
} else {
|
||||
re += 2;
|
||||
}
|
||||
|
||||
prog->bytelen = pc;
|
||||
re = _compilecode(re + 1, prog);
|
||||
re = _compilecode(re + 1, prog, sizecode);
|
||||
if (re == NULL || *re != ')') return NULL; // error, or no matching paren
|
||||
pc = prog->bytelen;
|
||||
|
||||
EMIT(pc++, Save);
|
||||
EMIT(pc++, 2 * sub + 1);
|
||||
prog->len++;
|
||||
if (capture) {
|
||||
EMIT(PC++, Save);
|
||||
EMIT(PC++, 2 * sub + 1);
|
||||
prog->len++;
|
||||
}
|
||||
|
||||
break;
|
||||
}
|
||||
case '?':
|
||||
if (pc == term) return NULL; // nothing to repeat
|
||||
insert_code(code, term, 2, &pc);
|
||||
EMIT(term, Split);
|
||||
EMIT(term + 1, REL(term, pc));
|
||||
prog->len++;
|
||||
break;
|
||||
case '*':
|
||||
if (pc == term) return NULL; // nothing to repeat
|
||||
insert_code(code, term, 2, &pc);
|
||||
EMIT(pc, Jmp);
|
||||
EMIT(pc + 1, REL(pc, term));
|
||||
pc += 2;
|
||||
if (PC == term) return NULL; // nothing to repeat
|
||||
INSERT_CODE(term, 2, PC);
|
||||
if (re[1] == '?') {
|
||||
EMIT(term, RSplit);
|
||||
re++;
|
||||
} else {
|
||||
EMIT(term, Split);
|
||||
}
|
||||
EMIT(term + 1, REL(term, pc));
|
||||
prog->len += 2;
|
||||
EMIT(term + 1, REL(term, PC));
|
||||
prog->len++;
|
||||
term = PC;
|
||||
break;
|
||||
case '+':
|
||||
if (pc == term) return NULL; // nothing to repeat
|
||||
case '*':
|
||||
if (PC == term) return NULL; // nothing to repeat
|
||||
INSERT_CODE(term, 2, PC);
|
||||
EMIT(PC, Jmp);
|
||||
EMIT(PC + 1, REL(PC, term));
|
||||
PC += 2;
|
||||
if (re[1] == '?') {
|
||||
EMIT(pc, Split);
|
||||
EMIT(term, RSplit);
|
||||
re++;
|
||||
} else {
|
||||
EMIT(pc, RSplit);
|
||||
EMIT(term, Split);
|
||||
}
|
||||
EMIT(pc + 1, REL(pc, term));
|
||||
pc += 2;
|
||||
EMIT(term + 1, REL(term, PC));
|
||||
prog->len += 2;
|
||||
term = PC;
|
||||
break;
|
||||
case '+':
|
||||
if (PC == term) return NULL; // nothing to repeat
|
||||
if (re[1] == '?') {
|
||||
EMIT(PC, Split);
|
||||
re++;
|
||||
} else {
|
||||
EMIT(PC, RSplit);
|
||||
}
|
||||
EMIT(PC + 1, REL(PC, term));
|
||||
PC += 2;
|
||||
prog->len++;
|
||||
term = PC;
|
||||
break;
|
||||
case '|':
|
||||
if (alt_label) {
|
||||
EMIT(alt_label, REL(alt_label, pc) + 1);
|
||||
EMIT(alt_label, REL(alt_label, PC) + 1);
|
||||
}
|
||||
insert_code(code, start, 2, &pc);
|
||||
EMIT(pc++, Jmp);
|
||||
alt_label = pc++;
|
||||
INSERT_CODE(start, 2, PC);
|
||||
EMIT(PC++, Jmp);
|
||||
alt_label = PC++;
|
||||
EMIT(start, Split);
|
||||
EMIT(start + 1, REL(start, pc));
|
||||
EMIT(start + 1, REL(start, PC));
|
||||
prog->len += 2;
|
||||
term = PC;
|
||||
break;
|
||||
case '^':
|
||||
EMIT(pc++, Bol);
|
||||
EMIT(PC++, Bol);
|
||||
prog->len++;
|
||||
term = PC;
|
||||
break;
|
||||
case '$':
|
||||
EMIT(pc++, Eol);
|
||||
EMIT(PC++, Eol);
|
||||
prog->len++;
|
||||
term = PC;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
if (alt_label) {
|
||||
EMIT(alt_label, REL(alt_label, pc) + 1);
|
||||
EMIT(alt_label, REL(alt_label, PC) + 1);
|
||||
}
|
||||
prog->bytelen = pc;
|
||||
return re;
|
||||
}
|
||||
|
||||
int re1_5_sizecode(const char *re)
|
||||
{
|
||||
ByteProg dummyprog = {
|
||||
// Save 0, Save 1, Match; more bytes for "search" (vs "match") prefix code
|
||||
.bytelen = 5 + NON_ANCHORED_PREFIX
|
||||
};
|
||||
|
||||
if (_compilecode(re, &dummyprog, /*sizecode*/1) == NULL) return -1;
|
||||
|
||||
return dummyprog.bytelen;
|
||||
}
|
||||
|
||||
int re1_5_compilecode(ByteProg *prog, const char *re)
|
||||
{
|
||||
prog->len = 0;
|
||||
@@ -221,7 +193,7 @@ int re1_5_compilecode(ByteProg *prog, const char *re)
|
||||
prog->insts[prog->bytelen++] = 0;
|
||||
prog->len++;
|
||||
|
||||
re = _compilecode(re, prog);
|
||||
re = _compilecode(re, prog, /*sizecode*/0);
|
||||
if (re == NULL || *re) return 1;
|
||||
|
||||
prog->insts[prog->bytelen++] = Save;
|
||||
@@ -234,25 +206,6 @@ int re1_5_compilecode(ByteProg *prog, const char *re)
|
||||
return 0;
|
||||
}
|
||||
|
||||
void
|
||||
cleanmarks(ByteProg *prog)
|
||||
{
|
||||
char *pc = prog->insts;
|
||||
char *end = pc + prog->bytelen;
|
||||
while (pc < end) {
|
||||
*pc &= 0x7f;
|
||||
switch (*pc) {
|
||||
case Jmp:
|
||||
case Split:
|
||||
case RSplit:
|
||||
case Save:
|
||||
case Char:
|
||||
pc++;
|
||||
}
|
||||
pc++;
|
||||
}
|
||||
}
|
||||
|
||||
#if 0
|
||||
int main(int argc, char *argv[])
|
||||
{
|
||||
|
||||
@@ -44,6 +44,9 @@ void re1_5_dumpcode(ByteProg *prog)
|
||||
printf("\n");
|
||||
break;
|
||||
}
|
||||
case NamedClass:
|
||||
printf("namedclass %c\n", code[pc++]);
|
||||
break;
|
||||
case Match:
|
||||
printf("match\n");
|
||||
break;
|
||||
|
||||
@@ -38,6 +38,10 @@ DRESULT disk_read (BYTE pdrv, BYTE* buff, DWORD sector, UINT count);
|
||||
DRESULT disk_write (BYTE pdrv, const BYTE* buff, DWORD sector, UINT count);
|
||||
DRESULT disk_ioctl (BYTE pdrv, BYTE cmd, void* buff);
|
||||
|
||||
/* Definitions of physical drive number for each media */
|
||||
#define PD_FLASH (0) /* Map FLASH drive to drive number 0 */
|
||||
#define PD_SDCARD (1) /* Map SDCARD drive to drive number 1 */
|
||||
#define PD_USER (2) /* Map USER mounts to drive number 2 */
|
||||
|
||||
/* Disk Status Bits (DSTATUS) */
|
||||
|
||||
|
||||
@@ -33,7 +33,7 @@
|
||||
#ifndef _FFCONF
|
||||
#define _FFCONF 32020 /* Revision ID */
|
||||
|
||||
#include "mpconfigport.h"
|
||||
#include "py/mpconfig.h"
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Functions and Buffer Configurations
|
||||
@@ -85,8 +85,11 @@
|
||||
#define _USE_FASTSEEK 0
|
||||
/* This option switches fast seek feature. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define _USE_LABEL 1
|
||||
#ifdef MICROPY_FATFS_USE_LABEL
|
||||
#define _USE_LABEL (MICROPY_FATFS_USE_LABEL)
|
||||
#else
|
||||
#define _USE_LABEL 0
|
||||
#endif
|
||||
/* This option switches volume label functions, f_getlabel() and f_setlabel().
|
||||
/ (0:Disable or 1:Enable) */
|
||||
|
||||
@@ -99,8 +102,11 @@
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Locale and Namespace Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _CODE_PAGE (MICROPY_LFN_CODE_PAGE)
|
||||
#ifdef MICROPY_FATFS_LFN_CODE_PAGE
|
||||
#define _CODE_PAGE (MICROPY_FATFS_LFN_CODE_PAGE)
|
||||
#else
|
||||
#define _CODE_PAGE 1
|
||||
#endif
|
||||
/* This option specifies the OEM code page to be used on the target system.
|
||||
/ Incorrect setting of the code page can cause a file open failure.
|
||||
/
|
||||
@@ -123,9 +129,16 @@
|
||||
/ 950 - Traditional Chinese Big5 (DBCS)
|
||||
*/
|
||||
|
||||
|
||||
#define _USE_LFN (MICROPY_ENABLE_LFN)
|
||||
#ifdef MICROPY_FATFS_ENABLE_LFN
|
||||
#define _USE_LFN (MICROPY_FATFS_ENABLE_LFN)
|
||||
#else
|
||||
#define _USE_LFN 0
|
||||
#endif
|
||||
#ifdef MICROPY_FATFS_MAX_LFN
|
||||
#define _MAX_LFN (MICROPY_FATFS_MAX_LFN)
|
||||
#else
|
||||
#define _MAX_LFN 255
|
||||
#endif
|
||||
/* The _USE_LFN option switches the LFN feature.
|
||||
/
|
||||
/ 0: Disable LFN feature. _MAX_LFN has no effect.
|
||||
@@ -157,8 +170,11 @@
|
||||
/
|
||||
/ When _LFN_UNICODE is 0, this option has no effect. */
|
||||
|
||||
|
||||
#define _FS_RPATH 2
|
||||
#ifdef MICROPY_FATFS_RPATH
|
||||
#define _FS_RPATH (MICROPY_FATFS_RPATH)
|
||||
#else
|
||||
#define _FS_RPATH 0
|
||||
#endif
|
||||
/* This option configures relative path feature.
|
||||
/
|
||||
/ 0: Disable relative path feature and remove related functions.
|
||||
@@ -172,7 +188,11 @@
|
||||
/ Drive/Volume Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _VOLUMES 3
|
||||
#ifdef MICROPY_FATFS_VOLUMES
|
||||
#define _VOLUMES (MICROPY_FATFS_VOLUMES)
|
||||
#else
|
||||
#define _VOLUMES 1
|
||||
#endif
|
||||
/* Number of volumes (logical drives) to be used. */
|
||||
|
||||
|
||||
@@ -184,8 +204,11 @@
|
||||
/ logical drives. Number of items must be equal to _VOLUMES. Valid characters for
|
||||
/ the drive ID strings are: A-Z and 0-9. */
|
||||
|
||||
|
||||
#define _MULTI_PARTITION 1
|
||||
#ifdef MICROPY_FATFS_MULTI_PARTITION
|
||||
#define _MULTI_PARTITION (MICROPY_FATFS_MULTI_PARTITION)
|
||||
#else
|
||||
#define _MULTI_PARTITION 0
|
||||
#endif
|
||||
/* This option switches multi-partition feature. By default (0), each logical drive
|
||||
/ number is bound to the same physical drive number and only an FAT volume found on
|
||||
/ the physical drive will be mounted. When multi-partition feature is enabled (1),
|
||||
@@ -236,7 +259,7 @@
|
||||
/ defined by _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR.
|
||||
/ When timestamp feature is enabled (_FS_NORTC == 0), get_fattime() function need
|
||||
/ to be added to the project to read current time form RTC. _NORTC_MON,
|
||||
/ _NORTC_MDAY and _NORTC_YEAR have no effect.
|
||||
/ _NORTC_MDAY and _NORTC_YEAR have no effect.
|
||||
/ These options have no effect at read-only configuration (_FS_READONLY == 1). */
|
||||
|
||||
|
||||
@@ -251,10 +274,24 @@
|
||||
/ can be opened simultaneously under file lock control. Note that the file
|
||||
/ lock feature is independent of re-entrancy. */
|
||||
|
||||
|
||||
#ifdef MICROPY_FATFS_REENTRANT
|
||||
#define _FS_REENTRANT (MICROPY_FATFS_REENTRANT)
|
||||
#else
|
||||
#define _FS_REENTRANT 0
|
||||
#endif
|
||||
|
||||
// milliseconds
|
||||
#ifdef MICROPY_FATFS_TIMEOUT
|
||||
#define _FS_TIMEOUT (MICROPY_FATFS_TIMEOUT)
|
||||
#else
|
||||
#define _FS_TIMEOUT 1000
|
||||
#endif
|
||||
|
||||
#ifdef MICROPY_FATFS_SYNC_T
|
||||
#define _SYNC_t MICROPY_FATFS_SYNC_T
|
||||
#else
|
||||
#define _SYNC_t HANDLE
|
||||
#endif
|
||||
/* The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs
|
||||
/ module itself. Note that regardless of this option, file access to different
|
||||
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
|
||||
@@ -1,266 +0,0 @@
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ FatFs - FAT file system module configuration file R0.11 (C)ChaN, 2015
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _FFCONF 32020 /* Revision ID */
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Functions and Buffer Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _FS_TINY 0
|
||||
/* This option switches tiny buffer configuration. (0:Normal or 1:Tiny)
|
||||
/ At the tiny configuration, size of the file object (FIL) is reduced _MAX_SS
|
||||
/ bytes. Instead of private sector buffer eliminated from the file object,
|
||||
/ common sector buffer in the file system object (FATFS) is used for the file
|
||||
/ data transfer. */
|
||||
|
||||
|
||||
#define _FS_READONLY 0
|
||||
/* This option switches read-only configuration. (0:Read/Write or 1:Read-only)
|
||||
/ Read-only configuration removes writing API functions, f_write(), f_sync(),
|
||||
/ f_unlink(), f_mkdir(), f_chmod(), f_rename(), f_truncate(), f_getfree()
|
||||
/ and optional writing functions as well. */
|
||||
|
||||
|
||||
#define _FS_MINIMIZE 0
|
||||
/* This option defines minimization level to remove some basic API functions.
|
||||
/
|
||||
/ 0: All basic functions are enabled.
|
||||
/ 1: f_stat(), f_getfree(), f_unlink(), f_mkdir(), f_chmod(), f_utime(),
|
||||
/ f_truncate() and f_rename() function are removed.
|
||||
/ 2: f_opendir(), f_readdir() and f_closedir() are removed in addition to 1.
|
||||
/ 3: f_lseek() function is removed in addition to 2. */
|
||||
|
||||
|
||||
#define _USE_STRFUNC 0
|
||||
/* This option switches string functions, f_gets(), f_putc(), f_puts() and
|
||||
/ f_printf().
|
||||
/
|
||||
/ 0: Disable string functions.
|
||||
/ 1: Enable without LF-CRLF conversion.
|
||||
/ 2: Enable with LF-CRLF conversion. */
|
||||
|
||||
|
||||
#define _USE_FIND 0
|
||||
/* This option switches filtered directory read feature and related functions,
|
||||
/ f_findfirst() and f_findnext(). (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define _USE_MKFS 0
|
||||
/* This option switches f_mkfs() function. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define _USE_FASTSEEK 0
|
||||
/* This option switches fast seek feature. (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define _USE_LABEL 0
|
||||
/* This option switches volume label functions, f_getlabel() and f_setlabel().
|
||||
/ (0:Disable or 1:Enable) */
|
||||
|
||||
|
||||
#define _USE_FORWARD 0
|
||||
/* This option switches f_forward() function. (0:Disable or 1:Enable)
|
||||
/ To enable it, also _FS_TINY need to be set to 1. */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Locale and Namespace Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _CODE_PAGE 932
|
||||
/* This option specifies the OEM code page to be used on the target system.
|
||||
/ Incorrect setting of the code page can cause a file open failure.
|
||||
/
|
||||
/ 1 - ASCII (No extended character. Non-LFN cfg. only)
|
||||
/ 437 - U.S.
|
||||
/ 720 - Arabic
|
||||
/ 737 - Greek
|
||||
/ 775 - Baltic
|
||||
/ 850 - Multilingual Latin 1
|
||||
/ 852 - Latin 2
|
||||
/ 855 - Cyrillic
|
||||
/ 857 - Turkish
|
||||
/ 858 - Multilingual Latin 1 + Euro
|
||||
/ 862 - Hebrew
|
||||
/ 866 - Russian
|
||||
/ 874 - Thai
|
||||
/ 932 - Japanese Shift_JIS (DBCS)
|
||||
/ 936 - Simplified Chinese GBK (DBCS)
|
||||
/ 949 - Korean (DBCS)
|
||||
/ 950 - Traditional Chinese Big5 (DBCS)
|
||||
*/
|
||||
|
||||
|
||||
#define _USE_LFN 0
|
||||
#define _MAX_LFN 255
|
||||
/* The _USE_LFN option switches the LFN feature.
|
||||
/
|
||||
/ 0: Disable LFN feature. _MAX_LFN has no effect.
|
||||
/ 1: Enable LFN with static working buffer on the BSS. Always NOT thread-safe.
|
||||
/ 2: Enable LFN with dynamic working buffer on the STACK.
|
||||
/ 3: Enable LFN with dynamic working buffer on the HEAP.
|
||||
/
|
||||
/ When enable the LFN feature, Unicode handling functions (option/unicode.c) must
|
||||
/ be added to the project. The LFN working buffer occupies (_MAX_LFN + 1) * 2 bytes.
|
||||
/ When use stack for the working buffer, take care on stack overflow. When use heap
|
||||
/ memory for the working buffer, memory management functions, ff_memalloc() and
|
||||
/ ff_memfree(), must be added to the project. */
|
||||
|
||||
|
||||
#define _LFN_UNICODE 0
|
||||
/* This option switches character encoding on the API. (0:ANSI/OEM or 1:Unicode)
|
||||
/ To use Unicode string for the path name, enable LFN feature and set _LFN_UNICODE
|
||||
/ to 1. This option also affects behavior of string I/O functions. */
|
||||
|
||||
|
||||
#define _STRF_ENCODE 3
|
||||
/* When _LFN_UNICODE is 1, this option selects the character encoding on the file to
|
||||
/ be read/written via string I/O functions, f_gets(), f_putc(), f_puts and f_printf().
|
||||
/
|
||||
/ 0: ANSI/OEM
|
||||
/ 1: UTF-16LE
|
||||
/ 2: UTF-16BE
|
||||
/ 3: UTF-8
|
||||
/
|
||||
/ When _LFN_UNICODE is 0, this option has no effect. */
|
||||
|
||||
|
||||
#define _FS_RPATH 0
|
||||
/* This option configures relative path feature.
|
||||
/
|
||||
/ 0: Disable relative path feature and remove related functions.
|
||||
/ 1: Enable relative path feature. f_chdir() and f_chdrive() are available.
|
||||
/ 2: f_getcwd() function is available in addition to 1.
|
||||
/
|
||||
/ Note that directory items read via f_readdir() are affected by this option. */
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ Drive/Volume Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _VOLUMES 1
|
||||
/* Number of volumes (logical drives) to be used. */
|
||||
|
||||
|
||||
#define _STR_VOLUME_ID 0
|
||||
#define _VOLUME_STRS "RAM","NAND","CF","SD1","SD2","USB1","USB2","USB3"
|
||||
/* _STR_VOLUME_ID option switches string volume ID feature.
|
||||
/ When _STR_VOLUME_ID is set to 1, also pre-defined strings can be used as drive
|
||||
/ number in the path name. _VOLUME_STRS defines the drive ID strings for each
|
||||
/ logical drives. Number of items must be equal to _VOLUMES. Valid characters for
|
||||
/ the drive ID strings are: A-Z and 0-9. */
|
||||
|
||||
|
||||
#define _MULTI_PARTITION 0
|
||||
/* This option switches multi-partition feature. By default (0), each logical drive
|
||||
/ number is bound to the same physical drive number and only an FAT volume found on
|
||||
/ the physical drive will be mounted. When multi-partition feature is enabled (1),
|
||||
/ each logical drive number is bound to arbitrary physical drive and partition
|
||||
/ listed in the VolToPart[]. Also f_fdisk() funciton will be available. */
|
||||
|
||||
|
||||
#define _MIN_SS 512
|
||||
#define _MAX_SS 512
|
||||
/* These options configure the range of sector size to be supported. (512, 1024,
|
||||
/ 2048 or 4096) Always set both 512 for most systems, all type of memory cards and
|
||||
/ harddisk. But a larger value may be required for on-board flash memory and some
|
||||
/ type of optical media. When _MAX_SS is larger than _MIN_SS, FatFs is configured
|
||||
/ to variable sector size and GET_SECTOR_SIZE command must be implemented to the
|
||||
/ disk_ioctl() function. */
|
||||
|
||||
|
||||
#define _USE_TRIM 0
|
||||
/* This option switches ATA-TRIM feature. (0:Disable or 1:Enable)
|
||||
/ To enable Trim feature, also CTRL_TRIM command should be implemented to the
|
||||
/ disk_ioctl() function. */
|
||||
|
||||
|
||||
#define _FS_NOFSINFO 0
|
||||
/* If you need to know correct free space on the FAT32 volume, set bit 0 of this
|
||||
/ option, and f_getfree() function at first time after volume mount will force
|
||||
/ a full FAT scan. Bit 1 controls the use of last allocated cluster number.
|
||||
/
|
||||
/ bit0=0: Use free cluster count in the FSINFO if available.
|
||||
/ bit0=1: Do not trust free cluster count in the FSINFO.
|
||||
/ bit1=0: Use last allocated cluster number in the FSINFO if available.
|
||||
/ bit1=1: Do not trust last allocated cluster number in the FSINFO.
|
||||
*/
|
||||
|
||||
|
||||
|
||||
/*---------------------------------------------------------------------------/
|
||||
/ System Configurations
|
||||
/---------------------------------------------------------------------------*/
|
||||
|
||||
#define _FS_NORTC 0
|
||||
#define _NORTC_MON 2
|
||||
#define _NORTC_MDAY 1
|
||||
#define _NORTC_YEAR 2015
|
||||
/* The _FS_NORTC option switches timestamp feature. If the system does not have
|
||||
/ an RTC function or valid timestamp is not needed, set _FS_NORTC to 1 to disable
|
||||
/ the timestamp feature. All objects modified by FatFs will have a fixed timestamp
|
||||
/ defined by _NORTC_MON, _NORTC_MDAY and _NORTC_YEAR.
|
||||
/ When timestamp feature is enabled (_FS_NORTC == 0), get_fattime() function need
|
||||
/ to be added to the project to read current time form RTC. _NORTC_MON,
|
||||
/ _NORTC_MDAY and _NORTC_YEAR have no effect.
|
||||
/ These options have no effect at read-only configuration (_FS_READONLY == 1). */
|
||||
|
||||
|
||||
#define _FS_LOCK 0
|
||||
/* The _FS_LOCK option switches file lock feature to control duplicated file open
|
||||
/ and illegal operation to open objects. This option must be 0 when _FS_READONLY
|
||||
/ is 1.
|
||||
/
|
||||
/ 0: Disable file lock feature. To avoid volume corruption, application program
|
||||
/ should avoid illegal open, remove and rename to the open objects.
|
||||
/ >0: Enable file lock feature. The value defines how many files/sub-directories
|
||||
/ can be opened simultaneously under file lock control. Note that the file
|
||||
/ lock feature is independent of re-entrancy. */
|
||||
|
||||
|
||||
#define _FS_REENTRANT 0
|
||||
#define _FS_TIMEOUT 1000
|
||||
#define _SYNC_t HANDLE
|
||||
/* The _FS_REENTRANT option switches the re-entrancy (thread safe) of the FatFs
|
||||
/ module itself. Note that regardless of this option, file access to different
|
||||
/ volume is always re-entrant and volume control functions, f_mount(), f_mkfs()
|
||||
/ and f_fdisk() function, are always not re-entrant. Only file/directory access
|
||||
/ to the same volume is under control of this feature.
|
||||
/
|
||||
/ 0: Disable re-entrancy. _FS_TIMEOUT and _SYNC_t have no effect.
|
||||
/ 1: Enable re-entrancy. Also user provided synchronization handlers,
|
||||
/ ff_req_grant(), ff_rel_grant(), ff_del_syncobj() and ff_cre_syncobj()
|
||||
/ function, must be added to the project. Samples are available in
|
||||
/ option/syscall.c.
|
||||
/
|
||||
/ The _FS_TIMEOUT defines timeout period in unit of time tick.
|
||||
/ The _SYNC_t defines O/S dependent sync object type. e.g. HANDLE, ID, OS_EVENT*,
|
||||
/ SemaphoreHandle_t and etc.. */
|
||||
|
||||
|
||||
#define _WORD_ACCESS 0
|
||||
/* The _WORD_ACCESS option is an only platform dependent option. It defines
|
||||
/ which access method is used to the word data on the FAT volume.
|
||||
/
|
||||
/ 0: Byte-by-byte access. Always compatible with all platforms.
|
||||
/ 1: Word access. Do not choose this unless under both the following conditions.
|
||||
/
|
||||
/ * Address misaligned memory access is always allowed to ALL instructions.
|
||||
/ * Byte order on the memory is little-endian.
|
||||
/
|
||||
/ If it is the case, _WORD_ACCESS can also be set to 1 to reduce code size.
|
||||
/ Following table shows allowable settings of some processor types.
|
||||
/
|
||||
/ ARM7TDMI 0 ColdFire 0 V850E 0
|
||||
/ Cortex-M3 0 Z80 0/1 V850ES 0/1
|
||||
/ Cortex-M0 0 x86 0/1 TLCS-870 0/1
|
||||
/ AVR 0/1 RX600(LE) 0/1 TLCS-900 0/1
|
||||
/ AVR32 0 RL78 0 R32C 0
|
||||
/ PIC18 0/1 SH-2 0 M16C 0/1
|
||||
/ PIC24 0 H8S 0 MSP430 0
|
||||
/ PIC32 0 H8/300H 0 8051 0/1
|
||||
*/
|
||||
|
||||
1
lib/lwip
Submodule
1
lib/lwip
Submodule
Submodule lib/lwip added at 5b8b5d459e
Some files were not shown because too many files have changed in this diff Show More
Reference in New Issue
Block a user