commit
310faf7fcc
|
@ -6,6 +6,7 @@ local/
|
|||
user_config.h
|
||||
server-ca.crt
|
||||
luac.cross
|
||||
luac.cross.int
|
||||
uz_unzip
|
||||
uz_zip
|
||||
tools/toolchains/
|
||||
|
@ -14,3 +15,7 @@ tools/toolchains/
|
|||
.cproject
|
||||
.project
|
||||
.settings/
|
||||
.vscode
|
||||
|
||||
#ignore temp file for build infos
|
||||
buildinfo.h
|
||||
|
|
37
.travis.yml
37
.travis.yml
|
@ -1,4 +1,20 @@
|
|||
#os:
|
||||
# - windows
|
||||
# - linux
|
||||
|
||||
language: cpp
|
||||
|
||||
matrix:
|
||||
include:
|
||||
- os: linux
|
||||
env:
|
||||
- OS="$TRAVIS_OS_NAME"
|
||||
- LUACC=./luac.cross
|
||||
- os: windows
|
||||
env:
|
||||
- MSBUILD_PATH="c:\Program Files (x86)\Microsoft Visual Studio\2017\BuildTools\MSBuild\15.0\Bin"
|
||||
- OS="$TRAVIS_OS_NAME"
|
||||
- LUACC=msvc/luac-cross/x64/Debug/luac.cross.exe
|
||||
addons:
|
||||
apt:
|
||||
packages:
|
||||
|
@ -8,16 +24,13 @@ cache:
|
|||
- directories:
|
||||
- cache
|
||||
script:
|
||||
- export BUILD_DATE=$(date +%Y%m%d)
|
||||
- make EXTRA_CCFLAGS="-DBUILD_DATE='\"'$BUILD_DATE'\"'" all
|
||||
- cd bin/
|
||||
- file_name_float="nodemcu_float_${TRAVIS_TAG}.bin"
|
||||
- srec_cat -output ${file_name_float} -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000
|
||||
- cd ../
|
||||
- make clean
|
||||
- make EXTRA_CCFLAGS="-DLUA_NUMBER_INTEGRAL -DBUILD_DATE='\"'$BUILD_DATE'\"'"
|
||||
- cd bin/
|
||||
- file_name_integer="nodemcu_integer_${TRAVIS_TAG}.bin"
|
||||
- srec_cat -output ${file_name_integer} -binary 0x00000.bin -binary -fill 0xff 0x00000 0x10000 0x10000.bin -binary -offset 0x10000
|
||||
- echo OS is $OS $TRAVIS_OS_NAME
|
||||
# http://docs.travis-ci.com/user/environment-variables/#Convenience-Variables
|
||||
- if [ "$TRAVIS_PULL_REQUEST" != "false" ]; then bash "$TRAVIS_BUILD_DIR"/tools/pr-build.sh; fi
|
||||
- if [ "$OS" = "linux" ]; then bash "$TRAVIS_BUILD_DIR"/tools/travis/ci-build-linux.sh; fi
|
||||
- if [ "$OS" = "windows" ]; then bash "$TRAVIS_BUILD_DIR"/tools/travis/ci-build-windows-ms.sh; fi
|
||||
- if [ "$OS" = "linux" -a "$TRAVIS_PULL_REQUEST" != "false" ]; then bash "$TRAVIS_BUILD_DIR"/tools/travis/pr-build.sh; fi
|
||||
- cd "$TRAVIS_BUILD_DIR"
|
||||
- echo "checking:"
|
||||
- find lua_modules lua_examples -iname "*.lua" -print0 | xargs -0 echo
|
||||
- find lua_modules lua_examples -iname "*.lua" -print0 | xargs -0 $LUACC -p
|
||||
# - if [ "$OS" = "linux" ]; then bash "$TRAVIS_BUILD_DIR"/tools/travis/run-luacheck.sh || true ; fi
|
||||
|
|
|
@ -26,6 +26,13 @@ Use the platform and tools you feel most comfortable with. There are no constrai
|
|||
- [Full-fledged Linux environment](http://www.esp8266.com/wiki/doku.php?id=toolchain#how_to_setup_a_vm_to_host_your_toolchain), either physical or virtual.
|
||||
- [Docker image](https://hub.docker.com/r/marcelstoer/nodemcu-build/) which allows running the build inside the container as if you were running a build script on your local machine.
|
||||
|
||||
## Writing Lua Code
|
||||
A great resource about writing Lua for NodeMCU can be found in [Lua Developer FAQ](https://nodemcu.readthedocs.io/en/latest/lua-developer-faq/) - make sure to read it! When you're writing your Lua code and it's not working as it should you can test it with `luacheck` tool that can help you find various types of bugs. To install it you have to install [luarocks](https://luarocks.org/) and use command `sudo luarocks install luacheck` to install the tool. Now you're ready to go! By using this command (assuming you're in `nodemcu-firmware` directory):
|
||||
|
||||
`luacheck --config tools/luacheck_config.lua <your file to check>`
|
||||
|
||||
you can look for bugs and problems within the code!
|
||||
|
||||
## Writing Documentation
|
||||
The NodeMCU documentation is maintained within the same repository as the code. The primary reason is to keep the two in sync more easily. It's thus trivial for the NodeMCU team to verify that a PR includes the necessary documentation. Furthermore, the documentation is merged automatically with the code if it moves from branch X to Y.
|
||||
|
||||
|
|
380
Makefile
380
Makefile
|
@ -2,29 +2,42 @@
|
|||
#
|
||||
.NOTPARALLEL:
|
||||
|
||||
TOOLCHAIN_VERSION:=20181106.0
|
||||
|
||||
# SDK base version, as released by Espressif
|
||||
SDK_BASE_VER:=2.2.1
|
||||
|
||||
# no patch: SDK_VER equals SDK_BASE_VER and sdk dir depends on sdk_extracted
|
||||
SDK_VER:=$(SDK_BASE_VER)
|
||||
SDK_DIR_DEPENDS:=sdk_extracted
|
||||
|
||||
# with patch: SDK_VER differs from SDK_BASE_VER and sdk dir depends on sdk_patched
|
||||
#SDK_PATCH_VER:=f8f27ce
|
||||
#SDK_VER:=$(SDK_BASE_VER)-$(SDK_PATCH_VER)
|
||||
#SDK_DIR_DEPENDS:=sdk_patched
|
||||
|
||||
SDK_FILE_VER:=$(SDK_BASE_VER)
|
||||
SDK_FILE_SHA1:=48f2242d5895823709f222bf0fffce9d525996c8
|
||||
# SDK_PATCH_SHA1:=0bc21ec77b08488f04d3e1c9d161b711d07201a8
|
||||
# Ensure we search "our" SDK before the tool-chain's SDK (if any)
|
||||
TOP_DIR:=$(abspath $(dir $(lastword $(MAKEFILE_LIST))))
|
||||
SDK_REL_DIR=sdk/esp_iot_sdk_v$(SDK_VER)
|
||||
SDK_DIR:=$(TOP_DIR)/$(SDK_REL_DIR)
|
||||
CCFLAGS:= -I$(TOP_DIR)/sdk-overrides/include -I$(TOP_DIR)/app/include/lwip/app -I$(SDK_DIR)/include
|
||||
LDFLAGS:= -L$(SDK_DIR)/lib -L$(SDK_DIR)/ld $(LDFLAGS)
|
||||
|
||||
# SDK base version, as released by Espressif depends on the RELEASE flag
|
||||
#
|
||||
# RELEASE = lastest pulls the latest V3.0.0 branch version as at the issue of this make
|
||||
# otherwise it pulls the labelled version in the SDK version's release directory
|
||||
#
|
||||
ifeq ("$(RELEASE)","latest-3.0")
|
||||
SDK_VER := 3.0.0
|
||||
SDK_FILE_SHA1 := NA
|
||||
SDK_ZIP_ROOT := ESP8266_NONOS_SDK-release-v$(SDK_VER)
|
||||
SDK_FILE_VER := release/v$(SDK_VER)
|
||||
else ifeq ("$(RELEASE)","master")
|
||||
SDK_VER := master
|
||||
SDK_FILE_SHA1 := NA
|
||||
SDK_ZIP_ROOT := ESP8266_NONOS_SDK-$(SDK_VER)
|
||||
SDK_FILE_VER := $(SDK_VER)
|
||||
else
|
||||
# SDK_VER := 3.0
|
||||
# SDK_FILE_VER := v$(SDK_VER)
|
||||
SDK_FILE_VER := e4434aa730e78c63040ace360493aef420ec267c
|
||||
SDK_VER := 3.0-e4434aa
|
||||
SDK_FILE_SHA1 := ac6528a6a206d3d4c220e4035ced423eb314cfbf
|
||||
SDK_ZIP_ROOT := ESP8266_NONOS_SDK-$(SDK_FILE_VER)
|
||||
endif
|
||||
SDK_REL_DIR := sdk/esp_iot_sdk_v$(SDK_VER)
|
||||
SDK_DIR := $(TOP_DIR)/$(SDK_REL_DIR)
|
||||
APP_DIR := $(TOP_DIR)/app
|
||||
|
||||
ESPTOOL_VER := 2.6
|
||||
|
||||
# Ensure that the Espresif SDK is search before application paths and also prevent
|
||||
# the SDK's c_types.h from being included from anywhere, by predefining its include-guard.
|
||||
|
||||
CCFLAGS := $(CCFLAGS) -I $(PDIR)sdk-overrides/include -I $(SDK_DIR)/include -D_C_TYPES_H_
|
||||
LDFLAGS := -L$(SDK_DIR)/lib -L$(SDK_DIR)/ld $(LDFLAGS)
|
||||
|
||||
ifdef DEBUG
|
||||
CCFLAGS += -ggdb -O0
|
||||
|
@ -33,111 +46,137 @@ else
|
|||
CCFLAGS += -O2
|
||||
endif
|
||||
|
||||
#Handling of V=1/VERBOSE=1 flag
|
||||
|
||||
# Handling of V=1/VERBOSE=1 flag
|
||||
#
|
||||
# if V=1, $(summary) does nothing
|
||||
# if V is unset or not 1, $(summary) echoes a summary
|
||||
VERBOSE ?=
|
||||
V ?= $(VERBOSE)
|
||||
ifeq ("$(V)","1")
|
||||
export summary := @true
|
||||
export summary := @true
|
||||
else
|
||||
export summary := @echo
|
||||
|
||||
# disable echoing of commands, directory names
|
||||
MAKEFLAGS += --silent -w
|
||||
export summary := @echo
|
||||
# disable echoing of commands, directory names
|
||||
MAKEFLAGS += --silent -w
|
||||
endif # $(V)==1
|
||||
|
||||
ifndef BAUDRATE
|
||||
BAUDRATE=115200
|
||||
BAUDRATE=115200
|
||||
endif
|
||||
|
||||
#############################################################
|
||||
# Select compile
|
||||
#
|
||||
ifeq ($(OS),Windows_NT)
|
||||
# WIN32
|
||||
# We are under windows.
|
||||
ifeq ($(XTENSA_CORE),lx106)
|
||||
# It is xcc
|
||||
AR = xt-ar
|
||||
CC = xt-xcc
|
||||
CXX = xt-xcc
|
||||
NM = xt-nm
|
||||
CPP = xt-cpp
|
||||
OBJCOPY = xt-objcopy
|
||||
#MAKE = xt-make
|
||||
CCFLAGS += --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal
|
||||
else
|
||||
# It is gcc, may be cygwin
|
||||
# Can we use -fdata-sections?
|
||||
CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections
|
||||
AR = xtensa-lx106-elf-ar
|
||||
CC = xtensa-lx106-elf-gcc
|
||||
CXX = xtensa-lx106-elf-g++
|
||||
NM = xtensa-lx106-elf-nm
|
||||
CPP = xtensa-lx106-elf-cpp
|
||||
OBJCOPY = xtensa-lx106-elf-objcopy
|
||||
endif
|
||||
FIRMWAREDIR = ..\\bin\\
|
||||
ifndef COMPORT
|
||||
ESPPORT = com1
|
||||
else
|
||||
ESPPORT = $(COMPORT)
|
||||
endif
|
||||
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
|
||||
# ->AMD64
|
||||
endif
|
||||
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
|
||||
# ->IA32
|
||||
endif
|
||||
else
|
||||
# We are under other system, may be Linux. Assume using gcc.
|
||||
# Can we use -fdata-sections?
|
||||
PLATFORM:=linux-x86_64
|
||||
ifndef COMPORT
|
||||
ESPPORT = /dev/ttyUSB0
|
||||
else
|
||||
ESPPORT = $(COMPORT)
|
||||
endif
|
||||
export PATH := $(PATH):$(TOP_DIR)/tools/toolchains/esp8266-$(PLATFORM)-$(TOOLCHAIN_VERSION)/bin/
|
||||
CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections
|
||||
AR = xtensa-lx106-elf-ar
|
||||
CC = $(WRAPCC) xtensa-lx106-elf-gcc
|
||||
CXX = $(WRAPCC) xtensa-lx106-elf-g++
|
||||
NM = xtensa-lx106-elf-nm
|
||||
CPP = $(WRAPCC) xtensa-lx106-elf-gcc -E
|
||||
OBJCOPY = xtensa-lx106-elf-objcopy
|
||||
FIRMWAREDIR = ../bin/
|
||||
UNAME_S := $(shell uname -s)
|
||||
ifeq ($(UNAME_S),Linux)
|
||||
# LINUX
|
||||
endif
|
||||
ifeq ($(UNAME_S),Darwin)
|
||||
# OSX
|
||||
endif
|
||||
UNAME_P := $(shell uname -p)
|
||||
ifeq ($(UNAME_P),x86_64)
|
||||
# ->AMD64
|
||||
endif
|
||||
ifneq ($(filter %86,$(UNAME_P)),)
|
||||
# ->IA32
|
||||
endif
|
||||
ifneq ($(filter arm%,$(UNAME_P)),)
|
||||
# ->ARM
|
||||
endif
|
||||
# ** HEALTH WARNING ** This section is largely legacy directives left over from
|
||||
# an Espressif template. As far as I (TerrryE) know, we've only used the Linux
|
||||
# Path. I have successfully build AMD and Intel (both x86, AMD64) and RPi ARM6
|
||||
# all under Ubuntu. Our docker container runs on Windows in an Ubuntu VM.
|
||||
# Johny Mattson maintains a prebuild AMD64 xtensa cross-compile gcc v4.8.5
|
||||
# toolchain which is compatible with the non-OS SDK and can be used on any recent
|
||||
# Ubuntu version including the Docker and Travis build environments.
|
||||
#
|
||||
# You have the option to build your own toolchain and specify a TOOLCHAIN_ROOT
|
||||
# environment variable (see https://github.com/pfalcon/esp-open-sdk). If your
|
||||
# architecture is compatable then you can omit this variable and the make will
|
||||
# download and use this prebuilt toolchain.
|
||||
#
|
||||
# If any developers wish to develop, test and support alternative environments
|
||||
# then please raise a GitHub issue on this work.
|
||||
#
|
||||
|
||||
ifndef $(OS)
|
||||
# Assume Windows if MAKE_HOST contains "indows" and Linux otherwise
|
||||
ifneq (,$(findstring indows,$(MAKE_HOST)))
|
||||
OS := windows
|
||||
else
|
||||
OS := linux
|
||||
endif
|
||||
endif
|
||||
#############################################################
|
||||
ESPTOOL ?= ../tools/esptool.py
|
||||
|
||||
ifneq (,$(findstring indows,$(OS)))
|
||||
#------------ BEGIN UNTESTED ------------ We are not under Linux, e.g.under windows.
|
||||
ifeq ($(XTENSA_CORE),lx106)
|
||||
# It is xcc
|
||||
AR = xt-ar
|
||||
CC = xt-xcc
|
||||
CXX = xt-xcc
|
||||
NM = xt-nm
|
||||
CPP = xt-cpp
|
||||
OBJCOPY = xt-objcopy
|
||||
#MAKE = xt-make
|
||||
CCFLAGS += --rename-section .text=.irom0.text --rename-section .literal=.irom0.literal
|
||||
else
|
||||
# It is gcc, may be cygwin
|
||||
# Can we use -fdata-sections?
|
||||
CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections
|
||||
AR = xtensa-lx106-elf-ar
|
||||
CC = xtensa-lx106-elf-gcc
|
||||
CXX = xtensa-lx106-elf-g++
|
||||
NM = xtensa-lx106-elf-nm
|
||||
CPP = xtensa-lx106-elf-cpp
|
||||
OBJCOPY = xtensa-lx106-elf-objcopy
|
||||
endif
|
||||
FIRMWAREDIR = ..\\bin\\
|
||||
ifndef COMPORT
|
||||
ESPPORT = com1
|
||||
else
|
||||
ESPPORT = $(COMPORT)
|
||||
endif
|
||||
ifeq ($(PROCESSOR_ARCHITECTURE),AMD64)
|
||||
# ->AMD64
|
||||
endif
|
||||
ifeq ($(PROCESSOR_ARCHITECTURE),x86)
|
||||
# ->IA32
|
||||
endif
|
||||
#---------------- END UNTESTED ---------------- We are under windows.
|
||||
else
|
||||
# We are under other system, may be Linux. Assume using gcc.
|
||||
|
||||
UNAME_S := $(shell uname -s)
|
||||
UNAME_P := $(shell uname -p)
|
||||
ifeq ($(OS),linux)
|
||||
ifndef TOOLCHAIN_ROOT
|
||||
TOOLCHAIN_VERSION = 20181106.0
|
||||
GCCTOOLCHAIN = linux-x86_64-$(TOOLCHAIN_VERSION)
|
||||
TOOLCHAIN_ROOT = $(TOP_DIR)/tools/toolchains/esp8266-$(GCCTOOLCHAIN)
|
||||
GITHUB_TOOLCHAIN = https://github.com/jmattsson/esp-toolchains
|
||||
export PATH:=$(PATH):$(TOOLCHAIN_ROOT)/bin
|
||||
endif
|
||||
endif
|
||||
|
||||
ifndef COMPORT
|
||||
ESPPORT = /dev/ttyUSB0
|
||||
else
|
||||
ESPPORT = $(COMPORT)
|
||||
endif
|
||||
|
||||
CCFLAGS += -ffunction-sections -fno-jump-tables -fdata-sections
|
||||
AR = xtensa-lx106-elf-ar
|
||||
CC = $(WRAPCC) xtensa-lx106-elf-gcc
|
||||
CXX = $(WRAPCC) xtensa-lx106-elf-g++
|
||||
NM = xtensa-lx106-elf-nm
|
||||
CPP = $(WRAPCC) xtensa-lx106-elf-gcc -E
|
||||
OBJCOPY = xtensa-lx106-elf-objcopy
|
||||
FIRMWAREDIR = ../bin/
|
||||
WGET = wget --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused
|
||||
endif
|
||||
|
||||
GITHUB_SDK = https://github.com/espressif/ESP8266_NONOS_SDK
|
||||
GITHUB_ESPTOOL = https://github.com/espressif/esptool
|
||||
|
||||
ESPTOOL ?= $(TOP_DIR)/tools/toolchains/esptool.py
|
||||
|
||||
CSRCS ?= $(wildcard *.c)
|
||||
CXXSRCS ?= $(wildcard *.cpp)
|
||||
ASRCs ?= $(wildcard *.s)
|
||||
ASRCS ?= $(wildcard *.S)
|
||||
SUBDIRS ?= $(patsubst %/,%,$(dir $(filter-out tools/Makefile,$(wildcard */Makefile))))
|
||||
|
||||
ODIR := .output
|
||||
ODIR := .output
|
||||
|
||||
ifdef TARGET
|
||||
CSRCS ?= $(wildcard *.c)
|
||||
CXXSRCS ?= $(wildcard *.cpp)
|
||||
ASRCs ?= $(wildcard *.s)
|
||||
ASRCS ?= $(wildcard *.S)
|
||||
|
||||
OBJODIR := $(ODIR)/$(TARGET)/$(FLAVOR)/obj
|
||||
|
||||
OBJS := $(CSRCS:%.c=$(OBJODIR)/%.o) \
|
||||
|
@ -160,19 +199,19 @@ BINODIR := $(ODIR)/$(TARGET)/$(FLAVOR)/bin
|
|||
OBINS := $(GEN_BINS:%=$(BINODIR)/%)
|
||||
|
||||
ifndef PDIR
|
||||
ifneq ($(wildcard $(TOP_DIR)/local/fs/*),)
|
||||
SPECIAL_MKTARGETS += spiffs-image
|
||||
else
|
||||
SPECIAL_MKTARGETS += spiffs-image-remove
|
||||
ifneq ($(wildcard $(TOP_DIR)/local/fs/*),)
|
||||
SPECIAL_MKTARGETS += spiffs-image
|
||||
else
|
||||
SPECIAL_MKTARGETS += spiffs-image-remove
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
endif # TARGET
|
||||
#
|
||||
# Note:
|
||||
# https://gcc.gnu.org/onlinedocs/gcc/Optimize-Options.html
|
||||
# If you add global optimize options like "-O2" here
|
||||
# they will override "-Os" defined above.
|
||||
# "-Os" should be used to reduce code size
|
||||
# If you add global optimize options then they will override "-Os" defined above.
|
||||
# Note that "-Os" should NOT be used to reduce code size because of the runtime
|
||||
# impact of the extra non-aligned exception burdon.
|
||||
#
|
||||
CCFLAGS += \
|
||||
-g \
|
||||
|
@ -183,7 +222,7 @@ CCFLAGS += \
|
|||
-fno-inline-functions \
|
||||
-nostdlib \
|
||||
-mlongcalls \
|
||||
-mtext-section-literals
|
||||
-mtext-section-literals \
|
||||
# -Wall
|
||||
|
||||
CFLAGS = $(CCFLAGS) $(DEFINES) $(EXTRA_CCFLAGS) $(STD_CFLAGS) $(INCLUDES)
|
||||
|
@ -194,6 +233,8 @@ DFLAGS = $(CCFLAGS) $(DDEFINES) $(EXTRA_CCFLAGS) $(STD_CFLAGS) $(INCLUDES)
|
|||
# Functions
|
||||
#
|
||||
|
||||
ifdef TARGET
|
||||
|
||||
define ShortcutRule
|
||||
$(1): .subdirs $(2)/$(1)
|
||||
endef
|
||||
|
@ -226,70 +267,82 @@ $(BINODIR)/%.bin: $(IMAGEODIR)/%.out
|
|||
$(summary) ESPTOOL $(patsubst $(TOP_DIR)/%,%,$(CURDIR))/$< $(FIRMWAREDIR)
|
||||
$(ESPTOOL) elf2image --flash_mode dio --flash_freq 40m $< -o $(FIRMWAREDIR)
|
||||
|
||||
endif # TARGET
|
||||
#############################################################
|
||||
# Rules base
|
||||
# Should be done in top-level makefile only
|
||||
#
|
||||
|
||||
all: toolchain sdk_pruned pre_build .subdirs $(OBJS) $(OLIBS) $(OIMAGES) $(OBINS) $(SPECIAL_MKTARGETS)
|
||||
ifndef TARGET
|
||||
all: toolchain sdk_pruned pre_build buildinfo .subdirs
|
||||
else
|
||||
all: .subdirs $(OBJS) $(OLIBS) $(OIMAGES) $(OBINS) $(SPECIAL_MKTARGETS)
|
||||
endif
|
||||
|
||||
.PHONY: sdk_extracted
|
||||
.PHONY: sdk_patched
|
||||
.PHONY: sdk_pruned
|
||||
.PHONY: toolchain
|
||||
|
||||
sdk_extracted: $(TOP_DIR)/sdk/.extracted-$(SDK_BASE_VER)
|
||||
sdk_patched: sdk_extracted $(TOP_DIR)/sdk/.patched-$(SDK_VER)
|
||||
sdk_pruned: $(SDK_DIR_DEPENDS) $(TOP_DIR)/sdk/.pruned-$(SDK_VER)
|
||||
sdk_extracted: $(TOP_DIR)/sdk/.extracted-$(SDK_VER)
|
||||
sdk_pruned: sdk_extracted toolchain $(TOP_DIR)/sdk/.pruned-$(SDK_VER)
|
||||
|
||||
ifeq ($(OS),Windows_NT)
|
||||
toolchain:
|
||||
else
|
||||
toolchain: $(TOP_DIR)/tools/toolchains/esp8266-$(PLATFORM)-$(TOOLCHAIN_VERSION)/bin/xtensa-lx106-elf-gcc
|
||||
ifdef GITHUB_TOOLCHAIN
|
||||
TOOLCHAIN_ROOT := $(TOP_DIR)/tools/toolchains/esp8266-linux-x86_64-$(TOOLCHAIN_VERSION)
|
||||
|
||||
$(TOP_DIR)/tools/toolchains/esp8266-$(PLATFORM)-$(TOOLCHAIN_VERSION)/bin/xtensa-lx106-elf-gcc: $(TOP_DIR)/cache/toolchain-esp8266-$(PLATFORM)-$(TOOLCHAIN_VERSION).tar.xz
|
||||
toolchain: $(TOOLCHAIN_ROOT)/bin $(ESPTOOL)
|
||||
|
||||
$(TOOLCHAIN_ROOT)/bin: $(TOP_DIR)/cache/toolchain-esp8266-$(GCCTOOLCHAIN).tar.xz
|
||||
mkdir -p $(TOP_DIR)/tools/toolchains/
|
||||
$(summary) EXTRACT $(patsubst $(TOP_DIR)/%,%,$<)
|
||||
tar -xJf $< -C $(TOP_DIR)/tools/toolchains/
|
||||
touch $@
|
||||
|
||||
$(TOP_DIR)/cache/toolchain-esp8266-$(PLATFORM)-$(TOOLCHAIN_VERSION).tar.xz:
|
||||
$(TOP_DIR)/cache/toolchain-esp8266-$(GCCTOOLCHAIN).tar.xz:
|
||||
mkdir -p $(TOP_DIR)/cache
|
||||
$(summary) WGET $(patsubst $(TOP_DIR)/%,%,$@)
|
||||
wget --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused https://github.com/jmattsson/esp-toolchains/releases/download/$(PLATFORM)-$(TOOLCHAIN_VERSION)/toolchain-esp8266-$(PLATFORM)-$(TOOLCHAIN_VERSION).tar.xz -O $@ || { rm -f "$@"; exit 1; }
|
||||
$(WGET) $(GITHUB_TOOLCHAIN)/releases/download/$(GCCTOOLCHAIN)/toolchain-esp8266-$(GCCTOOLCHAIN).tar.xz -O $@ \
|
||||
|| { rm -f "$@"; exit 1; }
|
||||
else
|
||||
toolchain: $(ESPTOOL)
|
||||
endif
|
||||
|
||||
$(TOP_DIR)/sdk/.extracted-$(SDK_BASE_VER): $(TOP_DIR)/cache/v$(SDK_FILE_VER).zip
|
||||
mkdir -p "$(dir $@)"
|
||||
$(summary) UNZIP $(patsubst $(TOP_DIR)/%,%,$<)
|
||||
(cd "$(dir $@)" && rm -fr esp_iot_sdk_v$(SDK_VER) ESP8266_NONOS_SDK-$(SDK_BASE_VER) && unzip $(TOP_DIR)/cache/v$(SDK_FILE_VER).zip ESP8266_NONOS_SDK-$(SDK_BASE_VER)/lib/* ESP8266_NONOS_SDK-$(SDK_BASE_VER)/ld/eagle.rom.addr.v6.ld ESP8266_NONOS_SDK-$(SDK_BASE_VER)/include/* ESP8266_NONOS_SDK-$(SDK_BASE_VER)/bin/esp_init_data_default_v05.bin)
|
||||
mv $(dir $@)/ESP8266_NONOS_SDK-$(SDK_BASE_VER) $(dir $@)/esp_iot_sdk_v$(SDK_BASE_VER)
|
||||
$(ESPTOOL): $(TOP_DIR)/cache/esptool/v$(ESPTOOL_VER).tar.gz
|
||||
mkdir -p $(TOP_DIR)/tools/toolchains/
|
||||
tar -C $(TOP_DIR)/tools/toolchains/ -xzf $< --strip-components=1 esptool-$(ESPTOOL_VER)/esptool.py
|
||||
chmod +x $@
|
||||
touch $@
|
||||
|
||||
$(TOP_DIR)/sdk/.patched-$(SDK_VER): $(TOP_DIR)/cache/$(SDK_PATCH_VER).patch
|
||||
mv $(dir $@)/esp_iot_sdk_v$(SDK_BASE_VER) $(dir $@)/esp_iot_sdk_v$(SDK_VER)
|
||||
$(summary) APPLY $(patsubst $(TOP_DIR)/%,%,$<)
|
||||
git apply --verbose -p1 --exclude='*VERSION' --exclude='*bin/at*' --directory=$(SDK_REL_DIR) $<
|
||||
$(TOP_DIR)/cache/esptool/v$(ESPTOOL_VER).tar.gz:
|
||||
mkdir -p $(TOP_DIR)/cache/esptool/
|
||||
$(WGET) $(GITHUB_ESPTOOL)/archive/v$(ESPTOOL_VER).tar.gz -O $@ || { rm -f "$@"; exit 1; }
|
||||
|
||||
$(TOP_DIR)/sdk/.extracted-$(SDK_VER): $(TOP_DIR)/cache/$(SDK_FILE_VER).zip
|
||||
mkdir -p "$(dir $@)"
|
||||
$(summary) UNZIP $(patsubst $(TOP_DIR)/%,%,$<)
|
||||
(cd "$(dir $@)" && \
|
||||
rm -fr esp_iot_sdk_v$(SDK_VER) ESP8266_NONOS_SDK-* && \
|
||||
unzip $(TOP_DIR)/cache/$(SDK_FILE_VER).zip \
|
||||
'*/lib/*' \
|
||||
'*/ld/*.v6.ld' \
|
||||
'*/include/*' \
|
||||
'*/bin/esp_init_data_default_v05.bin' \
|
||||
)
|
||||
mv $(dir $@)/$(SDK_ZIP_ROOT) $(dir $@)/esp_iot_sdk_v$(SDK_VER)
|
||||
touch $@
|
||||
|
||||
$(TOP_DIR)/sdk/.pruned-$(SDK_VER):
|
||||
rm -f $(SDK_DIR)/lib/liblwip.a $(SDK_DIR)/lib/libssl.a $(SDK_DIR)/lib/libmbedtls.a
|
||||
$(summary) PRUNE libmain.a libc.a
|
||||
echo $(PATH)
|
||||
$(AR) d $(SDK_DIR)/lib/libmain.a time.o
|
||||
$(AR) d $(SDK_DIR)/lib/libc.a lib_a-time.o
|
||||
touch $@
|
||||
|
||||
$(TOP_DIR)/cache/v$(SDK_FILE_VER).zip:
|
||||
$(TOP_DIR)/cache/$(SDK_FILE_VER).zip:
|
||||
mkdir -p "$(dir $@)"
|
||||
$(summary) WGET $(patsubst $(TOP_DIR)/%,%,$@)
|
||||
wget --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused https://github.com/espressif/ESP8266_NONOS_SDK/archive/v$(SDK_FILE_VER).zip -O $@ || { rm -f "$@"; exit 1; }
|
||||
(echo "$(SDK_FILE_SHA1) $@" | sha1sum -c -) || { rm -f "$@"; exit 1; }
|
||||
|
||||
$(TOP_DIR)/cache/$(SDK_PATCH_VER).patch:
|
||||
mkdir -p "$(dir $@)"
|
||||
$(summary) WGET $(SDK_PATCH_VER).patch
|
||||
wget --tries=10 --timeout=15 --waitretry=30 --read-timeout=20 --retry-connrefused "https://github.com/espressif/ESP8266_NONOS_SDK/compare/v$(SDK_BASE_VER)...$(SDK_PATCH_VER).patch" -O $@ || { rm -f "$@"; exit 1; }
|
||||
(echo "$(SDK_PATCH_SHA1) $@" | sha1sum -c -) || { rm -f "$@"; exit 1; }
|
||||
$(WGET) $(GITHUB_SDK)/archive/$(SDK_FILE_VER).zip -O $@ || { rm -f "$@"; exit 1; }
|
||||
if test "$(SDK_FILE_SHA1)" != "NA"; then echo "$(SDK_FILE_SHA1) $@" | sha1sum -c - || { rm -f "$@"; exit 1; }; fi
|
||||
|
||||
clean:
|
||||
$(foreach d, $(SUBDIRS), $(MAKE) -C $(d) clean;)
|
||||
|
@ -318,7 +371,7 @@ flash1m-dout:
|
|||
|
||||
flashinternal:
|
||||
ifndef PDIR
|
||||
$(MAKE) -C ./app flashinternal
|
||||
$(MAKE) -C $(APP_DIR) flashinternal
|
||||
else
|
||||
$(ESPTOOL) --port $(ESPPORT) --baud $(BAUDRATE) write_flash $(FLASHOPTIONS) 0x00000 $(FIRMWAREDIR)0x00000.bin 0x10000 $(FIRMWAREDIR)0x10000.bin
|
||||
endif
|
||||
|
@ -326,15 +379,12 @@ endif
|
|||
.subdirs:
|
||||
@set -e; $(foreach d, $(SUBDIRS), $(MAKE) -C $(d);)
|
||||
|
||||
#.subdirs:
|
||||
# $(foreach d, $(SUBDIRS), $(MAKE) -C $(d))
|
||||
|
||||
ifneq ($(MAKECMDGOALS),clean)
|
||||
ifneq ($(MAKECMDGOALS),clobber)
|
||||
ifdef DEPS
|
||||
sinclude $(DEPS)
|
||||
endif
|
||||
endif
|
||||
ifneq ($(MAKECMDGOALS),clobber)
|
||||
ifdef DEPS
|
||||
sinclude $(DEPS)
|
||||
endif
|
||||
endif
|
||||
endif
|
||||
|
||||
.PHONY: spiffs-image-remove
|
||||
|
@ -346,22 +396,28 @@ spiffs-image-remove:
|
|||
|
||||
spiffs-image: bin/0x10000.bin
|
||||
$(MAKE) -C tools
|
||||
|
||||
############ Note: this target needs moving into app/modules make ############
|
||||
.PHONY: pre_build
|
||||
|
||||
ifneq ($(wildcard $(TOP_DIR)/server-ca.crt),)
|
||||
pre_build: $(TOP_DIR)/app/modules/server-ca.crt.h
|
||||
pre_build: $(APP_DIR)/modules/server-ca.crt.h
|
||||
|
||||
$(TOP_DIR)/app/modules/server-ca.crt.h: $(TOP_DIR)/server-ca.crt
|
||||
$(APP_DIR)/modules/server-ca.crt.h: $(TOP_DIR)/server-ca.crt
|
||||
$(summary) MKCERT $(patsubst $(TOP_DIR)/%,%,$<)
|
||||
python $(TOP_DIR)/tools/make_server_cert.py $(TOP_DIR)/server-ca.crt > $(TOP_DIR)/app/modules/server-ca.crt.h
|
||||
python $(TOP_DIR)/tools/make_server_cert.py $(TOP_DIR)/server-ca.crt > $(APP_DIR)/modules/server-ca.crt.h
|
||||
|
||||
DEFINES += -DHAVE_SSL_SERVER_CRT=\"server-ca.crt.h\"
|
||||
else
|
||||
pre_build:
|
||||
@-rm -f $(TOP_DIR)/app/modules/server-ca.crt.h
|
||||
@-rm -f $(APP_DIR)/modules/server-ca.crt.h
|
||||
endif
|
||||
|
||||
.PHONY: buildinfo
|
||||
|
||||
buildinfo:
|
||||
tools/update_buildinfo.sh
|
||||
|
||||
ifdef TARGET
|
||||
$(OBJODIR)/%.o: %.c
|
||||
@mkdir -p $(dir $@);
|
||||
$(summary) CC $(patsubst $(TOP_DIR)/%,%,$(CURDIR))/$<
|
||||
|
@ -421,6 +477,7 @@ $(foreach lib,$(GEN_LIBS),$(eval $(call MakeLibrary,$(basename $(lib)))))
|
|||
|
||||
$(foreach image,$(GEN_IMAGES),$(eval $(call MakeImage,$(basename $(image)))))
|
||||
|
||||
endif # TARGET
|
||||
#############################################################
|
||||
# Recursion Magic - Don't touch this!!
|
||||
#
|
||||
|
@ -433,6 +490,5 @@ $(foreach image,$(GEN_IMAGES),$(eval $(call MakeImage,$(basename $(image)))))
|
|||
# Required for each makefile to inherit from the parent
|
||||
#
|
||||
|
||||
INCLUDES := $(INCLUDES) -I $(PDIR)include -I $(PDIR)include/$(TARGET)
|
||||
PDIR := ../$(PDIR)
|
||||
sinclude $(PDIR)Makefile
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
# **NodeMCU 2.2.1** #
|
||||
# NodeMCU 3.0.0
|
||||
|
||||
[](https://gitter.im/nodemcu/nodemcu-firmware?utm_source=badge&utm_medium=badge&utm_campaign=pr-badge&utm_content=badge)
|
||||
[](https://travis-ci.org/nodemcu/nodemcu-firmware)
|
||||
|
@ -14,7 +14,7 @@ The firmware was initially developed as is a companion project to the popular ES
|
|||
# Summary
|
||||
|
||||
- Easy to program wireless node and/or access point
|
||||
- Based on Lua 5.1.4 (without `debug` & `os` modules)
|
||||
- Based on Lua 5.1.4 but without `debug`, `io`, `os` and (most of the) `math` modules
|
||||
- Asynchronous event-driven programming model
|
||||
- more than **65 built-in modules**
|
||||
- Firmware available with or without floating point support (integer-only uses less memory)
|
||||
|
|
85
app/Makefile
85
app/Makefile
|
@ -15,8 +15,6 @@ TARGET = eagle
|
|||
#FLAVOR = release
|
||||
FLAVOR = debug
|
||||
|
||||
#EXTRA_CCFLAGS += -u
|
||||
|
||||
ifndef PDIR # {
|
||||
GEN_IMAGES= eagle.app.v6.out
|
||||
GEN_BINS= eagle.app.v6.bin
|
||||
|
@ -42,10 +40,10 @@ SUBDIRS= \
|
|||
smart \
|
||||
modules \
|
||||
spiffs \
|
||||
net \
|
||||
net \
|
||||
fatfs \
|
||||
esp-gdbstub \
|
||||
pm \
|
||||
pm \
|
||||
uzlib \
|
||||
$(OPT_SEL_MKTARGETS)
|
||||
|
||||
|
@ -54,19 +52,19 @@ endif # } PDIR
|
|||
APPDIR = .
|
||||
LDDIR = ../ld
|
||||
|
||||
TARGET_LDFLAGS = \
|
||||
TARGET_LDFLAGS = \
|
||||
-nostdlib \
|
||||
-Wl,-EL \
|
||||
--longcalls \
|
||||
--longcalls \
|
||||
--text-section-literals
|
||||
|
||||
LD_FILE = $(LDDIR)/nodemcu.ld
|
||||
|
||||
COMPONENTS_eagle.app.v6 = \
|
||||
COMPONENTS_eagle.app.v6 = \
|
||||
user/libuser.a \
|
||||
crypto/libcrypto.a \
|
||||
driver/libdriver.a \
|
||||
platform/libplatform.a \
|
||||
platform/libplatform.a \
|
||||
task/libtask.a \
|
||||
libc/liblibc.a \
|
||||
lua/liblua.a \
|
||||
|
@ -74,48 +72,50 @@ COMPONENTS_eagle.app.v6 = \
|
|||
smart/smart.a \
|
||||
spiffs/spiffs.a \
|
||||
fatfs/libfatfs.a \
|
||||
pm/libpm.a \
|
||||
esp-gdbstub/libgdbstub.a \
|
||||
net/libnodemcu_net.a \
|
||||
mbedtls/libmbedtls.a \
|
||||
modules/libmodules.a \
|
||||
pm/libpm.a \
|
||||
esp-gdbstub/libgdbstub.a \
|
||||
net/libnodemcu_net.a \
|
||||
mbedtls/libmbedtls.a \
|
||||
modules/libmodules.a \
|
||||
smart/smart.a \
|
||||
uzlib/libuzlib.a \
|
||||
$(OPT_SEL_COMPONENTS)
|
||||
|
||||
|
||||
# Inspect the modules library and work out which modules need to be linked.
|
||||
# For each enabled module, a symbol name of the form XYZ_module_selected is
|
||||
# returned. At link time those names are declared undefined, so those (and
|
||||
# only those) modules are pulled in.
|
||||
SELECTED_MODULE_SYMS=$(filter %_module_selected %module_selected1,$(shell $(NM) modules/.output/$(TARGET)/$(FLAVOR)/lib/libmodules.a))
|
||||
|
||||
LINKFLAGS_eagle.app.v6 = \
|
||||
-Wl,--gc-sections \
|
||||
-Wl,-Map=mapfile \
|
||||
LINKFLAGS_eagle.app.v6 = \
|
||||
-Wl,--gc-sections \
|
||||
-Wl,-Map=mapfile \
|
||||
-nostdlib \
|
||||
-T$(LD_FILE) \
|
||||
-Wl,@../ld/defsym.rom \
|
||||
-Wl,--no-check-sections \
|
||||
-Wl,--wrap=_xtos_set_exception_handler \
|
||||
-Wl,-static \
|
||||
-T$(LD_FILE) \
|
||||
-Wl,@../ld/defsym.rom \
|
||||
-Wl,--no-check-sections \
|
||||
-Wl,-static \
|
||||
$(addprefix -u , $(SELECTED_MODULE_SYMS)) \
|
||||
-Wl,--start-group \
|
||||
-Wl,--start-group \
|
||||
-lmain \
|
||||
-lc \
|
||||
$(DEP_LIBS_eagle.app.v6)\
|
||||
-Wl,--end-group \
|
||||
-Wl,--start-group \
|
||||
-lgcc \
|
||||
-lhal \
|
||||
-lphy \
|
||||
-lpp \
|
||||
-lnet80211 \
|
||||
-lsmartconfig \
|
||||
-lwpa \
|
||||
-lwpa2 \
|
||||
-lsmartconfig \
|
||||
-lcrypto \
|
||||
-lwps \
|
||||
$(DEP_LIBS_eagle.app.v6) \
|
||||
-Wl,--end-group \
|
||||
-lm
|
||||
-lc \
|
||||
-lm \
|
||||
-Wl,--end-group
|
||||
# -Wl,--cref
|
||||
# -Wl,--wrap=_xtos_set_exception_handler
|
||||
|
||||
DEPENDS_eagle.app.v6 = \
|
||||
$(LD_FILE) \
|
||||
|
@ -131,29 +131,16 @@ DEPENDS_eagle.app.v6 = \
|
|||
|
||||
#UNIVERSAL_TARGET_DEFINES = \
|
||||
|
||||
# Other potential configuration flags include:
|
||||
# -DTXRX_TXBUF_DEBUG
|
||||
# -DTXRX_RXBUF_DEBUG
|
||||
# -DWLAN_CONFIG_CCX
|
||||
CONFIGURATION_DEFINES = -D__ets__ \
|
||||
-DICACHE_FLASH \
|
||||
-DLUA_OPTIMIZE_MEMORY=2 \
|
||||
-DMIN_OPT_LEVEL=2 \
|
||||
-DLWIP_OPEN_SRC \
|
||||
-DPBUF_RSV_FOR_WLAN \
|
||||
-DEBUF_LWIP \
|
||||
-DUSE_OPTIMIZE_PRINTF \
|
||||
-DMBEDTLS_USER_CONFIG_FILE=\"user_mbedtls.h\" \
|
||||
CONFIGURATION_DEFINES += -DLWIP_OPEN_SRC
|
||||
|
||||
DEFINES += \
|
||||
$(UNIVERSAL_TARGET_DEFINES) \
|
||||
DEFINES += \
|
||||
$(UNIVERSAL_TARGET_DEFINES) \
|
||||
$(CONFIGURATION_DEFINES)
|
||||
|
||||
DDEFINES += \
|
||||
$(UNIVERSAL_TARGET_DEFINES) \
|
||||
DDEFINES += \
|
||||
$(UNIVERSAL_TARGET_DEFINES) \
|
||||
$(CONFIGURATION_DEFINES)
|
||||
|
||||
|
||||
#############################################################
|
||||
# Recursion Magic - Don't touch this!!
|
||||
#
|
||||
|
@ -165,10 +152,10 @@ DDEFINES += \
|
|||
#
|
||||
# Required for each makefile to inherit from the parent
|
||||
#
|
||||
|
||||
INCLUDES := $(INCLUDES) -I $(PDIR)include
|
||||
INCLUDES += -I ./
|
||||
INCLUDES := -I $(PDIR)libc -I $(PDIR)lua -I $(PDIR)platform \
|
||||
$(INCLUDES) -I $(PDIR) -I $(PDIR)include
|
||||
PDIR := ../$(PDIR)
|
||||
|
||||
sinclude $(PDIR)Makefile
|
||||
|
||||
.PHONY: FORCE
|
||||
|
|
|
@ -36,10 +36,6 @@ endif
|
|||
# Required for each makefile to inherit from the parent
|
||||
#
|
||||
|
||||
INCLUDES := $(INCLUDES) -I $(PDIR)include
|
||||
INCLUDES += -I ./
|
||||
INCLUDES += -I ../libc
|
||||
INCLUDES += -I ../lua
|
||||
PDIR := ../$(PDIR)
|
||||
sinclude $(PDIR)Makefile
|
||||
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "user_config.h"
|
||||
#include "c_stdio.h"
|
||||
#include "c_string.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include "coap.h"
|
||||
#include "uri.h"
|
||||
|
||||
|
@ -10,12 +10,12 @@ extern const coap_endpoint_t endpoints[];
|
|||
#ifdef COAP_DEBUG
|
||||
void coap_dumpHeader(coap_header_t *hdr)
|
||||
{
|
||||
c_printf("Header:\n");
|
||||
c_printf(" ver 0x%02X\n", hdr->ver);
|
||||
c_printf(" t 0x%02X\n", hdr->ver);
|
||||
c_printf(" tkl 0x%02X\n", hdr->tkl);
|
||||
c_printf(" code 0x%02X\n", hdr->code);
|
||||
c_printf(" id 0x%02X%02X\n", hdr->id[0], hdr->id[1]);
|
||||
printf("Header:\n");
|
||||
printf(" ver 0x%02X\n", hdr->ver);
|
||||
printf(" t 0x%02X\n", hdr->ver);
|
||||
printf(" tkl 0x%02X\n", hdr->tkl);
|
||||
printf(" code 0x%02X\n", hdr->code);
|
||||
printf(" id 0x%02X%02X\n", hdr->id[0], hdr->id[1]);
|
||||
}
|
||||
|
||||
void coap_dump(const uint8_t *buf, size_t buflen, bool bare)
|
||||
|
@ -23,14 +23,14 @@ void coap_dump(const uint8_t *buf, size_t buflen, bool bare)
|
|||
if (bare)
|
||||
{
|
||||
while(buflen--)
|
||||
c_printf("%02X%s", *buf++, (buflen > 0) ? " " : "");
|
||||
printf("%02X%s", *buf++, (buflen > 0) ? " " : "");
|
||||
}
|
||||
else
|
||||
{
|
||||
c_printf("Dump: ");
|
||||
printf("Dump: ");
|
||||
while(buflen--)
|
||||
c_printf("%02X%s", *buf++, (buflen > 0) ? " " : "");
|
||||
c_printf("\n");
|
||||
printf("%02X%s", *buf++, (buflen > 0) ? " " : "");
|
||||
printf("\n");
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
@ -100,7 +100,7 @@ int coap_buildToken(const coap_buffer_t *tokbuf, const coap_header_t *hdr, uint8
|
|||
return COAP_ERR_UNSUPPORTED;
|
||||
|
||||
if (hdr->tkl > 0)
|
||||
c_memcpy(p, tokbuf->p, hdr->tkl);
|
||||
memcpy(p, tokbuf->p, hdr->tkl);
|
||||
|
||||
// http://tools.ietf.org/html/rfc7252#section-3.1
|
||||
// inject options
|
||||
|
@ -260,12 +260,12 @@ int coap_buildOptionHeader(uint32_t optDelta, size_t length, uint8_t *buf, size_
|
|||
void coap_dumpOptions(coap_option_t *opts, size_t numopt)
|
||||
{
|
||||
size_t i;
|
||||
c_printf(" Options:\n");
|
||||
printf(" Options:\n");
|
||||
for (i=0;i<numopt;i++)
|
||||
{
|
||||
c_printf(" 0x%02X [ ", opts[i].num);
|
||||
printf(" 0x%02X [ ", opts[i].num);
|
||||
coap_dump(opts[i].buf.p, opts[i].buf.len, true);
|
||||
c_printf(" ]\n");
|
||||
printf(" ]\n");
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -273,9 +273,9 @@ void coap_dumpPacket(coap_packet_t *pkt)
|
|||
{
|
||||
coap_dumpHeader(&pkt->hdr);
|
||||
coap_dumpOptions(pkt->opts, pkt->numopts);
|
||||
c_printf("Payload: ");
|
||||
printf("Payload: ");
|
||||
coap_dump(pkt->payload.p, pkt->payload.len, true);
|
||||
c_printf("\n");
|
||||
printf("\n");
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -325,7 +325,7 @@ int coap_buffer_to_string(char *strbuf, size_t strbuflen, const coap_buffer_t *b
|
|||
{
|
||||
if (buf->len+1 > strbuflen)
|
||||
return COAP_ERR_BUFFER_TOO_SMALL;
|
||||
c_memcpy(strbuf, buf->p, buf->len);
|
||||
memcpy(strbuf, buf->p, buf->len);
|
||||
strbuf[buf->len] = 0;
|
||||
return 0;
|
||||
}
|
||||
|
@ -360,7 +360,7 @@ int coap_build(uint8_t *buf, size_t *buflen, const coap_packet_t *pkt)
|
|||
p += rc;
|
||||
left -= rc;
|
||||
|
||||
c_memcpy(p, pkt->opts[i].buf.p, pkt->opts[i].buf.len);
|
||||
memcpy(p, pkt->opts[i].buf.p, pkt->opts[i].buf.len);
|
||||
p += pkt->opts[i].buf.len;
|
||||
left -= pkt->opts[i].buf.len;
|
||||
running_delta = pkt->opts[i].num;
|
||||
|
@ -373,7 +373,7 @@ int coap_build(uint8_t *buf, size_t *buflen, const coap_packet_t *pkt)
|
|||
if (*buflen < 4 + 1 + pkt->payload.len + opts_len)
|
||||
return COAP_ERR_BUFFER_TOO_SMALL;
|
||||
buf[4 + opts_len] = 0xFF; // payload marker
|
||||
c_memcpy(buf+5 + opts_len, pkt->payload.p, pkt->payload.len);
|
||||
memcpy(buf+5 + opts_len, pkt->payload.p, pkt->payload.len);
|
||||
*buflen = opts_len + 5 + pkt->payload.len;
|
||||
}
|
||||
else
|
||||
|
@ -471,7 +471,7 @@ int coap_make_request(coap_rw_buffer_t *scratch, coap_packet_t *pkt, coap_msgtyp
|
|||
|
||||
/* split arg into Uri-* options */
|
||||
// const char *addr = uri->host.s;
|
||||
// if(uri->host.length && (c_strlen(addr) != uri->host.length || c_memcmp(addr, uri->host.s, uri->host.length) != 0)){
|
||||
// if(uri->host.length && (strlen(addr) != uri->host.length || memcmp(addr, uri->host.s, uri->host.length) != 0)){
|
||||
if(uri->host.length){
|
||||
/* add Uri-Host */
|
||||
// addr is destination address
|
||||
|
@ -525,9 +525,9 @@ int coap_handle_req(coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_
|
|||
goto next;
|
||||
for (i=0;i<ep->path->count;i++)
|
||||
{
|
||||
if (opt[i].buf.len != c_strlen(ep->path->elems[i]))
|
||||
if (opt[i].buf.len != strlen(ep->path->elems[i]))
|
||||
goto next;
|
||||
if (0 != c_memcmp(ep->path->elems[i], opt[i].buf.p, opt[i].buf.len))
|
||||
if (0 != memcmp(ep->path->elems[i], opt[i].buf.p, opt[i].buf.len))
|
||||
goto next;
|
||||
}
|
||||
// pre-path match!
|
||||
|
@ -551,5 +551,5 @@ void coap_setup(void)
|
|||
|
||||
int
|
||||
check_token(coap_packet_t *pkt) {
|
||||
return pkt->tok.len == the_token.len && c_memcmp(pkt->tok.p, the_token.p, the_token.len) == 0;
|
||||
return pkt->tok.len == the_token.len && memcmp(pkt->tok.p, the_token.p, the_token.len) == 0;
|
||||
}
|
||||
|
|
|
@ -5,8 +5,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "c_stdint.h"
|
||||
#include "c_stddef.h"
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include "lualib.h"
|
||||
#include "lauxlib.h"
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "user_config.h"
|
||||
#include "c_types.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#include "coap.h"
|
||||
#include "hash.h"
|
||||
|
|
|
@ -1,4 +1,4 @@
|
|||
#include "c_string.h"
|
||||
#include <string.h>
|
||||
#include "coap_io.h"
|
||||
#include "node.h"
|
||||
#include "espconn.h"
|
||||
|
@ -16,10 +16,10 @@ coap_tid_t coap_send(struct espconn *pesp_conn, coap_pdu_t *pdu) {
|
|||
espconn_sent(pesp_conn, (unsigned char *)(pdu->msg.p), pdu->msg.len);
|
||||
|
||||
if(pesp_conn->type == ESPCONN_TCP){
|
||||
c_memcpy(&ip, pesp_conn->proto.tcp->remote_ip, sizeof(ip));
|
||||
memcpy(&ip, pesp_conn->proto.tcp->remote_ip, sizeof(ip));
|
||||
port = pesp_conn->proto.tcp->remote_port;
|
||||
}else{
|
||||
c_memcpy(&ip, pesp_conn->proto.udp->remote_ip, sizeof(ip));
|
||||
memcpy(&ip, pesp_conn->proto.udp->remote_ip, sizeof(ip));
|
||||
port = pesp_conn->proto.udp->remote_port;
|
||||
}
|
||||
coap_transaction_id(ip, port, pdu->pkt, &id);
|
||||
|
|
|
@ -5,7 +5,6 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include "c_types.h"
|
||||
#include "lwip/ip_addr.h"
|
||||
#include "espconn.h"
|
||||
#include "pdu.h"
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "user_config.h"
|
||||
#include "c_types.h"
|
||||
#include "c_stdlib.h"
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "coap.h"
|
||||
|
||||
|
@ -51,7 +52,7 @@ size_t coap_server_respond(char *req, unsigned short reqlen, char *rsp, unsigned
|
|||
#endif
|
||||
}
|
||||
if(rsppkt.content.p){
|
||||
c_free(rsppkt.content.p);
|
||||
free(rsppkt.content.p);
|
||||
rsppkt.content.p = NULL;
|
||||
rsppkt.content.len = 0;
|
||||
}
|
||||
|
|
|
@ -1,6 +1,7 @@
|
|||
#include "node.h"
|
||||
#include "coap_timer.h"
|
||||
#include "os_type.h"
|
||||
#include "osapi.h"
|
||||
#include "pm/swtimer.h"
|
||||
|
||||
static os_timer_t coap_timer;
|
||||
|
|
|
@ -1,6 +1,6 @@
|
|||
#include "c_stdio.h"
|
||||
#include "c_string.h"
|
||||
#include "c_stdlib.h"
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "coap.h"
|
||||
|
||||
#include "lua.h"
|
||||
|
@ -21,14 +21,14 @@ void endpoint_setup(void)
|
|||
static const coap_endpoint_path_t path_well_known_core = {2, {".well-known", "core"}};
|
||||
static int handle_get_well_known_core(const coap_endpoint_t *ep, coap_rw_buffer_t *scratch, const coap_packet_t *inpkt, coap_packet_t *outpkt, uint8_t id_hi, uint8_t id_lo)
|
||||
{
|
||||
outpkt->content.p = (uint8_t *)c_zalloc(MAX_PAYLOAD_SIZE); // this should be free-ed when outpkt is built in coap_server_respond()
|
||||
outpkt->content.p = (uint8_t *)calloc(1,MAX_PAYLOAD_SIZE); // this should be free-ed when outpkt is built in coap_server_respond()
|
||||
if(outpkt->content.p == NULL){
|
||||
NODE_DBG("not enough memory\n");
|
||||
return COAP_ERR_BUFFER_TOO_SMALL;
|
||||
}
|
||||
outpkt->content.len = MAX_PAYLOAD_SIZE;
|
||||
build_well_known_rsp(outpkt->content.p, outpkt->content.len);
|
||||
return coap_make_response(scratch, outpkt, (const uint8_t *)outpkt->content.p, c_strlen(outpkt->content.p), id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CONTENT, COAP_CONTENTTYPE_APPLICATION_LINKFORMAT);
|
||||
return coap_make_response(scratch, outpkt, (const uint8_t *)outpkt->content.p, strlen(outpkt->content.p), id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CONTENT, COAP_CONTENTTYPE_APPLICATION_LINKFORMAT);
|
||||
}
|
||||
|
||||
static const coap_endpoint_path_t path_variable = {2, {"v1", "v"}};
|
||||
|
@ -49,17 +49,17 @@ static int handle_get_variable(const coap_endpoint_t *ep, coap_rw_buffer_t *scra
|
|||
{
|
||||
coap_luser_entry *h = ep->user_entry->next; // ->next: skip the first entry(head)
|
||||
while(NULL != h){
|
||||
if (opt[count-1].buf.len != c_strlen(h->name))
|
||||
if (opt[count-1].buf.len != strlen(h->name))
|
||||
{
|
||||
h = h->next;
|
||||
continue;
|
||||
}
|
||||
if (0 == c_memcmp(h->name, opt[count-1].buf.p, opt[count-1].buf.len))
|
||||
if (0 == memcmp(h->name, opt[count-1].buf.p, opt[count-1].buf.len))
|
||||
{
|
||||
NODE_DBG("/v1/v/");
|
||||
NODE_DBG((char *)h->name);
|
||||
NODE_DBG(" match.\n");
|
||||
if(c_strlen(h->name))
|
||||
if(strlen(h->name))
|
||||
{
|
||||
n = lua_gettop(L);
|
||||
lua_getglobal(L, h->name);
|
||||
|
@ -70,7 +70,7 @@ static int handle_get_variable(const coap_endpoint_t *ep, coap_rw_buffer_t *scra
|
|||
} else {
|
||||
const char *res = lua_tostring(L,-1);
|
||||
lua_settop(L, n);
|
||||
return coap_make_response(scratch, outpkt, (const uint8_t *)res, c_strlen(res), id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CONTENT, h->content_type);
|
||||
return coap_make_response(scratch, outpkt, (const uint8_t *)res, strlen(res), id_hi, id_lo, &inpkt->tok, COAP_RSPCODE_CONTENT, h->content_type);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -105,18 +105,18 @@ static int handle_post_function(const coap_endpoint_t *ep, coap_rw_buffer_t *scr
|
|||
{
|
||||
coap_luser_entry *h = ep->user_entry->next; // ->next: skip the first entry(head)
|
||||
while(NULL != h){
|
||||
if (opt[count-1].buf.len != c_strlen(h->name))
|
||||
if (opt[count-1].buf.len != strlen(h->name))
|
||||
{
|
||||
h = h->next;
|
||||
continue;
|
||||
}
|
||||
if (0 == c_memcmp(h->name, opt[count-1].buf.p, opt[count-1].buf.len))
|
||||
if (0 == memcmp(h->name, opt[count-1].buf.p, opt[count-1].buf.len))
|
||||
{
|
||||
NODE_DBG("/v1/f/");
|
||||
NODE_DBG((char *)h->name);
|
||||
NODE_DBG(" match.\n");
|
||||
|
||||
if(c_strlen(h->name))
|
||||
if(strlen(h->name))
|
||||
{
|
||||
n = lua_gettop(L);
|
||||
lua_getglobal(L, h->name);
|
||||
|
@ -173,7 +173,7 @@ static int handle_post_command(const coap_endpoint_t *ep, coap_rw_buffer_t *scra
|
|||
{
|
||||
char line[LUA_MAXINPUT];
|
||||
if (!coap_buffer_to_string(line, LUA_MAXINPUT, &inpkt->payload) &&
|
||||
lua_put_line(line, c_strlen(line))) {
|
||||
lua_put_line(line, strlen(line))) {
|
||||
NODE_DBG("\nResult(if any):\n");
|
||||
system_os_post (LUA_TASK_PRIO, LUA_PROCESS_LINE_SIG, 0);
|
||||
}
|
||||
|
@ -211,7 +211,7 @@ void build_well_known_rsp(char *rsp, uint16_t rsplen)
|
|||
int i;
|
||||
uint16_t len = rsplen;
|
||||
|
||||
c_memset(rsp, 0, len);
|
||||
memset(rsp, 0, len);
|
||||
|
||||
len--; // Null-terminated string
|
||||
|
||||
|
@ -222,57 +222,57 @@ void build_well_known_rsp(char *rsp, uint16_t rsplen)
|
|||
continue;
|
||||
}
|
||||
if (NULL == ep->user_entry){
|
||||
if (0 < c_strlen(rsp)) {
|
||||
c_strncat(rsp, ",", len);
|
||||
if (0 < strlen(rsp)) {
|
||||
strncat(rsp, ",", len);
|
||||
len--;
|
||||
}
|
||||
|
||||
c_strncat(rsp, "<", len);
|
||||
strncat(rsp, "<", len);
|
||||
len--;
|
||||
|
||||
for (i = 0; i < ep->path->count; i++) {
|
||||
c_strncat(rsp, "/", len);
|
||||
strncat(rsp, "/", len);
|
||||
len--;
|
||||
|
||||
c_strncat(rsp, ep->path->elems[i], len);
|
||||
len -= c_strlen(ep->path->elems[i]);
|
||||
strncat(rsp, ep->path->elems[i], len);
|
||||
len -= strlen(ep->path->elems[i]);
|
||||
}
|
||||
|
||||
c_strncat(rsp, ">;", len);
|
||||
strncat(rsp, ">;", len);
|
||||
len -= 2;
|
||||
|
||||
c_strncat(rsp, ep->core_attr, len);
|
||||
len -= c_strlen(ep->core_attr);
|
||||
strncat(rsp, ep->core_attr, len);
|
||||
len -= strlen(ep->core_attr);
|
||||
} else {
|
||||
coap_luser_entry *h = ep->user_entry->next; // ->next: skip the first entry(head)
|
||||
while(NULL != h){
|
||||
if (0 < c_strlen(rsp)) {
|
||||
c_strncat(rsp, ",", len);
|
||||
if (0 < strlen(rsp)) {
|
||||
strncat(rsp, ",", len);
|
||||
len--;
|
||||
}
|
||||
|
||||
c_strncat(rsp, "<", len);
|
||||
strncat(rsp, "<", len);
|
||||
len--;
|
||||
|
||||
for (i = 0; i < ep->path->count; i++) {
|
||||
c_strncat(rsp, "/", len);
|
||||
strncat(rsp, "/", len);
|
||||
len--;
|
||||
|
||||
c_strncat(rsp, ep->path->elems[i], len);
|
||||
len -= c_strlen(ep->path->elems[i]);
|
||||
strncat(rsp, ep->path->elems[i], len);
|
||||
len -= strlen(ep->path->elems[i]);
|
||||
}
|
||||
|
||||
c_strncat(rsp, "/", len);
|
||||
strncat(rsp, "/", len);
|
||||
len--;
|
||||
|
||||
c_strncat(rsp, h->name, len);
|
||||
len -= c_strlen(h->name);
|
||||
strncat(rsp, h->name, len);
|
||||
len -= strlen(h->name);
|
||||
|
||||
c_strncat(rsp, ">;", len);
|
||||
strncat(rsp, ">;", len);
|
||||
len -= 2;
|
||||
|
||||
c_strncat(rsp, ep->core_attr, len);
|
||||
len -= c_strlen(ep->core_attr);
|
||||
strncat(rsp, ep->core_attr, len);
|
||||
len -= strlen(ep->core_attr);
|
||||
|
||||
h = h->next;
|
||||
}
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
#include "hash.h"
|
||||
#include "c_string.h"
|
||||
#include <string.h>
|
||||
/* Caution: When changing this, update COAP_DEFAULT_WKC_HASHKEY
|
||||
* accordingly (see int coap_hash_path());
|
||||
*/
|
||||
|
@ -20,7 +20,7 @@ void coap_hash(const unsigned char *s, unsigned int len, coap_key_t h) {
|
|||
|
||||
void coap_transaction_id(const uint32_t ip, const uint32_t port, const coap_packet_t *pkt, coap_tid_t *id) {
|
||||
coap_key_t h;
|
||||
c_memset(h, 0, sizeof(coap_key_t));
|
||||
memset(h, 0, sizeof(coap_key_t));
|
||||
|
||||
/* Compare the transport address. */
|
||||
coap_hash((const unsigned char *)&(port), sizeof(port), h);
|
||||
|
|
|
@ -1,14 +1,14 @@
|
|||
#include "c_string.h"
|
||||
#include "c_stdlib.h"
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "node.h"
|
||||
|
||||
static inline coap_queue_t *
|
||||
coap_malloc_node(void) {
|
||||
return (coap_queue_t *)c_zalloc(sizeof(coap_queue_t));
|
||||
return (coap_queue_t *)calloc(1,sizeof(coap_queue_t));
|
||||
}
|
||||
|
||||
void coap_free_node(coap_queue_t *node) {
|
||||
c_free(node);
|
||||
free(node);
|
||||
}
|
||||
|
||||
int coap_insert_node(coap_queue_t **queue, coap_queue_t *node) {
|
||||
|
@ -73,7 +73,7 @@ coap_queue_t * coap_new_node(void) {
|
|||
return NULL;
|
||||
}
|
||||
|
||||
c_memset(node, 0, sizeof(*node));
|
||||
memset(node, 0, sizeof(*node));
|
||||
return node;
|
||||
}
|
||||
|
||||
|
|
|
@ -1,38 +1,38 @@
|
|||
#include "c_stdlib.h"
|
||||
#include <stdlib.h>
|
||||
#include "pdu.h"
|
||||
|
||||
coap_pdu_t * coap_new_pdu(void) {
|
||||
coap_pdu_t *pdu = NULL;
|
||||
pdu = (coap_pdu_t *)c_zalloc(sizeof(coap_pdu_t));
|
||||
pdu = (coap_pdu_t *)calloc(1,sizeof(coap_pdu_t));
|
||||
if(!pdu){
|
||||
NODE_DBG("coap_new_pdu malloc error.\n");
|
||||
return NULL;
|
||||
}
|
||||
|
||||
pdu->scratch.p = (uint8_t *)c_zalloc(MAX_REQ_SCRATCH_SIZE);
|
||||
pdu->scratch.p = (uint8_t *)calloc(1,MAX_REQ_SCRATCH_SIZE);
|
||||
if(!pdu->scratch.p){
|
||||
NODE_DBG("coap_new_pdu malloc error.\n");
|
||||
c_free(pdu);
|
||||
free(pdu);
|
||||
return NULL;
|
||||
}
|
||||
pdu->scratch.len = MAX_REQ_SCRATCH_SIZE;
|
||||
|
||||
pdu->pkt = (coap_packet_t *)c_zalloc(sizeof(coap_packet_t));
|
||||
pdu->pkt = (coap_packet_t *)calloc(1,sizeof(coap_packet_t));
|
||||
if(!pdu->pkt){
|
||||
NODE_DBG("coap_new_pdu malloc error.\n");
|
||||
c_free(pdu->scratch.p);
|
||||
c_free(pdu);
|
||||
free(pdu->scratch.p);
|
||||
free(pdu);
|
||||
return NULL;
|
||||
}
|
||||
pdu->pkt->content.p = NULL;
|
||||
pdu->pkt->content.len = 0;
|
||||
|
||||
pdu->msg.p = (uint8_t *)c_zalloc(MAX_REQUEST_SIZE+1); // +1 for string '\0'
|
||||
pdu->msg.p = (uint8_t *)calloc(1,MAX_REQUEST_SIZE+1); // +1 for string '\0'
|
||||
if(!pdu->msg.p){
|
||||
NODE_DBG("coap_new_pdu malloc error.\n");
|
||||
c_free(pdu->pkt);
|
||||
c_free(pdu->scratch.p);
|
||||
c_free(pdu);
|
||||
free(pdu->pkt);
|
||||
free(pdu->scratch.p);
|
||||
free(pdu);
|
||||
return NULL;
|
||||
}
|
||||
pdu->msg.len = MAX_REQUEST_SIZE;
|
||||
|
@ -44,22 +44,22 @@ void coap_delete_pdu(coap_pdu_t *pdu){
|
|||
return;
|
||||
|
||||
if(pdu->scratch.p){
|
||||
c_free(pdu->scratch.p);
|
||||
free(pdu->scratch.p);
|
||||
pdu->scratch.p = NULL;
|
||||
pdu->scratch.len = 0;
|
||||
}
|
||||
|
||||
if(pdu->pkt){
|
||||
c_free(pdu->pkt);
|
||||
free(pdu->pkt);
|
||||
pdu->pkt = NULL;
|
||||
}
|
||||
|
||||
if(pdu->msg.p){
|
||||
c_free(pdu->msg.p);
|
||||
free(pdu->msg.p);
|
||||
pdu->msg.p = NULL;
|
||||
pdu->msg.len = 0;
|
||||
}
|
||||
|
||||
c_free(pdu);
|
||||
free(pdu);
|
||||
pdu = NULL;
|
||||
}
|
||||
|
|
|
@ -6,23 +6,23 @@
|
|||
* README for terms of use.
|
||||
*/
|
||||
|
||||
#include "c_stdlib.h"
|
||||
#include "c_types.h"
|
||||
#include <stdlib.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "str.h"
|
||||
|
||||
str * coap_new_string(size_t size) {
|
||||
str *s = (str *)c_malloc(sizeof(str) + size + 1);
|
||||
str *s = (str *)malloc(sizeof(str) + size + 1);
|
||||
if ( !s ) {
|
||||
return NULL;
|
||||
}
|
||||
|
||||
c_memset(s, 0, sizeof(str));
|
||||
memset(s, 0, sizeof(str));
|
||||
s->s = ((unsigned char *)s) + sizeof(str);
|
||||
return s;
|
||||
}
|
||||
|
||||
void coap_delete_string(str *s) {
|
||||
c_free(s);
|
||||
free(s);
|
||||
}
|
||||
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#ifndef _COAP_STR_H_
|
||||
#define _COAP_STR_H_
|
||||
|
||||
#include "c_string.h"
|
||||
#include <string.h>
|
||||
|
||||
typedef struct {
|
||||
size_t length; /* length of string */
|
||||
|
|
|
@ -1,10 +1,10 @@
|
|||
/* uri.c -- helper functions for URI treatment
|
||||
*/
|
||||
|
||||
#include "c_stdio.h"
|
||||
#include "c_stdlib.h"
|
||||
#include "c_string.h"
|
||||
#include "c_ctype.h"
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
#include "coap.h"
|
||||
#include "uri.h"
|
||||
|
@ -43,7 +43,7 @@ int coap_split_uri(unsigned char *str_var, size_t len, coap_uri_t *uri) {
|
|||
if (!str_var || !uri)
|
||||
return -1;
|
||||
|
||||
c_memset(uri, 0, sizeof(coap_uri_t));
|
||||
memset(uri, 0, sizeof(coap_uri_t));
|
||||
uri->port = COAP_DEFAULT_PORT;
|
||||
|
||||
/* search for scheme */
|
||||
|
@ -394,16 +394,16 @@ int coap_split_query(coap_rw_buffer_t *scratch, coap_packet_t *pkt, const unsign
|
|||
coap_uri_t * coap_new_uri(const unsigned char *uri, unsigned int length) {
|
||||
unsigned char *result;
|
||||
|
||||
result = (unsigned char *)c_malloc(length + 1 + sizeof(coap_uri_t));
|
||||
result = (unsigned char *)malloc(length + 1 + sizeof(coap_uri_t));
|
||||
|
||||
if (!result)
|
||||
return NULL;
|
||||
|
||||
c_memcpy(URI_DATA(result), uri, length);
|
||||
memcpy(URI_DATA(result), uri, length);
|
||||
URI_DATA(result)[length] = '\0'; /* make it zero-terminated */
|
||||
|
||||
if (coap_split_uri(URI_DATA(result), length, (coap_uri_t *)result) < 0) {
|
||||
c_free(result);
|
||||
free(result);
|
||||
return NULL;
|
||||
}
|
||||
return (coap_uri_t *)result;
|
||||
|
|
|
@ -38,10 +38,6 @@ STD_CFLAGS=-std=gnu11 -Wimplicit
|
|||
# Required for each makefile to inherit from the parent
|
||||
#
|
||||
|
||||
INCLUDES := $(INCLUDES) -I $(PDIR)include
|
||||
INCLUDES += -I ./
|
||||
INCLUDES += -I ../libc
|
||||
INCLUDES += -I ../platform
|
||||
PDIR := ../$(PDIR)
|
||||
sinclude $(PDIR)Makefile
|
||||
|
||||
|
|
|
@ -34,7 +34,8 @@
|
|||
#include "osapi.h"
|
||||
#include "mem.h"
|
||||
#include <string.h>
|
||||
#include <c_errno.h>
|
||||
#include <strings.h>
|
||||
#include <errno.h>
|
||||
|
||||
#ifdef MD2_ENABLE
|
||||
#include "ssl/ssl_crypto.h"
|
||||
|
|
|
@ -1,12 +1,13 @@
|
|||
#ifndef _CRYPTO_DIGESTS_H_
|
||||
#define _CRYPTO_DIGESTS_H_
|
||||
|
||||
#include <c_types.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
typedef void (*create_ctx_fn)(void *ctx);
|
||||
typedef void (*update_ctx_fn)(void *ctx, const uint8_t *msg, int len);
|
||||
typedef void (*finalize_ctx_fn)(uint8_t *digest, void *ctx);
|
||||
typedef sint32_t ( *read_fn )(int fd, void *ptr, size_t len);
|
||||
typedef int32_t ( *read_fn )(int fd, void *ptr, size_t len);
|
||||
|
||||
/**
|
||||
* Description of a message digest mechanism.
|
||||
|
|
|
@ -33,7 +33,8 @@
|
|||
|
||||
#include "mech.h"
|
||||
#include "sdk-aes.h"
|
||||
#include "c_string.h"
|
||||
#include <string.h>
|
||||
#include <strings.h>
|
||||
|
||||
/* ----- AES ---------------------------------------------------------- */
|
||||
|
||||
|
@ -58,7 +59,7 @@ static bool do_aes (crypto_op_t *co, bool with_cbc)
|
|||
|
||||
char iv[AES_BLOCKSIZE] = { 0 };
|
||||
if (with_cbc && co->ivlen)
|
||||
c_memcpy (iv, co->iv, co->ivlen < AES_BLOCKSIZE ? co->ivlen : AES_BLOCKSIZE);
|
||||
memcpy (iv, co->iv, co->ivlen < AES_BLOCKSIZE ? co->ivlen : AES_BLOCKSIZE);
|
||||
|
||||
const char *src = co->data;
|
||||
char *dst = co->out;
|
||||
|
@ -68,7 +69,7 @@ static bool do_aes (crypto_op_t *co, bool with_cbc)
|
|||
{
|
||||
char block[AES_BLOCKSIZE] = { 0 };
|
||||
size_t n = left > AES_BLOCKSIZE ? AES_BLOCKSIZE : left;
|
||||
c_memcpy (block, src, n);
|
||||
memcpy (block, src, n);
|
||||
|
||||
if (with_cbc && co->op == OP_ENCRYPT)
|
||||
{
|
||||
|
|
|
@ -1,7 +1,9 @@
|
|||
#ifndef _MECH_H_
|
||||
#define _MECH_H_
|
||||
|
||||
#include "c_types.h"
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
typedef struct
|
||||
{
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#ifndef __SHA2_H__
|
||||
#define __SHA2_H__
|
||||
|
||||
#include <c_types.h>
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
/**************************************************************************
|
||||
* SHA256/384/512 declarations
|
||||
|
|
|
@ -37,13 +37,6 @@ endif
|
|||
# Required for each makefile to inherit from the parent
|
||||
#
|
||||
|
||||
INCLUDES := $(INCLUDES) -I $(PDIR)include
|
||||
INCLUDES += -I ./
|
||||
INCLUDES += -I ./include
|
||||
INCLUDES += -I ../include
|
||||
INCLUDES += -I ../../include
|
||||
INCLUDES += -I ../libc
|
||||
INCLUDES += -I ../platform
|
||||
PDIR := ../$(PDIR)
|
||||
sinclude $(PDIR)Makefile
|
||||
|
||||
|
|
|
@ -29,7 +29,7 @@
|
|||
|
||||
#include "user_interface.h"
|
||||
#include "platform.h"
|
||||
#include "c_stdio.h"
|
||||
#include <stdio.h>
|
||||
#include "dht.h"
|
||||
|
||||
#ifndef LOW
|
||||
|
|
|
@ -17,7 +17,7 @@
|
|||
// #else
|
||||
// #include <Arduino.h>
|
||||
// #endif
|
||||
#include "c_types.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#define DHT_LIB_VERSION "0.1.14"
|
||||
|
||||
|
@ -67,4 +67,4 @@ double dht_getTemperature(void);
|
|||
#endif
|
||||
//
|
||||
// END OF FILE
|
||||
//
|
||||
//
|
||||
|
|
|
@ -38,9 +38,6 @@ STD_CFLAGS=-std=gnu11 -Wimplicit
|
|||
# Required for each makefile to inherit from the parent
|
||||
#
|
||||
|
||||
INCLUDES := $(INCLUDES) -I $(PDIR)include
|
||||
INCLUDES += -I ./
|
||||
INCLUDES += -I ../platform
|
||||
PDIR := ../$(PDIR)
|
||||
sinclude $(PDIR)Makefile
|
||||
|
||||
|
|
|
@ -1,20 +1,421 @@
|
|||
/******************************************************************************
|
||||
* Copyright 2013-2014 Espressif Systems (Wuxi)
|
||||
/*
|
||||
* ESPRESSIF MIT License
|
||||
*
|
||||
* FileName: i2c_master.c
|
||||
* Copyright (c) 2016 <ESPRESSIF SYSTEMS (SHANGHAI) PTE LTD>
|
||||
*
|
||||
* Description: i2c master API
|
||||
* Permission is hereby granted for use on ESPRESSIF SYSTEMS ESP8266 only, in which case,
|
||||
* it is 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:
|
||||
*
|
||||
* Modification history:
|
||||
* 2014/3/12, v1.0 create this file.
|
||||
*******************************************************************************/
|
||||
* 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.
|
||||
*
|
||||
*
|
||||
* Rework of original driver: Natalia Sorokina <sonaux@gmail.com>, 2018
|
||||
*/
|
||||
|
||||
#include <stdlib.h>
|
||||
#include "ets_sys.h"
|
||||
#include "osapi.h"
|
||||
#include "gpio.h"
|
||||
#include "user_interface.h"
|
||||
|
||||
#include "cpu_esp8266.h"
|
||||
#include "pin_map.h"
|
||||
|
||||
#include "user_config.h"
|
||||
|
||||
#include "driver/i2c_master.h"
|
||||
|
||||
#include "pin_map.h"
|
||||
|
||||
#ifndef I2C_MASTER_OLD_VERSION
|
||||
/******************************************************************************
|
||||
* NEW driver
|
||||
* Enabled if I2C_MASTER_OLD_VERSION is not defined in user_config.h
|
||||
*******************************************************************************/
|
||||
// Supports multiple i2c buses
|
||||
// I2C speed in range 25kHz - 550kHz (25kHz - 1MHz if CPU at 160MHz)
|
||||
// If GPIO16 is used as SCL then speed is limited to 25kHz - 400kHz
|
||||
// Speed is defined for every bus separately
|
||||
|
||||
// enable use GPIO16 (D0) pin as SCL line
|
||||
#ifdef I2C_MASTER_GPIO16_ENABLE
|
||||
#define IS_PIN16(n) ((n)==16)
|
||||
// CPU_CYCLES_BETWEEN_DELAYS describes how much cpu cycles code runs
|
||||
// between i2c_master_setDC() calls if delay is zero and i2c_master_set_DC_delay()
|
||||
// is not being called. This is not exact value, but proportional with length of code.
|
||||
// Increasing the value results in less delay and faster i2c clock speed.
|
||||
#define CPU_CYCLES_BETWEEN_DELAYS 80
|
||||
// CPU_CYCLES_GPIO16 is added to CPU_CYCLES_BETWEEN_DELAYS,
|
||||
// as RTC-related IO takes much more time than standard GPIOs.
|
||||
// Increasing the value results in less delay and faster i2c clock speed for GPIO16.
|
||||
#define CPU_CYCLES_GPIO16 90
|
||||
|
||||
#else
|
||||
// If GPIO16 support is not enabled, remove GPIO16-related code during compile
|
||||
// and change timing constants.
|
||||
#define IS_PIN16(n) (0)
|
||||
#define CPU_CYCLES_BETWEEN_DELAYS 74
|
||||
#endif //I2C_MASTER_GPIO16_ENABLE
|
||||
|
||||
#define MIN_SPEED 25000
|
||||
#define MAX_NUMBER_OF_I2C NUM_I2C
|
||||
|
||||
typedef struct {
|
||||
uint8 last_SDA;
|
||||
uint8 last_SCL;
|
||||
uint8 pin_SDA;
|
||||
uint8 pin_SCL;
|
||||
uint32 pin_SDA_SCL_mask;
|
||||
uint32 pin_SDA_mask;
|
||||
uint32 pin_SCL_mask;
|
||||
uint32 speed;
|
||||
sint16 cycles_delay;
|
||||
} i2c_master_state_t;
|
||||
static i2c_master_state_t *i2c[MAX_NUMBER_OF_I2C];
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_set_DC_delay
|
||||
* Description : Internal used function - calculate delay for i2c_master_setDC
|
||||
* Parameters : bus id
|
||||
* Returns : NONE
|
||||
*******************************************************************************/
|
||||
LOCAL void ICACHE_FLASH_ATTR
|
||||
i2c_master_set_DC_delay(uint16 id)
|
||||
{
|
||||
// [cpu cycles per half SCL clock period] - [cpu cycles that code takes to run]
|
||||
i2c[id]->cycles_delay = system_get_cpu_freq() * 500000 / i2c[id]->speed - CPU_CYCLES_BETWEEN_DELAYS;
|
||||
#ifdef I2C_MASTER_GPIO16_ENABLE
|
||||
if(IS_PIN16(i2c[id]->pin_SCL)){ //if GPIO16
|
||||
i2c[id]->cycles_delay -= CPU_CYCLES_GPIO16; //decrease delay
|
||||
}
|
||||
#endif //I2C_MASTER_GPIO16_ENABLE
|
||||
if(i2c[id]->cycles_delay < 0){
|
||||
i2c[id]->cycles_delay = 0;
|
||||
}
|
||||
}
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_wait_cpu_cycles
|
||||
* Description : Internal used function - wait for given count of cpu cycles
|
||||
* Parameters : sint16 cycles_delay
|
||||
* Returns : NONE
|
||||
*******************************************************************************/
|
||||
static inline void i2c_master_wait_cpu_cycles(sint16 cycles_delay)
|
||||
{
|
||||
uint32 cycles_start;
|
||||
uint32 cycles_curr;
|
||||
// uses special 'ccount' register which is increased every CPU cycle
|
||||
// to make precise delay
|
||||
asm volatile("rsr %0, ccount":"=a"(cycles_start));
|
||||
do{
|
||||
asm volatile("rsr %0, ccount":"=a"(cycles_curr));
|
||||
} while (cycles_curr - cycles_start < cycles_delay);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_wait_gpio_SCL_high
|
||||
* Description : Internal used function - wait until SCL line in a high state
|
||||
(slave device may hold SCL line low until it is ready to proceed)
|
||||
* Parameters : bus id
|
||||
* Returns : NONE
|
||||
*******************************************************************************/
|
||||
static inline void i2c_master_wait_gpio_SCL_high(uint16 id)
|
||||
{
|
||||
// retrieves bitmask of all GPIOs from memory-mapped gpio register and exits if SCL bit is set
|
||||
// equivalent, but slow variant:
|
||||
// while(!(READ_PERI_REG(PERIPHS_GPIO_BASEADDR + GPIO_IN_ADDRESS) & i2c[id]->pin_SCL_mask)) {};
|
||||
// even slower: while (!(gpio_input_get() & i2c[id]->pin_SCL_mask)) {};
|
||||
asm volatile("l_wait:"
|
||||
"l16ui %0, %[gpio_in_addr], 0;" //read gpio state into register %0
|
||||
"memw;" //wait for read completion
|
||||
"bnall %0, %[gpio_SCL_mask], l_wait;" // test if SCL bit not set
|
||||
::[gpio_SCL_mask] "r" (i2c[id]->pin_SCL_mask),
|
||||
[gpio_in_addr] "r" (PERIPHS_GPIO_BASEADDR + GPIO_IN_ADDRESS)
|
||||
);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_setDC
|
||||
* Description : Internal used function -
|
||||
* set i2c SDA and SCL bit value for half clock cycle
|
||||
* Parameters : bus id, uint8 SDA, uint8 SCL
|
||||
* Returns : NONE
|
||||
*******************************************************************************/
|
||||
LOCAL void ICACHE_FLASH_ATTR
|
||||
i2c_master_setDC(uint16 id, uint8 SDA, uint8 SCL)
|
||||
{
|
||||
uint32 this_SDA_SCL_set_mask;
|
||||
uint32 this_SDA_SCL_clear_mask;
|
||||
i2c[id]->last_SDA = SDA;
|
||||
i2c[id]->last_SCL = SCL;
|
||||
|
||||
if(i2c[id]->cycles_delay > 0){
|
||||
i2c_master_wait_cpu_cycles(i2c[id]->cycles_delay);
|
||||
}
|
||||
if (IS_PIN16(i2c[id]->pin_SCL)){ //GPIO16 wired differently, it has it's own register address
|
||||
WRITE_PERI_REG(RTC_GPIO_OUT, SCL); // write SCL value
|
||||
if(1 == SDA){
|
||||
GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, i2c[id]->pin_SDA_mask); //SDA = 1
|
||||
}else{
|
||||
GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, i2c[id]->pin_SDA_mask); // SDA = 0
|
||||
}
|
||||
if(1 == SCL){ //clock stretching, GPIO16 version
|
||||
while(!(READ_PERI_REG(RTC_GPIO_IN_DATA) & 1)) {}; //read SCL value until SCL goes high
|
||||
}else{
|
||||
// dummy read operation and empty CPU cycles to maintain equal times for low and high state
|
||||
READ_PERI_REG(RTC_GPIO_IN_DATA) & 1; asm volatile("nop;nop;nop;nop;");
|
||||
}
|
||||
}
|
||||
else{
|
||||
this_SDA_SCL_set_mask = (SDA << i2c[id]->pin_SDA) | (SCL << i2c[id]->pin_SCL);
|
||||
this_SDA_SCL_clear_mask = i2c[id]->pin_SDA_SCL_mask ^ this_SDA_SCL_set_mask;
|
||||
GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, this_SDA_SCL_clear_mask);
|
||||
GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, this_SDA_SCL_set_mask);
|
||||
if(1 == SCL) { //clock stretching
|
||||
i2c_master_wait_gpio_SCL_high(id);
|
||||
}else{
|
||||
asm volatile("nop;nop;nop;"); // empty CPU cycles to maintain equal times for low and high state
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_getDC
|
||||
* Description : Internal used function -
|
||||
* get i2c SDA bit value
|
||||
* Parameters : bus id
|
||||
* Returns : uint8 - SDA bit value
|
||||
*******************************************************************************/
|
||||
static inline uint8 ICACHE_FLASH_ATTR
|
||||
i2c_master_getDC(uint16 id)
|
||||
{
|
||||
return (READ_PERI_REG(PERIPHS_GPIO_BASEADDR + GPIO_IN_ADDRESS) >> i2c[id]->pin_SDA) & 1;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_configured
|
||||
* Description : checks if i2c bus is configured
|
||||
* Parameters : bus id
|
||||
* Returns : boolean value, true if configured
|
||||
*******************************************************************************/
|
||||
bool ICACHE_FLASH_ATTR
|
||||
i2c_master_configured(uint16 id){
|
||||
return !(NULL == i2c[id]);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_init
|
||||
* Description : initialize I2C bus to enable i2c operations
|
||||
(reset state of all slave devices)
|
||||
* Parameters : bus id
|
||||
* Returns : NONE
|
||||
*******************************************************************************/
|
||||
void ICACHE_FLASH_ATTR
|
||||
i2c_master_init(uint16 id)
|
||||
{
|
||||
uint8 i;
|
||||
|
||||
i2c_master_setDC(id, 1, 0);
|
||||
|
||||
// when SCL = 0, toggle SDA to clear up
|
||||
i2c_master_setDC(id, 0, 0) ;
|
||||
i2c_master_setDC(id, 1, 0) ;
|
||||
|
||||
// set data_cnt to max value
|
||||
for (i = 0; i < 28; i++) {
|
||||
i2c_master_setDC(id, 1, 0);
|
||||
i2c_master_setDC(id, 1, 1);
|
||||
}
|
||||
|
||||
// reset all
|
||||
i2c_master_stop(id);
|
||||
return;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_setup
|
||||
* Description : Initializes and configures the driver on given bus ID
|
||||
* Parameters : bus id
|
||||
* Returns : configured speed
|
||||
*******************************************************************************/
|
||||
uint32 ICACHE_FLASH_ATTR
|
||||
i2c_master_setup(uint16 id, uint8 sda, uint8 scl, uint32 speed)
|
||||
{
|
||||
if(NULL == i2c[id]){
|
||||
i2c[id] = (i2c_master_state_t*) malloc(sizeof(i2c_master_state_t));
|
||||
}
|
||||
if(NULL == i2c[id]){ // if malloc failed
|
||||
return 0;
|
||||
}
|
||||
i2c[id]->last_SDA = 1; //default idle state
|
||||
i2c[id]->last_SCL = 1;
|
||||
i2c[id]->pin_SDA = pin_num[sda];
|
||||
i2c[id]->pin_SCL = pin_num[scl];
|
||||
i2c[id]->pin_SDA_mask = 1 << i2c[id]->pin_SDA;
|
||||
i2c[id]->pin_SCL_mask = 1 << i2c[id]->pin_SCL;
|
||||
i2c[id]->pin_SDA_SCL_mask = i2c[id]->pin_SDA_mask | i2c[id]->pin_SCL_mask;
|
||||
i2c[id]->speed = speed;
|
||||
i2c[id]->cycles_delay = 0;
|
||||
|
||||
if(i2c[id]->speed < MIN_SPEED){
|
||||
i2c[id]->speed = MIN_SPEED;
|
||||
}
|
||||
i2c_master_set_DC_delay(id); // recalibrate clock
|
||||
|
||||
ETS_GPIO_INTR_DISABLE(); //disable gpio interrupts
|
||||
|
||||
if (IS_PIN16(i2c[id]->pin_SCL)){ //if GPIO16
|
||||
CLEAR_PERI_REG_MASK(PAD_XPD_DCDC_CONF, 0x43); //disable all functions for XPD_DCDC
|
||||
SET_PERI_REG_MASK(PAD_XPD_DCDC_CONF, 0x1); // select function RTC_GPIO0 for pin XPD_DCDC
|
||||
CLEAR_PERI_REG_MASK(RTC_GPIO_CONF, 0x1); //mux configuration for out enable
|
||||
SET_PERI_REG_MASK(RTC_GPIO_ENABLE, 0x1); //out enable
|
||||
SET_PERI_REG_MASK(RTC_GPIO_OUT, 0x1); // set SCL high
|
||||
}
|
||||
else{
|
||||
PIN_FUNC_SELECT(pin_mux[scl], pin_func[scl]);
|
||||
SET_PERI_REG_MASK(PERIPHS_GPIO_BASEADDR + GPIO_PIN_ADDR(GPIO_ID_PIN(i2c[id]->pin_SCL)),
|
||||
GPIO_PIN_PAD_DRIVER_SET(GPIO_PAD_DRIVER_ENABLE)); //open drain
|
||||
gpio_output_set(i2c[id]->pin_SCL_mask, 0, i2c[id]->pin_SCL_mask, 0); //enable and set high
|
||||
}
|
||||
PIN_FUNC_SELECT(pin_mux[sda], pin_func[sda]);
|
||||
SET_PERI_REG_MASK(PERIPHS_GPIO_BASEADDR + GPIO_PIN_ADDR(GPIO_ID_PIN(i2c[id]->pin_SDA)),
|
||||
GPIO_PIN_PAD_DRIVER_SET(GPIO_PAD_DRIVER_ENABLE)); //open drain
|
||||
gpio_output_set(i2c[id]->pin_SDA_mask, 0, i2c[id]->pin_SDA_mask, 0); //enable and set high
|
||||
|
||||
ETS_GPIO_INTR_ENABLE(); //enable gpio interrupts
|
||||
|
||||
if (! (gpio_input_get() ^ i2c[id]->pin_SCL_mask)){ //SCL is in low state, bus failure
|
||||
return 0;
|
||||
}
|
||||
i2c_master_init(id);
|
||||
if (! (gpio_input_get() ^ i2c[id]->pin_SDA_mask)){ //SDA is in low state, bus failure
|
||||
return 0;
|
||||
}
|
||||
return i2c[id]->speed;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_start
|
||||
* Description : set i2c to send state
|
||||
* Parameters : bus id
|
||||
* Returns : NONE
|
||||
*******************************************************************************/
|
||||
void ICACHE_FLASH_ATTR
|
||||
i2c_master_start(uint16 id)
|
||||
{
|
||||
i2c_master_set_DC_delay(id); // recalibrate clock
|
||||
i2c_master_setDC(id, 1, i2c[id]->last_SCL);
|
||||
i2c_master_setDC(id, 1, 1);
|
||||
i2c_master_setDC(id, 0, 1);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_stop
|
||||
* Description : set i2c to stop sending state
|
||||
* Parameters : bus id
|
||||
* Returns : NONE
|
||||
*******************************************************************************/
|
||||
void ICACHE_FLASH_ATTR
|
||||
i2c_master_stop(uint16 id)
|
||||
{
|
||||
i2c_master_setDC(id, 0, i2c[id]->last_SCL);
|
||||
i2c_master_setDC(id, 0, 1);
|
||||
i2c_master_setDC(id, 1, 1);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_readByte
|
||||
* Description : read Byte from i2c bus
|
||||
* Parameters : bus id
|
||||
* Returns : uint8 - readed value
|
||||
*******************************************************************************/
|
||||
uint8 ICACHE_FLASH_ATTR
|
||||
i2c_master_readByte(uint16 id, sint16 ack)
|
||||
{
|
||||
uint8 retVal = 0;
|
||||
uint8 k;
|
||||
sint8 i;
|
||||
//invert and clamp ACK to 0/1, because ACK == 1 for i2c means SDA in low state
|
||||
uint8 ackLevel = (ack ? 0 : 1);
|
||||
|
||||
i2c_master_setDC(id, i2c[id]->last_SDA, 0);
|
||||
i2c_master_setDC(id, 1, 0);
|
||||
for (i = 7; i >= 0; i--) {
|
||||
i2c_master_setDC(id, 1, 1);
|
||||
k = i2c_master_getDC(id);
|
||||
i2c_master_setDC(id, 1, 0); // unnecessary in last iteration
|
||||
k <<= i;
|
||||
retVal |= k;
|
||||
}
|
||||
// set ACK
|
||||
i2c_master_setDC(id, ackLevel, 0);
|
||||
i2c_master_setDC(id, ackLevel, 1);
|
||||
i2c_master_setDC(id, 1, 0);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_writeByte
|
||||
* Description : write wrdata value(one byte) into i2c
|
||||
* Parameters : bus id, uint8 wrdata - write value
|
||||
* Returns : NONE
|
||||
*******************************************************************************/
|
||||
uint8 ICACHE_FLASH_ATTR
|
||||
i2c_master_writeByte(uint16 id, uint8 wrdata)
|
||||
{
|
||||
uint8 dat;
|
||||
sint8 i;
|
||||
uint8 retVal;
|
||||
|
||||
i2c_master_setDC(id, i2c[id]->last_SDA, 0);
|
||||
for (i = 7; i >= 0; i--) {
|
||||
dat = (wrdata >> i) & 1;
|
||||
i2c_master_setDC(id, dat, 0);
|
||||
i2c_master_setDC(id, dat, 1);
|
||||
}
|
||||
//get ACK
|
||||
i2c_master_setDC(id, 1, 0);
|
||||
i2c_master_setDC(id, 1, 1);
|
||||
retVal = i2c_master_getDC(id);
|
||||
i2c_master_setDC(id, 1, 0);
|
||||
return ! retVal;
|
||||
}
|
||||
|
||||
|
||||
|
||||
#else // if defined I2C_MASTER_OLD_VERSION
|
||||
/******************************************************************************
|
||||
* OLD driver
|
||||
* Enabled when I2C_MASTER_OLD_VERSION is defined in user_config.h
|
||||
*******************************************************************************/
|
||||
|
||||
#define I2C_MASTER_SDA_MUX (pin_mux[sda])
|
||||
#define I2C_MASTER_SCL_MUX (pin_mux[scl])
|
||||
#define I2C_MASTER_SDA_GPIO (pinSDA)
|
||||
#define I2C_MASTER_SCL_GPIO (pinSCL)
|
||||
#define I2C_MASTER_SDA_FUNC (pin_func[sda])
|
||||
#define I2C_MASTER_SCL_FUNC (pin_func[scl])
|
||||
#define I2C_MASTER_SDA_HIGH_SCL_HIGH() \
|
||||
gpio_output_set(1<<I2C_MASTER_SDA_GPIO | 1<<I2C_MASTER_SCL_GPIO, 0, 1<<I2C_MASTER_SDA_GPIO | 1<<I2C_MASTER_SCL_GPIO, 0)
|
||||
#define I2C_MASTER_SDA_HIGH_SCL_LOW() \
|
||||
gpio_output_set(1<<I2C_MASTER_SDA_GPIO, 1<<I2C_MASTER_SCL_GPIO, 1<<I2C_MASTER_SDA_GPIO | 1<<I2C_MASTER_SCL_GPIO, 0)
|
||||
#define I2C_MASTER_SDA_LOW_SCL_HIGH() \
|
||||
gpio_output_set(1<<I2C_MASTER_SCL_GPIO, 1<<I2C_MASTER_SDA_GPIO, 1<<I2C_MASTER_SDA_GPIO | 1<<I2C_MASTER_SCL_GPIO, 0)
|
||||
#define I2C_MASTER_SDA_LOW_SCL_LOW() \
|
||||
gpio_output_set(0, 1<<I2C_MASTER_SDA_GPIO | 1<<I2C_MASTER_SCL_GPIO, 1<<I2C_MASTER_SDA_GPIO | 1<<I2C_MASTER_SCL_GPIO, 0)
|
||||
#define i2c_master_wait os_delay_us
|
||||
#define I2C_MASTER_SPEED 100000
|
||||
#define I2C_MASTER_BUS_ID 0
|
||||
|
||||
LOCAL uint8 m_nLastSDA;
|
||||
LOCAL uint8 m_nLastSCL;
|
||||
|
@ -26,8 +427,7 @@ LOCAL uint8 pinSCL = 15;
|
|||
* FunctionName : i2c_master_setDC
|
||||
* Description : Internal used function -
|
||||
* set i2c SDA and SCL bit value for half clk cycle
|
||||
* Parameters : uint8 SDA
|
||||
* uint8 SCL
|
||||
* Parameters : uint8 SDA, uint8 SCL
|
||||
* Returns : NONE
|
||||
*******************************************************************************/
|
||||
LOCAL void ICACHE_FLASH_ATTR
|
||||
|
@ -49,11 +449,13 @@ i2c_master_setDC(uint8 SDA, uint8 SCL)
|
|||
} else {
|
||||
I2C_MASTER_SDA_HIGH_SCL_HIGH();
|
||||
}
|
||||
|
||||
if(1 == SCL) {
|
||||
do {
|
||||
sclLevel = GPIO_INPUT_GET(GPIO_ID_PIN(I2C_MASTER_SCL_GPIO));
|
||||
} while(sclLevel == 0);
|
||||
}
|
||||
i2c_master_wait(5);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
|
@ -64,7 +466,7 @@ i2c_master_setDC(uint8 SDA, uint8 SCL)
|
|||
* Returns : uint8 - SDA bit value
|
||||
*******************************************************************************/
|
||||
LOCAL uint8 ICACHE_FLASH_ATTR
|
||||
i2c_master_getDC(void)
|
||||
i2c_master_getDC()
|
||||
{
|
||||
uint8 sda_out;
|
||||
sda_out = GPIO_INPUT_GET(GPIO_ID_PIN(I2C_MASTER_SDA_GPIO));
|
||||
|
@ -74,53 +476,52 @@ i2c_master_getDC(void)
|
|||
/******************************************************************************
|
||||
* FunctionName : i2c_master_init
|
||||
* Description : initilize I2C bus to enable i2c operations
|
||||
* Parameters : NONE
|
||||
* Parameters : bus id
|
||||
* Returns : NONE
|
||||
*******************************************************************************/
|
||||
void ICACHE_FLASH_ATTR
|
||||
i2c_master_init(void)
|
||||
i2c_master_init(uint16 id)
|
||||
{
|
||||
uint8 i;
|
||||
|
||||
i2c_master_setDC(1, 0);
|
||||
i2c_master_wait(5);
|
||||
|
||||
// when SCL = 0, toggle SDA to clear up
|
||||
i2c_master_setDC(0, 0) ;
|
||||
i2c_master_wait(5);
|
||||
i2c_master_setDC(1, 0) ;
|
||||
i2c_master_wait(5);
|
||||
|
||||
// set data_cnt to max value
|
||||
for (i = 0; i < 28; i++) {
|
||||
i2c_master_setDC(1, 0);
|
||||
i2c_master_wait(5); // sda 1, scl 0
|
||||
i2c_master_setDC(1, 1);
|
||||
i2c_master_wait(5); // sda 1, scl 1
|
||||
}
|
||||
|
||||
// reset all
|
||||
i2c_master_stop();
|
||||
i2c_master_stop(I2C_MASTER_BUS_ID);
|
||||
return;
|
||||
}
|
||||
|
||||
uint8 i2c_master_get_pinSDA(){
|
||||
return pinSDA;
|
||||
}
|
||||
|
||||
uint8 i2c_master_get_pinSCL(){
|
||||
return pinSCL;
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_configured
|
||||
* Description : checks if i2c bus is configured
|
||||
* Parameters : bus id
|
||||
* Returns : boolean value, true if configured
|
||||
*******************************************************************************/
|
||||
bool ICACHE_FLASH_ATTR
|
||||
i2c_master_configured(uint16 id)
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_gpio_init
|
||||
* FunctionName : i2c_master_setup
|
||||
* Description : config SDA and SCL gpio to open-drain output mode,
|
||||
* mux and gpio num defined in i2c_master.h
|
||||
* Parameters : NONE
|
||||
* Returns : NONE
|
||||
* Parameters : bus id, uint8 sda, uint8 scl, uint32 speed
|
||||
* Returns : configured speed
|
||||
*******************************************************************************/
|
||||
void ICACHE_FLASH_ATTR
|
||||
i2c_master_gpio_init(uint8 sda, uint8 scl)
|
||||
uint32 ICACHE_FLASH_ATTR
|
||||
i2c_master_setup(uint16 id, uint8 sda, uint8 scl, uint32 speed)
|
||||
{
|
||||
pinSDA = pin_num[sda];
|
||||
pinSCL = pin_num[scl];
|
||||
|
@ -141,152 +542,61 @@ i2c_master_gpio_init(uint8 sda, uint8 scl)
|
|||
ETS_GPIO_INTR_ENABLE() ;
|
||||
// ETS_INTR_UNLOCK();
|
||||
|
||||
i2c_master_init();
|
||||
i2c_master_init(I2C_MASTER_BUS_ID);
|
||||
|
||||
return I2C_MASTER_SPEED;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_start
|
||||
* Description : set i2c to send state
|
||||
* Parameters : NONE
|
||||
* Parameters : bus id
|
||||
* Returns : NONE
|
||||
*******************************************************************************/
|
||||
void ICACHE_FLASH_ATTR
|
||||
i2c_master_start(void)
|
||||
i2c_master_start(uint16 id)
|
||||
{
|
||||
i2c_master_setDC(1, m_nLastSCL);
|
||||
i2c_master_wait(5);
|
||||
i2c_master_setDC(1, 1);
|
||||
i2c_master_wait(5); // sda 1, scl 1
|
||||
i2c_master_setDC(0, 1);
|
||||
i2c_master_wait(5); // sda 0, scl 1
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_stop
|
||||
* Description : set i2c to stop sending state
|
||||
* Parameters : NONE
|
||||
* Parameters : bus id
|
||||
* Returns : NONE
|
||||
*******************************************************************************/
|
||||
void ICACHE_FLASH_ATTR
|
||||
i2c_master_stop(void)
|
||||
i2c_master_stop(uint16 id)
|
||||
{
|
||||
i2c_master_wait(5);
|
||||
|
||||
i2c_master_setDC(0, m_nLastSCL);
|
||||
i2c_master_wait(5); // sda 0
|
||||
i2c_master_setDC(0, 1);
|
||||
i2c_master_wait(5); // sda 0, scl 1
|
||||
i2c_master_setDC(1, 1);
|
||||
i2c_master_wait(5); // sda 1, scl 1
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_setAck
|
||||
* Description : set ack to i2c bus as level value
|
||||
* Parameters : uint8 level - 0 or 1
|
||||
* Returns : NONE
|
||||
*******************************************************************************/
|
||||
void ICACHE_FLASH_ATTR
|
||||
i2c_master_setAck(uint8 level)
|
||||
{
|
||||
i2c_master_setDC(m_nLastSDA, 0);
|
||||
i2c_master_wait(5);
|
||||
i2c_master_setDC(level, 0);
|
||||
i2c_master_wait(5); // sda level, scl 0
|
||||
i2c_master_setDC(level, 1);
|
||||
i2c_master_wait(8); // sda level, scl 1
|
||||
i2c_master_setDC(level, 0);
|
||||
i2c_master_wait(5); // sda level, scl 0
|
||||
i2c_master_setDC(1, 0);
|
||||
i2c_master_wait(5);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_getAck
|
||||
* Description : confirm if peer send ack
|
||||
* Parameters : NONE
|
||||
* Returns : uint8 - ack value, 0 or 1
|
||||
*******************************************************************************/
|
||||
uint8 ICACHE_FLASH_ATTR
|
||||
i2c_master_getAck(void)
|
||||
{
|
||||
uint8 retVal;
|
||||
i2c_master_setDC(m_nLastSDA, 0);
|
||||
i2c_master_wait(5);
|
||||
i2c_master_setDC(1, 0);
|
||||
i2c_master_wait(5);
|
||||
i2c_master_setDC(1, 1);
|
||||
i2c_master_wait(5);
|
||||
|
||||
retVal = i2c_master_getDC();
|
||||
i2c_master_wait(5);
|
||||
i2c_master_setDC(1, 0);
|
||||
i2c_master_wait(5);
|
||||
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_checkAck
|
||||
* Description : get dev response
|
||||
* Parameters : NONE
|
||||
* Returns : true : get ack ; false : get nack
|
||||
*******************************************************************************/
|
||||
bool ICACHE_FLASH_ATTR
|
||||
i2c_master_checkAck(void)
|
||||
{
|
||||
if(i2c_master_getAck()){
|
||||
return FALSE;
|
||||
}else{
|
||||
return TRUE;
|
||||
}
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_send_ack
|
||||
* Description : response ack
|
||||
* Parameters : NONE
|
||||
* Returns : NONE
|
||||
*******************************************************************************/
|
||||
void ICACHE_FLASH_ATTR
|
||||
i2c_master_send_ack(void)
|
||||
{
|
||||
i2c_master_setAck(0x0);
|
||||
}
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_send_nack
|
||||
* Description : response nack
|
||||
* Parameters : NONE
|
||||
* Returns : NONE
|
||||
*******************************************************************************/
|
||||
void ICACHE_FLASH_ATTR
|
||||
i2c_master_send_nack(void)
|
||||
{
|
||||
i2c_master_setAck(0x1);
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_readByte
|
||||
* Description : read Byte from i2c bus
|
||||
* Parameters : NONE
|
||||
* Parameters : bus id
|
||||
* Returns : uint8 - readed value
|
||||
*******************************************************************************/
|
||||
uint8 ICACHE_FLASH_ATTR
|
||||
i2c_master_readByte(void)
|
||||
i2c_master_readByte(uint16 id, sint16 ack)
|
||||
{
|
||||
uint8 retVal = 0;
|
||||
uint8 k, i;
|
||||
uint8 ackLevel = (ack ? 0 : 1);
|
||||
|
||||
i2c_master_wait(5);
|
||||
i2c_master_setDC(m_nLastSDA, 0);
|
||||
i2c_master_wait(5); // sda 1, scl 0
|
||||
|
||||
for (i = 0; i < 8; i++) {
|
||||
i2c_master_wait(5);
|
||||
i2c_master_setDC(1, 0);
|
||||
i2c_master_wait(5); // sda 1, scl 0
|
||||
i2c_master_setDC(1, 1);
|
||||
i2c_master_wait(5); // sda 1, scl 1
|
||||
|
||||
k = i2c_master_getDC();
|
||||
i2c_master_wait(5);
|
||||
|
@ -300,40 +610,51 @@ i2c_master_readByte(void)
|
|||
}
|
||||
|
||||
i2c_master_setDC(1, 0);
|
||||
i2c_master_wait(5); // sda 1, scl 0
|
||||
|
||||
// set ACK
|
||||
i2c_master_setDC(m_nLastSDA, 0);
|
||||
i2c_master_setDC(ackLevel, 0);
|
||||
i2c_master_setDC(ackLevel, 1);
|
||||
i2c_master_wait(3);
|
||||
i2c_master_setDC(ackLevel, 0);
|
||||
i2c_master_setDC(1, 0);
|
||||
return retVal;
|
||||
}
|
||||
|
||||
/******************************************************************************
|
||||
* FunctionName : i2c_master_writeByte
|
||||
* Description : write wrdata value(one byte) into i2c
|
||||
* Parameters : uint8 wrdata - write value
|
||||
* Parameters : bus id, uint8 wrdata - write value
|
||||
* Returns : NONE
|
||||
*******************************************************************************/
|
||||
void ICACHE_FLASH_ATTR
|
||||
i2c_master_writeByte(uint8 wrdata)
|
||||
uint8 ICACHE_FLASH_ATTR
|
||||
i2c_master_writeByte(uint16 id, uint8 wrdata)
|
||||
{
|
||||
uint8 dat;
|
||||
sint8 i;
|
||||
uint8 retVal;
|
||||
|
||||
i2c_master_wait(5);
|
||||
|
||||
i2c_master_setDC(m_nLastSDA, 0);
|
||||
i2c_master_wait(5);
|
||||
|
||||
for (i = 7; i >= 0; i--) {
|
||||
dat = wrdata >> i;
|
||||
i2c_master_setDC(dat, 0);
|
||||
i2c_master_wait(5);
|
||||
i2c_master_setDC(dat, 1);
|
||||
i2c_master_wait(5);
|
||||
|
||||
if (i == 0) {
|
||||
i2c_master_wait(3); ////
|
||||
}
|
||||
|
||||
i2c_master_setDC(dat, 0);
|
||||
i2c_master_wait(5);
|
||||
}
|
||||
// get ACK
|
||||
i2c_master_setDC(m_nLastSDA, 0);
|
||||
i2c_master_setDC(1, 0);
|
||||
i2c_master_setDC(1, 1);
|
||||
retVal = i2c_master_getDC();
|
||||
i2c_master_wait(5);
|
||||
i2c_master_setDC(1, 0);
|
||||
return ! retVal;
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -0,0 +1,251 @@
|
|||
/*
|
||||
* Software PWM using soft-interrupt timer1.
|
||||
* Supports higher frequencies compared to Espressif provided one.
|
||||
*
|
||||
* Nikolay Fiykov
|
||||
*/
|
||||
|
||||
#include <stddef.h>
|
||||
#include <stdint.h>
|
||||
#include "mem.h"
|
||||
#include "pin_map.h"
|
||||
#include "platform.h"
|
||||
#include "hw_timer.h"
|
||||
#include "driver/pwm2.h"
|
||||
|
||||
#define PWM2_TMR_MAGIC_80MHZ 16
|
||||
#define PWM2_TMR_MAGIC_160MHZ 32
|
||||
|
||||
// module vars, lazy initialized, allocated only if pwm2 is being used
|
||||
|
||||
static pwm2_module_data_t *moduleData = NULL;
|
||||
|
||||
//############################
|
||||
// tools
|
||||
|
||||
static bool isPinSetup(const pwm2_module_data_t *data, const uint8_t pin) {
|
||||
return data->setupData.pin[pin].pulseResolutions > 0;
|
||||
}
|
||||
|
||||
static uint32_t getCPUTicksPerSec() {
|
||||
return system_get_cpu_freq() * 1000000;
|
||||
}
|
||||
|
||||
static uint8_t getCpuTimerTicksDivisor() {
|
||||
return system_get_cpu_freq() == 80 ? PWM2_TMR_MAGIC_80MHZ : PWM2_TMR_MAGIC_160MHZ;
|
||||
}
|
||||
|
||||
static uint32_t findGCD(uint32_t n1, uint32_t n2) {
|
||||
uint32_t n3;
|
||||
while (n2 != 0) {
|
||||
n3 = n1;
|
||||
n1 = n2;
|
||||
n2 = n3 % n2;
|
||||
}
|
||||
return n1;
|
||||
}
|
||||
|
||||
static uint32_t findGreatesCommonDividerForTimerTicks(uint32_t newTimerTicks, uint32_t oldTimerTicks) {
|
||||
return oldTimerTicks == 0 ? newTimerTicks : findGCD(newTimerTicks, oldTimerTicks);
|
||||
}
|
||||
|
||||
static uint16_t findAllEnabledGpioMask(pwm2_module_data_t *moduleData) {
|
||||
uint16_t enableGpioMask = 0;
|
||||
for (int i = 1; i < GPIO_PIN_NUM; i++) {
|
||||
if (moduleData->setupData.pin[i].pulseResolutions > 0) {
|
||||
enableGpioMask |= moduleData->interruptData.pin[i].gpioMask;
|
||||
}
|
||||
}
|
||||
return enableGpioMask;
|
||||
}
|
||||
|
||||
static uint32_t findCommonCPUTicksDivisor(pwm2_module_data_t *moduleData) {
|
||||
uint32_t gcdCPUTicks = 0;
|
||||
for (int i = 1; i < GPIO_PIN_NUM; i++) {
|
||||
if (moduleData->setupData.pin[i].pulseResolutions > 0) {
|
||||
gcdCPUTicks = findGreatesCommonDividerForTimerTicks(moduleData->setupData.pin[i].resolutionCPUTicks, gcdCPUTicks);
|
||||
}
|
||||
}
|
||||
return gcdCPUTicks;
|
||||
}
|
||||
|
||||
static uint32_t cpuToTimerTicks(uint32_t cpuTicks) {
|
||||
return cpuTicks / getCpuTimerTicksDivisor();
|
||||
}
|
||||
|
||||
static void updatePinResolutionToInterruptsMultiplier(pwm2_pin_setup_t *sPin, uint32_t timerCPUTicks) {
|
||||
sPin->resolutionInterruptCounterMultiplier = sPin->resolutionCPUTicks / timerCPUTicks;
|
||||
}
|
||||
|
||||
static void updatePinPulseToInterruptsCounter(pwm2_pin_interrupt_t *iPin, pwm2_pin_setup_t *sPin) {
|
||||
iPin->pulseInterruptCcounter = (sPin->pulseResolutions + 1) * sPin->resolutionInterruptCounterMultiplier;
|
||||
}
|
||||
|
||||
static uint8_t getDutyAdjustment(const uint32_t duty, const uint32_t pulse) {
|
||||
if (duty == 0) {
|
||||
return 0;
|
||||
} else if (duty == pulse) {
|
||||
return 2;
|
||||
} else {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
|
||||
static void updatePinOffCounter(pwm2_pin_interrupt_t *iPin, pwm2_pin_setup_t *sPin) {
|
||||
iPin->offInterruptCounter = (sPin->duty + getDutyAdjustment(sPin->duty, sPin->pulseResolutions)) * sPin->resolutionInterruptCounterMultiplier;
|
||||
}
|
||||
|
||||
static void reCalculateCommonToAllPinsData(pwm2_module_data_t *moduleData) {
|
||||
moduleData->interruptData.enabledGpioMask = findAllEnabledGpioMask(moduleData);
|
||||
moduleData->setupData.interruptTimerCPUTicks = findCommonCPUTicksDivisor(moduleData);
|
||||
moduleData->setupData.interruptTimerTicks = cpuToTimerTicks(moduleData->setupData.interruptTimerCPUTicks);
|
||||
for (int i = 1; i < GPIO_PIN_NUM; i++) {
|
||||
if (isPinSetup(moduleData, i)) {
|
||||
updatePinResolutionToInterruptsMultiplier(&moduleData->setupData.pin[i], moduleData->setupData.interruptTimerCPUTicks);
|
||||
updatePinPulseToInterruptsCounter(&moduleData->interruptData.pin[i], &moduleData->setupData.pin[i]);
|
||||
updatePinOffCounter(&moduleData->interruptData.pin[i], &moduleData->setupData.pin[i]);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static uint64_t enduserFreqToCPUTicks(const uint64_t divisableFreq, const uint64_t freqDivisor, const uint64_t resolution) {
|
||||
return (getCPUTicksPerSec() / (freqDivisor * resolution)) * divisableFreq;
|
||||
}
|
||||
|
||||
static uint16_t getPinGpioMask(uint8_t pin) {
|
||||
return 1 << GPIO_ID_PIN(pin_num[pin]);
|
||||
}
|
||||
|
||||
static void set_duty(pwm2_module_data_t *moduleData, const uint8_t pin, const uint32_t duty) {
|
||||
pwm2_pin_setup_t *sPin = &moduleData->setupData.pin[pin];
|
||||
pwm2_pin_interrupt_t *iPin = &moduleData->interruptData.pin[pin];
|
||||
sPin->duty = duty;
|
||||
updatePinOffCounter(iPin, sPin);
|
||||
}
|
||||
|
||||
static void configureAllPinsAsGpioOutput(pwm2_module_data_t *moduleData) {
|
||||
for (int i = 1; i < GPIO_PIN_NUM; i++) {
|
||||
if (isPinSetup(moduleData, i)) {
|
||||
PIN_FUNC_SELECT(pin_mux[i], pin_func[i]); // set pin as gpio
|
||||
PIN_PULLUP_EN(pin_mux[i]); // set pin pullup on
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
static void resetPinCounters(pwm2_module_data_t *moduleData) {
|
||||
for (int i = 1; i < GPIO_PIN_NUM; i++) {
|
||||
if (isPinSetup(moduleData, i)) {
|
||||
moduleData->interruptData.pin[i].currentInterruptCounter = 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
//############################
|
||||
// interrupt handler related
|
||||
|
||||
static inline void computeIsPinOn(pwm2_pin_interrupt_t *pin, uint16_t *maskOn) {
|
||||
if (pin->currentInterruptCounter == pin->pulseInterruptCcounter) {
|
||||
pin->currentInterruptCounter = 1;
|
||||
} else {
|
||||
pin->currentInterruptCounter++;
|
||||
}
|
||||
// ets_printf("curr=%u on=%u\n", pin->currentInterruptCounter, (pin->currentInterruptCounter < pin->offInterruptCounter));
|
||||
if (pin->currentInterruptCounter < pin->offInterruptCounter) {
|
||||
*maskOn |= pin->gpioMask;
|
||||
}
|
||||
}
|
||||
|
||||
static inline bool isPinSetup2(const pwm2_interrupt_handler_data_t *data, const uint8_t pin) {
|
||||
return data->pin[pin].gpioMask > 0;
|
||||
}
|
||||
|
||||
static inline uint16_t findAllPinOns(pwm2_interrupt_handler_data_t *data) {
|
||||
uint16_t maskOn = 0;
|
||||
for (int i = 1; i < GPIO_PIN_NUM; i++) {
|
||||
if (isPinSetup2(data, i)) {
|
||||
computeIsPinOn(&data->pin[i], &maskOn);
|
||||
}
|
||||
}
|
||||
return maskOn;
|
||||
}
|
||||
|
||||
static inline void setGpioPins(const uint16_t enabledGpioMask, const register uint16_t maskOn) {
|
||||
GPIO_REG_WRITE(GPIO_OUT_W1TS_ADDRESS, maskOn);
|
||||
const register uint16_t maskOff = ~maskOn & enabledGpioMask;
|
||||
GPIO_REG_WRITE(GPIO_OUT_W1TC_ADDRESS, maskOff);
|
||||
}
|
||||
|
||||
static void ICACHE_RAM_ATTR timerInterruptHandler(os_param_t arg) {
|
||||
pwm2_interrupt_handler_data_t *data = (pwm2_interrupt_handler_data_t *)arg;
|
||||
setGpioPins(data->enabledGpioMask, findAllPinOns(data));
|
||||
}
|
||||
|
||||
//############################
|
||||
// driver's public API
|
||||
|
||||
void pwm2_init() {
|
||||
moduleData = os_malloc(sizeof(pwm2_module_data_t));
|
||||
memset(moduleData, 0, sizeof(*moduleData));
|
||||
}
|
||||
|
||||
pwm2_module_data_t *pwm2_get_module_data() {
|
||||
return moduleData;
|
||||
}
|
||||
|
||||
bool pwm2_is_pin_setup(const uint8_t pin) {
|
||||
return isPinSetup(moduleData, pin);
|
||||
}
|
||||
|
||||
void pwm2_setup_pin(
|
||||
const uint8_t pin,
|
||||
const uint32_t divisableFreq,
|
||||
const uint32_t freqDivisor,
|
||||
const uint32_t resolution,
|
||||
const uint32_t initDuty
|
||||
)
|
||||
{
|
||||
moduleData->setupData.pin[pin].pulseResolutions = resolution;
|
||||
moduleData->setupData.pin[pin].divisableFrequency = divisableFreq;
|
||||
moduleData->setupData.pin[pin].frequencyDivisor = freqDivisor;
|
||||
moduleData->setupData.pin[pin].resolutionCPUTicks = enduserFreqToCPUTicks(divisableFreq, freqDivisor, resolution);
|
||||
moduleData->interruptData.pin[pin].gpioMask = getPinGpioMask(pin);
|
||||
reCalculateCommonToAllPinsData(moduleData);
|
||||
set_duty(moduleData, pin, initDuty);
|
||||
}
|
||||
|
||||
void pwm2_release_pin(const uint8_t pin) {
|
||||
moduleData->setupData.pin[pin].pulseResolutions = 0;
|
||||
moduleData->interruptData.pin[pin].gpioMask = 0;
|
||||
}
|
||||
|
||||
void pwm2_stop() {
|
||||
if (!moduleData->setupData.isStarted) {
|
||||
return;
|
||||
}
|
||||
platform_hw_timer_close_exclusive();
|
||||
GPIO_REG_WRITE(GPIO_ENABLE_W1TC_ADDRESS, moduleData->interruptData.enabledGpioMask); // clear pins of being gpio output
|
||||
moduleData->setupData.isStarted = false;
|
||||
}
|
||||
|
||||
bool pwm2_start() {
|
||||
if (moduleData->setupData.isStarted) {
|
||||
return true;
|
||||
}
|
||||
if (!platform_hw_timer_init_exclusive(FRC1_SOURCE, TRUE, timerInterruptHandler, (os_param_t)&moduleData->interruptData, (void (*)(void))NULL)) {
|
||||
return false;
|
||||
}
|
||||
configureAllPinsAsGpioOutput(moduleData);
|
||||
resetPinCounters(moduleData);
|
||||
GPIO_REG_WRITE(GPIO_ENABLE_W1TS_ADDRESS, moduleData->interruptData.enabledGpioMask); // set pins as gpio output
|
||||
moduleData->setupData.isStarted = true;
|
||||
platform_hw_timer_arm_ticks_exclusive(moduleData->setupData.interruptTimerTicks);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool pwm2_is_started() {
|
||||
return moduleData->setupData.isStarted;
|
||||
}
|
||||
|
||||
void pwm2_set_duty(const uint8_t pin, const uint32_t duty) {
|
||||
set_duty(moduleData, pin, duty);
|
||||
}
|
|
@ -2,7 +2,7 @@
|
|||
#include "os_type.h"
|
||||
#include "osapi.h"
|
||||
#include "driver/uart.h"
|
||||
#include "c_types.h"
|
||||
#include <stdint.h>
|
||||
|
||||
LOCAL os_timer_t readline_timer;
|
||||
|
||||
|
|
|
@ -11,9 +11,9 @@
|
|||
*/
|
||||
|
||||
#include "platform.h"
|
||||
#include "c_types.h"
|
||||
#include "../libc/c_stdlib.h"
|
||||
#include "../libc/c_stdio.h"
|
||||
#include <stdint.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "driver/rotary.h"
|
||||
#include "user_interface.h"
|
||||
#include "task/task.h"
|
||||
|
@ -87,7 +87,7 @@ int rotary_close(uint32_t channel)
|
|||
rotary_clear_pin(d->phase_b_pin);
|
||||
rotary_clear_pin(d->press_pin);
|
||||
|
||||
c_free(d);
|
||||
free(d);
|
||||
|
||||
set_gpio_bits();
|
||||
|
||||
|
@ -207,7 +207,7 @@ int rotary_setup(uint32_t channel, int phase_a, int phase_b, int press, task_han
|
|||
}
|
||||
}
|
||||
|
||||
DATA *d = (DATA *) c_zalloc(sizeof(DATA));
|
||||
DATA *d = (DATA *) calloc(1, sizeof(DATA));
|
||||
if (!d) {
|
||||
return -1;
|
||||
}
|
||||
|
|
|
@ -14,9 +14,10 @@
|
|||
*/
|
||||
|
||||
#include "platform.h"
|
||||
#include "c_types.h"
|
||||
#include "../libc/c_stdlib.h"
|
||||
#include "../libc/c_stdio.h"
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
#include <stdlib.h>
|
||||
#include <stdio.h>
|
||||
#include "driver/switec.h"
|
||||
#include "ets_sys.h"
|
||||
#include "os_type.h"
|
||||
|
@ -101,7 +102,7 @@ int switec_close(uint32_t channel)
|
|||
gpio_output_set(0, 0, 0, d->mask);
|
||||
|
||||
data[channel] = NULL;
|
||||
c_free(d);
|
||||
free(d);
|
||||
|
||||
// See if there are any other channels active
|
||||
for (channel = 0; channel < sizeof(data)/sizeof(data[0]); channel++) {
|
||||
|
@ -259,7 +260,7 @@ int switec_setup(uint32_t channel, int *pin, int max_deg_per_sec, task_handle_t
|
|||
}
|
||||
}
|
||||
|
||||
DATA *d = (DATA *) c_zalloc(sizeof(DATA));
|
||||
DATA *d = (DATA *) calloc(1, sizeof(DATA));
|
||||
if (!d) {
|
||||
return -1;
|
||||
}
|
||||
|
@ -269,7 +270,7 @@ int switec_setup(uint32_t channel, int *pin, int max_deg_per_sec, task_handle_t
|
|||
// no autoreload
|
||||
if (!platform_hw_timer_init(TIMER_OWNER, FRC1_SOURCE, FALSE)) {
|
||||
// Failed to get the timer
|
||||
c_free(d);
|
||||
free(d);
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
@ -299,12 +300,12 @@ int switec_setup(uint32_t channel, int *pin, int max_deg_per_sec, task_handle_t
|
|||
|
||||
#ifdef SWITEC_DEBUG
|
||||
for (i = 0; i < 4; i++) {
|
||||
c_printf("pin[%d]=%d\n", i, pin[i]);
|
||||
printf("pin[%d]=%d\n", i, pin[i]);
|
||||
}
|
||||
|
||||
c_printf("Mask=0x%x\n", d->mask);
|
||||
printf("Mask=0x%x\n", d->mask);
|
||||
for (i = 0; i < N_STATES; i++) {
|
||||
c_printf("pinstate[%d]=0x%x\n", i, d->pinstate[i]);
|
||||
printf("pinstate[%d]=0x%x\n", i, d->pinstate[i]);
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -37,8 +37,6 @@ endif
|
|||
# Required for each makefile to inherit from the parent
|
||||
#
|
||||
|
||||
INCLUDES += -I $(PDIR)include
|
||||
INCLUDES += -I ./
|
||||
INCLUDES += -I ../../include/ets
|
||||
PDIR := ../$(PDIR)
|
||||
sinclude $(PDIR)Makefile
|
||||
|
|
|
@ -10,7 +10,6 @@
|
|||
#include "gdbstub.h"
|
||||
#include "ets_sys.h"
|
||||
#include "eagle_soc.h"
|
||||
#include "c_types.h"
|
||||
#include "gpio.h"
|
||||
#include "xtensa/corebits.h"
|
||||
#include "driver/uart.h"
|
||||
|
@ -659,11 +658,22 @@ static void ATTR_GDBFN gdb_semihost_putchar1(char c) {
|
|||
}
|
||||
|
||||
#if !GDBSTUB_FREERTOS
|
||||
//The OS-less SDK uses the Xtensa HAL to handle exceptions. We can use those functions to catch any
|
||||
//fatal exceptions and invoke the debugger when this happens.
|
||||
/* The non-OS SDK uses the Xtensa HAL to handle exceptions, and the SDK now establishes exception
|
||||
* handlers for EXCCAUSE errors: ILLEGAL, INSTR_ERROR, LOAD_STORE_ERROR, PRIVILEGED, UNALIGNED,
|
||||
* LOAD_PROHIBITED and STORE_PROHIBITED. These handlers are established in SDK/app_main.c.
|
||||
* LOAD_STORE_ERROR is handled by SDK/user_exceptions.o:load_non_32_wide_handler() which is a
|
||||
* fork of our version. The remaining are handled by a static function at
|
||||
* SDK:app+main.c:offset 0x0348.
|
||||
*
|
||||
* Our SDK 2 load_non_32_wide_handler chained into the gdb stub handler if the error was anything
|
||||
* other than a L8UI, L16SI or L16UI at a flash mapped address. However in this current
|
||||
* implementation, we have left the Espressif handler in place and handle the other errors with
|
||||
* the debugger. This means that the debugger will not capture other load store errors. I
|
||||
* might revise this.
|
||||
*/
|
||||
static void ATTR_GDBINIT install_exceptions() {
|
||||
int i;
|
||||
int exno[]={EXCCAUSE_ILLEGAL, EXCCAUSE_SYSCALL, EXCCAUSE_INSTR_ERROR, EXCCAUSE_LOAD_STORE_ERROR,
|
||||
const int exno[]={EXCCAUSE_ILLEGAL, EXCCAUSE_SYSCALL, EXCCAUSE_INSTR_ERROR, /* EXCCAUSE_LOAD_STORE_ERROR, */
|
||||
EXCCAUSE_DIVIDE_BY_ZERO, EXCCAUSE_UNALIGNED, EXCCAUSE_INSTR_DATA_ERROR, EXCCAUSE_LOAD_STORE_DATA_ERROR,
|
||||
EXCCAUSE_INSTR_ADDR_ERROR, EXCCAUSE_LOAD_STORE_ADDR_ERROR, EXCCAUSE_INSTR_PROHIBITED,
|
||||
EXCCAUSE_LOAD_PROHIBITED, EXCCAUSE_STORE_PROHIBITED};
|
||||
|
|
|
@ -42,11 +42,6 @@ STD_CFLAGS=-std=gnu11 -Wimplicit -imacros $(FATFS_INC_DIR)fatfs_prefix_lib.h
|
|||
# Required for each makefile to inherit from the parent
|
||||
#
|
||||
|
||||
INCLUDES := $(INCLUDES) -I $(PDIR)include
|
||||
INCLUDES += -I ./
|
||||
INCLUDES += -I ../platform
|
||||
INCLUDES += -I ../libc
|
||||
INCLUDES += -I ../lua
|
||||
PDIR := ../$(PDIR)
|
||||
sinclude $(PDIR)Makefile
|
||||
|
||||
|
|
|
@ -1,5 +1,6 @@
|
|||
#include <c_stdlib.h>
|
||||
#include <c_string.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
#include "vfs_int.h"
|
||||
|
||||
|
@ -12,37 +13,37 @@ static FRESULT last_result = FR_OK;
|
|||
|
||||
static const char* const volstr[FF_VOLUMES] = {FF_VOLUME_STRS};
|
||||
|
||||
static int is_current_drive = FALSE;
|
||||
static int is_current_drive = false;
|
||||
|
||||
|
||||
// forward declarations
|
||||
static sint32_t myfatfs_close( const struct vfs_file *fd );
|
||||
static sint32_t myfatfs_read( const struct vfs_file *fd, void *ptr, size_t len );
|
||||
static sint32_t myfatfs_write( const struct vfs_file *fd, const void *ptr, size_t len );
|
||||
static sint32_t myfatfs_lseek( const struct vfs_file *fd, sint32_t off, int whence );
|
||||
static sint32_t myfatfs_eof( const struct vfs_file *fd );
|
||||
static sint32_t myfatfs_tell( const struct vfs_file *fd );
|
||||
static sint32_t myfatfs_flush( const struct vfs_file *fd );
|
||||
static int32_t myfatfs_close( const struct vfs_file *fd );
|
||||
static int32_t myfatfs_read( const struct vfs_file *fd, void *ptr, size_t len );
|
||||
static int32_t myfatfs_write( const struct vfs_file *fd, const void *ptr, size_t len );
|
||||
static int32_t myfatfs_lseek( const struct vfs_file *fd, int32_t off, int whence );
|
||||
static int32_t myfatfs_eof( const struct vfs_file *fd );
|
||||
static int32_t myfatfs_tell( const struct vfs_file *fd );
|
||||
static int32_t myfatfs_flush( const struct vfs_file *fd );
|
||||
static uint32_t myfatfs_fsize( const struct vfs_file *fd );
|
||||
static sint32_t myfatfs_ferrno( const struct vfs_file *fd );
|
||||
static int32_t myfatfs_ferrno( const struct vfs_file *fd );
|
||||
|
||||
static sint32_t myfatfs_closedir( const struct vfs_dir *dd );
|
||||
static sint32_t myfatfs_readdir( const struct vfs_dir *dd, struct vfs_stat *buf );
|
||||
static int32_t myfatfs_closedir( const struct vfs_dir *dd );
|
||||
static int32_t myfatfs_readdir( const struct vfs_dir *dd, struct vfs_stat *buf );
|
||||
|
||||
static vfs_vol *myfatfs_mount( const char *name, int num );
|
||||
static vfs_file *myfatfs_open( const char *name, const char *mode );
|
||||
static vfs_dir *myfatfs_opendir( const char *name );
|
||||
static sint32_t myfatfs_stat( const char *name, struct vfs_stat *buf );
|
||||
static sint32_t myfatfs_remove( const char *name );
|
||||
static sint32_t myfatfs_rename( const char *oldname, const char *newname );
|
||||
static sint32_t myfatfs_mkdir( const char *name );
|
||||
static sint32_t myfatfs_fsinfo( uint32_t *total, uint32_t *used );
|
||||
static sint32_t myfatfs_chdrive( const char *name );
|
||||
static sint32_t myfatfs_chdir( const char *name );
|
||||
static sint32_t myfatfs_errno( void );
|
||||
static int32_t myfatfs_stat( const char *name, struct vfs_stat *buf );
|
||||
static int32_t myfatfs_remove( const char *name );
|
||||
static int32_t myfatfs_rename( const char *oldname, const char *newname );
|
||||
static int32_t myfatfs_mkdir( const char *name );
|
||||
static int32_t myfatfs_fsinfo( uint32_t *total, uint32_t *used );
|
||||
static int32_t myfatfs_chdrive( const char *name );
|
||||
static int32_t myfatfs_chdir( const char *name );
|
||||
static int32_t myfatfs_errno( void );
|
||||
static void myfatfs_clearerr( void );
|
||||
|
||||
static sint32_t myfatfs_umount( const struct vfs_vol *vol );
|
||||
static int32_t myfatfs_umount( const struct vfs_vol *vol );
|
||||
|
||||
|
||||
// ---------------------------------------------------------------------------
|
||||
|
@ -112,12 +113,12 @@ struct myvfs_dir {
|
|||
//
|
||||
void *ff_memalloc( UINT size )
|
||||
{
|
||||
return c_malloc( size );
|
||||
return malloc( size );
|
||||
}
|
||||
|
||||
void ff_memfree( void *mblock )
|
||||
{
|
||||
c_free( mblock );
|
||||
free( mblock );
|
||||
}
|
||||
|
||||
// TODO
|
||||
|
@ -153,14 +154,14 @@ DWORD get_fattime( void )
|
|||
const struct myvfs_vol *myvol = (const struct myvfs_vol *)descr; \
|
||||
FATFS *fs = (FATFS *)&(myvol->fs);
|
||||
|
||||
static sint32_t myfatfs_umount( const struct vfs_vol *vol )
|
||||
static int32_t myfatfs_umount( const struct vfs_vol *vol )
|
||||
{
|
||||
GET_FATFS_FS(vol);
|
||||
|
||||
last_result = f_mount( NULL, myvol->ldrname, 0 );
|
||||
|
||||
c_free( myvol->ldrname );
|
||||
c_free( (void *)vol );
|
||||
free( myvol->ldrname );
|
||||
free( (void *)vol );
|
||||
|
||||
return last_result == FR_OK ? VFS_RES_OK : VFS_RES_ERR;
|
||||
}
|
||||
|
@ -173,19 +174,19 @@ static sint32_t myfatfs_umount( const struct vfs_vol *vol )
|
|||
const struct myvfs_file *myfd = (const struct myvfs_file *)descr; \
|
||||
FIL *fp = (FIL *)&(myfd->fp);
|
||||
|
||||
static sint32_t myfatfs_close( const struct vfs_file *fd )
|
||||
static int32_t myfatfs_close( const struct vfs_file *fd )
|
||||
{
|
||||
GET_FIL_FP(fd)
|
||||
|
||||
last_result = f_close( fp );
|
||||
|
||||
// free descriptor memory
|
||||
c_free( (void *)fd );
|
||||
free( (void *)fd );
|
||||
|
||||
return last_result == FR_OK ? VFS_RES_OK : VFS_RES_ERR;
|
||||
}
|
||||
|
||||
static sint32_t myfatfs_read( const struct vfs_file *fd, void *ptr, size_t len )
|
||||
static int32_t myfatfs_read( const struct vfs_file *fd, void *ptr, size_t len )
|
||||
{
|
||||
GET_FIL_FP(fd);
|
||||
UINT act_read;
|
||||
|
@ -195,7 +196,7 @@ static sint32_t myfatfs_read( const struct vfs_file *fd, void *ptr, size_t len )
|
|||
return last_result == FR_OK ? act_read : VFS_RES_ERR;
|
||||
}
|
||||
|
||||
static sint32_t myfatfs_write( const struct vfs_file *fd, const void *ptr, size_t len )
|
||||
static int32_t myfatfs_write( const struct vfs_file *fd, const void *ptr, size_t len )
|
||||
{
|
||||
GET_FIL_FP(fd);
|
||||
UINT act_written;
|
||||
|
@ -205,7 +206,7 @@ static sint32_t myfatfs_write( const struct vfs_file *fd, const void *ptr, size_
|
|||
return last_result == FR_OK ? act_written : VFS_RES_ERR;
|
||||
}
|
||||
|
||||
static sint32_t myfatfs_lseek( const struct vfs_file *fd, sint32_t off, int whence )
|
||||
static int32_t myfatfs_lseek( const struct vfs_file *fd, int32_t off, int whence )
|
||||
{
|
||||
GET_FIL_FP(fd);
|
||||
FSIZE_t new_pos;
|
||||
|
@ -231,7 +232,7 @@ static sint32_t myfatfs_lseek( const struct vfs_file *fd, sint32_t off, int when
|
|||
return last_result == FR_OK ? new_pos : VFS_RES_ERR;
|
||||
}
|
||||
|
||||
static sint32_t myfatfs_eof( const struct vfs_file *fd )
|
||||
static int32_t myfatfs_eof( const struct vfs_file *fd )
|
||||
{
|
||||
GET_FIL_FP(fd);
|
||||
|
||||
|
@ -240,7 +241,7 @@ static sint32_t myfatfs_eof( const struct vfs_file *fd )
|
|||
return f_eof( fp );
|
||||
}
|
||||
|
||||
static sint32_t myfatfs_tell( const struct vfs_file *fd )
|
||||
static int32_t myfatfs_tell( const struct vfs_file *fd )
|
||||
{
|
||||
GET_FIL_FP(fd);
|
||||
|
||||
|
@ -249,7 +250,7 @@ static sint32_t myfatfs_tell( const struct vfs_file *fd )
|
|||
return f_tell( fp );
|
||||
}
|
||||
|
||||
static sint32_t myfatfs_flush( const struct vfs_file *fd )
|
||||
static int32_t myfatfs_flush( const struct vfs_file *fd )
|
||||
{
|
||||
GET_FIL_FP(fd);
|
||||
|
||||
|
@ -267,7 +268,7 @@ static uint32_t myfatfs_fsize( const struct vfs_file *fd )
|
|||
return f_size( fp );
|
||||
}
|
||||
|
||||
static sint32_t myfatfs_ferrno( const struct vfs_file *fd )
|
||||
static int32_t myfatfs_ferrno( const struct vfs_file *fd )
|
||||
{
|
||||
return -last_result;
|
||||
}
|
||||
|
@ -280,24 +281,24 @@ static sint32_t myfatfs_ferrno( const struct vfs_file *fd )
|
|||
const struct myvfs_dir *mydd = (const struct myvfs_dir *)descr; \
|
||||
DIR *dp = (DIR *)&(mydd->dp);
|
||||
|
||||
static sint32_t myfatfs_closedir( const struct vfs_dir *dd )
|
||||
static int32_t myfatfs_closedir( const struct vfs_dir *dd )
|
||||
{
|
||||
GET_DIR_DP(dd);
|
||||
|
||||
last_result = f_closedir( dp );
|
||||
|
||||
// free descriptor memory
|
||||
c_free( (void *)dd );
|
||||
free( (void *)dd );
|
||||
|
||||
return last_result == FR_OK ? VFS_RES_OK : VFS_RES_ERR;
|
||||
}
|
||||
|
||||
static void myfatfs_fill_stat( const FILINFO *fno, struct vfs_stat *buf )
|
||||
{
|
||||
c_memset( buf, 0, sizeof( struct vfs_stat ) );
|
||||
memset( buf, 0, sizeof( struct vfs_stat ) );
|
||||
|
||||
// fill in supported stat entries
|
||||
c_strncpy( buf->name, fno->fname, FS_OBJ_NAME_LEN+1 );
|
||||
strncpy( buf->name, fno->fname, FS_OBJ_NAME_LEN+1 );
|
||||
buf->name[FS_OBJ_NAME_LEN] = '\0';
|
||||
buf->size = fno->fsize;
|
||||
buf->is_dir = fno->fattrib & AM_DIR ? 1 : 0;
|
||||
|
@ -316,7 +317,7 @@ static void myfatfs_fill_stat( const FILINFO *fno, struct vfs_stat *buf )
|
|||
buf->tm_valid = 1;
|
||||
}
|
||||
|
||||
static sint32_t myfatfs_readdir( const struct vfs_dir *dd, struct vfs_stat *buf )
|
||||
static int32_t myfatfs_readdir( const struct vfs_dir *dd, struct vfs_stat *buf )
|
||||
{
|
||||
GET_DIR_DP(dd);
|
||||
FILINFO fno;
|
||||
|
@ -340,19 +341,19 @@ static sint32_t myfatfs_readdir( const struct vfs_dir *dd, struct vfs_stat *buf
|
|||
static vfs_vol *myfatfs_mount( const char *name, int num )
|
||||
{
|
||||
struct myvfs_vol *vol;
|
||||
const size_t len = c_strlen( name );
|
||||
const size_t len = strlen( name );
|
||||
|
||||
// num argument specifies the physical driver = SS/CS pin number for this sd card
|
||||
if (num >= 0) {
|
||||
for (int i = 0; i < NUM_LOGICAL_DRIVES; i++) {
|
||||
if (0 == c_strncmp( name, volstr[i], c_strlen( volstr[i] ) )) {
|
||||
if (0 == strncmp( name, volstr[i], strlen( volstr[i] ) )) {
|
||||
VolToPart[i].pd = num;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (vol = c_malloc( sizeof( struct myvfs_vol ) )) {
|
||||
if (vol->ldrname = c_strdup( name )) {
|
||||
if (vol = malloc( sizeof( struct myvfs_vol ) )) {
|
||||
if (vol->ldrname = strdup( name )) {
|
||||
if (FR_OK == (last_result = f_mount( &(vol->fs), name, 1 ))) {
|
||||
vol->vfs_vol.fs_type = VFS_FS_FATFS;
|
||||
vol->vfs_vol.fns = &myfatfs_vol_fns;
|
||||
|
@ -362,29 +363,29 @@ static vfs_vol *myfatfs_mount( const char *name, int num )
|
|||
}
|
||||
|
||||
if (vol) {
|
||||
if (vol->ldrname) c_free( vol->ldrname );
|
||||
c_free( vol );
|
||||
if (vol->ldrname) free( vol->ldrname );
|
||||
free( vol );
|
||||
}
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static BYTE myfatfs_mode2flag( const char *mode )
|
||||
{
|
||||
if (c_strlen( mode ) == 1) {
|
||||
if(c_strcmp( mode, "w" ) == 0)
|
||||
if (strlen( mode ) == 1) {
|
||||
if(strcmp( mode, "w" ) == 0)
|
||||
return FA_WRITE | FA_CREATE_ALWAYS;
|
||||
else if (c_strcmp( mode, "r" ) == 0)
|
||||
else if (strcmp( mode, "r" ) == 0)
|
||||
return FA_READ | FA_OPEN_EXISTING;
|
||||
else if (c_strcmp( mode, "a" ) == 0)
|
||||
else if (strcmp( mode, "a" ) == 0)
|
||||
return FA_WRITE | FA_OPEN_ALWAYS;
|
||||
else
|
||||
return FA_READ | FA_OPEN_EXISTING;
|
||||
} else if (c_strlen( mode ) == 2) {
|
||||
if (c_strcmp( mode, "r+" ) == 0)
|
||||
} else if (strlen( mode ) == 2) {
|
||||
if (strcmp( mode, "r+" ) == 0)
|
||||
return FA_READ | FA_WRITE | FA_OPEN_EXISTING;
|
||||
else if (c_strcmp( mode, "w+" ) == 0)
|
||||
else if (strcmp( mode, "w+" ) == 0)
|
||||
return FA_READ | FA_WRITE | FA_CREATE_ALWAYS;
|
||||
else if (c_strcmp( mode, "a+" ) ==0 )
|
||||
else if (strcmp( mode, "a+" ) ==0 )
|
||||
return FA_READ | FA_WRITE | FA_OPEN_ALWAYS;
|
||||
else
|
||||
return FA_READ | FA_OPEN_EXISTING;
|
||||
|
@ -398,7 +399,7 @@ static vfs_file *myfatfs_open( const char *name, const char *mode )
|
|||
struct myvfs_file *fd;
|
||||
const BYTE flags = myfatfs_mode2flag( mode );
|
||||
|
||||
if (fd = c_malloc( sizeof( struct myvfs_file ) )) {
|
||||
if (fd = malloc( sizeof( struct myvfs_file ) )) {
|
||||
if (FR_OK == (last_result = f_open( &(fd->fp), name, flags ))) {
|
||||
// skip to end of file for append mode
|
||||
if (flags & FA_OPEN_ALWAYS)
|
||||
|
@ -408,7 +409,7 @@ static vfs_file *myfatfs_open( const char *name, const char *mode )
|
|||
fd->vfs_file.fns = &myfatfs_file_fns;
|
||||
return (vfs_file *)fd;
|
||||
} else {
|
||||
c_free( fd );
|
||||
free( fd );
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -419,20 +420,20 @@ static vfs_dir *myfatfs_opendir( const char *name )
|
|||
{
|
||||
struct myvfs_dir *dd;
|
||||
|
||||
if (dd = c_malloc( sizeof( struct myvfs_dir ) )) {
|
||||
if (dd = malloc( sizeof( struct myvfs_dir ) )) {
|
||||
if (FR_OK == (last_result = f_opendir( &(dd->dp), name ))) {
|
||||
dd->vfs_dir.fs_type = VFS_FS_FATFS;
|
||||
dd->vfs_dir.fns = &myfatfs_dir_fns;
|
||||
return (vfs_dir *)dd;
|
||||
} else {
|
||||
c_free( dd );
|
||||
free( dd );
|
||||
}
|
||||
}
|
||||
|
||||
return NULL;
|
||||
}
|
||||
|
||||
static sint32_t myfatfs_stat( const char *name, struct vfs_stat *buf )
|
||||
static int32_t myfatfs_stat( const char *name, struct vfs_stat *buf )
|
||||
{
|
||||
FILINFO fno;
|
||||
|
||||
|
@ -445,28 +446,28 @@ static sint32_t myfatfs_stat( const char *name, struct vfs_stat *buf )
|
|||
}
|
||||
}
|
||||
|
||||
static sint32_t myfatfs_remove( const char *name )
|
||||
static int32_t myfatfs_remove( const char *name )
|
||||
{
|
||||
last_result = f_unlink( name );
|
||||
|
||||
return last_result == FR_OK ? VFS_RES_OK : VFS_RES_ERR;
|
||||
}
|
||||
|
||||
static sint32_t myfatfs_rename( const char *oldname, const char *newname )
|
||||
static int32_t myfatfs_rename( const char *oldname, const char *newname )
|
||||
{
|
||||
last_result = f_rename( oldname, newname );
|
||||
|
||||
return last_result == FR_OK ? VFS_RES_OK : VFS_RES_ERR;
|
||||
}
|
||||
|
||||
static sint32_t myfatfs_mkdir( const char *name )
|
||||
static int32_t myfatfs_mkdir( const char *name )
|
||||
{
|
||||
last_result = f_mkdir( name );
|
||||
|
||||
return last_result == FR_OK ? VFS_RES_OK : VFS_RES_ERR;
|
||||
}
|
||||
|
||||
static sint32_t myfatfs_fsinfo( uint32_t *total, uint32_t *used )
|
||||
static int32_t myfatfs_fsinfo( uint32_t *total, uint32_t *used )
|
||||
{
|
||||
DWORD free_clusters;
|
||||
FATFS *fatfs;
|
||||
|
@ -480,21 +481,21 @@ static sint32_t myfatfs_fsinfo( uint32_t *total, uint32_t *used )
|
|||
return last_result == FR_OK ? VFS_RES_OK : VFS_RES_ERR;
|
||||
}
|
||||
|
||||
static sint32_t myfatfs_chdrive( const char *name )
|
||||
static int32_t myfatfs_chdrive( const char *name )
|
||||
{
|
||||
last_result = f_chdrive( name );
|
||||
|
||||
return last_result == FR_OK ? VFS_RES_OK : VFS_RES_ERR;
|
||||
}
|
||||
|
||||
static sint32_t myfatfs_chdir( const char *name )
|
||||
static int32_t myfatfs_chdir( const char *name )
|
||||
{
|
||||
last_result = f_chdir( name );
|
||||
|
||||
return last_result == FR_OK ? VFS_RES_OK : VFS_RES_ERR;
|
||||
}
|
||||
|
||||
static sint32_t myfatfs_errno( void )
|
||||
static int32_t myfatfs_errno( void )
|
||||
{
|
||||
return -last_result;
|
||||
}
|
||||
|
@ -515,10 +516,10 @@ vfs_fs_fns *myfatfs_realm( const char *inname, char **outname, int set_current_d
|
|||
|
||||
// logical drive is specified, check if it's one of ours
|
||||
for (int i = 0; i < FF_VOLUMES; i++) {
|
||||
size_t volstr_len = c_strlen( volstr[i] );
|
||||
if (0 == c_strncmp( &(inname[1]), volstr[i], volstr_len )) {
|
||||
oname = c_strdup( inname );
|
||||
c_strcpy( oname, volstr[i] );
|
||||
size_t volstr_len = strlen( volstr[i] );
|
||||
if (0 == strncmp( &(inname[1]), volstr[i], volstr_len )) {
|
||||
oname = strdup( inname );
|
||||
strcpy( oname, volstr[i] );
|
||||
oname[volstr_len] = ':';
|
||||
*outname = oname;
|
||||
|
||||
|
@ -529,11 +530,11 @@ vfs_fs_fns *myfatfs_realm( const char *inname, char **outname, int set_current_d
|
|||
} else {
|
||||
// no logical drive in patchspec, are we current drive?
|
||||
if (is_current_drive) {
|
||||
*outname = c_strdup( inname );
|
||||
*outname = strdup( inname );
|
||||
return &myfatfs_fs_fns;
|
||||
}
|
||||
}
|
||||
|
||||
if (set_current_drive) is_current_drive = FALSE;
|
||||
if (set_current_drive) is_current_drive = false;
|
||||
return NULL;
|
||||
}
|
||||
|
|
|
@ -38,11 +38,6 @@ STD_CFLAGS=-std=gnu11 -Wimplicit
|
|||
# Required for each makefile to inherit from the parent
|
||||
#
|
||||
|
||||
INCLUDES := $(INCLUDES) -I $(PDIR)include
|
||||
INCLUDES += -I ./
|
||||
INCLUDES += -I ./include
|
||||
INCLUDES += -I ../include
|
||||
INCLUDES += -I ../../include
|
||||
PDIR := ../$(PDIR)
|
||||
sinclude $(PDIR)Makefile
|
||||
|
||||
|
|
|
@ -13,7 +13,7 @@
|
|||
*/
|
||||
|
||||
#include "osapi.h"
|
||||
#include "../libc/c_stdio.h"
|
||||
#include <stdio.h>
|
||||
#include "user_interface.h"
|
||||
#include "espconn.h"
|
||||
#include "mem.h"
|
||||
|
|
|
@ -35,7 +35,7 @@
|
|||
#define __ARCH_CC_H__
|
||||
|
||||
//#include <string.h>
|
||||
#include "c_types.h"
|
||||
#include <stdint.h>
|
||||
#include "ets_sys.h"
|
||||
#include "osapi.h"
|
||||
#define EFAULT 14
|
||||
|
|
|
@ -1,74 +1,12 @@
|
|||
#ifndef __I2C_MASTER_H__
|
||||
#define __I2C_MASTER_H__
|
||||
|
||||
#define I2C_MASTER_SDA_MUX (pin_mux[sda])
|
||||
#define I2C_MASTER_SCL_MUX (pin_mux[scl])
|
||||
#define I2C_MASTER_SDA_GPIO (pinSDA)
|
||||
#define I2C_MASTER_SCL_GPIO (pinSCL)
|
||||
#define I2C_MASTER_SDA_FUNC (pin_func[sda])
|
||||
#define I2C_MASTER_SCL_FUNC (pin_func[scl])
|
||||
uint32 i2c_master_setup(uint16 id, uint8 sda, uint8 scl, uint32 speed);
|
||||
void i2c_master_init(uint16 id);
|
||||
bool i2c_master_configured(uint16 id);
|
||||
void i2c_master_stop(uint16 id);
|
||||
void i2c_master_start(uint16 id);
|
||||
uint8 i2c_master_readByte(uint16 id, sint16 ack);
|
||||
uint8 i2c_master_writeByte(uint16 id, uint8 wrdata);
|
||||
|
||||
// #define I2C_MASTER_SDA_MUX PERIPHS_IO_MUX_GPIO2_U
|
||||
// #define I2C_MASTER_SCL_MUX PERIPHS_IO_MUX_MTDO_U
|
||||
// #define I2C_MASTER_SDA_GPIO 2
|
||||
// #define I2C_MASTER_SCL_GPIO 15
|
||||
// #define I2C_MASTER_SDA_FUNC FUNC_GPIO2
|
||||
// #define I2C_MASTER_SCL_FUNC FUNC_GPIO15
|
||||
|
||||
// #define I2C_MASTER_SDA_MUX PERIPHS_IO_MUX_GPIO2_U
|
||||
// #define I2C_MASTER_SCL_MUX PERIPHS_IO_MUX_MTMS_U
|
||||
// #define I2C_MASTER_SDA_GPIO 2
|
||||
// #define I2C_MASTER_SCL_GPIO 14
|
||||
// #define I2C_MASTER_SDA_FUNC FUNC_GPIO2
|
||||
// #define I2C_MASTER_SCL_FUNC FUNC_GPIO14
|
||||
|
||||
//#define I2C_MASTER_SDA_MUX PERIPHS_IO_MUX_GPIO2_U
|
||||
//#define I2C_MASTER_SCL_MUX PERIPHS_IO_MUX_GPIO0_U
|
||||
//#define I2C_MASTER_SDA_GPIO 2
|
||||
//#define I2C_MASTER_SCL_GPIO 0
|
||||
//#define I2C_MASTER_SDA_FUNC FUNC_GPIO2
|
||||
//#define I2C_MASTER_SCL_FUNC FUNC_GPIO0
|
||||
|
||||
#if 0
|
||||
#define I2C_MASTER_GPIO_SET(pin) \
|
||||
gpio_output_set(1<<pin,0,1<<pin,0)
|
||||
|
||||
#define I2C_MASTER_GPIO_CLR(pin) \
|
||||
gpio_output_set(0,1<<pin,1<<pin,0)
|
||||
|
||||
#define I2C_MASTER_GPIO_OUT(pin,val) \
|
||||
if(val) I2C_MASTER_GPIO_SET(pin);\
|
||||
else I2C_MASTER_GPIO_CLR(pin)
|
||||
#endif
|
||||
|
||||
#define I2C_MASTER_SDA_HIGH_SCL_HIGH() \
|
||||
gpio_output_set(1<<I2C_MASTER_SDA_GPIO | 1<<I2C_MASTER_SCL_GPIO, 0, 1<<I2C_MASTER_SDA_GPIO | 1<<I2C_MASTER_SCL_GPIO, 0)
|
||||
|
||||
#define I2C_MASTER_SDA_HIGH_SCL_LOW() \
|
||||
gpio_output_set(1<<I2C_MASTER_SDA_GPIO, 1<<I2C_MASTER_SCL_GPIO, 1<<I2C_MASTER_SDA_GPIO | 1<<I2C_MASTER_SCL_GPIO, 0)
|
||||
|
||||
#define I2C_MASTER_SDA_LOW_SCL_HIGH() \
|
||||
gpio_output_set(1<<I2C_MASTER_SCL_GPIO, 1<<I2C_MASTER_SDA_GPIO, 1<<I2C_MASTER_SDA_GPIO | 1<<I2C_MASTER_SCL_GPIO, 0)
|
||||
|
||||
#define I2C_MASTER_SDA_LOW_SCL_LOW() \
|
||||
gpio_output_set(0, 1<<I2C_MASTER_SDA_GPIO | 1<<I2C_MASTER_SCL_GPIO, 1<<I2C_MASTER_SDA_GPIO | 1<<I2C_MASTER_SCL_GPIO, 0)
|
||||
|
||||
void i2c_master_gpio_init(uint8 sda, uint8 scl);
|
||||
void i2c_master_init(void);
|
||||
|
||||
#define i2c_master_wait os_delay_us
|
||||
void i2c_master_stop(void);
|
||||
void i2c_master_start(void);
|
||||
void i2c_master_setAck(uint8 level);
|
||||
uint8 i2c_master_getAck(void);
|
||||
uint8 i2c_master_readByte(void);
|
||||
void i2c_master_writeByte(uint8 wrdata);
|
||||
|
||||
bool i2c_master_checkAck(void);
|
||||
void i2c_master_send_ack(void);
|
||||
void i2c_master_send_nack(void);
|
||||
|
||||
uint8 i2c_master_get_pinSDA();
|
||||
uint8 i2c_master_get_pinSCL();
|
||||
|
||||
#endif
|
||||
#endif //__I2C_MASTER_H__
|
||||
|
|
|
@ -1,7 +1,8 @@
|
|||
#ifndef __ONEWIRE_H__
|
||||
#define __ONEWIRE_H__
|
||||
|
||||
#include "c_types.h"
|
||||
#include <stdint.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
// You can exclude certain features from OneWire. In theory, this
|
||||
// might save some space. In practice, the compiler automatically
|
||||
|
|
|
@ -0,0 +1,65 @@
|
|||
/*
|
||||
* Software PWM using soft-interrupt timer1.
|
||||
* Supports higher frequencies compared to Espressif provided one.
|
||||
*
|
||||
* Nikolay Fiykov
|
||||
*/
|
||||
|
||||
#ifndef __PWM2_H__
|
||||
#define __PWM2_H__
|
||||
|
||||
#include <stdint.h>
|
||||
#include "pin_map.h"
|
||||
|
||||
typedef struct {
|
||||
uint32_t offInterruptCounter;
|
||||
uint32_t pulseInterruptCcounter;
|
||||
uint32_t currentInterruptCounter;
|
||||
uint16_t gpioMask;
|
||||
} pwm2_pin_interrupt_t;
|
||||
|
||||
typedef struct {
|
||||
pwm2_pin_interrupt_t pin[GPIO_PIN_NUM];
|
||||
uint16_t enabledGpioMask;
|
||||
} pwm2_interrupt_handler_data_t;
|
||||
|
||||
typedef struct {
|
||||
uint32_t pulseResolutions;
|
||||
uint32_t divisableFrequency;
|
||||
uint32_t frequencyDivisor;
|
||||
uint32_t duty;
|
||||
uint32_t resolutionCPUTicks;
|
||||
uint32_t resolutionInterruptCounterMultiplier;
|
||||
} pwm2_pin_setup_t;
|
||||
|
||||
typedef struct {
|
||||
pwm2_pin_setup_t pin[GPIO_PIN_NUM];
|
||||
uint32_t interruptTimerCPUTicks;
|
||||
uint32_t interruptTimerTicks;
|
||||
bool isStarted;
|
||||
} pwm2_setup_data_t;
|
||||
|
||||
typedef struct {
|
||||
pwm2_interrupt_handler_data_t interruptData;
|
||||
pwm2_setup_data_t setupData;
|
||||
} pwm2_module_data_t;
|
||||
|
||||
// driver's public API
|
||||
|
||||
void pwm2_init();
|
||||
pwm2_module_data_t *pwm2_get_module_data();
|
||||
bool pwm2_is_pin_setup(const uint8_t pin);
|
||||
void pwm2_setup_pin(
|
||||
const uint8_t pin,
|
||||
const uint32_t divisableFreq,
|
||||
const uint32_t freqDivisor,
|
||||
const uint32_t resolution,
|
||||
const uint32_t initDuty
|
||||
);
|
||||
void pwm2_release_pin(const uint8_t pin);
|
||||
void pwm2_stop();
|
||||
bool pwm2_start();
|
||||
bool pwm2_is_started();
|
||||
void pwm2_set_duty(const uint8_t pin, const uint32_t duty);
|
||||
|
||||
#endif
|
|
@ -4,7 +4,7 @@
|
|||
#ifndef __ROTARY_H__
|
||||
#define __ROTARY_H__
|
||||
|
||||
#include "c_types.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#define ROTARY_CHANNEL_COUNT 3
|
||||
|
||||
|
|
|
@ -4,7 +4,7 @@
|
|||
#ifndef __SWITEC_H__
|
||||
#define __SWITEC_H__
|
||||
|
||||
#include "c_types.h"
|
||||
#include <stdint.h>
|
||||
|
||||
#define SWITEC_CHANNEL_COUNT 3
|
||||
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
|
||||
#include "uart_register.h"
|
||||
#include "eagle_soc.h"
|
||||
#include "c_types.h"
|
||||
#include <stdint.h>
|
||||
#include "os_type.h"
|
||||
|
||||
#define RX_BUFF_SIZE 0x100
|
||||
|
|
|
@ -14,7 +14,8 @@
|
|||
* Created on: Apr 22, 2016
|
||||
* Author: liuhan
|
||||
*/
|
||||
#include "c_types.h"
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "ets_sys.h"
|
||||
#include "os_type.h"
|
||||
|
|
|
@ -53,6 +53,7 @@ struct dhcp
|
|||
ip_addr_t offered_ip_addr;
|
||||
ip_addr_t offered_sn_mask;
|
||||
ip_addr_t offered_gw_addr;
|
||||
ip_addr_t offered_ntp_addr;
|
||||
|
||||
u32_t offered_t0_lease; /* lease period (in seconds) */
|
||||
u32_t offered_t1_renew; /* recommended renew time (usually 50% of lease period) */
|
||||
|
@ -207,6 +208,9 @@ void dhcp_fine_tmr(void);
|
|||
#define DHCP_OPTION_TCP_TTL 37
|
||||
#define DHCP_OPTION_END 255
|
||||
|
||||
/* time */
|
||||
#define DHCP_OPTION_NTP 42
|
||||
|
||||
/**add options for support more router by liuHan**/
|
||||
#define DHCP_OPTION_DOMAIN_NAME 15
|
||||
#define DHCP_OPTION_PRD 31
|
||||
|
|
|
@ -51,40 +51,39 @@ typedef size_t mem_size_t;
|
|||
* allow these defines to be overridden.
|
||||
*/
|
||||
#ifndef MEMLEAK_DEBUG
|
||||
|
||||
#ifndef mem_free
|
||||
#define mem_free vPortFree
|
||||
#define mem_free(s) vPortFree(s, "", __LINE__)
|
||||
#endif
|
||||
#ifndef mem_malloc
|
||||
#define mem_malloc pvPortMalloc
|
||||
#define mem_malloc(s) pvPortMalloc(s, "", __LINE__,false)
|
||||
#endif
|
||||
#ifndef mem_calloc
|
||||
#define mem_calloc pvPortCalloc
|
||||
#define mem_calloc(l, s) pvPortCalloc(l, s, "", __LINE__)
|
||||
#endif
|
||||
#ifndef mem_realloc
|
||||
#define mem_realloc pvPortRealloc
|
||||
#define mem_realloc(p, s) pvPortRealloc(p, s, "", __LINE__)
|
||||
#endif
|
||||
#ifndef mem_zalloc
|
||||
#define mem_zalloc pvPortZalloc
|
||||
#define mem_zalloc(s) pvPortZalloc(s, "", __LINE__)
|
||||
#endif
|
||||
|
||||
#else
|
||||
|
||||
#ifndef mem_free
|
||||
#define mem_free(s) \
|
||||
do{\
|
||||
const char *file = mem_debug_file;\
|
||||
vPortFree(s, file, __LINE__);\
|
||||
}while(0)
|
||||
#define mem_free(s) vPortFree(s, mem_debug_file, __LINE__)
|
||||
#endif
|
||||
#ifndef mem_malloc
|
||||
#define mem_malloc(s) ({const char *file = mem_debug_file; pvPortMalloc(s, file, __LINE__);})
|
||||
#define mem_malloc(s) pvPortMalloc(s, mem_debug_file, __LINE__,false)
|
||||
#endif
|
||||
#ifndef mem_calloc
|
||||
#define mem_calloc(l, s) ({const char *file = mem_debug_file; pvPortCalloc(l, s, file, __LINE__);})
|
||||
#define mem_calloc(l, s) pvPortCalloc(l, s, mem_debug_file, __LINE__)
|
||||
#endif
|
||||
#ifndef mem_realloc
|
||||
#define mem_realloc(p, s) ({const char *file = mem_debug_file; pvPortRealloc(p, s, file, __LINE__);})
|
||||
#define mem_realloc(p, s) pvPortRealloc(p, s, mem_debug_file, __LINE__)
|
||||
#endif
|
||||
#ifndef mem_zalloc
|
||||
#define mem_zalloc(s) ({const char *file = mem_debug_file; pvPortZalloc(s, file, __LINE__);})
|
||||
#define mem_zalloc(s) pvPortZalloc(s, mem_debug_file, __LINE__)
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
|
|
@ -38,6 +38,12 @@
|
|||
#ifndef MBEDTLS_BN_MUL_H
|
||||
#define MBEDTLS_BN_MUL_H
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include "bignum.h"
|
||||
|
||||
#if defined(MBEDTLS_HAVE_ASM)
|
||||
|
@ -734,7 +740,7 @@
|
|||
"sw $10, %2 \n\t" \
|
||||
: "=m" (c), "=m" (d), "=m" (s) \
|
||||
: "m" (s), "m" (d), "m" (c), "m" (b) \
|
||||
: "$9", "$10", "$11", "$12", "$13", "$14", "$15" \
|
||||
: "$9", "$10", "$11", "$12", "$13", "$14", "$15", "lo", "hi" \
|
||||
);
|
||||
|
||||
#endif /* MIPS */
|
||||
|
|
|
@ -122,6 +122,10 @@
|
|||
#error "MBEDTLS_ECP_C defined, but not all prerequisites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_PK_PARSE_C) && !defined(MBEDTLS_ASN1_PARSE_C)
|
||||
#error "MBEDTLS_PK_PARSE_C defined, but not all prerequesites"
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ENTROPY_C) && (!defined(MBEDTLS_SHA512_C) && \
|
||||
!defined(MBEDTLS_SHA256_C))
|
||||
#error "MBEDTLS_ENTROPY_C defined, but not all prerequisites"
|
||||
|
|
|
@ -28,6 +28,12 @@
|
|||
#ifndef MBEDTLS_CTR_DRBG_H
|
||||
#define MBEDTLS_CTR_DRBG_H
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include "aes.h"
|
||||
|
||||
#if defined(MBEDTLS_THREADING_C)
|
||||
|
|
|
@ -24,6 +24,12 @@
|
|||
#ifndef MBEDTLS_HMAC_DRBG_H
|
||||
#define MBEDTLS_HMAC_DRBG_H
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include "md.h"
|
||||
|
||||
#if defined(MBEDTLS_THREADING_C)
|
||||
|
|
|
@ -24,6 +24,12 @@
|
|||
#ifndef MBEDTLS_PKCS12_H
|
||||
#define MBEDTLS_PKCS12_H
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include "md.h"
|
||||
#include "cipher.h"
|
||||
#include "asn1.h"
|
||||
|
@ -46,6 +52,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ASN1_PARSE_C)
|
||||
|
||||
/**
|
||||
* \brief PKCS12 Password Based function (encryption / decryption)
|
||||
* for pbeWithSHAAnd128BitRC4
|
||||
|
@ -87,6 +95,8 @@ int mbedtls_pkcs12_pbe( mbedtls_asn1_buf *pbe_params, int mode,
|
|||
const unsigned char *input, size_t len,
|
||||
unsigned char *output );
|
||||
|
||||
#endif /* MBEDTLS_ASN1_PARSE_C */
|
||||
|
||||
/**
|
||||
* \brief The PKCS#12 derivation function uses a password and a salt
|
||||
* to produce pseudo-random bits for a particular "purpose".
|
||||
|
|
|
@ -26,6 +26,12 @@
|
|||
#ifndef MBEDTLS_PKCS5_H
|
||||
#define MBEDTLS_PKCS5_H
|
||||
|
||||
#if !defined(MBEDTLS_CONFIG_FILE)
|
||||
#include "config.h"
|
||||
#else
|
||||
#include MBEDTLS_CONFIG_FILE
|
||||
#endif
|
||||
|
||||
#include "asn1.h"
|
||||
#include "md.h"
|
||||
|
||||
|
@ -44,6 +50,8 @@
|
|||
extern "C" {
|
||||
#endif
|
||||
|
||||
#if defined(MBEDTLS_ASN1_PARSE_C)
|
||||
|
||||
/**
|
||||
* \brief PKCS#5 PBES2 function
|
||||
*
|
||||
|
@ -62,6 +70,8 @@ int mbedtls_pkcs5_pbes2( const mbedtls_asn1_buf *pbe_params, int mode,
|
|||
const unsigned char *data, size_t datalen,
|
||||
unsigned char *output );
|
||||
|
||||
#endif /* MBEDTLS_ASN1_PARSE_C */
|
||||
|
||||
/**
|
||||
* \brief PKCS#5 PBKDF2 using HMAC
|
||||
*
|
||||
|
|
|
@ -1618,6 +1618,14 @@ void mbedtls_ssl_conf_ca_chain( mbedtls_ssl_config *conf,
|
|||
* whether it matches those preferences - the server can then
|
||||
* decide what it wants to do with it.
|
||||
*
|
||||
* \note The provided \p pk_key needs to match the public key in the
|
||||
* first certificate in \p own_cert, or all handshakes using
|
||||
* that certificate will fail. It is your responsibility
|
||||
* to ensure that; this function will not perform any check.
|
||||
* You may use mbedtls_pk_check_pair() in order to perform
|
||||
* this check yourself, but be aware that this function can
|
||||
* be computationally expensive on some key types.
|
||||
*
|
||||
* \param conf SSL configuration
|
||||
* \param own_cert own public certificate chain
|
||||
* \param pk_key own private key
|
||||
|
|
|
@ -40,16 +40,16 @@
|
|||
*/
|
||||
#define MBEDTLS_VERSION_MAJOR 2
|
||||
#define MBEDTLS_VERSION_MINOR 7
|
||||
#define MBEDTLS_VERSION_PATCH 8
|
||||
#define MBEDTLS_VERSION_PATCH 9
|
||||
|
||||
/**
|
||||
* The single version number has the following structure:
|
||||
* MMNNPP00
|
||||
* Major version | Minor version | Patch version
|
||||
*/
|
||||
#define MBEDTLS_VERSION_NUMBER 0x02070800
|
||||
#define MBEDTLS_VERSION_STRING "2.7.8"
|
||||
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.7.8"
|
||||
#define MBEDTLS_VERSION_NUMBER 0x02070900
|
||||
#define MBEDTLS_VERSION_STRING "2.7.9"
|
||||
#define MBEDTLS_VERSION_STRING_FULL "mbed TLS 2.7.9"
|
||||
|
||||
#if defined(MBEDTLS_VERSION_C)
|
||||
|
||||
|
|
|
@ -2,7 +2,7 @@
|
|||
#define __MODULE_H__
|
||||
|
||||
#include "user_modules.h"
|
||||
#include "lrodefs.h"
|
||||
#include "lrotable.h"
|
||||
|
||||
/* Registering a module within NodeMCU is really easy these days!
|
||||
*
|
||||
|
@ -18,11 +18,11 @@
|
|||
*
|
||||
* Then simply put a line like this at the bottom of your module file:
|
||||
*
|
||||
* NODEMCU_MODULE(MYNAME, "myname", myname_map, luaopen_myname);
|
||||
* NODEMCU_MODULE(MYNAME, "myname", myname, luaopen_myname);
|
||||
*
|
||||
* or perhaps
|
||||
*
|
||||
* NODEMCU_MODULE(MYNAME, "myname", myname_map, NULL);
|
||||
* NODEMCU_MODULE(MYNAME, "myname", myname, NULL);
|
||||
*
|
||||
* if you don't need an init function.
|
||||
*
|
||||
|
@ -67,13 +67,8 @@
|
|||
*/
|
||||
#define NODEMCU_MODULE(cfgname, luaname, map, initfunc) \
|
||||
const LOCK_IN_SECTION(libs) \
|
||||
luaL_Reg MODULE_PASTE_(lua_lib_,cfgname) = { luaname, initfunc }; \
|
||||
luaR_entry MODULE_PASTE_(lua_lib_,cfgname) = { luaname, LRO_FUNCVAL(initfunc) }; \
|
||||
const LOCK_IN_SECTION(rotable) \
|
||||
luaR_entry MODULE_EXPAND_PASTE_(cfgname,MODULE_EXPAND_PASTE_(_module_selected,MODULE_PASTE_(LUA_USE_MODULES_,cfgname))) \
|
||||
= {LSTRKEY(luaname), LROVAL(map)}
|
||||
|
||||
#if !defined(LUA_CROSS_COMPILER) && !(MIN_OPT_LEVEL==2 && LUA_OPTIMIZE_MEMORY==2)
|
||||
# error "NodeMCU modules must be built with LTR enabled (MIN_OPT_LEVEL=2 and LUA_OPTIMIZE_MEMORY=2)"
|
||||
#endif
|
||||
|
||||
= {luaname, LRO_ROVAL(map ## _map)}
|
||||
#endif
|
||||
|
|
|
@ -1,12 +1,12 @@
|
|||
#ifndef __FPM_SLEEP_H__
|
||||
#define __FPM_SLEEP_H__
|
||||
#include "user_interface.h"
|
||||
#include "c_types.h"
|
||||
#include <stdint.h>
|
||||
#include "lauxlib.h"
|
||||
#include "gpio.h"
|
||||
#include "platform.h"
|
||||
#include "task/task.h"
|
||||
#include "c_string.h"
|
||||
#include <string.h>
|
||||
|
||||
#if defined(DEVELOP_VERSION)
|
||||
#define PMSLEEP_DEBUG
|
||||
|
@ -24,23 +24,17 @@
|
|||
#define PMSLEEP_ERR(...)
|
||||
#endif
|
||||
|
||||
|
||||
|
||||
|
||||
|
||||
#define PMSLEEP_SLEEP_MIN_TIME 50000
|
||||
#define PMSLEEP_SLEEP_MAX_TIME 268435454 //FPM_MAX_SLEEP_TIME-1
|
||||
#define pmSleep_INIT_CFG(X) pmSleep_param_t X = {.sleep_duration=0, .wake_pin=255, \
|
||||
.preserve_opmode=TRUE, .suspend_cb_ptr=NULL, .resume_cb_ptr=NULL}
|
||||
|
||||
#define PMSLEEP_INT_MAP \
|
||||
{ LSTRKEY( "INT_BOTH" ), LNUMVAL( GPIO_PIN_INTR_ANYEDGE ) }, \
|
||||
{ LSTRKEY( "INT_UP" ), LNUMVAL( GPIO_PIN_INTR_POSEDGE ) }, \
|
||||
{ LSTRKEY( "INT_DOWN" ), LNUMVAL( GPIO_PIN_INTR_NEGEDGE ) }, \
|
||||
{ LSTRKEY( "INT_HIGH" ), LNUMVAL( GPIO_PIN_INTR_HILEVEL ) }, \
|
||||
{ LSTRKEY( "INT_LOW" ), LNUMVAL( GPIO_PIN_INTR_LOLEVEL ) }
|
||||
|
||||
|
||||
LROT_NUMENTRY( INT_BOTH, GPIO_PIN_INTR_ANYEDGE ) \
|
||||
LROT_NUMENTRY( INT_UP, GPIO_PIN_INTR_POSEDGE ) \
|
||||
LROT_NUMENTRY( INT_DOWN, GPIO_PIN_INTR_NEGEDGE ) \
|
||||
LROT_NUMENTRY( INT_HIGH, GPIO_PIN_INTR_HILEVEL ) \
|
||||
LROT_NUMENTRY( INT_LOW, GPIO_PIN_INTR_LOLEVEL )
|
||||
|
||||
typedef struct pmSleep_param{
|
||||
uint32 sleep_duration;
|
||||
|
|
|
@ -3,7 +3,7 @@
|
|||
#ifndef _ROM_H_
|
||||
#define _ROM_H_
|
||||
|
||||
#include "c_types.h"
|
||||
#include <stdint.h>
|
||||
#include "ets_sys.h"
|
||||
|
||||
// SHA1 is assumed to match the netbsd sha1.h headers
|
||||
|
|
|
@ -1,7 +1,7 @@
|
|||
#ifndef RTC_ACCESS_H
|
||||
#define RTC_ACCESS_H
|
||||
|
||||
#include <c_types.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#define RTC_MMIO_BASE 0x60000700
|
||||
#define RTC_USER_MEM_BASE 0x60001200
|
||||
|
|
|
@ -38,7 +38,7 @@
|
|||
* relevant functions and expose these instead, through the rtctime.c module.
|
||||
*/
|
||||
|
||||
#include <c_types.h>
|
||||
#include <stdint.h>
|
||||
#include "sections.h"
|
||||
|
||||
#ifndef _RTCTIME_INTERNAL_H_
|
||||
|
|
|
@ -7,50 +7,53 @@
|
|||
// ***************************************************************************
|
||||
// Enable display drivers
|
||||
//
|
||||
// Uncomment the U8G2_DISPLAY_TABLE_ENTRY for the device(s) you want to
|
||||
// compile into the firmware.
|
||||
// Copy the uncommented U8G2_DISPLAY_TABLE_ENTRY for the device(s) you want to
|
||||
// compile into the firmware to U8G2_DISPLAY_TABLE_I2C or U8G2_DISPLAY_TABLE_SPI.
|
||||
// Stick to the assignments to *_I2C and *_SPI tables.
|
||||
|
||||
#ifndef U8G2_DISPLAY_TABLE_I2C_EXTRA
|
||||
|
||||
// I2C based displays go into here:
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1610_i2c_ea_dogxl160_f, uc1610_i2c_ea_dogxl160) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1325_i2c_nhd_128x64_f, ssd1325_i2c_nhd_128x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_i2c_64x48_er_f, ssd1306_i2c_64x48_er) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1608_i2c_erc24064_f, uc1608_i2c_erc24064) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7588_i2c_jlx12864_f, st7588_i2c_jlx12864) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1309_i2c_128x64_noname0_f, ssd1309_i2c_128x64_noname0) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1611_i2c_ea_dogxl240_f, uc1611_i2c_ea_dogxl240) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1305_i2c_128x32_noname_f, ssd1305_i2c_128x32_noname) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_i2c_128x32_univision_f, ssd1306_i2c_128x32_univision) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1608_i2c_240x128_f, uc1608_i2c_240x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ld7032_i2c_60x32_f, ld7032_i2c_60x32) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1611_i2c_ew50850_f, uc1611_i2c_ew50850) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1604_i2c_jlx19264_f, uc1604_i2c_jlx19264) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1601_i2c_128x32_f, uc1601_i2c_128x32) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1106_i2c_128x64_vcomh0_f, sh1106_i2c_128x64_vcomh0) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_i2c_96x16_er_f, ssd1306_i2c_96x16_er) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1106_i2c_128x64_noname_f, sh1106_i2c_128x64_noname) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1107_i2c_64x128_f, sh1107_i2c_64x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1107_i2c_seeed_96x96_f, sh1107_i2c_seeed_96x96) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1107_i2c_128x128_f, sh1107_i2c_128x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1107_i2c_seeed_96x96_f, sh1107_i2c_seeed_96x96) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1108_i2c_160x160_f, sh1108_i2c_160x160) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1122_i2c_256x64_f, sh1122_i2c_256x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_i2c_128x64_vcomh0_f, ssd1306_i2c_128x64_vcomh0) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_i2c_128x64_noname_f, ssd1306_i2c_128x64_noname) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1309_i2c_128x64_noname2_f, ssd1309_i2c_128x64_noname2) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd0323_i2c_os128064_f, ssd0323_i2c_os128064) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1305_i2c_128x32_noname_f, ssd1305_i2c_128x32_noname) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_i2c_64x48_er_f, ssd1306_i2c_64x48_er) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_i2c_96x16_er_f, ssd1306_i2c_96x16_er) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_i2c_128x32_univision_f, ssd1306_i2c_128x32_univision) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_i2c_128x64_alt0_f, ssd1306_i2c_128x64_alt0) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1611_i2c_ea_dogm240_f, uc1611_i2c_ea_dogm240) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_i2c_128x64_noname_f, ssd1306_i2c_128x64_noname) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_i2c_128x64_vcomh0_f, ssd1306_i2c_128x64_vcomh0) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1309_i2c_128x64_noname0_f, ssd1309_i2c_128x64_noname0) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1309_i2c_128x64_noname2_f, ssd1309_i2c_128x64_noname2) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1318_i2c_128x96_f, ssd1318_i2c_128x96) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1318_i2c_128x96_xcp_f, ssd1318_i2c_128x96_xcp) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1325_i2c_nhd_128x64_f, ssd1325_i2c_nhd_128x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1326_i2c_er_256x32_f, ssd1326_i2c_er_256x32 )\
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1327_i2c_seeed_96x96_f, ssd1327_i2c_seeed_96x96) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1327_i2c_ea_w128128_f, ssd1327_i2c_ea_w128128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1327_i2c_midas_128x128_f, ssd1327_i2c_midas_128x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1327_i2c_seeed_96x96_f, ssd1327_i2c_seeed_96x96) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7567_i2c_64x32_f, st7567_i2c_64x32) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7588_i2c_jlx12864_f, st7588_i2c_jlx12864) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st75256_i2c_jlx256128_f, st75256_i2c_jlx256128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st75256_i2c_jlx256160_f, st75256_i2c_jlx256160) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st75256_i2c_jlx240160_f, st75256_i2c_jlx240160) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st75256_i2c_jlx25664_f, st75256_i2c_jlx25664) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st75256_i2c_jlx172104_f, st75256_i2c_jlx172104) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1601_i2c_128x32_f, uc1601_i2c_128x32) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1604_i2c_jlx19264_f, uc1604_i2c_jlx19264) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1608_i2c_240x128_f, uc1608_i2c_240x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1608_i2c_erc24064_f, uc1608_i2c_erc24064) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1610_i2c_ea_dogxl160_f, uc1610_i2c_ea_dogxl160) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1611_i2c_ea_dogm240_f, uc1611_i2c_ea_dogm240) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1611_i2c_ea_dogxl240_f, uc1611_i2c_ea_dogxl240) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1611_i2c_ew50850_f, uc1611_i2c_ew50850) \
|
||||
|
||||
#define U8G2_DISPLAY_TABLE_I2C \
|
||||
U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_i2c_128x64_noname_f, ssd1306_i2c_128x64_noname) \
|
||||
|
@ -67,83 +70,89 @@
|
|||
#ifndef U8G2_DISPLAY_TABLE_SPI_EXTRA
|
||||
|
||||
// SPI based displays go into here:
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1606_172x72_f, ssd1606_172x72) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1608_240x128_f, uc1608_240x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_erc12864_f, st7565_erc12864) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1309_128x64_noname0_f, ssd1309_128x64_noname0) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1601_128x32_f, uc1601_128x32) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1608_erc24064_f, uc1608_erc24064) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_lm6059_f, st7565_lm6059) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1611_ea_dogxl240_f, uc1611_ea_dogxl240) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_nhd_c12864_f, st7565_nhd_c12864) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_128x64_vcomh0_f, ssd1306_128x64_vcomh0) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1305_128x32_noname_f, ssd1305_128x32_noname) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_max7219_32x8_f, max7219_32x8) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ls013b7dh03_128x128_f, ls013b7dh03_128x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_hx1230_96x68_f, hx1230_96x68) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_il3820_v2_296x128_f, il3820_v2_296x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1610_ea_dogxl160_f, uc1610_ea_dogxl160) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1611_ea_dogm240_f, uc1611_ea_dogm240) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1604_jlx19264_f, uc1604_jlx19264) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7920_s_192x32_f, st7920_s_192x32) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1325_nhd_128x64_f, ssd1325_nhd_128x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_128x64_noname_f, ssd1306_128x64_noname) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_128x64_alt0_f, ssd1306_128x64_alt0) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sed1520_122x32_f, sed1520_122x32) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_ea_dogm128_f, st7565_ea_dogm128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ld7032_60x32_f, ld7032_60x32) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1607_200x200_f, ssd1607_200x200) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1309_128x64_noname2_f, ssd1309_128x64_noname2) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1106_128x64_noname_f, sh1106_128x64_noname) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1107_64x128_f, sh1107_64x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1107_seeed_96x96_f, sh1107_seeed_96x96) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1107_128x128_f, sh1107_128x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1108_160x160_f, sh1108_160x160) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1122_256x64_f, sh1122_256x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_128x32_univision_f, ssd1306_128x32_univision) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7920_s_128x64_f, st7920_s_128x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_64128n_f, st7565_64128n) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1701_ea_dogs102_f, uc1701_ea_dogs102) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1611_ew50850_f, uc1611_ew50850) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1322_nhd_256x64_f, ssd1322_nhd_256x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1322_nhd_128x64_f, ssd1322_nhd_128x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_ea_dogm132_f, st7565_ea_dogm132) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1329_128x96_noname_f, ssd1329_128x96_noname) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_zolen_128x64_f, st7565_zolen_128x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st75256_jlx256128_f, st75256_jlx256128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_96x16_er_f, ssd1306_96x16_er) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ist3020_erc19264_f, ist3020_erc19264) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7588_jlx12864_f, st7588_jlx12864) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1326_er_256x32_f, ssd1326_er_256x32 )\
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1327_seeed_96x96_f, ssd1327_seeed_96x96) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1327_ea_w128128_f, ssd1327_ea_w128128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1327_midas_128x128_f, ssd1327_midas_128x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st75256_jlx172104_f, st75256_jlx172104) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_nhd_c12832_f, st7565_nhd_c12832) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st75256_jlx256160_f, st75256_jlx256160) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st75256_jlx240160_f, st75256_jlx240160) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st75256_jlx25664_f, st75256_jlx25664) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_64x48_er_f, ssd1306_64x48_er) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_pcf8812_96x65_f, pcf8812_96x65) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7567_pi_132x64_f, st7567_pi_132x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7567_jlx12864_f, st7567_jlx12864) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7567_enh_dg128064i_f, st7567_enh_dg128064i) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7567_64x32_f, st7567_64x32) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7586s_s028hn118a_f, st7586s_s028hn118a) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7586s_erc240160_f, st7586s_erc240160) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_pcd8544_84x48_f, pcd8544_84x48) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1106_128x64_vcomh0_f, sh1106_128x64_vcomh0) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_nt7534_tg12864r_f, nt7534_tg12864r) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1701_mini12864_f, uc1701_mini12864) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_t6963_240x128_f, t6963_240x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_t6963_240x64_f, t6963_240x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_t6963_256x64_f, t6963_256x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_t6963_128x64_f, t6963_128x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_t6963_160x80_f, t6963_160x80) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_lc7981_160x80_f, lc7981_160x80) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_lc7981_160x160_f, lc7981_160x160) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_lc7981_240x128_f, lc7981_240x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_lc7981_240x64_f, lc7981_240x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_hx1230_96x68_f, hx1230_96x68) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_lc7981_240x128_f, lc7981_240x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ld7032_60x32_f, ld7032_60x32) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ls013b7dh03_128x128_f, ls013b7dh03_128x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_max7219_32x8_f, max7219_32x8) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_nt7534_tg12864r_f, nt7534_tg12864r) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_pcd8544_84x48_f, pcd8544_84x48) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_pcf8812_96x65_f, pcf8812_96x65) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sed1520_122x32_f, sed1520_122x32) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1107_64x128_f, sh1107_64x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1106_128x64_noname_f, sh1106_128x64_noname) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1106_128x64_vcomh0_f, sh1106_128x64_vcomh0) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1107_128x128_f, sh1107_128x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1108_160x160_f, sh1108_160x160) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1107_seeed_96x96_f, sh1107_seeed_96x96) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_sh1122_256x64_f, sh1122_256x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd0323_os128064_f, ssd0323_os128064) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1305_128x32_noname_f, ssd1305_128x32_noname) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_64x48_er_f, ssd1306_64x48_er) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_96x16_er_f, ssd1306_96x16_er) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_128x32_univision_f, ssd1306_128x32_univision) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_128x64_alt0_f, ssd1306_128x64_alt0) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_128x64_noname_f, ssd1306_128x64_noname) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_128x64_vcomh0_f, ssd1306_128x64_vcomh0) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1309_128x64_noname0_f, ssd1309_128x64_noname0) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1309_128x64_noname2_f, ssd1309_128x64_noname2) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1318_128x96_f, ssd1318_128x96) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1318_128x96_xcp_f, ssd1318_128x96_xcp) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1322_nhd_128x64_f, ssd1322_nhd_128x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1322_nhd_256x64_f, ssd1322_nhd_256x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1325_nhd_128x64_f, ssd1325_nhd_128x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1326_er_256x32_f, ssd1326_er_256x32 )\
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1327_ea_w128128_f, ssd1327_ea_w128128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1327_midas_128x128_f, ssd1327_midas_128x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1327_seeed_96x96_f, ssd1327_seeed_96x96) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1329_128x96_noname_f, ssd1329_128x96_noname) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1606_172x72_f, ssd1606_172x72) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1607_200x200_f, ssd1607_200x200) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1607_gd_200x200_f, ssd1607_gd_200x200) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1607_ws_200x200_f, ssd1607_ws_200x200) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_64128n_f, st7565_64128n) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_ea_dogm132_f, st7565_ea_dogm132) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_ea_dogm128_f, st7565_ea_dogm128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_erc12864_f, st7565_erc12864) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_erc12864_alt_f, st7565_erc12864_alt) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_lm6059_f, st7565_lm6059) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_nhd_c12832_f, st7565_nhd_c12832) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_nhd_c12864_f, st7565_nhd_c12864) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7565_zolen_128x64_f, st7565_zolen_128x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7567_enh_dg128064i_f, st7567_enh_dg128064i) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7567_64x32_f, st7567_64x32) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7567_jlx12864_f, st7567_jlx12864) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7567_pi_132x64_f, st7567_pi_132x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7586s_erc240160_f, st7586s_erc240160) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7586s_s028hn118a_f, st7586s_s028hn118a) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7588_jlx12864_f, st7588_jlx12864) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7920_s_192x32_f, st7920_s_192x32) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st7920_s_128x64_f, st7920_s_128x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st75256_jlx25664_f, st75256_jlx25664) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st75256_jlx172104_f, st75256_jlx172104) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st75256_jlx240160_f, st75256_jlx240160) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st75256_jlx256128_f, st75256_jlx256128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_st75256_jlx256160_f, st75256_jlx256160) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_t6963_128x64_f, t6963_128x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_t6963_160x80_f, t6963_160x80) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_t6963_240x64_f, t6963_240x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_t6963_240x128_f, t6963_240x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_t6963_256x64_f, t6963_256x64) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1601_128x32_f, uc1601_128x32) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1604_jlx19264_f, uc1604_jlx19264) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1608_240x128_f, uc1608_240x128) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1608_erc24064_f, uc1608_erc24064) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1610_ea_dogxl160_f, uc1610_ea_dogxl160) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1611_ea_dogm240_f, uc1611_ea_dogm240) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1611_ea_dogxl240_f, uc1611_ea_dogxl240) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1611_ew50850_f, uc1611_ew50850) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1701_ea_dogs102_f, uc1701_ea_dogs102) \
|
||||
// U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_uc1701_mini12864_f, uc1701_mini12864) \
|
||||
|
||||
#define U8G2_DISPLAY_TABLE_SPI \
|
||||
U8G2_DISPLAY_TABLE_ENTRY(u8g2_Setup_ssd1306_128x64_noname_f, ssd1306_128x64_noname) \
|
||||
|
|
|
@ -7,8 +7,8 @@
|
|||
// this out and enabling the explicitly size, e.g. FLASH_4M. Valid sizes are
|
||||
// FLASH_512K, FLASH_1M, FLASH_2M, FLASH_4M, FLASH_8M, FLASH_16M.
|
||||
|
||||
#define FLASH_AUTOSIZE
|
||||
//#define FLASH_4M
|
||||
//#define FLASH_AUTOSIZE
|
||||
#define FLASH_4M
|
||||
|
||||
|
||||
// The firmware now selects a baudrate of 115,200 by default, but the driver
|
||||
|
@ -41,12 +41,12 @@
|
|||
|
||||
// The Lua Flash Store (LFS) allows you to store Lua code in Flash memory and
|
||||
// the Lua VMS will execute this code directly from flash without needing any
|
||||
// RAM overhead. If you want to enable LFS then set the following define to
|
||||
// the size of the store that you need. This can be any multiple of 4kB up to
|
||||
// a maximum 256Kb.
|
||||
|
||||
//#define LUA_FLASH_STORE 0x10000
|
||||
// RAM overhead. You can now configure LFS directly in the System Partition
|
||||
// Table insted of at compile time. However for backwards compatibility setting
|
||||
// LUA_FLASH_STORE defines the default partition size if the NodeMCU partition
|
||||
// tool is not used.
|
||||
|
||||
//#define LUA_FLASH_STORE 0x10000
|
||||
|
||||
// By default Lua executes the file init.lua at start up. The following
|
||||
// define allows you to replace this with an alternative startup. Warning:
|
||||
|
@ -71,11 +71,14 @@
|
|||
// general, limiting the size of the FS only to what your application needs
|
||||
// gives the fastest start-up and imaging times.
|
||||
|
||||
// You can now configure SPIFFS size and position directly in the System
|
||||
// Partition Table. However backwards compatibility SPIFFS_MAX_FILESYSTEM_SIZE
|
||||
// can be set and this defines the default SPIFFS partition size if the NodeMCU
|
||||
// partition tool is not used. The value (~0x0) means the maximum size remaining.
|
||||
|
||||
#define BUILD_SPIFFS
|
||||
//#define SPIFFS_FIXED_LOCATION 0x100000
|
||||
//#define SPIFFS_MAX_FILESYSTEM_SIZE 0x20000
|
||||
//#define SPIFFS_SIZE_1M_BOUNDARY
|
||||
#define SPIFFS_CACHE 1 // Enable if you use you SPIFFS in R/W mode
|
||||
//#define SPIFFS_MAX_FILESYSTEM_SIZE 0x20000
|
||||
#define SPIFFS_MAX_OPEN_FILES 4 // maximum number of open files for SPIFFS
|
||||
#define FS_OBJ_NAME_LEN 31 // maximum length of a filename
|
||||
|
||||
|
@ -156,6 +159,22 @@
|
|||
#define ENDUSER_SETUP_AP_SSID "SetupGadget"
|
||||
|
||||
|
||||
// I2C software driver partially supports use of GPIO16 (D0) pin for SCL line.
|
||||
// GPIO16 does not support open-drain mode and works in push-pull mode,
|
||||
// so clock stretching will not be possible, because circuit in slave device that
|
||||
// supposed to drive SCL low during stretching will not be capable to hold SCL low.
|
||||
// Also I2C speed will be limited to no more than 400000 Hz (FAST mode).
|
||||
// This define is does not have an effect on an old driver (see I2C_MASTER_OLD_VERSION).
|
||||
|
||||
//#define I2C_MASTER_GPIO16_ENABLE
|
||||
|
||||
// For compatibility reasons you can switch to old version of I2C software driver.
|
||||
// It does not support changing speed, have only one bus id = 0, does not support GPIO16
|
||||
// and works only in Standard(slow) mode with clock speed around 50kHz.
|
||||
|
||||
#define I2C_MASTER_OLD_VERSION
|
||||
|
||||
|
||||
// The following sections are only relevent for those developers who are
|
||||
// developing modules or core Lua changes and configure how extra diagnostics
|
||||
// are enabled in the firmware. These should only be configured if you are
|
||||
|
@ -190,6 +209,24 @@
|
|||
// change this if you have tracked the implications through the Firmware sources
|
||||
// and understand the these.
|
||||
|
||||
#define NODEMCU_EAGLEROM_PARTITION 1
|
||||
#define NODEMCU_IROM0TEXT_PARTITION 2
|
||||
#define NODEMCU_LFS0_PARTITION 3
|
||||
#define NODEMCU_LFS1_PARTITION 4
|
||||
#define NODEMCU_TLSCERT_PARTITION 5
|
||||
#define NODEMCU_SPIFFS0_PARTITION 6
|
||||
#define NODEMCU_SPIFFS1_PARTITION 7
|
||||
|
||||
#ifndef LUA_FLASH_STORE
|
||||
# define LUA_FLASH_STORE 0x0
|
||||
#endif
|
||||
|
||||
#define SPIFFS_FIXED_LOCATION 0x0
|
||||
#ifndef SPIFFS_MAX_FILESYSTEM_SIZE
|
||||
# define SPIFFS_MAX_FILESYSTEM_SIZE 0xFFFFFFFF
|
||||
#endif
|
||||
//#define SPIFFS_SIZE_1M_BOUNDARY
|
||||
|
||||
#define LUA_TASK_PRIO USER_TASK_PRIO_0
|
||||
#define LUA_PROCESS_LINE_SIG 2
|
||||
#define LUA_OPTIMIZE_DEBUG 2
|
||||
|
@ -207,7 +244,7 @@ extern void luaL_dbgbreak(void);
|
|||
#endif
|
||||
#endif
|
||||
|
||||
#if !defined(LUA_NUMBER_INTEGRAL) && defined (LUA_DWORD_ALIGNED_TVALUES)
|
||||
#if !defined(LUA_NUMBER_INTEGRAL) && !defined (LUA_DWORD_ALIGNED_TVALUES)
|
||||
#define LUA_PACK_TVALUES
|
||||
#else
|
||||
#undef LUA_PACK_TVALUES
|
||||
|
@ -218,6 +255,11 @@ extern void luaL_dbgbreak(void);
|
|||
#define COAP_DEBUG
|
||||
#endif /* DEVELOP_VERSION */
|
||||
|
||||
|
||||
#if !defined(LUA_CROSS_COMPILER) && !defined(dbg_printf)
|
||||
extern void dbg_printf(const char *fmt, ...);
|
||||
#endif
|
||||
|
||||
#ifdef NODE_DEBUG
|
||||
#define NODE_DBG dbg_printf
|
||||
#else
|
||||
|
@ -236,12 +278,7 @@ extern void luaL_dbgbreak(void);
|
|||
#define ICACHE_STORE_ATTR __attribute__((aligned(4)))
|
||||
#define ICACHE_STRING(x) ICACHE_STRING2(x)
|
||||
#define ICACHE_STRING2(x) #x
|
||||
#define ICACHE_RAM_ATTR \
|
||||
__attribute__((section(".iram0.text." __FILE__ "." ICACHE_STRING(__LINE__))))
|
||||
#define ICACHE_FLASH_RESERVED_ATTR \
|
||||
__attribute__((section(".irom.reserved." __FILE__ "." ICACHE_STRING(__LINE__)),\
|
||||
used,unused,aligned(INTERNAL_FLASH_SECTOR_SIZE)))
|
||||
|
||||
#define ICACHE_RAM_ATTR __attribute__((section(".iram0.text." __FILE__ "." ICACHE_STRING(__LINE__))))
|
||||
#ifdef GPIO_SAFE_NO_INTR_ENABLE
|
||||
#define NO_INTR_CODE ICACHE_RAM_ATTR __attribute__ ((noinline))
|
||||
#else
|
||||
|
|
|
@ -1,4 +1,5 @@
|
|||
#include "c_types.h"
|
||||
#include <stdint.h>
|
||||
#include <stddef.h>
|
||||
|
||||
#include "user_config.h"
|
||||
|
||||
|
@ -274,8 +275,10 @@
|
|||
//#define MBEDTLS_MEMORY_ALIGN_MULTIPLE 4 /**< Align on multiples of this value */
|
||||
|
||||
//#define MBEDTLS_PLATFORM_STD_MEM_HDR <stdlib.h> /**< Header to include if MBEDTLS_PLATFORM_NO_STD_FUNCTIONS is defined. Don't define if no header is needed. */
|
||||
#define MBEDTLS_PLATFORM_STD_CALLOC pvPortCalloc /**< Default allocator to use, can be undefined */
|
||||
#define MBEDTLS_PLATFORM_STD_FREE vPortFree /**< Default free to use, can be undefined */
|
||||
extern void *mbedtls_calloc_wrap(size_t n, size_t sz);
|
||||
#define MBEDTLS_PLATFORM_STD_CALLOC mbedtls_calloc_wrap /**< Default allocator to use, can be undefined */
|
||||
extern void mbedtls_free_wrap(void *p);
|
||||
#define MBEDTLS_PLATFORM_STD_FREE mbedtls_free_wrap /**< Default free to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_STD_EXIT exit /**< Default exit to use, can be undefined */
|
||||
//#define MBEDTLS_PLATFORM_STD_TIME time /**< Default time to use, can be undefined. MBEDTLS_HAVE_TIME must be enabled */
|
||||
//#define MBEDTLS_PLATFORM_STD_FPRINTF fprintf /**< Default fprintf to use, can be undefined */
|
||||
|
|
|
@ -22,7 +22,6 @@
|
|||
//#define LUA_USE_MODULES_CRON
|
||||
//#define LUA_USE_MODULES_CRYPTO
|
||||
#define LUA_USE_MODULES_DHT
|
||||
//#define LUA_USE_MODULES_DS18B20
|
||||
//#define LUA_USE_MODULES_ENCODER
|
||||
//#define LUA_USE_MODULES_ENDUSER_SETUP // USE_DNS in dhcpserver.h needs to be enabled for this module to work.
|
||||
#define LUA_USE_MODULES_FILE
|
||||
|
@ -43,7 +42,9 @@
|
|||
#define LUA_USE_MODULES_OW
|
||||
//#define LUA_USE_MODULES_PCM
|
||||
//#define LUA_USE_MODULES_PERF
|
||||
//#define LUA_USE_MODULES_PIPE
|
||||
//#define LUA_USE_MODULES_PWM
|
||||
//#define LUA_USE_MODULES_PWM2
|
||||
//#define LUA_USE_MODULES_RC
|
||||
//#define LUA_USE_MODULES_RFSWITCH
|
||||
//#define LUA_USE_MODULES_ROTARY
|
||||
|
|
|
@ -2,6 +2,7 @@
|
|||
#define __USER_VERSION_H__
|
||||
|
||||
#include "version.h" /* ESP firmware header */
|
||||
#include <buildinfo.h>
|
||||
|
||||
#define NODE_VERSION_MAJOR ESP_SDK_VERSION_MAJOR
|
||||
#define NODE_VERSION_MINOR ESP_SDK_VERSION_MINOR
|
||||
|
@ -11,10 +12,12 @@
|
|||
#define NODE_VERSION_STR(x) #x
|
||||
#define NODE_VERSION_XSTR(x) NODE_VERSION_STR(x)
|
||||
|
||||
#define NODE_VERSION "NodeMCU " ESP_SDK_VERSION_STRING "." NODE_VERSION_XSTR(NODE_VERSION_INTERNAL)
|
||||
# define NODE_VERSION "NodeMCU " ESP_SDK_VERSION_STRING "." NODE_VERSION_XSTR(NODE_VERSION_INTERNAL) " " NODE_VERSION_LONG
|
||||
// Leave the space after # in the line above. It busts replacement of NODE_VERSION in the docker build which is not needed anymore with this PR.
|
||||
// Can be removed when the script is adapted
|
||||
|
||||
#ifndef BUILD_DATE
|
||||
#define BUILD_DATE "unspecified"
|
||||
#define BUILD_DATE BUILDINFO_BUILD_DATE
|
||||
#endif
|
||||
|
||||
extern char SDK_VERSION[];
|
||||
|
|
|
@ -36,8 +36,6 @@ endif
|
|||
# Required for each makefile to inherit from the parent
|
||||
#
|
||||
|
||||
INCLUDES := $(INCLUDES) -I $(PDIR)include
|
||||
INCLUDES += -I ./
|
||||
PDIR := ../$(PDIR)
|
||||
sinclude $(PDIR)Makefile
|
||||
|
||||
|
|
|
@ -1,16 +0,0 @@
|
|||
#include "c_ctype.h"
|
||||
#include "c_types.h"
|
||||
|
||||
// int isalnum(int c){}
|
||||
// int isalpha(int c){}
|
||||
// int iscntrl(int c){}
|
||||
// int isdigit(int c){}
|
||||
// // int isgraph(int c){}
|
||||
// int islower(int c){}
|
||||
// int isprint(int c){}
|
||||
// int ispunct(int c){}
|
||||
// int isspace(int c){}
|
||||
// int isupper(int c){}
|
||||
// int isxdigit(int c){}
|
||||
// int tolower(int c){}
|
||||
// int toupper(int c){}
|
|
@ -1,42 +0,0 @@
|
|||
#ifndef _C_CTYPE_H_
|
||||
#define _C_CTYPE_H_
|
||||
|
||||
#if 0
|
||||
int isalnum(int);
|
||||
int isalpha(int);
|
||||
int iscntrl(int);
|
||||
int isdigit(int);
|
||||
// int isgraph(int);
|
||||
int islower(int);
|
||||
int isprint(int);
|
||||
int ispunct(int);
|
||||
int isspace(int);
|
||||
int isupper(int);
|
||||
int isxdigit(int);
|
||||
int tolower(int);
|
||||
int toupper(int);
|
||||
|
||||
#if !defined(__STRICT_ANSI__) || defined(__cplusplus) || __STDC_VERSION__ >= 199901L
|
||||
// int isblank(int);
|
||||
#endif
|
||||
|
||||
#ifndef __STRICT_ANSI__
|
||||
// int isascii(int);
|
||||
// int toascii(int);
|
||||
#define _tolower(__c) ((unsigned char)(__c) - 'A' + 'a')
|
||||
#define _toupper(__c) ((unsigned char)(__c) - 'a' + 'A')
|
||||
#endif
|
||||
|
||||
#define _U 01
|
||||
#define _L 02
|
||||
#define _N 04
|
||||
#define _S 010
|
||||
#define _P 020
|
||||
#define _C 040
|
||||
#define _X 0100
|
||||
#define _B 0200
|
||||
|
||||
/* For C++ backward-compatibility only. */
|
||||
// extern char _ctype_[];
|
||||
#endif
|
||||
#endif /* _C_CTYPE_H_ */
|
|
@ -1,19 +0,0 @@
|
|||
#ifndef __c_errno_h
|
||||
#define __c_errno_h
|
||||
|
||||
#include <errno.h>
|
||||
// #ifndef errno
|
||||
// extern int errno;
|
||||
// #endif
|
||||
|
||||
// #define EDOM 1
|
||||
// #define ERANGE 2
|
||||
// #define EILSEQ 4
|
||||
// #define ESIGNUM 3
|
||||
// #define EINVAL 5
|
||||
// #define ENOMEM 6
|
||||
|
||||
#endif
|
||||
|
||||
/* end of c_errno.h */
|
||||
|
|
@ -1,9 +0,0 @@
|
|||
#ifndef __c_fcntl_h
|
||||
#define __c_fcntl_h
|
||||
|
||||
#include <fcntl.h>
|
||||
|
||||
#endif
|
||||
|
||||
/* end of c_fcntl.h */
|
||||
|
|
@ -1,58 +0,0 @@
|
|||
#ifndef __c_limits_h
|
||||
#define __c_limits_h
|
||||
|
||||
#include <limits.h>
|
||||
#if 0
|
||||
#define CHAR_BIT 8
|
||||
/* max number of bits for smallest object that is not a bit-field (byte) */
|
||||
#define SCHAR_MIN (-128)
|
||||
/* mimimum value for an object of type signed char */
|
||||
#define SCHAR_MAX 127
|
||||
/* maximum value for an object of type signed char */
|
||||
#define UCHAR_MAX 255
|
||||
/* maximum value for an object of type unsigned char */
|
||||
#ifdef __FEATURE_SIGNED_CHAR
|
||||
#define CHAR_MIN (-128)
|
||||
/* minimum value for an object of type char */
|
||||
#define CHAR_MAX 127
|
||||
/* maximum value for an object of type char */
|
||||
#else
|
||||
#define CHAR_MIN 0
|
||||
/* minimum value for an object of type char */
|
||||
#define CHAR_MAX 255
|
||||
/* maximum value for an object of type char */
|
||||
#endif
|
||||
|
||||
#define SHRT_MIN (-0x8000)
|
||||
/* minimum value for an object of type short int */
|
||||
#define SHRT_MAX 0x7fff
|
||||
/* maximum value for an object of type short int */
|
||||
#define USHRT_MAX 65535
|
||||
/* maximum value for an object of type unsigned short int */
|
||||
#define INT_MIN (~0x7fffffff) /* -2147483648 and 0x80000000 are unsigned */
|
||||
/* minimum value for an object of type int */
|
||||
#define INT_MAX 0x7fffffff
|
||||
/* maximum value for an object of type int */
|
||||
#define UINT_MAX 0xffffffffU
|
||||
/* maximum value for an object of type unsigned int */
|
||||
#define LONG_MIN (~0x7fffffffL)
|
||||
/* minimum value for an object of type long int */
|
||||
#define LONG_MAX 0x7fffffffL
|
||||
/* maximum value for an object of type long int */
|
||||
#define ULONG_MAX 0xffffffffUL
|
||||
/* maximum value for an object of type unsigned long int */
|
||||
#if !defined(__STRICT_ANSI__) || (defined(__STDC_VERSION__) && 199901L <= __STDC_VERSION__)
|
||||
#define LLONG_MIN (~0x7fffffffffffffffLL)
|
||||
/* minimum value for an object of type long long int */
|
||||
#define LLONG_MAX 0x7fffffffffffffffLL
|
||||
/* maximum value for an object of type long long int */
|
||||
#define ULLONG_MAX 0xffffffffffffffffULL
|
||||
/* maximum value for an object of type unsigned long int */
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* end of c_limits.h */
|
||||
|
|
@ -1,62 +0,0 @@
|
|||
/*
|
||||
c_locale.h
|
||||
Values appropriate for the formatting of monetary and other
|
||||
numberic quantities.
|
||||
*/
|
||||
|
||||
#ifndef _C_LOCALE_H_
|
||||
#define _C_LOCALE_H_
|
||||
|
||||
#include <locale.h>
|
||||
|
||||
#if 0
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#define LC_ALL 0
|
||||
#define LC_COLLATE 1
|
||||
#define LC_CTYPE 2
|
||||
#define LC_MONETARY 3
|
||||
#define LC_NUMERIC 4
|
||||
#define LC_TIME 5
|
||||
#define LC_MESSAGES 6
|
||||
|
||||
struct lconv
|
||||
{
|
||||
char *decimal_point;
|
||||
char *thousands_sep;
|
||||
char *grouping;
|
||||
char *int_curr_symbol;
|
||||
char *currency_symbol;
|
||||
char *mon_decimal_point;
|
||||
char *mon_thousands_sep;
|
||||
char *mon_grouping;
|
||||
char *positive_sign;
|
||||
char *negative_sign;
|
||||
char int_frac_digits;
|
||||
char frac_digits;
|
||||
char p_cs_precedes;
|
||||
char p_sep_by_space;
|
||||
char n_cs_precedes;
|
||||
char n_sep_by_space;
|
||||
char p_sign_posn;
|
||||
char n_sign_posn;
|
||||
char int_n_cs_precedes;
|
||||
char int_n_sep_by_space;
|
||||
char int_n_sign_posn;
|
||||
char int_p_cs_precedes;
|
||||
char int_p_sep_by_space;
|
||||
char int_p_sign_posn;
|
||||
};
|
||||
|
||||
#ifndef _REENT_ONLY
|
||||
// char *setlocale(int category, const char *locale);
|
||||
struct lconv *localeconv(void);
|
||||
#endif
|
||||
|
||||
// struct _reent;
|
||||
// char *_setlocale_r(struct _reent *, int category, const char *locale);
|
||||
// struct lconv *_localeconv_r(struct _reent *);
|
||||
#endif
|
||||
#endif /* _C_LOCALE_H_ */
|
|
@ -1,62 +0,0 @@
|
|||
#ifndef _C_MATH_H_
|
||||
#define _C_MATH_H_
|
||||
#include <math.h>
|
||||
|
||||
double floor(double);
|
||||
double pow(double, double);
|
||||
|
||||
#if 0
|
||||
#ifndef HUGE_VAL
|
||||
#define HUGE_VAL (1.0e99)
|
||||
#endif
|
||||
|
||||
#ifndef HUGE_VALF
|
||||
#define HUGE_VALF (1.0e999999999F)
|
||||
#endif
|
||||
|
||||
#if !defined(HUGE_VALL) && defined(_HAVE_LONG_DOUBLE)
|
||||
#define HUGE_VALL (1.0e999999999L)
|
||||
#endif
|
||||
|
||||
#if !defined(INFINITY)
|
||||
#define INFINITY (HUGE_VALF)
|
||||
#endif
|
||||
|
||||
|
||||
/* Reentrant ANSI C functions. */
|
||||
|
||||
#ifndef __math_68881
|
||||
// double atan(double);
|
||||
// double cos(double);
|
||||
// double sin(double);
|
||||
// double tan(double);
|
||||
// double tanh(double);
|
||||
// double frexp(double, int *);
|
||||
// double modf(double, double *);
|
||||
// double ceil(double);
|
||||
// double fabs(double);
|
||||
// double floor(double);
|
||||
#endif /* ! defined (__math_68881) */
|
||||
|
||||
/* Non reentrant ANSI C functions. */
|
||||
|
||||
#ifndef _REENT_ONLY
|
||||
#ifndef __math_68881
|
||||
// double acos(double);
|
||||
// double asin(double);
|
||||
// double atan2(double, double);
|
||||
// double cosh(double);
|
||||
// double sinh(double);
|
||||
// double exp(double);
|
||||
// double ldexp(double, int);
|
||||
// double log(double);
|
||||
// double log10(double);
|
||||
// double pow(double, double);
|
||||
// double sqrt(double);
|
||||
// double fmod(double, double);
|
||||
#endif /* ! defined (__math_68881) */
|
||||
#endif /* ! defined (_REENT_ONLY) */
|
||||
|
||||
#endif
|
||||
|
||||
#endif /* _MATH_H_ */
|
|
@ -1,6 +0,0 @@
|
|||
#ifndef _C_SIGNAL_H_
|
||||
#define _C_SIGNAL_H_
|
||||
|
||||
#include <signal.h>
|
||||
|
||||
#endif /* _C_SIGNAL_H_ */
|
|
@ -1,22 +0,0 @@
|
|||
#ifndef __c_stdarg_h
|
||||
#define __c_stdarg_h
|
||||
|
||||
#if defined(__GNUC__)
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
#else
|
||||
|
||||
typedef char * va_list;
|
||||
|
||||
#define _INTSIZEOF(n) ((sizeof(n) + sizeof(int) - 1) & ~(sizeof(int) - 1))
|
||||
|
||||
#define va_start(ap,v) (ap = (va_list)&v + _INTSIZEOF(v))
|
||||
#define va_arg(ap,t) (*(t *)((ap += _INTSIZEOF(t)) - _INTSIZEOF(t)))
|
||||
#define va_end(ap) (ap = (va_list)0)
|
||||
|
||||
#endif
|
||||
|
||||
#endif
|
||||
|
||||
/* end of c_stdarg.h */
|
|
@ -1,23 +0,0 @@
|
|||
#ifndef __c_stddef_h
|
||||
#define __c_stddef_h
|
||||
|
||||
typedef signed int ptrdiff_t;
|
||||
|
||||
#if !defined(offsetof)
|
||||
#define offsetof(s, m) (size_t)&(((s *)0)->m)
|
||||
#endif
|
||||
|
||||
#if !defined(__size_t)
|
||||
#define __size_t 1
|
||||
typedef unsigned int size_t; /* others (e.g. <stdio.h>) also define */
|
||||
/* the unsigned integral type of the result of the sizeof operator. */
|
||||
#endif
|
||||
|
||||
#undef NULL /* others (e.g. <stdio.h>) also define */
|
||||
#define NULL 0
|
||||
/* null pointer constant. */
|
||||
|
||||
#endif
|
||||
|
||||
/* end of c_stddef.h */
|
||||
|
|
@ -1,273 +0,0 @@
|
|||
#ifndef __c_stdint_h
|
||||
#define __c_stdint_h
|
||||
|
||||
#include "c_types.h"
|
||||
#if 0
|
||||
/*
|
||||
* Depending on compiler version __int64 or __INT64_TYPE__ should be defined.
|
||||
*/
|
||||
#ifndef __int64
|
||||
#ifdef __INT64_TYPE__
|
||||
#define __int64 __INT64_TYPE__
|
||||
#else
|
||||
#define __int64 long long
|
||||
#endif
|
||||
/* On some architectures neither of these may be defined - if so, fall
|
||||
through and error out if used. */
|
||||
#endif
|
||||
|
||||
#ifndef __STDINT_DECLS
|
||||
#define __STDINT_DECLS
|
||||
|
||||
#undef __CLIBNS
|
||||
|
||||
#ifdef __cplusplus
|
||||
namespace std {
|
||||
#define __CLIBNS std::
|
||||
extern "C" {
|
||||
#else
|
||||
#define __CLIBNS
|
||||
#endif /* __cplusplus */
|
||||
|
||||
|
||||
/*
|
||||
* 'signed' is redundant below, except for 'signed char' and if
|
||||
* the typedef is used to declare a bitfield.
|
||||
* '__int64' is used instead of 'long long' so that this header
|
||||
* can be used in --strict mode.
|
||||
*/
|
||||
|
||||
/* 7.18.1.1 */
|
||||
|
||||
/* exact-width signed integer types */
|
||||
typedef signed char int8_t;
|
||||
typedef signed short int int16_t;
|
||||
typedef signed int int32_t;
|
||||
typedef signed __int64 int64_t;
|
||||
|
||||
/* exact-width unsigned integer types */
|
||||
typedef unsigned char uint8_t;
|
||||
typedef unsigned short int uint16_t;
|
||||
typedef unsigned int uint32_t;
|
||||
typedef unsigned __int64 uint64_t;
|
||||
|
||||
/* 7.18.1.2 */
|
||||
|
||||
/* smallest type of at least n bits */
|
||||
/* minimum-width signed integer types */
|
||||
typedef signed char int_least8_t;
|
||||
typedef signed short int int_least16_t;
|
||||
typedef signed int int_least32_t;
|
||||
typedef signed __int64 int_least64_t;
|
||||
|
||||
/* minimum-width unsigned integer types */
|
||||
typedef unsigned char uint_least8_t;
|
||||
typedef unsigned short int uint_least16_t;
|
||||
typedef unsigned int uint_least32_t;
|
||||
typedef unsigned __int64 uint_least64_t;
|
||||
|
||||
/* 7.18.1.3 */
|
||||
|
||||
/* fastest minimum-width signed integer types */
|
||||
typedef signed int int_fast8_t;
|
||||
typedef signed int int_fast16_t;
|
||||
typedef signed int int_fast32_t;
|
||||
typedef signed __int64 int_fast64_t;
|
||||
|
||||
/* fastest minimum-width unsigned integer types */
|
||||
typedef unsigned int uint_fast8_t;
|
||||
typedef unsigned int uint_fast16_t;
|
||||
typedef unsigned int uint_fast32_t;
|
||||
typedef unsigned __int64 uint_fast64_t;
|
||||
|
||||
/* 7.18.1.4 integer types capable of holding object pointers */
|
||||
typedef signed int intptr_t;
|
||||
typedef unsigned int uintptr_t;
|
||||
|
||||
/* 7.18.1.5 greatest-width integer types */
|
||||
typedef signed __int64 intmax_t;
|
||||
typedef unsigned __int64 uintmax_t;
|
||||
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_LIMIT_MACROS)
|
||||
|
||||
/* 7.18.2.1 */
|
||||
|
||||
/* minimum values of exact-width signed integer types */
|
||||
#define INT8_MIN -128
|
||||
#define INT16_MIN -32768
|
||||
#define INT32_MIN (~0x7fffffff) /* -2147483648 is unsigned */
|
||||
#define INT64_MIN __ESCAPE__(~0x7fffffffffffffffll) /* -9223372036854775808 is unsigned */
|
||||
|
||||
/* maximum values of exact-width signed integer types */
|
||||
#define INT8_MAX 127
|
||||
#define INT16_MAX 32767
|
||||
#define INT32_MAX 2147483647
|
||||
#define INT64_MAX __ESCAPE__(9223372036854775807ll)
|
||||
|
||||
/* maximum values of exact-width unsigned integer types */
|
||||
#define UINT8_MAX 255
|
||||
#define UINT16_MAX 65535
|
||||
#define UINT32_MAX 4294967295u
|
||||
#define UINT64_MAX __ESCAPE__(18446744073709551615ull)
|
||||
|
||||
/* 7.18.2.2 */
|
||||
|
||||
/* minimum values of minimum-width signed integer types */
|
||||
#define INT_LEAST8_MIN -128
|
||||
#define INT_LEAST16_MIN -32768
|
||||
#define INT_LEAST32_MIN (~0x7fffffff)
|
||||
#define INT_LEAST64_MIN __ESCAPE__(~0x7fffffffffffffffll)
|
||||
|
||||
/* maximum values of minimum-width signed integer types */
|
||||
#define INT_LEAST8_MAX 127
|
||||
#define INT_LEAST16_MAX 32767
|
||||
#define INT_LEAST32_MAX 2147483647
|
||||
#define INT_LEAST64_MAX __ESCAPE__(9223372036854775807ll)
|
||||
|
||||
/* maximum values of minimum-width unsigned integer types */
|
||||
#define UINT_LEAST8_MAX 255
|
||||
#define UINT_LEAST16_MAX 65535
|
||||
#define UINT_LEAST32_MAX 4294967295u
|
||||
#define UINT_LEAST64_MAX __ESCAPE__(18446744073709551615ull)
|
||||
|
||||
/* 7.18.2.3 */
|
||||
|
||||
/* minimum values of fastest minimum-width signed integer types */
|
||||
#define INT_FAST8_MIN (~0x7fffffff)
|
||||
#define INT_FAST16_MIN (~0x7fffffff)
|
||||
#define INT_FAST32_MIN (~0x7fffffff)
|
||||
#define INT_FAST64_MIN __ESCAPE__(~0x7fffffffffffffffll)
|
||||
|
||||
/* maximum values of fastest minimum-width signed integer types */
|
||||
#define INT_FAST8_MAX 2147483647
|
||||
#define INT_FAST16_MAX 2147483647
|
||||
#define INT_FAST32_MAX 2147483647
|
||||
#define INT_FAST64_MAX __ESCAPE__(9223372036854775807ll)
|
||||
|
||||
/* maximum values of fastest minimum-width unsigned integer types */
|
||||
#define UINT_FAST8_MAX 4294967295u
|
||||
#define UINT_FAST16_MAX 4294967295u
|
||||
#define UINT_FAST32_MAX 4294967295u
|
||||
#define UINT_FAST64_MAX __ESCAPE__(18446744073709551615ull)
|
||||
|
||||
/* 7.18.2.4 */
|
||||
|
||||
/* minimum value of pointer-holding signed integer type */
|
||||
#define INTPTR_MIN (~0x7fffffff)
|
||||
|
||||
/* maximum value of pointer-holding signed integer type */
|
||||
#define INTPTR_MAX 2147483647
|
||||
|
||||
/* maximum value of pointer-holding unsigned integer type */
|
||||
#define UINTPTR_MAX 4294967295u
|
||||
|
||||
/* 7.18.2.5 */
|
||||
|
||||
/* minimum value of greatest-width signed integer type */
|
||||
#define INTMAX_MIN __ESCAPE__(~0x7fffffffffffffffll)
|
||||
|
||||
/* maximum value of greatest-width signed integer type */
|
||||
#define INTMAX_MAX __ESCAPE__(9223372036854775807ll)
|
||||
|
||||
/* maximum value of greatest-width unsigned integer type */
|
||||
#define UINTMAX_MAX __ESCAPE__(18446744073709551615ull)
|
||||
|
||||
/* 7.18.3 */
|
||||
|
||||
/* limits of ptrdiff_t */
|
||||
#define PTRDIFF_MIN (~0x7fffffff)
|
||||
#define PTRDIFF_MAX 2147483647
|
||||
|
||||
/* limits of sig_atomic_t */
|
||||
#define SIG_ATOMIC_MIN (~0x7fffffff)
|
||||
#define SIG_ATOMIC_MAX 2147483647
|
||||
|
||||
/* limit of size_t */
|
||||
#define SIZE_MAX 4294967295u
|
||||
|
||||
/* limits of wchar_t */
|
||||
/* NB we have to undef and redef because they're defined in both
|
||||
* stdint.h and wchar.h */
|
||||
#undef WCHAR_MIN
|
||||
#undef WCHAR_MAX
|
||||
|
||||
#if defined(__WCHAR32) || (defined(__ARM_SIZEOF_WCHAR_T) && __ARM_SIZEOF_WCHAR_T == 4)
|
||||
#define WCHAR_MIN 0
|
||||
#define WCHAR_MAX 0xffffffffU
|
||||
#else
|
||||
#define WCHAR_MIN 0
|
||||
#define WCHAR_MAX 65535
|
||||
#endif
|
||||
|
||||
/* limits of wint_t */
|
||||
#define WINT_MIN (~0x7fffffff)
|
||||
#define WINT_MAX 2147483647
|
||||
|
||||
#endif /* __STDC_LIMIT_MACROS */
|
||||
|
||||
#if !defined(__cplusplus) || defined(__STDC_CONSTANT_MACROS)
|
||||
|
||||
/* 7.18.4.1 macros for minimum-width integer constants */
|
||||
#define INT8_C(x) (x)
|
||||
#define INT16_C(x) (x)
|
||||
#define INT32_C(x) (x)
|
||||
#define INT64_C(x) __ESCAPE__(x ## ll)
|
||||
|
||||
#define UINT8_C(x) (x ## u)
|
||||
#define UINT16_C(x) (x ## u)
|
||||
#define UINT32_C(x) (x ## u)
|
||||
#define UINT64_C(x) __ESCAPE__(x ## ull)
|
||||
|
||||
/* 7.18.4.2 macros for greatest-width integer constants */
|
||||
#define INTMAX_C(x) __ESCAPE__(x ## ll)
|
||||
#define UINTMAX_C(x) __ESCAPE__(x ## ull)
|
||||
|
||||
#endif /* __STDC_CONSTANT_MACROS */
|
||||
|
||||
#ifdef __cplusplus
|
||||
} /* extern "C" */
|
||||
} /* namespace std */
|
||||
#endif /* __cplusplus */
|
||||
#endif /* __STDINT_DECLS */
|
||||
|
||||
#ifdef __cplusplus
|
||||
#ifndef __STDINT_NO_EXPORTS
|
||||
using ::std::int8_t;
|
||||
using ::std::int16_t;
|
||||
using ::std::int32_t;
|
||||
using ::std::int64_t;
|
||||
using ::std::uint8_t;
|
||||
using ::std::uint16_t;
|
||||
using ::std::uint32_t;
|
||||
using ::std::uint64_t;
|
||||
using ::std::int_least8_t;
|
||||
using ::std::int_least16_t;
|
||||
using ::std::int_least32_t;
|
||||
using ::std::int_least64_t;
|
||||
using ::std::uint_least8_t;
|
||||
using ::std::uint_least16_t;
|
||||
using ::std::uint_least32_t;
|
||||
using ::std::uint_least64_t;
|
||||
using ::std::int_fast8_t;
|
||||
using ::std::int_fast16_t;
|
||||
using ::std::int_fast32_t;
|
||||
using ::std::int_fast64_t;
|
||||
using ::std::uint_fast8_t;
|
||||
using ::std::uint_fast16_t;
|
||||
using ::std::uint_fast32_t;
|
||||
using ::std::uint_fast64_t;
|
||||
using ::std::intptr_t;
|
||||
using ::std::uintptr_t;
|
||||
using ::std::intmax_t;
|
||||
using ::std::uintmax_t;
|
||||
#endif
|
||||
#endif /* __cplusplus */
|
||||
#endif
|
||||
|
||||
#endif /* __c_stdint_h */
|
||||
|
||||
/* end of c_stdint.h */
|
||||
|
||||
|
||||
|
|
@ -1,105 +0,0 @@
|
|||
#ifndef _C_STDIO_H_
|
||||
#define _C_STDIO_H_
|
||||
|
||||
#define __need_size_t
|
||||
|
||||
#include "c_stddef.h"
|
||||
#include "osapi.h"
|
||||
// #include "driver/uart.h"
|
||||
|
||||
// #define __need___va_list
|
||||
//#include "c_stdarg.h"
|
||||
|
||||
//struct __sFILE{
|
||||
// int _r; /* read space left for getc() */
|
||||
// int _w; /* write space left for putc() */
|
||||
//};
|
||||
// typedef struct __sFILE __FILE;
|
||||
// typedef __FILE FILE;
|
||||
|
||||
extern int c_stdin;
|
||||
extern int c_stdout;
|
||||
extern int c_stderr;
|
||||
|
||||
// #define _IOFBF 0 /* setvbuf should set fully buffered */
|
||||
// #define _IOLBF 1 /* setvbuf should set line buffered */
|
||||
// #define _IONBF 2 /* setvbuf should set unbuffered */
|
||||
|
||||
// #ifndef NULL
|
||||
// #define NULL 0
|
||||
// #endif
|
||||
|
||||
#define EOF (-1)
|
||||
|
||||
#ifdef __BUFSIZ__
|
||||
#define BUFSIZ __BUFSIZ__
|
||||
#else
|
||||
#define BUFSIZ 1024
|
||||
#endif
|
||||
|
||||
#ifndef SEEK_SET
|
||||
#define SEEK_SET 0 /* set file offset to offset */
|
||||
#endif
|
||||
#ifndef SEEK_CUR
|
||||
#define SEEK_CUR 1 /* set file offset to current plus offset */
|
||||
#endif
|
||||
#ifndef SEEK_END
|
||||
#define SEEK_END 2 /* set file offset to EOF plus offset */
|
||||
#endif
|
||||
|
||||
// #define c_malloc os_malloc
|
||||
// #define c_zalloc os_zalloc
|
||||
// #define c_free os_free
|
||||
|
||||
extern void output_redirect(const char *str);
|
||||
#define c_puts output_redirect
|
||||
|
||||
// #define c_printf os_printf
|
||||
// int c_printf(const char *c, ...);
|
||||
#if defined( LUA_NUMBER_INTEGRAL )
|
||||
#define c_sprintf os_sprintf
|
||||
#else
|
||||
#include "c_stdarg.h"
|
||||
int c_sprintf(char* s,const char *fmt, ...);
|
||||
#endif
|
||||
|
||||
extern void dbg_printf(const char *fmt, ...) __attribute__ ((format (printf, 1, 2)));
|
||||
|
||||
#define c_vsprintf ets_vsprintf
|
||||
#define c_printf(...) do { \
|
||||
unsigned char __print_buf[BUFSIZ]; \
|
||||
c_sprintf(__print_buf, __VA_ARGS__); \
|
||||
c_puts(__print_buf); \
|
||||
} while(0)
|
||||
|
||||
// #define c_getc ets_getc
|
||||
// #define c_getchar ets_getc
|
||||
// note: contact esp to ensure the real getchar function..
|
||||
|
||||
// FILE *c_fopen(const char *_name, const char *_type);
|
||||
// FILE *c_freopen(const char *, const char *, FILE *);
|
||||
// FILE *c_tmpfile(void);
|
||||
|
||||
// int c_putchar(int);
|
||||
// int c_printf(const char *, ...);
|
||||
// int c_sprintf(char *, const char *, ...);
|
||||
// int c_getc(FILE *);
|
||||
|
||||
// int c_ungetc(int, FILE *);
|
||||
|
||||
// int c_fprintf(FILE *, const char *, ...);
|
||||
// int c_fscanf(FILE *, const char *, ...);
|
||||
// int c_fclose(FILE *);
|
||||
// int c_fflush(FILE *);
|
||||
// int c_setvbuf(FILE *, char *, int, size_t);
|
||||
// void c_clearerr(FILE *);
|
||||
// int c_fseek(FILE *, long, int);
|
||||
// long c_ftell( FILE *);
|
||||
// int c_fputs(const char *, FILE *);
|
||||
// char *c_fgets(char *, int, FILE *);
|
||||
// size_t c_fread(void *, size_t _size, size_t _n, FILE *);
|
||||
// size_t c_fwrite(const void * , size_t _size, size_t _n, FILE *);
|
||||
// int c_feof(FILE *);
|
||||
// int c_ferror(FILE *);
|
||||
|
||||
#endif /* _C_STDIO_H_ */
|
|
@ -1,64 +0,0 @@
|
|||
/*
|
||||
* c_stdlib.h
|
||||
*
|
||||
* Definitions for common types, variables, and functions.
|
||||
*/
|
||||
|
||||
#ifndef _C_STDLIB_H_
|
||||
#define _C_STDLIB_H_
|
||||
|
||||
#include "c_stddef.h"
|
||||
#include "mem.h"
|
||||
|
||||
#include <stdlib.h>
|
||||
|
||||
#define EXIT_FAILURE 1
|
||||
#define EXIT_SUCCESS 0
|
||||
|
||||
#define __INT_MAX__ 2147483647
|
||||
#undef __RAND_MAX
|
||||
#if __INT_MAX__ == 32767
|
||||
#define __RAND_MAX 32767
|
||||
#else
|
||||
#define __RAND_MAX 0x7fffffff
|
||||
#endif
|
||||
#define RAND_MAX __RAND_MAX
|
||||
|
||||
#ifndef mem_realloc
|
||||
#define mem_realloc pvPortRealloc
|
||||
#endif
|
||||
#ifndef os_realloc
|
||||
#define os_realloc(p, s) mem_realloc((p), (s))
|
||||
#endif
|
||||
|
||||
#define c_free os_free
|
||||
#define c_malloc os_malloc
|
||||
#define c_zalloc os_zalloc
|
||||
#define c_realloc os_realloc
|
||||
|
||||
#define c_abs abs
|
||||
#define c_atoi atoi
|
||||
//#define c_strtod strtod
|
||||
#define c_strtol strtol
|
||||
#define c_strtoul strtoul
|
||||
|
||||
// int c_abs(int);
|
||||
|
||||
// void c_exit(int);
|
||||
|
||||
//const char *c_getenv(const char *__string);
|
||||
|
||||
// void *c_malloc(size_t __size);
|
||||
// void *c_zalloc(size_t __size);
|
||||
// void c_free(void *);
|
||||
|
||||
// int c_rand(void);
|
||||
// void c_srand(unsigned int __seed);
|
||||
|
||||
// int c_atoi(const char *__nptr);
|
||||
double c_strtod(const char *__n, char **__end_PTR);
|
||||
// // long c_strtol(const char *__n, char **__end_PTR, int __base);
|
||||
// unsigned long c_strtoul(const char *__n, char **__end_PTR, int __base);
|
||||
// // long long c_strtoll(const char *__n, char **__end_PTR, int __base);
|
||||
|
||||
#endif /* _C_STDLIB_H_ */
|
|
@ -1,129 +0,0 @@
|
|||
#include "c_string.h"
|
||||
#include "c_stdlib.h"
|
||||
|
||||
// const char *c_strstr(const char * __s1, const char * __s2){
|
||||
// }
|
||||
|
||||
// char *c_strncat(char * s1, const char * s2, size_t n){
|
||||
// }
|
||||
|
||||
// size_t c_strcspn(const char * s1, const char * s2){
|
||||
// }
|
||||
|
||||
// const char *c_strpbrk(const char * s1, const char * s2){
|
||||
// }
|
||||
|
||||
// int c_strcoll(const char * s1, const char * s2){
|
||||
// }
|
||||
//
|
||||
char *c_strdup(const char *c) {
|
||||
int len = os_strlen(c) + 1;
|
||||
char *ret = os_malloc(len);
|
||||
if (ret) {
|
||||
memcpy(ret, c, len);
|
||||
}
|
||||
return ret;
|
||||
}
|
||||
|
||||
/* $OpenBSD: strlcpy.c,v 1.8 2003/06/17 21:56:24 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Copy src to string dst of size siz. At most siz-1 characters
|
||||
* will be copied. Always NUL terminates (unless siz == 0).
|
||||
* Returns strlen(src); if retval >= siz, truncation occurred.
|
||||
*/
|
||||
size_t
|
||||
c_strlcpy(char *dst, const char *src, size_t siz)
|
||||
{
|
||||
register char *d = dst;
|
||||
register const char *s = src;
|
||||
register size_t n = siz;
|
||||
|
||||
/* Copy as many bytes as will fit */
|
||||
if (n != 0 && --n != 0) {
|
||||
do {
|
||||
if ((*d++ = *s++) == 0)
|
||||
break;
|
||||
} while (--n != 0);
|
||||
}
|
||||
|
||||
/* Not enough room in dst, add NUL and traverse rest of src */
|
||||
if (n == 0) {
|
||||
if (siz != 0)
|
||||
*d = '\0'; /* NUL-terminate dst */
|
||||
while (*s++)
|
||||
;
|
||||
}
|
||||
|
||||
return(s - src - 1); /* count does not include NUL */
|
||||
}
|
||||
|
||||
/* $OpenBSD: strlcat.c,v 1.11 2003/06/17 21:56:24 millert Exp $ */
|
||||
|
||||
/*
|
||||
* Copyright (c) 1998 Todd C. Miller <Todd.Miller@courtesan.com>
|
||||
*
|
||||
* Permission to use, copy, modify, and distribute this software for any
|
||||
* purpose with or without fee is hereby granted, provided that the above
|
||||
* copyright notice and this permission notice appear in all copies.
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS" AND THE AUTHOR DISCLAIMS ALL WARRANTIES
|
||||
* WITH REGARD TO THIS SOFTWARE INCLUDING ALL IMPLIED WARRANTIES OF
|
||||
* MERCHANTABILITY AND FITNESS. IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR
|
||||
* ANY SPECIAL, DIRECT, INDIRECT, OR CONSEQUENTIAL DAMAGES OR ANY DAMAGES
|
||||
* WHATSOEVER RESULTING FROM LOSS OF USE, DATA OR PROFITS, WHETHER IN AN
|
||||
* ACTION OF CONTRACT, NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF
|
||||
* OR IN CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
|
||||
*/
|
||||
|
||||
/*
|
||||
* Appends src to string dst of size siz (unlike strncat, siz is the
|
||||
* full size of dst, not space left). At most siz-1 characters
|
||||
* will be copied. Always NUL terminates (unless siz <= strlen(dst)).
|
||||
* Returns strlen(src) + MIN(siz, strlen(initial dst)).
|
||||
* If retval >= siz, truncation occurred.
|
||||
*/
|
||||
size_t
|
||||
c_strlcat(char *dst, const char *src, size_t siz)
|
||||
{
|
||||
register char *d = dst;
|
||||
register const char *s = src;
|
||||
register size_t n = siz;
|
||||
size_t dlen;
|
||||
|
||||
/* Find the end of dst and adjust bytes left but don't go past end */
|
||||
while (n-- != 0 && *d != '\0')
|
||||
d++;
|
||||
dlen = d - dst;
|
||||
n = siz - dlen;
|
||||
|
||||
if (n == 0)
|
||||
return(dlen + strlen(s));
|
||||
while (*s != '\0') {
|
||||
if (n != 1) {
|
||||
*d++ = *s;
|
||||
n--;
|
||||
}
|
||||
s++;
|
||||
}
|
||||
*d = '\0';
|
||||
|
||||
return(dlen + (s - src)); /* count does not include NUL */
|
||||
}
|
||||
|
|
@ -1,49 +0,0 @@
|
|||
/*
|
||||
* c_string.h
|
||||
*
|
||||
* Definitions for memory and string functions.
|
||||
*/
|
||||
|
||||
#ifndef _C_STRING_H_
|
||||
#define _C_STRING_H_
|
||||
#include "c_stddef.h"
|
||||
#include "osapi.h"
|
||||
|
||||
#ifndef NULL
|
||||
#define NULL 0
|
||||
#endif
|
||||
|
||||
#define c_memcmp os_memcmp
|
||||
#define c_memcpy os_memcpy
|
||||
#define c_memset os_memset
|
||||
|
||||
#define c_strcat os_strcat
|
||||
#define c_strchr os_strchr
|
||||
#define c_strcmp os_strcmp
|
||||
#define c_strcpy os_strcpy
|
||||
#define c_strlen os_strlen
|
||||
#define c_strncmp os_strncmp
|
||||
#define c_strncpy os_strncpy
|
||||
// #define c_strstr os_strstr
|
||||
#define c_strncasecmp c_strncmp
|
||||
|
||||
#define c_strstr strstr
|
||||
#define c_strncat strncat
|
||||
#define c_strcspn strcspn
|
||||
#define c_strpbrk strpbrk
|
||||
#define c_strcoll strcoll
|
||||
#define c_strrchr strrchr
|
||||
|
||||
// const char *c_strstr(const char * __s1, const char * __s2);
|
||||
// char *c_strncat(char * __restrict /*s1*/, const char * __restrict /*s2*/, size_t n);
|
||||
// size_t c_strcspn(const char * s1, const char * s2);
|
||||
// const char *c_strpbrk(const char * /*s1*/, const char * /*s2*/);
|
||||
// int c_strcoll(const char * /*s1*/, const char * /*s2*/);
|
||||
//
|
||||
|
||||
extern size_t c_strlcpy(char *dst, const char *src, size_t siz);
|
||||
extern size_t c_strlcat(char *dst, const char *src, size_t siz);
|
||||
extern char *c_strdup(const char *src);
|
||||
|
||||
|
||||
#endif /* _C_STRING_H_ */
|
|
@ -1,6 +1,5 @@
|
|||
#include "c_math.h"
|
||||
#include "c_types.h"
|
||||
#include "user_config.h"
|
||||
#include <math.h>
|
||||
#include <stdbool.h>
|
||||
|
||||
double floor(double x)
|
||||
{
|
||||
|
@ -11,7 +10,7 @@ double floor(double x)
|
|||
#define MINEXP -2047 /* (MIN_EXP * 16) - 1 */
|
||||
#define HUGE MAXFLOAT
|
||||
|
||||
double a1[] ICACHE_STORE_ATTR ICACHE_RODATA_ATTR =
|
||||
static const double a1[] =
|
||||
{
|
||||
1.0,
|
||||
0.95760328069857365,
|
||||
|
@ -31,7 +30,7 @@ double a1[] ICACHE_STORE_ATTR ICACHE_RODATA_ATTR =
|
|||
0.52213689121370692,
|
||||
0.50000000000000000
|
||||
};
|
||||
double a2[] ICACHE_STORE_ATTR ICACHE_RODATA_ATTR =
|
||||
static const double a2[] =
|
||||
{
|
||||
0.24114209503420288E-17,
|
||||
0.92291566937243079E-18,
|
||||
|
@ -42,18 +41,19 @@ double a2[] ICACHE_STORE_ATTR ICACHE_RODATA_ATTR =
|
|||
0.29306999570789681E-17,
|
||||
0.11260851040933474E-17
|
||||
};
|
||||
double p1 ICACHE_STORE_ATTR ICACHE_RODATA_ATTR = 0.833333333333332114e-1;
|
||||
double p2 ICACHE_STORE_ATTR ICACHE_RODATA_ATTR = 0.125000000005037992e-1;
|
||||
double p3 ICACHE_STORE_ATTR ICACHE_RODATA_ATTR = 0.223214212859242590e-2;
|
||||
double p4 ICACHE_STORE_ATTR ICACHE_RODATA_ATTR = 0.434457756721631196e-3;
|
||||
double q1 ICACHE_STORE_ATTR ICACHE_RODATA_ATTR = 0.693147180559945296e0;
|
||||
double q2 ICACHE_STORE_ATTR ICACHE_RODATA_ATTR = 0.240226506959095371e0;
|
||||
double q3 ICACHE_STORE_ATTR ICACHE_RODATA_ATTR = 0.555041086640855953e-1;
|
||||
double q4 ICACHE_STORE_ATTR ICACHE_RODATA_ATTR = 0.961812905951724170e-2;
|
||||
double q5 ICACHE_STORE_ATTR ICACHE_RODATA_ATTR = 0.133335413135857847e-2;
|
||||
double q6 ICACHE_STORE_ATTR ICACHE_RODATA_ATTR = 0.154002904409897646e-3;
|
||||
double q7 ICACHE_STORE_ATTR ICACHE_RODATA_ATTR = 0.149288526805956082e-4;
|
||||
double k ICACHE_STORE_ATTR ICACHE_RODATA_ATTR = 0.442695040888963407;
|
||||
static const double
|
||||
p1 = 0.833333333333332114e-1,
|
||||
p2 = 0.125000000005037992e-1,
|
||||
p3 = 0.223214212859242590e-2,
|
||||
p4 = 0.434457756721631196e-3,
|
||||
q1 = 0.693147180559945296e0,
|
||||
q2 = 0.240226506959095371e0,
|
||||
q3 = 0.555041086640855953e-1,
|
||||
q4 = 0.961812905951724170e-2,
|
||||
q5 = 0.133335413135857847e-2,
|
||||
q6 = 0.154002904409897646e-3,
|
||||
q7 = 0.149288526805956082e-4,
|
||||
k = 0.442695040888963407;
|
||||
|
||||
double pow(double x, double y)
|
||||
{
|
||||
|
@ -134,103 +134,3 @@ double pow(double x, double y)
|
|||
double res = ldexp(z, m);
|
||||
return flipsignal ? -res : res;
|
||||
}
|
||||
|
||||
#if 0
|
||||
#ifndef __math_68881
|
||||
double atan(double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
double cos(double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
double sin(double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
double tan(double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
double tanh(double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
double frexp(double x, int *y)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
double modf(double x, double *y)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
double ceil(double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
double fabs(double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
double floor(double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
#endif /* ! defined (__math_68881) */
|
||||
|
||||
/* Non reentrant ANSI C functions. */
|
||||
|
||||
#ifndef _REENT_ONLY
|
||||
#ifndef __math_68881
|
||||
double acos(double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
double asin(double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
double atan2(double x, double y)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
double cosh(double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
double sinh(double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
double exp(double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
double ldexp(double x, int y)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
double log(double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
double log10(double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
double pow(double x, double y)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
double sqrt(double x)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
double fmod(double x, double y)
|
||||
{
|
||||
return x;
|
||||
}
|
||||
#endif /* ! defined (__math_68881) */
|
||||
#endif /* ! defined (_REENT_ONLY) */
|
||||
#endif
|
|
@ -1,61 +1,28 @@
|
|||
#include "c_stdio.h"
|
||||
// #include "driver/uart.h"
|
||||
#include <stdio.h>
|
||||
|
||||
int c_stdin = 999;
|
||||
int c_stdout = 1000;
|
||||
int c_stderr = 1001;
|
||||
|
||||
// FILE *c_fopen(const char *_name, const char *_type){
|
||||
// }
|
||||
// FILE *c_freopen(const char *_name, const char *_type, FILE *_f){
|
||||
// }
|
||||
// FILE *c_tmpfile(void){
|
||||
// }
|
||||
|
||||
// int c_putchar(int c){
|
||||
// }
|
||||
|
||||
// int c_printf(const char *c, ...){
|
||||
// }
|
||||
|
||||
// int c_sprintf(char *c, const char *s, ...){
|
||||
// }
|
||||
|
||||
// int c_fprintf(FILE *f, const char *s, ...){
|
||||
// }
|
||||
// int c_fscanf(FILE *f, const char *s, ...){
|
||||
// }
|
||||
// int c_fclose(FILE *f){
|
||||
// }
|
||||
// int c_fflush(FILE *f){
|
||||
// }
|
||||
// int c_setvbuf(FILE *f, char *c, int d, size_t t){
|
||||
// }
|
||||
// void c_clearerr(FILE *f){
|
||||
// }
|
||||
// int c_fseek(FILE *f, long l, int d){
|
||||
// }
|
||||
// long c_ftell( FILE *f){
|
||||
// }
|
||||
// int c_fputs(const char *c, FILE *f){
|
||||
// }
|
||||
// char *c_fgets(char *c, int d, FILE *f){
|
||||
// }
|
||||
// int c_ungetc(int d, FILE *f){
|
||||
// }
|
||||
// size_t c_fread(void *p, size_t _size, size_t _n, FILE *f){
|
||||
// }
|
||||
// size_t c_fwrite(const void *p, size_t _size, size_t _n, FILE *f){
|
||||
// }
|
||||
// int c_feof(FILE *f){
|
||||
// }
|
||||
// int c_ferror(FILE *f){
|
||||
// }
|
||||
// int c_getc(FILE *f){
|
||||
// }
|
||||
|
||||
#if defined( LUA_NUMBER_INTEGRAL )
|
||||
|
||||
#include <stdarg.h>
|
||||
|
||||
int sprintf(char *s, const char *fmt, ...)
|
||||
{
|
||||
int n;
|
||||
va_list arg;
|
||||
va_start(arg, fmt);
|
||||
n = ets_vsprintf(s, fmt, arg);
|
||||
va_end(arg);
|
||||
return n;
|
||||
}
|
||||
|
||||
int vsprintf (char *d, const char *s, va_list ap)
|
||||
{
|
||||
return ets_vsprintf(d, s, ap);
|
||||
}
|
||||
|
||||
#else
|
||||
|
||||
#define FLOATINGPT 1
|
||||
|
@ -97,8 +64,7 @@ int c_stderr = 1001;
|
|||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
//#include <string.h>
|
||||
#include "c_string.h"
|
||||
#include <string.h>
|
||||
|
||||
char *
|
||||
strichr(char *p, int c)
|
||||
|
@ -147,8 +113,7 @@ strichr(char *p, int c)
|
|||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
//#include <string.h>
|
||||
#include "c_string.h"
|
||||
#include <string.h>
|
||||
|
||||
#define FMT_RJUST 0
|
||||
#define FMT_LJUST 1
|
||||
|
@ -221,10 +186,8 @@ str_fmt(char *p, int size, int fmt)
|
|||
* SUCH DAMAGE.
|
||||
*
|
||||
*/
|
||||
//#include <string.h>
|
||||
//#include <ctype.h>
|
||||
#include "c_string.h"
|
||||
#include "c_ctype.h"
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
void
|
||||
strtoupper(char *p)
|
||||
|
@ -269,10 +232,9 @@ strtoupper(char *p)
|
|||
*/
|
||||
|
||||
//#include <sys/types.h>
|
||||
//#include <string.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
//#include <pmon.h>
|
||||
#include "c_string.h"
|
||||
typedef unsigned int u_int32_t;
|
||||
typedef unsigned int u_int;
|
||||
typedef unsigned long u_long;
|
||||
typedef int32_t register_t;
|
||||
|
@ -371,7 +333,7 @@ _atob (u_quad_t *vp, char *p, int base)
|
|||
* converts p to binary result in vp, rtn 1 on success
|
||||
*/
|
||||
int
|
||||
atob(u_int32_t *vp, char *p, int base)
|
||||
atob(uint32_t *vp, char *p, int base)
|
||||
{
|
||||
u_quad_t v;
|
||||
|
||||
|
@ -554,13 +516,10 @@ gethex(int32_t *vp, char *p, int n)
|
|||
*
|
||||
*/
|
||||
//#include <stdio.h>
|
||||
//#include <stdarg.h>
|
||||
//#include <string.h>
|
||||
//#include <ctype.h>
|
||||
//#include <pmon.h>
|
||||
#include "c_stdarg.h"
|
||||
#include "c_string.h"
|
||||
#include "c_ctype.h"
|
||||
#include <stdarg.h>
|
||||
#include <string.h>
|
||||
#include <ctype.h>
|
||||
|
||||
/*
|
||||
* int vsprintf(d,s,ap)
|
||||
|
@ -1091,10 +1050,9 @@ exponent(char *p, int exp, int fmtch)
|
|||
}
|
||||
return (p);
|
||||
}
|
||||
#endif /* FLOATINGPT */
|
||||
|
||||
|
||||
int c_sprintf(char *s, const char *fmt, ...)
|
||||
int sprintf(char *s, const char *fmt, ...)
|
||||
{
|
||||
int n;
|
||||
va_list arg;
|
||||
|
@ -1104,4 +1062,6 @@ int c_sprintf(char *s, const char *fmt, ...)
|
|||
return n;
|
||||
}
|
||||
|
||||
#endif /* FLOATINGPT */
|
||||
|
||||
#endif
|
|
@ -1,23 +1,14 @@
|
|||
//#include "user_interface.h"
|
||||
#include "user_config.h"
|
||||
|
||||
#ifdef LUA_CROSS_COMPILER
|
||||
|
||||
#include <stdlib.h>
|
||||
#include <ctype.h>
|
||||
#include <string.h>
|
||||
#include <stdint.h>
|
||||
|
||||
#ifdef LUA_CROSS_COMPILER
|
||||
#define ICACHE_RODATA_ATTR
|
||||
#define TRUE 1
|
||||
#define FALSE 0
|
||||
|
||||
#else
|
||||
|
||||
#include "c_stdlib.h"
|
||||
#include "c_types.h"
|
||||
#include "c_string.h"
|
||||
#include <_ansi.h>
|
||||
//#include <reent.h>
|
||||
//#include "mprec.h"
|
||||
#endif
|
||||
double powersOf10[] ICACHE_STORE_ATTR ICACHE_RODATA_ATTR = /* Table giving binary powers of 10. Entry */
|
||||
{
|
||||
|
@ -32,7 +23,7 @@ double powersOf10[] ICACHE_STORE_ATTR ICACHE_RODATA_ATTR = /* Table giving bin
|
|||
1.0e256
|
||||
};
|
||||
|
||||
double c_strtod(const char *string, char **endPtr)
|
||||
double strtod(const char *string, char **endPtr)
|
||||
{
|
||||
int maxExponent = 511; /* Largest possible base 10 exponent. Any
|
||||
* exponent larger than this will already
|
||||
|
@ -256,10 +247,3 @@ done:
|
|||
}
|
||||
return fraction;
|
||||
}
|
||||
|
||||
// long c_strtol(const char *__n, char **__end_PTR, int __base){
|
||||
// }
|
||||
// unsigned long c_strtoul(const char *__n, char **__end_PTR, int __base){
|
||||
// }
|
||||
// long long c_strtoll(const char *__n, char **__end_PTR, int __base){
|
||||
// }
|
|
@ -40,12 +40,6 @@ STD_CFLAGS=-std=gnu11 -Wimplicit
|
|||
# Required for each makefile to inherit from the parent
|
||||
#
|
||||
|
||||
INCLUDES := $(INCLUDES) -I $(PDIR)include
|
||||
INCLUDES += -I ./
|
||||
INCLUDES += -I ../spiffs
|
||||
INCLUDES += -I ../libc
|
||||
INCLUDES += -I ../modules
|
||||
INCLUDES += -I ../platform
|
||||
INCLUDES += -I ../uzlib
|
||||
PDIR := ../$(PDIR)
|
||||
sinclude $(PDIR)Makefile
|
||||
|
|
|
@ -10,9 +10,8 @@
|
|||
|
||||
#include "lua.h"
|
||||
|
||||
//#include C_HEADER_ASSERT
|
||||
#include C_HEADER_MATH
|
||||
#include C_HEADER_STRING
|
||||
#include <math.h>
|
||||
#include <string.h>
|
||||
#include "lapi.h"
|
||||
#include "ldebug.h"
|
||||
#include "ldo.h"
|
||||
|
@ -463,7 +462,7 @@ LUA_API void lua_pushstring (lua_State *L, const char *s) {
|
|||
if (s == NULL)
|
||||
lua_pushnil(L);
|
||||
else
|
||||
lua_pushlstring(L, s, c_strlen(s));
|
||||
lua_pushlstring(L, s, strlen(s));
|
||||
}
|
||||
|
||||
|
||||
|
|
|
@ -7,18 +7,19 @@
|
|||
#define LUAC_CROSS_FILE
|
||||
|
||||
#include "lua.h"
|
||||
#include C_HEADER_CTYPE
|
||||
#include <ctype.h>
|
||||
#ifdef __MINGW__
|
||||
#include <errno.h>
|
||||
#else
|
||||
#ifdef _MSC_VER //msvc #defines errno, which interferes with our #include macro
|
||||
#undef errno
|
||||
#endif
|
||||
#include C_HEADER_ERRNO
|
||||
#include <errno.h>
|
||||
#endif
|
||||
#include C_HEADER_STDIO
|
||||
#include C_HEADER_STDLIB
|
||||
#include C_HEADER_STRING
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <fcntl.h>
|
||||
#ifndef LUA_CROSS_COMPILER
|
||||
#include "vfs.h"
|
||||
#include "user_interface.h"
|
||||
|
@ -100,7 +101,7 @@ static void scanBlocks (void) {
|
|||
for (i=0; p ;i++) {
|
||||
s = memcmp(p->mark, marker, MARKSIZE) ? '<' : ' ';
|
||||
e = memcmp(cast(char *, p+1) + p->size, marker, MARKSIZE) ? '>' : ' ';
|
||||
c_printf("%4u %p %8lu %c %c\n", i, p, p->size, s, e);
|
||||
printf("%4u %p %8lu %c %c\n", i, p, p->size, s, e);
|
||||
ASSERT(p->next);
|
||||
p = p->next;
|
||||
}
|
||||
|
@ -136,7 +137,7 @@ static void freeblock (MemHeader *block) {
|
|||
p->next = next;
|
||||
}
|
||||
fillmem(block, sizeof(MemHeader) + size + MARKSIZE); /* erase block */
|
||||
c_free(block); /* actually free block */
|
||||
free(block); /* actually free block */
|
||||
mc.numblocks--; /* update counts */
|
||||
mc.total -= size;
|
||||
}
|
||||
|
@ -163,7 +164,7 @@ void *debug_realloc (void *b, size_t oldsize, size_t size) {
|
|||
MemHeader *newblock;
|
||||
size_t commonsize = (oldsize < size) ? oldsize : size;
|
||||
size_t realsize = sizeof(MemHeader) + size + MARKSIZE;
|
||||
newblock = cast(MemHeader *, c_malloc(realsize)); /* alloc a new block */
|
||||
newblock = cast(MemHeader *, malloc(realsize)); /* alloc a new block */
|
||||
if (newblock == NULL)
|
||||
return NULL; /* really out of memory? */
|
||||
if (block) {
|
||||
|
@ -190,7 +191,7 @@ void *debug_realloc (void *b, size_t oldsize, size_t size) {
|
|||
|
||||
/* }====================================================================== */
|
||||
#else
|
||||
#define this_realloc(p,os,s) c_realloc(p,s)
|
||||
#define this_realloc(p,os,s) realloc(p,s)
|
||||
#endif /* DEBUG_ALLOCATOR */
|
||||
|
||||
/*
|
||||
|
@ -205,7 +206,7 @@ LUALIB_API int luaL_argerror (lua_State *L, int narg, const char *extramsg) {
|
|||
if (!lua_getstack(L, 0, &ar)) /* no stack frame? */
|
||||
return luaL_error(L, "bad argument #%d (%s)", narg, extramsg);
|
||||
lua_getinfo(L, "n", &ar);
|
||||
if (c_strcmp(ar.namewhat, "method") == 0) {
|
||||
if (strcmp(ar.namewhat, "method") == 0) {
|
||||
narg--; /* do not count `self' */
|
||||
if (narg == 0) /* error is in the self argument itself? */
|
||||
return luaL_error(L, "calling " LUA_QS " on bad self (%s)",
|
||||
|
@ -262,7 +263,7 @@ LUALIB_API int luaL_checkoption (lua_State *L, int narg, const char *def,
|
|||
luaL_checkstring(L, narg);
|
||||
int i;
|
||||
for (i=0; lst[i]; i++)
|
||||
if (c_strcmp(lst[i], name) == 0)
|
||||
if (strcmp(lst[i], name) == 0)
|
||||
return i;
|
||||
return luaL_argerror(L, narg,
|
||||
lua_pushfstring(L, "invalid option " LUA_QS, name));
|
||||
|
@ -352,7 +353,7 @@ LUALIB_API const char *luaL_optlstring (lua_State *L, int narg,
|
|||
const char *def, size_t *len) {
|
||||
if (lua_isnoneornil(L, narg)) {
|
||||
if (len)
|
||||
*len = (def ? c_strlen(def) : 0);
|
||||
*len = (def ? strlen(def) : 0);
|
||||
return def;
|
||||
}
|
||||
else return luaL_checklstring(L, narg, len);
|
||||
|
@ -419,11 +420,7 @@ LUALIB_API void (luaL_register) (lua_State *L, const char *libname,
|
|||
|
||||
LUALIB_API void (luaL_register_light) (lua_State *L, const char *libname,
|
||||
const luaL_Reg *l) {
|
||||
#if LUA_OPTIMIZE_MEMORY > 0
|
||||
luaI_openlib(L, libname, l, 0, LUA_USELIGHTFUNCTIONS);
|
||||
#else
|
||||
luaI_openlib(L, libname, l, 0, LUA_USECCLOSURES);
|
||||
#endif
|
||||
}
|
||||
|
||||
static int libsize (const luaL_Reg *l) {
|
||||
|
@ -537,10 +534,10 @@ LUALIB_API int luaL_getn (lua_State *L, int t) {
|
|||
LUALIB_API const char *luaL_gsub (lua_State *L, const char *s, const char *p,
|
||||
const char *r) {
|
||||
const char *wild;
|
||||
size_t l = c_strlen(p);
|
||||
size_t l = strlen(p);
|
||||
luaL_Buffer b;
|
||||
luaL_buffinit(L, &b);
|
||||
while ((wild = c_strstr(s, p)) != NULL) {
|
||||
while ((wild = strstr(s, p)) != NULL) {
|
||||
luaL_addlstring(&b, s, wild - s); /* push prefix */
|
||||
luaL_addstring(&b, r); /* push replacement in place of pattern */
|
||||
s = wild + l; /* continue after `p' */
|
||||
|
@ -556,8 +553,8 @@ LUALIB_API const char *luaL_findtable (lua_State *L, int idx,
|
|||
const char *e;
|
||||
lua_pushvalue(L, idx);
|
||||
do {
|
||||
e = c_strchr(fname, '.');
|
||||
if (e == NULL) e = fname + c_strlen(fname);
|
||||
e = strchr(fname, '.');
|
||||
if (e == NULL) e = fname + strlen(fname);
|
||||
lua_pushlstring(L, fname, e - fname);
|
||||
lua_rawget(L, -2);
|
||||
|
||||
|
@ -638,7 +635,7 @@ LUALIB_API void luaL_addlstring (luaL_Buffer *B, const char *s, size_t l) {
|
|||
|
||||
|
||||
LUALIB_API void luaL_addstring (luaL_Buffer *B, const char *s) {
|
||||
luaL_addlstring(B, s, c_strlen(s));
|
||||
luaL_addlstring(B, s, strlen(s));
|
||||
}
|
||||
|
||||
|
||||
|
@ -654,7 +651,7 @@ LUALIB_API void luaL_addvalue (luaL_Buffer *B) {
|
|||
size_t vl;
|
||||
const char *s = lua_tolstring(L, -1, &vl);
|
||||
if (vl <= bufffree(B)) { /* fit into buffer? */
|
||||
c_memcpy(B->p, s, vl); /* put it there */
|
||||
memcpy(B->p, s, vl); /* put it there */
|
||||
B->p += vl;
|
||||
lua_pop(L, 1); /* remove from stack */
|
||||
}
|
||||
|
@ -734,14 +731,14 @@ static const char *getF (lua_State *L, void *ud, size_t *size) {
|
|||
*size = 1;
|
||||
return "\n";
|
||||
}
|
||||
if (c_feof(lf->f)) return NULL;
|
||||
*size = c_fread(lf->buff, 1, sizeof(lf->buff), lf->f);
|
||||
if (feof(lf->f)) return NULL;
|
||||
*size = fread(lf->buff, 1, sizeof(lf->buff), lf->f);
|
||||
return (*size > 0) ? lf->buff : NULL;
|
||||
}
|
||||
|
||||
|
||||
static int errfile (lua_State *L, const char *what, int fnameindex) {
|
||||
const char *serr = c_strerror(errno);
|
||||
const char *serr = strerror(errno);
|
||||
const char *filename = lua_tostring(L, fnameindex) + 1;
|
||||
lua_pushfstring(L, "cannot %s %s: %s", what, filename, serr);
|
||||
lua_remove(L, fnameindex);
|
||||
|
@ -761,27 +758,27 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
|
|||
}
|
||||
else {
|
||||
lua_pushfstring(L, "@%s", filename);
|
||||
lf.f = c_fopen(filename, "r");
|
||||
lf.f = fopen(filename, "r");
|
||||
if (lf.f == NULL) return errfile(L, "open", fnameindex);
|
||||
}
|
||||
c = c_getc(lf.f);
|
||||
c = getc(lf.f);
|
||||
if (c == '#') { /* Unix exec. file? */
|
||||
lf.extraline = 1;
|
||||
while ((c = c_getc(lf.f)) != EOF && c != '\n') ; /* skip first line */
|
||||
if (c == '\n') c = c_getc(lf.f);
|
||||
while ((c = getc(lf.f)) != EOF && c != '\n') ; /* skip first line */
|
||||
if (c == '\n') c = getc(lf.f);
|
||||
}
|
||||
if (c == LUA_SIGNATURE[0] && filename) { /* binary file? */
|
||||
lf.f = c_freopen(filename, "rb", lf.f); /* reopen in binary mode */
|
||||
lf.f = freopen(filename, "rb", lf.f); /* reopen in binary mode */
|
||||
if (lf.f == NULL) return errfile(L, "reopen", fnameindex);
|
||||
/* skip eventual `#!...' */
|
||||
while ((c = c_getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) {}
|
||||
while ((c = getc(lf.f)) != EOF && c != LUA_SIGNATURE[0]) {}
|
||||
|
||||
lf.extraline = 0;
|
||||
}
|
||||
c_ungetc(c, lf.f);
|
||||
ungetc(c, lf.f);
|
||||
status = lua_load(L, getF, &lf, lua_tostring(L, -1));
|
||||
readstatus = c_ferror(lf.f);
|
||||
if (filename) c_fclose(lf.f); /* close file (even in case of errors) */
|
||||
readstatus = ferror(lf.f);
|
||||
if (filename) fclose(lf.f); /* close file (even in case of errors) */
|
||||
if (readstatus) {
|
||||
lua_settop(L, fnameindex); /* ignore results from `lua_load' */
|
||||
return errfile(L, "read", fnameindex);
|
||||
|
@ -792,8 +789,6 @@ LUALIB_API int luaL_loadfile (lua_State *L, const char *filename) {
|
|||
|
||||
#else
|
||||
|
||||
#include C_HEADER_FCNTL
|
||||
|
||||
typedef struct LoadFSF {
|
||||
int extraline;
|
||||
int f;
|
||||
|
@ -897,7 +892,7 @@ LUALIB_API int luaL_loadbuffer (lua_State *L, const char *buff, size_t size,
|
|||
|
||||
|
||||
LUALIB_API int (luaL_loadstring) (lua_State *L, const char *s) {
|
||||
return luaL_loadbuffer(L, s, c_strlen(s), s);
|
||||
return luaL_loadbuffer(L, s, strlen(s), s);
|
||||
}
|
||||
|
||||
|
||||
|
@ -932,7 +927,7 @@ static void *l_alloc (void *ud, void *ptr, size_t osize, size_t nsize) {
|
|||
#ifdef DEBUG_ALLOCATOR
|
||||
return (void *)this_realloc(ptr, osize, nsize);
|
||||
#else
|
||||
c_free(ptr);
|
||||
free(ptr);
|
||||
return NULL;
|
||||
#endif
|
||||
}
|
||||
|
@ -992,7 +987,7 @@ LUALIB_API void luaL_dbgbreak(void) {
|
|||
static int panic (lua_State *L) {
|
||||
(void)L; /* to avoid warnings */
|
||||
#if defined(LUA_USE_STDIO)
|
||||
c_fprintf(c_stderr, "PANIC: unprotected error in call to Lua API (%s)\n",
|
||||
fprintf(c_stderr, "PANIC: unprotected error in call to Lua API (%s)\n",
|
||||
lua_tostring(L, -1));
|
||||
#else
|
||||
luai_writestringerror("PANIC: unprotected error in call to Lua API (%s)\n",
|
||||
|
|
|
@ -8,15 +8,9 @@
|
|||
#ifndef lauxlib_h
|
||||
#define lauxlib_h
|
||||
|
||||
|
||||
#include "lua.h"
|
||||
|
||||
#ifdef LUA_CROSS_COMPILER
|
||||
#include <stdio.h>
|
||||
#else
|
||||
#include "c_stdio.h"
|
||||
#endif
|
||||
|
||||
|
||||
#if defined(LUA_COMPAT_GETN)
|
||||
LUALIB_API int (luaL_getn) (lua_State *L, int t);
|
||||
|
|
|
@ -11,12 +11,12 @@
|
|||
#define LUAC_CROSS_FILE
|
||||
|
||||
#include "lua.h"
|
||||
#include C_HEADER_STDIO
|
||||
#include C_HEADER_STRING
|
||||
#include C_HEADER_STDLIB
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
#include "lrodefs.h"
|
||||
#include "lrotable.h"
|
||||
|
||||
|
||||
|
||||
|
@ -41,16 +41,16 @@ static int luaB_print (lua_State *L) {
|
|||
return luaL_error(L, LUA_QL("tostring") " must return a string to "
|
||||
LUA_QL("print"));
|
||||
#if defined(LUA_USE_STDIO)
|
||||
if (i>1) c_fputs("\t", c_stdout);
|
||||
c_fputs(s, c_stdout);
|
||||
if (i>1) fputs("\t", c_stdout);
|
||||
fputs(s, c_stdout);
|
||||
#else
|
||||
if (i>1) luai_writestring("\t", 1);
|
||||
luai_writestring(s, c_strlen(s));
|
||||
luai_writestring(s, strlen(s));
|
||||
#endif
|
||||
lua_pop(L, 1); /* pop result */
|
||||
}
|
||||
#if defined(LUA_USE_STDIO)
|
||||
c_fputs("\n", c_stdout);
|
||||
fputs("\n", c_stdout);
|
||||
#else
|
||||
luai_writeline();
|
||||
#endif
|
||||
|
@ -72,7 +72,7 @@ static int luaB_tonumber (lua_State *L) {
|
|||
char *s2;
|
||||
unsigned long n;
|
||||
luaL_argcheck(L, 2 <= base && base <= 36, 2, "base out of range");
|
||||
n = c_strtoul(s1, &s2, base);
|
||||
n = strtoul(s1, &s2, base);
|
||||
if (s1 != s2) { /* at least one valid digit? */
|
||||
while (isspace((unsigned char)(*s2))) s2++; /* skip trailing spaces */
|
||||
if (*s2 == '\0') { /* no invalid trailing characters? */
|
||||
|
@ -462,64 +462,59 @@ static int luaB_newproxy (lua_State *L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
#include "lrodefs.h"
|
||||
#include "lrotable.h"
|
||||
|
||||
extern const luaR_entry lua_rotable_base[];
|
||||
LROT_EXTERN(lua_rotable_base);
|
||||
|
||||
/*
|
||||
* ESP builds use specific linker directives to marshal all ROTable declarations
|
||||
* into a single ROTable in the PSECT ".lua_rotable".
|
||||
* Separate ROTables are used for the base functions and library ROTables, with
|
||||
* the base functions ROTable declared below. The library ROTable is chained
|
||||
* from this using its __index meta-method.
|
||||
*
|
||||
* This is not practical on Posix builds using a standard link so for cross
|
||||
* compiler builds, separate ROTables are used for the base functions and library
|
||||
* ROTables, with the latter chained from the former using its __index meta-method.
|
||||
* In this case all library ROTables are defined in linit.c.
|
||||
* ESP builds use specific linker directives to marshal all the ROTable entries
|
||||
* for the library modules into a single ROTable in the PSECT ".lua_rotable".
|
||||
* This is not practical on Posix builds using a standard GNU link, so the
|
||||
* equivalent ROTable for the core libraries defined in linit.c for the cross-
|
||||
* compiler build.
|
||||
*/
|
||||
#ifdef LUA_CROSS_COMPILER
|
||||
#define BASE_ROTABLE base_func_map
|
||||
#define LOCK_IN_ROTABLE
|
||||
static const LUA_REG_TYPE base_func_meta[] = {
|
||||
LROT_TABENTRY(__index, lua_rotable_base),
|
||||
LROT_END};
|
||||
#else
|
||||
#define BASE_ROTABLE lua_rotable_base
|
||||
#define LOCK_IN_ROTABLE __attribute__((used,unused,section(".lua_rotable")))
|
||||
#endif
|
||||
|
||||
static const LUA_REG_TYPE LOCK_IN_ROTABLE base_func_map[] = {
|
||||
LROT_FUNCENTRY(assert, luaB_assert),
|
||||
LROT_FUNCENTRY(collectgarbage, luaB_collectgarbage),
|
||||
LROT_FUNCENTRY(dofile, luaB_dofile),
|
||||
LROT_FUNCENTRY(error, luaB_error),
|
||||
LROT_FUNCENTRY(gcinfo, luaB_gcinfo),
|
||||
LROT_FUNCENTRY(getfenv, luaB_getfenv),
|
||||
LROT_FUNCENTRY(getmetatable, luaB_getmetatable),
|
||||
LROT_FUNCENTRY(loadfile, luaB_loadfile),
|
||||
LROT_FUNCENTRY(load, luaB_load),
|
||||
LROT_FUNCENTRY(loadstring, luaB_loadstring),
|
||||
LROT_FUNCENTRY(next, luaB_next),
|
||||
LROT_FUNCENTRY(pcall, luaB_pcall),
|
||||
LROT_FUNCENTRY(print, luaB_print),
|
||||
LROT_FUNCENTRY(rawequal, luaB_rawequal),
|
||||
LROT_FUNCENTRY(rawget, luaB_rawget),
|
||||
LROT_FUNCENTRY(rawset, luaB_rawset),
|
||||
LROT_FUNCENTRY(select, luaB_select),
|
||||
LROT_FUNCENTRY(setfenv, luaB_setfenv),
|
||||
LROT_FUNCENTRY(setmetatable, luaB_setmetatable),
|
||||
LROT_FUNCENTRY(tonumber, luaB_tonumber),
|
||||
LROT_FUNCENTRY(tostring, luaB_tostring),
|
||||
LROT_FUNCENTRY(type, luaB_type),
|
||||
LROT_FUNCENTRY(unpack, luaB_unpack),
|
||||
LROT_EXTERN(lua_rotables);
|
||||
|
||||
LROT_PUBLIC_BEGIN(base_func_meta)
|
||||
LROT_TABENTRY( __index, lua_rotables )
|
||||
LROT_END(base_func, base_func_meta, LROT_MASK_INDEX)
|
||||
|
||||
LROT_PUBLIC_BEGIN(base_func)
|
||||
LROT_FUNCENTRY(assert, luaB_assert)
|
||||
LROT_FUNCENTRY(collectgarbage, luaB_collectgarbage)
|
||||
LROT_FUNCENTRY(dofile, luaB_dofile)
|
||||
LROT_FUNCENTRY(error, luaB_error)
|
||||
LROT_FUNCENTRY(gcinfo, luaB_gcinfo)
|
||||
LROT_FUNCENTRY(getfenv, luaB_getfenv)
|
||||
LROT_FUNCENTRY(getmetatable, luaB_getmetatable)
|
||||
LROT_FUNCENTRY(loadfile, luaB_loadfile)
|
||||
LROT_FUNCENTRY(load, luaB_load)
|
||||
LROT_FUNCENTRY(loadstring, luaB_loadstring)
|
||||
LROT_FUNCENTRY(next, luaB_next)
|
||||
LROT_FUNCENTRY(pcall, luaB_pcall)
|
||||
LROT_FUNCENTRY(print, luaB_print)
|
||||
LROT_FUNCENTRY(rawequal, luaB_rawequal)
|
||||
LROT_FUNCENTRY(rawget, luaB_rawget)
|
||||
LROT_FUNCENTRY(rawset, luaB_rawset)
|
||||
LROT_FUNCENTRY(select, luaB_select)
|
||||
LROT_FUNCENTRY(setfenv, luaB_setfenv)
|
||||
LROT_FUNCENTRY(setmetatable, luaB_setmetatable)
|
||||
LROT_FUNCENTRY(tonumber, luaB_tonumber)
|
||||
LROT_FUNCENTRY(tostring, luaB_tostring)
|
||||
LROT_FUNCENTRY(type, luaB_type)
|
||||
LROT_FUNCENTRY(unpack, luaB_unpack)
|
||||
LROT_FUNCENTRY(xpcall, luaB_xpcall)
|
||||
#ifdef LUA_CROSS_COMPILER
|
||||
,LROT_TABENTRY(__metatable, base_func_meta),
|
||||
LROT_END
|
||||
#endif
|
||||
};
|
||||
LROT_TABENTRY(__metatable, base_func_meta)
|
||||
LROT_END(base_func, base_func_meta, LROT_MASK_INDEX)
|
||||
|
||||
static const luaL_Reg base_funcs[] = {
|
||||
{NULL, NULL}
|
||||
};
|
||||
LROT_BEGIN(G_meta)
|
||||
LROT_TABENTRY( __index, base_func )
|
||||
LROT_END(G_meta, NULL, 0)
|
||||
|
||||
|
||||
/*
|
||||
|
@ -650,17 +645,14 @@ static int luaB_corunning (lua_State *L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
#undef MIN_OPT_LEVEL
|
||||
#define MIN_OPT_LEVEL 1
|
||||
const LUA_REG_TYPE co_funcs[] = {
|
||||
{LSTRKEY("create"), LFUNCVAL(luaB_cocreate)},
|
||||
{LSTRKEY("resume"), LFUNCVAL(luaB_coresume)},
|
||||
{LSTRKEY("running"), LFUNCVAL(luaB_corunning)},
|
||||
{LSTRKEY("status"), LFUNCVAL(luaB_costatus)},
|
||||
{LSTRKEY("wrap"), LFUNCVAL(luaB_cowrap)},
|
||||
{LSTRKEY("yield"), LFUNCVAL(luaB_yield)},
|
||||
{LNILKEY, LNILVAL}
|
||||
};
|
||||
LROT_PUBLIC_BEGIN(co_funcs)
|
||||
LROT_FUNCENTRY( create, luaB_cocreate )
|
||||
LROT_FUNCENTRY( resume, luaB_coresume )
|
||||
LROT_FUNCENTRY( running, luaB_corunning )
|
||||
LROT_FUNCENTRY( status, luaB_costatus )
|
||||
LROT_FUNCENTRY( wrap, luaB_cowrap )
|
||||
LROT_FUNCENTRY( yield, luaB_yield )
|
||||
LROT_END (co_funcs, NULL, 0)
|
||||
|
||||
/* }====================================================== */
|
||||
|
||||
|
@ -676,14 +668,12 @@ static void base_open (lua_State *L) {
|
|||
/* set global _G */
|
||||
lua_pushvalue(L, LUA_GLOBALSINDEX);
|
||||
lua_setglobal(L, "_G");
|
||||
|
||||
/* open lib into global table */
|
||||
luaL_register_light(L, "_G", base_funcs);
|
||||
#if LUA_OPTIMIZE_MEMORY > 0
|
||||
lua_pushvalue(L, -1);
|
||||
lua_setmetatable(L, -2);
|
||||
lua_pushrotable(L, (void *)BASE_ROTABLE);
|
||||
lua_setglobal(L, "__index");
|
||||
#endif
|
||||
luaL_register_light(L, "_G", &((luaL_Reg) {0}));
|
||||
lua_pushrotable(L, LROT_TABLEREF(G_meta));
|
||||
lua_setmetatable(L, LUA_GLOBALSINDEX);
|
||||
|
||||
lua_pushliteral(L, LUA_VERSION);
|
||||
lua_setglobal(L, "_VERSION"); /* set global _VERSION */
|
||||
/* `ipairs' and `pairs' need auxliliary functions as upvalues */
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#define LUAC_CROSS_FILE
|
||||
|
||||
#include "lua.h"
|
||||
#include C_HEADER_STDLIB
|
||||
#include <stdlib.h>
|
||||
|
||||
#include "lcode.h"
|
||||
#include "ldebug.h"
|
||||
|
@ -81,7 +81,7 @@ static void fixjump (FuncState *fs, int pc, int dest) {
|
|||
Instruction *jmp = &fs->f->code[pc];
|
||||
int offset = dest-(pc+1);
|
||||
lua_assert(dest != NO_JUMP);
|
||||
if (c_abs(offset) > MAXARG_sBx)
|
||||
if (abs(offset) > MAXARG_sBx)
|
||||
luaX_syntaxerror(fs->ls, "control structure too long");
|
||||
SETARG_sBx(*jmp, offset);
|
||||
}
|
||||
|
|
|
@ -10,28 +10,28 @@
|
|||
#define LUAC_CROSS_FILE
|
||||
|
||||
#include "lua.h"
|
||||
#include C_HEADER_STDIO
|
||||
#include C_HEADER_STDLIB
|
||||
#include C_HEADER_STRING
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
#include <string.h>
|
||||
|
||||
#include "lauxlib.h"
|
||||
#include "lualib.h"
|
||||
#include "lstring.h"
|
||||
#include "lflash.h"
|
||||
#include "lrotable.h"
|
||||
|
||||
#include "user_modules.h"
|
||||
|
||||
|
||||
|
||||
static int db_getregistry (lua_State *L) {
|
||||
lua_pushvalue(L, LUA_REGISTRYINDEX);
|
||||
return 1;
|
||||
}
|
||||
|
||||
static int db_getstrings (lua_State *L) {
|
||||
size_t i,n;
|
||||
size_t i,n=0;
|
||||
stringtable *tb;
|
||||
GCObject *o;
|
||||
#if defined(LUA_FLASH_STORE) && !defined(LUA_CROSS_COMPILER)
|
||||
#ifndef LUA_CROSS_COMPILER
|
||||
const char *opt = lua_tolstring (L, 1, &n);
|
||||
if (n==3 && memcmp(opt, "ROM", 4) == 0) {
|
||||
if (G(L)->ROstrt.hash == NULL)
|
||||
|
@ -155,24 +155,24 @@ static int db_getinfo (lua_State *L) {
|
|||
if (!lua_getinfo(L1, options, &ar))
|
||||
return luaL_argerror(L, arg+2, "invalid option");
|
||||
lua_createtable(L, 0, 2);
|
||||
if (c_strchr(options, 'S')) {
|
||||
if (strchr(options, 'S')) {
|
||||
settabss(L, "source", ar.source);
|
||||
settabss(L, "short_src", ar.short_src);
|
||||
settabsi(L, "linedefined", ar.linedefined);
|
||||
settabsi(L, "lastlinedefined", ar.lastlinedefined);
|
||||
settabss(L, "what", ar.what);
|
||||
}
|
||||
if (c_strchr(options, 'l'))
|
||||
if (strchr(options, 'l'))
|
||||
settabsi(L, "currentline", ar.currentline);
|
||||
if (c_strchr(options, 'u'))
|
||||
if (strchr(options, 'u'))
|
||||
settabsi(L, "nups", ar.nups);
|
||||
if (c_strchr(options, 'n')) {
|
||||
if (strchr(options, 'n')) {
|
||||
settabss(L, "name", ar.name);
|
||||
settabss(L, "namewhat", ar.namewhat);
|
||||
}
|
||||
if (c_strchr(options, 'L'))
|
||||
if (strchr(options, 'L'))
|
||||
treatstackoption(L, L1, "activelines");
|
||||
if (c_strchr(options, 'f'))
|
||||
if (strchr(options, 'f'))
|
||||
treatstackoption(L, L1, "func");
|
||||
return 1; /* return table */
|
||||
}
|
||||
|
@ -261,9 +261,9 @@ static void hookf (lua_State *L, lua_Debug *ar) {
|
|||
|
||||
static int makemask (const char *smask, int count) {
|
||||
int mask = 0;
|
||||
if (c_strchr(smask, 'c')) mask |= LUA_MASKCALL;
|
||||
if (c_strchr(smask, 'r')) mask |= LUA_MASKRET;
|
||||
if (c_strchr(smask, 'l')) mask |= LUA_MASKLINE;
|
||||
if (strchr(smask, 'c')) mask |= LUA_MASKCALL;
|
||||
if (strchr(smask, 'r')) mask |= LUA_MASKRET;
|
||||
if (strchr(smask, 'l')) mask |= LUA_MASKLINE;
|
||||
if (count > 0) mask |= LUA_MASKCOUNT;
|
||||
return mask;
|
||||
}
|
||||
|
@ -340,19 +340,19 @@ static int db_debug (lua_State *L) {
|
|||
for (;;) {
|
||||
char buffer[LUA_MAXINPUT];
|
||||
#if defined(LUA_USE_STDIO)
|
||||
c_fputs("lua_debug> ", c_stderr);
|
||||
if (c_fgets(buffer, sizeof(buffer), c_stdin) == 0 ||
|
||||
fputs("lua_debug> ", c_stderr);
|
||||
if (fgets(buffer, sizeof(buffer), c_stdin) == 0 ||
|
||||
#else
|
||||
// luai_writestringerror("%s", "lua_debug>");
|
||||
if (lua_readline(L, buffer, "lua_debug>") == 0 ||
|
||||
#endif
|
||||
c_strcmp(buffer, "cont\n") == 0)
|
||||
strcmp(buffer, "cont\n") == 0)
|
||||
return 0;
|
||||
if (luaL_loadbuffer(L, buffer, c_strlen(buffer), "=(debug command)") ||
|
||||
if (luaL_loadbuffer(L, buffer, strlen(buffer), "=(debug command)") ||
|
||||
lua_pcall(L, 0, 0, 0)) {
|
||||
#if defined(LUA_USE_STDIO)
|
||||
c_fputs(lua_tostring(L, -1), c_stderr);
|
||||
c_fputs("\n", c_stderr);
|
||||
fputs(lua_tostring(L, -1), c_stderr);
|
||||
fputs("\n", c_stderr);
|
||||
#else
|
||||
luai_writestringerror("%s\n", lua_tostring(L, -1));
|
||||
#endif
|
||||
|
@ -417,32 +417,28 @@ static int db_errorfb (lua_State *L) {
|
|||
return 1;
|
||||
}
|
||||
|
||||
#undef MIN_OPT_LEVEL
|
||||
#define MIN_OPT_LEVEL 1
|
||||
#include "lrodefs.h"
|
||||
const LUA_REG_TYPE dblib[] = {
|
||||
LROT_PUBLIC_BEGIN(dblib)
|
||||
#ifndef LUA_USE_BUILTIN_DEBUG_MINIMAL
|
||||
{LSTRKEY("debug"), LFUNCVAL(db_debug)},
|
||||
{LSTRKEY("getfenv"), LFUNCVAL(db_getfenv)},
|
||||
{LSTRKEY("gethook"), LFUNCVAL(db_gethook)},
|
||||
{LSTRKEY("getinfo"), LFUNCVAL(db_getinfo)},
|
||||
{LSTRKEY("getlocal"), LFUNCVAL(db_getlocal)},
|
||||
LROT_FUNCENTRY( debug, db_debug )
|
||||
LROT_FUNCENTRY( getfenv, db_getfenv )
|
||||
LROT_FUNCENTRY( gethook, db_gethook )
|
||||
LROT_FUNCENTRY( getinfo, db_getinfo )
|
||||
LROT_FUNCENTRY( getlocal, db_getlocal )
|
||||
#endif
|
||||
{LSTRKEY("getregistry"), LFUNCVAL(db_getregistry)},
|
||||
{LSTRKEY("getstrings"), LFUNCVAL(db_getstrings)},
|
||||
LROT_FUNCENTRY( getregistry, db_getregistry )
|
||||
LROT_FUNCENTRY( getstrings, db_getstrings )
|
||||
#ifndef LUA_USE_BUILTIN_DEBUG_MINIMAL
|
||||
{LSTRKEY("getmetatable"), LFUNCVAL(db_getmetatable)},
|
||||
{LSTRKEY("getupvalue"), LFUNCVAL(db_getupvalue)},
|
||||
{LSTRKEY("setfenv"), LFUNCVAL(db_setfenv)},
|
||||
{LSTRKEY("sethook"), LFUNCVAL(db_sethook)},
|
||||
{LSTRKEY("setlocal"), LFUNCVAL(db_setlocal)},
|
||||
{LSTRKEY("setmetatable"), LFUNCVAL(db_setmetatable)},
|
||||
{LSTRKEY("setupvalue"), LFUNCVAL(db_setupvalue)},
|
||||
LROT_FUNCENTRY( getmetatable, db_getmetatable )
|
||||
LROT_FUNCENTRY( getupvalue, db_getupvalue )
|
||||
LROT_FUNCENTRY( setfenv, db_setfenv )
|
||||
LROT_FUNCENTRY( sethook, db_sethook )
|
||||
LROT_FUNCENTRY( setlocal, db_setlocal )
|
||||
LROT_FUNCENTRY( setmetatable, db_setmetatable )
|
||||
LROT_FUNCENTRY( setupvalue, db_setupvalue )
|
||||
#endif
|
||||
{LSTRKEY("traceback"), LFUNCVAL(db_errorfb)},
|
||||
{LNILKEY, LNILVAL}
|
||||
};
|
||||
LROT_FUNCENTRY( traceback, db_errorfb )
|
||||
LROT_END(dblib, NULL, 0)
|
||||
|
||||
LUALIB_API int luaopen_debug (lua_State *L) {
|
||||
LREGISTER(L, LUA_DBLIBNAME, dblib);
|
||||
return 0;
|
||||
}
|
||||
|
|
|
@ -10,7 +10,7 @@
|
|||
#define LUAC_CROSS_FILE
|
||||
|
||||
#include "lua.h"
|
||||
#include C_HEADER_STRING
|
||||
#include <string.h>
|
||||
|
||||
#include "lapi.h"
|
||||
#include "lcode.h"
|
||||
|
@ -253,7 +253,7 @@ static int stripdebug (lua_State *L, Proto *f, int level) {
|
|||
TString* dummy;
|
||||
switch (level) {
|
||||
case 3:
|
||||
sizepackedlineinfo = c_strlen(cast(char *, f->packedlineinfo))+1;
|
||||
sizepackedlineinfo = strlen(cast(char *, f->packedlineinfo))+1;
|
||||
f->packedlineinfo = luaM_freearray(L, f->packedlineinfo, sizepackedlineinfo, unsigned char);
|
||||
len += sizepackedlineinfo;
|
||||
case 2:
|
||||
|
@ -344,7 +344,7 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
|
|||
plight = fvalue(ci->func);
|
||||
}
|
||||
status = auxgetinfo(L, what, ar, f, plight, ci);
|
||||
if (c_strchr(what, 'f')) {
|
||||
if (strchr(what, 'f')) {
|
||||
if (f != NULL)
|
||||
setclvalue(L, L->top, f)
|
||||
else if (plight != NULL)
|
||||
|
@ -353,7 +353,7 @@ LUA_API int lua_getinfo (lua_State *L, const char *what, lua_Debug *ar) {
|
|||
setnilvalue(L->top);
|
||||
incr_top(L);
|
||||
}
|
||||
if (c_strchr(what, 'L'))
|
||||
if (strchr(what, 'L'))
|
||||
collectvalidlines(L, f);
|
||||
lua_unlock(L);
|
||||
return status;
|
||||
|
|
|
@ -11,7 +11,7 @@
|
|||
#define LUAC_CROSS_FILE
|
||||
|
||||
#include "lua.h"
|
||||
#include C_HEADER_STRING
|
||||
#include <string.h>
|
||||
|
||||
#include "ldebug.h"
|
||||
#include "ldo.h"
|
||||
|
|
|
@ -9,7 +9,7 @@
|
|||
#define LUAC_CROSS_FILE
|
||||
|
||||
#include "lua.h"
|
||||
#include C_HEADER_STRING
|
||||
#include <string.h>
|
||||
|
||||
#include "lobject.h"
|
||||
#include "lstate.h"
|
||||
|
@ -150,9 +150,9 @@ static void DumpNumber(lua_Number x, DumpState* D)
|
|||
if(D->target.is_arm_fpa)
|
||||
{
|
||||
char *pnum=(char*)&y, temp[4];
|
||||
c_memcpy(temp,pnum,4);
|
||||
c_memcpy(pnum,pnum+4,4);
|
||||
c_memcpy(pnum+4,temp,4);
|
||||
memcpy(temp,pnum,4);
|
||||
memcpy(pnum,pnum+4,4);
|
||||
memcpy(pnum+4,temp,4);
|
||||
}
|
||||
MaybeByteSwap((char*)&y,8,D);
|
||||
DumpVar(y,D);
|
||||
|
@ -171,7 +171,7 @@ static void DumpCode(const Proto *f, DumpState* D)
|
|||
Align4(D);
|
||||
for (i=0; i<f->sizecode; i++)
|
||||
{
|
||||
c_memcpy(buf,&f->code[i],sizeof(Instruction));
|
||||
memcpy(buf,&f->code[i],sizeof(Instruction));
|
||||
MaybeByteSwap(buf,sizeof(Instruction),D);
|
||||
DumpBlock(buf,sizeof(Instruction),D);
|
||||
}
|
||||
|
@ -230,7 +230,7 @@ static void DumpDebug(const Proto* f, DumpState* D)
|
|||
int i,n;
|
||||
|
||||
#ifdef LUA_OPTIMIZE_DEBUG
|
||||
n = (D->strip || f->packedlineinfo == NULL) ? 0: c_strlen(cast(char *,f->packedlineinfo))+1;
|
||||
n = (D->strip || f->packedlineinfo == NULL) ? 0: strlen(cast(char *,f->packedlineinfo))+1;
|
||||
DumpInt(n,D);
|
||||
Align4(D);
|
||||
if (n)
|
||||
|
@ -281,7 +281,7 @@ static void DumpHeader(DumpState* D)
|
|||
char *h=buf;
|
||||
|
||||
/* This code must be kept in sync wiht luaU_header */
|
||||
c_memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1);
|
||||
memcpy(h,LUA_SIGNATURE,sizeof(LUA_SIGNATURE)-1);
|
||||
h+=sizeof(LUA_SIGNATURE)-1;
|
||||
*h++=(char)LUAC_VERSION;
|
||||
*h++=(char)LUAC_FORMAT;
|
||||
|
|
|
@ -2,7 +2,6 @@
|
|||
|
||||
#include "legc.h"
|
||||
#include "lstate.h"
|
||||
#include "c_types.h"
|
||||
|
||||
void legc_set_mode(lua_State *L, int mode, int limit) {
|
||||
global_State *g = G(L);
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show More
Loading…
Reference in New Issue