├── CMakeLists.txt ├── LICENSE ├── Makefile ├── README.md ├── main ├── CMakeLists.txt ├── component.mk ├── ulp │ ├── i2c-bmp180.S │ ├── i2c-util.S │ ├── i2c.S │ ├── main.S │ └── stack.S └── ulp_example_main.c └── sdkconfig /CMakeLists.txt: -------------------------------------------------------------------------------- 1 | # The following lines of boilerplate have to be in your project's CMakeLists 2 | # in this exact order for cmake to work correctly 3 | cmake_minimum_required(VERSION 3.5) 4 | 5 | set(SUPPORTED_TARGETS esp32) 6 | include($ENV{IDF_PATH}/tools/cmake/project.cmake) 7 | project(ulp-example) -------------------------------------------------------------------------------- /LICENSE: -------------------------------------------------------------------------------- 1 | GNU LESSER GENERAL PUBLIC LICENSE 2 | Version 3, 29 June 2007 3 | 4 | Copyright (C) 2007 Free Software Foundation, Inc. 5 | Everyone is permitted to copy and distribute verbatim copies 6 | of this license document, but changing it is not allowed. 7 | 8 | 9 | This version of the GNU Lesser General Public License incorporates 10 | the terms and conditions of version 3 of the GNU General Public 11 | License, supplemented by the additional permissions listed below. 12 | 13 | 0. Additional Definitions. 14 | 15 | As used herein, "this License" refers to version 3 of the GNU Lesser 16 | General Public License, and the "GNU GPL" refers to version 3 of the GNU 17 | General Public License. 18 | 19 | "The Library" refers to a covered work governed by this License, 20 | other than an Application or a Combined Work as defined below. 21 | 22 | An "Application" is any work that makes use of an interface provided 23 | by the Library, but which is not otherwise based on the Library. 24 | Defining a subclass of a class defined by the Library is deemed a mode 25 | of using an interface provided by the Library. 26 | 27 | A "Combined Work" is a work produced by combining or linking an 28 | Application with the Library. The particular version of the Library 29 | with which the Combined Work was made is also called the "Linked 30 | Version". 31 | 32 | The "Minimal Corresponding Source" for a Combined Work means the 33 | Corresponding Source for the Combined Work, excluding any source code 34 | for portions of the Combined Work that, considered in isolation, are 35 | based on the Application, and not on the Linked Version. 36 | 37 | The "Corresponding Application Code" for a Combined Work means the 38 | object code and/or source code for the Application, including any data 39 | and utility programs needed for reproducing the Combined Work from the 40 | Application, but excluding the System Libraries of the Combined Work. 41 | 42 | 1. Exception to Section 3 of the GNU GPL. 43 | 44 | You may convey a covered work under sections 3 and 4 of this License 45 | without being bound by section 3 of the GNU GPL. 46 | 47 | 2. Conveying Modified Versions. 48 | 49 | If you modify a copy of the Library, and, in your modifications, a 50 | facility refers to a function or data to be supplied by an Application 51 | that uses the facility (other than as an argument passed when the 52 | facility is invoked), then you may convey a copy of the modified 53 | version: 54 | 55 | a) under this License, provided that you make a good faith effort to 56 | ensure that, in the event an Application does not supply the 57 | function or data, the facility still operates, and performs 58 | whatever part of its purpose remains meaningful, or 59 | 60 | b) under the GNU GPL, with none of the additional permissions of 61 | this License applicable to that copy. 62 | 63 | 3. Object Code Incorporating Material from Library Header Files. 64 | 65 | The object code form of an Application may incorporate material from 66 | a header file that is part of the Library. You may convey such object 67 | code under terms of your choice, provided that, if the incorporated 68 | material is not limited to numerical parameters, data structure 69 | layouts and accessors, or small macros, inline functions and templates 70 | (ten or fewer lines in length), you do both of the following: 71 | 72 | a) Give prominent notice with each copy of the object code that the 73 | Library is used in it and that the Library and its use are 74 | covered by this License. 75 | 76 | b) Accompany the object code with a copy of the GNU GPL and this license 77 | document. 78 | 79 | 4. Combined Works. 80 | 81 | You may convey a Combined Work under terms of your choice that, 82 | taken together, effectively do not restrict modification of the 83 | portions of the Library contained in the Combined Work and reverse 84 | engineering for debugging such modifications, if you also do each of 85 | the following: 86 | 87 | a) Give prominent notice with each copy of the Combined Work that 88 | the Library is used in it and that the Library and its use are 89 | covered by this License. 90 | 91 | b) Accompany the Combined Work with a copy of the GNU GPL and this license 92 | document. 93 | 94 | c) For a Combined Work that displays copyright notices during 95 | execution, include the copyright notice for the Library among 96 | these notices, as well as a reference directing the user to the 97 | copies of the GNU GPL and this license document. 98 | 99 | d) Do one of the following: 100 | 101 | 0) Convey the Minimal Corresponding Source under the terms of this 102 | License, and the Corresponding Application Code in a form 103 | suitable for, and under terms that permit, the user to 104 | recombine or relink the Application with a modified version of 105 | the Linked Version to produce a modified Combined Work, in the 106 | manner specified by section 6 of the GNU GPL for conveying 107 | Corresponding Source. 108 | 109 | 1) Use a suitable shared library mechanism for linking with the 110 | Library. A suitable mechanism is one that (a) uses at run time 111 | a copy of the Library already present on the user's computer 112 | system, and (b) will operate properly with a modified version 113 | of the Library that is interface-compatible with the Linked 114 | Version. 115 | 116 | e) Provide Installation Information, but only if you would otherwise 117 | be required to provide such information under section 6 of the 118 | GNU GPL, and only to the extent that such information is 119 | necessary to install and execute a modified version of the 120 | Combined Work produced by recombining or relinking the 121 | Application with a modified version of the Linked Version. (If 122 | you use option 4d0, the Installation Information must accompany 123 | the Minimal Corresponding Source and Corresponding Application 124 | Code. If you use option 4d1, you must provide the Installation 125 | Information in the manner specified by section 6 of the GNU GPL 126 | for conveying Corresponding Source.) 127 | 128 | 5. Combined Libraries. 129 | 130 | You may place library facilities that are a work based on the 131 | Library side by side in a single library together with other library 132 | facilities that are not Applications and are not covered by this 133 | License, and convey such a combined library under terms of your 134 | choice, if you do both of the following: 135 | 136 | a) Accompany the combined library with a copy of the same work based 137 | on the Library, uncombined with any other library facilities, 138 | conveyed under the terms of this License. 139 | 140 | b) Give prominent notice with the combined library that part of it 141 | is a work based on the Library, and explaining where to find the 142 | accompanying uncombined form of the same work. 143 | 144 | 6. Revised Versions of the GNU Lesser General Public License. 145 | 146 | The Free Software Foundation may publish revised and/or new versions 147 | of the GNU Lesser General Public License from time to time. Such new 148 | versions will be similar in spirit to the present version, but may 149 | differ in detail to address new problems or concerns. 150 | 151 | Each version is given a distinguishing version number. If the 152 | Library as you received it specifies that a certain numbered version 153 | of the GNU Lesser General Public License "or any later version" 154 | applies to it, you have the option of following the terms and 155 | conditions either of that published version or of any later version 156 | published by the Free Software Foundation. If the Library as you 157 | received it does not specify a version number of the GNU Lesser 158 | General Public License, you may choose any version of the GNU Lesser 159 | General Public License ever published by the Free Software Foundation. 160 | 161 | If the Library as you received it specifies that a proxy can decide 162 | whether future versions of the GNU Lesser General Public License shall 163 | apply, that proxy's public statement of acceptance of any version is 164 | permanent authorization for you to choose that version for the 165 | Library. 166 | -------------------------------------------------------------------------------- /Makefile: -------------------------------------------------------------------------------- 1 | # 2 | # This is a project Makefile. It is assumed the directory this Makefile resides in is a 3 | # project subdirectory. 4 | # 5 | 6 | PROJECT_NAME := ulp-i2c 7 | 8 | include $(IDF_PATH)/make/project.mk 9 | 10 | -------------------------------------------------------------------------------- /README.md: -------------------------------------------------------------------------------- 1 | # ULP I2C demo application 2 | 3 | Example of ESP-32 ULP I2C application which reads a sensor (BMP-180) and wakes up the main processors after a significant change 4 | of the measured values. 5 | 6 | Note that the ULP is quite limited in program size and IO options. 7 | An alternative is to use an ATTiny as ULP processor, see: 8 | 9 | https://github.com/tomtor/ESPTiny 10 | 11 | ## IDF requirements 12 | Tested on IDF 4.1 with CMake build system 13 | 14 | ## I2C bit banged support 15 | Note that this example uses a bit-banged I2C implementation, because the hardware ULP I2C support cannot read 16 bit values. 16 | This is not essential for the BMP-180, but some sensors like the ADS-1015 **DO** require 16-bit readouts. 17 | 18 | ## Example of Macro usage and ULP stack/subroutines 19 | In additon this example shows ULP stack handling and reusable subroutines examples, like 20 | 21 | ### waitMs 22 | 23 | Wait some milliseconds 24 | 25 | ### abs 26 | Compute abs value of register 27 | 28 | ## Credits 29 | Parts of the original C code from 30 | 31 | https://github.com/adafruit/Adafruit-BMP085-Library 32 | 33 | were translated to ESP assembly. 34 | 35 | ## Warning 36 | 37 | Be aware of an assembler bug: 38 | 39 | https://www.esp32.com/viewtopic.php?f=2&t=3228 40 | 41 | -------------------------------------------------------------------------------- /main/CMakeLists.txt: -------------------------------------------------------------------------------- 1 | idf_component_register(SRCS "ulp_example_main.c" 2 | INCLUDE_DIRS "" 3 | REQUIRES soc nvs_flash ulp) 4 | # 5 | # ULP support additions to component CMakeLists.txt. 6 | # 7 | # 1. The ULP app name must be unique (if multiple components use ULP). 8 | set(ulp_app_name ulp_${COMPONENT_NAME}) 9 | # 10 | # 2. Specify all assembly source files. 11 | # Files should be placed into a separate directory (in this case, ulp/), 12 | # which should not be added to COMPONENT_SRCS. 13 | set(ulp_s_sources "ulp/i2c-bmp180.S" "ulp/i2c-util.S" "ulp/i2c.S" "ulp/main.S" "ulp/stack.S") 14 | # 15 | # 3. List all the component source files which include automatically 16 | # generated ULP export file, ${ulp_app_name}.h: 17 | set(ulp_exp_dep_srcs "ulp_example_main.c") 18 | # 19 | # 4. Call function to build ULP binary and embed in project using the argument 20 | # values above. 21 | ulp_embed_binary(${ulp_app_name} "${ulp_s_sources}" "${ulp_exp_dep_srcs}") 22 | -------------------------------------------------------------------------------- /main/component.mk: -------------------------------------------------------------------------------- 1 | # 2 | # ULP support additions to component makefile. 3 | # 4 | # 1. ULP_APP_NAME must be unique (if multiple components use ULP) 5 | # Default value, override if necessary: 6 | ULP_APP_NAME ?= ulp_$(COMPONENT_NAME) 7 | # 8 | # 2. Specify all assembly source files here. 9 | # Files should be placed into a separate directory (in this case, ulp/), 10 | # which should not be added to COMPONENT_SRCDIRS. 11 | ULP_S_SOURCES = $(addprefix $(COMPONENT_PATH)/ulp/, \ 12 | main.S \ 13 | i2c-bmp180.S \ 14 | i2c-util.S \ 15 | i2c.S \ 16 | ) 17 | # 18 | # 3. List all the component object files which include automatically 19 | # generated ULP export file, $(ULP_APP_NAME).h: 20 | ULP_EXP_DEP_OBJECTS := ulp_example_main.o 21 | # 22 | # 4. Include build rules for ULP program 23 | include $(IDF_PATH)/components/ulp/component_ulp_common.mk 24 | # 25 | # Link object files and generate map file 26 | $(ULP_ELF): $(ULP_OBJECTS) $(ULP_LD_SCRIPT) 27 | $(summary) ULP_LD $(patsubst $(PWD)/%,%,$(CURDIR))/$@ 28 | $(ULP_LD) -o $@ -A elf32-esp32ulp -Map=$(ULP_MAP) -T $(ULP_LD_SCRIPT) $(ULP_OBJECTS) 29 | # 30 | # End of ULP support additions to component makefile. 31 | # 32 | -------------------------------------------------------------------------------- /main/ulp/i2c-bmp180.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Demo of I2C ULP routines 3 | */ 4 | 5 | #include "soc/rtc_cntl_reg.h" 6 | #include "soc/rtc_io_reg.h" 7 | #include "soc/soc_ulp.h" 8 | 9 | #include "stack.S" 10 | 11 | .set BMP180_ADDR,0x77 // 7-bit address 12 | 13 | .set BMP180_REG_CONTROL,0xF4 14 | .set BMP180_REG_RESULT,0xF6 15 | 16 | .set BMP180_COMMAND_TEMPERATURE,0x2E 17 | .set BMP180_COMMAND_PRESSURE0,0x34 18 | .set BMP180_COMMAND_PRESSURE1,0x74 19 | .set BMP180_COMMAND_PRESSURE2,0xB4 20 | .set BMP180_COMMAND_PRESSURE3,0xF4 21 | 22 | /* Define variables, which go into .bss section (zero-initialized data) */ 23 | .bss 24 | 25 | .global temp 26 | temp: .long 0 27 | .global pressure, pressure2 28 | pressure: .long 0 29 | pressure2: .long 0 30 | 31 | .global ac1, ac2, ac3, ac4, ac5, ac6, b1, b2, mb, mc, md 32 | 33 | ac1: .long 0 34 | ac2: .long 0 35 | ac3: .long 0 36 | ac4: .long 0 37 | ac5: .long 0 38 | ac6: .long 0 39 | 40 | b1: .long 0 41 | b2: .long 0 42 | 43 | mb: .long 0 44 | mc: .long 0 45 | md: .long 0 46 | 47 | /* Code goes into .text section */ 48 | .text 49 | 50 | .global readBMP 51 | readBMP: 52 | move r1,ac1 53 | ld r0,r1,0 54 | jumpr initBMP,1,lt 55 | didInit: 56 | move r1,BMP180_ADDR 57 | push r1 58 | move r1,BMP180_REG_CONTROL 59 | push r1 60 | move r1,BMP180_COMMAND_TEMPERATURE 61 | push r1 62 | psr 63 | jump write8 64 | add r3,r3,3 // remove 3 arguments from stack 65 | move r0,r2 // test for error in r2 66 | jumpr fail,1,ge 67 | 68 | // Wait 5ms for sensor computation 69 | move r2,5 70 | psr 71 | jump waitMs 72 | 73 | // Read 16 bit result 74 | move r1,BMP180_ADDR 75 | push r1 76 | move r1,BMP180_REG_RESULT 77 | push r1 78 | psr 79 | jump read16 80 | add r3,r3,2 // remove call parameters from stack 81 | move r1,r0 // save result 82 | move r0,r2 // test for error 83 | jumpr fail,1,ge 84 | move r2,temp // store result 85 | st r1,r2,0 86 | 87 | // Read raw pressure 88 | move r1,BMP180_ADDR 89 | push r1 90 | move r1,BMP180_REG_CONTROL 91 | push r1 92 | move r1,BMP180_COMMAND_PRESSURE1 93 | push r1 94 | psr 95 | jump write8 96 | add r3,r3,3 // remove 3 arguments from stack 97 | move r0,r2 // test for error in r2 98 | jumpr fail,1,ge 99 | 100 | // Wait 8 ms for sensor computation 101 | move r2,8 102 | psr 103 | jump waitMs 104 | 105 | move r1,BMP180_ADDR 106 | push r1 107 | move r1,BMP180_REG_RESULT 108 | push r1 109 | psr 110 | jump read16 111 | add r3,r3,2 // remove call parameters from stack 112 | move r1,r0 // save result 113 | move r0,r2 // test for error 114 | jumpr fail,1,ge 115 | move r2,pressure // store result 116 | st r1,r2,0 117 | 118 | move r1,BMP180_ADDR 119 | push r1 120 | move r1,(BMP180_REG_RESULT+2) 121 | push r1 122 | psr 123 | jump read8 124 | add r3,r3,2 // remove call parameters from stack 125 | move r1,r0 // save result 126 | move r0,r2 // test for error 127 | jumpr fail,1,ge 128 | move r2,pressure2 // store result 129 | st r1,r2,0 130 | 131 | ret 132 | 133 | fail: 134 | move r1,temp 135 | move r0,0 // 0 signals error 136 | st r0,r1,0 137 | ret 138 | 139 | 140 | #define BMP085_CAL_AC1 0xAA 141 | #define BMP085_CAL_AC2 0xAC 142 | #define BMP085_CAL_AC3 0xAE 143 | #define BMP085_CAL_AC4 0xB0 144 | #define BMP085_CAL_AC5 0xB2 145 | #define BMP085_CAL_AC6 0xB4 146 | #define BMP085_CAL_B1 0xB6 147 | #define BMP085_CAL_B2 0xB8 148 | #define BMP085_CAL_MB 0xBA 149 | #define BMP085_CAL_MC 0xBC 150 | #define BMP085_CAL_MD 0xBE 151 | 152 | // Read calibration data 153 | initBMP: 154 | move r1,ac1 155 | push r1 156 | move r1,BMP180_ADDR 157 | push r1 158 | move r1,BMP085_CAL_AC1 159 | push r1 160 | read_cal: 161 | psr 162 | jump read16 163 | or r2,r2,0 // test error 164 | jump readok,eq 165 | jump fail 166 | readok: 167 | ld r1,r3,12 168 | st r0,r1,0 169 | add r1,r1,1 170 | st r1,r3,12 // next cal parameter address 171 | ld r0,r3,4 172 | add r0,r0,2 // next register 173 | st r0,r3,4 174 | jumpr read_cal,BMP085_CAL_MD+2,lt 175 | add r3,r3,3 176 | jump didInit 177 | 178 | // Wait for r2 milliseconds 179 | waitMs: 180 | wait 8000 181 | sub r2,r2,1 182 | jump doneWaitMs,eq 183 | jump waitMs 184 | doneWaitMs: 185 | ret 186 | -------------------------------------------------------------------------------- /main/ulp/i2c-util.S: -------------------------------------------------------------------------------- 1 | /* 2 | * I2C ULP utility routines 3 | */ 4 | 5 | #include "soc/rtc_cntl_reg.h" 6 | #include "soc/rtc_io_reg.h" 7 | #include "soc/soc_ulp.h" 8 | 9 | #include "stack.S" 10 | 11 | .text 12 | 13 | write_intro: 14 | psr 15 | jump i2c_start_cond 16 | 17 | ld r2,r3,20 // Address 18 | lsh r2,r2,1 19 | psr 20 | jump i2c_write_byte 21 | jumpr popfail,1,ge 22 | 23 | ld r2,r3,16 // Register 24 | psr 25 | jump i2c_write_byte 26 | jumpr popfail,1,ge 27 | ret 28 | 29 | 30 | .global write8 31 | write8: 32 | psr 33 | jump write_intro 34 | 35 | write_b: 36 | ld r2,r3,8 // data byte 37 | psr 38 | jump i2c_write_byte 39 | jumpr fail,1,ge 40 | 41 | psr 42 | jump i2c_stop_cond 43 | 44 | move r2,0 // Ok 45 | ret 46 | 47 | 48 | .global write16 49 | write16: 50 | psr 51 | jump write_intro 52 | 53 | ld r2,r3,8 // data byte 1 54 | rsh r2,r2,8 55 | psr 56 | jump i2c_write_byte 57 | jumpr fail,1,ge 58 | 59 | jump write_b 60 | 61 | 62 | read_intro: 63 | psr 64 | jump i2c_start_cond 65 | 66 | ld r2,r3,16 // Address 67 | lsh r2,r2,1 68 | psr 69 | jump i2c_write_byte 70 | jumpr popfail,1,ge 71 | 72 | ld r2,r3,12 // Register 73 | psr 74 | jump i2c_write_byte 75 | jumpr popfail,1,ge 76 | 77 | psr 78 | jump i2c_start_cond 79 | 80 | ld r2,r3,16 81 | lsh r2,r2,1 82 | or r2,r2,1 // Address Read 83 | psr 84 | jump i2c_write_byte 85 | jumpr popfail,1,ge 86 | 87 | ret 88 | popfail: 89 | pop r1 // pop caller return address 90 | move r2,1 91 | ret 92 | 93 | .global read8 94 | read8: 95 | psr 96 | jump read_intro 97 | 98 | move r2,1 // last byte 99 | psr 100 | jump i2c_read_byte 101 | push r0 102 | 103 | psr 104 | jump i2c_stop_cond 105 | 106 | pop r0 107 | 108 | move r2,0 // OK 109 | ret 110 | fail: 111 | move r2,1 112 | ret 113 | 114 | .global read16 115 | read16: 116 | psr 117 | jump read_intro 118 | 119 | move r2,0 120 | psr 121 | jump i2c_read_byte 122 | push r0 123 | 124 | move r2,1 // last byte 125 | psr 126 | jump i2c_read_byte 127 | push r0 128 | 129 | psr 130 | jump i2c_stop_cond 131 | 132 | pop r0 133 | pop r2 // first byte 134 | lsh r2,r2,8 135 | or r2,r2,r0 136 | move r0,r2 137 | 138 | move r2,0 // OK 139 | ret 140 | -------------------------------------------------------------------------------- /main/ulp/i2c.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Demo of I2C ULP routines 3 | */ 4 | 5 | #include "soc/rtc_cntl_reg.h" 6 | #include "soc/rtc_io_reg.h" 7 | #include "soc/soc_ulp.h" 8 | 9 | #include "stack.S" 10 | 11 | 12 | /* 13 | * =============================== I2C code ========================================== 14 | * Implementation of pseudo code from 15 | * https://en.wikipedia.org/wiki/I%C2%B2C#Example_of_bit-banging_the_I.C2.B2C_master_protocol 16 | */ 17 | 18 | .bss 19 | i2c_started: 20 | .long 0 21 | 22 | i2c_didInit: 23 | .long 0 24 | 25 | .text 26 | 27 | .global i2c_start_cond 28 | .global i2c_stop_cond 29 | .global i2c_write_bit 30 | .global i2c_read_bit 31 | .global i2c_write_byte 32 | .global i2c_read_byte 33 | 34 | .macro I2C_delay 35 | wait 10 // 38 // minimal 4.7us 36 | .endm 37 | 38 | .macro read_SCL // Return current level of SCL line, 0 or 1 39 | READ_RTC_REG(RTC_GPIO_IN_REG, RTC_GPIO_IN_NEXT_S + 9, 1) // RTC_GPIO_9 == GPIO_32 40 | .endm 41 | 42 | .macro read_SDA // Return current level of SDA line, 0 or 1 43 | READ_RTC_REG(RTC_GPIO_IN_REG, RTC_GPIO_IN_NEXT_S + 8, 1) // RTC_GPIO_8 == GPIO_33 44 | .endm 45 | 46 | .macro set_SCL // Do not drive SCL (set pin high-impedance) 47 | WRITE_RTC_REG(RTC_GPIO_ENABLE_W1TC_REG, RTC_GPIO_ENABLE_W1TC_S + 9, 1, 1) 48 | .endm 49 | 50 | .macro clear_SCL // Actively drive SCL signal low 51 | // Output mode 52 | WRITE_RTC_REG(RTC_GPIO_ENABLE_W1TS_REG, RTC_GPIO_ENABLE_W1TS_S + 9, 1, 1) 53 | .endm 54 | 55 | .macro set_SDA // Do not drive SDA (set pin high-impedance) 56 | WRITE_RTC_REG(RTC_GPIO_ENABLE_W1TC_REG, RTC_GPIO_ENABLE_W1TC_S + 8, 1, 1) 57 | .endm 58 | 59 | .macro clear_SDA // Actively drive SDA signal low 60 | // Output mode 61 | WRITE_RTC_REG(RTC_GPIO_ENABLE_W1TS_REG, RTC_GPIO_ENABLE_W1TS_S + 8, 1, 1) 62 | .endm 63 | 64 | 65 | i2c_start_cond: 66 | move r1,i2c_didInit 67 | ld r0,r1,0 68 | jumpr didInit,1,ge 69 | move r0,1 70 | st r0,r1,0 71 | // set GPIO to pull low when activated 72 | WRITE_RTC_REG(RTC_GPIO_OUT_REG, RTC_GPIO_OUT_DATA_S + 9, 1, 0) 73 | WRITE_RTC_REG(RTC_GPIO_OUT_REG, RTC_GPIO_OUT_DATA_S + 8, 1, 0) 74 | didInit: 75 | move r2,i2c_started 76 | ld r0,r2,0 77 | jumpr not_started,1,lt 78 | // if started, do a restart condition 79 | // set SDA to 1 80 | set_SDA 81 | I2C_delay 82 | set_SCL 83 | clock_stretch: // TODO: Add timeout? 84 | read_SCL 85 | jumpr clock_stretch,1,lt 86 | 87 | // Repeated start setup time, minimum 4.7us 88 | I2C_delay 89 | 90 | not_started: 91 | // if (read_SDA() == 0) { 92 | // arbitration_lost(); 93 | // } 94 | 95 | // SCL is high, set SDA from 1 to 0. 96 | clear_SDA 97 | I2C_delay 98 | clear_SCL 99 | move r0,1 100 | st r0,r2,0 101 | 102 | ret 103 | 104 | 105 | i2c_stop_cond: 106 | // set SDA to 0 107 | clear_SDA 108 | I2C_delay 109 | 110 | set_SCL 111 | clock_stretch_stop: 112 | read_SCL 113 | jumpr clock_stretch_stop,1,lt 114 | 115 | // Stop bit setup time, minimum 4us 116 | I2C_delay 117 | 118 | // SCL is high, set SDA from 0 to 1 119 | set_SDA 120 | I2C_delay 121 | // if (read_SDA() == 0) { 122 | // arbitration_lost(); 123 | // } 124 | 125 | move r2,i2c_started 126 | move r0,0 127 | st r0,r2,0 128 | 129 | ret 130 | 131 | 132 | // Write a bit to I2C bus 133 | i2c_write_bit: 134 | jumpr bit0,1,lt 135 | set_SDA 136 | jump bit1 137 | bit0: 138 | clear_SDA 139 | bit1: 140 | 141 | // SDA change propagation delay 142 | I2C_delay 143 | // Set SCL high to indicate a new valid SDA value is available 144 | set_SCL 145 | // Wait for SDA value to be read by slave, minimum of 4us for standard mode 146 | I2C_delay 147 | 148 | clock_stretch_write: 149 | read_SCL 150 | jumpr clock_stretch_write,1,lt 151 | 152 | // SCL is high, now data is valid 153 | // If SDA is high, check that nobody else is driving SDA 154 | // if (bit && (read_SDA() == 0)) { 155 | // arbitration_lost(); 156 | // } 157 | 158 | // Clear the SCL to low in preparation for next change 159 | clear_SCL 160 | 161 | ret 162 | 163 | 164 | // Read a bit from I2C bus 165 | i2c_read_bit: 166 | // Let the slave drive data 167 | set_SDA 168 | // Wait for SDA value to be written by slave, minimum of 4us for standard mode 169 | I2C_delay 170 | // Set SCL high to indicate a new valid SDA value is available 171 | set_SCL 172 | 173 | clock_stretch_read: 174 | read_SCL 175 | jumpr clock_stretch_read,1,lt 176 | 177 | // Wait for SDA value to be written by slave, minimum of 4us for standard mode 178 | I2C_delay 179 | // SCL is high, read out bit 180 | read_SDA 181 | // Set SCL low in preparation for next operation 182 | clear_SCL 183 | 184 | ret // bit in r0 185 | 186 | // Write a byte to I2C bus. Return 0 if ack by the slave. 187 | i2c_write_byte: 188 | stage_rst 189 | next_bit: 190 | and r0,r2,0x80 191 | psr 192 | jump i2c_write_bit 193 | lsh r2,r2,1 194 | stage_inc 1 195 | jumps next_bit,8,lt 196 | 197 | psr 198 | jump i2c_read_bit 199 | ret // nack 200 | 201 | 202 | // Read a byte from I2C bus 203 | i2c_read_byte: 204 | push r2 205 | move r2,0 206 | stage_rst 207 | next_bit_read: 208 | psr 209 | jump i2c_read_bit 210 | lsh r2,r2,1 211 | or r2,r2,r0 212 | stage_inc 1 213 | jumps next_bit_read,8,lt 214 | 215 | pop r0 216 | psr 217 | jump i2c_write_bit 218 | 219 | move r0,r2 220 | 221 | ret 222 | 223 | -------------------------------------------------------------------------------- /main/ulp/main.S: -------------------------------------------------------------------------------- 1 | /* 2 | * Demo of I2C ULP routines 3 | */ 4 | 5 | #include "soc/rtc_cntl_reg.h" 6 | #include "soc/rtc_io_reg.h" 7 | #include "soc/soc_ulp.h" 8 | 9 | #include "stack.S" 10 | 11 | 12 | /* Define variables, which go into .bss section (zero-initialized data) */ 13 | .bss 14 | 15 | prev_temp: .long 0 16 | prev_pressure: .long 0 17 | prev_pressure2: .long 0 18 | 19 | .global counter 20 | counter: .long 0 21 | 22 | .global stack 23 | stack: 24 | .skip 100 25 | .global stackEnd 26 | stackEnd: 27 | .long 0 28 | 29 | 30 | /* Code goes into .text section */ 31 | .text 32 | .global entry 33 | entry: 34 | move r3,stackEnd 35 | 36 | // Read the BMP-180 every 4 timer cycles: 37 | move r1,counter 38 | ld r0,r1,0 39 | add r0,r0,1 40 | st r0,r1,0 // increment counter 41 | and r0,r0,0x3 42 | jumpr waitNext,1,ge 43 | 44 | // GPIO2 LED ON 45 | WRITE_RTC_REG(RTC_GPIO_OUT_REG, RTC_GPIO_OUT_DATA_S + 12, 1, 1) 46 | 47 | psr 48 | jump readBMP 49 | 50 | // GPIO2 LED OFF 51 | WRITE_RTC_REG(RTC_GPIO_OUT_REG, RTC_GPIO_OUT_DATA_S + 12, 1, 0) 52 | 53 | /* wake up after significant change */ 54 | move r1,pressure 55 | ld r0,r1,0 56 | move r1,prev_pressure 57 | ld r2,r1,0 58 | sub r0,r0,r2 59 | psr 60 | jump abs 61 | jumpr testTemp,6,lt 62 | jump wakeUp 63 | 64 | testTemp: 65 | move r1,temp 66 | ld r0,r1,0 67 | move r1,prev_temp 68 | ld r2,r1,0 69 | sub r0,r0,r2 70 | psr 71 | jump abs 72 | jumpr waitNext,10,lt 73 | 74 | wakeUp: 75 | /* save new pressure and temp */ 76 | move r1,pressure 77 | ld r0,r1,0 78 | move r1,prev_pressure 79 | st r0,r1,0 80 | move r1,temp 81 | ld r0,r1,0 82 | move r1,prev_temp 83 | st r0,r1,0 84 | /* Wake up the SoC, end program */ 85 | wake 86 | /* Stop the wakeup timer so it does not restart ULP */ 87 | WRITE_RTC_FIELD(RTC_CNTL_STATE0_REG, RTC_CNTL_ULP_CP_SLP_TIMER_EN, 0) 88 | 89 | waitNext: 90 | halt 91 | 92 | // Compute abs value of R0 93 | abs: 94 | and r1,r0,0x8000 95 | jump noNegate,eq 96 | move r1,0 97 | sub r0,r1,r0 98 | noNegate: 99 | ret 100 | -------------------------------------------------------------------------------- /main/ulp/stack.S: -------------------------------------------------------------------------------- 1 | /* 2 | * ULP stack and subroutine macros 3 | */ 4 | 5 | .macro push rx 6 | st \rx,r3,0 7 | sub r3,r3,1 8 | .endm 9 | 10 | .macro pop rx 11 | add r3,r3,1 12 | ld \rx,r3,0 13 | .endm 14 | 15 | // Prepare subroutine jump, uses scratch register sr 16 | .macro psr sr=r1 pos=. 17 | .set _next2,(\pos+16) 18 | move \sr,_next2 19 | push \sr 20 | .endm 21 | 22 | // Return from subroutine 23 | .macro ret sr=r1 24 | pop \sr 25 | jump \sr 26 | .endm 27 | -------------------------------------------------------------------------------- /main/ulp_example_main.c: -------------------------------------------------------------------------------- 1 | /* ULP I2C bit bang BMP-180 Example 2 | 3 | This example code is in the Public Domain (or CC0 licensed, at your option.) 4 | 5 | Unless required by applicable law or agreed to in writing, this 6 | software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR 7 | CONDITIONS OF ANY KIND, either express or implied. 8 | */ 9 | 10 | #include 11 | #include 12 | #include "esp_sleep.h" 13 | #include "nvs.h" 14 | #include "nvs_flash.h" 15 | #include "soc/rtc_cntl_reg.h" 16 | #include "soc/rtc_io_reg.h" 17 | #include "soc/sens_reg.h" 18 | #include "soc/soc.h" 19 | #include "driver/gpio.h" 20 | #include "driver/rtc_io.h" 21 | #include "esp32/ulp.h" 22 | #include "freertos/FreeRTOS.h" 23 | #include "freertos/task.h" 24 | #include "sdkconfig.h" 25 | 26 | #include "ulp_main.h" 27 | 28 | extern const uint8_t ulp_main_bin_start[] asm("_binary_ulp_main_bin_start"); 29 | extern const uint8_t ulp_main_bin_end[] asm("_binary_ulp_main_bin_end"); 30 | 31 | 32 | const gpio_num_t gpio_led = GPIO_NUM_2; 33 | const gpio_num_t gpio_scl = GPIO_NUM_32; 34 | const gpio_num_t gpio_sda = GPIO_NUM_33; 35 | //const gpio_num_t gpio_builtin = GPIO_NUM_22; 36 | 37 | 38 | static void init_ulp_program() 39 | { 40 | rtc_gpio_init(gpio_led); 41 | rtc_gpio_set_direction(gpio_led, RTC_GPIO_MODE_OUTPUT_ONLY); 42 | 43 | rtc_gpio_init(gpio_scl); 44 | rtc_gpio_set_direction(gpio_scl, RTC_GPIO_MODE_INPUT_ONLY); 45 | rtc_gpio_init(gpio_sda); 46 | rtc_gpio_set_direction(gpio_sda, RTC_GPIO_MODE_INPUT_ONLY); 47 | 48 | esp_err_t err = ulp_load_binary(0, ulp_main_bin_start, 49 | (ulp_main_bin_end - ulp_main_bin_start) / sizeof(uint32_t)); 50 | ESP_ERROR_CHECK(err); 51 | 52 | /* Set ULP wake up period to T = 1000ms 53 | * Minimum pulse width has to be T * (ulp_debounce_counter + 1) = 80ms. 54 | */ 55 | REG_SET_FIELD(SENS_ULP_CP_SLEEP_CYC0_REG, SENS_SLEEP_CYCLES_S0, 150000); 56 | 57 | } 58 | 59 | 60 | #define ac1 ((short)ulp_ac1) 61 | #define ac2 ((short)ulp_ac2) 62 | #define ac3 ((short)ulp_ac3) 63 | #define ac4 ((uint16_t)ulp_ac4) 64 | #define ac5 ((uint16_t)ulp_ac5) 65 | #define ac6 ((uint16_t)ulp_ac6) 66 | #define b1 ((short)ulp_b1) 67 | #define b2 ((short)ulp_b2) 68 | #define mb ((short)ulp_mb) 69 | #define mc ((short)ulp_mc) 70 | #define md ((short)ulp_md) 71 | 72 | int computeB5(int32_t UT) { 73 | int32_t X1 = (UT - (int32_t)ac6) * ((int32_t)ac5) >> 15; 74 | int32_t X2 = ((int32_t)mc << 11) / (X1+(int32_t)md); 75 | return X1 + X2; 76 | } 77 | 78 | static void print_status() 79 | { 80 | // printf("%d ", ac1); 81 | // printf("%d ", ac2); 82 | // printf("%d ", ac3); 83 | // printf("%d ", ac4); 84 | // printf("%d ", ac5); 85 | // printf("%d\n", ac6); 86 | // printf("%d ", b1); 87 | // printf("%d ", b2); 88 | // printf("%d ", mb); 89 | // printf("%d ", mc); 90 | // printf("%d ", md); 91 | // printf("\n"); 92 | 93 | printf("rawT: %d Address: 0x%04x counter: %d\n", ulp_temp & 0xFFFF, ulp_temp >> 19, ulp_counter & 0xFFFF); 94 | printf("rawP1/2: %d %d\n", ulp_pressure & 0xFFFF, ulp_pressure2 & 0xFFFF); 95 | 96 | int oversampling= 1; 97 | 98 | int32_t UP= ((((ulp_pressure & 0xFFFF) << 8) | (ulp_pressure2 & 0xFFFF)) >> (8-oversampling)); 99 | int32_t B3, B5, B6, X1, X2, X3, p; 100 | uint32_t B4, B7; 101 | 102 | float temp; 103 | B5 = computeB5(ulp_temp & 0xFFFF); 104 | temp = (B5+8) / 16.0; 105 | temp /= 10; 106 | printf("\nTemperature: %.2f\n", temp); 107 | 108 | // do pressure calcs 109 | B6 = B5 - 4000; 110 | X1 = ((int32_t)b2 * ( (B6 * B6)>>12 )) >> 11; 111 | X2 = ((int32_t)ac2 * B6) >> 11; 112 | X3 = X1 + X2; 113 | B3 = ((((int32_t)ac1*4 + X3) << oversampling) + 2) / 4; 114 | 115 | X1 = ((int32_t)ac3 * B6) >> 13; 116 | X2 = ((int32_t)b1 * ((B6 * B6) >> 12)) >> 16; 117 | X3 = ((X1 + X2) + 2) >> 2; 118 | B4 = ((uint32_t)ac4 * (uint32_t)(X3 + 32768)) >> 15; 119 | B7 = ((uint32_t)UP - B3) * (uint32_t)( 50000UL >> oversampling ); 120 | 121 | if (B7 < 0x80000000) { 122 | p = (B7 * 2) / B4; 123 | } else { 124 | p = (B7 / B4) * 2; 125 | } 126 | X1 = (p >> 8) * (p >> 8); 127 | X1 = (X1 * 3038) >> 16; 128 | X2 = (-7357 * p) >> 16; 129 | 130 | p = p + ((X1 + X2 + (int32_t)3791)>>4); 131 | float pressure = p, altitude_meters= 3; 132 | printf("Pressure: %.2f\n\n", (pressure / pow(1.0-altitude_meters/44330, 5.255))/100.0); 133 | } 134 | 135 | void app_main() 136 | { 137 | esp_sleep_wakeup_cause_t cause = esp_sleep_get_wakeup_cause(); 138 | if (cause != ESP_SLEEP_WAKEUP_ULP) { 139 | printf("Not ULP wakeup, initializing ULP\n"); 140 | init_ulp_program(); 141 | } else { 142 | 143 | printf("ULP wakeup, printing status\n"); 144 | print_status(); 145 | } 146 | 147 | printf("Entering deep sleep\n\n"); 148 | 149 | ESP_ERROR_CHECK( esp_sleep_enable_ulp_wakeup() ); 150 | 151 | /* Start the program */ 152 | esp_err_t err = ulp_run(&ulp_entry - RTC_SLOW_MEM); 153 | ESP_ERROR_CHECK(err); 154 | 155 | esp_deep_sleep_start(); 156 | } 157 | -------------------------------------------------------------------------------- /sdkconfig: -------------------------------------------------------------------------------- 1 | # 2 | # Automatically generated file; DO NOT EDIT. 3 | # Espressif IoT Development Framework Configuration 4 | # 5 | 6 | # 7 | # SDK tool configuration 8 | # 9 | CONFIG_TOOLPREFIX="xtensa-esp32-elf-" 10 | CONFIG_PYTHON="python" 11 | CONFIG_MAKE_WARN_UNDEFINED_VARIABLES=y 12 | 13 | # 14 | # Bootloader config 15 | # 16 | CONFIG_LOG_BOOTLOADER_LEVEL_NONE=y 17 | CONFIG_LOG_BOOTLOADER_LEVEL_ERROR= 18 | CONFIG_LOG_BOOTLOADER_LEVEL_WARN= 19 | CONFIG_LOG_BOOTLOADER_LEVEL_INFO= 20 | CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG= 21 | CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE= 22 | CONFIG_LOG_BOOTLOADER_LEVEL=0 23 | 24 | # 25 | # Security features 26 | # 27 | CONFIG_SECURE_BOOT_ENABLED= 28 | CONFIG_FLASH_ENCRYPTION_ENABLED= 29 | 30 | # 31 | # Serial flasher config 32 | # 33 | CONFIG_ESPTOOLPY_PORT="/dev/ttyUSB0" 34 | CONFIG_ESPTOOLPY_BAUD_115200B= 35 | CONFIG_ESPTOOLPY_BAUD_230400B= 36 | CONFIG_ESPTOOLPY_BAUD_921600B=y 37 | CONFIG_ESPTOOLPY_BAUD_2MB= 38 | CONFIG_ESPTOOLPY_BAUD_OTHER= 39 | CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 40 | CONFIG_ESPTOOLPY_BAUD=921600 41 | CONFIG_ESPTOOLPY_COMPRESSED=y 42 | CONFIG_FLASHMODE_QIO= 43 | CONFIG_FLASHMODE_QOUT= 44 | CONFIG_FLASHMODE_DIO=y 45 | CONFIG_FLASHMODE_DOUT= 46 | CONFIG_ESPTOOLPY_FLASHMODE="dio" 47 | CONFIG_ESPTOOLPY_FLASHFREQ_80M= 48 | CONFIG_ESPTOOLPY_FLASHFREQ_40M=y 49 | CONFIG_ESPTOOLPY_FLASHFREQ_26M= 50 | CONFIG_ESPTOOLPY_FLASHFREQ_20M= 51 | CONFIG_ESPTOOLPY_FLASHFREQ="40m" 52 | CONFIG_ESPTOOLPY_FLASHSIZE_1MB= 53 | CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y 54 | CONFIG_ESPTOOLPY_FLASHSIZE_4MB= 55 | CONFIG_ESPTOOLPY_FLASHSIZE_8MB= 56 | CONFIG_ESPTOOLPY_FLASHSIZE_16MB= 57 | CONFIG_ESPTOOLPY_FLASHSIZE="2MB" 58 | CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y 59 | CONFIG_ESPTOOLPY_BEFORE_RESET=y 60 | CONFIG_ESPTOOLPY_BEFORE_NORESET= 61 | CONFIG_ESPTOOLPY_BEFORE="default_reset" 62 | CONFIG_ESPTOOLPY_AFTER_RESET=y 63 | CONFIG_ESPTOOLPY_AFTER_NORESET= 64 | CONFIG_ESPTOOLPY_AFTER="hard_reset" 65 | CONFIG_MONITOR_BAUD_9600B= 66 | CONFIG_MONITOR_BAUD_57600B= 67 | CONFIG_MONITOR_BAUD_115200B=y 68 | CONFIG_MONITOR_BAUD_230400B= 69 | CONFIG_MONITOR_BAUD_921600B= 70 | CONFIG_MONITOR_BAUD_2MB= 71 | CONFIG_MONITOR_BAUD_OTHER= 72 | CONFIG_MONITOR_BAUD_OTHER_VAL=115200 73 | CONFIG_MONITOR_BAUD=115200 74 | 75 | # 76 | # Partition Table 77 | # 78 | CONFIG_PARTITION_TABLE_SINGLE_APP=y 79 | CONFIG_PARTITION_TABLE_TWO_OTA= 80 | CONFIG_PARTITION_TABLE_CUSTOM= 81 | CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" 82 | CONFIG_PARTITION_TABLE_CUSTOM_APP_BIN_OFFSET=0x10000 83 | CONFIG_PARTITION_TABLE_FILENAME="partitions_singleapp.csv" 84 | CONFIG_APP_OFFSET=0x10000 85 | 86 | # 87 | # Compiler options 88 | # 89 | CONFIG_OPTIMIZATION_LEVEL_DEBUG= 90 | CONFIG_OPTIMIZATION_LEVEL_RELEASE=y 91 | CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y 92 | CONFIG_OPTIMIZATION_ASSERTIONS_SILENT= 93 | CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED= 94 | 95 | # 96 | # Component config 97 | # 98 | 99 | # 100 | # Application Level Tracing 101 | # 102 | CONFIG_ESP32_APPTRACE_DEST_TRAX= 103 | CONFIG_ESP32_APPTRACE_DEST_NONE=y 104 | CONFIG_ESP32_APPTRACE_ENABLE= 105 | CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y 106 | 107 | # 108 | # FreeRTOS SystemView Tracing 109 | # 110 | CONFIG_AWS_IOT_SDK= 111 | CONFIG_BT_ENABLED= 112 | CONFIG_BT_RESERVE_DRAM=0 113 | 114 | # 115 | # ESP32-specific 116 | # 117 | CONFIG_ESP32_DEFAULT_CPU_FREQ_80= 118 | CONFIG_ESP32_DEFAULT_CPU_FREQ_160=y 119 | CONFIG_ESP32_DEFAULT_CPU_FREQ_240= 120 | CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=160 121 | CONFIG_MEMMAP_SMP=y 122 | CONFIG_SPIRAM_SUPPORT= 123 | CONFIG_MEMMAP_TRACEMEM= 124 | CONFIG_MEMMAP_TRACEMEM_TWOBANKS= 125 | CONFIG_ESP32_TRAX= 126 | CONFIG_TRACEMEM_RESERVE_DRAM=0x0 127 | CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH= 128 | CONFIG_ESP32_ENABLE_COREDUMP_TO_UART= 129 | CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y 130 | CONFIG_ESP32_ENABLE_COREDUMP= 131 | CONFIG_TWO_UNIVERSAL_MAC_ADDRESS= 132 | CONFIG_FOUR_UNIVERSAL_MAC_ADDRESS=y 133 | CONFIG_NUMBER_OF_UNIVERSAL_MAC_ADDRESS=4 134 | CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 135 | CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=4096 136 | CONFIG_MAIN_TASK_STACK_SIZE=4096 137 | CONFIG_IPC_TASK_STACK_SIZE=1024 138 | CONFIG_TIMER_TASK_STACK_SIZE=4096 139 | CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y 140 | CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF= 141 | CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR= 142 | CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF= 143 | CONFIG_NEWLIB_STDIN_LINE_ENDING_LF= 144 | CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y 145 | CONFIG_NEWLIB_NANO_FORMAT= 146 | CONFIG_CONSOLE_UART_DEFAULT=y 147 | CONFIG_CONSOLE_UART_CUSTOM= 148 | CONFIG_CONSOLE_UART_NONE= 149 | CONFIG_CONSOLE_UART_NUM=0 150 | CONFIG_CONSOLE_UART_BAUDRATE=115200 151 | CONFIG_ULP_COPROC_ENABLED=y 152 | CONFIG_ULP_COPROC_RESERVE_MEM=2048 153 | CONFIG_ESP32_PANIC_PRINT_HALT= 154 | CONFIG_ESP32_PANIC_PRINT_REBOOT=y 155 | CONFIG_ESP32_PANIC_SILENT_REBOOT= 156 | CONFIG_ESP32_PANIC_GDBSTUB= 157 | CONFIG_ESP32_DEBUG_OCDAWARE=y 158 | CONFIG_INT_WDT=y 159 | CONFIG_INT_WDT_TIMEOUT_MS=300 160 | CONFIG_INT_WDT_CHECK_CPU1=y 161 | CONFIG_TASK_WDT=y 162 | CONFIG_TASK_WDT_PANIC= 163 | CONFIG_TASK_WDT_TIMEOUT_S=5 164 | CONFIG_TASK_WDT_CHECK_IDLE_TASK=y 165 | CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1=y 166 | CONFIG_BROWNOUT_DET=y 167 | CONFIG_BROWNOUT_DET_LVL_SEL_0=y 168 | CONFIG_BROWNOUT_DET_LVL_SEL_1= 169 | CONFIG_BROWNOUT_DET_LVL_SEL_2= 170 | CONFIG_BROWNOUT_DET_LVL_SEL_3= 171 | CONFIG_BROWNOUT_DET_LVL_SEL_4= 172 | CONFIG_BROWNOUT_DET_LVL_SEL_5= 173 | CONFIG_BROWNOUT_DET_LVL_SEL_6= 174 | CONFIG_BROWNOUT_DET_LVL_SEL_7= 175 | CONFIG_BROWNOUT_DET_LVL=0 176 | CONFIG_ESP32_TIME_SYSCALL_USE_RTC= 177 | CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y 178 | CONFIG_ESP32_TIME_SYSCALL_USE_FRC1= 179 | CONFIG_ESP32_TIME_SYSCALL_USE_NONE= 180 | CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC=y 181 | CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL= 182 | CONFIG_ESP32_RTC_CLK_CAL_CYCLES=1024 183 | CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=900 184 | CONFIG_ESP32_XTAL_FREQ_40= 185 | CONFIG_ESP32_XTAL_FREQ_26= 186 | CONFIG_ESP32_XTAL_FREQ_AUTO=y 187 | CONFIG_ESP32_XTAL_FREQ=0 188 | CONFIG_DISABLE_BASIC_ROM_CONSOLE= 189 | CONFIG_NO_BLOBS= 190 | 191 | # 192 | # Wi-Fi 193 | # 194 | CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 195 | CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 196 | CONFIG_ESP32_WIFI_STATIC_TX_BUFFER= 197 | CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y 198 | CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1 199 | CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32 200 | CONFIG_ESP32_WIFI_AMPDU_ENABLED=y 201 | CONFIG_ESP32_WIFI_TX_BA_WIN=6 202 | CONFIG_ESP32_WIFI_RX_BA_WIN=6 203 | CONFIG_ESP32_WIFI_NVS_ENABLED=y 204 | 205 | # 206 | # PHY 207 | # 208 | CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y 209 | CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION= 210 | CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 211 | CONFIG_ESP32_PHY_MAX_TX_POWER=20 212 | 213 | # 214 | # Ethernet 215 | # 216 | CONFIG_DMA_RX_BUF_NUM=10 217 | CONFIG_DMA_TX_BUF_NUM=10 218 | CONFIG_EMAC_L2_TO_L3_RX_BUF_MODE= 219 | CONFIG_EMAC_TASK_PRIORITY=20 220 | 221 | # 222 | # FAT Filesystem support 223 | # 224 | CONFIG_FATFS_CODEPAGE_ASCII=y 225 | CONFIG_FATFS_CODEPAGE_437= 226 | CONFIG_FATFS_CODEPAGE_720= 227 | CONFIG_FATFS_CODEPAGE_737= 228 | CONFIG_FATFS_CODEPAGE_771= 229 | CONFIG_FATFS_CODEPAGE_775= 230 | CONFIG_FATFS_CODEPAGE_850= 231 | CONFIG_FATFS_CODEPAGE_852= 232 | CONFIG_FATFS_CODEPAGE_855= 233 | CONFIG_FATFS_CODEPAGE_857= 234 | CONFIG_FATFS_CODEPAGE_860= 235 | CONFIG_FATFS_CODEPAGE_861= 236 | CONFIG_FATFS_CODEPAGE_862= 237 | CONFIG_FATFS_CODEPAGE_863= 238 | CONFIG_FATFS_CODEPAGE_864= 239 | CONFIG_FATFS_CODEPAGE_865= 240 | CONFIG_FATFS_CODEPAGE_866= 241 | CONFIG_FATFS_CODEPAGE_869= 242 | CONFIG_FATFS_CODEPAGE_932= 243 | CONFIG_FATFS_CODEPAGE_936= 244 | CONFIG_FATFS_CODEPAGE_949= 245 | CONFIG_FATFS_CODEPAGE_950= 246 | CONFIG_FATFS_CODEPAGE=1 247 | CONFIG_FATFS_MAX_LFN=255 248 | 249 | # 250 | # FreeRTOS 251 | # 252 | CONFIG_FREERTOS_UNICORE= 253 | CONFIG_FREERTOS_CORETIMER_0=y 254 | CONFIG_FREERTOS_CORETIMER_1= 255 | CONFIG_FREERTOS_HZ=100 256 | CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y 257 | CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE= 258 | CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL= 259 | CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY=y 260 | CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK= 261 | CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y 262 | CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=1 263 | CONFIG_FREERTOS_ASSERT_FAIL_ABORT=y 264 | CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE= 265 | CONFIG_FREERTOS_ASSERT_DISABLE= 266 | CONFIG_FREERTOS_BREAK_ON_SCHEDULER_START_JTAG=y 267 | CONFIG_ENABLE_MEMORY_DEBUG= 268 | CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1024 269 | CONFIG_FREERTOS_ISR_STACKSIZE=1536 270 | CONFIG_FREERTOS_LEGACY_HOOKS= 271 | CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16 272 | CONFIG_SUPPORT_STATIC_ALLOCATION= 273 | CONFIG_TIMER_TASK_PRIORITY=1 274 | CONFIG_TIMER_TASK_STACK_DEPTH=2048 275 | CONFIG_TIMER_QUEUE_LENGTH=10 276 | CONFIG_FREERTOS_DEBUG_INTERNALS= 277 | 278 | # 279 | # Heap memory debugging 280 | # 281 | CONFIG_HEAP_POISONING_DISABLED=y 282 | CONFIG_HEAP_POISONING_LIGHT= 283 | CONFIG_HEAP_POISONING_COMPREHENSIVE= 284 | CONFIG_HEAP_TRACING= 285 | 286 | # 287 | # Log output 288 | # 289 | CONFIG_LOG_DEFAULT_LEVEL_NONE=y 290 | CONFIG_LOG_DEFAULT_LEVEL_ERROR= 291 | CONFIG_LOG_DEFAULT_LEVEL_WARN= 292 | CONFIG_LOG_DEFAULT_LEVEL_INFO= 293 | CONFIG_LOG_DEFAULT_LEVEL_DEBUG= 294 | CONFIG_LOG_DEFAULT_LEVEL_VERBOSE= 295 | CONFIG_LOG_DEFAULT_LEVEL=0 296 | CONFIG_LOG_COLORS=y 297 | 298 | # 299 | # LWIP 300 | # 301 | CONFIG_L2_TO_L3_COPY= 302 | CONFIG_LWIP_MAX_SOCKETS=10 303 | CONFIG_LWIP_THREAD_LOCAL_STORAGE_INDEX=0 304 | CONFIG_LWIP_SO_REUSE= 305 | CONFIG_LWIP_SO_RCVBUF= 306 | CONFIG_LWIP_DHCP_MAX_NTP_SERVERS=1 307 | CONFIG_LWIP_IP_FRAG= 308 | CONFIG_LWIP_IP_REASSEMBLY= 309 | CONFIG_LWIP_STATS= 310 | CONFIG_LWIP_ETHARP_TRUST_IP_MAC=y 311 | CONFIG_TCPIP_RECVMBOX_SIZE=32 312 | 313 | # 314 | # TCP 315 | # 316 | CONFIG_TCP_MAXRTX=12 317 | CONFIG_TCP_SYNMAXRTX=6 318 | CONFIG_TCP_MSS=1436 319 | CONFIG_TCP_MSL=60000 320 | CONFIG_TCP_SND_BUF_DEFAULT=5744 321 | CONFIG_TCP_WND_DEFAULT=5744 322 | CONFIG_TCP_RECVMBOX_SIZE=6 323 | CONFIG_TCP_QUEUE_OOSEQ=y 324 | CONFIG_TCP_OVERSIZE_MSS=y 325 | CONFIG_TCP_OVERSIZE_QUARTER_MSS= 326 | CONFIG_TCP_OVERSIZE_DISABLE= 327 | 328 | # 329 | # UDP 330 | # 331 | CONFIG_UDP_RECVMBOX_SIZE=6 332 | CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y 333 | CONFIG_TCPIP_TASK_STACK_SIZE=2560 334 | CONFIG_PPP_SUPPORT= 335 | 336 | # 337 | # ICMP 338 | # 339 | CONFIG_LWIP_MULTICAST_PING= 340 | CONFIG_LWIP_BROADCAST_PING= 341 | 342 | # 343 | # mbedTLS 344 | # 345 | CONFIG_MBEDTLS_SSL_MAX_CONTENT_LEN=16384 346 | CONFIG_MBEDTLS_DEBUG= 347 | CONFIG_MBEDTLS_HARDWARE_AES=y 348 | CONFIG_MBEDTLS_HARDWARE_MPI=y 349 | CONFIG_MBEDTLS_MPI_USE_INTERRUPT=y 350 | CONFIG_MBEDTLS_HARDWARE_SHA=y 351 | CONFIG_MBEDTLS_HAVE_TIME=y 352 | CONFIG_MBEDTLS_HAVE_TIME_DATE= 353 | CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y 354 | CONFIG_MBEDTLS_TLS_SERVER_ONLY= 355 | CONFIG_MBEDTLS_TLS_CLIENT_ONLY= 356 | CONFIG_MBEDTLS_TLS_DISABLED= 357 | CONFIG_MBEDTLS_TLS_SERVER=y 358 | CONFIG_MBEDTLS_TLS_CLIENT=y 359 | CONFIG_MBEDTLS_TLS_ENABLED=y 360 | 361 | # 362 | # TLS Key Exchange Methods 363 | # 364 | CONFIG_MBEDTLS_PSK_MODES= 365 | CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y 366 | CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA=y 367 | CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE=y 368 | CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=y 369 | CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=y 370 | CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y 371 | CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y 372 | CONFIG_MBEDTLS_SSL_RENEGOTIATION=y 373 | CONFIG_MBEDTLS_SSL_PROTO_SSL3= 374 | CONFIG_MBEDTLS_SSL_PROTO_TLS1=y 375 | CONFIG_MBEDTLS_SSL_PROTO_TLS1_1=y 376 | CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y 377 | CONFIG_MBEDTLS_SSL_PROTO_DTLS= 378 | CONFIG_MBEDTLS_SSL_ALPN=y 379 | CONFIG_MBEDTLS_SSL_SESSION_TICKETS=y 380 | 381 | # 382 | # Symmetric Ciphers 383 | # 384 | CONFIG_MBEDTLS_AES_C=y 385 | CONFIG_MBEDTLS_CAMELLIA_C= 386 | CONFIG_MBEDTLS_DES_C= 387 | CONFIG_MBEDTLS_RC4_DISABLED=y 388 | CONFIG_MBEDTLS_RC4_ENABLED_NO_DEFAULT= 389 | CONFIG_MBEDTLS_RC4_ENABLED= 390 | CONFIG_MBEDTLS_BLOWFISH_C= 391 | CONFIG_MBEDTLS_XTEA_C= 392 | CONFIG_MBEDTLS_CCM_C=y 393 | CONFIG_MBEDTLS_GCM_C=y 394 | CONFIG_MBEDTLS_RIPEMD160_C= 395 | 396 | # 397 | # Certificates 398 | # 399 | CONFIG_MBEDTLS_PEM_PARSE_C=y 400 | CONFIG_MBEDTLS_PEM_WRITE_C=y 401 | CONFIG_MBEDTLS_X509_CRL_PARSE_C=y 402 | CONFIG_MBEDTLS_X509_CSR_PARSE_C=y 403 | CONFIG_MBEDTLS_ECP_C=y 404 | CONFIG_MBEDTLS_ECDH_C=y 405 | CONFIG_MBEDTLS_ECDSA_C=y 406 | CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED=y 407 | CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED=y 408 | CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y 409 | CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y 410 | CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y 411 | CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED=y 412 | CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED=y 413 | CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y 414 | CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y 415 | CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y 416 | CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y 417 | CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y 418 | CONFIG_MBEDTLS_ECP_NIST_OPTIM=y 419 | 420 | # 421 | # OpenSSL 422 | # 423 | CONFIG_OPENSSL_DEBUG= 424 | CONFIG_OPENSSL_ASSERT_DO_NOTHING=y 425 | CONFIG_OPENSSL_ASSERT_EXIT= 426 | 427 | # 428 | # PThreads 429 | # 430 | CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5 431 | CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=2048 432 | 433 | # 434 | # SPI Flash driver 435 | # 436 | CONFIG_SPI_FLASH_ENABLE_COUNTERS= 437 | CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y 438 | 439 | # 440 | # SPIFFS Configuration 441 | # 442 | CONFIG_SPIFFS_MAX_PARTITIONS=3 443 | 444 | # 445 | # SPIFFS Cache Configuration 446 | # 447 | CONFIG_SPIFFS_CACHE=y 448 | CONFIG_SPIFFS_CACHE_WR=y 449 | CONFIG_SPIFFS_CACHE_STATS= 450 | CONFIG_SPIFFS_PAGE_CHECK=y 451 | CONFIG_SPIFFS_GC_MAX_RUNS=10 452 | CONFIG_SPIFFS_GC_STATS= 453 | CONFIG_SPIFFS_OBJ_NAME_LEN=32 454 | CONFIG_SPIFFS_USE_MAGIC=y 455 | CONFIG_SPIFFS_USE_MAGIC_LENGTH=y 456 | 457 | # 458 | # Debug Configuration 459 | # 460 | CONFIG_SPIFFS_DBG= 461 | CONFIG_SPIFFS_API_DBG= 462 | CONFIG_SPIFFS_GC_DBG= 463 | CONFIG_SPIFFS_CACHE_DBG= 464 | CONFIG_SPIFFS_CHECK_DBG= 465 | CONFIG_SPIFFS_TEST_VISUALISATION= 466 | 467 | # 468 | # tcpip adapter 469 | # 470 | CONFIG_IP_LOST_TIMER_INTERVAL=120 471 | 472 | # 473 | # Wear Levelling 474 | # 475 | CONFIG_WL_SECTOR_SIZE_512= 476 | CONFIG_WL_SECTOR_SIZE_4096=y 477 | CONFIG_WL_SECTOR_SIZE=4096 478 | --------------------------------------------------------------------------------