├── .cproject ├── .gitignore ├── .project ├── .settings ├── language.settings.xml ├── org.eclipse.cdt.codan.core.prefs ├── org.eclipse.cdt.core.prefs ├── org.eclipse.cdt.managedbuilder.core.prefs └── org.eclipse.core.resources.prefs ├── AutoMake.bat ├── LICENSE ├── Makefile ├── ProgBin.bat ├── README.md ├── app ├── .gitignore ├── Makefile ├── sdklib │ ├── .gitignore │ ├── Makefile │ ├── lwip │ │ ├── COPYING │ │ ├── Makefile │ │ ├── api │ │ │ ├── Makefile │ │ │ ├── api_lib.c │ │ │ ├── api_msg.c │ │ │ ├── err.c │ │ │ ├── netbuf.c │ │ │ ├── netdb.c │ │ │ ├── netifapi.c │ │ │ ├── sockets.c │ │ │ └── tcpip.c │ │ ├── app │ │ │ ├── Espressif.License │ │ │ ├── Makefile │ │ │ ├── dhcpserver.c │ │ │ ├── espconn.c │ │ │ ├── espconn_mdns.c │ │ │ ├── espconn_tcp.c │ │ │ ├── espconn_udp.c │ │ │ ├── netio.c │ │ │ └── ping.c │ │ ├── core │ │ │ ├── Makefile │ │ │ ├── def.c │ │ │ ├── dhcp.c │ │ │ ├── dns.c │ │ │ ├── init.c │ │ │ ├── ipv4 │ │ │ │ ├── Makefile │ │ │ │ ├── autoip.c │ │ │ │ ├── icmp.c │ │ │ │ ├── igmp.c │ │ │ │ ├── inet.c │ │ │ │ ├── inet_chksum.c │ │ │ │ ├── ip.c │ │ │ │ ├── ip_addr.c │ │ │ │ └── ip_frag.c │ │ │ ├── mdns.c │ │ │ ├── mem.c │ │ │ ├── memp.c │ │ │ ├── netif.c │ │ │ ├── pbuf.c │ │ │ ├── raw.c │ │ │ ├── sntp.c │ │ │ ├── stats.c │ │ │ ├── sys.c │ │ │ ├── tcp.c │ │ │ ├── tcp_in.c │ │ │ ├── tcp_out.c │ │ │ ├── timers.c │ │ │ └── udp.c │ │ └── netif │ │ │ ├── Makefile │ │ │ └── etharp.c │ ├── phy │ │ ├── Makefile │ │ └── phy_chip_v6_unused.c │ ├── pp │ │ ├── Makefile │ │ └── pplibadd.c │ ├── system │ │ ├── Makefile │ │ ├── app_main.c │ │ ├── eagle_lwip_if.c │ │ ├── ets_run_new.c │ │ ├── ets_timer.c │ │ ├── main-vectors.c │ │ ├── mem_manager.c │ │ ├── os_printf.c │ │ ├── rom2ram.c │ │ ├── spi_flash.c │ │ ├── spi_overlap.c │ │ └── wdt.c │ └── wpa │ │ ├── Makefile │ │ ├── os_xtensa.c │ │ └── wpa_debug.c └── user │ ├── Makefile │ ├── README.md │ └── user_main.c ├── asm_damp.bat ├── bin ├── 0x00000.bin ├── 0x07000.bin ├── blank.bin ├── clear_eep.bin ├── esp_init_data_default.bin ├── rapid_loader.bin ├── rapid_loader_40m.bin └── readme.txt ├── esptool.py ├── include ├── arch │ ├── cc.h │ ├── perf.h │ └── sys_arch.h ├── bios.h ├── bios │ ├── add_funcs.h │ ├── cha1.h │ ├── ets.h │ ├── gpio.h │ ├── mem.h │ ├── rom_phy.h │ ├── rtc_dtm.h │ ├── spiflash.h │ ├── uart.h │ ├── vectors.h │ ├── xthal.h │ └── xtos.h ├── c_types.h ├── ets_sys.h ├── gpio.h ├── hw │ ├── core-isa.h │ ├── corebits.h │ ├── eagle_soc.h │ ├── eagle_soc_.h │ ├── esp8266.h │ ├── gpio_register.h │ ├── i2s_reg.h │ ├── pin_mux_register.h │ ├── sdio_slv.h │ ├── slc_register.h │ ├── specreg.h │ ├── spi.h │ ├── spi_register.h │ ├── timer_register.h │ └── uart_register.h ├── ip_addr.h ├── lwip │ ├── api.h │ ├── api_msg.h │ ├── app │ │ ├── dhcpserver.h │ │ ├── espconn.h │ │ ├── espconn_tcp.h │ │ ├── espconn_udp.h │ │ └── ping.h │ ├── arch.h │ ├── autoip.h │ ├── debug.h │ ├── def.h │ ├── dhcp.h │ ├── dns.h │ ├── err.h │ ├── icmp.h │ ├── igmp.h │ ├── inet.h │ ├── inet_chksum.h │ ├── init.h │ ├── ip.h │ ├── ip_addr.h │ ├── ip_frag.h │ ├── mdns.h │ ├── mem.h │ ├── memp.h │ ├── memp_std.h │ ├── netbuf.h │ ├── netdb.h │ ├── netif.h │ ├── netifapi.h │ ├── opt.h │ ├── pbuf.h │ ├── puck_def.h │ ├── raw.h │ ├── sio.h │ ├── snmp.h │ ├── snmp_asn1.h │ ├── snmp_msg.h │ ├── snmp_structs.h │ ├── sntp.h │ ├── sockets.h │ ├── stats.h │ ├── sys.h │ ├── tcp.h │ ├── tcp_impl.h │ ├── tcpip.h │ ├── timers.h │ └── udp.h ├── lwipopts.h ├── netif │ ├── etharp.h │ ├── if_llc.h │ ├── ppp_oe.h │ └── wlan_lwip_if.h ├── os_type.h ├── osapi.h ├── phy │ └── phy.h ├── pp │ └── esf_buf.h ├── queue.h ├── sdk │ ├── add_func.h │ ├── app_main.h │ ├── ets_run_new.h │ ├── fatal_errs.h │ ├── flash.h │ ├── libmain.h │ ├── mem_manager.h │ ├── os_printf.h │ ├── rom2ram.h │ ├── sdk_config.h │ ├── sys_const.h │ └── wdt.h ├── user_config.h └── user_interface.h ├── info ├── ESP8266_reg │ ├── ESP8266_Pin_List_141105.xlsx │ ├── ESP8266_RF_init_esp_init_data_default_bin.xlsx │ ├── gpio_reg.xlsx │ ├── pin_reg.xlsx │ ├── spi_reg.xlsx │ ├── timers_reg.xlsx │ └── uart_reg.xlsx └── libs │ ├── bios │ ├── SpiFlash.c │ ├── cha1.c │ ├── ets_run.c │ ├── gpio.c │ ├── mem.c │ ├── rtc_dtm.c │ ├── uartdev.c │ └── wdt.c │ ├── main │ ├── UserEnter.s │ ├── debug-vector.s │ ├── double-vector.s │ ├── kernel-vector.s │ ├── nmi-vector.s │ ├── nmi.c │ ├── startup.c │ ├── user-vector.s │ ├── user_interface.c │ └── wdt.c │ ├── net80211 │ ├── Descript.ion │ └── ieee80211_output.h │ └── phy │ ├── phy.c │ ├── phy_chip_v6.c │ ├── phy_get_vdd33.c │ └── phy_sleep.c ├── ld ├── eagle.app.v6.ld └── eagle.rom.addr.v6.ld ├── lib ├── clibsdk.bat ├── libcrypto.a ├── libdhcps.a ├── liblwipif.a ├── libmgcc.a ├── libmlwip.a ├── libmmain.a ├── libmmain.a.patch.txt ├── libmphy.a ├── libmwpa.a ├── libnet80211.a ├── libpp.a ├── libsdk.a ├── mlibsdk.bat ├── new_libdhcps.bat ├── new_liblwipif.bat ├── new_libmgcc.bat ├── new_libmlwip.bat ├── new_libmmain.bat ├── new_libmphy.bat ├── new_libmwpa.bat ├── o-asm.bat └── rom_files_list.txt ├── mem.txt └── mem_usage.bat /.gitignore: -------------------------------------------------------------------------------- 1 | *.output* 2 | /AutoMake/ 3 | /GreateLib/ 4 | /MinEspSDKLib.asm 5 | /eagle.app.v6.asm 6 | /CreateLib/ 7 | -------------------------------------------------------------------------------- /.project: -------------------------------------------------------------------------------- 1 | 2 | 3 | MinEspSDKLib 4 | 5 | 6 | 7 | 8 | 9 | org.eclipse.cdt.managedbuilder.core.genmakebuilder 10 | clean,full,incremental, 11 | 12 | 13 | 14 | 15 | org.eclipse.cdt.managedbuilder.core.ScannerConfigBuilder 16 | full,incremental, 17 | 18 | 19 | 20 | 21 | 22 | org.eclipse.cdt.core.cnature 23 | org.eclipse.cdt.core.ccnature 24 | org.eclipse.cdt.managedbuilder.core.managedBuildNature 25 | org.eclipse.cdt.managedbuilder.core.ScannerConfigNature 26 | 27 | 28 | -------------------------------------------------------------------------------- /.settings/language.settings.xml: -------------------------------------------------------------------------------- 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 9 | 10 | 11 | 12 | 13 | 14 | 15 | 16 | 17 | 18 | 19 | 20 | 21 | 22 | 23 | 24 | 25 | 26 | 27 | 28 | 29 | 30 | 31 | -------------------------------------------------------------------------------- /.settings/org.eclipse.cdt.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | environment/project/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786.1772762371/PATH/delimiter=; 3 | environment/project/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786.1772762371/PATH/operation=replace 4 | environment/project/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786.1772762371/PATH/value=C\:\\MinGW\\bin;C\:\\MinGW\\msys\\1.0\\bin;C\:\\Espressif\\xtensa-lx106-elf\\bin;C\:\\Python27 5 | environment/project/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786.1772762371/append=true 6 | environment/project/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786.1772762371/appendContributed=true 7 | environment/project/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786/PATH/delimiter=; 8 | environment/project/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786/PATH/operation=replace 9 | environment/project/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786/PATH/value=C\:\\MinGW\\bin;C\:\\MinGW\\msys\\1.0\\bin;C\:\\Espressif\\xtensa-lx106-elf\\bin;C\:\\Python27 10 | environment/project/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786/append=true 11 | environment/project/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786/appendContributed=true 12 | -------------------------------------------------------------------------------- /.settings/org.eclipse.cdt.managedbuilder.core.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | environment/buildEnvironmentInclude/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786.1772762371/CPATH/delimiter=; 3 | environment/buildEnvironmentInclude/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786.1772762371/CPATH/operation=remove 4 | environment/buildEnvironmentInclude/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786.1772762371/C_INCLUDE_PATH/delimiter=; 5 | environment/buildEnvironmentInclude/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786.1772762371/C_INCLUDE_PATH/operation=remove 6 | environment/buildEnvironmentInclude/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786.1772762371/append=true 7 | environment/buildEnvironmentInclude/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786.1772762371/appendContributed=true 8 | environment/buildEnvironmentInclude/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786/CPATH/delimiter=; 9 | environment/buildEnvironmentInclude/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786/CPATH/operation=remove 10 | environment/buildEnvironmentInclude/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786/C_INCLUDE_PATH/delimiter=; 11 | environment/buildEnvironmentInclude/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786/C_INCLUDE_PATH/operation=remove 12 | environment/buildEnvironmentInclude/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786/append=true 13 | environment/buildEnvironmentInclude/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786/appendContributed=true 14 | environment/buildEnvironmentLibrary/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786.1772762371/append=true 15 | environment/buildEnvironmentLibrary/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786.1772762371/appendContributed=true 16 | environment/buildEnvironmentLibrary/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786/LIBRARY_PATH/delimiter=; 17 | environment/buildEnvironmentLibrary/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786/LIBRARY_PATH/operation=remove 18 | environment/buildEnvironmentLibrary/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786/append=true 19 | environment/buildEnvironmentLibrary/cdt.managedbuild.toolchain.gnu.mingw.base.1544080900.2027218786/appendContributed=true 20 | -------------------------------------------------------------------------------- /.settings/org.eclipse.core.resources.prefs: -------------------------------------------------------------------------------- 1 | eclipse.preferences.version=1 2 | encoding/=UTF-8 3 | -------------------------------------------------------------------------------- /AutoMake.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | @if %1x==x goto aaa_end 3 | @if not exist %1 goto err_end 4 | @echo ------------------------------------------------------------------------------ 5 | @C:\Python27\python.exe ..\esptool.py elf2image -o ..\bin\ -ff 80m -fm qio -fs 4m %1 6 | @echo ------------------------------------------------------------------------------ 7 | @if not exist ..\bin\0x00000.bin goto err_end 8 | @echo Add rapid_loader... 9 | @if exist ..\bin\0.bin del ..\bin\0.bin >nul 10 | @rename ..\bin\0x00000.bin 0.bin >nul 11 | @copy /b ..\bin\rapid_loader.bin + ..\bin\0.bin ..\bin\0x00000.bin >nul 12 | goto end 13 | :aaa_end 14 | echo Use Eclipse Manage Configurations: AutoMake! 15 | goto end 16 | :err_end 17 | echo Error! 18 | :end 19 | -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | This is free and unencumbered software released into the public domain. 2 | 3 | Anyone is free to copy, modify, publish, use, compile, sell, or 4 | distribute this software, either in source code form or as a compiled 5 | binary, for any purpose, commercial or non-commercial, and by any 6 | means. 7 | 8 | In jurisdictions that recognize copyright laws, the author or authors 9 | of this software dedicate any and all copyright interest in the 10 | software to the public domain. We make this dedication for the benefit 11 | of the public at large and to the detriment of our heirs and 12 | successors. We intend this dedication to be an overt act of 13 | relinquishment in perpetuity of all present and future rights to this 14 | software under copyright law. 15 | 16 | THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, 17 | EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF 18 | MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. 19 | IN NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY CLAIM, DAMAGES OR 20 | OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, 21 | ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR 22 | OTHER DEALINGS IN THE SOFTWARE. 23 | 24 | For more information, please refer to 25 | -------------------------------------------------------------------------------- /ProgBin.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | @if %1x==x goto aaa_end 3 | @if not exist bin/%1.bin goto err_end 4 | @C:/Python27/python.exe esptool.py -p %2 -b %3 write_flash -ff 80m -fm qio -fs 4m 0x00000 bin/0x00000.bin %1 bin/%1.bin 5 | goto end 6 | :aaa_end 7 | echo Use Eclipse! 8 | goto end 9 | :err_end 10 | echo Error! 11 | :end 12 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # MinEspSDK (meSDK) 2 | Minimalist SDK on ESP8266ex v1.5.2 3 | --- 4 | 5 | A complete set of Wi-Fi and [LwIP](http://savannah.nongnu.org/projects/lwip/) functions.
6 | Имеет полный набор функций работы с WiFi и UDP/TCP (LwIP ver1.4.0).
7 | Данная сборка не содержит espconn и SSL.
8 | Проектируется для работы с датчиками и будет содержать расширения для быстрого
9 | старта после deep-sleep с возможностями управления дальнейшей загрузки SDK или
10 | опроса датчиков и нового перехода в режим deep-sleep.
11 | В целях экономии питания, время от просыпания после deep-sleep до старта опроса
12 | датчиков и для принятия решения повторного засыпания или загрузки полного SDK
13 | для коммуникации и передачи накопленных данных будет составлять 30..40 мс.
14 | В текщей версии, при стандартных настройках по умолчанию, после события подачи
15 | питания, reset или deep-sleep соединение по TCP при фиксированном ip модуля в
16 | режиме STATION к модулю в режиме SOFTAP устанавливается примерно не более чем
17 | через 540 мс. Основное время занимает инициализации SDK в части WiFi.
18 | Далее полудуплексный трафик TCP составляет более 1-го Мегабайта в секунду.
19 | 20 | From [Espressif SDK](http://bbs.espressif.com/) ver 1.5.2 used only:
21 | libpp.a, libwpa.a, libcrypto.a, libnet80211.a, parts libphy.a, user_interface.o
22 | Из [Espressif SDK](http://bbs.espressif.com/) ver 1.5.2 используются только описанные части.
23 | Остальные части даны с исходными кодами.
24 | LwIP based on [Open source LWIP for ESP_IOT_SDK_V1.4.0](http://bbs.espressif.com/viewtopic.php?f=46&t=1221).
25 | 26 | Supported options 48 kbytes IRAM.
27 | Supported '[Rapid Loader](https://github.com/pvvx/Rapid_Loader/)' and Flash 512 кbytes - 16 Mbytes.
28 | Поддержка расширенной памяти IRAM в 48 килобайт (опция USE_MAX_IRAM 48),
29 | Flash от 512 килобайт до 16 Мегабайт и ускоряющего загрузку SDK 'лоадера'.
30 | 31 | Free IRAM : 12 or 28 kbytes (option 48k IRAM)
32 | Free Heap : 55 kbytes
33 | Total Free RAM : 83 kbytes
34 | 35 | Options programming Flash:
36 | 37 | SPI_SPEED: 40MHz or 80MHz.
38 | SPI_MODE: QIO only.
39 | FLASH_SIZE: Always set the size to 512 KB flash.
40 | Automatic determination of the real size of the flash.
41 | При заливке прошивки в модуль всегда устанавливайте размер Flash в 512 килобайт.
42 | Реальный размер Flash определяется автоматически во время старта SDK.
43 | 44 | Для компиляции SDK используется [Unofficial Developer Kit](http://esp8266.ru/forum/forums/devkit/).
45 | 46 | В Eclipse заданы 3 опции Manage Configurations:
47 | 1. AutoMake (собрать проект для прошивки, используются установки в Eclipse)
48 | 2. CreateLib (собрать библиотеку libsdk.a, используются установки в Eclipse)
49 | 3. Default (собрать проект для прошивки, используя makefile)
50 | 51 | Полный комплект для сборки проекта с помощью SDK библиотеки:
52 | libsdk.a + [libmicroc.a](https://github.com/anakod/esp_microc) и include
53 | 54 | -------------------------------------------------------------------------------- /app/.gitignore: -------------------------------------------------------------------------------- 1 | *.output* 2 | -------------------------------------------------------------------------------- /app/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################# 2 | # Required variables for each makefile 3 | # Discard this section from all parent makefiles 4 | # Expected variables (with automatic defaults): 5 | # SUBDIRS (all subdirs with a Makefile) 6 | # GEN_LIBS - list of libs to be generated () 7 | # GEN_IMAGES - list of object file images to be generated () 8 | # GEN_BINS - list of binaries to be generated () 9 | # COMPONENTS_xxx - a list of libs/objs in the form 10 | # subdir/lib to be extracted and rolled up into 11 | # a generated lib/image xxx.a () 12 | # 13 | TARGET = eagle 14 | 15 | ifndef PDIR # { 16 | GEN_IMAGES = eagle.app.v6.out 17 | GEN_BINS = eagle.app.v6.bin 18 | 19 | SUBDIRS = \ 20 | sdklib \ 21 | user 22 | 23 | endif # } PDIR 24 | 25 | APPDIR = . 26 | LDDIR = ../ld 27 | 28 | LD_FILE = $(LDDIR)/eagle.app.v6.ld 29 | 30 | DEPENDS_eagle.app.v6 = \ 31 | $(LD_FILE) \ 32 | $(LDDIR)/eagle.rom.addr.v6.ld 33 | 34 | COMPONENTS_eagle.app.v6 = \ 35 | user/libuser.a 36 | 37 | LINK_LIBS = \ 38 | -lsdk 39 | 40 | # -lmicroc \ 41 | 42 | LINKFLAGS_eagle.app.v6 = \ 43 | -nostartfiles \ 44 | -nodefaultlibs \ 45 | -nostdlib \ 46 | -L../lib \ 47 | -T$(LD_FILE) \ 48 | -Wl,--no-check-sections \ 49 | -u call_user_start \ 50 | -Wl,-static \ 51 | -Wl,-Map -Wl,$(@:.out=.map) \ 52 | -Wl,--start-group \ 53 | $(LINK_LIBS) \ 54 | $(DEP_LIBS_eagle.app.v6) \ 55 | -Wl,--end-group 56 | 57 | # -Wl,--wrap=os_printf_plus \ 58 | 59 | CONFIGURATION_DEFINES += \ 60 | -DICACHE_FLASH \ 61 | -DPBUF_RSV_FOR_WLAN \ 62 | -DLWIP_OPEN_SRC \ 63 | -DEBUF_LWIP 64 | 65 | DEFINES += $(CONFIGURATION_DEFINES) 66 | 67 | DDEFINES += $(CONFIGURATION_DEFINES) 68 | 69 | ############################################################# 70 | # Recursion Magic - Don't touch this!! 71 | # 72 | # Each subtree potentially has an include directory 73 | # corresponding to the common APIs applicable to modules 74 | # rooted at that subtree. Accordingly, the INCLUDE PATH 75 | # of a module can only contain the include directories up 76 | # its parent path, and not its siblings 77 | # 78 | # Required for each makefile to inherit from the parent 79 | # 80 | 81 | #INCLUDES := $(INCLUDES) -I $(PDIR)include 82 | #INCLUDES += -I ./ 83 | PDIR := ../$(PDIR) 84 | sinclude $(PDIR)Makefile 85 | 86 | 87 | .PHONY: FORCE 88 | FORCE: 89 | -------------------------------------------------------------------------------- /app/sdklib/.gitignore: -------------------------------------------------------------------------------- 1 | *.output* 2 | -------------------------------------------------------------------------------- /app/sdklib/Makefile: -------------------------------------------------------------------------------- 1 | ############################################################# 2 | # Required variables for each makefile 3 | # Discard this section from all parent makefiles 4 | # Expected variables (with automatic defaults): 5 | # SUBDIRS (all subdirs with a Makefile) 6 | # GEN_LIBS - list of libs to be generated () 7 | # GEN_IMAGES - list of object file images to be generated () 8 | # GEN_BINS - list of binaries to be generated () 9 | # COMPONENTS_xxx - a list of libs/objs in the form 10 | # subdir/lib to be extracted and rolled up into 11 | # a generated lib/image xxx.a () 12 | # 13 | TARGET = eagle 14 | 15 | USE_OPEN_LWIP = 140 16 | USE_OPEN_DHCPS = 1 17 | 18 | UP_EXTRACT_DIR = .. 19 | 20 | COMPONENTS_libsdk = \ 21 | system/libaddmmain.a \ 22 | phy/libaddmphy.a \ 23 | pp/libaddpp.a \ 24 | wpa/libaddwpa.a 25 | 26 | ifdef USE_OPEN_LWIP 27 | COMPONENTS_libsdk += lwip/liblwip.a 28 | CONFIGURATION_DEFINES += -DUSE_OPEN_LWIP 29 | endif 30 | 31 | ifdef USE_OPEN_DHCPS 32 | CONFIGURATION_DEFINES += -DUSE_OPEN_DHCPS 33 | endif 34 | 35 | ifndef PDIR # { 36 | GEN_LIBS = libsdk.a 37 | SUBDIRS = \ 38 | system \ 39 | phy \ 40 | pp \ 41 | wpa 42 | 43 | ifdef USE_OPEN_LWIP 44 | SUBDIRS += lwip 45 | endif 46 | 47 | ADDLIBDIR = ../../lib/ 48 | SPECIAL_MKTARGETS = $(ADDLIBDIR)libsdk.a 49 | INPLIB = .output/eagle/lib/libsdk.a 50 | 51 | ADDLIBS_libsdk = \ 52 | libmgcc.a \ 53 | libmmain.a \ 54 | libmphy.a \ 55 | libpp.a \ 56 | libmwpa.a \ 57 | libcrypto.a \ 58 | libnet80211.a 59 | 60 | ifndef USE_OPEN_LWIP 61 | ADDLIBS_libsdk += \ 62 | liblwipif.a \ 63 | libmlwip.a 64 | endif 65 | 66 | ifndef USE_OPEN_DHCPS 67 | ADDLIBS_libsdk += libdhcps.a 68 | endif 69 | 70 | endif # } PDIR 71 | 72 | APPDIR = . 73 | 74 | ############################################################# 75 | # Recursion Magic - Don't touch this!! 76 | # 77 | # Each subtree potentially has an include directory 78 | # corresponding to the common APIs applicable to modules 79 | # rooted at that subtree. Accordingly, the INCLUDE PATH 80 | # of a module can only contain the include directories up 81 | # its parent path, and not its siblings 82 | # 83 | # Required for each makefile to inherit from the parent 84 | 85 | # INCLUDES := $(INCLUDES) -I $(PDIR)include 86 | PDIR := ../$(PDIR) 87 | sinclude $(PDIR)Makefile 88 | 89 | 90 | .PHONY: FORCE 91 | FORCE: 92 | -------------------------------------------------------------------------------- /app/sdklib/lwip/COPYING: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, 2002 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | 33 | 34 | -------------------------------------------------------------------------------- /app/sdklib/lwip/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | # Required variables for each makefile 4 | # Discard this section from all parent makefiles 5 | # Expected variables (with automatic defaults): 6 | # CSRCS (all "C" files in the dir) 7 | # SUBDIRS (all subdirs with a Makefile) 8 | # GEN_LIBS - list of libs to be generated () 9 | # GEN_IMAGES - list of images to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | ifndef PDIR 15 | UP_EXTRACT_DIR = .. 16 | GEN_LIBS = liblwip.a 17 | COMPONENTS_liblwip = api/liblwipapi.a \ 18 | app/liblwipapp.a \ 19 | core/liblwipcore.a \ 20 | core/ipv4/liblwipipv4.a \ 21 | netif/liblwipnetif.a 22 | endif 23 | 24 | 25 | ############################################################# 26 | # Configuration i.e. compile options etc. 27 | # Target specific stuff (defines etc.) goes in here! 28 | # Generally values applying to a tree are captured in the 29 | # makefile at its root level - these are then overridden 30 | # for a subtree within the makefile rooted therein 31 | # 32 | #DEFINES += 33 | 34 | ############################################################# 35 | # Recursion Magic - Don't touch this!! 36 | # 37 | # Each subtree potentially has an include directory 38 | # corresponding to the common APIs applicable to modules 39 | # rooted at that subtree. Accordingly, the INCLUDE PATH 40 | # of a module can only contain the include directories up 41 | # its parent path, and not its siblings 42 | # 43 | # Required for each makefile to inherit from the parent 44 | # 45 | 46 | INCLUDES := $(INCLUDES) -I $(PDIR)include 47 | INCLUDES += -I ./ 48 | PDIR := ../$(PDIR) 49 | sinclude $(PDIR)Makefile 50 | 51 | -------------------------------------------------------------------------------- /app/sdklib/lwip/api/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | # Required variables for each makefile 4 | # Discard this section from all parent makefiles 5 | # Expected variables (with automatic defaults): 6 | # CSRCS (all "C" files in the dir) 7 | # SUBDIRS (all subdirs with a Makefile) 8 | # GEN_LIBS - list of libs to be generated () 9 | # GEN_IMAGES - list of images to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | ifndef PDIR 15 | 16 | GEN_LIBS = liblwipapi.a 17 | 18 | endif 19 | 20 | 21 | ############################################################# 22 | # Configuration i.e. compile options etc. 23 | # Target specific stuff (defines etc.) goes in here! 24 | # Generally values applying to a tree are captured in the 25 | # makefile at its root level - these are then overridden 26 | # for a subtree within the makefile rooted therein 27 | # 28 | #DEFINES += 29 | 30 | ############################################################# 31 | # Recursion Magic - Don't touch this!! 32 | # 33 | # Each subtree potentially has an include directory 34 | # corresponding to the common APIs applicable to modules 35 | # rooted at that subtree. Accordingly, the INCLUDE PATH 36 | # of a module can only contain the include directories up 37 | # its parent path, and not its siblings 38 | # 39 | # Required for each makefile to inherit from the parent 40 | # 41 | 42 | INCLUDES := $(INCLUDES) -I $(PDIR)include 43 | INCLUDES += -I ./ 44 | PDIR := ../$(PDIR) 45 | sinclude $(PDIR)Makefile 46 | 47 | -------------------------------------------------------------------------------- /app/sdklib/lwip/api/err.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Error Management module 4 | * 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Adam Dunkels 36 | * 37 | */ 38 | 39 | #include "lwip/err.h" 40 | 41 | #ifdef LWIP_DEBUG 42 | 43 | static const char *err_strerr[] = { 44 | "Ok.", /* ERR_OK 0 */ 45 | "Out of memory error.", /* ERR_MEM -1 */ 46 | "Buffer error.", /* ERR_BUF -2 */ 47 | "Timeout.", /* ERR_TIMEOUT -3 */ 48 | "Routing problem.", /* ERR_RTE -4 */ 49 | "Operation in progress.", /* ERR_INPROGRESS -5 */ 50 | "Illegal value.", /* ERR_VAL -6 */ 51 | "Operation would block.", /* ERR_WOULDBLOCK -7 */ 52 | "Connection aborted.", /* ERR_ABRT -8 */ 53 | "Connection reset.", /* ERR_RST -9 */ 54 | "Connection closed.", /* ERR_CLSD -10 */ 55 | "Not connected.", /* ERR_CONN -11 */ 56 | "Illegal argument.", /* ERR_ARG -12 */ 57 | "Address in use.", /* ERR_USE -13 */ 58 | "Low-level netif error.", /* ERR_IF -14 */ 59 | "Already connected.", /* ERR_ISCONN -15 */ 60 | }; 61 | 62 | /** 63 | * Convert an lwip internal error to a string representation. 64 | * 65 | * @param err an lwip internal err_t 66 | * @return a string representation for err 67 | */ 68 | const char * 69 | lwip_strerr(err_t err) 70 | { 71 | return err_strerr[-err]; 72 | 73 | } 74 | 75 | #endif /* LWIP_DEBUG */ 76 | -------------------------------------------------------------------------------- /app/sdklib/lwip/api/netbuf.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/app/sdklib/lwip/api/netbuf.c -------------------------------------------------------------------------------- /app/sdklib/lwip/api/tcpip.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/app/sdklib/lwip/api/tcpip.c -------------------------------------------------------------------------------- /app/sdklib/lwip/app/Espressif.License: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/app/sdklib/lwip/app/Espressif.License -------------------------------------------------------------------------------- /app/sdklib/lwip/app/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | # Required variables for each makefile 4 | # Discard this section from all parent makefiles 5 | # Expected variables (with automatic defaults): 6 | # CSRCS (all "C" files in the dir) 7 | # SUBDIRS (all subdirs with a Makefile) 8 | # GEN_LIBS - list of libs to be generated () 9 | # GEN_IMAGES - list of images to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | ifndef PDIR 15 | 16 | GEN_LIBS = liblwipapp.a 17 | 18 | endif 19 | 20 | 21 | ############################################################# 22 | # Configuration i.e. compile options etc. 23 | # Target specific stuff (defines etc.) goes in here! 24 | # Generally values applying to a tree are captured in the 25 | # makefile at its root level - these are then overridden 26 | # for a subtree within the makefile rooted therein 27 | # 28 | #DEFINES += 29 | 30 | ############################################################# 31 | # Recursion Magic - Don't touch this!! 32 | # 33 | # Each subtree potentially has an include directory 34 | # corresponding to the common APIs applicable to modules 35 | # rooted at that subtree. Accordingly, the INCLUDE PATH 36 | # of a module can only contain the include directories up 37 | # its parent path, and not its siblings 38 | # 39 | # Required for each makefile to inherit from the parent 40 | # 41 | 42 | INCLUDES := $(INCLUDES) -I $(PDIR)include 43 | INCLUDES += -I ./ 44 | PDIR := ../$(PDIR) 45 | sinclude $(PDIR)Makefile 46 | 47 | -------------------------------------------------------------------------------- /app/sdklib/lwip/core/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | # Required variables for each makefile 4 | # Discard this section from all parent makefiles 5 | # Expected variables (with automatic defaults): 6 | # CSRCS (all "C" files in the dir) 7 | # SUBDIRS (all subdirs with a Makefile) 8 | # GEN_LIBS - list of libs to be generated () 9 | # GEN_IMAGES - list of images to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | ifndef PDIR 15 | 16 | GEN_LIBS = liblwipcore.a 17 | 18 | endif 19 | 20 | 21 | ############################################################# 22 | # Configuration i.e. compile options etc. 23 | # Target specific stuff (defines etc.) goes in here! 24 | # Generally values applying to a tree are captured in the 25 | # makefile at its root level - these are then overridden 26 | # for a subtree within the makefile rooted therein 27 | # 28 | #DEFINES += 29 | 30 | ############################################################# 31 | # Recursion Magic - Don't touch this!! 32 | # 33 | # Each subtree potentially has an include directory 34 | # corresponding to the common APIs applicable to modules 35 | # rooted at that subtree. Accordingly, the INCLUDE PATH 36 | # of a module can only contain the include directories up 37 | # its parent path, and not its siblings 38 | # 39 | # Required for each makefile to inherit from the parent 40 | # 41 | 42 | INCLUDES := $(INCLUDES) -I $(PDIR)include 43 | INCLUDES += -I ./ 44 | PDIR := ../$(PDIR) 45 | sinclude $(PDIR)Makefile 46 | 47 | -------------------------------------------------------------------------------- /app/sdklib/lwip/core/def.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Common functions used throughout the stack. 4 | * 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Simon Goldschmidt 36 | * 37 | */ 38 | 39 | #include "lwip/opt.h" 40 | #include "lwip/def.h" 41 | 42 | /** 43 | * These are reference implementations of the byte swapping functions. 44 | * Again with the aim of being simple, correct and fully portable. 45 | * Byte swapping is the second thing you would want to optimize. You will 46 | * need to port it to your architecture and in your cc.h: 47 | * 48 | * #define LWIP_PLATFORM_BYTESWAP 1 49 | * #define LWIP_PLATFORM_HTONS(x) 50 | * #define LWIP_PLATFORM_HTONL(x) 51 | * 52 | * Note ntohs() and ntohl() are merely references to the htonx counterparts. 53 | */ 54 | 55 | #if (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN) 56 | 57 | /** 58 | * Convert an u16_t from host- to network byte order. 59 | * 60 | * @param n u16_t in host byte order 61 | * @return n in network byte order 62 | */ 63 | u16_t 64 | lwip_htons(u16_t n) 65 | { 66 | return ((n & 0xff) << 8) | ((n & 0xff00) >> 8); 67 | } 68 | 69 | /** 70 | * Convert an u16_t from network- to host byte order. 71 | * 72 | * @param n u16_t in network byte order 73 | * @return n in host byte order 74 | */ 75 | u16_t 76 | lwip_ntohs(u16_t n) 77 | { 78 | return lwip_htons(n); 79 | } 80 | 81 | /** 82 | * Convert an u32_t from host- to network byte order. 83 | * 84 | * @param n u32_t in host byte order 85 | * @return n in network byte order 86 | */ 87 | u32_t 88 | lwip_htonl(u32_t n) 89 | { 90 | return ((n & 0xff) << 24) | 91 | ((n & 0xff00) << 8) | 92 | ((n & 0xff0000UL) >> 8) | 93 | ((n & 0xff000000UL) >> 24); 94 | } 95 | 96 | /** 97 | * Convert an u32_t from network- to host byte order. 98 | * 99 | * @param n u32_t in network byte order 100 | * @return n in host byte order 101 | */ 102 | u32_t 103 | lwip_ntohl(u32_t n) 104 | { 105 | return lwip_htonl(n); 106 | } 107 | 108 | #endif /* (LWIP_PLATFORM_BYTESWAP == 0) && (BYTE_ORDER == LITTLE_ENDIAN) */ 109 | -------------------------------------------------------------------------------- /app/sdklib/lwip/core/ipv4/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | # Required variables for each makefile 4 | # Discard this section from all parent makefiles 5 | # Expected variables (with automatic defaults): 6 | # CSRCS (all "C" files in the dir) 7 | # SUBDIRS (all subdirs with a Makefile) 8 | # GEN_LIBS - list of libs to be generated () 9 | # GEN_IMAGES - list of images to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | ifndef PDIR 15 | 16 | GEN_LIBS = liblwipipv4.a 17 | 18 | endif 19 | 20 | 21 | ############################################################# 22 | # Configuration i.e. compile options etc. 23 | # Target specific stuff (defines etc.) goes in here! 24 | # Generally values applying to a tree are captured in the 25 | # makefile at its root level - these are then overridden 26 | # for a subtree within the makefile rooted therein 27 | # 28 | #DEFINES += 29 | 30 | ############################################################# 31 | # Recursion Magic - Don't touch this!! 32 | # 33 | # Each subtree potentially has an include directory 34 | # corresponding to the common APIs applicable to modules 35 | # rooted at that subtree. Accordingly, the INCLUDE PATH 36 | # of a module can only contain the include directories up 37 | # its parent path, and not its siblings 38 | # 39 | # Required for each makefile to inherit from the parent 40 | # 41 | 42 | INCLUDES := $(INCLUDES) -I $(PDIR)include 43 | INCLUDES += -I ./ 44 | PDIR := ../$(PDIR) 45 | sinclude $(PDIR)Makefile 46 | 47 | -------------------------------------------------------------------------------- /app/sdklib/lwip/core/ipv4/icmp.c: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/app/sdklib/lwip/core/ipv4/icmp.c -------------------------------------------------------------------------------- /app/sdklib/lwip/core/ipv4/inet.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Functions common to all TCP/IPv4 modules, such as the byte order functions. 4 | * 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Adam Dunkels 36 | * 37 | */ 38 | 39 | #include "lwip/opt.h" 40 | 41 | #include "lwip/inet.h" 42 | 43 | -------------------------------------------------------------------------------- /app/sdklib/lwip/core/sys.c: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * lwIP Operating System abstraction 4 | * 5 | */ 6 | 7 | /* 8 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 9 | * All rights reserved. 10 | * 11 | * Redistribution and use in source and binary forms, with or without modification, 12 | * are permitted provided that the following conditions are met: 13 | * 14 | * 1. Redistributions of source code must retain the above copyright notice, 15 | * this list of conditions and the following disclaimer. 16 | * 2. Redistributions in binary form must reproduce the above copyright notice, 17 | * this list of conditions and the following disclaimer in the documentation 18 | * and/or other materials provided with the distribution. 19 | * 3. The name of the author may not be used to endorse or promote products 20 | * derived from this software without specific prior written permission. 21 | * 22 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 23 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 24 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 25 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 26 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 27 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 28 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 29 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 30 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 31 | * OF SUCH DAMAGE. 32 | * 33 | * This file is part of the lwIP TCP/IP stack. 34 | * 35 | * Author: Adam Dunkels 36 | * 37 | */ 38 | 39 | #include "lwip/opt.h" 40 | 41 | #include "lwip/sys.h" 42 | 43 | /* Most of the functions defined in sys.h must be implemented in the 44 | * architecture-dependent file sys_arch.c */ 45 | 46 | #if !NO_SYS 47 | 48 | /** 49 | * Sleep for some ms. Timeouts are NOT processed while sleeping. 50 | * 51 | * @param ms number of milliseconds to sleep 52 | */ 53 | void 54 | sys_msleep(u32_t ms) 55 | { 56 | if (ms > 0) { 57 | sys_sem_t delaysem; 58 | err_t err = sys_sem_new(&delaysem, 0); 59 | if (err == ERR_OK) { 60 | sys_arch_sem_wait(&delaysem, ms); 61 | sys_sem_free(&delaysem); 62 | } 63 | } 64 | } 65 | 66 | #endif /* !NO_SYS */ 67 | -------------------------------------------------------------------------------- /app/sdklib/lwip/netif/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | # Required variables for each makefile 4 | # Discard this section from all parent makefiles 5 | # Expected variables (with automatic defaults): 6 | # CSRCS (all "C" files in the dir) 7 | # SUBDIRS (all subdirs with a Makefile) 8 | # GEN_LIBS - list of libs to be generated () 9 | # GEN_IMAGES - list of images to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | ifndef PDIR 15 | 16 | GEN_LIBS = liblwipnetif.a 17 | 18 | endif 19 | 20 | 21 | ############################################################# 22 | # Configuration i.e. compile options etc. 23 | # Target specific stuff (defines etc.) goes in here! 24 | # Generally values applying to a tree are captured in the 25 | # makefile at its root level - these are then overridden 26 | # for a subtree within the makefile rooted therein 27 | # 28 | #DEFINES += 29 | 30 | ############################################################# 31 | # Recursion Magic - Don't touch this!! 32 | # 33 | # Each subtree potentially has an include directory 34 | # corresponding to the common APIs applicable to modules 35 | # rooted at that subtree. Accordingly, the INCLUDE PATH 36 | # of a module can only contain the include directories up 37 | # its parent path, and not its siblings 38 | # 39 | # Required for each makefile to inherit from the parent 40 | # 41 | 42 | INCLUDES := $(INCLUDES) -I $(PDIR)include 43 | INCLUDES += -I ./ 44 | PDIR := ../$(PDIR) 45 | sinclude $(PDIR)Makefile 46 | 47 | -------------------------------------------------------------------------------- /app/sdklib/phy/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | # Required variables for each makefile 4 | # Discard this section from all parent makefiles 5 | # Expected variables (with automatic defaults): 6 | # CSRCS (all "C" files in the dir) 7 | # SUBDIRS (all subdirs with a Makefile) 8 | # GEN_LIBS - list of libs to be generated () 9 | # GEN_IMAGES - list of images to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | ifndef PDIR 15 | GEN_LIBS = libaddmphy.a 16 | endif 17 | 18 | ############################################################# 19 | # Configuration i.e. compile options etc. 20 | # Target specific stuff (defines etc.) goes in here! 21 | # Generally values applying to a tree are captured in the 22 | # makefile at its root level - these are then overridden 23 | # for a subtree within the makefile rooted therein 24 | # 25 | #DEFINES += 26 | 27 | ############################################################# 28 | # Recursion Magic - Don't touch this!! 29 | # 30 | # Each subtree potentially has an include directory 31 | # corresponding to the common APIs applicable to modules 32 | # rooted at that subtree. Accordingly, the INCLUDE PATH 33 | # of a module can only contain the include directories up 34 | # its parent path, and not its siblings 35 | # 36 | # Required for each makefile to inherit from the parent 37 | # 38 | 39 | #INCLUDES := $(INCLUDES) -I $(PDIR)include 40 | PDIR := ../$(PDIR) 41 | sinclude $(PDIR)Makefile 42 | 43 | -------------------------------------------------------------------------------- /app/sdklib/phy/phy_chip_v6_unused.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: phy_chip_v6_unused.c 3 | * Description: Alternate SDK (libphy.a) 4 | * (c) PV` 2015 5 | *******************************************************************************/ 6 | #include "user_config.h" 7 | #include "bios.h" 8 | #include "hw/esp8266.h" 9 | #include "phy/phy.h" 10 | 11 | // (!) закоменитрованы неиспользуемые функции 12 | 13 | // вызывается из phy_chip_v6.o 14 | void ICACHE_FLASH_ATTR chip_v6_set_sense(void) 15 | { 16 | // ret.n 17 | } 18 | 19 | /* 20 | void ICACHE_FLASH_ATTR chip_v6_get_sense(void) 21 | { 22 | // ret.n 23 | } 24 | */ 25 | 26 | // вызывается из phy_chip_v6.o 27 | int ICACHE_FLASH_ATTR chip_v6_unset_chanfreq(void) 28 | { 29 | return 0; 30 | } 31 | 32 | /* 33 | int ICACHE_FLASH_ATTR data_collect(void) 34 | { 35 | ??? 36 | } 37 | 38 | void ICACHE_FLASH_ATTR operation_test(void) 39 | { 40 | ??? 41 | } 42 | 43 | 44 | // используется из slop_test() 45 | void ICACHE_FLASH_ATTR slop_wdt_feed(void) 46 | { 47 | WDT_FEED = WDT_FEED_MAGIC; 48 | } 49 | 50 | void ICACHE_FLASH_ATTR slop_test(void) 51 | { 52 | 53 | os_printf_plus("slop_test\n"); 54 | CLK_PRE_PORT |= 1; 55 | i2c_writeReg_Mask(106, 2, 8, 4, 0, 0); 56 | uint32 x = IOREG(0x3FF20C00); 57 | RFChannelSel(14); 58 | int i; 59 | for(i=0; i<200; i++) { 60 | slop_wdt_feed(); 61 | IOREG(0x60000738) = operation_test(); 62 | pm_set_sleep_mode(2); 63 | pm_wakeup_opt(8, 0); 64 | pm_set_sleep_cycles(170); 65 | x = IOREG(0x3FF20C00); 66 | pm_goto_sleep(2); 67 | pm_wait4wakeup(2); 68 | pm_wakeup_init(2, 0); 69 | x = IOREG(0x3FF20C00); 70 | } 71 | } 72 | 73 | void ICACHE_FLASH_ATTR wd_reset_cnt(void) 74 | { 75 | uint32 x = rtc_get_reset_reason(); 76 | if(x == 4) os_printf("wd_reset %d\n", RTC_RAM_BASE[0xFC>>2]); 77 | else if(x == 2 || x != 1) { 78 | RTC_RAM_BASE[0xFC>>2] = 0; 79 | os_printf("wd_reset %d\n", RTC_RAM_BASE[0xFC>>2]); 80 | } 81 | } 82 | */ 83 | -------------------------------------------------------------------------------- /app/sdklib/pp/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | # Required variables for each makefile 4 | # Discard this section from all parent makefiles 5 | # Expected variables (with automatic defaults): 6 | # CSRCS (all "C" files in the dir) 7 | # SUBDIRS (all subdirs with a Makefile) 8 | # GEN_LIBS - list of libs to be generated () 9 | # GEN_IMAGES - list of images to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | ifndef PDIR 15 | GEN_LIBS = libaddpp.a 16 | endif 17 | 18 | ############################################################# 19 | # Configuration i.e. compile options etc. 20 | # Target specific stuff (defines etc.) goes in here! 21 | # Generally values applying to a tree are captured in the 22 | # makefile at its root level - these are then overridden 23 | # for a subtree within the makefile rooted therein 24 | # 25 | #DEFINES += 26 | 27 | ############################################################# 28 | # Recursion Magic - Don't touch this!! 29 | # 30 | # Each subtree potentially has an include directory 31 | # corresponding to the common APIs applicable to modules 32 | # rooted at that subtree. Accordingly, the INCLUDE PATH 33 | # of a module can only contain the include directories up 34 | # its parent path, and not its siblings 35 | # 36 | # Required for each makefile to inherit from the parent 37 | # 38 | 39 | PDIR := ../$(PDIR) 40 | sinclude $(PDIR)Makefile 41 | 42 | -------------------------------------------------------------------------------- /app/sdklib/pp/pplibadd.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FileName: pplibadd.c 3 | * Description: Alternate SDK (libpp.a) 4 | * (c) PV` 2015 5 | */ 6 | #include "c_types.h" 7 | #include "user_config.h" 8 | 9 | #if DEF_SDK_VERSION >= 1300 10 | /* bit_popcount() используется из SDK libpp.a: if_hwctrl.o и trc.o */ 11 | uint32 ICACHE_FLASH_ATTR bit_popcount(uint32 x) 12 | { 13 | uint32 ret = 0; 14 | while(x) { 15 | ret += x & 1; 16 | x >>= 1; 17 | } 18 | return ret; 19 | } 20 | #endif 21 | -------------------------------------------------------------------------------- /app/sdklib/system/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | # Required variables for each makefile 4 | # Discard this section from all parent makefiles 5 | # Expected variables (with automatic defaults): 6 | # CSRCS (all "C" files in the dir) 7 | # SUBDIRS (all subdirs with a Makefile) 8 | # GEN_LIBS - list of libs to be generated () 9 | # GEN_IMAGES - list of images to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | ifndef PDIR 15 | GEN_LIBS = libaddmmain.a 16 | endif 17 | 18 | ############################################################# 19 | # Configuration i.e. compile options etc. 20 | # Target specific stuff (defines etc.) goes in here! 21 | # Generally values applying to a tree are captured in the 22 | # makefile at its root level - these are then overridden 23 | # for a subtree within the makefile rooted therein 24 | # 25 | #DEFINES += 26 | 27 | ############################################################# 28 | # Recursion Magic - Don't touch this!! 29 | # 30 | # Each subtree potentially has an include directory 31 | # corresponding to the common APIs applicable to modules 32 | # rooted at that subtree. Accordingly, the INCLUDE PATH 33 | # of a module can only contain the include directories up 34 | # its parent path, and not its siblings 35 | # 36 | # Required for each makefile to inherit from the parent 37 | # 38 | 39 | #INCLUDES := $(INCLUDES) -I $(PDIR)include 40 | #INCLUDES += -I ./include 41 | PDIR := ../$(PDIR) 42 | sinclude $(PDIR)Makefile 43 | 44 | -------------------------------------------------------------------------------- /app/sdklib/system/ets_run_new.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: ets_run_new.c 3 | * Description: Alternate SDK 4 | * (c) PV` 2015 5 | ******************************************************************************/ 6 | 7 | #include "sdk/sdk_config.h" 8 | #ifdef USE_ETS_RUN_NEW 9 | #include "bios.h" 10 | #include "hw/esp8266.h" 11 | #include "hw/spi_register.h" 12 | #include "sdk/add_func.h" 13 | 14 | #define SDK_TASKS_WAIT 20480 // 20 ms. Максимальное время между запусками обработки задач SDK/WiFi при использовании run_sdk_tasks() в цикле 15 | #define SDK_TASKS_RUNT 1024 // 1 ms. Время для обработки задач SDK/WiFi при использования run_sdk_tasks() в цикле 16 | #define MIN_DELAY_US 512 // 512 us. Минимальное время для отработки task_delay_us(us), если меньше то вызывается ets_delay_us(us); 17 | 18 | 19 | uint32 old_task_time DATA_IRAM_ATTR; // штамп времени поледнего запуска обработки задач SDK/WiFi 20 | volatile uint32 ets_run_ret DATA_IRAM_ATTR; // флаг выхода из ets_run_new() 21 | 22 | void ICACHE_IRAM_ATTR ets_run_new(void) { 23 | uint8 bnum; 24 | uint8 bctp = ets_bit_task_priority = 0; 25 | while (1) { 26 | while (1) { 27 | ets_intr_lock(); 28 | bnum = ets_bit_count_task; 29 | asm volatile ("nsau %0, %1;" :"=r"(bnum) : "r"(bnum)); // Normalization Shift Amount Unsigned 30 | bnum = 32 - bnum; 31 | if (bctp < bnum) 32 | break; 33 | if (SPI0_CTRL & SPI_ENABLE_AHB) { // 'cache flash' включена? Можно вызывать callbacks. 34 | if (ets_idle_cb != NULL) 35 | ets_idle_cb(ets_idle_arg); 36 | else if (ets_run_ret) { 37 | ets_run_ret = 0; 38 | ets_intr_unlock(); 39 | return; 40 | } 41 | } 42 | asm volatile ("waiti 0;"); // Wait for Interrupt 43 | ets_intr_unlock(); 44 | }; 45 | ss_task * cur_task = &ets_tab_task[bnum - 1]; 46 | sargc_tsk * argc = &cur_task->argc[cur_task->cnts++]; 47 | if (cur_task->size == cur_task->cnts) 48 | cur_task->cnts = 0; 49 | if (--cur_task->cnte == 0) { 50 | ets_bit_count_task &= ~cur_task->bitn; 51 | } 52 | ets_bit_task_priority = bnum; 53 | ets_intr_unlock(); 54 | cur_task->func(argc); 55 | ets_bit_task_priority = bctp; 56 | }; 57 | } 58 | 59 | void delay_wait_cb(void *px) { 60 | old_task_time = phy_get_mactime(); 61 | ets_run_ret = 1; 62 | } 63 | 64 | void ICACHE_FLASH_ATTR task_delay_us(uint32 us) { 65 | if (us < MIN_DELAY_US) 66 | ets_delay_us(us); 67 | else { 68 | ETSTimer delay_timer; 69 | ets_timer_disarm(&delay_timer); 70 | ets_timer_setfn(&delay_timer, (ETSTimerFunc *) (delay_wait_cb), NULL); 71 | ets_timer_arm_new(&delay_timer, us - 128, 0, 0); 72 | ets_run_new(); 73 | } 74 | } 75 | 76 | void ICACHE_FLASH_ATTR run_sdk_tasks(void) { 77 | uint32 t = phy_get_mactime(); 78 | if (t - old_task_time > SDK_TASKS_WAIT) { 79 | task_delay_us(SDK_TASKS_RUNT); 80 | } 81 | } 82 | 83 | #endif // USE_ETS_RUN_NEW 84 | -------------------------------------------------------------------------------- /app/sdklib/system/ets_timer.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: ets_timer.c 3 | * Description: Alternate SDK (libmain.a) 4 | * (c) PV` 2015 5 | ******************************************************************************/ 6 | #include "bios.h" 7 | #include "hw/eagle_soc.h" 8 | #include "hw/esp8266.h" 9 | 10 | extern bool timer2_ms_flag; 11 | 12 | #define MIN_US_TIMER 0 13 | 14 | // us timer 15 | // 0xFFFFFFFF/(80000000 >> 4) = 858.993459 16 | // (80000000 >> 4)/(1000000>>2) = 20 17 | // (80000000 >> 4)/1000000 = 5 18 | // ms timer 19 | // 0xFFFFFFFF/(80000000 >> 8) = 13743.895344 20 | // (80000000 >> 8)/(1000>>2) = 1250 21 | // (80000000 >> 8)/1000 = 312.5 22 | #define XS_TO_RTC_TIMER_TICKS(t, prescaler, period) \ 23 | (((t) > (0xFFFFFFFF/(APB_CLK_FREQ >> prescaler))) ? \ 24 | (((t) >> 2) * ((APB_CLK_FREQ >> prescaler)/(period>>2)) + ((t) & 0x3) * ((APB_CLK_FREQ >> prescaler)/period)) : \ 25 | (((t) * (APB_CLK_FREQ >> prescaler)) / period)) 26 | 27 | void ets_timer_arm_new(ETSTimer *ptimer, uint32_t us_ms, int repeat_flag, int isMstimer) 28 | { 29 | ets_intr_lock(); 30 | if(ptimer->timer_next != (ETSTimer *)0xffffffff) ets_timer_disarm(ptimer); 31 | if(us_ms) { 32 | if(timer2_ms_flag == 0) { // us_timer 33 | if(isMstimer) us_ms *= 1000; 34 | #if ((APB_CLK_FREQ>>4)%1000000) 35 | us_ms = XS_TO_RTC_TIMER_TICKS(us_ms, 4, 1000000); 36 | #else 37 | us_ms *= (APB_CLK_FREQ>>4)/1000000; 38 | #endif 39 | } 40 | else { // ms_timer 41 | #if ((APB_CLK_FREQ>>8)%1000) 42 | us_ms = XS_TO_RTC_TIMER_TICKS(us_ms, 8, 1000); 43 | #else 44 | us_ms *= (APB_CLK_FREQ>>8)/1000; 45 | #endif 46 | } 47 | } 48 | #if MIN_US_TIMER != 0 49 | if(us_ms < MIN_US_TIMER) us_ms = MIN_US_TIMER; 50 | #endif 51 | if(repeat_flag) ptimer->timer_period = us_ms; 52 | MEMW(); 53 | timer_insert(TIMER1_COUNT + us_ms, ptimer); 54 | } 55 | 56 | /* 57 | // ------------------------------------------------------ 58 | // system_timer_reinit 59 | // устанавливает делитель таймера на :16 вместо :256 60 | void ICACHE_FLASH_ATTR system_timer_reinit(void) 61 | { 62 | timer2_ms_flag = 1; 63 | TIMER1_CTRL = 0x84; 64 | } 65 | */ 66 | -------------------------------------------------------------------------------- /app/sdklib/system/os_printf.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: os_printf.c 3 | * Description: Alternate SDK (libmain.a) 4 | * (c) PV` 2015 5 | *******************************************************************************/ 6 | #include "bios.h" 7 | #include 8 | #include "sdk/rom2ram.h" 9 | #include "sdk/os_printf.h" 10 | 11 | extern char * _sprintf_buf; // 0x3FFFE360 12 | extern char print_mem_buf[1024]; // 0x3FFFE364..0x3FFFEA80 max 1820 bytes 13 | extern bool system_get_os_print(void); 14 | //============================================================================= 15 | // FLASH code (ICACHE_FLASH_ATTR) 16 | //============================================================================= 17 | //============================================================================= 18 | // int os_printf_plus(const char *format, ...) 19 | // Использует буфер в области RAM-BIOS 20 | //----------------------------------------------------------------------------- 21 | int ICACHE_FLASH_ATTR __wrap_os_printf_plus(const char *format, ...) 22 | //int ICACHE_FLASH_ATTR rom_printf(const char *format, ...) 23 | { 24 | int i = 0; 25 | if(system_get_os_print()) { 26 | va_list args; 27 | va_start(args, format); 28 | i = ets_vprintf(ets_write_char, ((uint32)format >> 30)? rom_strcpy(print_mem_buf, (void *)format, sizeof(print_mem_buf)-1) : format, args); 29 | va_end (args); 30 | } 31 | return i; 32 | } 33 | 34 | //============================================================================= 35 | // int os_sprintf_plus(char *str, const char *format, ...) 36 | // Использует буфер в области RAM-BIOS 37 | // Вывод может быть расположен в IRAM 38 | //----------------------------------------------------------------------------- 39 | void ICACHE_FLASH_ATTR _sprintf_out(char c) 40 | { 41 | if(_sprintf_buf != NULL) { 42 | write_align4_chr(_sprintf_buf++, c); // *_sprintf_buf++ = c; 43 | write_align4_chr(_sprintf_buf, 0); // *_sprintf_buf = 0; 44 | } 45 | } 46 | 47 | int ICACHE_FLASH_ATTR ets_sprintf(char *str, const char *format, ...) 48 | { 49 | _sprintf_buf = str; 50 | va_list args; 51 | va_start(args, format); 52 | int i = ets_vprintf(_sprintf_out, ((uint32)format >> 30)? rom_strcpy(print_mem_buf, (void *)format, sizeof(print_mem_buf)-1) : format, args); 53 | va_end (args); 54 | return i; 55 | } 56 | -------------------------------------------------------------------------------- /app/sdklib/system/spi_overlap.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: app_main.c 3 | * Description: Alternate SDK (libmain.a) 4 | * (c) PV` 2015 5 | * disasm SDK 1.2.0 6 | *******************************************************************************/ 7 | #include "user_config.h" 8 | 9 | #ifdef USE_OVERLAP_MODE 10 | // не используется для модулей с одной flash! 11 | #include "bios.h" 12 | #include "hw/esp8266.h" 13 | #include "hw/spi_register.h" 14 | #include "flash.h" 15 | 16 | user_spi_flash_read flash_read DATA_IRAM_ATTR; 17 | //============================================================================= 18 | // overlap_hspi_read_data() 19 | //----------------------------------------------------------------------------- 20 | void spi_flash_set_read_func(user_spi_flash_read read) 21 | { 22 | flash_read = read; 23 | } 24 | //============================================================================= 25 | // overlap_hspi_init() 26 | //----------------------------------------------------------------------------- 27 | void overlap_hspi_init(void) 28 | { 29 | while((SPI0_EXT2) || (SPI1_CMD & 0xFFFC0000)); // 0x600001F8 || 0x60000100 30 | PERI_IO_SWAP |= 0x80; // two spi masters on cspi 31 | SPI0_EXT3 |= 1; 32 | SPI1_EXT3 |= SPI_INT_HOLD_ENA; 33 | SPI1_USER |= SPI_CS_SETUP; 34 | SPI1_PIN = (SPI1_PIN & 0xfffffffe) | (SPI_CS2_DIS | SPI_CS1_DIS); // SPI_CS0_ENA 35 | // SPI1_CLOCK &= ~SPI_CLK_EQU_SYSCLK; // deleted in SDKv1.1.0 libmain_patch_01.a 36 | } 37 | //============================================================================= 38 | // overlap_hspi_deinit() 39 | //----------------------------------------------------------------------------- 40 | void overlap_hspi_deinit(void) 41 | { 42 | while((SPI0_EXT2) || (SPI1_CMD & 0xFFFC0000)); // 0x600001F8 || 0x60000100 43 | PERI_IO_SWAP &= 0xFFFFFF7F; // two spi masters on cspi 44 | SPI0_EXT3 &= 0xFFFFFFFE; 45 | SPI1_EXT3 &= 0xFFFFFFFC; 46 | SPI1_USER &= 0xFFFFFFDF; 47 | SPI1_PIN = (SPI1_PIN & 0xfffffffe) | (SPI_CS2_DIS | SPI_CS1_DIS); 48 | // SPI1_CLOCK &= ~SPI_CLK_EQU_SYSCLK; // deleted in SDKv1.1.0 libmain_patch_01.a 49 | } 50 | //============================================================================= 51 | // overlap_hspi_read_data() 52 | //----------------------------------------------------------------------------- 53 | #define SPI_FBLK 32 54 | int overlap_hspi_read_data(SpiFlashChip *fchip, uint32 faddr, void *des, uint32 size) 55 | { 56 | SPI1_PIN = (SPI1_PIN & 0x7E) | (SPI_CS2_DIS | SPI_CS1_DIS); 57 | if(fchip->chip_size < faddr + size) return SPI_FLASH_RESULT_OK; 58 | if(des == NULL) return SPI_FLASH_RESULT_ERR; 59 | if(size < 1) return SPI_FLASH_RESULT_ERR; 60 | uint32 blksize = (uint32)des & 3; 61 | if(blksize) { 62 | blksize = 4 - blksize; 63 | if(size < blksize) blksize = size; 64 | SPI1_ADDR = faddr | (blksize << 24); 65 | SPI1_CMD = SPI_READ; 66 | size -= blksize; 67 | faddr += blksize; 68 | while(SPI1_CMD); 69 | register uint32 data_buf = SPI1_W0; 70 | do { 71 | *(uint8 *)des = data_buf; 72 | des = (uint8 *)des + 1; 73 | data_buf >>= 8; 74 | } while(--blksize); 75 | } 76 | while(size) { 77 | if(size < SPI_FBLK) blksize = size; 78 | else blksize = SPI_FBLK; 79 | SPI1_ADDR = faddr | (blksize << 24); 80 | SPI1_CMD = SPI_READ; 81 | size -= blksize; 82 | faddr += blksize; 83 | while(SPI1_CMD); 84 | // volatile uint32 *srcdw = (volatile uint32 *)(SPI0_BASE+0x40); 85 | uint32 *srcdw = (uint32 *)(&SPI1_W0); 86 | // uint32 *srcdw = (uint32 *)(SPI0_BASE+0x40); 87 | while(blksize >> 2) { 88 | *((uint32 *)des) = *srcdw++; 89 | des = ((uint32 *)des) + 1; 90 | blksize -= 4; 91 | } 92 | if(blksize) { 93 | uint32 data_buf = *srcdw; 94 | do { 95 | *(uint8 *)des = data_buf; 96 | des = (uint8 *)des + 1; 97 | data_buf >>= 8; 98 | } while(--blksize); 99 | break; 100 | } 101 | } 102 | return SPI_FLASH_RESULT_OK; 103 | } 104 | 105 | 106 | #endif 107 | -------------------------------------------------------------------------------- /app/sdklib/wpa/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | # Required variables for each makefile 4 | # Discard this section from all parent makefiles 5 | # Expected variables (with automatic defaults): 6 | # CSRCS (all "C" files in the dir) 7 | # SUBDIRS (all subdirs with a Makefile) 8 | # GEN_LIBS - list of libs to be generated () 9 | # GEN_IMAGES - list of images to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | ifndef PDIR 15 | GEN_LIBS = libaddwpa.a 16 | endif 17 | 18 | ############################################################# 19 | # Configuration i.e. compile options etc. 20 | # Target specific stuff (defines etc.) goes in here! 21 | # Generally values applying to a tree are captured in the 22 | # makefile at its root level - these are then overridden 23 | # for a subtree within the makefile rooted therein 24 | # 25 | #DEFINES += 26 | 27 | ############################################################# 28 | # Recursion Magic - Don't touch this!! 29 | # 30 | # Each subtree potentially has an include directory 31 | # corresponding to the common APIs applicable to modules 32 | # rooted at that subtree. Accordingly, the INCLUDE PATH 33 | # of a module can only contain the include directories up 34 | # its parent path, and not its siblings 35 | # 36 | # Required for each makefile to inherit from the parent 37 | # 38 | 39 | PDIR := ../$(PDIR) 40 | sinclude $(PDIR)Makefile 41 | 42 | -------------------------------------------------------------------------------- /app/sdklib/wpa/os_xtensa.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FileName: os_xtenca.c 3 | * Description: Alternate SDK (libwpa.a) 4 | * (c) PV` 2015 5 | */ 6 | 7 | #include "user_config.h" 8 | #include "bios.h" 9 | 10 | /* 11 | char * ICACHE_FLASH_ATTR ets_strdup(char * s) 12 | { 13 | char * pret = (0); 14 | if(s != (0)) { 15 | uint32 len = ets_strlen(s) + 1; 16 | pret = (char *)os_malloc(len); 17 | if(pret != (0)) ets_memcpy(pret, s, len); 18 | } 19 | return pret; 20 | } 21 | */ 22 | 23 | uint32 ICACHE_FLASH_ATTR os_get_time(void) 24 | { 25 | return 0; 26 | } 27 | 28 | extern uint32 phy_get_rand(void); // return *((uint32 *)(&g_phyFuns+0x290)) ^ *((uint32 *)0x3FF20E44); 29 | 30 | uint32 ICACHE_FLASH_ATTR r_rand(void) 31 | { 32 | return phy_get_rand(); 33 | } 34 | 35 | uint32 ICACHE_FLASH_ATTR os_random(void) 36 | { 37 | return phy_get_rand(); 38 | } 39 | 40 | /* os_get_random - Get cryptographically strong pseudo random data : 41 | * Buffer for pseudo random data : 42 | * Length of the buffer Returns: 43 | * 0 on success, -1 on failure */ 44 | int ICACHE_FLASH_ATTR os_get_random(unsigned char * buf, size_t len) 45 | { 46 | if(buf != NULL) { 47 | while(len) { 48 | uint32 z = phy_get_rand(); 49 | do { 50 | *buf++ = (char)z; 51 | z >>= 8; 52 | } while(--len & 3); 53 | } 54 | } 55 | return 0; 56 | } 57 | 58 | /* 59 | Name: strrchr 60 | Prototype: char * strrchr (const char *string, int c) 61 | Description: 62 | The function strrchr is like strchr, except that it searches backwards 63 | from the end of the string string (instead of forwards from the 64 | front). 65 | For example, 66 | strrchr ("hello, world", 'l') 67 | "ld" */ 68 | char * ICACHE_FLASH_ATTR ets_strrchr(const char *string, int c) 69 | { 70 | char * pret = NULL; 71 | if(string != NULL) { 72 | char ch; 73 | do { 74 | ch = *string; 75 | if(ch == c) pret = (char *)string; 76 | string ++; 77 | } while(ch != 0); 78 | } 79 | return pret; 80 | } 81 | -------------------------------------------------------------------------------- /app/sdklib/wpa/wpa_debug.c: -------------------------------------------------------------------------------- 1 | /* 2 | * FileName: wpa_debug.c 3 | * Description: Alternate SDK (libwpa.a) 4 | * (c) PV` 2015 5 | */ 6 | #include "user_config.h" 7 | #include "bios.h" 8 | 9 | unsigned int ICACHE_FLASH_ATTR eloop_cancel_timeout(void) 10 | { 11 | return 0; 12 | } 13 | 14 | unsigned int ICACHE_FLASH_ATTR eloop_register_timeout(void) 15 | { 16 | return 0; 17 | } 18 | -------------------------------------------------------------------------------- /app/user/Makefile: -------------------------------------------------------------------------------- 1 | 2 | ############################################################# 3 | # Required variables for each makefile 4 | # Discard this section from all parent makefiles 5 | # Expected variables (with automatic defaults): 6 | # CSRCS (all "C" files in the dir) 7 | # SUBDIRS (all subdirs with a Makefile) 8 | # GEN_LIBS - list of libs to be generated () 9 | # GEN_IMAGES - list of images to be generated () 10 | # COMPONENTS_xxx - a list of libs/objs in the form 11 | # subdir/lib to be extracted and rolled up into 12 | # a generated lib/image xxx.a () 13 | # 14 | ifndef PDIR 15 | GEN_LIBS = libuser.a 16 | endif 17 | 18 | ############################################################# 19 | # Configuration i.e. compile options etc. 20 | # Target specific stuff (defines etc.) goes in here! 21 | # Generally values applying to a tree are captured in the 22 | # makefile at its root level - these are then overridden 23 | # for a subtree within the makefile rooted therein 24 | # 25 | #DEFINES += 26 | 27 | ############################################################# 28 | # Recursion Magic - Don't touch this!! 29 | # 30 | # Each subtree potentially has an include directory 31 | # corresponding to the common APIs applicable to modules 32 | # rooted at that subtree. Accordingly, the INCLUDE PATH 33 | # of a module can only contain the include directories up 34 | # its parent path, and not its siblings 35 | # 36 | # Required for each makefile to inherit from the parent 37 | # 38 | 39 | #INCLUDES := $(INCLUDES) -I $(PDIR)include 40 | INCLUDES += -I ./include 41 | PDIR := ../$(PDIR) 42 | sinclude $(PDIR)Makefile 43 | 44 | -------------------------------------------------------------------------------- /app/user/README.md: -------------------------------------------------------------------------------- 1 | # Пример user_main.c 2 | 3 | Выводит в отладочный порт (TX UART1, 230400 Baud): 4 | ``` 5 | meSDK 1.5.2 6 | 7 | Save rx_gain_dc table (0, 1) 8 | Found free IRAM: base: 0x40104e84, size: 12668 bytes 9 | System memory: 10 | data : 0x3ffe8000 ~ 0x3ffe8364, len: 868 11 | rodata: 0x3ffe8364 ~ 0x3ffe8444, len: 224 12 | bss : 0x3ffe8448 ~ 0x3ffee230, len: 24040 13 | heap : 0x3ffee230 ~ 0x3fffc000, len: 56784 14 | Start 'heap' size: 56536 bytes 15 | Set CPU CLK: 160 MHz 16 | 17 | SDK Init - Ok 18 | Current 'heap' size: 53648 bytes 19 | Set CPU CLK: 160 MHz 20 | ``` -------------------------------------------------------------------------------- /asm_damp.bat: -------------------------------------------------------------------------------- 1 | @if exist .\app\.output\eagle\image\eagle.app.v6.out C:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-objdump -S .\app\.output\eagle\image\eagle.app.v6.out > eagle.app.v6.asm 2 | @if exist .\AutoMake\MinEspSDKLib.elf C:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-objdump -S .\AutoMake\MinEspSDKLib.elf > MinEspSDKLib.asm 3 | 4 | 5 | -------------------------------------------------------------------------------- /bin/0x00000.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/bin/0x00000.bin -------------------------------------------------------------------------------- /bin/0x07000.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/bin/0x07000.bin -------------------------------------------------------------------------------- /bin/blank.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/bin/blank.bin -------------------------------------------------------------------------------- /bin/clear_eep.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/bin/clear_eep.bin -------------------------------------------------------------------------------- /bin/esp_init_data_default.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/bin/esp_init_data_default.bin -------------------------------------------------------------------------------- /bin/rapid_loader.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/bin/rapid_loader.bin -------------------------------------------------------------------------------- /bin/rapid_loader_40m.bin: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/bin/rapid_loader_40m.bin -------------------------------------------------------------------------------- /bin/readme.txt: -------------------------------------------------------------------------------- 1 | Addr - file name - Info 2 | -------------------------------------------------------- 3 | 0x00000 - bin/0x00000.bin - Program codes IRAM/RAM 4 | 0x07000 - bin/0x07000.bin - Program codes Cache Flash 5 | 0x7C000 - bin/esp_init_data_default.bin - RF SDK options 6 | 0x7E000 - bin/blank.bin - Default SDK WiFi config 7 | 8 | bin/rapid_loader.bin - loader FlashSPI CLK x2 (80MHz) 9 | bin/rapid_loader_m40.bin - loader FlashSPI CLK x1 (40MHz) 10 | 11 | 12 | -------------------------------------------------------------------------------- /include/arch/cc.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | */ 34 | #ifndef __ARCH_CC_H__ 35 | #define __ARCH_CC_H__ 36 | 37 | //#include 38 | #include "c_types.h" 39 | #include "ets_sys.h" 40 | #include "osapi.h" 41 | #define EFAULT 14 42 | 43 | //#define LWIP_PROVIDE_ERRNO 44 | 45 | #if (1) 46 | #define BYTE_ORDER LITTLE_ENDIAN 47 | #else 48 | #define BYTE_ORDER BIG_ENDIAN 49 | #endif 50 | 51 | 52 | typedef unsigned char u8_t; 53 | typedef signed char s8_t; 54 | typedef unsigned short u16_t; 55 | typedef signed short s16_t; 56 | typedef unsigned long u32_t; 57 | typedef signed long s32_t; 58 | typedef unsigned long mem_ptr_t; 59 | 60 | #define S16_F "d" 61 | #define U16_F "d" 62 | #define X16_F "x" 63 | 64 | #define S32_F "d" 65 | #define U32_F "d" 66 | #define X32_F "x" 67 | 68 | 69 | 70 | //#define PACK_STRUCT_FIELD(x) x __attribute__((packed)) 71 | #define PACK_STRUCT_FIELD(x) x 72 | #define PACK_STRUCT_STRUCT __attribute__((packed)) 73 | #define PACK_STRUCT_BEGIN 74 | #define PACK_STRUCT_END 75 | 76 | //#define LWIP_DEBUG 77 | 78 | #ifdef LWIP_DEBUG 79 | #define LWIP_PLATFORM_DIAG(x) os_printf x 80 | #define LWIP_PLATFORM_ASSERT(x) ETS_ASSERT(x) 81 | #else 82 | #define LWIP_PLATFORM_DIAG(x) 83 | #define LWIP_PLATFORM_ASSERT(x) 84 | #endif 85 | 86 | #define SYS_ARCH_DECL_PROTECT(x) 87 | #define SYS_ARCH_PROTECT(x) 88 | #define SYS_ARCH_UNPROTECT(x) 89 | 90 | #define LWIP_PLATFORM_BYTESWAP 1 91 | #define LWIP_PLATFORM_HTONS(_n) ((u16_t)((((_n) & 0xff) << 8) | (((_n) >> 8) & 0xff))) 92 | #define LWIP_PLATFORM_HTONL(_n) ((u32_t)( (((_n) & 0xff) << 24) | (((_n) & 0xff00) << 8) | (((_n) >> 8) & 0xff00) | (((_n) >> 24) & 0xff) )) 93 | 94 | #if LWIP_RAW 95 | extern u8_t memp_memory_RAW_PCB_base[]; 96 | #endif /* LWIP_RAW */ 97 | 98 | #if LWIP_UDP 99 | extern u8_t memp_memory_UDP_PCB_base[]; 100 | #endif /* LWIP_UDP */ 101 | 102 | #if LWIP_TCP 103 | extern u8_t memp_memory_TCP_PCB_base[]; 104 | extern u8_t memp_memory_TCP_PCB_LISTEN_base[]; 105 | extern u8_t memp_memory_TCP_SEG_base[] SHMEM_ATTR; 106 | #endif /* LWIP_TCP */ 107 | 108 | #if (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS)) /* LWIP_TIMERS */ 109 | extern u8_t memp_memory_SYS_TIMEOUT_base[]; 110 | #endif /* LWIP_TIMERS */ 111 | 112 | extern u8_t memp_memory_PBUF_base[]; 113 | extern u8_t memp_memory_PBUF_POOL_base[]; 114 | 115 | 116 | 117 | #endif /* __ARCH_CC_H__ */ 118 | -------------------------------------------------------------------------------- /include/arch/perf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001, Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without 6 | * modification, are permitted provided that the following conditions 7 | * are met: 8 | * 1. Redistributions of source code must retain the above copyright 9 | * notice, this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright 11 | * notice, this list of conditions and the following disclaimer in the 12 | * documentation and/or other materials provided with the distribution. 13 | * 3. Neither the name of the Institute nor the names of its contributors 14 | * may be used to endorse or promote products derived from this software 15 | * without specific prior written permission. 16 | * 17 | * THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND 18 | * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 19 | * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 20 | * ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE 21 | * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 22 | * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 23 | * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 24 | * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 25 | * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 26 | * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 27 | * SUCH DAMAGE. 28 | * 29 | * This file is part of the lwIP TCP/IP stack. 30 | * 31 | * Author: Adam Dunkels 32 | * 33 | */ 34 | #ifndef __PERF_H__ 35 | #define __PERF_H__ 36 | 37 | #define PERF_START /* null definition */ 38 | #define PERF_STOP(x) /* null definition */ 39 | 40 | #endif /* __PERF_H__ */ 41 | -------------------------------------------------------------------------------- /include/arch/sys_arch.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/include/arch/sys_arch.h -------------------------------------------------------------------------------- /include/bios.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: bios.h 3 | * Description: funcs in ROM-BIOS 4 | * Alternate SDK 5 | * Author: PV` 6 | * (c) PV` 2015 7 | *******************************************************************************/ 8 | #ifndef _INCLUDE_BIOS_H_ 9 | #define _INCLUDE_BIOS_H_ 10 | #include "bios/spiflash.h" 11 | #include "bios/cha1.h" 12 | #include "bios/ets.h" 13 | #include "bios/gpio.h" 14 | #include "bios/uart.h" 15 | #include "bios/vectors.h" 16 | #include "bios/xthal.h" 17 | #include "bios/xtos.h" 18 | #include "bios/rtc_dtm.h" 19 | #include "bios/add_funcs.h" 20 | 21 | #endif // _INCLUDE_BIOS_H_ 22 | -------------------------------------------------------------------------------- /include/bios/add_funcs.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: add_funcs.h 3 | * Description: Do not sorted functions ROM-BIOS 4 | * Alternate SDK 5 | * Author: PV` 6 | * (c) PV` 2015 7 | *******************************************************************************/ 8 | #ifndef _INCLUDE_BIOS_ADD_FUNCS_H_ 9 | #define _INCLUDE_BIOS_ADD_FUNCS_H_ 10 | 11 | int rom_get_power_db(void); 12 | void rom_en_pwdet(int); 13 | void rom_i2c_writeReg(uint32 block, uint32 host_id, uint32 reg_add, uint32 data); 14 | void rom_i2c_writeReg_Mask(uint32 block, uint32 host_id, uint32 reg_add, uint32 Msb, uint32 Lsb, uint32 indata); 15 | uint8 rom_i2c_readReg_Mask(uint32 block, uint32 host_id, uint32 reg_add, uint32 Msb, uint32 Lsb); 16 | uint8 rom_i2c_readReg(uint32 block, uint32 host_id, uint32 reg_add); 17 | 18 | 19 | #endif /* _INCLUDE_BIOS_ADD_FUNCS_H_ */ 20 | -------------------------------------------------------------------------------- /include/bios/cha1.h: -------------------------------------------------------------------------------- 1 | /* 2 | * sha1.h -- 3 | * 4 | * SHA1 encryption 5 | */ 6 | #ifndef _SHA1_H_ 7 | #define _SHA1_H_ 8 | 9 | #include "c_types.h" 10 | 11 | /********************************************************* 12 | * Copyright (C) 1998 VMware, Inc. All rights reserved. 13 | * 14 | * This program is free software; you can redistribute it and/or modify it 15 | * under the terms of the GNU Lesser General Public License as published 16 | * by the Free Software Foundation version 2.1 and no later version. 17 | * 18 | * This program is distributed in the hope that it will be useful, but 19 | * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY 20 | * or FITNESS FOR A PARTICULAR PURPOSE. See the Lesser GNU General Public 21 | * License for more details. 22 | * 23 | * You should have received a copy of the GNU Lesser General Public License 24 | * along with this program; if not, write to the Free Software Foundation, Inc., 25 | * 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA. 26 | * 27 | *********************************************************/ 28 | 29 | /********************************************************* 30 | * The contents of this file are subject to the terms of the Common 31 | * Development and Distribution License (the "License") version 1.0 32 | * and no later version. You may not use this file except in 33 | * compliance with the License. 34 | * 35 | * You can obtain a copy of the License at 36 | * http://www.opensource.org/licenses/cddl1.php 37 | * 38 | * See the License for the specific language governing permissions 39 | * and limitations under the License. 40 | * 41 | *********************************************************/ 42 | 43 | /* 44 | SHA-1 in C 45 | By Steve Reid 46 | 100% Public Domain 47 | 48 | Test Vectors (from FIPS PUB 180-1) 49 | "abc" 50 | A9993E36 4706816A BA3E2571 7850C26C 9CD0D89D 51 | "abcdbcdecdefdefgefghfghighijhijkijkljklmklmnlmnomnopnopq" 52 | 84983E44 1C3BD26E BAAE4AA1 F95129E5 E54670F1 53 | A million repetitions of "a" 54 | 34AA973C D4C4DAA4 F61EEB2B DBAD2731 6534016F 55 | */ 56 | 57 | #define SHA1_HASH_LEN 20 58 | 59 | typedef struct { 60 | uint32 state[5]; 61 | uint32 count[2]; 62 | uint8 buffer[64]; 63 | } SHA1_CTX; 64 | 65 | #define SHA1HANDSOFF /* Copies data before messing with it. */ 66 | 67 | void SHA1Init(SHA1_CTX* context); 68 | #ifdef SHA1HANDSOFF 69 | void SHA1Update(SHA1_CTX* context, 70 | const uint8 *data, 71 | size_t len); 72 | #else 73 | void SHA1Update(SHA1_CTX* context, 74 | uint8 *data, 75 | size_t len); 76 | #endif 77 | void SHA1Final(uint8 digest[SHA1_HASH_LEN], SHA1_CTX* context); 78 | 79 | void SHA1Transform(uint32 state[5], const uint8 buffer[64]); 80 | 81 | /* eagle.rom.addr.v6.ld 82 | PROVIDE ( SHA1Final = 0x4000b648 ); 83 | PROVIDE ( SHA1Init = 0x4000b584 ); 84 | PROVIDE ( SHA1Transform = 0x4000a364 ); 85 | PROVIDE ( SHA1Update = 0x4000b5a8 ); 86 | */ 87 | #endif // ifndef _SHA1_H_ 88 | 89 | -------------------------------------------------------------------------------- /include/bios/mem.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: mem.h 3 | * Description: mem funcs in ROM-BIOS 4 | * Alternate SDK 5 | * Author: PV` 6 | * (c) PV` 2015 7 | *******************************************************************************/ 8 | #ifndef _BIOS_MEM_H_ 9 | #define _BIOS_MEM_H_ 10 | 11 | #include "c_types.h" 12 | /* WARNING !!! mem_xxx use size < 4096 !!! */ 13 | extern void mem_init(void * start_addr); // uint8 * 14 | extern void * mem_malloc(uint16 size); // size < 4096 15 | extern void * mem_calloc(uint16 n, uint16 count); // n*count < 4096 16 | extern void * mem_zalloc(uint16 size); // size < 4096, = mem_calloc(1, size); 17 | extern void * mem_realloc(void * p, uint16 size); 18 | extern void * mem_trim(void * p, uint16 size); 19 | extern void mem_free(uint8 * x); 20 | 21 | /* 22 | PROVIDE ( mem_calloc = 0x40001c2c ); 23 | PROVIDE ( mem_free = 0x400019e0 ); 24 | PROVIDE ( mem_init = 0x40001998 ); 25 | PROVIDE ( mem_malloc = 0x40001b40 ); 26 | PROVIDE ( mem_realloc = 0x40001c6c ); 27 | PROVIDE ( mem_trim = 0x40001a14 ); 28 | PROVIDE ( mem_zalloc = 0x40001c58 ); 29 | */ 30 | #endif /* _BIOS_MEM_H_ */ 31 | -------------------------------------------------------------------------------- /include/bios/rtc_dtm.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: gpio_bios.h 3 | * Description: rtc & dtm funcs in ROM-BIOS 4 | * Alternate SDK 5 | * Author: PV` 6 | * (c) PV` 2015 7 | *******************************************************************************/ 8 | #ifndef _BIOS_RTC_DTM_H_ 9 | #define _BIOS_RTC_DTM_H_ 10 | 11 | #include "c_types.h" 12 | 13 | /* 14 | PROVIDE ( ets_rtc_int_register = 0x40002a40 ); 15 | PROVIDE ( ets_enter_sleep = 0x400027b8 ); 16 | PROVIDE ( rtc_enter_sleep = 0x40002870 ); 17 | PROVIDE ( rtc_get_reset_reason = 0x400025e0 ); 18 | PROVIDE ( rtc_intr_handler = 0x400029ec ); 19 | PROVIDE ( rtc_set_sleep_mode = 0x40002668 ); 20 | PROVIDE ( dtm_get_intr_mask = 0x400026d0 ); 21 | PROVIDE ( dtm_params_init = 0x4000269c ); 22 | PROVIDE ( dtm_set_intr_mask = 0x400026c8 ); 23 | PROVIDE ( dtm_set_params = 0x400026dc ); 24 | PROVIDE ( software_reset = 0x4000264c ); 25 | PROVIDE ( save_rxbcn_mactime = 0x400027a4 ); 26 | PROVIDE ( save_tsf_us = 0x400027ac ); 27 | */ 28 | 29 | struct sdtm_params // RAM_BIOS:3FFFDD64 30 | { 31 | ETSTimer timer;//+0x00..0x14 32 | uint32 dtm_14;//+0x14 // a6 dtm_set_params 33 | uint32 rxbcn_mactime;//+0x18 34 | uint32 tsf_us;//+0x1C 35 | uint32 sleep_time;//+0x20 time 36 | uint32 timer_us;//+0x24 37 | uint32 time_ms;//+0x28 38 | uint32 dtm_2C;//+0x2C // a4 dtm_set_params 39 | uint32 mode;//+0x30 40 | uint32 cycles;//+0x34 timer cycles 41 | uint32 intr_mask;//+0x38 42 | uint32 sleep_func;//+0x3C 43 | uint32 int_func;//+0x40 44 | uint32 dtm_44;//+0x44 45 | }; 46 | 47 | // RAM_BIOS:3FFFDD64 48 | extern struct sdtm_params dtm_params; // 64 bytes 49 | // RAM_BIOS:3FFFC700 50 | extern uint32 rtc_claib; // ~ = 0x7073 51 | /* software_reset: Not work for any mode! */ 52 | void software_reset(void); 53 | void rtc_set_sleep_mode(uint32 a, uint32 t, uint32 m); 54 | /*rtc_reset_reason: =1 - ch_pd, =2 - reset, =4 - Wdt Reset ... > 7 unknown reset */ 55 | uint32 rtc_get_reset_reason(void); 56 | void save_rxbcn_mactime(uint32 t); 57 | void save_tsf_us(uint32 us); 58 | void dtm_set_intr_mask(uint32 mask); 59 | uint32 dtm_get_intr_mask(void); 60 | void dtm_params_init(void * sleep_func, void * int_func); 61 | void dtm_set_params(int mode, int time_ms_a3, int a4, int cycles, int a6); 62 | void rtc_intr_handler(void); 63 | void rtc_enter_sleep(void); 64 | void ets_rtc_int_register(void); 65 | /* { ets_set_idle_cb(rtc_enter_sleep, 0); } */ 66 | void ets_enter_sleep(void); 67 | 68 | #endif /* _BIOS_RTC_DTM_H_ */ 69 | -------------------------------------------------------------------------------- /include/bios/spiflash.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: spiflash_bios.h 3 | * Description: SPI in ROM-BIOS 4 | * Alternate SDK 5 | * Author: PV` 6 | * (c) PV` 2015 7 | *******************************************************************************/ 8 | 9 | #ifndef _INCLUDE_BIOS_SPI_H_ 10 | #define _INCLUDE_BIOS_SPI_H_ 11 | 12 | #include "c_types.h" 13 | 14 | struct SPIFlashHsz { 15 | uint8 spi_freg: 4; // Low four bits: 0 = 40MHz, 1= 26MHz, 2 = 20MHz, 0x3 = 80MHz 16 | uint8 flash_size: 4; // High four bits: 0 = 512K, 1 = 256K, 2 = 1M, 3 = 2M, 4 = 4M, 17 | }__attribute__((packed)); 18 | 19 | struct SPIFlashHead { // заголовок flash (использует загрузчик BIOS) 20 | uint8 id; // = 0xE9 21 | uint8 number_segs; // Number of segments 22 | uint8 spi_interface; // SPI Flash Interface (0 = QIO, 1 = QOUT, 2 = DIO, 0x3 = DOUT) 23 | struct SPIFlashHsz hsz; // options 24 | } __attribute__((packed)); 25 | 26 | struct SPIFlashHeadSegment { 27 | uint32 memory_offset; // Memory offset 28 | uint32 segment_size; // Segment size 29 | }; 30 | 31 | struct SPIFlashHeader { // полный заголовок flash (использует загрузчик BIOS) 32 | struct SPIFlashHead head; 33 | uint32 entry_point; // Entry point 34 | struct SPIFlashHeadSegment seg; // Segment 35 | } __attribute__((packed)); 36 | 37 | typedef struct{ 38 | uint32_t deviceId; //+00 39 | uint32_t chip_size; //+04 chip size in byte 40 | uint32_t block_size; //+08 41 | uint32_t sector_size; //+0c 42 | uint32_t page_size; //+10 43 | uint32_t status_mask; //+14 44 | } SpiFlashChip; 45 | 46 | typedef enum { 47 | SPI_FLASH_RESULT_OK, 48 | SPI_FLASH_RESULT_ERR, 49 | SPI_FLASH_RESULT_TIMEOUT 50 | } SpiFlashOpResult; 51 | 52 | extern SpiFlashChip * flashchip; // in RAM-BIOS: 0x3fffc714 53 | 54 | void Cache_Read_Disable(void); 55 | void Cache_Read_Enable(uint32_t a, uint32_t b, uint32_t c); 56 | 57 | SpiFlashOpResult SPI_read_status(SpiFlashChip *sflashchip, uint32_t *sta); 58 | SpiFlashOpResult SPI_write_status(SpiFlashChip *sflashchip, uint32_t sta); 59 | SpiFlashOpResult SPI_write_enable(SpiFlashChip *sflashchip); 60 | 61 | SpiFlashOpResult Wait_SPI_Idle(SpiFlashChip *sflashchip); 62 | 63 | SpiFlashOpResult SPIEraseArea(uint32_t start_addr, size_t lenght); // ВНИМАНИЕ! имеет внутренную ошибку. Не используйте эту функцию ROM-BIOS! 64 | SpiFlashOpResult SPIEraseBlock(uint32_t blocknum); 65 | SpiFlashOpResult SPIEraseSector(uint32_t sectornum); 66 | SpiFlashOpResult SPIEraseChip(void); 67 | SpiFlashOpResult SPILock(void); 68 | SpiFlashOpResult SPIUnlock(void); 69 | 70 | SpiFlashOpResult SPIRead(uint32_t faddr, uint32_t *dst, size_t size); 71 | int SPIReadModeCnfig(uint32_t mode); 72 | void SPIFlashCnfig(uint32_t spi_interface, uint32_t spi_freg); 73 | SpiFlashOpResult SPIWrite(uint32_t faddr, const uint32_t *src, size_t size); 74 | SpiFlashOpResult SPIParamCfg(uint32_t deviceId, uint32_t chip_size, uint32_t block_size, uint32_t sector_size, uint32_t page_size, uint32_t status_mask); // Set flashchip 75 | SpiFlashOpResult spi_flash_attach(void); // SelectSpiFunction; SPIFlashCnfig(5,4); SPIReadModeCnfig(5); 76 | SpiFlashOpResult SelectSpiFunction(void); // GPIO7..11 fun = QSPI, *0x60000D48 = 0, return 0 77 | 78 | /* in eagle.rom.addr.v6.ld : 79 | PROVIDE ( Cache_Read_Disable = 0x400047f0 ); 80 | PROVIDE ( Cache_Read_Enable = 0x40004678 ); 81 | 82 | PROVIDE ( SPI_read_status = 0x400043c8 ); 83 | PROVIDE ( SPI_write_status = 0x40004400 ); 84 | PROVIDE ( SPI_write_enable = 0x4000443c ); 85 | 86 | PROVIDE ( Wait_SPI_Idle = 0x4000448c ); 87 | PROVIDE ( SPIEraseArea = 0x40004b44 ); 88 | PROVIDE ( SPIEraseBlock = 0x400049b4 ); 89 | PROVIDE ( SPIEraseChip = 0x40004984 ); 90 | PROVIDE ( SPIEraseSector = 0x40004a00 ); 91 | PROVIDE ( SPILock = 0x400048a8 ); 92 | PROVIDE ( SPIUnlock = 0x40004878 ); 93 | PROVIDE ( SPIParamCfg = 0x40004c2c ); 94 | PROVIDE ( SPIRead = 0x40004b1c ); 95 | PROVIDE ( SPIReadModeCnfig = 0x400048ec ); 96 | PROVIDE ( SPIWrite = 0x40004a4c ); 97 | 98 | PROVIDE ( SelectSpiFunction = 0x40003f58 ); 99 | PROVIDE ( spi_flash_attach = 0x40004644 ); 100 | 101 | +PROVIDE ( SPIFlashCnfig = 0x40004568); 102 | 103 | PROVIDE ( flashchip = 0x3fffc714); 104 | */ 105 | 106 | #endif /* _INCLUDE_BIOS_SPI_H_ */ 107 | -------------------------------------------------------------------------------- /include/bios/vectors.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: Vectors.h 3 | * Description: Vectors funcs in ROM-BIOS 4 | * Alternate SDK 5 | * Author: PV` 6 | * (c) PV` 2015 7 | *******************************************************************************/ 8 | 9 | #ifndef _INCLUDE_BIOS_VECTORS_H_ 10 | #define _INCLUDE_BIOS_VECTORS_H_ 11 | 12 | /* 13 | PROVIDE ( _DebugExceptionVector = 0x40000010 ); 14 | PROVIDE ( _NMIExceptionVector = 0x40000020 ); 15 | PROVIDE ( _KernelExceptionVector = 0x40000030 ); 16 | PROVIDE ( _UserExceptionVector = 0x40000050 ); 17 | PROVIDE ( _DoubleExceptionVector = 0x40000070 ); 18 | #PROVIDE ( _ResetVector = 0x40000080 ); 19 | PROVIDE ( _ResetHandler = 0x400000a4 ); 20 | */ 21 | 22 | void _ResetVector(void); 23 | 24 | #endif /* _INCLUDE_BIOS_VECTORS_H_ */ 25 | -------------------------------------------------------------------------------- /include/bios/xthal.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: xthal_bios.h 3 | * Description: HAL funcs in ROM-BIOS 4 | * Alternate SDK 5 | * Author: PV` 6 | * (c) PV` 2015 7 | *******************************************************************************/ 8 | #ifndef _INCLUDE_BIOS_XTAL_H_ 9 | #define _INCLUDE_BIOS_XTAL_H_ 10 | 11 | #ifndef XTENSA_HAL_H // xtensa-lx106-elf/include/xtensa/hal.h 12 | 13 | // Instruction/Data RAM/ROM Access 14 | extern void* xthal_memcpy(void *dst, const void *src, unsigned len); 15 | extern void* xthal_bcopy(const void *src, void *dst, unsigned len); 16 | 17 | /* set and get CCOMPAREn registers (if not present, get returns 0) */ 18 | extern void xthal_set_ccompare(int x, unsigned r); // { if(x) return; wsr.ccompare0 = r } 19 | extern unsigned xthal_get_ccompare(int x); // { if(x) return 0; else return rsr.ccompare0 } 20 | 21 | /* get CCOUNT register (if not present return 0) */ 22 | extern unsigned xthal_get_ccount(void); // { return rsr.ccount} 23 | 24 | /* INTENABLE,INTERRUPT,INTSET,INTCLEAR register access functions: */ 25 | extern unsigned xthal_get_interrupt( void ); // { return rsr.interrupt } 26 | #define xthal_get_intread xthal_get_interrupt /* backward compatibility */ 27 | extern void xthal_set_intclear( unsigned ); // { return wsr.intclear } 28 | 29 | // Register Windows 30 | /* This spill any live register windows (other than the caller's): 31 | * (NOTE: current implementation require privileged code, but 32 | * a user-callable implementation is possible.) */ 33 | extern void xthal_window_spill( void ); // { return; } 34 | extern void xthal_window_spill_nw( void ); // { return 0; } 35 | 36 | extern unsigned xthal_spill_registers_into_stack_nw(void); // { return 0; } 37 | 38 | 39 | /* eagle.rom.addr.v6.ld 40 | PROVIDE ( xthal_bcopy = 0x40000688 ); 41 | -PROVIDE ( xthal_copy123 = 0x4000074c ); 42 | PROVIDE ( xthal_get_ccompare = 0x4000dd4c ); 43 | PROVIDE ( xthal_get_ccount = 0x4000dd38 ); 44 | PROVIDE ( xthal_get_interrupt = 0x4000dd58 ); 45 | PROVIDE ( xthal_get_intread = 0x4000dd58 ); 46 | PROVIDE ( xthal_memcpy = 0x400006c4 ); 47 | PROVIDE ( xthal_set_ccompare = 0x4000dd40 ); 48 | PROVIDE ( xthal_set_intclear = 0x4000dd60 ); 49 | PROVIDE ( xthal_spill_registers_into_stack_nw = 0x4000e320 ); 50 | PROVIDE ( xthal_window_spill = 0x4000e324 ); 51 | PROVIDE ( xthal_window_spill_nw = 0x4000e320 ); 52 | */ 53 | 54 | #endif /* XTENSA_HAL_H */ 55 | #endif /* _INCLUDE_BIOS_XTAL_H_ */ 56 | -------------------------------------------------------------------------------- /include/bios/xtos.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: xtos_bios.h 3 | * Description: xtos funcs in ROM-BIOS 4 | * Alternate SDK 5 | * Author: PV` 6 | * (c) PV` 2015 7 | *******************************************************************************/ 8 | #ifndef _INCLUDE_BIOS_XTOS_H_ 9 | #define _INCLUDE_BIOS_XTOS_H_ 10 | 11 | #ifndef XTRUNTIME_H 12 | 13 | /*typedef void (_xtos_timerdelta_func)(int);*/ 14 | #ifdef __cplusplus 15 | typedef void (_xtos_handler_func)(...); 16 | #else 17 | typedef void (_xtos_handler_func)(); 18 | #endif 19 | typedef _xtos_handler_func *_xtos_handler; 20 | 21 | 22 | extern unsigned int _xtos_ints_off( unsigned int mask ); 23 | extern unsigned int _xtos_ints_on( unsigned int mask ); 24 | extern _xtos_handler _xtos_set_interrupt_handler( int n, _xtos_handler f ); 25 | extern _xtos_handler _xtos_set_interrupt_handler_arg( int n, _xtos_handler f, void *arg ); 26 | extern _xtos_handler _xtos_set_exception_handler( int n, _xtos_handler f ); 27 | extern unsigned _xtos_set_intlevel( int intlevel ); 28 | extern unsigned _xtos_set_min_intlevel( int intlevel ); 29 | extern unsigned _xtos_set_vpri( unsigned vpri ); 30 | 31 | extern unsigned _xtos_restore_intlevel( unsigned restoreval ); 32 | 33 | 34 | /* 35 | PROVIDE ( _xtos_ints_off = 0x4000bda4 ); 36 | PROVIDE ( _xtos_ints_on = 0x4000bd84 ); 37 | PROVIDE ( _xtos_restore_intlevel = 0x4000056c ); 38 | PROVIDE ( _xtos_set_exception_handler = 0x40000454 ); 39 | PROVIDE ( _xtos_set_interrupt_handler = 0x4000bd70 ); 40 | PROVIDE ( _xtos_set_interrupt_handler_arg = 0x4000bd28 ); 41 | PROVIDE ( _xtos_set_intlevel = 0x4000dbfc ); 42 | PROVIDE ( _xtos_set_min_intlevel = 0x4000dc18 ); 43 | PROVIDE ( _xtos_set_vpri = 0x40000574 ); 44 | PROVIDE ( _xtos_return_from_exc = 0x4000dc54 ); // \xtensa-elf\src\xtos\exc-return.S 45 | 46 | PROVIDE ( _xtos_alloca_handler = 0x4000dbe0 ); 47 | PROVIDE ( _xtos_c_wrapper_handler = 0x40000598 ); 48 | PROVIDE ( _xtos_cause3_handler = 0x40000590 ); 49 | PROVIDE ( _xtos_l1int_handler = 0x4000048c ); 50 | PROVIDE ( _xtos_p_none = 0x4000dbf8 ); 51 | PROVIDE ( _xtos_syscall_handler = 0x4000dbe4 ); 52 | PROVIDE ( _xtos_unhandled_exception = 0x4000dc44 ); 53 | PROVIDE ( _xtos_unhandled_interrupt = 0x4000dc3c ); 54 | */ 55 | /* 56 | _rom_store: 57 | _xtos_unhandled_exception // 0 IllegalInstruction 58 | _xtos_syscall_handler // 1 Syscall 59 | _xtos_unhandled_exception // 2 InstructionFetchError 60 | _xtos_unhandled_exception // 3 LoadStoreError 61 | _xtos_l1int_handler // 4 Level1Interrupt 62 | _xtos_alloca_handler // 5 Alloca (MOVSP) 63 | _xtos_unhandled_exception // 6 IntegerDivideByZero 64 | _xtos_unhandled_exception // 7 Speculation 65 | _xtos_unhandled_exception // 8 Privileged 66 | _xtos_unhandled_exception // 9 Unaligned 67 | _xtos_unhandled_exception //10 (reserved for Tensilica) 68 | _xtos_unhandled_exception //11 (reserved for Tensilica) 69 | _xtos_cause3_handler //12 PIF data error on fetch 70 | _xtos_cause3_handler //13 PIF data error on ld/st 71 | _xtos_cause3_handler //14 PIF address error on fetch 72 | _xtos_cause3_handler //15 PIF address error on ld/st 73 | _xtos_unhandled_exception //16 InstTLBMiss 74 | _xtos_unhandled_exception //17 InstTLBMultiHit 75 | _xtos_unhandled_exception //18 InstFetchPrivilege 76 | _xtos_unhandled_exception //19 (reserved for Tensilica) 77 | _xtos_unhandled_exception //20 InstFetchProhibited 78 | _xtos_unhandled_exception //21 (reserved for Tensilica) 79 | _xtos_unhandled_exception //22 (reserved for Tensilica) 80 | _xtos_unhandled_exception //23 (reserved for Tensilica) 81 | _xtos_unhandled_exception //24 LoadStoreTLBMiss 82 | _xtos_unhandled_exception //25 LoadStoreTLBMultiHit 83 | _xtos_unhandled_exception //26 LoadStorePrivilege 84 | _xtos_unhandled_exception //27 (reserved for Tensilica) 85 | _xtos_unhandled_exception //28 LoadProhibited 86 | _xtos_unhandled_exception //29 StoreProhibited 87 | _xtos_unhandled_exception //30 (reserved for Tensilica) 88 | _xtos_unhandled_exception //31 (reserved for Tensilica) 89 | .... 90 | _xtos_p_none 91 | .... 92 | */ 93 | #endif // XTRUNTIME_H 94 | #endif // _INCLUDE_BIOS_XTOS_H_ 95 | -------------------------------------------------------------------------------- /include/c_types.h: -------------------------------------------------------------------------------- 1 | /* 2 | * C types 3 | */ 4 | 5 | #ifndef _C_TYPES_H_ 6 | #define _C_TYPES_H_ 7 | 8 | typedef unsigned char uint8_t; 9 | typedef signed char sint8_t; 10 | typedef signed char int8_t; 11 | typedef unsigned short uint16_t; 12 | typedef signed short sint16_t; 13 | typedef signed short int16_t; 14 | typedef unsigned long uint32_t; 15 | typedef signed long sint32_t; 16 | typedef signed long int32_t; 17 | typedef signed long long sint64_t; 18 | typedef unsigned long long uint64_t; 19 | typedef unsigned long long u_int64_t; 20 | typedef float real32_t; 21 | typedef double real64_t; 22 | 23 | typedef unsigned char uint8; 24 | typedef unsigned char u8; 25 | typedef signed char sint8; 26 | typedef signed char int8; 27 | typedef signed char s8; 28 | typedef unsigned short uint16; 29 | typedef unsigned short u16; 30 | typedef signed short sint16; 31 | typedef signed short s16; 32 | typedef unsigned int uint32; 33 | typedef unsigned int u_int; 34 | typedef unsigned int u32; 35 | typedef signed int sint32; 36 | typedef signed int s32; 37 | typedef int int32; 38 | typedef signed long long sint64; 39 | typedef unsigned long long uint64; 40 | typedef unsigned long long u64; 41 | typedef float real32; 42 | typedef double real64; 43 | 44 | #define __le16 u16 45 | 46 | typedef unsigned int size_t; 47 | typedef signed char err_t; 48 | 49 | 50 | #define __packed __attribute__((packed)) 51 | 52 | #define LOCAL static 53 | 54 | #ifndef NULL 55 | #define NULL (void *)0 56 | #endif /* NULL */ 57 | 58 | /* probably should not put STATUS here */ 59 | typedef enum { 60 | OK = 0, 61 | FAIL, 62 | PENDING, 63 | BUSY, 64 | CANCEL, 65 | } STATUS; 66 | 67 | #define BIT(nr) (1UL << (nr)) 68 | 69 | #define REG_SET_BIT(_r, _b) (*(volatile uint32_t*)(_r) |= (_b)) 70 | #define REG_CLR_BIT(_r, _b) (*(volatile uint32_t*)(_r) &= ~(_b)) 71 | 72 | #define DMEM_ATTR __attribute__((section(".bss"))) 73 | #define SHMEM_ATTR 74 | 75 | #ifdef ICACHE_FLASH 76 | #define ICACHE_FLASH_ATTR __attribute__((section(".irom0.text"))) 77 | #define ICACHE_RODATA_ATTR __attribute__((aligned(4),section(".irom.text"))) 78 | #else 79 | #define ICACHE_FLASH_ATTR 80 | #define ICACHE_RODATA_ATTR 81 | #endif 82 | 83 | #ifndef DATA_IRAM_ATTR 84 | #define DATA_IRAM_ATTR __attribute__((aligned(4), section(".iram.data"))) 85 | #endif 86 | 87 | #define __forceinline __attribute__((always_inline)) inline 88 | 89 | #ifndef __cplusplus 90 | typedef unsigned char bool; 91 | #define BOOL bool 92 | #define true (1) 93 | #define false (0) 94 | #define TRUE true 95 | #define FALSE false 96 | 97 | 98 | #endif /* !__cplusplus */ 99 | 100 | #endif /* _C_TYPES_H_ */ 101 | -------------------------------------------------------------------------------- /include/ets_sys.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * Define user specified Event signals and Task priorities here 4 | * 5 | */ 6 | 7 | #ifndef _ETS_SYS_H 8 | #define _ETS_SYS_H 9 | 10 | #include "c_types.h" 11 | #include "hw/eagle_soc.h" 12 | 13 | typedef uint32_t ETSSignal; 14 | typedef uint32_t ETSParam; 15 | 16 | typedef struct ETSEventTag ETSEvent; 17 | 18 | struct ETSEventTag { 19 | ETSSignal sig; 20 | ETSParam par; 21 | }; 22 | 23 | typedef void (*ETSTask)(ETSEvent *e); 24 | 25 | /* timer related */ 26 | typedef uint32_t ETSHandle; 27 | typedef void ETSTimerFunc(void *timer_arg); 28 | 29 | typedef struct _ETSTIMER_ { 30 | struct _ETSTIMER_ *timer_next; 31 | uint32_t timer_expire; 32 | uint32_t timer_period; 33 | ETSTimerFunc *timer_func; 34 | void *timer_arg; 35 | } ETSTimer; 36 | 37 | /* interrupt related */ 38 | #define ETS_SLC_INUM 1 39 | #define ETS_SPI_INUM 2 40 | #define ETS_GPIO_INUM 4 41 | #define ETS_UART_INUM 5 42 | #define ETS_UART1_INUM 5 43 | #define ETS_CCOMPARE0_INUM 6 44 | #define ETS_SOFT_INUM 7 45 | #define ETS_WDT_INUM 8 46 | #define ETS_FRC_TIMER1_INUM 9 /* use edge*/ 47 | 48 | #define ETS_INTR_LOCK() \ 49 | ets_intr_lock() 50 | 51 | #define ETS_INTR_UNLOCK() \ 52 | ets_intr_unlock() 53 | 54 | #define ETS_CCOMPARE0_INTR_ATTACH(func, arg) \ 55 | ets_isr_attach(ETS_CCOMPARE0_INUM, (func), (void *)(arg)) 56 | 57 | #define ETS_SLC_INTR_ATTACH(func, arg) \ 58 | ets_isr_attach(ETS_SLC_INUM, (func), (void *)(arg)) 59 | 60 | #define ETS_FRC_TIMER1_INTR_ATTACH(func, arg) \ 61 | ets_isr_attach(ETS_FRC_TIMER1_INUM, (func), (void *)(arg)) 62 | 63 | #define ETS_GPIO_INTR_ATTACH(func, arg) \ 64 | ets_isr_attach(ETS_GPIO_INUM, (func), (void *)(arg)) 65 | 66 | #define ETS_UART_INTR_ATTACH(func, arg) \ 67 | ets_isr_attach(ETS_UART_INUM, (func), (void *)(arg)) 68 | 69 | #define ETS_SPI_INTR_ATTACH(func, arg) \ 70 | ets_isr_attach(ETS_SPI_INUM, (func), (void *)(arg)) 71 | 72 | #define ETS_INTR_ENABLE(inum) \ 73 | ets_isr_unmask((1<= GPIO_ID_PIN0) && (reg_id <= GPIO_ID_PIN(GPIO_PIN_COUNT-1))) 13 | 14 | #define GPIO_REGID_TO_PINIDX(reg_id) ((reg_id) - GPIO_ID_PIN0) 15 | 16 | typedef enum { 17 | GPIO_PIN_INTR_DISABLE = 0, 18 | GPIO_PIN_INTR_POSEDGE = 1, 19 | GPIO_PIN_INTR_NEGEDGE = 2, 20 | GPIO_PIN_INTR_ANYEDGE = 3, 21 | GPIO_PIN_INTR_LOLEVEL = 4, 22 | GPIO_PIN_INTR_HILEVEL = 5 23 | } GPIO_INT_TYPE; 24 | 25 | #define GPIO_OUTPUT_SET(gpio_no, bit_value) \ 26 | gpio_output_set((bit_value)<>gpio_no)&BIT0) 29 | 30 | /* GPIO interrupt handler, registered through gpio_intr_handler_register */ 31 | typedef void (* gpio_intr_handler_fn_t)(uint32 intr_mask, void *arg); 32 | 33 | 34 | /* 35 | * Initialize GPIO. This includes reading the GPIO Configuration DataSet 36 | * to initialize "output enables" and pin configurations for each gpio pin. 37 | * Must be called once during startup. 38 | */ 39 | void gpio_init(void); 40 | 41 | /* 42 | * Change GPIO pin output by setting, clearing, or disabling pins. 43 | * In general, it is expected that a bit will be set in at most one 44 | * of these masks. If a bit is clear in all masks, the output state 45 | * remains unchanged. 46 | * 47 | * There is no particular ordering guaranteed; so if the order of 48 | * writes is significant, calling code should divide a single call 49 | * into multiple calls. 50 | */ 51 | void gpio_output_set(uint32 set_mask, 52 | uint32 clear_mask, 53 | uint32 enable_mask, 54 | uint32 disable_mask); 55 | 56 | /* 57 | * Sample the value of GPIO input pins and returns a bitmask. 58 | */ 59 | uint32 gpio_input_get(void); 60 | 61 | /* 62 | * Set the specified GPIO register to the specified value. 63 | * This is a very general and powerful interface that is not 64 | * expected to be used during normal operation. It is intended 65 | * mainly for debug, or for unusual requirements. 66 | */ 67 | void gpio_register_set(uint32 reg_id, uint32 value); 68 | 69 | /* Get the current value of the specified GPIO register. */ 70 | uint32 gpio_register_get(uint32 reg_id); 71 | 72 | /* 73 | * Register an application-specific interrupt handler for GPIO pin 74 | * interrupts. Once the interrupt handler is called, it will not 75 | * be called again until after a call to gpio_intr_ack. Any GPIO 76 | * interrupts that occur during the interim are masked. 77 | * 78 | * The application-specific handler is called with a mask of 79 | * pending GPIO interrupts. After processing pin interrupts, the 80 | * application-specific handler may wish to use gpio_intr_pending 81 | * to check for any additional pending interrupts before it returns. 82 | */ 83 | void gpio_intr_handler_register(gpio_intr_handler_fn_t fn, void *arg); 84 | 85 | /* Determine which GPIO interrupts are pending. */ 86 | uint32 gpio_intr_pending(void); 87 | 88 | /* 89 | * Acknowledge GPIO interrupts. 90 | * Intended to be called from the gpio_intr_handler_fn. 91 | */ 92 | void gpio_intr_ack(uint32 ack_mask); 93 | 94 | void gpio_pin_wakeup_enable(uint32 i, GPIO_INT_TYPE intr_state); 95 | 96 | void gpio_pin_wakeup_disable(); 97 | 98 | void gpio_pin_intr_state_set(uint32 i, GPIO_INT_TYPE intr_state); 99 | 100 | #endif // _GPIO_H_ 101 | -------------------------------------------------------------------------------- /include/hw/sdio_slv.h: -------------------------------------------------------------------------------- 1 | #ifndef SDIO_SLAVE_H 2 | #define SDIO_SLAVE_H 3 | #include "hw/slc_register.h" 4 | #include "c_types.h" 5 | #include "user_interface.h" 6 | struct sdio_queue 7 | { 8 | uint32 blocksize:12; 9 | uint32 datalen:12; 10 | uint32 unused:5; 11 | uint32 sub_sof:1; 12 | uint32 eof:1; 13 | uint32 owner:1; 14 | 15 | uint32 buf_ptr; 16 | uint32 next_link_ptr; 17 | }; 18 | 19 | struct sdio_slave_status_element 20 | { 21 | uint32 wr_busy:1; 22 | uint32 rd_empty :1; 23 | uint32 comm_cnt :3; 24 | uint32 intr_no :3; 25 | uint32 rx_length:16; 26 | uint32 res:8; 27 | }; 28 | 29 | union sdio_slave_status 30 | { 31 | struct sdio_slave_status_element elm_value; 32 | uint32 word_value; 33 | }; 34 | 35 | #define RX_AVAILIBLE 2 36 | #define TX_AVAILIBLE 1 37 | #define INIT_STAGE 0 38 | 39 | #define SDIO_QUEUE_LEN 8 40 | #define MOSI 0 41 | #define MISO 1 42 | #define SDIO_DATA_ERROR 6 43 | 44 | #define SLC_INTEREST_EVENT (SLC_TX_EOF_INT_ENA | SLC_RX_EOF_INT_ENA | SLC_RX_UDF_INT_ENA | SLC_TX_DSCR_ERR_INT_ENA) 45 | #define TRIG_TOHOST_INT() SET_PERI_REG_MASK(SLC_INTVEC_TOHOST , BIT0);\ 46 | CLEAR_PERI_REG_MASK(SLC_INTVEC_TOHOST , BIT0) 47 | 48 | /* 49 | void sdio_slave_init(void); 50 | void sdio_slave_isr(void *para); 51 | void sdio_task_init(void); 52 | void sdio_err_task(os_event_t *e); 53 | void rx_buff_load_done(uint16 rx_len); 54 | void tx_buff_handle_done(void); 55 | void rx_buff_read_done(void); 56 | void tx_buff_write_done(void); 57 | */ 58 | #endif 59 | -------------------------------------------------------------------------------- /include/hw/specreg.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Xtensa Special Register symbolic names 3 | */ 4 | 5 | #ifndef __SPECREG_H 6 | #define __SPECREG_H 7 | 8 | /* Special registers: */ 9 | #define LBEG 0 10 | #define LEND 1 11 | #define LCOUNT 2 12 | #define SAR 3 13 | #define BR 4 14 | #define LITBASE 5 15 | #define SCOMPARE1 12 16 | #define ACCLO 16 17 | #define ACCHI 17 18 | #define MR_0 32 19 | #define MR_1 33 20 | #define MR_2 34 21 | #define MR_3 35 22 | #define PREFCTL 40 23 | #define WINDOWBASE 72 24 | #define WINDOWSTART 73 25 | #define PTEVADDR 83 26 | #define RASID 90 27 | #define ITLBCFG 91 28 | #define DTLBCFG 92 29 | #define IBREAKENABLE 96 30 | #define CACHEATTR 98 31 | #define DDR 104 32 | #define IBREAKA_0 128 33 | #define IBREAKA_1 129 34 | #define DBREAKA_0 144 35 | #define DBREAKA_1 145 36 | #define DBREAKC_0 160 37 | #define DBREAKC_1 161 38 | #define EPC_1 177 39 | #define EPC_2 178 40 | #define EPC_3 179 41 | #define EPC_4 180 42 | #define EPC_5 181 43 | #define EPC_6 182 44 | #define EPC_7 183 45 | #define DEPC 192 46 | #define EPS_2 194 47 | #define EPS_3 195 48 | #define EPS_4 196 49 | #define EPS_5 197 50 | #define EPS_6 198 51 | #define EPS_7 199 52 | #define EXCSAVE_1 209 53 | #define EXCSAVE_2 210 54 | #define EXCSAVE_3 211 55 | #define EXCSAVE_4 212 56 | #define EXCSAVE_5 213 57 | #define EXCSAVE_6 214 58 | #define EXCSAVE_7 215 59 | #define CPENABLE 224 60 | #define INTERRUPT 226 61 | #define INTREAD INTERRUPT /* alternate name for backward compatibility */ 62 | #define INTSET INTERRUPT /* alternate name for backward compatibility */ 63 | #define INTCLEAR 227 64 | #define INTENABLE 228 65 | #define PS 230 66 | #define VECBASE 231 67 | #define EXCCAUSE 232 68 | #define DEBUGCAUSE 233 69 | #define CCOUNT 234 70 | #define PRID 235 71 | #define ICOUNT 236 72 | #define ICOUNTLEVEL 237 73 | #define EXCVADDR 238 74 | #define CCOMPARE_0 240 75 | #define CCOMPARE_1 241 76 | #define CCOMPARE_2 242 77 | #define MISC_REG_0 244 78 | #define MISC_REG_1 245 79 | #define MISC_REG_2 246 80 | #define MISC_REG_3 247 81 | 82 | /* Special cases (bases of special register series): */ 83 | #define MR 32 84 | #define IBREAKA 128 85 | #define DBREAKA 144 86 | #define DBREAKC 160 87 | #define EPC 176 88 | #define EPS 192 89 | #define EXCSAVE 208 90 | #define CCOMPARE 240 91 | #define MISC_REG 244 92 | 93 | #define __stringify_1(x...) #x 94 | #define __stringify(x...) __stringify_1(x) 95 | #define RSR(sr) ({uint32_t r; asm volatile ("rsr %0,"__stringify(sr) : "=a"(r)); r;}) 96 | 97 | #endif /* __SPECREG_H */ 98 | -------------------------------------------------------------------------------- /include/hw/timer_register.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ESP8266 TIMER registers 3 | */ 4 | 5 | #ifndef _TIMER_REGISTER_H_ 6 | #define _TIMER_REGISTER_H_ 7 | 8 | #define PERIPHS_TIMER_BASEDDR 0x60000600 9 | 10 | #define FRC1_LOAD_ADDRESS (PERIPHS_TIMER_BASEDDR + 0x0) 11 | #define TIMER_FRC1_LOAD_VALUE 0x007FFFFF 12 | #define TIMER_FRC1_LOAD_VALUE_S 0 13 | #define FRC1_LOAD_DATA_MSB 22 14 | #define FRC1_LOAD_DATA_LSB 0 15 | #define FRC1_LOAD_DATA_MASK 0x007fffff 16 | 17 | #define FRC1_COUNT_ADDRESS (PERIPHS_TIMER_BASEDDR + 0x4) 18 | #define TIMER_FRC1_COUNT 0x007FFFFF 19 | #define TIMER_FRC1_COUNT_S 0 20 | #define FRC1_COUNT_DATA_MSB 22 21 | #define FRC1_COUNT_DATA_LSB 0 22 | #define FRC1_COUNT_DATA_MASK 0x007fffff 23 | 24 | #define FRC1_CTRL_ADDRESS (PERIPHS_TIMER_BASEDDR + 0x8) 25 | #define TIMER_FRC1_INT (BIT(8)) 26 | #define TIMER_FRC1_CTRL 0x000000FF 27 | #define TIMER_FRC1_CTRL_S 0 28 | #define FRC1_CTRL_DATA_MSB 7 29 | #define FRC1_CTRL_DATA_LSB 0 30 | #define FRC1_CTRL_DATA_MASK 0x000000ff 31 | 32 | #define FRC1_INT_ADDRESS (PERIPHS_TIMER_BASEDDR + 0xC) 33 | #define TIMER_FRC1_INT_CLR_MASK (BIT(0)) 34 | #define FRC1_INT_CLR_MSB 0 35 | #define FRC1_INT_CLR_LSB 0 36 | #define FRC1_INT_CLR_MASK 0x00000001 37 | 38 | #define FRC2_LOAD_ADDRESS (PERIPHS_TIMER_BASEDDR + 0x20) 39 | #define TIMER_FRC2_LOAD_VALUE 0xFFFFFFFF 40 | #define TIMER_FRC2_LOAD_VALUE_S 0 41 | #define FRC2_LOAD_DATA_MSB 31 42 | #define FRC2_LOAD_DATA_LSB 0 43 | #define FRC2_LOAD_DATA_MASK 0xffffffff 44 | 45 | #define FRC2_COUNT_ADDRESS (PERIPHS_TIMER_BASEDDR + 0x24) 46 | #define TIMER_FRC2_COUNT 0xFFFFFFFF 47 | #define TIMER_FRC2_COUNT_S 0 48 | #define FRC2_COUNT_DATA_MSB 31 49 | #define FRC2_COUNT_DATA_LSB 0 50 | #define FRC2_COUNT_DATA_MASK 0xffffffff 51 | 52 | #define FRC2_CTRL_ADDRESS (PERIPHS_TIMER_BASEDDR + 0x28) 53 | #define TIMER_FRC2_INT (BIT(8)) 54 | #define TIMER_FRC2_CTRL 0x000000FF 55 | #define TIMER_FRC2_CTRL_S 0 56 | #define FRC2_CTRL_DATA_MSB 7 57 | #define FRC2_CTRL_DATA_LSB 0 58 | #define FRC2_CTRL_DATA_MASK 0x000000ff 59 | 60 | #define FRC2_INT_ADDRESS (PERIPHS_TIMER_BASEDDR + 0x2C) 61 | #define TIMER_FRC2_INT_CLR_MASK (BIT(0)) 62 | #define FRC2_INT_CLR_MSB 0 63 | #define FRC2_INT_CLR_LSB 0 64 | #define FRC2_INT_CLR_MASK 0x00000001 65 | 66 | #define FRC2_ALARM_ADDRESS (PERIPHS_TIMER_BASEDDR + 0x30) 67 | #define TIMER_FRC2_ALARM 0xFFFFFFFF 68 | #define TIMER_FRC2_ALARM_S 0 69 | #define FRC2_ALARM_DATA_MSB 31 70 | #define FRC2_ALARM_DATA_LSB 0 71 | #define FRC2_ALARM_DATA_MASK 0xffffffff 72 | 73 | #endif 74 | -------------------------------------------------------------------------------- /include/ip_addr.h: -------------------------------------------------------------------------------- 1 | #ifndef __IP_ADDR_H__ 2 | #define __IP_ADDR_H__ 3 | 4 | #include "c_types.h" 5 | 6 | struct ip_addr { 7 | uint32 addr; 8 | }; 9 | 10 | typedef struct ip_addr ip_addr_t; 11 | 12 | struct ip_info { 13 | struct ip_addr ip; 14 | struct ip_addr netmask; 15 | struct ip_addr gw; 16 | }; 17 | 18 | #define IP4_ADDR(ipaddr, a,b,c,d) \ 19 | (ipaddr)->addr = ((uint32)((d) & 0xff) << 24) | \ 20 | ((uint32)((c) & 0xff) << 16) | \ 21 | ((uint32)((b) & 0xff) << 8) | \ 22 | (uint32)((a) & 0xff) 23 | 24 | /** 25 | * Determine if two address are on the same network. 26 | * 27 | * @arg addr1 IP address 1 28 | * @arg addr2 IP address 2 29 | * @arg mask network identifier mask 30 | * @return !0 if the network identifiers of both address match 31 | */ 32 | #define ip_addr_netcmp(addr1, addr2, mask) (((addr1)->addr & \ 33 | (mask)->addr) == \ 34 | ((addr2)->addr & \ 35 | (mask)->addr)) 36 | 37 | /** Set an IP address given by the four byte-parts. 38 | Little-endian version that prevents the use of htonl. */ 39 | #define IP4_ADDR(ipaddr, a,b,c,d) \ 40 | (ipaddr)->addr = ((uint32)((d) & 0xff) << 24) | \ 41 | ((uint32)((c) & 0xff) << 16) | \ 42 | ((uint32)((b) & 0xff) << 8) | \ 43 | (uint32)((a) & 0xff) 44 | 45 | #define ip4_addr1(ipaddr) (((uint8*)(ipaddr))[0]) 46 | #define ip4_addr2(ipaddr) (((uint8*)(ipaddr))[1]) 47 | #define ip4_addr3(ipaddr) (((uint8*)(ipaddr))[2]) 48 | #define ip4_addr4(ipaddr) (((uint8*)(ipaddr))[3]) 49 | 50 | #define ip4_addr1_16(ipaddr) ((uint16)ip4_addr1(ipaddr)) 51 | #define ip4_addr2_16(ipaddr) ((uint16)ip4_addr2(ipaddr)) 52 | #define ip4_addr3_16(ipaddr) ((uint16)ip4_addr3(ipaddr)) 53 | #define ip4_addr4_16(ipaddr) ((uint16)ip4_addr4(ipaddr)) 54 | 55 | 56 | /** 255.255.255.255 */ 57 | #define IPADDR_NONE ((uint32)0xffffffffUL) 58 | /** 0.0.0.0 */ 59 | #define IPADDR_ANY ((uint32)0x00000000UL) 60 | uint32 ipaddr_addr(const char *cp); 61 | 62 | #define IP2STR(ipaddr) ip4_addr1_16(ipaddr), \ 63 | ip4_addr2_16(ipaddr), \ 64 | ip4_addr3_16(ipaddr), \ 65 | ip4_addr4_16(ipaddr) 66 | 67 | #define IPSTR "%d.%d.%d.%d" 68 | 69 | #endif /* __IP_ADDR_H__ */ 70 | -------------------------------------------------------------------------------- /include/lwip/app/dhcpserver.h: -------------------------------------------------------------------------------- 1 | #ifndef __DHCPS_H__ 2 | #define __DHCPS_H__ 3 | 4 | #define USE_DNS 5 | 6 | typedef struct dhcps_state{ 7 | sint16_t state; 8 | } dhcps_state; 9 | 10 | // ����dhcpclient�Զ����һ��DHCP msg�ṹ�� 11 | typedef struct dhcps_msg { 12 | uint8_t op, htype, hlen, hops; 13 | uint8_t xid[4]; 14 | uint16_t secs, flags; 15 | uint8_t ciaddr[4]; 16 | uint8_t yiaddr[4]; 17 | uint8_t siaddr[4]; 18 | uint8_t giaddr[4]; 19 | uint8_t chaddr[16]; 20 | uint8_t sname[64]; 21 | uint8_t file[128]; 22 | uint8_t options[312]; 23 | }dhcps_msg; 24 | 25 | #ifndef LWIP_OPEN_SRC 26 | struct dhcps_lease { 27 | // bool enable; -> dhcps_lease_flag 28 | struct ip_addr start_ip; 29 | struct ip_addr end_ip; 30 | }; 31 | 32 | enum dhcps_offer_option{ 33 | OFFER_START = 0x00, 34 | OFFER_ROUTER = 0x01, 35 | OFFER_END 36 | }; 37 | #endif 38 | 39 | struct dhcps_pool{ 40 | struct ip_addr ip; 41 | uint8 mac[6]; 42 | uint32 lease_timer; 43 | }; 44 | 45 | typedef struct _list_node{ 46 | void *pnode; 47 | struct _list_node *pnext; 48 | }list_node; 49 | 50 | extern uint32 dhcps_lease_time; 51 | 52 | #define DHCPS_LEASE_TIMER dhcps_lease_time //0x05A0 53 | #define DHCPS_MAX_LEASE 0x64 54 | #define BOOTP_BROADCAST 0x8000 55 | 56 | #define DHCP_REQUEST 1 57 | #define DHCP_REPLY 2 58 | #define DHCP_HTYPE_ETHERNET 1 59 | #define DHCP_HLEN_ETHERNET 6 60 | #define DHCP_MSG_LEN 236 61 | 62 | #define DHCPS_SERVER_PORT 67 63 | #define DHCPS_CLIENT_PORT 68 64 | 65 | #define DHCPDISCOVER 1 66 | #define DHCPOFFER 2 67 | #define DHCPREQUEST 3 68 | #define DHCPDECLINE 4 69 | #define DHCPACK 5 70 | #define DHCPNAK 6 71 | #define DHCPRELEASE 7 72 | 73 | #define DHCP_OPTION_SUBNET_MASK 1 74 | #define DHCP_OPTION_ROUTER 3 75 | #define DHCP_OPTION_DNS_SERVER 6 76 | #define DHCP_OPTION_REQ_IPADDR 50 77 | #define DHCP_OPTION_LEASE_TIME 51 78 | #define DHCP_OPTION_MSG_TYPE 53 79 | #define DHCP_OPTION_SERVER_ID 54 80 | #define DHCP_OPTION_INTERFACE_MTU 26 81 | #define DHCP_OPTION_PERFORM_ROUTER_DISCOVERY 31 82 | #define DHCP_OPTION_BROADCAST_ADDRESS 28 83 | #define DHCP_OPTION_REQ_LIST 55 84 | #define DHCP_OPTION_END 255 85 | 86 | //#define USE_CLASS_B_NET 1 87 | #define DHCPS_DEBUG 0 88 | #define MAX_STATION_NUM 8 89 | 90 | #define DHCPS_STATE_OFFER 1 91 | #define DHCPS_STATE_DECLINE 2 92 | #define DHCPS_STATE_ACK 3 93 | #define DHCPS_STATE_NAK 4 94 | #define DHCPS_STATE_IDLE 5 95 | #define DHCPS_STATE_RELEASE 6 96 | 97 | #define dhcps_router_enabled(offer) ((offer & OFFER_ROUTER) != 0) 98 | 99 | void dhcps_start(struct ip_info *info); 100 | void dhcps_stop(void); 101 | 102 | #endif 103 | 104 | -------------------------------------------------------------------------------- /include/lwip/app/espconn_tcp.h: -------------------------------------------------------------------------------- 1 | #ifndef __ESPCONN_TCP_H__ 2 | #define __ESPCONN_TCP_H__ 3 | 4 | #include "lwipopts.h" 5 | #ifdef USE_ESPCONN 6 | 7 | #ifndef ESPCONN_TCP_DEBUG 8 | #define ESPCONN_TCP_DEBUG LWIP_DBG_OFF 9 | #endif 10 | #include "lwip/app/espconn.h" 11 | 12 | #ifndef ESPCONN_TCP_TIMER 13 | #define ESPCONN_TCP_TIMER 40 14 | #endif 15 | 16 | #define espconn_keepalive_enable(pcb) ((pcb)->so_options |= SOF_KEEPALIVE) 17 | #define espconn_keepalive_disable(pcb) ((pcb)->so_options &= ~SOF_KEEPALIVE) 18 | 19 | /****************************************************************************** 20 | * FunctionName : espconn_kill_oldest_pcb 21 | * Description : A oldest incoming connection has been killed. 22 | * Parameters : none 23 | * Returns : none 24 | *******************************************************************************/ 25 | 26 | extern void espconn_kill_oldest_pcb(void); 27 | 28 | /****************************************************************************** 29 | * FunctionName : espconn_tcp_disconnect 30 | * Description : A new incoming connection has been disconnected. 31 | * Parameters : espconn -- the espconn used to disconnect with host 32 | * Returns : none 33 | *******************************************************************************/ 34 | 35 | extern void espconn_tcp_disconnect(espconn_msg *pdiscon); 36 | 37 | /****************************************************************************** 38 | * FunctionName : espconn_tcp_client 39 | * Description : Initialize the client: set up a connect PCB and bind it to 40 | * the defined port 41 | * Parameters : espconn -- the espconn used to build client 42 | * Returns : none 43 | *******************************************************************************/ 44 | 45 | extern sint8 espconn_tcp_client(struct espconn* espconn); 46 | 47 | /****************************************************************************** 48 | * FunctionName : espconn_tcp_server 49 | * Description : Initialize the server: set up a listening PCB and bind it to 50 | * the defined port 51 | * Parameters : espconn -- the espconn used to build server 52 | * Returns : none 53 | *******************************************************************************/ 54 | 55 | extern sint8 espconn_tcp_server(struct espconn *espconn); 56 | 57 | #endif // USE_ESPCONN 58 | 59 | #endif /* __CLIENT_TCP_H__ */ 60 | 61 | -------------------------------------------------------------------------------- /include/lwip/app/espconn_udp.h: -------------------------------------------------------------------------------- 1 | #ifndef __ESPCONN_UDP_H__ 2 | #define __ESPCONN_UDP_H__ 3 | 4 | #include "lwipopts.h" 5 | #ifdef USE_ESPCONN 6 | 7 | #ifndef ESPCONN_UDP_DEBUG 8 | #define ESPCONN_UDP_DEBUG LWIP_DBG_OFF 9 | #endif 10 | 11 | #include "lwip/app/espconn.h" 12 | 13 | /****************************************************************************** 14 | * FunctionName : espconn_udp_client 15 | * Description : Initialize the client: set up a PCB and bind it to the port 16 | * Parameters : pespconn -- the espconn used to build client 17 | * Returns : none 18 | *******************************************************************************/ 19 | 20 | extern sint8 espconn_udp_client(struct espconn *pespconn); 21 | 22 | /****************************************************************************** 23 | * FunctionName : espconn_udp_disconnect 24 | * Description : A new incoming connection has been disconnected. 25 | * Parameters : espconn -- the espconn used to disconnect with host 26 | * Returns : none 27 | *******************************************************************************/ 28 | 29 | extern void espconn_udp_disconnect(espconn_msg *pdiscon); 30 | 31 | /****************************************************************************** 32 | * FunctionName : espconn_udp_server 33 | * Description : Initialize the server: set up a PCB and bind it to the port 34 | * Parameters : pespconn -- the espconn used to build server 35 | * Returns : none 36 | *******************************************************************************/ 37 | 38 | extern sint8 espconn_udp_server(struct espconn *espconn); 39 | 40 | /****************************************************************************** 41 | * FunctionName : espconn_udp_sent 42 | * Description : sent data for client or server 43 | * Parameters : void *arg -- client or server to send 44 | * uint8* psent -- Data to send 45 | * uint16 length -- Length of data to send 46 | * Returns : none 47 | *******************************************************************************/ 48 | 49 | extern err_t espconn_udp_sent(void *arg, uint8 *psent, uint16 length); 50 | 51 | /****************************************************************************** 52 | * FunctionName : espconn_udp_sendto 53 | * Description : sent data for UDP 54 | * Parameters : void *arg -- UDP to send 55 | * uint8* psent -- Data to send 56 | * uint16 length -- Length of data to send 57 | * Returns : return espconn error code. 58 | * - ESPCONN_OK. Successful. No error occured. 59 | * - ESPCONN_MEM. Out of memory. 60 | * - ESPCONN_RTE. Could not find route to destination address. 61 | * - More errors could be returned by lower protocol layers. 62 | *******************************************************************************/ 63 | extern err_t espconn_udp_sendto(void *arg, uint8 *psent, uint16 length); 64 | 65 | #endif // USE_ESPCONN 66 | 67 | #endif /* __ESPCONN_UDP_H__ */ 68 | 69 | 70 | -------------------------------------------------------------------------------- /include/lwip/app/ping.h: -------------------------------------------------------------------------------- 1 | #ifndef __PING_H__ 2 | #define __PING_H__ 3 | #include "lwip/ip_addr.h" 4 | #include "lwip/icmp.h" 5 | /** 6 | * PING_USE_SOCKETS: Set to 1 to use sockets, otherwise the raw api is used 7 | */ 8 | #ifndef PING_USE_SOCKETS 9 | #define PING_USE_SOCKETS LWIP_SOCKET 10 | #endif 11 | 12 | /** 13 | * PING_DEBUG: Enable debugging for PING. 14 | */ 15 | #ifndef PING_DEBUG 16 | #define PING_DEBUG LWIP_DBG_OFF 17 | #endif 18 | 19 | /** ping receive timeout - in milliseconds */ 20 | #ifndef PING_RCV_TIMEO 21 | #define PING_RCV_TIMEO 1000 22 | #endif 23 | 24 | /** ping delay - in milliseconds */ 25 | #ifndef PING_COARSE 26 | #define PING_COARSE 1000 27 | #endif 28 | 29 | /** ping identifier - must fit on a u16_t */ 30 | #ifndef PING_ID 31 | #define PING_ID 0xAFAF 32 | #endif 33 | 34 | /** ping additional data size to include in the packet */ 35 | #ifndef PING_DATA_SIZE 36 | #define PING_DATA_SIZE 32 37 | #endif 38 | 39 | /** ping result action - no default action */ 40 | #ifndef PING_RESULT 41 | #define PING_RESULT(ping_ok) 42 | #endif 43 | 44 | #define DEFAULT_PING_MAX_COUNT 4 45 | #define PING_TIMEOUT_MS 1000 46 | 47 | typedef void (* ping_recv_function)(void* arg, void *pdata); 48 | typedef void (* ping_sent_function)(void* arg, void *pdata); 49 | 50 | struct ping_option{ 51 | uint32 count; 52 | uint32 ip; 53 | uint32 coarse_time; 54 | ping_recv_function recv_function; 55 | ping_sent_function sent_function; 56 | void* reverse; 57 | }; 58 | 59 | struct ping_msg{ 60 | struct ping_option *ping_opt; 61 | struct raw_pcb *ping_pcb; 62 | uint32 ping_start; 63 | uint32 ping_sent; 64 | uint32 timeout_count; 65 | uint32 max_count; 66 | uint32 sent_count; 67 | uint32 coarse_time; 68 | }; 69 | 70 | struct ping_resp{ 71 | uint32 total_count; 72 | uint32 resp_time; 73 | uint32 seqno; 74 | uint32 timeout_count; 75 | uint32 bytes; 76 | uint32 total_bytes; 77 | uint32 total_time; 78 | sint8 ping_err; 79 | }; 80 | 81 | bool ping_start(struct ping_option *ping_opt); 82 | bool ping_regist_recv(struct ping_option *ping_opt, ping_recv_function ping_recv); 83 | bool ping_regist_sent(struct ping_option *ping_opt, ping_sent_function ping_sent); 84 | 85 | #endif /* __PING_H__ */ 86 | -------------------------------------------------------------------------------- /include/lwip/debug.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_DEBUG_H__ 33 | #define __LWIP_DEBUG_H__ 34 | 35 | #include "lwip/arch.h" 36 | 37 | /** lower two bits indicate debug level 38 | * - 0 all 39 | * - 1 warning 40 | * - 2 serious 41 | * - 3 severe 42 | */ 43 | #define LWIP_DBG_LEVEL_ALL 0x00 44 | #define LWIP_DBG_LEVEL_OFF LWIP_DBG_LEVEL_ALL /* compatibility define only */ 45 | #define LWIP_DBG_LEVEL_WARNING 0x01 /* bad checksums, dropped packets, ... */ 46 | #define LWIP_DBG_LEVEL_SERIOUS 0x02 /* memory allocation failures, ... */ 47 | #define LWIP_DBG_LEVEL_SEVERE 0x03 48 | #define LWIP_DBG_MASK_LEVEL 0x03 49 | 50 | /** flag for LWIP_DEBUGF to enable that debug message */ 51 | #define LWIP_DBG_ON 0x80U 52 | /** flag for LWIP_DEBUGF to disable that debug message */ 53 | #define LWIP_DBG_OFF 0x00U 54 | 55 | /** flag for LWIP_DEBUGF indicating a tracing message (to follow program flow) */ 56 | #define LWIP_DBG_TRACE 0x40U 57 | /** flag for LWIP_DEBUGF indicating a state debug message (to follow module states) */ 58 | #define LWIP_DBG_STATE 0x20U 59 | /** flag for LWIP_DEBUGF indicating newly added code, not thoroughly tested yet */ 60 | #define LWIP_DBG_FRESH 0x10U 61 | /** flag for LWIP_DEBUGF to halt after printing this debug message */ 62 | #define LWIP_DBG_HALT 0x08U 63 | 64 | #ifndef LWIP_NOASSERT 65 | #define LWIP_ASSERT(message, assertion) do { if(!(assertion)) \ 66 | LWIP_PLATFORM_ASSERT(message); } while(0) 67 | #else /* LWIP_NOASSERT */ 68 | #define LWIP_ASSERT(message, assertion) 69 | #endif /* LWIP_NOASSERT */ 70 | 71 | /** if "expression" isn't true, then print "message" and execute "handler" expression */ 72 | #ifndef LWIP_ERROR 73 | #define LWIP_ERROR(message, expression, handler) do { if (!(expression)) { \ 74 | LWIP_PLATFORM_ASSERT(message); handler;}} while(0) 75 | #endif /* LWIP_ERROR */ 76 | 77 | #ifdef LWIP_DEBUG 78 | /** print debug message only if debug message type is enabled... 79 | * AND is of correct type AND is at least LWIP_DBG_LEVEL 80 | */ 81 | #define LWIP_DEBUGF(debug, message) do { \ 82 | if ( \ 83 | ((debug) & LWIP_DBG_ON) && \ 84 | ((debug) & LWIP_DBG_TYPES_ON) && \ 85 | ((s16_t)((debug) & LWIP_DBG_MASK_LEVEL) >= LWIP_DBG_MIN_LEVEL)) { \ 86 | LWIP_PLATFORM_DIAG(message); \ 87 | if ((debug) & LWIP_DBG_HALT) { \ 88 | while(1); \ 89 | } \ 90 | } \ 91 | } while(0) 92 | 93 | #else /* LWIP_DEBUG */ 94 | #define LWIP_DEBUGF(debug, message) 95 | #endif /* LWIP_DEBUG */ 96 | 97 | #endif /* __LWIP_DEBUG_H__ */ 98 | 99 | -------------------------------------------------------------------------------- /include/lwip/err.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_ERR_H__ 33 | #define __LWIP_ERR_H__ 34 | 35 | #include "lwip/opt.h" 36 | #include "lwip/arch.h" 37 | 38 | #ifdef __cplusplus 39 | extern "C" { 40 | #endif 41 | 42 | /** Define LWIP_ERR_T in cc.h if you want to use 43 | * a different type for your platform (must be signed). */ 44 | #ifdef LWIP_ERR_T 45 | typedef LWIP_ERR_T err_t; 46 | #else /* LWIP_ERR_T */ 47 | typedef s8_t err_t; 48 | #endif /* LWIP_ERR_T*/ 49 | 50 | /* Definitions for error constants. */ 51 | 52 | #define ERR_OK 0 /* No error, everything OK. */ 53 | #define ERR_MEM -1 /* Out of memory error. */ 54 | #define ERR_BUF -2 /* Buffer error. */ 55 | #define ERR_TIMEOUT -3 /* Timeout. */ 56 | #define ERR_RTE -4 /* Routing problem. */ 57 | #define ERR_INPROGRESS -5 /* Operation in progress */ 58 | #define ERR_VAL -6 /* Illegal value. */ 59 | #define ERR_WOULDBLOCK -7 /* Operation would block. */ 60 | 61 | #define ERR_IS_FATAL(e) ((e) < ERR_WOULDBLOCK) 62 | 63 | #define ERR_ABRT -8 /* Connection aborted. */ 64 | #define ERR_RST -9 /* Connection reset. */ 65 | #define ERR_CLSD -10 /* Connection closed. */ 66 | #define ERR_CONN -11 /* Not connected. */ 67 | 68 | #define ERR_ARG -12 /* Illegal argument. */ 69 | 70 | #define ERR_USE -13 /* Address in use. */ 71 | 72 | #define ERR_IF -14 /* Low-level netif error */ 73 | #define ERR_ISCONN -15 /* Already connected. */ 74 | 75 | 76 | #ifdef LWIP_DEBUG 77 | extern const char *lwip_strerr(err_t err)ICACHE_FLASH_ATTR; 78 | #else 79 | #define lwip_strerr(x) "" 80 | #endif /* LWIP_DEBUG */ 81 | 82 | #ifdef __cplusplus 83 | } 84 | #endif 85 | 86 | #endif /* __LWIP_ERR_H__ */ 87 | -------------------------------------------------------------------------------- /include/lwip/icmp.h: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/include/lwip/icmp.h -------------------------------------------------------------------------------- /include/lwip/inet_chksum.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_INET_CHKSUM_H__ 33 | #define __LWIP_INET_CHKSUM_H__ 34 | 35 | #include "lwip/opt.h" 36 | 37 | #include "lwip/pbuf.h" 38 | #include "lwip/ip_addr.h" 39 | 40 | /** Swap the bytes in an u16_t: much like htons() for little-endian */ 41 | #ifndef SWAP_BYTES_IN_WORD 42 | #if LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN) 43 | /* little endian and PLATFORM_BYTESWAP defined */ 44 | #define SWAP_BYTES_IN_WORD(w) LWIP_PLATFORM_HTONS(w) 45 | #else /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN) */ 46 | /* can't use htons on big endian (or PLATFORM_BYTESWAP not defined)... */ 47 | #define SWAP_BYTES_IN_WORD(w) (((w) & 0xff) << 8) | (((w) & 0xff00) >> 8) 48 | #endif /* LWIP_PLATFORM_BYTESWAP && (BYTE_ORDER == LITTLE_ENDIAN)*/ 49 | #endif /* SWAP_BYTES_IN_WORD */ 50 | 51 | /** Split an u32_t in two u16_ts and add them up */ 52 | #ifndef FOLD_U32T 53 | #define FOLD_U32T(u) (((u) >> 16) + ((u) & 0x0000ffffUL)) 54 | #endif 55 | 56 | #if LWIP_CHECKSUM_ON_COPY 57 | /** Function-like macro: same as MEMCPY but returns the checksum of copied data 58 | as u16_t */ 59 | #ifndef LWIP_CHKSUM_COPY 60 | #define LWIP_CHKSUM_COPY(dst, src, len) lwip_chksum_copy(dst, src, len) 61 | #ifndef LWIP_CHKSUM_COPY_ALGORITHM 62 | #define LWIP_CHKSUM_COPY_ALGORITHM 1 63 | #endif /* LWIP_CHKSUM_COPY_ALGORITHM */ 64 | #endif /* LWIP_CHKSUM_COPY */ 65 | #else /* LWIP_CHECKSUM_ON_COPY */ 66 | #define LWIP_CHKSUM_COPY_ALGORITHM 0 67 | #endif /* LWIP_CHECKSUM_ON_COPY */ 68 | 69 | #ifdef __cplusplus 70 | extern "C" { 71 | #endif 72 | 73 | u16_t inet_chksum(void *dataptr, u16_t len)ICACHE_FLASH_ATTR; 74 | u16_t inet_chksum_pbuf(struct pbuf *p)ICACHE_FLASH_ATTR; 75 | u16_t inet_chksum_pseudo(struct pbuf *p, 76 | ip_addr_t *src, ip_addr_t *dest, 77 | u8_t proto, u16_t proto_len)ICACHE_FLASH_ATTR; 78 | u16_t inet_chksum_pseudo_partial(struct pbuf *p, 79 | ip_addr_t *src, ip_addr_t *dest, 80 | u8_t proto, u16_t proto_len, u16_t chksum_len)ICACHE_FLASH_ATTR; 81 | #if LWIP_CHKSUM_COPY_ALGORITHM 82 | u16_t lwip_chksum_copy(void *dst, const void *src, u16_t len)ICACHE_FLASH_ATTR; 83 | #endif /* LWIP_CHKSUM_COPY_ALGORITHM */ 84 | 85 | #ifdef __cplusplus 86 | } 87 | #endif 88 | 89 | #endif /* __LWIP_INET_H__ */ 90 | 91 | -------------------------------------------------------------------------------- /include/lwip/init.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_INIT_H__ 33 | #define __LWIP_INIT_H__ 34 | 35 | #include "lwip/opt.h" 36 | 37 | #ifdef __cplusplus 38 | extern "C" { 39 | #endif 40 | 41 | /** X.x.x: Major version of the stack */ 42 | #define LWIP_VERSION_MAJOR 1U 43 | /** x.X.x: Minor version of the stack */ 44 | #define LWIP_VERSION_MINOR 4U 45 | /** x.x.X: Revision of the stack */ 46 | #define LWIP_VERSION_REVISION 0U 47 | /** For release candidates, this is set to 1..254 48 | * For official releases, this is set to 255 (LWIP_RC_RELEASE) 49 | * For development versions (CVS), this is set to 0 (LWIP_RC_DEVELOPMENT) */ 50 | #define LWIP_VERSION_RC 2U 51 | 52 | /** LWIP_VERSION_RC is set to LWIP_RC_RELEASE for official releases */ 53 | #define LWIP_RC_RELEASE 255U 54 | /** LWIP_VERSION_RC is set to LWIP_RC_DEVELOPMENT for CVS versions */ 55 | #define LWIP_RC_DEVELOPMENT 0U 56 | 57 | #define LWIP_VERSION_IS_RELEASE (LWIP_VERSION_RC == LWIP_RC_RELEASE) 58 | #define LWIP_VERSION_IS_DEVELOPMENT (LWIP_VERSION_RC == LWIP_RC_DEVELOPMENT) 59 | #define LWIP_VERSION_IS_RC ((LWIP_VERSION_RC != LWIP_RC_RELEASE) && (LWIP_VERSION_RC != LWIP_RC_DEVELOPMENT)) 60 | 61 | /** Provides the version of the stack */ 62 | #define LWIP_VERSION (LWIP_VERSION_MAJOR << 24 | LWIP_VERSION_MINOR << 16 | \ 63 | LWIP_VERSION_REVISION << 8 | LWIP_VERSION_RC) 64 | 65 | /* Modules initialization */ 66 | void lwip_init(void) ICACHE_FLASH_ATTR; 67 | //void lwip_init(void); 68 | 69 | #ifdef __cplusplus 70 | } 71 | #endif 72 | 73 | #endif /* __LWIP_INIT_H__ */ 74 | -------------------------------------------------------------------------------- /include/lwip/ip_frag.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Jani Monoses 30 | * 31 | */ 32 | 33 | #ifndef __LWIP_IP_FRAG_H__ 34 | #define __LWIP_IP_FRAG_H__ 35 | 36 | #include "lwip/opt.h" 37 | #include "lwip/err.h" 38 | #include "lwip/pbuf.h" 39 | #include "lwip/netif.h" 40 | #include "lwip/ip_addr.h" 41 | #include "lwip/ip.h" 42 | 43 | #ifdef __cplusplus 44 | extern "C" { 45 | #endif 46 | 47 | #if IP_REASSEMBLY 48 | /* The IP reassembly timer interval in milliseconds. */ 49 | #define IP_TMR_INTERVAL 1000 50 | 51 | /* IP reassembly helper struct. 52 | * This is exported because memp needs to know the size. 53 | */ 54 | struct ip_reassdata { 55 | struct ip_reassdata *next; 56 | struct pbuf *p; 57 | struct ip_hdr iphdr; 58 | u16_t datagram_len; 59 | u8_t flags; 60 | u8_t timer; 61 | }; 62 | 63 | void ip_reass_init(void)ICACHE_FLASH_ATTR; 64 | void ip_reass_tmr(void)ICACHE_FLASH_ATTR; 65 | struct pbuf * ip_reass(struct pbuf *p)ICACHE_FLASH_ATTR; 66 | #endif /* IP_REASSEMBLY */ 67 | 68 | #if IP_FRAG 69 | #if !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF 70 | /** A custom pbuf that holds a reference to another pbuf, which is freed 71 | * when this custom pbuf is freed. This is used to create a custom PBUF_REF 72 | * that points into the original pbuf. */ 73 | struct pbuf_custom_ref { 74 | /** 'base class' */ 75 | struct pbuf_custom pc; 76 | /** pointer to the original pbuf that is referenced */ 77 | struct pbuf *original; 78 | }; 79 | #endif /* !IP_FRAG_USES_STATIC_BUF && !LWIP_NETIF_TX_SINGLE_PBUF */ 80 | 81 | err_t ip_frag(struct pbuf *p, struct netif *netif, ip_addr_t *dest)ICACHE_FLASH_ATTR; 82 | #endif /* IP_FRAG */ 83 | 84 | #ifdef __cplusplus 85 | } 86 | #endif 87 | 88 | #endif /* __LWIP_IP_FRAG_H__ */ 89 | -------------------------------------------------------------------------------- /include/lwip/netifapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Redistribution and use in source and binary forms, with or without modification, 3 | * are permitted provided that the following conditions are met: 4 | * 5 | * 1. Redistributions of source code must retain the above copyright notice, 6 | * this list of conditions and the following disclaimer. 7 | * 2. Redistributions in binary form must reproduce the above copyright notice, 8 | * this list of conditions and the following disclaimer in the documentation 9 | * and/or other materials provided with the distribution. 10 | * 3. The name of the author may not be used to endorse or promote products 11 | * derived from this software without specific prior written permission. 12 | * 13 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 14 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 15 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 16 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 17 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 18 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 19 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 20 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 21 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 22 | * OF SUCH DAMAGE. 23 | * 24 | * This file is part of the lwIP TCP/IP stack. 25 | * 26 | */ 27 | 28 | #ifndef __LWIP_NETIFAPI_H__ 29 | #define __LWIP_NETIFAPI_H__ 30 | 31 | #include "lwip/opt.h" 32 | 33 | #if LWIP_NETIF_API /* don't build if not configured for use in lwipopts.h */ 34 | 35 | #include "lwip/sys.h" 36 | #include "lwip/netif.h" 37 | #include "lwip/dhcp.h" 38 | #include "lwip/autoip.h" 39 | 40 | #ifdef __cplusplus 41 | extern "C" { 42 | #endif 43 | 44 | typedef void (*netifapi_void_fn)(struct netif *netif); 45 | typedef err_t (*netifapi_errt_fn)(struct netif *netif); 46 | 47 | struct netifapi_msg_msg { 48 | #if !LWIP_TCPIP_CORE_LOCKING 49 | sys_sem_t sem; 50 | #endif /* !LWIP_TCPIP_CORE_LOCKING */ 51 | err_t err; 52 | struct netif *netif; 53 | union { 54 | struct { 55 | ip_addr_t *ipaddr; 56 | ip_addr_t *netmask; 57 | ip_addr_t *gw; 58 | void *state; 59 | netif_init_fn init; 60 | netif_input_fn input; 61 | } add; 62 | struct { 63 | netifapi_void_fn voidfunc; 64 | netifapi_errt_fn errtfunc; 65 | } common; 66 | } msg; 67 | }; 68 | 69 | struct netifapi_msg { 70 | void (* function)(struct netifapi_msg_msg *msg); 71 | struct netifapi_msg_msg msg; 72 | }; 73 | 74 | 75 | /* API for application */ 76 | err_t netifapi_netif_add ( struct netif *netif, 77 | ip_addr_t *ipaddr, 78 | ip_addr_t *netmask, 79 | ip_addr_t *gw, 80 | void *state, 81 | netif_init_fn init, 82 | netif_input_fn input); 83 | 84 | err_t netifapi_netif_set_addr ( struct netif *netif, 85 | ip_addr_t *ipaddr, 86 | ip_addr_t *netmask, 87 | ip_addr_t *gw ); 88 | 89 | err_t netifapi_netif_common ( struct netif *netif, 90 | netifapi_void_fn voidfunc, 91 | netifapi_errt_fn errtfunc); 92 | 93 | #define netifapi_netif_remove(n) netifapi_netif_common(n, netif_remove, NULL) 94 | #define netifapi_netif_set_up(n) netifapi_netif_common(n, netif_set_up, NULL) 95 | #define netifapi_netif_set_down(n) netifapi_netif_common(n, netif_set_down, NULL) 96 | #define netifapi_netif_set_default(n) netifapi_netif_common(n, netif_set_default, NULL) 97 | #define netifapi_dhcp_start(n) netifapi_netif_common(n, NULL, dhcp_start) 98 | #define netifapi_dhcp_stop(n) netifapi_netif_common(n, dhcp_stop, NULL) 99 | #define netifapi_autoip_start(n) netifapi_netif_common(n, NULL, autoip_start) 100 | #define netifapi_autoip_stop(n) netifapi_netif_common(n, NULL, autoip_stop) 101 | 102 | #ifdef __cplusplus 103 | } 104 | #endif 105 | 106 | #endif /* LWIP_NETIF_API */ 107 | 108 | #endif /* __LWIP_NETIFAPI_H__ */ 109 | -------------------------------------------------------------------------------- /include/lwip/puck_def.h: -------------------------------------------------------------------------------- 1 | /* 2 | * puck_def.h 3 | * 4 | * Created on: Jul 22, 2010 5 | * Author: dtoma 6 | */ 7 | 8 | #ifndef PUCK_DEF_H_ 9 | #define PUCK_DEF_H_ 10 | 11 | 12 | 13 | #define INSTRUMENT_PORT 8760 14 | 15 | #define INSTRUMENT_LENGTH 80 16 | 17 | #define MDNS_NAME_LENGTH 68 //68 18 | 19 | char* PUCK_SERVICE = NULL; 20 | //#define PUCK_SERVICE "_Escpressif._tcp.local" 21 | #define DNS_SD_SERVICE "_services._dns-sd._udp.local" 22 | #define SERVICE_DESCRIPTION "PUCK PROTOCOL" 23 | #define PUCK_SERVICE_LENGTH 30 24 | 25 | #define UUID_LEN 16 26 | #define DS_VERS_LEN 2 27 | #define DS_SIZE_LEN 2 28 | #define MAN_ID_LEN 4 29 | #define MAN_MODEL_LEN 2 30 | #define MAN_VERS_LEN 2 31 | #define SER_NUM_LEN 4 32 | #define NAME_LEN 64 33 | #define PUCK_DATASHEET_SIZE 96 34 | 35 | #define UUID_OFFSET 0 36 | #define DS_VERS_OFFSET UUID_LEN + UUID_OFFSET 37 | #define DS_SIZE_OFFSET DS_VERS_LEN + DS_VERS_OFFSET 38 | #define MAN_ID_OFFSET DS_SIZE_LEN + DS_SIZE_OFFSET 39 | #define MAN_MODEL_OFFSET MAN_ID_LEN + MAN_ID_OFFSET 40 | #define MAN_VERS_OFFSET MAN_MODEL_LEN + MAN_MODEL_OFFSET 41 | #define SER_NUM_OFFSET MAN_VERS_LEN + MAN_VERS_OFFSET 42 | #define NAME_OFFSET SER_NUM_LEN + SER_NUM_OFFSET 43 | 44 | #endif /* __PUCK_DEF_H__ */ 45 | -------------------------------------------------------------------------------- /include/lwip/raw.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * 31 | */ 32 | #ifndef __LWIP_RAW_H__ 33 | #define __LWIP_RAW_H__ 34 | 35 | #include "lwip/opt.h" 36 | 37 | #if LWIP_RAW /* don't build if not configured for use in lwipopts.h */ 38 | 39 | #include "lwip/pbuf.h" 40 | #include "lwip/def.h" 41 | #include "lwip/ip.h" 42 | #include "lwip/ip_addr.h" 43 | 44 | #ifdef __cplusplus 45 | extern "C" { 46 | #endif 47 | 48 | struct raw_pcb; 49 | 50 | /** Function prototype for raw pcb receive callback functions. 51 | * @param arg user supplied argument (raw_pcb.recv_arg) 52 | * @param pcb the raw_pcb which received data 53 | * @param p the packet buffer that was received 54 | * @param addr the remote IP address from which the packet was received 55 | * @return 1 if the packet was 'eaten' (aka. deleted), 56 | * 0 if the packet lives on 57 | * If returning 1, the callback is responsible for freeing the pbuf 58 | * if it's not used any more. 59 | */ 60 | typedef u8_t (*raw_recv_fn)(void *arg, struct raw_pcb *pcb, struct pbuf *p, 61 | ip_addr_t *addr); 62 | 63 | struct raw_pcb { 64 | /* Common members of all PCB types */ 65 | IP_PCB; 66 | 67 | struct raw_pcb *next; 68 | 69 | u8_t protocol; 70 | 71 | /** receive callback function */ 72 | raw_recv_fn recv; 73 | /* user-supplied argument for the recv callback */ 74 | void *recv_arg; 75 | }; 76 | 77 | /* The following functions is the application layer interface to the 78 | RAW code. */ 79 | struct raw_pcb * raw_new (u8_t proto)ICACHE_FLASH_ATTR; 80 | void raw_remove (struct raw_pcb *pcb)ICACHE_FLASH_ATTR; 81 | err_t raw_bind (struct raw_pcb *pcb, ip_addr_t *ipaddr)ICACHE_FLASH_ATTR; 82 | err_t raw_connect (struct raw_pcb *pcb, ip_addr_t *ipaddr)ICACHE_FLASH_ATTR; 83 | 84 | void raw_recv (struct raw_pcb *pcb, raw_recv_fn recv, void *recv_arg)ICACHE_FLASH_ATTR; 85 | err_t raw_sendto (struct raw_pcb *pcb, struct pbuf *p, ip_addr_t *ipaddr)ICACHE_FLASH_ATTR; 86 | err_t raw_send (struct raw_pcb *pcb, struct pbuf *p); 87 | 88 | /* The following functions are the lower layer interface to RAW. */ 89 | u8_t raw_input (struct pbuf *p, struct netif *inp)ICACHE_FLASH_ATTR; 90 | #define raw_init() /* Compatibility define, not init needed. */ 91 | 92 | #ifdef __cplusplus 93 | } 94 | #endif 95 | 96 | #endif /* LWIP_RAW */ 97 | 98 | #endif /* __LWIP_RAW_H__ */ 99 | -------------------------------------------------------------------------------- /include/lwip/snmp_asn1.h: -------------------------------------------------------------------------------- 1 | /** 2 | * @file 3 | * Abstract Syntax Notation One (ISO 8824, 8825) codec. 4 | */ 5 | 6 | /* 7 | * Copyright (c) 2006 Axon Digital Design B.V., The Netherlands. 8 | * All rights reserved. 9 | * 10 | * Redistribution and use in source and binary forms, with or without modification, 11 | * are permitted provided that the following conditions are met: 12 | * 13 | * 1. Redistributions of source code must retain the above copyright notice, 14 | * this list of conditions and the following disclaimer. 15 | * 2. Redistributions in binary form must reproduce the above copyright notice, 16 | * this list of conditions and the following disclaimer in the documentation 17 | * and/or other materials provided with the distribution. 18 | * 3. The name of the author may not be used to endorse or promote products 19 | * derived from this software without specific prior written permission. 20 | * 21 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 22 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 23 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 24 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 25 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 26 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 27 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 28 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 29 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 30 | * OF SUCH DAMAGE. 31 | * 32 | * Author: Christiaan Simons 33 | */ 34 | 35 | #ifndef __LWIP_SNMP_ASN1_H__ 36 | #define __LWIP_SNMP_ASN1_H__ 37 | 38 | #include "lwip/opt.h" 39 | #include "lwip/err.h" 40 | #include "lwip/pbuf.h" 41 | #include "lwip/snmp.h" 42 | 43 | #if LWIP_SNMP 44 | 45 | #ifdef __cplusplus 46 | extern "C" { 47 | #endif 48 | 49 | #define SNMP_ASN1_UNIV (0) /* (!0x80 | !0x40) */ 50 | #define SNMP_ASN1_APPLIC (0x40) /* (!0x80 | 0x40) */ 51 | #define SNMP_ASN1_CONTXT (0x80) /* ( 0x80 | !0x40) */ 52 | 53 | #define SNMP_ASN1_CONSTR (0x20) /* ( 0x20) */ 54 | #define SNMP_ASN1_PRIMIT (0) /* (!0x20) */ 55 | 56 | /* universal tags */ 57 | #define SNMP_ASN1_INTEG 2 58 | #define SNMP_ASN1_OC_STR 4 59 | #define SNMP_ASN1_NUL 5 60 | #define SNMP_ASN1_OBJ_ID 6 61 | #define SNMP_ASN1_SEQ 16 62 | 63 | /* application specific (SNMP) tags */ 64 | #define SNMP_ASN1_IPADDR 0 /* octet string size(4) */ 65 | #define SNMP_ASN1_COUNTER 1 /* u32_t */ 66 | #define SNMP_ASN1_GAUGE 2 /* u32_t */ 67 | #define SNMP_ASN1_TIMETICKS 3 /* u32_t */ 68 | #define SNMP_ASN1_OPAQUE 4 /* octet string */ 69 | 70 | /* context specific (SNMP) tags */ 71 | #define SNMP_ASN1_PDU_GET_REQ 0 72 | #define SNMP_ASN1_PDU_GET_NEXT_REQ 1 73 | #define SNMP_ASN1_PDU_GET_RESP 2 74 | #define SNMP_ASN1_PDU_SET_REQ 3 75 | #define SNMP_ASN1_PDU_TRAP 4 76 | 77 | err_t snmp_asn1_dec_type(struct pbuf *p, u16_t ofs, u8_t *type); 78 | err_t snmp_asn1_dec_length(struct pbuf *p, u16_t ofs, u8_t *octets_used, u16_t *length); 79 | err_t snmp_asn1_dec_u32t(struct pbuf *p, u16_t ofs, u16_t len, u32_t *value); 80 | err_t snmp_asn1_dec_s32t(struct pbuf *p, u16_t ofs, u16_t len, s32_t *value); 81 | err_t snmp_asn1_dec_oid(struct pbuf *p, u16_t ofs, u16_t len, struct snmp_obj_id *oid); 82 | err_t snmp_asn1_dec_raw(struct pbuf *p, u16_t ofs, u16_t len, u16_t raw_len, u8_t *raw); 83 | 84 | void snmp_asn1_enc_length_cnt(u16_t length, u8_t *octets_needed); 85 | void snmp_asn1_enc_u32t_cnt(u32_t value, u16_t *octets_needed); 86 | void snmp_asn1_enc_s32t_cnt(s32_t value, u16_t *octets_needed); 87 | void snmp_asn1_enc_oid_cnt(u8_t ident_len, s32_t *ident, u16_t *octets_needed); 88 | err_t snmp_asn1_enc_type(struct pbuf *p, u16_t ofs, u8_t type); 89 | err_t snmp_asn1_enc_length(struct pbuf *p, u16_t ofs, u16_t length); 90 | err_t snmp_asn1_enc_u32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, u32_t value); 91 | err_t snmp_asn1_enc_s32t(struct pbuf *p, u16_t ofs, u16_t octets_needed, s32_t value); 92 | err_t snmp_asn1_enc_oid(struct pbuf *p, u16_t ofs, u8_t ident_len, s32_t *ident); 93 | err_t snmp_asn1_enc_raw(struct pbuf *p, u16_t ofs, u16_t raw_len, u8_t *raw); 94 | 95 | #ifdef __cplusplus 96 | } 97 | #endif 98 | 99 | #endif /* LWIP_SNMP */ 100 | 101 | #endif /* __LWIP_SNMP_ASN1_H__ */ 102 | -------------------------------------------------------------------------------- /include/lwip/sntp.h: -------------------------------------------------------------------------------- 1 | #ifndef LWIP_SNTP_H 2 | #define LWIP_SNTP_H 3 | 4 | #include "lwip/opt.h" 5 | #include "lwip/ip_addr.h" 6 | 7 | #ifdef __cplusplus 8 | extern "C" { 9 | #endif 10 | 11 | /** The maximum number of SNTP servers that can be set */ 12 | #ifndef SNTP_MAX_SERVERS 13 | #define SNTP_MAX_SERVERS 3 14 | #endif 15 | 16 | /** Set this to 1 to implement the callback function called by dhcp when 17 | * NTP servers are received. */ 18 | #ifndef SNTP_GET_SERVERS_FROM_DHCP 19 | #define SNTP_GET_SERVERS_FROM_DHCP 0//LWIP_DHCP_GET_NTP_SRV 20 | #endif 21 | 22 | /* Set this to 1 to support DNS names (or IP address strings) to set sntp servers */ 23 | #ifndef SNTP_SERVER_DNS 24 | #define SNTP_SERVER_DNS 1 25 | #endif 26 | 27 | /** One server address/name can be defined as default if SNTP_SERVER_DNS == 1: 28 | * #define SNTP_SERVER_ADDRESS "pool.ntp.org" 29 | */ 30 | uint32 sntp_get_current_timestamp(); 31 | char* sntp_get_real_time(long t); 32 | 33 | void sntp_init(void); 34 | void sntp_stop(void); 35 | 36 | sint8 sntp_get_timezone(void); 37 | bool sntp_set_timezone(sint8 timezone); 38 | void sntp_setserver(u8_t idx, ip_addr_t *addr); 39 | ip_addr_t sntp_getserver(u8_t idx); 40 | 41 | #if SNTP_SERVER_DNS 42 | void sntp_setservername(u8_t idx, char *server); 43 | char *sntp_getservername(u8_t idx); 44 | #endif /* SNTP_SERVER_DNS */ 45 | 46 | #if SNTP_GET_SERVERS_FROM_DHCP 47 | void sntp_servermode_dhcp(int set_servers_from_dhcp); 48 | #else /* SNTP_GET_SERVERS_FROM_DHCP */ 49 | #define sntp_servermode_dhcp(x) 50 | #endif /* SNTP_GET_SERVERS_FROM_DHCP */ 51 | 52 | #ifdef __cplusplus 53 | } 54 | #endif 55 | 56 | #endif /* LWIP_SNTP_H */ 57 | -------------------------------------------------------------------------------- /include/lwip/timers.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2001-2004 Swedish Institute of Computer Science. 3 | * All rights reserved. 4 | * 5 | * Redistribution and use in source and binary forms, with or without modification, 6 | * are permitted provided that the following conditions are met: 7 | * 8 | * 1. Redistributions of source code must retain the above copyright notice, 9 | * this list of conditions and the following disclaimer. 10 | * 2. Redistributions in binary form must reproduce the above copyright notice, 11 | * this list of conditions and the following disclaimer in the documentation 12 | * and/or other materials provided with the distribution. 13 | * 3. The name of the author may not be used to endorse or promote products 14 | * derived from this software without specific prior written permission. 15 | * 16 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR IMPLIED 17 | * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF 18 | * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT 19 | * SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, 20 | * EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT 21 | * OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS 22 | * INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN 23 | * CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING 24 | * IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY 25 | * OF SUCH DAMAGE. 26 | * 27 | * This file is part of the lwIP TCP/IP stack. 28 | * 29 | * Author: Adam Dunkels 30 | * Simon Goldschmidt 31 | * 32 | */ 33 | #ifndef __LWIP_TIMERS_H__ 34 | #define __LWIP_TIMERS_H__ 35 | 36 | #include "lwip/opt.h" 37 | 38 | /* Timers are not supported when NO_SYS==1 and NO_SYS_NO_TIMERS==1 */ 39 | #define LWIP_TIMERS (!NO_SYS || (NO_SYS && !NO_SYS_NO_TIMERS)) 40 | 41 | #if LWIP_TIMERS 42 | 43 | #include "lwip/err.h" 44 | #include "lwip/sys.h" 45 | 46 | #ifdef __cplusplus 47 | extern "C" { 48 | #endif 49 | 50 | #ifndef LWIP_DEBUG_TIMERNAMES 51 | #ifdef LWIP_DEBUG 52 | #define LWIP_DEBUG_TIMERNAMES SYS_DEBUG 53 | #else /* LWIP_DEBUG */ 54 | #define LWIP_DEBUG_TIMERNAMES 0 55 | #endif /* LWIP_DEBUG*/ 56 | #endif 57 | 58 | /** Function prototype for a timeout callback function. Register such a function 59 | * using sys_timeout(). 60 | * 61 | * @param arg Additional argument to pass to the function - set up by sys_timeout() 62 | */ 63 | typedef void (* sys_timeout_handler)(void *arg); 64 | 65 | struct sys_timeo { 66 | struct sys_timeo *next; 67 | u32_t time; 68 | sys_timeout_handler h; 69 | void *arg; 70 | #if LWIP_DEBUG_TIMERNAMES 71 | const char* handler_name; 72 | #endif /* LWIP_DEBUG_TIMERNAMES */ 73 | }; 74 | 75 | void sys_timeouts_init(void)ICACHE_FLASH_ATTR; 76 | 77 | #if LWIP_DEBUG_TIMERNAMES 78 | void sys_timeout_debug(u32_t msecs, sys_timeout_handler handler, void *arg, const char* handler_name)ICACHE_FLASH_ATTR; 79 | #define sys_timeout(msecs, handler, arg) sys_timeout_debug(msecs, handler, arg, #handler) 80 | #else /* LWIP_DEBUG_TIMERNAMES */ 81 | void sys_timeout(u32_t msecs, sys_timeout_handler handler, void *arg)ICACHE_FLASH_ATTR; 82 | #endif /* LWIP_DEBUG_TIMERNAMES */ 83 | 84 | void sys_untimeout(sys_timeout_handler handler, void *arg)ICACHE_FLASH_ATTR; 85 | #if NO_SYS 86 | void sys_check_timeouts(void)ICACHE_FLASH_ATTR; 87 | void sys_restart_timeouts(void)ICACHE_FLASH_ATTR; 88 | #else /* NO_SYS */ 89 | void sys_timeouts_mbox_fetch(sys_mbox_t *mbox, void **msg); 90 | #endif /* NO_SYS */ 91 | 92 | 93 | #ifdef __cplusplus 94 | } 95 | #endif 96 | 97 | #endif /* LWIP_TIMERS */ 98 | #endif /* __LWIP_TIMERS_H__ */ 99 | -------------------------------------------------------------------------------- /include/netif/wlan_lwip_if.h: -------------------------------------------------------------------------------- 1 | /* 2 | * Copyright (c) 2010-2011 Espressif System 3 | * Add pvv 4 | */ 5 | 6 | #ifndef _WLAN_LWIP_IF_H_ 7 | #define _WLAN_LWIP_IF_H_ 8 | 9 | #define LWIP_IF0_PRIO 28 10 | #define LWIP_IF1_PRIO 29 11 | 12 | #ifdef USE_OPEN_LWIP 13 | 14 | struct ieee80211_conn { 15 | struct netif *myif; //+0 16 | #if DEF_SDK_VERSION >= 1400 // (SDK 1.4.0) 17 | uint32_t padding[(200-4)>>2]; //+4 (SDK 1.4.0) 18 | #else 19 | uint32_t padding[(176-4)>>2]; //+4 20 | #endif 21 | uint32_t dhcps_if; //+176 // + 0xB0 // +200 SDK 1.4.0 22 | }; 23 | #endif 24 | 25 | enum { 26 | SIG_LWIP_RX = 0, 27 | }; 28 | 29 | struct netif * eagle_lwip_if_alloc(struct ieee80211_conn *conn, uint8 *macaddr, struct ip_info *info) ICACHE_FLASH_ATTR; 30 | struct netif * eagle_lwip_getif(int index); 31 | 32 | #ifndef IOT_SIP_MODE 33 | err_t ieee80211_output_pbuf(struct netif *ifp, struct pbuf* pb); 34 | #else 35 | err_t ieee80211_output_pbuf(struct ieee80211_conn *conn, esf_buf *eb); 36 | #endif 37 | 38 | extern uint8 * hostname; 39 | extern bool default_hostname; // = true; 40 | 41 | #endif /* _WLAN_LWIP_IF_H_ */ 42 | -------------------------------------------------------------------------------- /include/os_type.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * mapping to ETS structures 4 | * 5 | */ 6 | #ifndef _OS_TYPES_H_ 7 | #define _OS_TYPES_H_ 8 | 9 | #include "ets_sys.h" 10 | 11 | #define os_signal_t ETSSignal 12 | #define os_param_t ETSParam 13 | #define os_event_t ETSEvent 14 | #define os_task_t ETSTask 15 | #define os_timer_t ETSTimer 16 | #define os_timer_func_t ETSTimerFunc 17 | 18 | #endif 19 | -------------------------------------------------------------------------------- /include/osapi.h: -------------------------------------------------------------------------------- 1 | /* 2 | */ 3 | 4 | #ifndef _OSAPI_H_ 5 | #define _OSAPI_H_ 6 | 7 | #include 8 | #include "user_config.h" 9 | #include "bios.h" 10 | #include "sdk/os_printf.h" 11 | 12 | #define os_bzero ets_bzero 13 | #define os_delay_us ets_delay_us 14 | #define os_install_putc1 ets_install_putc1 15 | #define os_install_putc2 ets_install_putc2 16 | #define os_intr_lock ets_intr_lock 17 | #define os_intr_unlock ets_intr_unlock 18 | #define os_isr_attach ets_isr_attach 19 | #define os_isr_mask ets_isr_mask 20 | #define os_isr_unmask ets_isr_unmask 21 | #define os_memcmp ets_memcmp 22 | #define os_memcpy ets_memcpy 23 | #define os_memmove ets_memmove 24 | #define os_memset ets_memset 25 | #define os_putc ets_putc 26 | #define os_str2macaddr ets_str2macaddr 27 | //#define os_strcat strcat 28 | #define os_strchr rom_strchr 29 | #define os_strrchr ets_strrchr 30 | #define os_strcmp ets_strcmp 31 | #define os_strcpy ets_strcpy 32 | #define os_strlen ets_strlen 33 | #define os_strncmp ets_strncmp 34 | #define os_strncpy ets_strncpy 35 | #define os_strstr ets_strstr 36 | #define os_random phy_get_rand 37 | extern uint32 phy_get_rand(void); 38 | #ifdef USE_US_TIMER 39 | #define os_timer_arm_us(a, b, c) ets_timer_arm_new(a, b, c, 0) 40 | #endif 41 | #define os_timer_arm(a, b, c) ets_timer_arm_new(a, b, c, 1) 42 | #define os_timer_disarm ets_timer_disarm 43 | #define os_timer_done ets_timer_done 44 | #define os_timer_handler_isr ets_timer_handler_isr 45 | #define os_timer_init ets_timer_init 46 | #define os_timer_setfn ets_timer_setfn 47 | 48 | #define os_update_cpu_frequency ets_update_cpu_frequency 49 | 50 | //#define os_sprintf ets_sprintf 51 | 52 | #ifdef USE_OPTIMIZE_PRINTF 53 | #define os_printf(fmt, ...) do { \ 54 | static const char flash_str[] ICACHE_RODATA_ATTR = fmt; \ 55 | __wrap_os_printf_plus(flash_str, ##__VA_ARGS__); \ 56 | } while(0) 57 | #define os_sprintf_fd(des, fmt, ...) do { \ 58 | static const char flash_str[] ICACHE_RODATA_ATTR = fmt; \ 59 | ets_sprintf(des, flash_str, ##__VA_ARGS__); \ 60 | } while(0) 61 | #define os_printf_plus __wrap_os_printf_plus 62 | #else 63 | #define os_printf __wrap_os_printf_plus 64 | #endif 65 | 66 | #endif 67 | 68 | -------------------------------------------------------------------------------- /include/phy/phy.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: phy.h 3 | * Description: Reverse SDK 1.0.0/1.1.0 (phy.a) 4 | * Author: PV` 5 | *******************************************************************************/ 6 | 7 | #ifndef _LIBS_PHY_H_ 8 | #define _LIBS_PHY_H_ 9 | 10 | #include "bios/rom_phy.h" 11 | 12 | typedef void (* phy_func_var_int_int)(int ch, int n); 13 | typedef void (* phy_func_var_int)(int); 14 | typedef void (* phy_func_void)(void); 15 | 16 | struct phy_funcs{ 17 | phy_func_var_int_int rf_init; // +00 = int chip_v6_rf_init(int ch, int n); 18 | phy_func_var_int set_chanfreq; // +04 = void chip_v6_set_chanfreq(int chfr); 19 | phy_func_var_int set_chan; // +08 = void chip_v6_set_chan(int ch); 20 | phy_func_void unset_chanfreq; // +12 = int chip_v6_unset_chanfreq(void) // return 0; 21 | phy_func_void enable_cca; // +16 = void rom_chip_v5_enable_cca(void) // *0x60009B00 &= ~0x10000000; 22 | phy_func_void disable_cca; // +20 = void rom_chip_v5_disable_cca(void) // *0x60009B00 |= 0x10000000; 23 | phy_func_var_int initialize_bb; // +24 = int chip_v6_initialize_bb(void) 24 | phy_func_void set_sense; // +28 = void chip_v6_set_sense(void) 25 | }; 26 | 27 | extern struct phy_func_tab * g_phyFuns; 28 | //extern uint8 chip6_phy_init_ctrl[128]; // in sys_const.h 29 | 30 | void register_phy_ops(struct phy_funcs * phy_base); 31 | void register_get_phy_addr(struct phy_funcs * prt); 32 | int phy_change_channel(int chfr); 33 | uint32 phy_get_mactime(void); 34 | int chip_v6_set_chanfreq(uint32 chfr) ICACHE_FLASH_ATTR; 35 | void phy_init(int8 ch, int n) ICACHE_FLASH_ATTR; 36 | void RFChannelSel(int8 ch) ICACHE_FLASH_ATTR; 37 | void phy_delete_channel(void) ICACHE_FLASH_ATTR; 38 | void phy_enable_agc(void) ICACHE_FLASH_ATTR; 39 | void phy_disable_agc(void) ICACHE_FLASH_ATTR; 40 | void phy_initialize_bb(int n) ICACHE_FLASH_ATTR; 41 | void phy_set_sense(void) ICACHE_FLASH_ATTR; 42 | 43 | 44 | #endif /* _LIBS_PHY_H_ */ 45 | 46 | -------------------------------------------------------------------------------- /include/pp/esf_buf.h: -------------------------------------------------------------------------------- 1 | /* 2 | * 3 | * esf buffer data structure 4 | */ 5 | 6 | #ifndef _ESF_BUF_H_ 7 | #define _ESF_BUF_H_ 8 | 9 | #define EP_OFFSET 36 /* see comments in pbuf.h */ 10 | 11 | #endif /* _ESF_BUF_H_ */ 12 | -------------------------------------------------------------------------------- /include/sdk/app_main.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: aap_main.h 3 | * Description: Alternate SDK (libmain.a) 4 | * Author: PV` 5 | * (c) PV` 2015 6 | ******************************************************************************/ 7 | 8 | #ifndef _INCLUDE_APP_MAIN_H_ 9 | #define _INCLUDE_APP_MAIN_H_ 10 | 11 | #include "sdk/libmain.h" 12 | 13 | extern struct s_info info; // ip,mask,gw,mac AP, ST 14 | extern init_done_cb_t done_cb; 15 | extern ETSTimer check_timeouts_timer; // timer_lwip 16 | extern uint8 user_init_flag; 17 | //============================================================================= 18 | // funcs libmain.a: app_main.o 19 | //----------------------------------------------------------------------------- 20 | void sflash_something(uint32 flash_speed); 21 | void read_macaddr_from_otp(uint8 *mac); 22 | void user_uart_wait_tx_fifo_empty(uint32 n, uint32 x); 23 | void startup(void) ICACHE_FLASH_ATTR; 24 | void read_wifi_config(void) ICACHE_FLASH_ATTR; 25 | void init_wifi(uint8 * init_data, uint8 * mac) ICACHE_FLASH_ATTR; 26 | void uart_wait_tx_fifo_empty(void) ICACHE_FLASH_ATTR; 27 | void user_uart_wait_tx_fifo_empty(uint32 uart_num, uint32 x); 28 | //----------------------------------------------------------------------------- 29 | void uart1_write_char(char c); 30 | void uart0_write_char(char c); 31 | 32 | #endif /* _INCLUDE_APP_MAIN_H_ */ 33 | -------------------------------------------------------------------------------- /include/sdk/ets_run_new.h: -------------------------------------------------------------------------------- 1 | /* 2 | * ets_run_new.h 3 | * 4 | * Created on: 22 авг. 2015 г. 5 | * Author: PVV 6 | */ 7 | 8 | #ifndef _SDK_ETS_RUN_NEW_H_ 9 | #define _SDK_ETS_RUN_NEW_H_ 10 | 11 | #include "sdk/sdk_config.h" 12 | #ifdef USE_ETS_RUN_NEW 13 | 14 | void ets_run_new(void); 15 | void task_delay_us(uint32 us); 16 | void run_sdk_tasks(void); 17 | 18 | #endif 19 | 20 | #endif /* _SDK_ETS_RUN_NEW_H_ */ 21 | -------------------------------------------------------------------------------- /include/sdk/fatal_errs.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: libmain.h 3 | * Description: Alternate SDK (libmain.a) 4 | * Author: PV` 5 | * (c) PV` 2015 6 | *******************************************************************************/ 7 | 8 | #ifndef _INCLUDE_FATAL_ERRS_H_ 9 | #define _INCLUDE_FATAL_ERRS_H_ 10 | 11 | 12 | #define RST_EVENT_WDT 1 13 | #define RST_EVENT_EXP 2 14 | #define RST_EVENT_SOFT_WDT 3 15 | #define RST_EVENT_SOFT_RESET 4 16 | #define RST_EVENT_DEEP_SLEEP 5 17 | #define RST_EXT_SYS 6 18 | #define RST_EVENT_RES 8 19 | #define FATAL_ERR_R6PHY 9 // "register_chipv6_phy" 20 | #define FATAL_ERR_ALIGN 10 // "Read align4" 21 | #define RST_EVENT_MAX 32 22 | 23 | 24 | void fatal_error(uint32 errn, void *addr, void *txt); 25 | 26 | #endif // _INCLUDE_FATAL_ERRS_H_ 27 | -------------------------------------------------------------------------------- /include/sdk/flash.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: spi_flash.h 3 | * Description: FLASH 4 | * Alternate SDK 5 | * Author: PV` 6 | * (c) PV` 2015 7 | *******************************************************************************/ 8 | 9 | #ifndef SPI_FLASH_H 10 | #define SPI_FLASH_H 11 | 12 | #include "sdk_config.h" 13 | #include "bios/spiflash.h" 14 | 15 | #define SPI_FLASH_SEC_SIZE 4096 16 | 17 | uint32 spi_flash_get_id(void); 18 | SpiFlashOpResult spi_flash_read_status(uint32_t * sta); 19 | SpiFlashOpResult spi_flash_write_status(uint32_t sta); 20 | SpiFlashOpResult spi_flash_erase_sector(uint16 sec); 21 | SpiFlashOpResult spi_flash_write(uint32 faddr, uint32 *src_addr, uint32 size); 22 | SpiFlashOpResult spi_flash_read(uint32 faddr, void *des, uint32 size); 23 | SpiFlashOpResult spi_flash_erase_block(uint32 blk); 24 | 25 | uint32 spi_flash_real_size(void) ICACHE_FLASH_ATTR; 26 | 27 | #ifdef USE_OVERLAP_MODE 28 | 29 | typedef SpiFlashOpResult (* user_spi_flash_read)( 30 | SpiFlashChip *spi, 31 | uint32 src_addr, 32 | uint32 *des_addr, 33 | uint32 size); 34 | 35 | extern user_spi_flash_read flash_read; 36 | 37 | void spi_flash_set_read_func(user_spi_flash_read read); 38 | 39 | #endif 40 | 41 | #define MASK_ADDR_FLASH_ICACHE_DATA 0xfffff 42 | 43 | #define spi_flash_read_byte(faddr, dest) spi_flash_read(faddr, dest, 1); 44 | 45 | #ifdef USE_FIX_SDK_FLASH_SIZE 46 | 47 | #define flashchip_sector_size 4096 48 | 49 | #define open_16m() flashchip->chip_size = FLASH_MAX_SIZE 50 | #define close_16m() flashchip->chip_size = FLASH_MIN_SIZE 51 | 52 | #else 53 | 54 | #define flashchip_sector_size flashchip->sector_size 55 | 56 | #define open_16m() 57 | #define close_16m() 58 | 59 | #endif 60 | 61 | #endif 62 | -------------------------------------------------------------------------------- /include/sdk/mem_manager.h: -------------------------------------------------------------------------------- 1 | #ifndef __MEM_H__ 2 | #define __MEM_H__ 3 | 4 | // в модуле mem_manager.o 5 | 6 | void *pvPortMalloc( size_t xWantedSize ); 7 | void vPortFree( void *pv ); 8 | void *pvPortZalloc(size_t size); 9 | void *pvPortCalloc(unsigned int n, unsigned int count); 10 | void *pvPortRealloc(void * p, size_t size); 11 | size_t xPortGetFreeHeapSize(void); 12 | void prvHeapInit(void) ICACHE_FLASH_ATTR ; 13 | 14 | #define os_malloc pvPortMalloc 15 | #define os_free vPortFree 16 | #define os_zalloc pvPortZalloc 17 | #define os_calloc pvPortCalloc 18 | #define os_realloc pvPortRealloc 19 | #define system_get_free_heap_size xPortGetFreeHeapSize 20 | 21 | #endif // __MEM_H__ 22 | 23 | -------------------------------------------------------------------------------- /include/sdk/os_printf.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: os_printf.h 3 | * Description: Alternate SDK (libmain.a) 4 | * Author: PV` 5 | * (c) PV` 2015 6 | *******************************************************************************/ 7 | 8 | #ifndef _INCLUDE_OS_PRINTF_H_ 9 | #define _INCLUDE_OS_PRINTF_H_ 10 | 11 | 12 | int __wrap_os_printf_plus(const char *format, ...) ICACHE_FLASH_ATTR; 13 | //#define rom_printf __wrap_os_printf_plus 14 | //int rom_printf(const char *format, ...) ICACHE_FLASH_ATTR; 15 | void _sprintf_out(char c) ICACHE_FLASH_ATTR; 16 | int ets_sprintf(char *str, const char *format, ...) ICACHE_FLASH_ATTR; 17 | 18 | #endif /* _INCLUDE_OS_PRINTF_H_ */ 19 | -------------------------------------------------------------------------------- /include/sdk/rom2ram.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: rom2ram.h 3 | * Description: Alternate SDK (libmain.a) 4 | * Author: PV` 5 | * (c) PV` 2015 6 | *******************************************************************************/ 7 | 8 | #ifndef _INCLUDE_ROM2RAM_H_ 9 | #define _INCLUDE_ROM2RAM_H_ 10 | 11 | /* Копирует данные из области align(4) (flash, iram, registers) в область align(1) (ram) */ 12 | int copy_s4d1(unsigned char * pd, void * ps, unsigned int len); 13 | /* Копирует данные из области align(1) (ram) в область align(4) (flash, iram, registers) */ 14 | int copy_s1d4(void * pd, unsigned char * ps, unsigned int len); 15 | /* strlen() для строк в сегментах flash и IRAM */ 16 | unsigned int rom_strlen(const char * ps); 17 | /* strcpy() из сегментов flash и IRAM */ 18 | char * rom_strcpy(char * pd_, void * ps, unsigned int maxlen); 19 | /* xstrcpy() из сегментов flash и IRAM с возвратом размера строки: 20 | на выходе размер строки, без учета терминатора '\0' */ 21 | unsigned int rom_xstrcpy(char * pd, const char * ps); 22 | /* сравнение строки в ram со строкой в сегменте flash и IRAM 23 | = 1 если шаблон совпадает */ 24 | int rom_xstrcmp(char * pd, const char * ps); 25 | /* Чтение буфера в IRAM */ 26 | bool eRamRead(uint32 addr, uint8 *pd, uint32 len); 27 | /* Запись буфера в IRAM */ 28 | bool eRamWrite(uint32 addr, uint8 *ps, uint32 len); 29 | /* strchr() поиск символа в строках находящихся в сегментах flash и IRAM */ 30 | char * rom_strchr(const char * ps, char c); 31 | 32 | #define read_align4_chr(a) (*((*((unsigned int *)((unsigned int)a & (~3))))>>(((unsigned int)a & 3) << 3))) 33 | 34 | char get_align4_chr(const char *ps); 35 | void write_align4_chr(unsigned char *pd, unsigned char c); 36 | 37 | //const char *rom_strchr(const char * ps, char c); 38 | //char * ets_strrchr(const char *string, int c); 39 | 40 | typedef struct t_eraminfo // описание свободной области в iram 41 | { 42 | uint32 *base; // адрес начала буфера 43 | int32 size; // размер в байтах 44 | }ERAMInfo; 45 | 46 | /* описание свободной области (буфера) в iram */ 47 | extern ERAMInfo eraminfo; 48 | /* Определение размера свободного буфера в IRAM и очистка BSS IRAM (сегмент DATA_IRAM_ATTR) */ 49 | int iram_buf_init(void); 50 | 51 | #endif /* _INCLUDE_ROM2RAM_H_ */ 52 | -------------------------------------------------------------------------------- /include/sdk/sdk_config.h: -------------------------------------------------------------------------------- 1 | #ifndef _sdk_config_h_ 2 | #define _sdk_config_h_ 3 | 4 | #define DEF_SDK_VERSION 1520 // 1302 // ver 1.3.0 + patch (lib_1.3.0_deep_sleep_plus_freq_offset_plus_freedom_callback_02.zip SDK ver: 1.3.0 compiled @ Aug 19 2015 17:50:07) 5 | #define SDK_VERSION_TXT "1.5.2" 6 | 7 | #define DEFAULT_SOFTAP_IP 0x0104A8C0 // ip 192.168.4.1 8 | #define DEFAULT_SOFTAP_MASK 0x00FFFFFF // mask 255.255.255.0 9 | 10 | #define DEBUGSOO 2 // 0 - откл вывода, 1 - минимум, 2 - норма, >3 - текушая отладка, >4 - удалить что найдется :) 11 | 12 | #define DEBUG_UART 1 // включить вывод в загрузчике сообщений, номер UART 13 | #define DEBUG_UART0_BAUD 115200 14 | #define DEBUG_UART1_BAUD 230400 15 | 16 | #define STARTUP_CPU_CLK 160 17 | 18 | #ifndef ICACHE_FLASH // (назначается в MakeFile -DICACHE_FLASH) 19 | #define ICACHE_FLASH 20 | // #define ICACHE_FLASH_ATTR __attribute__((section(".irom0.text"))) 21 | // #define ICACHE_RODATA_ATTR __attribute__((aligned(4), section(".irom.text"))) 22 | #endif 23 | 24 | // #define USE_OPEN_LWIP 140 // использовать OpenLwIP 1.4.0 (назначается в app/MakeFile #USE_OPEN_LWIP = 140) 25 | // #define USE_OPEN_DHCPS 1 // использовать исходник или либу из SDK (назначается в app/MakeFile #USE_OPEN_DHCP = 1) 26 | 27 | #ifndef USE_MAX_IRAM 28 | // #define USE_MAX_IRAM 48 // использовать часть cache под IRAM, IRAM size = 49152 байт 29 | #define USE_MAX_IRAM 32 // использовать часть IRAM под переменные LWIP (uint32_t only!) 30 | #endif 31 | 32 | /* USE_FIX_QSPI_FLASH - использовать фиксированную частоту работы QPI 33 | и 'песочницу' в 512 кбайт для SDK с flash 34 | Опции: 35 | 80 - 80 MHz QSPI 36 | другое значение - 40 MHz QSPI */ 37 | // #define USE_FIX_QSPI_FLASH 80 // назначается в MakeFile -DUSE_FIX_QSPI_FLASH=$(SPI_SPEED) 38 | 39 | #ifdef USE_FIX_QSPI_FLASH 40 | #define USE_FIX_SDK_FLASH_SIZE 41 | #endif 42 | 43 | //#define USE_READ_ALIGN_ISR // побайтный доступ к IRAM и cache Flash через EXCCAUSE_LOAD_STORE_ERROR 44 | 45 | //#define USE_OVERLAP_MODE // используются две и более flash 46 | 47 | #ifndef USE_OPTIMIZE_PRINTF 48 | #define USE_OPTIMIZE_PRINTF 49 | #endif 50 | 51 | #ifndef USE_US_TIMER 52 | #define USE_US_TIMER 53 | #endif 54 | 55 | //#define USE_TIMER0 // использовать аппаратный таймер 0 (NMI или стандартное прерывание) 56 | //#define TIMER0_USE_NMI_VECTOR // использовать NMI вектор для таймера 0 (перенаправление таблицы векторов CPU) (см main-vectors.c) 57 | 58 | //#define USE_ETS_RUN_NEW // использовать ets_run_new() вместо ets_run() 59 | 60 | //------------------------------------------------------------------------------ 61 | /* LwIP Options */ 62 | 63 | #ifndef LWIP_OPEN_SRC // (назначается в MakeFile -DLWIP_OPEN_SRC) 64 | #define LWIP_OPEN_SRC 65 | #endif 66 | 67 | #ifndef PBUF_RSV_FOR_WLAN // (назначается в MakeFile -DPBUF_RSV_FOR_WLAN) 68 | #define PBUF_RSV_FOR_WLAN 69 | #endif 70 | #ifndef EBUF_LWIP // (назначается в MakeFile -DEBUF_LWIP) 71 | #define EBUF_LWIP 72 | #endif 73 | //------------------------------------------------------------------------------ 74 | #ifdef USE_ETS_RUN_NEW 75 | #define ets_run ets_run_new 76 | #endif 77 | 78 | #endif // _sdk_config_h_ 79 | 80 | 81 | -------------------------------------------------------------------------------- /include/sdk/wdt.h: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: wdt.h 3 | * Description: Alternate SDK (libmain.a) 4 | * Author: PV` 5 | * (c) PV` 2015 6 | * ver 0.0.0 (b0) 7 | *******************************************************************************/ 8 | 9 | #ifndef _INCLUDE_WDT_H_ 10 | #define _INCLUDE_WDT_H_ 11 | 12 | #include "ets_sys.h" 13 | #include "sdk/fatal_errs.h" 14 | 15 | #if DEF_SDK_VERSION >= 1119 // (SDK 1.1.1..1.1.2) 16 | void wdt_init(int flg) ICACHE_FLASH_ATTR; 17 | #else 18 | void wdt_init(void) ICACHE_FLASH_ATTR; 19 | void wdt_feed(void); 20 | void wdt_task(ETSEvent *e); 21 | #endif 22 | 23 | // #define DEBUG_EXCEPTION // для отладки 24 | 25 | #ifdef DEBUG_EXCEPTION 26 | struct exception_frame 27 | { 28 | uint32 epc; 29 | uint32 ps; 30 | uint32 sar; 31 | uint32 unused; 32 | union { 33 | struct { 34 | uint32 a0; 35 | // note: no a1 here! 36 | uint32 a2; 37 | uint32 a3; 38 | uint32 a4; 39 | uint32 a5; 40 | uint32 a6; 41 | uint32 a7; 42 | uint32 a8; 43 | uint32 a9; 44 | uint32 a10; 45 | uint32 a11; 46 | uint32 a12; 47 | uint32 a13; 48 | uint32 a14; 49 | uint32 a15; 50 | }; 51 | uint32 a_reg[15]; 52 | }; 53 | uint32 cause; 54 | }; 55 | void default_exception_handler(struct exception_frame *ef, uint32 cause); 56 | #else 57 | void default_exception_handler(void); 58 | #endif 59 | 60 | void store_exception_error(uint32 errn); 61 | 62 | void os_print_reset_error(void) ICACHE_FLASH_ATTR; 63 | 64 | 65 | #endif /* _INCLUDE_WDT_H_ */ 66 | -------------------------------------------------------------------------------- /include/user_config.h: -------------------------------------------------------------------------------- 1 | #ifndef _user_config_h_ 2 | #define _user_config_h_ 3 | 4 | #include "sdk/sdk_config.h" 5 | 6 | #define SYS_VERSION "0.0.0" 7 | 8 | //~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ 9 | 10 | #endif // _user_config_h_ 11 | 12 | 13 | -------------------------------------------------------------------------------- /info/ESP8266_reg/ESP8266_Pin_List_141105.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/info/ESP8266_reg/ESP8266_Pin_List_141105.xlsx -------------------------------------------------------------------------------- /info/ESP8266_reg/ESP8266_RF_init_esp_init_data_default_bin.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/info/ESP8266_reg/ESP8266_RF_init_esp_init_data_default_bin.xlsx -------------------------------------------------------------------------------- /info/ESP8266_reg/gpio_reg.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/info/ESP8266_reg/gpio_reg.xlsx -------------------------------------------------------------------------------- /info/ESP8266_reg/pin_reg.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/info/ESP8266_reg/pin_reg.xlsx -------------------------------------------------------------------------------- /info/ESP8266_reg/spi_reg.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/info/ESP8266_reg/spi_reg.xlsx -------------------------------------------------------------------------------- /info/ESP8266_reg/timers_reg.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/info/ESP8266_reg/timers_reg.xlsx -------------------------------------------------------------------------------- /info/ESP8266_reg/uart_reg.xlsx: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/info/ESP8266_reg/uart_reg.xlsx -------------------------------------------------------------------------------- /info/libs/bios/ets_run.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: ets_run.c 3 | * Description: Alternate SDK 4 | * Author: PV` 5 | * (c) PV` 2015 6 | *******************************************************************************/ 7 | #include "user_config.h" 8 | #include "bios.h" 9 | #include "hw/esp8266.h" 10 | 11 | typedef void (* tfunc_tsk)(void *); 12 | typedef struct _sargc_tsk 13 | { 14 | uint32 x1; 15 | uint32 x2; 16 | }sargc_tsk; 17 | 18 | typedef struct _ss_task{ 19 | tfunc_tsk func; //+0 20 | sargc_tsk * argc; //+4 21 | uint8 size; //+8 22 | uint8 ch_09; //+9 23 | uint8 cnts; //+10 24 | uint8 cnte; //+11 25 | uint32 bitn; //+12 26 | }ss_task; 27 | 28 | // RAM_BIOS:3FFFC6FC вписать в eagle.rom.addr.v6.ld 29 | extern uint8 ets_bit_task_priority; 30 | // RAM_BIOS:3FFFDAB0 вписать в eagle.rom.addr.v6.ld 31 | extern tfunc_tsk ets_idle_cb; 32 | // RAM_BIOS:3FFFDAB4 вписать в eagle.rom.addr.v6.ld 33 | extern void * ets_idle_arg; 34 | // RAM_BIOS:3FFFDAB8 вписать в eagle.rom.addr.v6.ld 35 | extern uint32 ets_bit_count_task; 36 | // RAM_BIOS:3FFFDAC0 вписать в eagle.rom.addr.v6.ld 37 | extern ss_task ets_tab_task[32]; // 512 байт 32x16 38 | 39 | 40 | void ets_run(void) 41 | { 42 | uint8 bnum; 43 | uint8 bctp = ets_bit_task_priority = 0; // для вызова с назначенным приоритетом 44 | while(1) { 45 | while(1) { 46 | ets_intr_lock(); 47 | bnum = ets_bit_count_task; 48 | asm volatile ("nsau %0, %1;" :"=r"(bnum) : "r"(bnum)); // Normalization Shift Amount Unsigned 49 | bnum = 32 - bnum; 50 | if(bctp < bnum) break; 51 | if(ets_idle_cb != NULL) ets_idle_cb(ets_idle_arg); 52 | asm volatile ("waiti 0;"); // Wait for Interrupt 53 | ets_intr_unlock(); 54 | }; 55 | ss_task * cur_task = &ets_tab_task[bnum-1]; 56 | sargc_tsk * argc = &cur_task->argc[cur_task->cnts++]; 57 | if(cur_task->size == cur_task->cnts) cur_task->cnts = 0; 58 | if(--cur_task->cnte == 0) { 59 | ets_bit_count_task &= ~cur_task->bitn; 60 | } 61 | ets_bit_task_priority = bnum; 62 | ets_intr_unlock(); 63 | cur_task->func(argc); 64 | ets_bit_task_priority = bctp; 65 | }; 66 | } 67 | 68 | -------------------------------------------------------------------------------- /info/libs/bios/gpio.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: gpio.c 3 | * Description: gpio funcs in ROM-BIOS 4 | * Alternate SDK ver 0.0.0 (b1) 5 | * Author: PV` 6 | * (c) PV` 2015 7 | *******************************************************************************/ 8 | #include "c_types.h" 9 | #include "bios.h" 10 | #include "hw/esp8266.h" 11 | 12 | // ROM:40004D90 13 | void gpio_pin_intr_state_set(uint32 i, GPIO_INT_TYPE intr_state) 14 | { 15 | ets_intr_lock(); 16 | volatile uint32 * gpio_pinx = &GPIO_PIN0; 17 | uint32 x = gpio_pinx[i] & 0xC7F; 18 | gpio_pinx[i] = x | intr_state << 7; 19 | ets_intr_unlock(); 20 | } 21 | -------------------------------------------------------------------------------- /info/libs/bios/mem.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: mem.c 3 | * Description: mem funcs in ROM-BIOS 4 | * Alternate SDK ver 0.0.0 (b0) 5 | * Author: PV` 6 | * (c) PV` 2015 7 | *******************************************************************************/ 8 | #include "c_types.h" 9 | #include "esp8266.h" 10 | 11 | struct _smem_ { // RAM_BIOS:3FFFDD30 12 | uint8 * x0; 13 | uint8 * x1; 14 | uint8 * x2; 15 | }_mem_; 16 | 17 | void mem_init(uint8 *a2) 18 | { 19 | uint8 * a4 = (a2 + 3) & 0xFFFFFFFC; 20 | a4[1] = 16; 21 | a4[2] = 0; 22 | a4[3] = 0; 23 | a4[4] = 0; 24 | uint8 * a7 = a4 + 0x1000; 25 | _mem_.x0 = a4; 26 | _mem_.x1 = a7; 27 | _mem_.x2 = a4; 28 | a4 += 0xf84; 29 | a4[124] = (uint8)a7; 30 | a4[125] = 16; 31 | a4[126] = (uint8)a7; 32 | a4[127] = 16; 33 | a4[128] = 1; 34 | } 35 | -------------------------------------------------------------------------------- /info/libs/bios/wdt.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: wdt.c 3 | * Description: wdt funcs in ROM-BIOS 4 | * Alternate SDK ver 0.0.1 5 | * Author: PV` 6 | * (c) PV` 2015 7 | *******************************************************************************/ 8 | #include "c_types.h" 9 | #include "bios.h" 10 | #include "hw/esp8266.h" 11 | 12 | // RAM_BIOS:3FFFC708 13 | struct swdt_info wdt_info; 14 | 15 | // RAM_BIOS:3FFFDDE0 16 | ETSTimer wdt_timer; 17 | 18 | // ROM:40002F34 19 | uint32_t ets_wdt_get_mode(void) 20 | { 21 | return wdt_info.wdt_mode; 22 | } 23 | 24 | // ROM:40002F14 25 | int _wdt_abcode(int b) 26 | { 27 | if(b == 3) return 11; 28 | if(b == 6) return 12; 29 | if(b == 12) return 13; 30 | return 0; 31 | } 32 | 33 | // ROM:40002FA0 34 | void ets_wdt_enable(int mode, uint32_t a, uint32_t b) 35 | { 36 | if(wdt_info.wdt_mode != 2) ets_isr_mask(0x100); 37 | wdt_info.a = a; 38 | wdt_info.b = b; 39 | WDT_CTRL &= 0x7E; // Disable WDT 40 | if(mode == 1) { 41 | ets_timer_setfn(wdt_timer, wdt_timer_proc, NULL); 42 | ets_timer_arm(wdt_timer, 10, 1); 43 | WDT_CTRL = 0x3C; 44 | WDT_REG1 = _wdt_abcode(b); 45 | WDT_CTRL |= 1; 46 | wdt_info.wdt_mode = mode; 47 | } 48 | else if(mode == 2 || mode == 4) { 49 | WDT_CTRL = 0x38; 50 | int x = _wdt_abcode(a); 51 | WDT_REG1 = x; 52 | WDT_REG2 = x; 53 | if(mode != 2) { 54 | WDT_CTRL |= 1; 55 | wdt_info.wdt_mode = mode; 56 | } 57 | else { 58 | ets_isr_unmask(0x100); 59 | WDT_CTRL |= 1; 60 | wdt_info.wdt_mode = mode; 61 | } 62 | } 63 | else if(mode == 3) { 64 | WDT_CTRL = 0x3C; 65 | WDT_REG1 = _wdt_abcode(a); 66 | WDT_CTRL |= 1; 67 | wdt_info.wdt_mode = mode; 68 | } 69 | else { 70 | WDT_CTRL |= 1; 71 | wdt_info.wdt_mode = mode; 72 | } 73 | } 74 | 75 | // ROM:40003158 76 | void ets_wdt_restore(int mode) 77 | { 78 | if(mode) ets_wdt_enable(mode, wdt_info.a, wdt_info.b); 79 | } 80 | 81 | 82 | // ROM:40002F3C 83 | void _wdt_timer_proc(void) 84 | { 85 | int mode = ets_wdt_get_mode(); 86 | if(mode == 1) { 87 | WDT_FEED = WDT_FEED_MAGIC; 88 | WDT_BASE[4]; // просто чтение 0x60000910 89 | } 90 | else if(mode == 2) { 91 | if(WDT_BASE[4] == 1) { 92 | WDT_BASE[6] = WDT_FEED_MAGIC; // 0x60000918 93 | WDT_FEED = WDT_FEED_MAGIC; 94 | } 95 | } 96 | } 97 | 98 | // ROM:400030F0 99 | int ets_wdt_disable(void) 100 | { 101 | WDT_CTRL &= 0x7E; 102 | WDT_FEED = WDT_FEED_MAGIC; 103 | int mode = ets_wdt_get_mode(); 104 | if(mode == 1) { 105 | ets_timer_disarm(wdt_timer); 106 | } 107 | else if(mode == 2) { 108 | ets_isr_mask(0x100); 109 | } 110 | return mode; 111 | } 112 | 113 | // ROM:40002F88 114 | void wdt_timer_proc(void) 115 | { 116 | _wdt_timer_proc(); 117 | } 118 | 119 | // ROM:40003170 120 | void ets_wdt_init(void) 121 | { 122 | WDT_CTRL &= 0xFFE; 123 | ets_isr_attach(8, wdt_timer_proc, 0); 124 | INTC_EDGE_EN |= 1; 125 | } 126 | 127 | -------------------------------------------------------------------------------- /info/libs/main/UserEnter.s: -------------------------------------------------------------------------------- 1 | 2 | .begin literal_prefix .UserEnter 3 | .section .UserEnter.text, "ax" 4 | 5 | .align 4 6 | .global call_user_start 7 | 8 | call_user_start: 9 | movi a2, 0x401 10 | slli a2, a2, 20 11 | wsr.vecbase a2 12 | j call_user_start1 13 | 14 | // .size call_user_start, . - call_user_start 15 | 16 | .end literal_prefix 17 | 18 | 19 | 20 | -------------------------------------------------------------------------------- /info/libs/main/debug-vector.s: -------------------------------------------------------------------------------- 1 | // This code goes at the debug exception vector 2 | 3 | .begin literal_prefix .DebugExceptionVector 4 | .section .DebugExceptionVector.text, "ax" 5 | 6 | .align 4 7 | .global _DebugExceptionVector 8 | 9 | _DebugExceptionVector: 10 | 11 | 1: waiti 2 // XCHAL_DEBUGLEVEL // unexpected debug exception, loop in low-power mode 12 | j 1b // infinite loop - unexpected debug exception 13 | 14 | .global pNmiFunc 15 | .align 4 16 | 17 | pNmiFunc: .word 0 18 | 19 | .size _DebugExceptionVector, . - _DebugExceptionVector 20 | 21 | .end literal_prefix 22 | 23 | 24 | 25 | -------------------------------------------------------------------------------- /info/libs/main/double-vector.s: -------------------------------------------------------------------------------- 1 | 2 | .begin literal_prefix .DoubleExceptionVector 3 | .section .DoubleExceptionVector.text, "ax" 4 | 5 | .align 4 6 | .global _DoubleExceptionVector 7 | 8 | _DoubleExceptionVector: 9 | 10 | 1: break 1,4 11 | j 1b 12 | 13 | .size _DoubleExceptionVector, . - _DoubleExceptionVector 14 | 15 | .end literal_prefix 16 | 17 | 18 | 19 | -------------------------------------------------------------------------------- /info/libs/main/kernel-vector.s: -------------------------------------------------------------------------------- 1 | 2 | .begin literal_prefix .KernelExceptionVector 3 | .section .KernelExceptionVector.text, "ax" 4 | 5 | .align 4 6 | .global _KernelExceptionVector 7 | 8 | _KernelExceptionVector: 9 | 10 | 1: break 1,0 // unexpected kernel exception 11 | j 1b // infinite loop - unexpected kernel exception 12 | 13 | .align 4 14 | .global puev_store_regs 15 | 16 | puev_store_regs: .word 0x3FFFC000 17 | 18 | .size _KernelExceptionVector, . - _KernelExceptionVector 19 | 20 | .end literal_prefix 21 | 22 | 23 | 24 | -------------------------------------------------------------------------------- /info/libs/main/nmi-vector.s: -------------------------------------------------------------------------------- 1 | // The NMI exception vector handles non-maskable interrupts. 2 | 3 | .begin literal_prefix .NMIExceptionVector 4 | .section .NMIExceptionVector.text, "ax" 5 | 6 | .align 4 7 | .global _NMIExceptionVector 8 | 9 | _NMIExceptionVector: 10 | 11 | // rfi 3 12 | wsr.excsave3 a0 // wsr a0, EXCSAVE+XCHAL_NMILEVEL 13 | call0 _NMILevelVector 14 | 15 | .size _NMIExceptionVector, . - _NMIExceptionVector 16 | 17 | .end literal_prefix 18 | 19 | .begin literal_prefix .NMILevelVector 20 | .section .NMILevelVector.text, "ax" 21 | 22 | .align 4 23 | .global _NMILevelVector 24 | 25 | _NMILevelVector: 26 | l32r a0, _store_regs 27 | s32i.n a2, a0, 40 28 | l32r a2, _xxx_a 29 | s32i.n a1, a0, 36 30 | l32i.n a2, a2, 0 31 | s32i.n a3, a0, 44 32 | xsr.excsave3 a2 33 | s32i.n a4, a0, 48 34 | s32i.n a2, a0, 32 35 | rsr.epc1 a3 36 | rsr.exccause a4 37 | s32i.n a3, a0, 12 38 | s32i.n a4, a0, 16 39 | rsr.excvaddr a3 40 | s32i.n a3, a0, 20 41 | rsr.excsave1 a4 42 | s32i.n a4, a0, 24 43 | s32i.n a5, a0, 52 44 | s32i.n a6, a0, 56 45 | s32i.n a7, a0, 60 46 | s32i a8, a0, 64 47 | s32i a9, a0, 68 48 | s32i a10, a0, 72 49 | s32i a11, a0, 76 50 | s32i a12, a0, 80 51 | s32i a13, a0, 84 52 | s32i a14, a0, 88 53 | s32i a15, a0, 92 54 | l32r a1, _store_regs 55 | movi.n a0, 0 56 | movi.n a2, 35 57 | wsr.ps a2 58 | rsync 59 | rsr.sar a14 60 | s32i.n a14, a1, 0 61 | l32r a13, pNmiFunc 62 | callx0 a13 63 | l32i.n a15, a1, 0 64 | wsr.sar a15 65 | movi.n a2, 51 66 | wsr.ps a2 67 | rsync 68 | l32i.n a4, a1, 48 69 | l32i.n a5, a1, 52 70 | l32i.n a6, a1, 56 71 | l32i.n a7, a1, 60 72 | l32i a8, a1, 64 73 | l32i a9, a1, 68 74 | l32i a10, a1, 72 75 | l32i a11, a1, 76 76 | l32i a12, a1, 80 77 | l32i a13, a1, 84 78 | l32i a14, a1, 88 79 | l32i a15, a1, 92 80 | l32i.n a2, a1, 12 81 | l32i.n a3, a1, 16 82 | wsr.epc1 a2 83 | wsr.exccause a3 84 | l32i.n a2, a1, 20 85 | wsr.excvaddr a2 86 | l32i.n a3, a1, 24 87 | wsr.excsave1 a3 88 | l32i.n a0, a1, 32 89 | rsr.sar a3 90 | l32r a2, p_dport_ 91 | movi a2, 0x3ff 92 | slli a2, a2, 20 93 | wsr.sar a3 94 | movi.n a3, 15 95 | s32i.n a3, a2, 0 96 | l32i.n a2, a1, 40 97 | l32i.n a3, a1, 44 98 | l32i.n a1, a1, 36 99 | rfi 3 100 | 101 | -------------------------------------------------------------------------------- /info/libs/main/user-vector.s: -------------------------------------------------------------------------------- 1 | // Vector code 2 | .begin literal_prefix .UserExceptionVector 3 | .section .UserExceptionVector.text, "ax" 4 | 5 | .align 4 6 | .global _UserExceptionVector 7 | 8 | _UserExceptionVector: 9 | 10 | // wsr.excsave1 a0 11 | addmi a1, a1, -0x100 12 | s32i.n a2, a1, 0x14 13 | s32i.n a3, a1, 0x18 14 | l32r a3, puev_store_regs 15 | rsr.exccause a2 16 | addx4 a3, a2, a3 17 | l32i.n a3, a3, 0 18 | s32i.n a4, a1, 0x1C 19 | jx a3 20 | 21 | .end literal_prefix 22 | 23 | -------------------------------------------------------------------------------- /info/libs/net80211/Descript.ion: -------------------------------------------------------------------------------- 1 | net80211 https://github.com/freebsd/freebsd/tree/master/sys/net80211 2 | -------------------------------------------------------------------------------- /info/libs/net80211/ieee80211_output.h: -------------------------------------------------------------------------------- 1 | /* 2 | https://github.com/freebsd/freebsd/blob/master/sys/net80211/ieee80211_proto.h 3 | https://github.com/freebsd/freebsd/blob/master/sys/net80211/ieee80211_output.c 4 | */ 5 | 6 | 7 | struct ieee80211vap; 8 | 9 | 10 | ieee80211_output_pbuf ?? 11 | ieee80211_tx_mgt_cb ?? 12 | 13 | void ieee80211_send_setup(struct ieee80211_node *, struct mbuf *, int, int, 14 | const uint8_t [IEEE80211_ADDR_LEN], const uint8_t [IEEE80211_ADDR_LEN], 15 | const uint8_t [IEEE80211_ADDR_LEN]); 16 | int ieee80211_mgmt_output(struct ieee80211_node *, struct mbuf *, int, 17 | struct ieee80211_bpf_params *); 18 | 19 | int ieee80211_send_nulldata(struct ieee80211_node *); 20 | 21 | uint8_t *ieee80211_add_rates(uint8_t *, const struct ieee80211_rateset *); 22 | uint8_t *ieee80211_add_xrates(uint8_t *, const struct ieee80211_rateset *); 23 | 24 | int ieee80211_send_probereq(struct ieee80211_node *ni, 25 | const uint8_t sa[IEEE80211_ADDR_LEN], 26 | const uint8_t da[IEEE80211_ADDR_LEN], 27 | const uint8_t bssid[IEEE80211_ADDR_LEN], 28 | const uint8_t *ssid, size_t ssidlen); 29 | 30 | uint16_t ieee80211_getcapinfo(struct ieee80211vap *, 31 | struct ieee80211_channel *); 32 | 33 | int ieee80211_send_mgmt(struct ieee80211_node *, int, int); 34 | 35 | struct mbuf *ieee80211_alloc_proberesp(struct ieee80211_node *, int); 36 | 37 | int ieee80211_send_proberesp(struct ieee80211vap *, 38 | const uint8_t da[IEEE80211_ADDR_LEN], int); 39 | 40 | /* 41 | * Beacon frames constructed by ieee80211_beacon_alloc 42 | * have the following structure filled in so drivers 43 | * can update the frame later w/ minimal overhead. 44 | */ 45 | struct ieee80211_beacon_offsets { 46 | uint8_t bo_flags[4]; /* update/state flags */ 47 | uint16_t *bo_caps; /* capabilities */ 48 | uint8_t *bo_cfp; /* start of CFParms element */ 49 | uint8_t *bo_tim; /* start of atim/dtim */ 50 | uint8_t *bo_wme; /* start of WME parameters */ 51 | uint8_t *bo_tdma; /* start of TDMA parameters */ 52 | uint8_t *bo_tim_trailer;/* start of fixed-size trailer */ 53 | uint16_t bo_tim_len; /* atim/dtim length in bytes */ 54 | uint16_t bo_tim_trailer_len;/* tim trailer length in bytes */ 55 | uint8_t *bo_erp; /* start of ERP element */ 56 | uint8_t *bo_htinfo; /* start of HT info element */ 57 | uint8_t *bo_ath; /* start of ATH parameters */ 58 | uint8_t *bo_appie; /* start of AppIE element */ 59 | uint16_t bo_appie_len; /* AppIE length in bytes */ 60 | uint16_t bo_csa_trailer_len; 61 | uint8_t *bo_csa; /* start of CSA element */ 62 | uint8_t *bo_quiet; /* start of Quiet element */ 63 | uint8_t *bo_meshconf; /* start of MESHCONF element */ 64 | uint8_t *bo_spare[3]; 65 | }; 66 | struct mbuf *ieee80211_beacon_alloc(struct ieee80211_node *, 67 | struct ieee80211_beacon_offsets *); 68 | -------------------------------------------------------------------------------- /info/libs/phy/phy.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: phy.c 3 | * Description: Reverse SDK 1.0.0 (libphy.a) 4 | * Author: PV` 5 | *******************************************************************************/ 6 | #include "user_config.h" 7 | #include "os_type.h" 8 | #include "hw/esp8266.h" 9 | #include "phy/phy.h" 10 | 11 | 12 | struct phy_funcs * ptr_phy; // off_3FFEA990 13 | 14 | // used register_chipv6_phy() 15 | void ICACHE_FLASH_ATTR register_phy_ops(struct phy_funcs * phy_base) 16 | { 17 | ptr_phy = phy_base; 18 | phy_init(1, 0); 19 | } 20 | 21 | extern void chip_v6_initialize_bb(int); 22 | extern int chip_v6_rf_init(int ch, int n); 23 | 24 | void ICACHE_FLASH_ATTR phy_init(int8 ch, int n) //(int8 ch, b)??? 25 | { 26 | // ptr_phy->rf_init(ch, n); 27 | // ptr_phy->initialize_bb(n); 28 | 29 | chip_v6_rf_init(ch, n); 30 | chip_v6_initialize_bb(n); 31 | } 32 | 33 | // used register_chipv6_phy() (reduce_current_init()) 34 | void ICACHE_FLASH_ATTR register_get_phy_addr(struct phy_funcs * ptrf) 35 | { 36 | ptr_phy = ptrf; 37 | } 38 | 39 | // used chm_set_current_channel() 40 | int phy_change_channel(int chfr) 41 | { 42 | // ptr_phy->set_chanfreq(chfr); 43 | chip_v6_set_chanfreq(chfr); 44 | return 0; 45 | } 46 | 47 | #if 0 48 | // not used 49 | uint32 phy_get_mactime(void) 50 | { 51 | MEMW(); 52 | return IOREG(0x3FF20C00); // phy_mactime 53 | } 54 | #endif 55 | 56 | /* в phy_chip_v6.o 57 | extern void chip_v6_set_chan(int frch); 58 | int ICACHE_FLASH_ATTR chip_v6_set_chanfreq(uint32 chfr) 59 | { 60 | chip_v6_set_chan(g_phyFuns->mhz2ieee(chfr, 0x80)); // chip_v6_set_chan(rom_mhz2ieee(x, 0x80)) 61 | return 0; 62 | } 63 | */ 64 | 65 | #if 0 66 | // used slop_test() 67 | void ICACHE_FLASH_ATTR RFChannelSel(int8 ch) 68 | { 69 | ptr_phy->set_chan(ch); 70 | } 71 | 72 | // not used 73 | void ICACHE_FLASH_ATTR phy_delete_channel(void) 74 | { 75 | ptr_phy->unset_chanfreq(); 76 | } 77 | #endif 78 | 79 | extern void rom_chip_v5_enable_cca(void); 80 | extern void rom_chip_v5_disable_cca(void); 81 | // used init_wifi() 82 | void ICACHE_FLASH_ATTR phy_enable_agc(void) 83 | { 84 | // MEMW(); 85 | // IOREG(0x60009B00) &= ~0x10000000; 86 | // ptr_phy->enable_cca(); 87 | rom_chip_v5_enable_cca(); 88 | } 89 | 90 | // used init_wifi() 91 | void ICACHE_FLASH_ATTR phy_disable_agc(void) 92 | { 93 | // IOREG(0x60009B00) |= 0x10000000; 94 | // ptr_phy->disable_cca(); 95 | rom_chip_v5_disable_cca(); 96 | } 97 | 98 | #if 0 99 | // not used 100 | void ICACHE_FLASH_ATTR phy_initialize_bb(int n) 101 | { 102 | ptr_phy->initialize_bb(n); 103 | } 104 | 105 | // not used 106 | void ICACHE_FLASH_ATTR phy_set_sense(void) 107 | { 108 | ptr_phy->set_sense(); 109 | } 110 | 111 | void bb_init(void ) 112 | { 113 | ptr_phy->initialize_bb(); 114 | } 115 | 116 | void rf_init(int8 ch) 117 | { 118 | ptr_phy->rf_init(ch); 119 | } 120 | #endif 121 | 122 | void phy_set_powerup_option(int option) 123 | { 124 | IO_RTC_POWERUP = option; // 0x6000073C = option 125 | } 126 | -------------------------------------------------------------------------------- /info/libs/phy/phy_get_vdd33.c: -------------------------------------------------------------------------------- 1 | /* 2 | * phy_get_vdd33.c 3 | * 4 | * Created on: 08 сент. 2015 г. 5 | * Author: PVV 6 | */ 7 | 8 | #include "user_config.h" 9 | #include "bios.h" 10 | #include "hw/esp8266.h" 11 | #include "sys_const.h" 12 | 13 | #define i2c_saradc 0x6C // 108 14 | #define i2c_saradc_hostid 2 15 | #define i2c_saradc_en_test 0 16 | #define i2c_saradc_en_test_msb 5 17 | #define i2c_saradc_en_test_lsb 5 18 | 19 | #define i2c_writeReg_Mask(block, host_id, reg_add, Msb, Lsb, indata) \ 20 | rom_i2c_writeReg_Mask(block, host_id, reg_add, Msb, Lsb, indata) 21 | 22 | #define i2c_readReg_Mask(block, host_id, reg_add, Msb, Lsb) \ 23 | rom_i2c_readReg_Mask(block, host_id, reg_add, Msb, Lsb) 24 | 25 | #define i2c_writeReg_Mask_def(block, reg_add, indata) \ 26 | i2c_writeReg_Mask(block, block##_hostid, reg_add, reg_add##_msb, reg_add##_lsb, indata) 27 | 28 | #define i2c_readReg_Mask_def(block, reg_add) \ 29 | i2c_readReg_Mask(block, block##_hostid, reg_add, reg_add##_msb, reg_add##_lsb) 30 | 31 | 32 | extern uint8 sleep_mode_flag; 33 | 34 | void read_sar_dout(uint16 * buf) 35 | { 36 | volatile uint32 * sar_regs = &SAR_BASE[32]; // 8 шт. с адреса 0x60000D80 37 | int i; 38 | for(i = 0; i < 8; i++) { 39 | int x = ~(*sar_regs++); 40 | int z = (x & 0xFF) - 21; 41 | x &= 0x700; 42 | if(z > 0) x = ((z * 279) >> 8) + x; 43 | buf[i] = x; 44 | } 45 | } 46 | 47 | int readvdd33(int flg) 48 | { 49 | uint16 sardata[8], sar_out = 0; 50 | if(flg) { 51 | HDRF_BASE[37] |= 1; // 0x60000594 |= 1; 52 | } 53 | int pb6_1 = pbus_rd(6,1); // g_phyFuns->pbus_rd(6,1); 54 | int r107 = i2c_readReg_Mask(107, 2, 9, 2, 0); // g_phyFuns->i2c_readReg_Mask(107, 2, 9, 2, 0); 55 | int r108 = i2c_readReg_Mask(108, 2, 0, 5, 5); // g_phyFuns->i2c_readReg_Mask(108, 2, 0, 5, 5); 56 | pbus_force_test(6, 1, 2 | pb6_1); // g_phyFuns->pbus_force_test(6, 1, (2 | pb6_1) & 0xffff ); 57 | i2c_writeReg_Mask(107, 2, 9, 7, 7, 1); // g_phyFuns->i2c_writeReg_Mask(107, 2, 9, 7, 7, 1) 58 | i2c_writeReg_Mask(107, 2, 9, 2, 0, 0); // g_phyFuns->i2c_writeReg_Mask(107, 2, 9, 2, 0, 0) 59 | i2c_writeReg_Mask_def(i2c_saradc, i2c_saradc_en_test, 1); // g_phyFuns->i2c_writeReg_Mask(i2c_saradc, 2, 0, 5, 5, 1); 60 | SAR_BASE[23] |= 1<<23; // 0x60000D5C |= 0x800000 61 | SAR_BASE[23] &= ~(1<<21); // 0x60000D5C &= 0xFFDFFFFF 62 | if((SAR_BASE[20]>>24)&0xFF) while((SAR_BASE[20]>>24)&0x7); // 0x60000D50 63 | SAR_BASE[20] &= 0xFFD; // 0x60000D50 &= 0xFFD 64 | SAR_BASE[20] |= 1<<1; // 0x60000D50 |= 2 65 | ets_delay_us(25); 66 | read_sar_dout(sardata); 67 | int i; 68 | for(i = 0; i < 8; i++) sar_out += sardata[i]; 69 | pbus_force_test(6, 1, pb6_1); 70 | i2c_writeReg_Mask(107, 2, 9, 2, 0, r107); 71 | i2c_writeReg_Mask_def(i2c_saradc, i2c_saradc_en_test, r108); // i2c_writeReg_Mask(108, 2, 0, 5, 5, r108); 72 | if(flg) { 73 | HDRF_BASE[37] &= 0x7E; // 0x60000594 &= 0x7E 74 | } 75 | sar_out <<= 10; 76 | sar_out += 0x800; 77 | return ((sar_out >> 12) & 0xFFFF); 78 | } 79 | 80 | int phy_get_vdd33(void) 81 | { 82 | int vdd33 = 0xFFFF; 83 | if(sleep_mode_flag == 0) pm_set_sleep_mode(4); 84 | if(chip6_phy_init_ctrl[108] == 0xff) { 85 | vdd33 = readvdd33(1); 86 | } 87 | while((SAR_BASE[20]>>24)&0x7); // 0x60000D50 88 | SAR_BASE[23] &= ~(1<<21); // 0x60000D5C 89 | SAR_BASE[23] &= ~(1<<23); 90 | SAR_BASE[24] &= 0xFFE; // 0x60000D60 91 | SAR_BASE[24] |= 0x001; 92 | if(sleep_mode_flag == 0) { 93 | pm_wakeup_init(4,0); 94 | } 95 | return vdd33; 96 | } 97 | 98 | uint16 system_get_vdd33(void) 99 | { 100 | return phy_get_vdd33() & 0x3FF; 101 | } 102 | 103 | 104 | 105 | -------------------------------------------------------------------------------- /info/libs/phy/phy_sleep.c: -------------------------------------------------------------------------------- 1 | /****************************************************************************** 2 | * FileName: phy_sleep.c 3 | * Description: Alternate SDK (libphy.a) 4 | * Author: PV` 5 | * (c) PV` 2015 6 | *******************************************************************************/ 7 | 8 | #include "user_config.h" 9 | #include "bios.h" 10 | #include "hw/esp8266.h" 11 | #include "phy/phy.h" 12 | 13 | // pm_rtc_clock_cali() 14 | // clockgate_watchdog() 15 | // pm_usec2rtc() 16 | // pm_rtc2usec() 17 | //+ pm_set_sleep_cycles() 18 | // pm_sleep_opt() 19 | // pm_wakeup_opt() 20 | // get_chip_version() 21 | // pm_sleep_opt_bb_off() 22 | // pm_sleep_opt_bb_on() 23 | // pm_set_pll_xtal_wait_time() 24 | // pm_prepare_to_sleep() 25 | // pm_sdio_nidle() 26 | // chg_lslp_mem_opt_8266() 27 | // pm_goto_sleep() 28 | //+ pm_wait4wakeup() 29 | // pm_open_rf() 30 | // pm_sleep_set_mac() 31 | // pm_set_wakeup_mac() 32 | // pm_check_mac_idle() 33 | // pm_set_sleep_btco() 34 | // pm_set_wakeup_btco() 35 | // pm_set_sleep_mode() 36 | // pm_unmask_bt() 37 | //+ pm_wakeup_init() 38 | // sleep_opt_8266() 39 | // sleep_opt_bb_on_8266() 40 | // sleep_reset_analog_rtcreg_8266() 41 | 42 | 43 | extern uint32 chip6_sleep_params; 44 | 45 | void ICACHE_FLASH_ATTR pm_set_sleep_cycles(uint32 x) 46 | { 47 | RTC_BASE[1] = x + RTC_BASE[7]; 48 | if(x <= 5000) x = 1; 49 | else x = 0; 50 | periodic_cal_sat = x; 51 | } 52 | 53 | void ICACHE_FLASH_ATTR pm_wakeup_opt(uint32 a2, uint32 a3) 54 | { 55 | RTC_BASE[0x18>>2] = (RTC_BASE[0x18>>2] & 0xFC0) | a2; 56 | RTC_BASE[0xA8>>2] = (RTC_BASE[0xA8>>2] & 0x7E) | a3; 57 | } 58 | 59 | extern uint8 software_slp_reject; 60 | extern uint8 hardware_reject; 61 | 62 | void ICACHE_FLASH_ATTR pm_wait4wakeup(uint32 a2) 63 | { 64 | if((a2 == 1 || a2 == 2) && (software_slp_reject == 0)) { 65 | while((RTC_BASE[0x28>>2] & 3) == 0); 66 | hardware_reject = RTC_BASE[0x28>>2] & 2; 67 | } 68 | } 69 | 70 | void pm_prepare_to_sleep(void) 71 | { 72 | if(chip6_phy_init_ctrl[57] != 2 && chip6_phy_init_ctrl[58] != 1 && chip6_phy_init_ctrl[58] != 3) { 73 | GPIO16_FUN = 2; // 0x600007A0 = 2 74 | } 75 | } 76 | 77 | 78 | 79 | 80 | 81 | -------------------------------------------------------------------------------- /lib/clibsdk.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | @if not %1x==x goto aaa 3 | if exist ..\CreateLib\MinEspSDKLib.lib cd ..\CreateLib 4 | if exist ..\AutoMake\MinEspSDKLib.lib cd ..\AutoMake 5 | call ..\lib\clibsdk.bat MinEspSDKLib.lib 6 | cd ..\lib 7 | goto end 8 | :aaa 9 | if not exist %1 goto err_end 10 | if not exist ..\lib\libmmain.a goto err_end 11 | if not exist ..\lib\libmphy.a goto err_end 12 | if not exist ..\lib\libmwpa.a goto err_end 13 | if not exist ..\lib\libnet80211.a goto err_end 14 | if not exist ..\lib\libpp.a goto err_end 15 | if not exist ..\lib\libmgcc.a goto err_end 16 | if not exist ..\lib\libcrypto.a goto err_end 17 | if not exist _temp md _temp 18 | cd _temp 19 | c:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar xo ..\%1 20 | c:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar xo ..\..\lib\libmmain.a 21 | c:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar xo ..\..\lib\libmphy.a 22 | c:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar xo ..\..\lib\libmwpa.a 23 | c:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar xo ..\..\lib\libnet80211.a 24 | c:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar xo ..\..\lib\libpp.a 25 | c:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar xo ..\..\lib\libmgcc.a 26 | c:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar xo ..\..\lib\libcrypto.a 27 | if exist ..\..\lib\libsdk.a del ..\..\lib\libsdk.a 28 | c:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar ru ..\..\lib\libsdk.a *.o 29 | cd .. 30 | rd /q /s _temp 31 | if exist ..\lib\libsdk.a goto end 32 | :err_end 33 | echo "Error!" 34 | :end -------------------------------------------------------------------------------- /lib/libcrypto.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/lib/libcrypto.a -------------------------------------------------------------------------------- /lib/libdhcps.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/lib/libdhcps.a -------------------------------------------------------------------------------- /lib/liblwipif.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/lib/liblwipif.a -------------------------------------------------------------------------------- /lib/libmgcc.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/lib/libmgcc.a -------------------------------------------------------------------------------- /lib/libmlwip.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/lib/libmlwip.a -------------------------------------------------------------------------------- /lib/libmmain.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/lib/libmmain.a -------------------------------------------------------------------------------- /lib/libmmain.a.patch.txt: -------------------------------------------------------------------------------- 1 | error REASON_DEEP_SLEEP_AWAKE in libmmain.a 2 | 00001483: 08 82 3 | 00001484: 71 69 4 | 00001485: 12 42 5 | 00001486: C1 06 6 | 00001487: 20 FF 7 | 00001488: 82 FF 8 | 00001489: 69 0D 9 | 0000148A: 42 F0 10 | -------------------------------------------------------------------------------- /lib/libmphy.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/lib/libmphy.a -------------------------------------------------------------------------------- /lib/libmwpa.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/lib/libmwpa.a -------------------------------------------------------------------------------- /lib/libnet80211.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/lib/libnet80211.a -------------------------------------------------------------------------------- /lib/libpp.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/lib/libpp.a -------------------------------------------------------------------------------- /lib/libsdk.a: -------------------------------------------------------------------------------- https://raw.githubusercontent.com/pvvx/MinEspSDKLib/6e88ca8008d01fc66a9b4e71a2b5302c6241c577/lib/libsdk.a -------------------------------------------------------------------------------- /lib/mlibsdk.bat: -------------------------------------------------------------------------------- 1 | @echo off 2 | if not exist ..\app\sdklib\.output\eagle\lib\libsdk.a goto err_end 3 | del libsdk.a 4 | md sdklib 5 | cd sdklib 6 | c:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar xo ..\..\app\sdklib\.output\eagle\lib\libsdk.a 7 | c:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar xo ..\libmmain.a 8 | c:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar xo ..\libmphy.a 9 | c:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar xo ..\libmwpa.a 10 | c:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar xo ..\libcrypto.a 11 | c:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar xo ..\libnet80211.a 12 | c:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar xo ..\libpp.a 13 | c:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar xo ..\libmgcc.a 14 | c:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar ru ..\libsdk.a *.o 15 | cd .. 16 | rd /q /s sdklib 17 | goto end 18 | :err_end 19 | echo Error! 20 | :end -------------------------------------------------------------------------------- /lib/new_libdhcps.bat: -------------------------------------------------------------------------------- 1 | del libdhcps.a 2 | md main.lib 3 | cd main.lib 4 | C:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar x C:\Espressif\ESP8266_SDK\lib\liblwip.a 5 | C:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar ru ..\libdhcps.a dhcpserver.o 6 | cd .. 7 | rd /q /s main.lib 8 | -------------------------------------------------------------------------------- /lib/new_liblwipif.bat: -------------------------------------------------------------------------------- 1 | del liblwipif.a 2 | md main.lib 3 | cd main.lib 4 | C:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar x C:\Espressif\ESP8266_SDK\lib\libmain.a 5 | C:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar ru ..\liblwipif.a eagle_lwip_if.o 6 | cd .. 7 | rd /q /s main.lib 8 | -------------------------------------------------------------------------------- /lib/new_libmgcc.bat: -------------------------------------------------------------------------------- 1 | del libmgcc.a 2 | md libgcc 3 | cd libgcc 4 | @rem C:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar x C:\Espressif\xtensa-lx106-elf\lib\gcc\xtensa-lx106-elf\4.8.2\libgcc.a 5 | C:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar x C:\Espressif\xtensa-lx106-elf\lib\gcc\xtensa-lx106-elf\5.1.0\libgcc.a 6 | @rem delete: 7 | @rem _fixunsdfsi.o _umoddi3.o _umodsi3.o _extendsfdf2.o _fixdfsi.o _divsi3.o _divdf3.o _divdi3.o _fixunssfsi.o 8 | @rem _floatsidf.o _floatsisf.o _floatunsidf.o _floatunsisf.o _muldf3.o _muldi3.o _mulsf3.o _truncdfsf2.o 9 | @rem _udivdi3.o _udivsi3.o _umulsidi3.o _addsubdf3.o _addsubsf3.o 10 | for /f "delims=" %%f in (../rom_files_list.txt) do del "%%f.o" 11 | C:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar ru ..\libmgcc.a *.o 12 | cd .. 13 | rd /q /s libgcc 14 | -------------------------------------------------------------------------------- /lib/new_libmlwip.bat: -------------------------------------------------------------------------------- 1 | del libmlwip.a 2 | md lwip.lib 3 | cd lwip.lib 4 | C:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar x C:\Espressif\ESP8266_SDK\lib\liblwip.a 5 | @rem sockets.o api_lib.o api_msg.o err.o netbuf.o netdb.o netifapi.o tcpip.o def.o mem.o stats.o sys.o sys_arch.o autoip.o inet.o ip_frag.o 6 | @rem del: mdns.o dhcpserver.o 7 | C:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar ru ..\libmlwip.a dhcp.o dns.o init.o memp.o netif.o pbuf.o tcp.o tcp_in.o tcp_out.o timers.o udp.o icmp.o igmp.o inet_chksum.o ip.o ip_addr.o etharp.o raw.o 8 | cd .. 9 | rd /q /s lwip.lib 10 | -------------------------------------------------------------------------------- /lib/new_libmmain.bat: -------------------------------------------------------------------------------- 1 | del libmmain.a 2 | md main.lib 3 | cd main.lib 4 | C:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar x C:\Espressif\ESP8266_SDK\lib\libmain.a 5 | @rem eagle_lib.o ets_timer.o mem_manager.o user_interface.o eagle_lwip_if.o 6 | @rem del: spi_flash.o app_main.o ets_timer.o eagle_lwip_if.o mem_manager.o eagle_lib.o 7 | C:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar ru ..\libmmain.a user_interface.o 8 | cd .. 9 | rd /q /s main.lib 10 | -------------------------------------------------------------------------------- /lib/new_libmphy.bat: -------------------------------------------------------------------------------- 1 | del libmphy.a 2 | md libphy.lib 3 | cd libphy.lib 4 | C:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar x C:\Espressif\ESP8266_SDK\lib\libphy.a 5 | @rem phy.o phy_chip_v6.o phy_chip_v6_ana.o phy_chip_v6_cal.o phy_sleep.o 6 | @rem delete: ate_test.o phy_chip_v6_unused.o 7 | C:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar ru ..\libmphy.a phy.o phy_chip_v6.o phy_chip_v6_ana.o phy_chip_v6_cal.o phy_sleep.o 8 | cd .. 9 | rd /q /s libphy.lib 10 | -------------------------------------------------------------------------------- /lib/new_libmwpa.bat: -------------------------------------------------------------------------------- 1 | del libmwpa.a 2 | md wpa.lib 3 | cd wpa.lib 4 | C:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar x C:\Espressif\ESP8266_SDK\lib\libwpa.a 5 | @rem aes-internal-enc.o aes-wrap.o ap_config.o common.o ieee802_1x.o sta_info.o wpa.o wpa_auth.o wpa_auth_ie.o wpa_common.o wpa_ie.o wpa_main.o wpabuf.o wpas_glue.o 6 | @rem del: wpa_debug.o os_xtensa.o 7 | C:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar ru ..\libmwpa.a ap_config.o common.o ieee802_1x.o sta_info.o wpa.o wpa_auth.o wpa_auth_ie.o wpa_common.o wpa_ie.o wpa_main.o wpabuf.o wpas_glue.o 8 | @rem none: aes-internal-enc.o aes-wrap.o 9 | cd .. 10 | rd /q /s wpa.lib 11 | -------------------------------------------------------------------------------- /lib/o-asm.bat: -------------------------------------------------------------------------------- 1 | for %%a in (*.a) do ( 2 | md %%a.o 3 | cd %%a.o 4 | C:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-ar x ..\%%a 5 | for %%o in (*.o) do C:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-objdump -S %%o > %%o.asm 6 | cd .. 7 | ) 8 | 9 | -------------------------------------------------------------------------------- /lib/rom_files_list.txt: -------------------------------------------------------------------------------- 1 | _addsubsf3 2 | _addsubdf3 3 | _divdf3 4 | _divdi3 5 | _divsi3 6 | _extendsfdf2 7 | _fixdfsi 8 | _fixunsdfsi 9 | _fixunssfsi 10 | _floatsidf 11 | _floatsisf 12 | _floatunsidf 13 | _floatunsisf 14 | _muldf3 15 | _muldi3 16 | _mulsf3 17 | _truncdfsf2 18 | _udivdi3 19 | _udivsi3 20 | _umoddi3 21 | _umodsi3 22 | _umulsidi3 -------------------------------------------------------------------------------- /mem.txt: -------------------------------------------------------------------------------- 1 | Section| Description| Start (hex)| End (hex)|Used space 2 | ------------------------------------------------------------------------------ 3 | data| Initialized Data (RAM)| 3FFE8000| 3FFE8364| 868 4 | rodata| ReadOnly Data (RAM)| 3FFE8364| 3FFE8428| 196 5 | bss| Uninitialized Data (RAM)| 3FFE8428| 3FFEE210| 24040 6 | lit4| Uninitialized Data (IRAM)| 40104E84| 40104F18| 148 7 | text| Uncached Code (IRAM)| 40100000| 40104E84| 20100 8 | irom0_text| Cached Code (SPI)| 40207000| 40230E16| 171542 9 | ------------------------------------------------------------------------------ 10 | Entry Point : 40100000 call_user_start() 11 | Total Used RAM : 45352 12 | Free IRam : 12520 or 28904 (option 48k IRAM) 13 | Free Heap : 56816 14 | Total Free RAM : 85720 -------------------------------------------------------------------------------- /mem_usage.bat: -------------------------------------------------------------------------------- 1 | C:\Espressif\utils\MemAnalyzer.exe C:\Espressif\xtensa-lx106-elf\bin\xtensa-lx106-elf-objdump.exe .\app\.output\eagle\image\eagle.app.v6.out >>mem.txt 2 | --------------------------------------------------------------------------------