From f985f7be553ee74112cd110a4441d45eb8bcebc4 Mon Sep 17 00:00:00 2001 From: RicardoEA <ricardo@focus.uy> Date: Tue, 18 Oct 2022 16:06:02 -0300 Subject: [PATCH] Initial commit The initial commit is based on the code done by Guillermo in order to control the Robotito. --- .gitignore | 1 + Robotito/.gitignore | 10 + Robotito/.vscode/extensions.json | 10 + Robotito/.vscode/settings.json | 6 + Robotito/CMakeLists.txt | 3 + Robotito/include/README | 39 + Robotito/include/control.h | 84 + Robotito/include/encoders.h | 35 + Robotito/include/hwTimer.h | 130 ++ Robotito/include/math_vector_operations.h | 65 + Robotito/include/motors.h | 31 + Robotito/lib/README | 46 + Robotito/platformio.ini | 14 + Robotito/sdkconfig.esp32thing | 1393 +++++++++++++++++ Robotito/src/CMakeLists.txt | 6 + Robotito/src/control/CMakeLists.txt | 3 + Robotito/src/control/control.c | 221 +++ Robotito/src/control/include/control.h | 84 + Robotito/src/encoders/CMakeLists.txt | 2 + Robotito/src/encoders/encoders.c | 319 ++++ Robotito/src/encoders/include/encoders.h | 35 + Robotito/src/hwTimer/CMakeLists.txt | 2 + Robotito/src/hwTimer/hwTimer.c | 277 ++++ Robotito/src/hwTimer/include/hwTimer.h | 130 ++ Robotito/src/main.c | 113 ++ .../src/math_vector_operations/CMakeLists.txt | 2 + .../include/math_vector_operations.h | 65 + .../math_vector_operations.c | 71 + Robotito/src/motors/CMakeLists.txt | 2 + Robotito/src/motors/include/motors.h | 31 + Robotito/src/motors/motors.c | 117 ++ Robotito/test/README | 11 + 32 files changed, 3358 insertions(+) create mode 100644 .gitignore create mode 100644 Robotito/.gitignore create mode 100644 Robotito/.vscode/extensions.json create mode 100644 Robotito/.vscode/settings.json create mode 100644 Robotito/CMakeLists.txt create mode 100644 Robotito/include/README create mode 100644 Robotito/include/control.h create mode 100644 Robotito/include/encoders.h create mode 100644 Robotito/include/hwTimer.h create mode 100644 Robotito/include/math_vector_operations.h create mode 100644 Robotito/include/motors.h create mode 100644 Robotito/lib/README create mode 100644 Robotito/platformio.ini create mode 100644 Robotito/sdkconfig.esp32thing create mode 100644 Robotito/src/CMakeLists.txt create mode 100644 Robotito/src/control/CMakeLists.txt create mode 100644 Robotito/src/control/control.c create mode 100644 Robotito/src/control/include/control.h create mode 100644 Robotito/src/encoders/CMakeLists.txt create mode 100644 Robotito/src/encoders/encoders.c create mode 100644 Robotito/src/encoders/include/encoders.h create mode 100644 Robotito/src/hwTimer/CMakeLists.txt create mode 100644 Robotito/src/hwTimer/hwTimer.c create mode 100644 Robotito/src/hwTimer/include/hwTimer.h create mode 100644 Robotito/src/main.c create mode 100644 Robotito/src/math_vector_operations/CMakeLists.txt create mode 100644 Robotito/src/math_vector_operations/include/math_vector_operations.h create mode 100644 Robotito/src/math_vector_operations/math_vector_operations.c create mode 100644 Robotito/src/motors/CMakeLists.txt create mode 100644 Robotito/src/motors/include/motors.h create mode 100644 Robotito/src/motors/motors.c create mode 100644 Robotito/test/README diff --git a/.gitignore b/.gitignore new file mode 100644 index 0000000..e43b0f9 --- /dev/null +++ b/.gitignore @@ -0,0 +1 @@ +.DS_Store diff --git a/Robotito/.gitignore b/Robotito/.gitignore new file mode 100644 index 0000000..759fbd4 --- /dev/null +++ b/Robotito/.gitignore @@ -0,0 +1,10 @@ +.pio +.vscode/.browse.c_cpp.db* +.vscode/c_cpp_properties.json +.vscode/launch.json +.vscode/ipch +.pioenvs +.piolibdeps +.clang_complete +.gcc-flags.json +.pio \ No newline at end of file diff --git a/Robotito/.vscode/extensions.json b/Robotito/.vscode/extensions.json new file mode 100644 index 0000000..080e70d --- /dev/null +++ b/Robotito/.vscode/extensions.json @@ -0,0 +1,10 @@ +{ + // See http://go.microsoft.com/fwlink/?LinkId=827846 + // for the documentation about the extensions.json format + "recommendations": [ + "platformio.platformio-ide" + ], + "unwantedRecommendations": [ + "ms-vscode.cpptools-extension-pack" + ] +} diff --git a/Robotito/.vscode/settings.json b/Robotito/.vscode/settings.json new file mode 100644 index 0000000..13d835d --- /dev/null +++ b/Robotito/.vscode/settings.json @@ -0,0 +1,6 @@ +{ + "files.associations": { + "encoders.h": "c", + "motors.h": "c" + } +} \ No newline at end of file diff --git a/Robotito/CMakeLists.txt b/Robotito/CMakeLists.txt new file mode 100644 index 0000000..bd00ce1 --- /dev/null +++ b/Robotito/CMakeLists.txt @@ -0,0 +1,3 @@ +cmake_minimum_required(VERSION 3.16.0) +include($ENV{IDF_PATH}/tools/cmake/project.cmake) +project(Robotito) diff --git a/Robotito/include/README b/Robotito/include/README new file mode 100644 index 0000000..194dcd4 --- /dev/null +++ b/Robotito/include/README @@ -0,0 +1,39 @@ + +This directory is intended for project header files. + +A header file is a file containing C declarations and macro definitions +to be shared between several project source files. You request the use of a +header file in your project source file (C, C++, etc) located in `src` folder +by including it, with the C preprocessing directive `#include'. + +```src/main.c + +#include "header.h" + +int main (void) +{ + ... +} +``` + +Including a header file produces the same results as copying the header file +into each source file that needs it. Such copying would be time-consuming +and error-prone. With a header file, the related declarations appear +in only one place. If they need to be changed, they can be changed in one +place, and programs that include the header file will automatically use the +new version when next recompiled. The header file eliminates the labor of +finding and changing all the copies as well as the risk that a failure to +find one copy will result in inconsistencies within a program. + +In C, the usual convention is to give header files names that end with `.h'. +It is most portable to use only letters, digits, dashes, and underscores in +header file names, and at most one dot. + +Read more about using header files in official GCC documentation: + +* Include Syntax +* Include Operation +* Once-Only Headers +* Computed Includes + +https://gcc.gnu.org/onlinedocs/cpp/Header-Files.html diff --git a/Robotito/include/control.h b/Robotito/include/control.h new file mode 100644 index 0000000..8470f8c --- /dev/null +++ b/Robotito/include/control.h @@ -0,0 +1,84 @@ +#ifndef CONTROL_H +#define CONTROL_H + +#include <stdint.h> +#include "esp_err.h" +#include "motors.h" +#include "encoders.h" +#include "hwTimer.h" +#include "math_vector_operations.h" + +#define NMOTORS 3 +#define MOTOR_PINS {25,26, 27,28, 29,30} +#define MOTOR_ENC {39,37, 38,36, 34,35} + +#define MOTOR_PWM_SUBUNIT_IO {MCPWM0A, MCPWM0B, MCPWM1A, MCPWM1B, MCPWM2A, MCPWM2B} +#define MOTOR_PWM_SUBUNIT_TIMER {MCPWM_TIMER_0, MCPWM_TIMER_1, MCPWM_TIMER_2} +#define MOTOR_PWM_UNIT MCPWM_UNIT_0 +#define OMNI_PID_NRO_TIMER 0 +#define OMNI_ODOM_NRO_TIMER 2 + +#define OMNI_PID_CTRL_TIMER 0.05 // in seconds +#define OMNI_ODOM_CTRL_TIMER 0.5 // in seconds + +#define MAX_OUTPUT 100.0 +#define WHEEL_DIAMETER 0.038 // in meters +#define WHEEL_RADIUS WHEEL_DIAMETER/2// in meters +#define ROBOT_RADIUS 0.0675 // in meters + +#define ENC_CPR 3 //counts per revolution +#define MOTOR_REDUCTION 50 +#define TICS_PER_REVOLUTION ENC_CPR*MOTOR_REDUCTION +#define RAD_PER_TICK 2*PI/TICS_PER_REVOLUTION +#define M_PER_SEC_TO_TICS_PER_SEC 1/(RAD_PER_TICK*WHEEL_RADIUS) + +#define MAX_SPEED_POWER 90 // power % at which MAX_SPEED_TICS is obtained +#define MAX_SPEED_TICS 1080 //tics/s at MAX_SPEED_POWER + +#define MAX_SPEED_RAD MAX_SPEED_TICS*RAD_PER_TICK // rad/s +#define MAX_SPEED_LIN MAX_SPEED_RAD*WHEEL_DIAMETER / 2 // m/s + +#define TICS_TO_RAD_S RAD_PER_TICK/OMNI_ODOM_CTRL_TIMER + +#define KP 0.01 +#define KI 0.05 +#define KD 0.0 +#define KF MAX_SPEED_POWER/MAX_SPEED_TICS + +typedef struct { + + motor_h_t *driver; + encoder_h_t *encoder; + + int32_t vel_counter; + int32_t odom_counter; + + float target_v; + float accum_error; + float prev_error; + float output; + +} servo_t; + +typedef struct { + float x; + float x_dot; + float y; + float y_dot; + float phi; + float phi_dot; + +} odom_t; + + + +static servo_t motors[NMOTORS]; +static odom_t odometry; + +esp_err_t omni_init(); + +esp_err_t omni_set_enable(bool start); + +esp_err_t omni_drive(float x_dot ,float y_dot ,float w_dot ,float phi); + +#endif /* CONTROL_H */ \ No newline at end of file diff --git a/Robotito/include/encoders.h b/Robotito/include/encoders.h new file mode 100644 index 0000000..1fe4f76 --- /dev/null +++ b/Robotito/include/encoders.h @@ -0,0 +1,35 @@ +#ifndef ENCODER_H +#define ENCODER_H + +#include <stdint.h> +#include "esp_err.h" + +#define CONFIG_ENCODER_THREAD_STACK_SIZE 8192 +#define CONFIG_ENCODER_THREAD_PRIORITY 20 +#define CONFIG_ENCODER_CPU 0 + +typedef void (*encoder_callback_t)(int, int8_t, uint32_t); + +typedef struct { + int8_t A; ///< A pin + int8_t B; ///< B pin + uint8_t state; ///< Current state's machine state + int32_t counter; ///< Current counter value + encoder_callback_t callback; ///< Callback function + int callback_id; ///< Callback id + uint8_t deferred; ///< Deferred callback? +} encoder_h_t; + +typedef struct { + encoder_h_t *h; + int8_t dir; + uint32_t counter; +} encoder_deferred_data_t; + +esp_err_t encoder_setup(int8_t a, int8_t b, encoder_h_t **h); +esp_err_t encoder_unsetup(encoder_h_t *h); +esp_err_t encoder_read(encoder_h_t *h, int32_t *val); +esp_err_t encoder_write(encoder_h_t *h, int32_t val); +esp_err_t encoder_register_callback(encoder_h_t *h, encoder_callback_t callback, int id, uint8_t deferred); + +#endif /* ENCODER_H */ \ No newline at end of file diff --git a/Robotito/include/hwTimer.h b/Robotito/include/hwTimer.h new file mode 100644 index 0000000..99936eb --- /dev/null +++ b/Robotito/include/hwTimer.h @@ -0,0 +1,130 @@ +#ifndef TIMER_H +#define TIMER_H + +#include "driver/timer.h" +#include <stdint.h> +#include "esp_err.h" + + +#define CONFIG_HWTIMER_THREAD_STACK_SIZE 8192 +#define CONFIG_HWTIMER_THREAD_PRIORITY 10 +#define CPU_LAST_TIMER 3 +#define CPU_FIRST_TIMER 0 + + +typedef struct{ + int8_t unit; +} tmr_alarm_t; + +typedef struct { + uint8_t setup; + void (*callback)(void *); + timer_isr_handle_t isrh; +} tmr_t; + +typedef void(*tmr_isr_t)(void *); + +/** + * @brief Configures a timer. After timer is configured you must start timer using + * tmr_start function. No sanity checks are done (use only in driver develop). + * + * @param unit Hardware timer, from 0 to 3. + * @param micros Period of timer, in microseconds. + * @param callback Callback function to call every micros period. + * @param deferred If 0, the callback are executed in the isr. If 1, the callback + * is deferred and is called outside the interrupt. Non deferred + * callbacks must reside in IRAM. + * + * @return 0 if success, -1 if error (memory error) + * + */ +int tmr_ll_setup(uint8_t unit, uint32_t micros, void(*callback)(void *)); + +/** + * @brief Removes a timer and the resources that uses. + * tmr_start function. No sanity checks are done (use only in driver develop). + * + * @param unit Hardware timer, from 0 to 3. + */ +void tmr_ll_unsetup(uint8_t unit); + +/** + * @brief Start a previous configured timer. No sanity checks are done (use only in driver develop). + * + * @param unit Hardware timer, from 0 to 3. + */ +void tmr_ll_start(uint8_t unit); + +/** + * @brief Stop a previous configured timer. No sanity checks are done (use only in driver develop). + * + * @param unit Hardware timer, from 0 to 3. + */ +void tmr_ll_stop(uint8_t unit); + +/** + * @brief Configures a timer. After timer is configured you must start timer using + * tmr_start function. + * + * @param unit Hardware timer, from 0 to 3. + * @param micros Period of timer, in microseconds. + * @param callback Callback function to call every micros period. + * @param deferred If 0, the callback are executed in the isr. If 1, the callback + * is deferred and is called outside the interrupt. Non deferred + * callbacks must reside in IRAM. + * + * @return + * - NULL success + * - Pointer to driver_error_t if some error occurs. + * + * TIMER_ERR_INVALID_UNIT + * TIMER_ERR_INVALID_PERIOD + * SPI_ERR_DEVICE_IS_NOT_SELECTED + * SPI_ERR_NOT_ENOUGH_MEMORY + */ +esp_err_t tmr_setup(int8_t unit, uint32_t micros, void(*callback)(void *)); + +/** + * @brief Removes a timer and the resources that uses. + * tmr_start function. No sanity checks are done (use only in driver develop). + * + * @param unit Hardware timer, from 0 to 3. + * + * @return + * - NULL success + * - Pointer to driver_error_t if some error occurs. + * + * TIMER_ERR_INVALID_UNIT + */ +esp_err_t tmr_unsetup(int8_t unit); + +/** + * @brief Start a previous configured timer. + * + * @param unit Hardware timer, from 0 to 3. + * + * @return + * - NULL success + * - Pointer to driver_error_t if some error occurs. + * + * TIMER_ERR_IS_NOT_SETUP + */ +esp_err_t tmr_start(int8_t unit); + +/** + * @brief Stop a previous configured timer. + * + * @param unit Hardware timer, from 0 to 3. + * + * @return + * - NULL success + * - Pointer to driver_error_t if some error occurs. + * + * TIMER_ERR_IS_NOT_SETUP + */ +esp_err_t tmr_stop(int8_t unit); + +void get_group_idx(int8_t unit, int *groupn, int *idx); + +#endif /* TIMER_H */ + diff --git a/Robotito/include/math_vector_operations.h b/Robotito/include/math_vector_operations.h new file mode 100644 index 0000000..bedbbd4 --- /dev/null +++ b/Robotito/include/math_vector_operations.h @@ -0,0 +1,65 @@ +#ifndef VECTOR_MATH_H +#define VECTOR_MATH_H + +#include "math.h" + +#define PI 3.1415926535897932384626433832795 +#define PIdiv180 (PI/180.0) +#define SQR(x) (x*x) +#define SGN(x) (x<0?-1:1) +#define ABS(x) (x<0?-x:x) +#define NULL_VECTOR F3dVector(0.0f,0.0f,0.0f) + +///////////////////////////////// +//Note: All angles in degrees // +///////////////////////////////// + +typedef struct { + float x,y,z; +} sF3dVector_t; + +typedef struct { + float x1,y1,z1,x2,y2,z2,x3,y3,z3; +} sF3dMatrix_t; + + +float getLength(sF3dVector_t* v); +void normalize(sF3dVector_t* v); + + +/** + * v = v + v2 +**/ +void sum (sF3dVector_t* v, sF3dVector_t v2); + +/** + * v = v - v2 +**/ + +void difference (sF3dVector_t* v, sF3dVector_t v2); + +/** + * v = v*r +**/ +void float_mul (sF3dVector_t* v, float r); + +/** + * v = v/r +**/ +void float_div (sF3dVector_t* v, float r); + +/** + * ret dot product +**/ +float dotProduct (sF3dVector_t* v, sF3dVector_t v2); + +/** + * ret v = vectorial product +**/ +void crossProduct (sF3dVector_t* v, sF3dVector_t v2); + +/** + * v = M*v +**/ +void vector_mul (sF3dMatrix_t m, sF3dVector_t* v); +#endif /* VECTOR_MATH_H */ \ No newline at end of file diff --git a/Robotito/include/motors.h b/Robotito/include/motors.h new file mode 100644 index 0000000..b2bfbed --- /dev/null +++ b/Robotito/include/motors.h @@ -0,0 +1,31 @@ +/* +Program: Motor Library + +File: Motor.h +*/ +#ifndef DRV8833_h +#define DRV8833_h + +#include <stdint.h> +#include "esp_err.h" +#include "driver/mcpwm.h" + +typedef struct { + int intSpeed; + int8_t pin1; + int8_t pin2; + char info; // bit0: isrunning, bit1: braked + double defaultDuty; + mcpwm_unit_t mcpwm_unit; + mcpwm_io_signals_t mcpwm_a; + mcpwm_io_signals_t mcpwm_b; + mcpwm_timer_t mcpwm_timer; +} motor_h_t; + + +esp_err_t motor_install(int8_t a, int8_t b, mcpwm_unit_t pwm_u, mcpwm_io_signals_t pwm1, mcpwm_io_signals_t pwm2, mcpwm_timer_t t, motor_h_t **m); +esp_err_t motor_set_speed(motor_h_t *m, int intIn); +esp_err_t motor_stop(motor_h_t *m); +esp_err_t motor_start(motor_h_t *m); + +#endif /* DRV8833_h */ \ No newline at end of file diff --git a/Robotito/lib/README b/Robotito/lib/README new file mode 100644 index 0000000..6debab1 --- /dev/null +++ b/Robotito/lib/README @@ -0,0 +1,46 @@ + +This directory is intended for project specific (private) libraries. +PlatformIO will compile them to static libraries and link into executable file. + +The source code of each library should be placed in a an own separate directory +("lib/your_library_name/[here are source files]"). + +For example, see a structure of the following two libraries `Foo` and `Bar`: + +|--lib +| | +| |--Bar +| | |--docs +| | |--examples +| | |--src +| | |- Bar.c +| | |- Bar.h +| | |- library.json (optional, custom build options, etc) https://docs.platformio.org/page/librarymanager/config.html +| | +| |--Foo +| | |- Foo.c +| | |- Foo.h +| | +| |- README --> THIS FILE +| +|- platformio.ini +|--src + |- main.c + +and a contents of `src/main.c`: +``` +#include <Foo.h> +#include <Bar.h> + +int main (void) +{ + ... +} + +``` + +PlatformIO Library Dependency Finder will find automatically dependent +libraries scanning project source files. + +More information about PlatformIO Library Dependency Finder +- https://docs.platformio.org/page/librarymanager/ldf.html diff --git a/Robotito/platformio.ini b/Robotito/platformio.ini new file mode 100644 index 0000000..c312d73 --- /dev/null +++ b/Robotito/platformio.ini @@ -0,0 +1,14 @@ +; PlatformIO Project Configuration File +; +; Build options: build flags, source filter +; Upload options: custom upload port, speed and extra flags +; Library options: dependencies, extra library storages +; Advanced options: extra scripting +; +; Please visit documentation for the other options and examples +; https://docs.platformio.org/page/projectconf.html + +[env:esp32thing] +platform = espressif32 +board = esp32thing +framework = espidf diff --git a/Robotito/sdkconfig.esp32thing b/Robotito/sdkconfig.esp32thing new file mode 100644 index 0000000..6cc543c --- /dev/null +++ b/Robotito/sdkconfig.esp32thing @@ -0,0 +1,1393 @@ +# +# Automatically generated file. DO NOT EDIT. +# Espressif IoT Development Framework (ESP-IDF) Project Configuration +# +CONFIG_IDF_CMAKE=y +CONFIG_IDF_TARGET_ARCH_XTENSA=y +CONFIG_IDF_TARGET="esp32" +CONFIG_IDF_TARGET_ESP32=y +CONFIG_IDF_FIRMWARE_CHIP_ID=0x0000 + +# +# SDK tool configuration +# +CONFIG_SDK_TOOLPREFIX="xtensa-esp32-elf-" +# CONFIG_SDK_TOOLCHAIN_SUPPORTS_TIME_WIDE_64_BITS is not set +# end of SDK tool configuration + +# +# Build type +# +CONFIG_APP_BUILD_TYPE_APP_2NDBOOT=y +# CONFIG_APP_BUILD_TYPE_ELF_RAM is not set +CONFIG_APP_BUILD_GENERATE_BINARIES=y +CONFIG_APP_BUILD_BOOTLOADER=y +CONFIG_APP_BUILD_USE_FLASH_SECTIONS=y +# end of Build type + +# +# Application manager +# +CONFIG_APP_COMPILE_TIME_DATE=y +# CONFIG_APP_EXCLUDE_PROJECT_VER_VAR is not set +# CONFIG_APP_EXCLUDE_PROJECT_NAME_VAR is not set +# CONFIG_APP_PROJECT_VER_FROM_CONFIG is not set +CONFIG_APP_RETRIEVE_LEN_ELF_SHA=16 +# end of Application manager + +# +# Bootloader config +# +CONFIG_BOOTLOADER_OFFSET_IN_FLASH=0x1000 +CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_SIZE=y +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_DEBUG is not set +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_PERF is not set +# CONFIG_BOOTLOADER_COMPILER_OPTIMIZATION_NONE is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_NONE is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_ERROR is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_WARN is not set +CONFIG_BOOTLOADER_LOG_LEVEL_INFO=y +# CONFIG_BOOTLOADER_LOG_LEVEL_DEBUG is not set +# CONFIG_BOOTLOADER_LOG_LEVEL_VERBOSE is not set +CONFIG_BOOTLOADER_LOG_LEVEL=3 +# CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_8V is not set +CONFIG_BOOTLOADER_VDDSDIO_BOOST_1_9V=y +# CONFIG_BOOTLOADER_FACTORY_RESET is not set +# CONFIG_BOOTLOADER_APP_TEST is not set +CONFIG_BOOTLOADER_REGION_PROTECTION_ENABLE=y +CONFIG_BOOTLOADER_WDT_ENABLE=y +# CONFIG_BOOTLOADER_WDT_DISABLE_IN_USER_CODE is not set +CONFIG_BOOTLOADER_WDT_TIME_MS=9000 +# CONFIG_BOOTLOADER_APP_ROLLBACK_ENABLE is not set +# CONFIG_BOOTLOADER_SKIP_VALIDATE_IN_DEEP_SLEEP is not set +# CONFIG_BOOTLOADER_SKIP_VALIDATE_ON_POWER_ON is not set +# CONFIG_BOOTLOADER_SKIP_VALIDATE_ALWAYS is not set +CONFIG_BOOTLOADER_RESERVE_RTC_SIZE=0 +# CONFIG_BOOTLOADER_CUSTOM_RESERVE_RTC is not set +CONFIG_BOOTLOADER_FLASH_XMC_SUPPORT=y +# end of Bootloader config + +# +# Security features +# +# CONFIG_SECURE_SIGNED_APPS_NO_SECURE_BOOT is not set +# CONFIG_SECURE_BOOT is not set +# CONFIG_SECURE_FLASH_ENC_ENABLED is not set +# end of Security features + +# +# Serial flasher config +# +CONFIG_ESPTOOLPY_BAUD_OTHER_VAL=115200 +# CONFIG_ESPTOOLPY_NO_STUB is not set +# CONFIG_ESPTOOLPY_FLASHMODE_QIO is not set +# CONFIG_ESPTOOLPY_FLASHMODE_QOUT is not set +CONFIG_ESPTOOLPY_FLASHMODE_DIO=y +# CONFIG_ESPTOOLPY_FLASHMODE_DOUT is not set +CONFIG_ESPTOOLPY_FLASH_SAMPLE_MODE_STR=y +CONFIG_ESPTOOLPY_FLASHMODE="dio" +# CONFIG_ESPTOOLPY_FLASHFREQ_80M is not set +CONFIG_ESPTOOLPY_FLASHFREQ_40M=y +# CONFIG_ESPTOOLPY_FLASHFREQ_26M is not set +# CONFIG_ESPTOOLPY_FLASHFREQ_20M is not set +CONFIG_ESPTOOLPY_FLASHFREQ="40m" +# CONFIG_ESPTOOLPY_FLASHSIZE_1MB is not set +CONFIG_ESPTOOLPY_FLASHSIZE_2MB=y +# CONFIG_ESPTOOLPY_FLASHSIZE_4MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_8MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_16MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_32MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_64MB is not set +# CONFIG_ESPTOOLPY_FLASHSIZE_128MB is not set +CONFIG_ESPTOOLPY_FLASHSIZE="2MB" +CONFIG_ESPTOOLPY_FLASHSIZE_DETECT=y +CONFIG_ESPTOOLPY_BEFORE_RESET=y +# CONFIG_ESPTOOLPY_BEFORE_NORESET is not set +CONFIG_ESPTOOLPY_BEFORE="default_reset" +CONFIG_ESPTOOLPY_AFTER_RESET=y +# CONFIG_ESPTOOLPY_AFTER_NORESET is not set +CONFIG_ESPTOOLPY_AFTER="hard_reset" +# CONFIG_ESPTOOLPY_MONITOR_BAUD_CONSOLE is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_9600B is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_57600B is not set +CONFIG_ESPTOOLPY_MONITOR_BAUD_115200B=y +# CONFIG_ESPTOOLPY_MONITOR_BAUD_230400B is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_921600B is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_2MB is not set +# CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER is not set +CONFIG_ESPTOOLPY_MONITOR_BAUD_OTHER_VAL=115200 +CONFIG_ESPTOOLPY_MONITOR_BAUD=115200 +# end of Serial flasher config + +# +# Partition Table +# +CONFIG_PARTITION_TABLE_SINGLE_APP=y +# CONFIG_PARTITION_TABLE_SINGLE_APP_LARGE is not set +# CONFIG_PARTITION_TABLE_TWO_OTA is not set +# CONFIG_PARTITION_TABLE_CUSTOM is not set +CONFIG_PARTITION_TABLE_CUSTOM_FILENAME="partitions.csv" +CONFIG_PARTITION_TABLE_FILENAME="partitions_singleapp.csv" +CONFIG_PARTITION_TABLE_OFFSET=0x8000 +CONFIG_PARTITION_TABLE_MD5=y +# end of Partition Table + +# +# Compiler options +# +CONFIG_COMPILER_OPTIMIZATION_DEFAULT=y +# CONFIG_COMPILER_OPTIMIZATION_SIZE is not set +# CONFIG_COMPILER_OPTIMIZATION_PERF is not set +# CONFIG_COMPILER_OPTIMIZATION_NONE is not set +CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_ENABLE=y +# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_SILENT is not set +# CONFIG_COMPILER_OPTIMIZATION_ASSERTIONS_DISABLE is not set +CONFIG_COMPILER_OPTIMIZATION_ASSERTION_LEVEL=2 +# CONFIG_COMPILER_OPTIMIZATION_CHECKS_SILENT is not set +CONFIG_COMPILER_HIDE_PATHS_MACROS=y +# CONFIG_COMPILER_CXX_EXCEPTIONS is not set +# CONFIG_COMPILER_CXX_RTTI is not set +CONFIG_COMPILER_STACK_CHECK_MODE_NONE=y +# CONFIG_COMPILER_STACK_CHECK_MODE_NORM is not set +# CONFIG_COMPILER_STACK_CHECK_MODE_STRONG is not set +# CONFIG_COMPILER_STACK_CHECK_MODE_ALL is not set +# CONFIG_COMPILER_WARN_WRITE_STRINGS is not set +# CONFIG_COMPILER_DISABLE_GCC8_WARNINGS is not set +# CONFIG_COMPILER_DUMP_RTL_FILES is not set +# end of Compiler options + +# +# Component config +# + +# +# Application Level Tracing +# +# CONFIG_APPTRACE_DEST_JTAG is not set +CONFIG_APPTRACE_DEST_NONE=y +CONFIG_APPTRACE_LOCK_ENABLE=y +# end of Application Level Tracing + +# +# ESP-ASIO +# +# CONFIG_ASIO_SSL_SUPPORT is not set +# end of ESP-ASIO + +# +# Bluetooth +# +# CONFIG_BT_ENABLED is not set +# end of Bluetooth + +# +# CoAP Configuration +# +CONFIG_COAP_MBEDTLS_PSK=y +# CONFIG_COAP_MBEDTLS_PKI is not set +# CONFIG_COAP_MBEDTLS_DEBUG is not set +CONFIG_COAP_LOG_DEFAULT_LEVEL=0 +# end of CoAP Configuration + +# +# Driver configurations +# + +# +# ADC configuration +# +# CONFIG_ADC_FORCE_XPD_FSM is not set +CONFIG_ADC_DISABLE_DAC=y +# end of ADC configuration + +# +# MCPWM configuration +# +# CONFIG_MCPWM_ISR_IN_IRAM is not set +# end of MCPWM configuration + +# +# SPI configuration +# +# CONFIG_SPI_MASTER_IN_IRAM is not set +CONFIG_SPI_MASTER_ISR_IN_IRAM=y +# CONFIG_SPI_SLAVE_IN_IRAM is not set +CONFIG_SPI_SLAVE_ISR_IN_IRAM=y +# end of SPI configuration + +# +# TWAI configuration +# +# CONFIG_TWAI_ISR_IN_IRAM is not set +# CONFIG_TWAI_ERRATA_FIX_BUS_OFF_REC is not set +# CONFIG_TWAI_ERRATA_FIX_TX_INTR_LOST is not set +# CONFIG_TWAI_ERRATA_FIX_RX_FRAME_INVALID is not set +# CONFIG_TWAI_ERRATA_FIX_RX_FIFO_CORRUPT is not set +# end of TWAI configuration + +# +# UART configuration +# +# CONFIG_UART_ISR_IN_IRAM is not set +# end of UART configuration + +# +# RTCIO configuration +# +# CONFIG_RTCIO_SUPPORT_RTC_GPIO_DESC is not set +# end of RTCIO configuration + +# +# GPIO Configuration +# +# CONFIG_GPIO_ESP32_SUPPORT_SWITCH_SLP_PULL is not set +# end of GPIO Configuration + +# +# GDMA Configuration +# +# CONFIG_GDMA_CTRL_FUNC_IN_IRAM is not set +# CONFIG_GDMA_ISR_IRAM_SAFE is not set +# end of GDMA Configuration +# end of Driver configurations + +# +# eFuse Bit Manager +# +# CONFIG_EFUSE_CUSTOM_TABLE is not set +# CONFIG_EFUSE_VIRTUAL is not set +# CONFIG_EFUSE_CODE_SCHEME_COMPAT_NONE is not set +CONFIG_EFUSE_CODE_SCHEME_COMPAT_3_4=y +# CONFIG_EFUSE_CODE_SCHEME_COMPAT_REPEAT is not set +CONFIG_EFUSE_MAX_BLK_LEN=192 +# end of eFuse Bit Manager + +# +# ESP-TLS +# +CONFIG_ESP_TLS_USING_MBEDTLS=y +# CONFIG_ESP_TLS_USE_SECURE_ELEMENT is not set +# CONFIG_ESP_TLS_CLIENT_SESSION_TICKETS is not set +# CONFIG_ESP_TLS_SERVER is not set +# CONFIG_ESP_TLS_PSK_VERIFICATION is not set +# CONFIG_ESP_TLS_INSECURE is not set +# end of ESP-TLS + +# +# ESP32-specific +# +CONFIG_ESP32_REV_MIN_0=y +# CONFIG_ESP32_REV_MIN_1 is not set +# CONFIG_ESP32_REV_MIN_2 is not set +# CONFIG_ESP32_REV_MIN_3 is not set +CONFIG_ESP32_REV_MIN=0 +CONFIG_ESP32_DPORT_WORKAROUND=y +# CONFIG_ESP32_DEFAULT_CPU_FREQ_80 is not set +CONFIG_ESP32_DEFAULT_CPU_FREQ_160=y +# CONFIG_ESP32_DEFAULT_CPU_FREQ_240 is not set +CONFIG_ESP32_DEFAULT_CPU_FREQ_MHZ=160 +# CONFIG_ESP32_SPIRAM_SUPPORT is not set +# CONFIG_ESP32_TRAX is not set +CONFIG_ESP32_TRACEMEM_RESERVE_DRAM=0x0 +# CONFIG_ESP32_ULP_COPROC_ENABLED is not set +CONFIG_ESP32_ULP_COPROC_RESERVE_MEM=0 +CONFIG_ESP32_DEBUG_OCDAWARE=y +CONFIG_ESP32_BROWNOUT_DET=y +CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_0=y +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_1 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_2 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_ESP32_BROWNOUT_DET_LVL_SEL_7 is not set +CONFIG_ESP32_BROWNOUT_DET_LVL=0 +CONFIG_ESP32_TIME_SYSCALL_USE_RTC_FRC1=y +# CONFIG_ESP32_TIME_SYSCALL_USE_RTC is not set +# CONFIG_ESP32_TIME_SYSCALL_USE_FRC1 is not set +# CONFIG_ESP32_TIME_SYSCALL_USE_NONE is not set +CONFIG_ESP32_RTC_CLK_SRC_INT_RC=y +# CONFIG_ESP32_RTC_CLK_SRC_EXT_CRYS is not set +# CONFIG_ESP32_RTC_CLK_SRC_EXT_OSC is not set +# CONFIG_ESP32_RTC_CLK_SRC_INT_8MD256 is not set +CONFIG_ESP32_RTC_CLK_CAL_CYCLES=1024 +CONFIG_ESP32_DEEP_SLEEP_WAKEUP_DELAY=2000 +CONFIG_ESP32_XTAL_FREQ_40=y +# CONFIG_ESP32_XTAL_FREQ_26 is not set +# CONFIG_ESP32_XTAL_FREQ_AUTO is not set +CONFIG_ESP32_XTAL_FREQ=40 +# CONFIG_ESP32_DISABLE_BASIC_ROM_CONSOLE is not set +# CONFIG_ESP32_NO_BLOBS is not set +# CONFIG_ESP32_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set +# CONFIG_ESP32_COMPATIBLE_PRE_V3_1_BOOTLOADERS is not set +# CONFIG_ESP32_USE_FIXED_STATIC_RAM_SIZE is not set +CONFIG_ESP32_DPORT_DIS_INTERRUPT_LVL=5 +# end of ESP32-specific + +# +# ADC-Calibration +# +CONFIG_ADC_CAL_EFUSE_TP_ENABLE=y +CONFIG_ADC_CAL_EFUSE_VREF_ENABLE=y +CONFIG_ADC_CAL_LUT_ENABLE=y +# end of ADC-Calibration + +# +# Common ESP-related +# +CONFIG_ESP_ERR_TO_NAME_LOOKUP=y +# end of Common ESP-related + +# +# Ethernet +# +CONFIG_ETH_ENABLED=y +CONFIG_ETH_USE_ESP32_EMAC=y +CONFIG_ETH_PHY_INTERFACE_RMII=y +CONFIG_ETH_RMII_CLK_INPUT=y +# CONFIG_ETH_RMII_CLK_OUTPUT is not set +CONFIG_ETH_RMII_CLK_IN_GPIO=0 +CONFIG_ETH_DMA_BUFFER_SIZE=512 +CONFIG_ETH_DMA_RX_BUFFER_NUM=10 +CONFIG_ETH_DMA_TX_BUFFER_NUM=10 +CONFIG_ETH_USE_SPI_ETHERNET=y +# CONFIG_ETH_SPI_ETHERNET_DM9051 is not set +# CONFIG_ETH_SPI_ETHERNET_W5500 is not set +# CONFIG_ETH_SPI_ETHERNET_KSZ8851SNL is not set +# CONFIG_ETH_USE_OPENETH is not set +# end of Ethernet + +# +# Event Loop Library +# +# CONFIG_ESP_EVENT_LOOP_PROFILING is not set +CONFIG_ESP_EVENT_POST_FROM_ISR=y +CONFIG_ESP_EVENT_POST_FROM_IRAM_ISR=y +# end of Event Loop Library + +# +# GDB Stub +# +# end of GDB Stub + +# +# ESP HTTP client +# +CONFIG_ESP_HTTP_CLIENT_ENABLE_HTTPS=y +# CONFIG_ESP_HTTP_CLIENT_ENABLE_BASIC_AUTH is not set +CONFIG_ESP_HTTP_CLIENT_ENABLE_DIGEST_AUTH=y +# end of ESP HTTP client + +# +# HTTP Server +# +CONFIG_HTTPD_MAX_REQ_HDR_LEN=512 +CONFIG_HTTPD_MAX_URI_LEN=512 +CONFIG_HTTPD_ERR_RESP_NO_DELAY=y +CONFIG_HTTPD_PURGE_BUF_LEN=32 +# CONFIG_HTTPD_LOG_PURGE_DATA is not set +# CONFIG_HTTPD_WS_SUPPORT is not set +# end of HTTP Server + +# +# ESP HTTPS OTA +# +# CONFIG_OTA_ALLOW_HTTP is not set +# end of ESP HTTPS OTA + +# +# ESP HTTPS server +# +# CONFIG_ESP_HTTPS_SERVER_ENABLE is not set +# end of ESP HTTPS server + +# +# Hardware Settings +# + +# +# MAC Config +# +CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_STA=y +CONFIG_ESP_MAC_ADDR_UNIVERSE_WIFI_AP=y +CONFIG_ESP_MAC_ADDR_UNIVERSE_BT=y +CONFIG_ESP_MAC_ADDR_UNIVERSE_ETH=y +# CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_TWO is not set +CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES_FOUR=y +CONFIG_ESP32_UNIVERSAL_MAC_ADDRESSES=4 +# end of MAC Config + +# +# Sleep Config +# +CONFIG_ESP_SLEEP_POWER_DOWN_FLASH=y +CONFIG_ESP_SLEEP_RTC_BUS_ISO_WORKAROUND=y +# CONFIG_ESP_SLEEP_GPIO_RESET_WORKAROUND is not set +# CONFIG_ESP_SLEEP_FLASH_LEAKAGE_WORKAROUND is not set +# end of Sleep Config + +# +# RTC Clock Config +# +# end of RTC Clock Config +# end of Hardware Settings + +# +# IPC (Inter-Processor Call) +# +CONFIG_ESP_IPC_TASK_STACK_SIZE=1536 +CONFIG_ESP_IPC_USES_CALLERS_PRIORITY=y +CONFIG_ESP_IPC_ISR_ENABLE=y +# end of IPC (Inter-Processor Call) + +# +# LCD and Touch Panel +# + +# +# LCD Peripheral Configuration +# +CONFIG_LCD_PANEL_IO_FORMAT_BUF_SIZE=32 +# end of LCD Peripheral Configuration +# end of LCD and Touch Panel + +# +# ESP NETIF Adapter +# +CONFIG_ESP_NETIF_IP_LOST_TIMER_INTERVAL=120 +CONFIG_ESP_NETIF_TCPIP_LWIP=y +# CONFIG_ESP_NETIF_LOOPBACK is not set +CONFIG_ESP_NETIF_TCPIP_ADAPTER_COMPATIBLE_LAYER=y +# end of ESP NETIF Adapter + +# +# PHY +# +CONFIG_ESP_PHY_CALIBRATION_AND_DATA_STORAGE=y +# CONFIG_ESP_PHY_INIT_DATA_IN_PARTITION is not set +CONFIG_ESP_PHY_MAX_WIFI_TX_POWER=20 +CONFIG_ESP_PHY_MAX_TX_POWER=20 +CONFIG_ESP_PHY_REDUCE_TX_POWER=y +# end of PHY + +# +# Power Management +# +# CONFIG_PM_ENABLE is not set +# end of Power Management + +# +# ESP System Settings +# +# CONFIG_ESP_SYSTEM_PANIC_PRINT_HALT is not set +CONFIG_ESP_SYSTEM_PANIC_PRINT_REBOOT=y +# CONFIG_ESP_SYSTEM_PANIC_SILENT_REBOOT is not set +# CONFIG_ESP_SYSTEM_PANIC_GDBSTUB is not set +# CONFIG_ESP_SYSTEM_GDBSTUB_RUNTIME is not set + +# +# Memory protection +# +# end of Memory protection + +CONFIG_ESP_SYSTEM_EVENT_QUEUE_SIZE=32 +CONFIG_ESP_SYSTEM_EVENT_TASK_STACK_SIZE=2304 +CONFIG_ESP_MAIN_TASK_STACK_SIZE=3584 +CONFIG_ESP_MAIN_TASK_AFFINITY_CPU0=y +# CONFIG_ESP_MAIN_TASK_AFFINITY_CPU1 is not set +# CONFIG_ESP_MAIN_TASK_AFFINITY_NO_AFFINITY is not set +CONFIG_ESP_MAIN_TASK_AFFINITY=0x0 +CONFIG_ESP_MINIMAL_SHARED_STACK_SIZE=2048 +CONFIG_ESP_CONSOLE_UART_DEFAULT=y +# CONFIG_ESP_CONSOLE_UART_CUSTOM is not set +# CONFIG_ESP_CONSOLE_NONE is not set +CONFIG_ESP_CONSOLE_UART=y +CONFIG_ESP_CONSOLE_MULTIPLE_UART=y +CONFIG_ESP_CONSOLE_UART_NUM=0 +CONFIG_ESP_CONSOLE_UART_BAUDRATE=115200 +CONFIG_ESP_INT_WDT=y +CONFIG_ESP_INT_WDT_TIMEOUT_MS=300 +CONFIG_ESP_INT_WDT_CHECK_CPU1=y +CONFIG_ESP_TASK_WDT=y +# CONFIG_ESP_TASK_WDT_PANIC is not set +CONFIG_ESP_TASK_WDT_TIMEOUT_S=5 +CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU0=y +CONFIG_ESP_TASK_WDT_CHECK_IDLE_TASK_CPU1=y +# CONFIG_ESP_PANIC_HANDLER_IRAM is not set +# CONFIG_ESP_DEBUG_STUBS_ENABLE is not set +# CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_5 is not set +CONFIG_ESP_SYSTEM_CHECK_INT_LEVEL_4=y +# end of ESP System Settings + +# +# High resolution timer (esp_timer) +# +# CONFIG_ESP_TIMER_PROFILING is not set +CONFIG_ESP_TIME_FUNCS_USE_RTC_TIMER=y +CONFIG_ESP_TIME_FUNCS_USE_ESP_TIMER=y +CONFIG_ESP_TIMER_TASK_STACK_SIZE=3584 +CONFIG_ESP_TIMER_INTERRUPT_LEVEL=1 +# CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD is not set +# CONFIG_ESP_TIMER_IMPL_FRC2 is not set +CONFIG_ESP_TIMER_IMPL_TG0_LAC=y +# end of High resolution timer (esp_timer) + +# +# Wi-Fi +# +CONFIG_ESP32_WIFI_ENABLED=y +CONFIG_ESP32_WIFI_STATIC_RX_BUFFER_NUM=10 +CONFIG_ESP32_WIFI_DYNAMIC_RX_BUFFER_NUM=32 +# CONFIG_ESP32_WIFI_STATIC_TX_BUFFER is not set +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER=y +CONFIG_ESP32_WIFI_TX_BUFFER_TYPE=1 +CONFIG_ESP32_WIFI_DYNAMIC_TX_BUFFER_NUM=32 +# CONFIG_ESP32_WIFI_CSI_ENABLED is not set +CONFIG_ESP32_WIFI_AMPDU_TX_ENABLED=y +CONFIG_ESP32_WIFI_TX_BA_WIN=6 +CONFIG_ESP32_WIFI_AMPDU_RX_ENABLED=y +CONFIG_ESP32_WIFI_RX_BA_WIN=6 +CONFIG_ESP32_WIFI_NVS_ENABLED=y +CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_0=y +# CONFIG_ESP32_WIFI_TASK_PINNED_TO_CORE_1 is not set +CONFIG_ESP32_WIFI_SOFTAP_BEACON_MAX_LEN=752 +CONFIG_ESP32_WIFI_MGMT_SBUF_NUM=32 +CONFIG_ESP32_WIFI_IRAM_OPT=y +CONFIG_ESP32_WIFI_RX_IRAM_OPT=y +CONFIG_ESP32_WIFI_ENABLE_WPA3_SAE=y +# CONFIG_ESP_WIFI_SLP_IRAM_OPT is not set +# CONFIG_ESP_WIFI_STA_DISCONNECTED_PM_ENABLE is not set +# CONFIG_ESP_WIFI_GMAC_SUPPORT is not set +CONFIG_ESP_WIFI_SOFTAP_SUPPORT=y +# end of Wi-Fi + +# +# Core dump +# +# CONFIG_ESP_COREDUMP_ENABLE_TO_FLASH is not set +# CONFIG_ESP_COREDUMP_ENABLE_TO_UART is not set +CONFIG_ESP_COREDUMP_ENABLE_TO_NONE=y +# end of Core dump + +# +# FAT Filesystem support +# +# CONFIG_FATFS_CODEPAGE_DYNAMIC is not set +CONFIG_FATFS_CODEPAGE_437=y +# CONFIG_FATFS_CODEPAGE_720 is not set +# CONFIG_FATFS_CODEPAGE_737 is not set +# CONFIG_FATFS_CODEPAGE_771 is not set +# CONFIG_FATFS_CODEPAGE_775 is not set +# CONFIG_FATFS_CODEPAGE_850 is not set +# CONFIG_FATFS_CODEPAGE_852 is not set +# CONFIG_FATFS_CODEPAGE_855 is not set +# CONFIG_FATFS_CODEPAGE_857 is not set +# CONFIG_FATFS_CODEPAGE_860 is not set +# CONFIG_FATFS_CODEPAGE_861 is not set +# CONFIG_FATFS_CODEPAGE_862 is not set +# CONFIG_FATFS_CODEPAGE_863 is not set +# CONFIG_FATFS_CODEPAGE_864 is not set +# CONFIG_FATFS_CODEPAGE_865 is not set +# CONFIG_FATFS_CODEPAGE_866 is not set +# CONFIG_FATFS_CODEPAGE_869 is not set +# CONFIG_FATFS_CODEPAGE_932 is not set +# CONFIG_FATFS_CODEPAGE_936 is not set +# CONFIG_FATFS_CODEPAGE_949 is not set +# CONFIG_FATFS_CODEPAGE_950 is not set +CONFIG_FATFS_CODEPAGE=437 +CONFIG_FATFS_LFN_NONE=y +# CONFIG_FATFS_LFN_HEAP is not set +# CONFIG_FATFS_LFN_STACK is not set +CONFIG_FATFS_FS_LOCK=0 +CONFIG_FATFS_TIMEOUT_MS=10000 +CONFIG_FATFS_PER_FILE_CACHE=y +# CONFIG_FATFS_USE_FASTSEEK is not set +# end of FAT Filesystem support + +# +# Modbus configuration +# +CONFIG_FMB_COMM_MODE_TCP_EN=y +CONFIG_FMB_TCP_PORT_DEFAULT=502 +CONFIG_FMB_TCP_PORT_MAX_CONN=5 +CONFIG_FMB_TCP_CONNECTION_TOUT_SEC=20 +CONFIG_FMB_COMM_MODE_RTU_EN=y +CONFIG_FMB_COMM_MODE_ASCII_EN=y +CONFIG_FMB_MASTER_TIMEOUT_MS_RESPOND=150 +CONFIG_FMB_MASTER_DELAY_MS_CONVERT=200 +CONFIG_FMB_QUEUE_LENGTH=20 +CONFIG_FMB_PORT_TASK_STACK_SIZE=4096 +CONFIG_FMB_SERIAL_BUF_SIZE=256 +CONFIG_FMB_SERIAL_ASCII_BITS_PER_SYMB=8 +CONFIG_FMB_SERIAL_ASCII_TIMEOUT_RESPOND_MS=1000 +CONFIG_FMB_PORT_TASK_PRIO=10 +# CONFIG_FMB_PORT_TASK_AFFINITY_NO_AFFINITY is not set +CONFIG_FMB_PORT_TASK_AFFINITY_CPU0=y +# CONFIG_FMB_PORT_TASK_AFFINITY_CPU1 is not set +CONFIG_FMB_PORT_TASK_AFFINITY=0x0 +CONFIG_FMB_CONTROLLER_SLAVE_ID_SUPPORT=y +CONFIG_FMB_CONTROLLER_SLAVE_ID=0x00112233 +CONFIG_FMB_CONTROLLER_NOTIFY_TIMEOUT=20 +CONFIG_FMB_CONTROLLER_NOTIFY_QUEUE_SIZE=20 +CONFIG_FMB_CONTROLLER_STACK_SIZE=4096 +CONFIG_FMB_EVENT_QUEUE_TIMEOUT=20 +# CONFIG_FMB_TIMER_PORT_ENABLED is not set +CONFIG_FMB_TIMER_GROUP=0 +CONFIG_FMB_TIMER_INDEX=0 +CONFIG_FMB_MASTER_TIMER_GROUP=0 +CONFIG_FMB_MASTER_TIMER_INDEX=0 +# CONFIG_FMB_TIMER_ISR_IN_IRAM is not set +# end of Modbus configuration + +# +# FreeRTOS +# +# CONFIG_FREERTOS_UNICORE is not set +CONFIG_FREERTOS_NO_AFFINITY=0x7FFFFFFF +CONFIG_FREERTOS_TICK_SUPPORT_CORETIMER=y +CONFIG_FREERTOS_CORETIMER_0=y +# CONFIG_FREERTOS_CORETIMER_1 is not set +CONFIG_FREERTOS_SYSTICK_USES_CCOUNT=y +CONFIG_FREERTOS_HZ=100 +CONFIG_FREERTOS_ASSERT_ON_UNTESTED_FUNCTION=y +# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_NONE is not set +# CONFIG_FREERTOS_CHECK_STACKOVERFLOW_PTRVAL is not set +CONFIG_FREERTOS_CHECK_STACKOVERFLOW_CANARY=y +# CONFIG_FREERTOS_WATCHPOINT_END_OF_STACK is not set +CONFIG_FREERTOS_INTERRUPT_BACKTRACE=y +CONFIG_FREERTOS_THREAD_LOCAL_STORAGE_POINTERS=1 +CONFIG_FREERTOS_ASSERT_FAIL_ABORT=y +# CONFIG_FREERTOS_ASSERT_FAIL_PRINT_CONTINUE is not set +# CONFIG_FREERTOS_ASSERT_DISABLE is not set +CONFIG_FREERTOS_IDLE_TASK_STACKSIZE=1536 +CONFIG_FREERTOS_ISR_STACKSIZE=1536 +# CONFIG_FREERTOS_LEGACY_HOOKS is not set +CONFIG_FREERTOS_MAX_TASK_NAME_LEN=16 +CONFIG_FREERTOS_SUPPORT_STATIC_ALLOCATION=y +# CONFIG_FREERTOS_ENABLE_STATIC_TASK_CLEAN_UP is not set +CONFIG_FREERTOS_TIMER_TASK_PRIORITY=1 +CONFIG_FREERTOS_TIMER_TASK_STACK_DEPTH=2048 +CONFIG_FREERTOS_TIMER_QUEUE_LENGTH=10 +CONFIG_FREERTOS_QUEUE_REGISTRY_SIZE=0 +# CONFIG_FREERTOS_USE_TRACE_FACILITY is not set +# CONFIG_FREERTOS_GENERATE_RUN_TIME_STATS is not set +CONFIG_FREERTOS_TASK_FUNCTION_WRAPPER=y +CONFIG_FREERTOS_CHECK_MUTEX_GIVEN_BY_OWNER=y +# CONFIG_FREERTOS_CHECK_PORT_CRITICAL_COMPLIANCE is not set +# CONFIG_FREERTOS_PLACE_FUNCTIONS_INTO_FLASH is not set +CONFIG_FREERTOS_DEBUG_OCDAWARE=y +# CONFIG_FREERTOS_FPU_IN_ISR is not set +CONFIG_FREERTOS_ENABLE_TASK_SNAPSHOT=y +# CONFIG_FREERTOS_PLACE_SNAPSHOT_FUNS_INTO_FLASH is not set +# end of FreeRTOS + +# +# Hardware Abstraction Layer (HAL) and Low Level (LL) +# +CONFIG_HAL_ASSERTION_EQUALS_SYSTEM=y +# CONFIG_HAL_ASSERTION_DISABLE is not set +# CONFIG_HAL_ASSERTION_SILIENT is not set +# CONFIG_HAL_ASSERTION_ENABLE is not set +CONFIG_HAL_DEFAULT_ASSERTION_LEVEL=2 +# end of Hardware Abstraction Layer (HAL) and Low Level (LL) + +# +# Heap memory debugging +# +CONFIG_HEAP_POISONING_DISABLED=y +# CONFIG_HEAP_POISONING_LIGHT is not set +# CONFIG_HEAP_POISONING_COMPREHENSIVE is not set +CONFIG_HEAP_TRACING_OFF=y +# CONFIG_HEAP_TRACING_STANDALONE is not set +# CONFIG_HEAP_TRACING_TOHOST is not set +# CONFIG_HEAP_ABORT_WHEN_ALLOCATION_FAILS is not set +# end of Heap memory debugging + +# +# jsmn +# +# CONFIG_JSMN_PARENT_LINKS is not set +# CONFIG_JSMN_STRICT is not set +# end of jsmn + +# +# libsodium +# +# end of libsodium + +# +# Log output +# +# CONFIG_LOG_DEFAULT_LEVEL_NONE is not set +# CONFIG_LOG_DEFAULT_LEVEL_ERROR is not set +# CONFIG_LOG_DEFAULT_LEVEL_WARN is not set +CONFIG_LOG_DEFAULT_LEVEL_INFO=y +# CONFIG_LOG_DEFAULT_LEVEL_DEBUG is not set +# CONFIG_LOG_DEFAULT_LEVEL_VERBOSE is not set +CONFIG_LOG_DEFAULT_LEVEL=3 +CONFIG_LOG_MAXIMUM_EQUALS_DEFAULT=y +# CONFIG_LOG_MAXIMUM_LEVEL_DEBUG is not set +# CONFIG_LOG_MAXIMUM_LEVEL_VERBOSE is not set +CONFIG_LOG_MAXIMUM_LEVEL=3 +CONFIG_LOG_COLORS=y +CONFIG_LOG_TIMESTAMP_SOURCE_RTOS=y +# CONFIG_LOG_TIMESTAMP_SOURCE_SYSTEM is not set +# end of Log output + +# +# LWIP +# +CONFIG_LWIP_LOCAL_HOSTNAME="espressif" +# CONFIG_LWIP_NETIF_API is not set +# CONFIG_LWIP_TCPIP_CORE_LOCKING is not set +CONFIG_LWIP_DNS_SUPPORT_MDNS_QUERIES=y +# CONFIG_LWIP_L2_TO_L3_COPY is not set +# CONFIG_LWIP_IRAM_OPTIMIZATION is not set +CONFIG_LWIP_TIMERS_ONDEMAND=y +CONFIG_LWIP_MAX_SOCKETS=10 +# CONFIG_LWIP_USE_ONLY_LWIP_SELECT is not set +# CONFIG_LWIP_SO_LINGER is not set +CONFIG_LWIP_SO_REUSE=y +CONFIG_LWIP_SO_REUSE_RXTOALL=y +# CONFIG_LWIP_SO_RCVBUF is not set +# CONFIG_LWIP_NETBUF_RECVINFO is not set +CONFIG_LWIP_IP4_FRAG=y +CONFIG_LWIP_IP6_FRAG=y +# CONFIG_LWIP_IP4_REASSEMBLY is not set +# CONFIG_LWIP_IP6_REASSEMBLY is not set +# CONFIG_LWIP_IP_FORWARD is not set +# CONFIG_LWIP_STATS is not set +# CONFIG_LWIP_ETHARP_TRUST_IP_MAC is not set +CONFIG_LWIP_ESP_GRATUITOUS_ARP=y +CONFIG_LWIP_GARP_TMR_INTERVAL=60 +CONFIG_LWIP_TCPIP_RECVMBOX_SIZE=32 +CONFIG_LWIP_DHCP_DOES_ARP_CHECK=y +# CONFIG_LWIP_DHCP_DISABLE_CLIENT_ID is not set +CONFIG_LWIP_DHCP_DISABLE_VENDOR_CLASS_ID=y +# CONFIG_LWIP_DHCP_RESTORE_LAST_IP is not set +CONFIG_LWIP_DHCP_OPTIONS_LEN=68 + +# +# DHCP server +# +CONFIG_LWIP_DHCPS=y +CONFIG_LWIP_DHCPS_LEASE_UNIT=60 +CONFIG_LWIP_DHCPS_MAX_STATION_NUM=8 +# end of DHCP server + +# CONFIG_LWIP_AUTOIP is not set +CONFIG_LWIP_IPV6=y +# CONFIG_LWIP_IPV6_AUTOCONFIG is not set +CONFIG_LWIP_IPV6_NUM_ADDRESSES=3 +# CONFIG_LWIP_IPV6_FORWARD is not set +# CONFIG_LWIP_NETIF_STATUS_CALLBACK is not set +CONFIG_LWIP_NETIF_LOOPBACK=y +CONFIG_LWIP_LOOPBACK_MAX_PBUFS=8 + +# +# TCP +# +CONFIG_LWIP_MAX_ACTIVE_TCP=16 +CONFIG_LWIP_MAX_LISTENING_TCP=16 +CONFIG_LWIP_TCP_HIGH_SPEED_RETRANSMISSION=y +CONFIG_LWIP_TCP_MAXRTX=12 +CONFIG_LWIP_TCP_SYNMAXRTX=12 +CONFIG_LWIP_TCP_MSS=1440 +CONFIG_LWIP_TCP_TMR_INTERVAL=250 +CONFIG_LWIP_TCP_MSL=60000 +CONFIG_LWIP_TCP_SND_BUF_DEFAULT=5744 +CONFIG_LWIP_TCP_WND_DEFAULT=5744 +CONFIG_LWIP_TCP_RECVMBOX_SIZE=6 +CONFIG_LWIP_TCP_QUEUE_OOSEQ=y +# CONFIG_LWIP_TCP_SACK_OUT is not set +# CONFIG_LWIP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set +CONFIG_LWIP_TCP_OVERSIZE_MSS=y +# CONFIG_LWIP_TCP_OVERSIZE_QUARTER_MSS is not set +# CONFIG_LWIP_TCP_OVERSIZE_DISABLE is not set +CONFIG_LWIP_TCP_RTO_TIME=1500 +# end of TCP + +# +# UDP +# +CONFIG_LWIP_MAX_UDP_PCBS=16 +CONFIG_LWIP_UDP_RECVMBOX_SIZE=6 +# end of UDP + +# +# Checksums +# +# CONFIG_LWIP_CHECKSUM_CHECK_IP is not set +# CONFIG_LWIP_CHECKSUM_CHECK_UDP is not set +CONFIG_LWIP_CHECKSUM_CHECK_ICMP=y +# end of Checksums + +CONFIG_LWIP_TCPIP_TASK_STACK_SIZE=3072 +CONFIG_LWIP_TCPIP_TASK_AFFINITY_NO_AFFINITY=y +# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU0 is not set +# CONFIG_LWIP_TCPIP_TASK_AFFINITY_CPU1 is not set +CONFIG_LWIP_TCPIP_TASK_AFFINITY=0x7FFFFFFF +# CONFIG_LWIP_PPP_SUPPORT is not set +CONFIG_LWIP_IPV6_MEMP_NUM_ND6_QUEUE=3 +CONFIG_LWIP_IPV6_ND6_NUM_NEIGHBORS=5 +# CONFIG_LWIP_SLIP_SUPPORT is not set + +# +# ICMP +# +CONFIG_LWIP_ICMP=y +# CONFIG_LWIP_MULTICAST_PING is not set +# CONFIG_LWIP_BROADCAST_PING is not set +# end of ICMP + +# +# LWIP RAW API +# +CONFIG_LWIP_MAX_RAW_PCBS=16 +# end of LWIP RAW API + +# +# SNTP +# +CONFIG_LWIP_SNTP_MAX_SERVERS=1 +# CONFIG_LWIP_DHCP_GET_NTP_SRV is not set +CONFIG_LWIP_SNTP_UPDATE_DELAY=3600000 +# end of SNTP + +CONFIG_LWIP_ESP_LWIP_ASSERT=y + +# +# Hooks +# +# CONFIG_LWIP_HOOK_TCP_ISN_NONE is not set +CONFIG_LWIP_HOOK_TCP_ISN_DEFAULT=y +# CONFIG_LWIP_HOOK_TCP_ISN_CUSTOM is not set +CONFIG_LWIP_HOOK_IP6_ROUTE_NONE=y +# CONFIG_LWIP_HOOK_IP6_ROUTE_DEFAULT is not set +# CONFIG_LWIP_HOOK_IP6_ROUTE_CUSTOM is not set +CONFIG_LWIP_HOOK_ND6_GET_GW_NONE=y +# CONFIG_LWIP_HOOK_ND6_GET_GW_DEFAULT is not set +# CONFIG_LWIP_HOOK_ND6_GET_GW_CUSTOM is not set +CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_NONE=y +# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_DEFAULT is not set +# CONFIG_LWIP_HOOK_NETCONN_EXT_RESOLVE_CUSTOM is not set +# end of Hooks + +# CONFIG_LWIP_DEBUG is not set +# end of LWIP + +# +# mbedTLS +# +CONFIG_MBEDTLS_INTERNAL_MEM_ALLOC=y +# CONFIG_MBEDTLS_DEFAULT_MEM_ALLOC is not set +# CONFIG_MBEDTLS_CUSTOM_MEM_ALLOC is not set +CONFIG_MBEDTLS_ASYMMETRIC_CONTENT_LEN=y +CONFIG_MBEDTLS_SSL_IN_CONTENT_LEN=16384 +CONFIG_MBEDTLS_SSL_OUT_CONTENT_LEN=4096 +# CONFIG_MBEDTLS_DYNAMIC_BUFFER is not set +# CONFIG_MBEDTLS_DEBUG is not set + +# +# mbedTLS v2.28.x related +# +# CONFIG_MBEDTLS_SSL_VARIABLE_BUFFER_LENGTH is not set +# CONFIG_MBEDTLS_X509_TRUSTED_CERT_CALLBACK is not set +# CONFIG_MBEDTLS_SSL_CONTEXT_SERIALIZATION is not set +CONFIG_MBEDTLS_SSL_KEEP_PEER_CERTIFICATE=y +# end of mbedTLS v2.28.x related + +# +# Certificate Bundle +# +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE=y +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_FULL=y +# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_CMN is not set +# CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_DEFAULT_NONE is not set +# CONFIG_MBEDTLS_CUSTOM_CERTIFICATE_BUNDLE is not set +CONFIG_MBEDTLS_CERTIFICATE_BUNDLE_MAX_CERTS=200 +# end of Certificate Bundle + +# CONFIG_MBEDTLS_ECP_RESTARTABLE is not set +# CONFIG_MBEDTLS_CMAC_C is not set +CONFIG_MBEDTLS_HARDWARE_AES=y +CONFIG_MBEDTLS_HARDWARE_MPI=y +CONFIG_MBEDTLS_HARDWARE_SHA=y +CONFIG_MBEDTLS_ROM_MD5=y +# CONFIG_MBEDTLS_ATCA_HW_ECDSA_SIGN is not set +# CONFIG_MBEDTLS_ATCA_HW_ECDSA_VERIFY is not set +CONFIG_MBEDTLS_HAVE_TIME=y +# CONFIG_MBEDTLS_HAVE_TIME_DATE is not set +CONFIG_MBEDTLS_ECDSA_DETERMINISTIC=y +CONFIG_MBEDTLS_SHA512_C=y +CONFIG_MBEDTLS_TLS_SERVER_AND_CLIENT=y +# CONFIG_MBEDTLS_TLS_SERVER_ONLY is not set +# CONFIG_MBEDTLS_TLS_CLIENT_ONLY is not set +# CONFIG_MBEDTLS_TLS_DISABLED is not set +CONFIG_MBEDTLS_TLS_SERVER=y +CONFIG_MBEDTLS_TLS_CLIENT=y +CONFIG_MBEDTLS_TLS_ENABLED=y + +# +# TLS Key Exchange Methods +# +# CONFIG_MBEDTLS_PSK_MODES is not set +CONFIG_MBEDTLS_KEY_EXCHANGE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_DHE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ELLIPTIC_CURVE=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_RSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDHE_ECDSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_ECDSA=y +CONFIG_MBEDTLS_KEY_EXCHANGE_ECDH_RSA=y +# end of TLS Key Exchange Methods + +CONFIG_MBEDTLS_SSL_RENEGOTIATION=y +# CONFIG_MBEDTLS_SSL_PROTO_SSL3 is not set +CONFIG_MBEDTLS_SSL_PROTO_TLS1=y +CONFIG_MBEDTLS_SSL_PROTO_TLS1_1=y +CONFIG_MBEDTLS_SSL_PROTO_TLS1_2=y +# CONFIG_MBEDTLS_SSL_PROTO_GMTSSL1_1 is not set +# CONFIG_MBEDTLS_SSL_PROTO_DTLS is not set +CONFIG_MBEDTLS_SSL_ALPN=y +CONFIG_MBEDTLS_CLIENT_SSL_SESSION_TICKETS=y +CONFIG_MBEDTLS_X509_CHECK_KEY_USAGE=y +CONFIG_MBEDTLS_X509_CHECK_EXTENDED_KEY_USAGE=y +CONFIG_MBEDTLS_SERVER_SSL_SESSION_TICKETS=y + +# +# Symmetric Ciphers +# +CONFIG_MBEDTLS_AES_C=y +# CONFIG_MBEDTLS_CAMELLIA_C is not set +# CONFIG_MBEDTLS_DES_C is not set +CONFIG_MBEDTLS_RC4_DISABLED=y +# CONFIG_MBEDTLS_RC4_ENABLED_NO_DEFAULT is not set +# CONFIG_MBEDTLS_RC4_ENABLED is not set +# CONFIG_MBEDTLS_BLOWFISH_C is not set +# CONFIG_MBEDTLS_XTEA_C is not set +CONFIG_MBEDTLS_CCM_C=y +CONFIG_MBEDTLS_GCM_C=y +# CONFIG_MBEDTLS_NIST_KW_C is not set +# end of Symmetric Ciphers + +# CONFIG_MBEDTLS_RIPEMD160_C is not set + +# +# Certificates +# +CONFIG_MBEDTLS_PEM_PARSE_C=y +CONFIG_MBEDTLS_PEM_WRITE_C=y +CONFIG_MBEDTLS_X509_CRL_PARSE_C=y +CONFIG_MBEDTLS_X509_CSR_PARSE_C=y +# end of Certificates + +CONFIG_MBEDTLS_ECP_C=y +CONFIG_MBEDTLS_ECDH_C=y +CONFIG_MBEDTLS_ECDSA_C=y +# CONFIG_MBEDTLS_ECJPAKE_C is not set +CONFIG_MBEDTLS_ECP_DP_SECP192R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP224R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP256R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP384R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP521R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP192K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP224K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_SECP256K1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP256R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP384R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_BP512R1_ENABLED=y +CONFIG_MBEDTLS_ECP_DP_CURVE25519_ENABLED=y +CONFIG_MBEDTLS_ECP_NIST_OPTIM=y +# CONFIG_MBEDTLS_POLY1305_C is not set +# CONFIG_MBEDTLS_CHACHA20_C is not set +# CONFIG_MBEDTLS_HKDF_C is not set +# CONFIG_MBEDTLS_THREADING_C is not set +# CONFIG_MBEDTLS_LARGE_KEY_SOFTWARE_MPI is not set +# CONFIG_MBEDTLS_SECURITY_RISKS is not set +# end of mbedTLS + +# +# mDNS +# +CONFIG_MDNS_MAX_SERVICES=10 +CONFIG_MDNS_TASK_PRIORITY=1 +CONFIG_MDNS_TASK_STACK_SIZE=4096 +# CONFIG_MDNS_TASK_AFFINITY_NO_AFFINITY is not set +CONFIG_MDNS_TASK_AFFINITY_CPU0=y +# CONFIG_MDNS_TASK_AFFINITY_CPU1 is not set +CONFIG_MDNS_TASK_AFFINITY=0x0 +CONFIG_MDNS_SERVICE_ADD_TIMEOUT_MS=2000 +# CONFIG_MDNS_STRICT_MODE is not set +CONFIG_MDNS_TIMER_PERIOD_MS=100 +# CONFIG_MDNS_NETWORKING_SOCKET is not set +CONFIG_MDNS_MULTIPLE_INSTANCE=y +# end of mDNS + +# +# ESP-MQTT Configurations +# +CONFIG_MQTT_PROTOCOL_311=y +CONFIG_MQTT_TRANSPORT_SSL=y +CONFIG_MQTT_TRANSPORT_WEBSOCKET=y +CONFIG_MQTT_TRANSPORT_WEBSOCKET_SECURE=y +# CONFIG_MQTT_MSG_ID_INCREMENTAL is not set +# CONFIG_MQTT_SKIP_PUBLISH_IF_DISCONNECTED is not set +# CONFIG_MQTT_REPORT_DELETED_MESSAGES is not set +# CONFIG_MQTT_USE_CUSTOM_CONFIG is not set +# CONFIG_MQTT_TASK_CORE_SELECTION_ENABLED is not set +# CONFIG_MQTT_CUSTOM_OUTBOX is not set +# end of ESP-MQTT Configurations + +# +# Newlib +# +CONFIG_NEWLIB_STDOUT_LINE_ENDING_CRLF=y +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_LF is not set +# CONFIG_NEWLIB_STDOUT_LINE_ENDING_CR is not set +# CONFIG_NEWLIB_STDIN_LINE_ENDING_CRLF is not set +# CONFIG_NEWLIB_STDIN_LINE_ENDING_LF is not set +CONFIG_NEWLIB_STDIN_LINE_ENDING_CR=y +# CONFIG_NEWLIB_NANO_FORMAT is not set +# end of Newlib + +# +# NVS +# +# CONFIG_NVS_ASSERT_ERROR_CHECK is not set +# end of NVS + +# +# OpenSSL +# +# CONFIG_OPENSSL_DEBUG is not set +CONFIG_OPENSSL_ERROR_STACK=y +# CONFIG_OPENSSL_ASSERT_DO_NOTHING is not set +CONFIG_OPENSSL_ASSERT_EXIT=y +# end of OpenSSL + +# +# OpenThread +# +# CONFIG_OPENTHREAD_ENABLED is not set +# end of OpenThread + +# +# PThreads +# +CONFIG_PTHREAD_TASK_PRIO_DEFAULT=5 +CONFIG_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 +CONFIG_PTHREAD_STACK_MIN=768 +CONFIG_PTHREAD_DEFAULT_CORE_NO_AFFINITY=y +# CONFIG_PTHREAD_DEFAULT_CORE_0 is not set +# CONFIG_PTHREAD_DEFAULT_CORE_1 is not set +CONFIG_PTHREAD_TASK_CORE_DEFAULT=-1 +CONFIG_PTHREAD_TASK_NAME_DEFAULT="pthread" +# end of PThreads + +# +# SPI Flash driver +# +# CONFIG_SPI_FLASH_VERIFY_WRITE is not set +# CONFIG_SPI_FLASH_ENABLE_COUNTERS is not set +CONFIG_SPI_FLASH_ROM_DRIVER_PATCH=y +CONFIG_SPI_FLASH_DANGEROUS_WRITE_ABORTS=y +# CONFIG_SPI_FLASH_DANGEROUS_WRITE_FAILS is not set +# CONFIG_SPI_FLASH_DANGEROUS_WRITE_ALLOWED is not set +# CONFIG_SPI_FLASH_USE_LEGACY_IMPL is not set +# CONFIG_SPI_FLASH_SHARE_SPI1_BUS is not set +# CONFIG_SPI_FLASH_BYPASS_BLOCK_ERASE is not set +CONFIG_SPI_FLASH_YIELD_DURING_ERASE=y +CONFIG_SPI_FLASH_ERASE_YIELD_DURATION_MS=20 +CONFIG_SPI_FLASH_ERASE_YIELD_TICKS=1 +CONFIG_SPI_FLASH_WRITE_CHUNK_SIZE=8192 +# CONFIG_SPI_FLASH_SIZE_OVERRIDE is not set +# CONFIG_SPI_FLASH_CHECK_ERASE_TIMEOUT_DISABLED is not set +# CONFIG_SPI_FLASH_OVERRIDE_CHIP_DRIVER_LIST is not set + +# +# Auto-detect flash chips +# +CONFIG_SPI_FLASH_SUPPORT_ISSI_CHIP=y +CONFIG_SPI_FLASH_SUPPORT_MXIC_CHIP=y +CONFIG_SPI_FLASH_SUPPORT_GD_CHIP=y +CONFIG_SPI_FLASH_SUPPORT_WINBOND_CHIP=y +# CONFIG_SPI_FLASH_SUPPORT_BOYA_CHIP is not set +# CONFIG_SPI_FLASH_SUPPORT_TH_CHIP is not set +# end of Auto-detect flash chips + +CONFIG_SPI_FLASH_ENABLE_ENCRYPTED_READ_WRITE=y +# end of SPI Flash driver + +# +# SPIFFS Configuration +# +CONFIG_SPIFFS_MAX_PARTITIONS=3 + +# +# SPIFFS Cache Configuration +# +CONFIG_SPIFFS_CACHE=y +CONFIG_SPIFFS_CACHE_WR=y +# CONFIG_SPIFFS_CACHE_STATS is not set +# end of SPIFFS Cache Configuration + +CONFIG_SPIFFS_PAGE_CHECK=y +CONFIG_SPIFFS_GC_MAX_RUNS=10 +# CONFIG_SPIFFS_GC_STATS is not set +CONFIG_SPIFFS_PAGE_SIZE=256 +CONFIG_SPIFFS_OBJ_NAME_LEN=32 +# CONFIG_SPIFFS_FOLLOW_SYMLINKS is not set +CONFIG_SPIFFS_USE_MAGIC=y +CONFIG_SPIFFS_USE_MAGIC_LENGTH=y +CONFIG_SPIFFS_META_LENGTH=4 +CONFIG_SPIFFS_USE_MTIME=y + +# +# Debug Configuration +# +# CONFIG_SPIFFS_DBG is not set +# CONFIG_SPIFFS_API_DBG is not set +# CONFIG_SPIFFS_GC_DBG is not set +# CONFIG_SPIFFS_CACHE_DBG is not set +# CONFIG_SPIFFS_CHECK_DBG is not set +# CONFIG_SPIFFS_TEST_VISUALISATION is not set +# end of Debug Configuration +# end of SPIFFS Configuration + +# +# TCP Transport +# + +# +# Websocket +# +CONFIG_WS_TRANSPORT=y +CONFIG_WS_BUFFER_SIZE=1024 +# end of Websocket +# end of TCP Transport + +# +# Unity unit testing library +# +CONFIG_UNITY_ENABLE_FLOAT=y +CONFIG_UNITY_ENABLE_DOUBLE=y +# CONFIG_UNITY_ENABLE_64BIT is not set +# CONFIG_UNITY_ENABLE_COLOR is not set +CONFIG_UNITY_ENABLE_IDF_TEST_RUNNER=y +# CONFIG_UNITY_ENABLE_FIXTURE is not set +# CONFIG_UNITY_ENABLE_BACKTRACE_ON_FAIL is not set +# end of Unity unit testing library + +# +# Virtual file system +# +CONFIG_VFS_SUPPORT_IO=y +CONFIG_VFS_SUPPORT_DIR=y +CONFIG_VFS_SUPPORT_SELECT=y +CONFIG_VFS_SUPPRESS_SELECT_DEBUG_OUTPUT=y +CONFIG_VFS_SUPPORT_TERMIOS=y + +# +# Host File System I/O (Semihosting) +# +CONFIG_VFS_SEMIHOSTFS_MAX_MOUNT_POINTS=1 +# end of Host File System I/O (Semihosting) +# end of Virtual file system + +# +# Wear Levelling +# +# CONFIG_WL_SECTOR_SIZE_512 is not set +CONFIG_WL_SECTOR_SIZE_4096=y +CONFIG_WL_SECTOR_SIZE=4096 +# end of Wear Levelling + +# +# Wi-Fi Provisioning Manager +# +CONFIG_WIFI_PROV_SCAN_MAX_ENTRIES=16 +CONFIG_WIFI_PROV_AUTOSTOP_TIMEOUT=30 +CONFIG_WIFI_PROV_BLE_FORCE_ENCRYPTION=y +# end of Wi-Fi Provisioning Manager + +# +# Supplicant +# +CONFIG_WPA_MBEDTLS_CRYPTO=y +# CONFIG_WPA_WAPI_PSK is not set +# CONFIG_WPA_SUITE_B_192 is not set +# CONFIG_WPA_DEBUG_PRINT is not set +# CONFIG_WPA_TESTING_OPTIONS is not set +# CONFIG_WPA_WPS_STRICT is not set +# CONFIG_WPA_11KV_SUPPORT is not set +# CONFIG_WPA_MBO_SUPPORT is not set +# CONFIG_WPA_DPP_SUPPORT is not set +# end of Supplicant +# end of Component config + +# +# Compatibility options +# +# CONFIG_LEGACY_INCLUDE_COMMON_HEADERS is not set +# end of Compatibility options + +# Deprecated options for backward compatibility +CONFIG_TOOLPREFIX="xtensa-esp32-elf-" +# CONFIG_LOG_BOOTLOADER_LEVEL_NONE is not set +# CONFIG_LOG_BOOTLOADER_LEVEL_ERROR is not set +# CONFIG_LOG_BOOTLOADER_LEVEL_WARN is not set +CONFIG_LOG_BOOTLOADER_LEVEL_INFO=y +# CONFIG_LOG_BOOTLOADER_LEVEL_DEBUG is not set +# CONFIG_LOG_BOOTLOADER_LEVEL_VERBOSE is not set +CONFIG_LOG_BOOTLOADER_LEVEL=3 +# CONFIG_APP_ROLLBACK_ENABLE is not set +# CONFIG_FLASH_ENCRYPTION_ENABLED is not set +# CONFIG_FLASHMODE_QIO is not set +# CONFIG_FLASHMODE_QOUT is not set +CONFIG_FLASHMODE_DIO=y +# CONFIG_FLASHMODE_DOUT is not set +# CONFIG_MONITOR_BAUD_9600B is not set +# CONFIG_MONITOR_BAUD_57600B is not set +CONFIG_MONITOR_BAUD_115200B=y +# CONFIG_MONITOR_BAUD_230400B is not set +# CONFIG_MONITOR_BAUD_921600B is not set +# CONFIG_MONITOR_BAUD_2MB is not set +# CONFIG_MONITOR_BAUD_OTHER is not set +CONFIG_MONITOR_BAUD_OTHER_VAL=115200 +CONFIG_MONITOR_BAUD=115200 +CONFIG_COMPILER_OPTIMIZATION_LEVEL_DEBUG=y +# CONFIG_COMPILER_OPTIMIZATION_LEVEL_RELEASE is not set +CONFIG_OPTIMIZATION_ASSERTIONS_ENABLED=y +# CONFIG_OPTIMIZATION_ASSERTIONS_SILENT is not set +# CONFIG_OPTIMIZATION_ASSERTIONS_DISABLED is not set +CONFIG_OPTIMIZATION_ASSERTION_LEVEL=2 +# CONFIG_CXX_EXCEPTIONS is not set +CONFIG_STACK_CHECK_NONE=y +# CONFIG_STACK_CHECK_NORM is not set +# CONFIG_STACK_CHECK_STRONG is not set +# CONFIG_STACK_CHECK_ALL is not set +# CONFIG_WARN_WRITE_STRINGS is not set +# CONFIG_DISABLE_GCC8_WARNINGS is not set +# CONFIG_ESP32_APPTRACE_DEST_TRAX is not set +CONFIG_ESP32_APPTRACE_DEST_NONE=y +CONFIG_ESP32_APPTRACE_LOCK_ENABLE=y +CONFIG_ADC2_DISABLE_DAC=y +# CONFIG_SPIRAM_SUPPORT is not set +CONFIG_TRACEMEM_RESERVE_DRAM=0x0 +# CONFIG_ULP_COPROC_ENABLED is not set +CONFIG_ULP_COPROC_RESERVE_MEM=0 +CONFIG_BROWNOUT_DET=y +CONFIG_BROWNOUT_DET_LVL_SEL_0=y +# CONFIG_BROWNOUT_DET_LVL_SEL_1 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_2 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_3 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_4 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_5 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_6 is not set +# CONFIG_BROWNOUT_DET_LVL_SEL_7 is not set +CONFIG_BROWNOUT_DET_LVL=0 +CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_RC=y +# CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_CRYSTAL is not set +# CONFIG_ESP32_RTC_CLOCK_SOURCE_EXTERNAL_OSC is not set +# CONFIG_ESP32_RTC_CLOCK_SOURCE_INTERNAL_8MD256 is not set +# CONFIG_DISABLE_BASIC_ROM_CONSOLE is not set +# CONFIG_NO_BLOBS is not set +# CONFIG_COMPATIBLE_PRE_V2_1_BOOTLOADERS is not set +# CONFIG_EVENT_LOOP_PROFILING is not set +CONFIG_POST_EVENTS_FROM_ISR=y +CONFIG_POST_EVENTS_FROM_IRAM_ISR=y +# CONFIG_TWO_UNIVERSAL_MAC_ADDRESS is not set +CONFIG_FOUR_UNIVERSAL_MAC_ADDRESS=y +CONFIG_NUMBER_OF_UNIVERSAL_MAC_ADDRESS=4 +CONFIG_ESP_SYSTEM_PD_FLASH=y +# CONFIG_ESP32C3_LIGHTSLEEP_GPIO_RESET_WORKAROUND is not set +CONFIG_IPC_TASK_STACK_SIZE=1536 +CONFIG_ESP32_PHY_CALIBRATION_AND_DATA_STORAGE=y +# CONFIG_ESP32_PHY_INIT_DATA_IN_PARTITION is not set +CONFIG_ESP32_PHY_MAX_WIFI_TX_POWER=20 +CONFIG_ESP32_PHY_MAX_TX_POWER=20 +CONFIG_ESP32_REDUCE_PHY_TX_POWER=y +# CONFIG_ESP32S2_PANIC_PRINT_HALT is not set +CONFIG_ESP32S2_PANIC_PRINT_REBOOT=y +# CONFIG_ESP32S2_PANIC_SILENT_REBOOT is not set +# CONFIG_ESP32S2_PANIC_GDBSTUB is not set +CONFIG_SYSTEM_EVENT_QUEUE_SIZE=32 +CONFIG_SYSTEM_EVENT_TASK_STACK_SIZE=2304 +CONFIG_MAIN_TASK_STACK_SIZE=3584 +CONFIG_CONSOLE_UART_DEFAULT=y +# CONFIG_CONSOLE_UART_CUSTOM is not set +# CONFIG_ESP_CONSOLE_UART_NONE is not set +CONFIG_CONSOLE_UART=y +CONFIG_CONSOLE_UART_NUM=0 +CONFIG_CONSOLE_UART_BAUDRATE=115200 +CONFIG_INT_WDT=y +CONFIG_INT_WDT_TIMEOUT_MS=300 +CONFIG_INT_WDT_CHECK_CPU1=y +CONFIG_TASK_WDT=y +# CONFIG_TASK_WDT_PANIC is not set +CONFIG_TASK_WDT_TIMEOUT_S=5 +CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU0=y +CONFIG_TASK_WDT_CHECK_IDLE_TASK_CPU1=y +# CONFIG_ESP32_DEBUG_STUBS_ENABLE is not set +CONFIG_TIMER_TASK_STACK_SIZE=3584 +# CONFIG_ESP32_ENABLE_COREDUMP_TO_FLASH is not set +# CONFIG_ESP32_ENABLE_COREDUMP_TO_UART is not set +CONFIG_ESP32_ENABLE_COREDUMP_TO_NONE=y +CONFIG_MB_MASTER_TIMEOUT_MS_RESPOND=150 +CONFIG_MB_MASTER_DELAY_MS_CONVERT=200 +CONFIG_MB_QUEUE_LENGTH=20 +CONFIG_MB_SERIAL_TASK_STACK_SIZE=4096 +CONFIG_MB_SERIAL_BUF_SIZE=256 +CONFIG_MB_SERIAL_TASK_PRIO=10 +CONFIG_MB_CONTROLLER_SLAVE_ID_SUPPORT=y +CONFIG_MB_CONTROLLER_SLAVE_ID=0x00112233 +CONFIG_MB_CONTROLLER_NOTIFY_TIMEOUT=20 +CONFIG_MB_CONTROLLER_NOTIFY_QUEUE_SIZE=20 +CONFIG_MB_CONTROLLER_STACK_SIZE=4096 +CONFIG_MB_EVENT_QUEUE_TIMEOUT=20 +# CONFIG_MB_TIMER_PORT_ENABLED is not set +CONFIG_MB_TIMER_GROUP=0 +CONFIG_MB_TIMER_INDEX=0 +# CONFIG_ENABLE_STATIC_TASK_CLEAN_UP_HOOK is not set +CONFIG_TIMER_TASK_PRIORITY=1 +CONFIG_TIMER_TASK_STACK_DEPTH=2048 +CONFIG_TIMER_QUEUE_LENGTH=10 +# CONFIG_L2_TO_L3_COPY is not set +# CONFIG_USE_ONLY_LWIP_SELECT is not set +CONFIG_ESP_GRATUITOUS_ARP=y +CONFIG_GARP_TMR_INTERVAL=60 +CONFIG_TCPIP_RECVMBOX_SIZE=32 +CONFIG_TCP_MAXRTX=12 +CONFIG_TCP_SYNMAXRTX=12 +CONFIG_TCP_MSS=1440 +CONFIG_TCP_MSL=60000 +CONFIG_TCP_SND_BUF_DEFAULT=5744 +CONFIG_TCP_WND_DEFAULT=5744 +CONFIG_TCP_RECVMBOX_SIZE=6 +CONFIG_TCP_QUEUE_OOSEQ=y +# CONFIG_ESP_TCP_KEEP_CONNECTION_WHEN_IP_CHANGES is not set +CONFIG_TCP_OVERSIZE_MSS=y +# CONFIG_TCP_OVERSIZE_QUARTER_MSS is not set +# CONFIG_TCP_OVERSIZE_DISABLE is not set +CONFIG_UDP_RECVMBOX_SIZE=6 +CONFIG_TCPIP_TASK_STACK_SIZE=3072 +CONFIG_TCPIP_TASK_AFFINITY_NO_AFFINITY=y +# CONFIG_TCPIP_TASK_AFFINITY_CPU0 is not set +# CONFIG_TCPIP_TASK_AFFINITY_CPU1 is not set +CONFIG_TCPIP_TASK_AFFINITY=0x7FFFFFFF +# CONFIG_PPP_SUPPORT is not set +CONFIG_ESP32_PTHREAD_TASK_PRIO_DEFAULT=5 +CONFIG_ESP32_PTHREAD_TASK_STACK_SIZE_DEFAULT=3072 +CONFIG_ESP32_PTHREAD_STACK_MIN=768 +CONFIG_ESP32_DEFAULT_PTHREAD_CORE_NO_AFFINITY=y +# CONFIG_ESP32_DEFAULT_PTHREAD_CORE_0 is not set +# CONFIG_ESP32_DEFAULT_PTHREAD_CORE_1 is not set +CONFIG_ESP32_PTHREAD_TASK_CORE_DEFAULT=-1 +CONFIG_ESP32_PTHREAD_TASK_NAME_DEFAULT="pthread" +CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ABORTS=y +# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_FAILS is not set +# CONFIG_SPI_FLASH_WRITING_DANGEROUS_REGIONS_ALLOWED is not set +CONFIG_SUPPRESS_SELECT_DEBUG_OUTPUT=y +CONFIG_SUPPORT_TERMIOS=y +CONFIG_SEMIHOSTFS_MAX_MOUNT_POINTS=1 +# End of deprecated options diff --git a/Robotito/src/CMakeLists.txt b/Robotito/src/CMakeLists.txt new file mode 100644 index 0000000..483bc0c --- /dev/null +++ b/Robotito/src/CMakeLists.txt @@ -0,0 +1,6 @@ +# This file was automatically generated for projects +# without default 'CMakeLists.txt' file. + +FILE(GLOB_RECURSE app_sources ${CMAKE_SOURCE_DIR}/src/*.*) + +idf_component_register(SRCS ${app_sources}) diff --git a/Robotito/src/control/CMakeLists.txt b/Robotito/src/control/CMakeLists.txt new file mode 100644 index 0000000..ea4a9bd --- /dev/null +++ b/Robotito/src/control/CMakeLists.txt @@ -0,0 +1,3 @@ +idf_component_register(SRCS "control.c" + INCLUDE_DIRS "include" + REQUIRES motors encoders hwTimer math_vector_operations) diff --git a/Robotito/src/control/control.c b/Robotito/src/control/control.c new file mode 100644 index 0000000..09219e6 --- /dev/null +++ b/Robotito/src/control/control.c @@ -0,0 +1,221 @@ +#include <stdio.h> +#include "control.h" + +/* + * Helper functions + */ + +static void callback_enc_func(int i_callback, int8_t dir, uint32_t counter) { + motors[i_callback].vel_counter+=dir; + motors[i_callback].odom_counter+=dir; +} + +static void getW(sF3dVector_t* v, float phi){ + + float pi_3 = PI/3; + + sF3dMatrix_t m; + m.x1 = -sin(phi); + m.y1 = cos(phi); + m.z1 = ROBOT_RADIUS; + m.x2 = -sin(pi_3 - phi); + m.y2 = -cos(pi_3 - phi); + m.z2 = ROBOT_RADIUS; + m.x3 = sin(pi_3 + phi); + m.y3 = -cos(pi_3 + phi); + m.z3 = ROBOT_RADIUS; + + vector_mul(m, v); +} + +static void getInverseW(sF3dVector_t* v, float phi){ + + float pi_6 = PI/6; + float dostercios = 2.0/3; + float robot_r_3 = 1.0/(ROBOT_RADIUS*3); + + sF3dMatrix_t m; + m.x1 = -sin(phi)*dostercios; + m.y1 = -cos(pi_6 + phi)*dostercios; + m.z1 = cos(phi - pi_6)*dostercios; + m.x2 = cos(phi)*dostercios; + m.y2 = -sin(pi_6 + phi)*dostercios; + m.z2 = sin(phi - pi_6)*dostercios; + m.x3 = robot_r_3; + m.y3 = robot_r_3; + m.z3 = robot_r_3; + + vector_mul(m, v); + +} + +static void callback_motors_pid(){ + for (int i=0; i<NMOTORS; i++) { + servo_t *m = &(motors[i]); + + float current_v = m->vel_counter / OMNI_PID_CTRL_TIMER; // compute curren motor vel in tics/s + m->vel_counter = 0; // reset counter + //printf("motor %i, tics: %i, current_v: %f\n", i, m->counter, current_v); + + float error = m->target_v - current_v; // compute error + float accum_error = m->accum_error+error; // accumulate error + + m->output = KF * m->target_v; // compute PID output value + m->output += KP * error; + m->output += KI * accum_error; + m->output += KD * (error - m->prev_error); + + if (m->output>MAX_OUTPUT) { + m->output=MAX_OUTPUT; + } else if (m->output<-MAX_OUTPUT) { + m->output=-MAX_OUTPUT; + } else { + m->accum_error = accum_error; // only here, for windup protection + } + + m->prev_error = error; // save prev error + } + + // set motors speeds + for (int i=0; i<NMOTORS; i++) { + motor_set_speed(motors[i].driver, motors[i].output); + } +} + +static void callback_odometry(){ + odom_t *o = &(odometry); // get odometry actual info + + int32_t tics_motores[NMOTORS]; + for (int i=0; i<NMOTORS; i++) { + servo_t *m = &(motors[i]); + tics_motores[i] = m->odom_counter; // get motors odomo counter + m->odom_counter = 0; // reset counter + } + + sF3dVector_t *v = calloc(1, sizeof(sF3dVector_t)); + v->x = tics_motores[0] * TICS_TO_RAD_S * WHEEL_RADIUS; + v->y = tics_motores[1] * TICS_TO_RAD_S * WHEEL_RADIUS; + v->z = tics_motores[2] * TICS_TO_RAD_S * WHEEL_RADIUS; + + getInverseW(v, o->phi); + + o->x += v->x; + o->x_dot = v->x; + o->y += v->y; + o->y_dot = v->y; + o->phi += v->z; + o->phi_dot = v->z; + + free(v); +} + +/* + * Operation functions + */ + +esp_err_t omni_init(){ + + int8_t default_pins[] = MOTOR_PINS; + int8_t default_enc[] = MOTOR_ENC; + mcpwm_io_signals_t default_pwm_subunit_io[] = MOTOR_PWM_SUBUNIT_IO; + mcpwm_timer_t default_pwm_subunit_timer[] = MOTOR_PWM_SUBUNIT_TIMER; + + + for (int i=0; i<NMOTORS; i++) { + + int8_t pin1 = default_pins[2*i]; + int8_t pin2 = default_pins[2*i+1]; + int8_t encA = default_enc[2*i]; + int8_t encB = default_enc[2*i+1]; + mcpwm_io_signals_t pwm_a = default_pwm_subunit_io[2*i]; + mcpwm_io_signals_t pwm_b = default_pwm_subunit_io[2*i+1]; + mcpwm_timer_t timer_unit = default_pwm_subunit_timer[i]; + + printf("Setting motor %d pins:%d,%d enc:%d,%d", i, pin1, pin2, encA, encB); + + motor_h_t *m; + motor_install(pin1,pin2, MOTOR_PWM_UNIT, pwm_a, pwm_b, timer_unit, &m); + + //saving servo structure + motors[i].driver= m; + + //encoder + encoder_h_t *e; + encoder_setup(encA,encB,&e); + encoder_register_callback(e, callback_enc_func, i, 1); + + //saving encoder structure + motors[i].encoder=e; + + printf(" done\r\n"); + motors[i].target_v=0; + } + + odometry.x = 0; + odometry.x_dot = 0; + odometry.y = 0; + odometry.y_dot = 0; + odometry.phi = 0; + odometry.phi_dot = 0; + + // SET TASK TO RUN ISR for motors pid and odometry. + + if (tmr_setup(OMNI_PID_NRO_TIMER, 1000*1000*OMNI_PID_CTRL_TIMER, callback_motors_pid) != ESP_OK) { + return ESP_FAIL; + } + + if (tmr_setup(OMNI_ODOM_NRO_TIMER, 1000*1000*OMNI_ODOM_CTRL_TIMER, callback_odometry) != ESP_OK) { + return ESP_FAIL; + } + + return ESP_OK; +}; + +esp_err_t omni_set_enable(bool start){ + if (start){ + if ((tmr_start(OMNI_PID_NRO_TIMER) != ESP_OK)) { + return ESP_FAIL; + } + if ((tmr_start(OMNI_ODOM_NRO_TIMER) != ESP_OK)) { + return ESP_FAIL; + } + for (int i=0; i<NMOTORS; i++) { + motor_start(motors[i].driver); + motors[i].vel_counter = 0; + motors[i].odom_counter = 0; + } + }else{ + if ((tmr_stop(OMNI_PID_NRO_TIMER) != ESP_OK)) { + return ESP_FAIL; + } + if ((tmr_stop(OMNI_ODOM_NRO_TIMER) != ESP_OK)) { + return ESP_FAIL; + } + for (int i=0; i<NMOTORS; i++) { + motor_stop(motors[i].driver); + } + } + return ESP_OK; +} + +esp_err_t omni_drive(float x_dot ,float y_dot ,float w_dot ,float phi){ + + sF3dVector_t *v = calloc(1, sizeof(sF3dVector_t)); + v->x = x_dot; + v->y = y_dot; + v->z = w_dot; + + getW(v, phi); + + motors[0].target_v = v->x * M_PER_SEC_TO_TICS_PER_SEC; + motors[1].target_v = v->y * M_PER_SEC_TO_TICS_PER_SEC; + motors[2].target_v = v->z * M_PER_SEC_TO_TICS_PER_SEC; + + free(v); + + motors[0].accum_error = 0; + motors[1].accum_error = 0; + motors[2].accum_error = 0; + + return ESP_OK; +} diff --git a/Robotito/src/control/include/control.h b/Robotito/src/control/include/control.h new file mode 100644 index 0000000..8470f8c --- /dev/null +++ b/Robotito/src/control/include/control.h @@ -0,0 +1,84 @@ +#ifndef CONTROL_H +#define CONTROL_H + +#include <stdint.h> +#include "esp_err.h" +#include "motors.h" +#include "encoders.h" +#include "hwTimer.h" +#include "math_vector_operations.h" + +#define NMOTORS 3 +#define MOTOR_PINS {25,26, 27,28, 29,30} +#define MOTOR_ENC {39,37, 38,36, 34,35} + +#define MOTOR_PWM_SUBUNIT_IO {MCPWM0A, MCPWM0B, MCPWM1A, MCPWM1B, MCPWM2A, MCPWM2B} +#define MOTOR_PWM_SUBUNIT_TIMER {MCPWM_TIMER_0, MCPWM_TIMER_1, MCPWM_TIMER_2} +#define MOTOR_PWM_UNIT MCPWM_UNIT_0 +#define OMNI_PID_NRO_TIMER 0 +#define OMNI_ODOM_NRO_TIMER 2 + +#define OMNI_PID_CTRL_TIMER 0.05 // in seconds +#define OMNI_ODOM_CTRL_TIMER 0.5 // in seconds + +#define MAX_OUTPUT 100.0 +#define WHEEL_DIAMETER 0.038 // in meters +#define WHEEL_RADIUS WHEEL_DIAMETER/2// in meters +#define ROBOT_RADIUS 0.0675 // in meters + +#define ENC_CPR 3 //counts per revolution +#define MOTOR_REDUCTION 50 +#define TICS_PER_REVOLUTION ENC_CPR*MOTOR_REDUCTION +#define RAD_PER_TICK 2*PI/TICS_PER_REVOLUTION +#define M_PER_SEC_TO_TICS_PER_SEC 1/(RAD_PER_TICK*WHEEL_RADIUS) + +#define MAX_SPEED_POWER 90 // power % at which MAX_SPEED_TICS is obtained +#define MAX_SPEED_TICS 1080 //tics/s at MAX_SPEED_POWER + +#define MAX_SPEED_RAD MAX_SPEED_TICS*RAD_PER_TICK // rad/s +#define MAX_SPEED_LIN MAX_SPEED_RAD*WHEEL_DIAMETER / 2 // m/s + +#define TICS_TO_RAD_S RAD_PER_TICK/OMNI_ODOM_CTRL_TIMER + +#define KP 0.01 +#define KI 0.05 +#define KD 0.0 +#define KF MAX_SPEED_POWER/MAX_SPEED_TICS + +typedef struct { + + motor_h_t *driver; + encoder_h_t *encoder; + + int32_t vel_counter; + int32_t odom_counter; + + float target_v; + float accum_error; + float prev_error; + float output; + +} servo_t; + +typedef struct { + float x; + float x_dot; + float y; + float y_dot; + float phi; + float phi_dot; + +} odom_t; + + + +static servo_t motors[NMOTORS]; +static odom_t odometry; + +esp_err_t omni_init(); + +esp_err_t omni_set_enable(bool start); + +esp_err_t omni_drive(float x_dot ,float y_dot ,float w_dot ,float phi); + +#endif /* CONTROL_H */ \ No newline at end of file diff --git a/Robotito/src/encoders/CMakeLists.txt b/Robotito/src/encoders/CMakeLists.txt new file mode 100644 index 0000000..ed27a46 --- /dev/null +++ b/Robotito/src/encoders/CMakeLists.txt @@ -0,0 +1,2 @@ +idf_component_register(SRCS "encoders.c" + INCLUDE_DIRS "include") diff --git a/Robotito/src/encoders/encoders.c b/Robotito/src/encoders/encoders.c new file mode 100644 index 0000000..c587bce --- /dev/null +++ b/Robotito/src/encoders/encoders.c @@ -0,0 +1,319 @@ +/* Rotary encoder handler for arduino. v1.1 + * + * Copyright 2011 Ben Buxton. Licenced under the GNU GPL Version 3. + * Contact: bb@cactii.net + * + * A typical mechanical rotary encoder emits a two bit gray code + * on 3 output pins. Every step in the output (often accompanied + * by a physical 'click') generates a specific sequence of output + * codes on the pins. + * + * There are 3 pins used for the rotary encoding - one common and + * two 'bit' pins. + * + * The following is the typical sequence of code on the output when + * moving from one step to the next: + * + * Position Bit1 Bit2 + * ---------------------- + * Step1 0 0 + * 1/4 1 0 + * 1/2 1 1 + * 3/4 0 1 + * Step2 0 0 + * + * From this table, we can see that when moving from one 'click' to + * the next, there are 4 changes in the output code. + * + * - From an initial 0 - 0, Bit1 goes high, Bit0 stays low. + * - Then both bits are high, halfway through the step. + * - Then Bit1 goes low, but Bit2 stays high. + * - Finally at the end of the step, both bits return to 0. + * + * Detecting the direction is easy - the table simply goes in the other + * direction (read up instead of down). + * + * To decode this, we use a simple state machine. Every time the output + * code changes, it follows state, until finally a full steps worth of + * code is received (in the correct order). At the final 0-0, it returns + * a value indicating a step in one direction or the other. + * + * It's also possible to use 'half-step' mode. This just emits an event + * at both the 0-0 and 1-1 positions. This might be useful for some + * encoders where you want to detect all positions. + * + * If an invalid state happens (for example we go from '0-1' straight + * to '1-0'), the state machine resets to the start until 0-0 and the + * next valid codes occur. + * + * The biggest advantage of using a state machine over other algorithms + * is that this has inherent debounce built in. Other algorithms emit spurious + * output with switch bounce, but this one will simply flip between + * sub-states until the bounce settles, then continue along the state + * machine. + * A side effect of debounce is that fast rotations can cause steps to + * be skipped. By not requiring debounce, fast rotations can be accurately + * measured. + * Another advantage is the ability to properly handle bad state, such + * as due to EMI, etc. + * It is also a lot simpler than others - a static state table and less + * than 10 lines of logic. + */ + +#include "sdkconfig.h" +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/queue.h" +#include "esp_attr.h" +#include "encoders.h" +#include "driver/gpio.h" + + +#include <stdio.h> +#include <string.h> + + + +/* + * The below state table has, for each state (row), the new state + * to set based on the next encoder output. From left to right in, + * the table, the encoder outputs are 00, 01, 10, 11, and the value + * in that position is the new state to set. + */ + +// Values returned by 'process' +// No complete step yet. +#define DIR_NONE 0x0 +// Clockwise step. +#define DIR_CW 0x10 +// Anti-clockwise step. +#define DIR_CCW 0x20 +#define R_START 0x0 + +// Use the full-step state table (emits a code at 00 only) +#define R_CW_FINAL 0x1 +#define R_CW_BEGIN 0x2 +#define R_CW_NEXT 0x3 +#define R_CCW_BEGIN 0x4 +#define R_CCW_FINAL 0x5 +#define R_CCW_NEXT 0x6 + +#define GPIO_ALL_IN 0b1111111100001110111111111111111111111111ULL + +const uint8_t ttable[7][4] = { + // R_START + {R_START, R_CW_BEGIN, R_CCW_BEGIN, R_START}, + // R_CW_FINAL + {R_CW_NEXT, R_START, R_CW_FINAL, R_START | DIR_CW}, + // R_CW_BEGIN + {R_CW_NEXT, R_CW_BEGIN, R_START, R_START}, + // R_CW_NEXT + {R_CW_NEXT, R_CW_BEGIN, R_CW_FINAL, R_START}, + // R_CCW_BEGIN + {R_CCW_NEXT, R_START, R_CCW_BEGIN, R_START}, + // R_CCW_FINAL + {R_CCW_NEXT, R_CCW_FINAL, R_START, R_START | DIR_CCW}, + // R_CCW_NEXT + {R_CCW_NEXT, R_CCW_FINAL, R_CCW_BEGIN, R_START}, +}; + +static xQueueHandle queue = NULL; +static TaskHandle_t task = NULL; +static uint8_t attached = 0; + +/* + * Helper functions + */ + +static void encoder_task(void *arg) { + encoder_deferred_data_t data; + + for(;;) { + xQueueReceive(queue, &data, portMAX_DELAY); + + if (data.h->callback) { + data.h->callback(data.h->callback_id, data.dir, data.counter); + } + } +} + +static void IRAM_ATTR encoder_isr(void* arg) { + + encoder_h_t *encoder = (encoder_h_t *)arg; + encoder_deferred_data_t data; + uint8_t result, has_data; + int8_t dir; + + has_data = 0; + dir = 0; + + uint8_t A = (uint8_t) gpio_get_level(encoder->A); + uint8_t B = (uint8_t) gpio_get_level(encoder->B); + + + // Grab state of input pins. + uint8_t pinstate = (A << 1) | B; + + // Determine new state from the pins and state table. + encoder->state = ttable[encoder->state & 0xf][pinstate]; + result = encoder->state & 0x30; + + if (result == DIR_CW) { + encoder->counter++; + has_data = 1; + dir = 1; + } else if (result == DIR_CCW) { + encoder->counter--; + has_data = 1; + dir = -1; + } + + if (has_data && encoder->callback) { + if (encoder->deferred) { + data.h = encoder; + data.counter = encoder->counter; + data.dir = dir; + xQueueSendFromISR(queue, &data, NULL); + } else { + encoder->callback(encoder->callback_id, dir, encoder->counter); + } + } +} + +/* + * Operation functions + */ + +esp_err_t encoder_setup(int8_t a, int8_t b, encoder_h_t **h) { + // Sanity checks + if ((!GPIO_IS_VALID_GPIO(a)) && ((GPIO_ALL_IN & (1ULL << a)))) { + return ESP_ERR_INVALID_ARG; + } + + if ((!GPIO_IS_VALID_GPIO(b)) && ((GPIO_ALL_IN & (1ULL << b)))) { + return ESP_ERR_INVALID_ARG; + } + + // Allocate space for the encoder + encoder_h_t *encoder = calloc(1, sizeof(encoder_h_t)); + if (!encoder) { + return ESP_ERR_NO_MEM; + } + + encoder->A = a; + encoder->B = b; + encoder->state = R_START; + encoder->counter = 0; + + //gpio configuration encoder a + gpio_config_t io_conf; + io_conf.intr_type = GPIO_PIN_INTR_DISABLE; + io_conf.mode = GPIO_MODE_INPUT; + io_conf.pin_bit_mask = (1ULL << a); + io_conf.pull_down_en = 0; + io_conf.pull_up_en = 1; + + gpio_config(&io_conf); + + //gpio configuration encoder b + io_conf.pin_bit_mask = (1ULL << b); + gpio_config(&io_conf); + + gpio_install_isr_service(0); + + gpio_set_pull_mode(a, GPIO_PULLUP_ONLY); + gpio_set_intr_type(a, GPIO_INTR_ANYEDGE); + gpio_isr_handler_add(a, encoder_isr, (void *)encoder); + + gpio_set_pull_mode(b, GPIO_PULLUP_ONLY); + gpio_set_intr_type(b, GPIO_INTR_ANYEDGE); + gpio_isr_handler_add(b, encoder_isr, (void *)encoder); + + + *h = encoder; + + attached++; + + return ESP_OK; +} + +esp_err_t encoder_unsetup(encoder_h_t *h) { + portDISABLE_INTERRUPTS(); + + if (attached == 0) { + portENABLE_INTERRUPTS(); + return ESP_OK; + } + + // Remove interrupts + gpio_isr_handler_remove(h->A); + gpio_isr_handler_remove(h->B); + + if (attached == 1) { + if (task) { + vTaskDelete(task); + task = NULL; + } + + if (queue) { + vQueueDelete(queue); + queue = NULL; + } + } + + attached--; + + free(h); + + portENABLE_INTERRUPTS(); + + return ESP_OK; +} + +esp_err_t encoder_read(encoder_h_t *h, int32_t *val) { + portDISABLE_INTERRUPTS(); + *val = h->counter; + portENABLE_INTERRUPTS(); + + return ESP_OK; +} + +esp_err_t encoder_write(encoder_h_t *h, int32_t val) { + portDISABLE_INTERRUPTS(); + h->counter = val; + portENABLE_INTERRUPTS(); + + return ESP_OK; +} + +esp_err_t encoder_register_callback(encoder_h_t *h, encoder_callback_t callback, int callback_id, uint8_t deferred) { + portDISABLE_INTERRUPTS(); + + h->callback = callback; + h->callback_id = callback_id; + h->deferred = deferred; + + if (deferred) { + if (!queue) { + queue = xQueueCreate(10, sizeof(encoder_deferred_data_t)); + if (!queue) { + portENABLE_INTERRUPTS(); + return ESP_ERR_NO_MEM; + } + } + + if (!task) { + BaseType_t xReturn; + + xReturn = xTaskCreatePinnedToCore(encoder_task, "encoder", CONFIG_ENCODER_THREAD_STACK_SIZE, NULL, CONFIG_ENCODER_THREAD_PRIORITY, &task, CONFIG_ENCODER_CPU); + if (xReturn != pdPASS) { + portENABLE_INTERRUPTS(); + return ESP_ERR_NO_MEM; + } + } + } + + portENABLE_INTERRUPTS(); + + return ESP_OK; +} diff --git a/Robotito/src/encoders/include/encoders.h b/Robotito/src/encoders/include/encoders.h new file mode 100644 index 0000000..1fe4f76 --- /dev/null +++ b/Robotito/src/encoders/include/encoders.h @@ -0,0 +1,35 @@ +#ifndef ENCODER_H +#define ENCODER_H + +#include <stdint.h> +#include "esp_err.h" + +#define CONFIG_ENCODER_THREAD_STACK_SIZE 8192 +#define CONFIG_ENCODER_THREAD_PRIORITY 20 +#define CONFIG_ENCODER_CPU 0 + +typedef void (*encoder_callback_t)(int, int8_t, uint32_t); + +typedef struct { + int8_t A; ///< A pin + int8_t B; ///< B pin + uint8_t state; ///< Current state's machine state + int32_t counter; ///< Current counter value + encoder_callback_t callback; ///< Callback function + int callback_id; ///< Callback id + uint8_t deferred; ///< Deferred callback? +} encoder_h_t; + +typedef struct { + encoder_h_t *h; + int8_t dir; + uint32_t counter; +} encoder_deferred_data_t; + +esp_err_t encoder_setup(int8_t a, int8_t b, encoder_h_t **h); +esp_err_t encoder_unsetup(encoder_h_t *h); +esp_err_t encoder_read(encoder_h_t *h, int32_t *val); +esp_err_t encoder_write(encoder_h_t *h, int32_t val); +esp_err_t encoder_register_callback(encoder_h_t *h, encoder_callback_t callback, int id, uint8_t deferred); + +#endif /* ENCODER_H */ \ No newline at end of file diff --git a/Robotito/src/hwTimer/CMakeLists.txt b/Robotito/src/hwTimer/CMakeLists.txt new file mode 100644 index 0000000..e519eaa --- /dev/null +++ b/Robotito/src/hwTimer/CMakeLists.txt @@ -0,0 +1,2 @@ +idf_component_register(SRCS "hwTimer.c" + INCLUDE_DIRS "include") diff --git a/Robotito/src/hwTimer/hwTimer.c b/Robotito/src/hwTimer/hwTimer.c new file mode 100644 index 0000000..a4f875d --- /dev/null +++ b/Robotito/src/hwTimer/hwTimer.c @@ -0,0 +1,277 @@ +#include "sdkconfig.h" +#include "hwTimer.h" +#include "esp_attr.h" +#include "driver/timer.h" + +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/queue.h" + +#include <math.h> +#include <string.h> + +typedef struct { + tmr_t timer[CPU_LAST_TIMER + 1]; ///< Timer array with needed information about timers + xQueueHandle queue; ///< Alarm queue for deferred callbacks + TaskHandle_t task; ///< Task handle for deferred callbacks +} tmr_driver_t; + +// Driver info +static tmr_driver_t *tmr = NULL; + +void IRAM_ATTR get_group_idx(int8_t unit, int *groupn, int *idx) { + switch (unit) { + case 0: *groupn = 0; *idx = 0; return; + case 1: *groupn = 0; *idx = 1; return; + case 2: *groupn = 1; *idx = 0; return; + case 3: *groupn = 1; *idx = 1; return; + } +} + +static int have_timers(int8_t groupn) { + int i; + + for(i=0; i < CPU_LAST_TIMER + 1;i++) { + if ((groupn == 0) && (i > 1)) { + continue; + } + + if ((groupn == 1) && (i < 2)) { + continue; + } + + if (tmr->timer[i].setup) return 1; + } + + return 0; +} + +static void alarm_task(void *arg) { + tmr_alarm_t alarm; + + for(;;) { + xQueueReceive(tmr->queue, &alarm, portMAX_DELAY); + + if (tmr->timer[alarm.unit].callback) { + tmr->timer[alarm.unit].callback((void *)((int)alarm.unit)); + } + } +} + +static void IRAM_ATTR isr(void *arg) { + int unit = (int) arg; + int groupn, idx; + portBASE_TYPE high_priority_task_awoken = 0; + + // Get group number / idx + get_group_idx(unit, &groupn, &idx); + + // Get timer group device + timg_dev_t *group = (groupn==0?&TIMERG0:&TIMERG1); + + // Check that interrupt is for us + uint32_t intr_status = group->int_st_timers.val; + + if (intr_status & BIT(idx)) { + // Reload alarm value + group->hw_timer[idx].update = 1; + + // Clear inerrupt mask + if (idx == 0) { + group->int_clr_timers.t0 = 1; + } else { + group->int_clr_timers.t1 = 1; + } + + // Queue alarm + tmr_alarm_t alarm; + + alarm.unit = unit; + + xQueueSendFromISR(tmr->queue, &alarm, &high_priority_task_awoken); + + // Enable alarm again + group->hw_timer[idx].config.alarm_en = 1; + } + + if (high_priority_task_awoken == pdTRUE) { + portYIELD_FROM_ISR(); + } +} + +/* + * Low-level functions + * + */ +int tmr_ll_setup(uint8_t unit, uint32_t micros, void(*callback)(void *)) { + int groupn, idx; + + // Allocate space for driver info + if (!tmr) { + tmr = calloc(1, sizeof(tmr_driver_t)); + if (!tmr) { + return -1; + } + } + + if (tmr->timer[unit].setup) { + return 0; + } + + // The ISR a message is queued to the queue and callback is + // executed from a task. + // Create queue if not created + if (!tmr->queue) { + tmr->queue = xQueueCreate(10, sizeof(tmr_alarm_t)); + if (!tmr->queue) { + return -1; + } + } + + // Create task if not created + if (!tmr->task) { + BaseType_t xReturn; + + xReturn = xTaskCreatePinnedToCore(alarm_task, "tmral", CONFIG_HWTIMER_THREAD_STACK_SIZE, NULL, CONFIG_HWTIMER_THREAD_PRIORITY, &tmr->task, xPortGetCoreID()); + if (xReturn != pdPASS) { + return -1; + } + } + + + get_group_idx(unit, &groupn, &idx); + + // Configure time and stop + // Timer is configure for decrement every 1 usec, so + // alarm valus is exactly the period, expressed in usec + timer_config_t config; + + config.alarm_en = 1; + config.auto_reload = 1; + config.counter_dir = TIMER_COUNT_UP; + config.divider = 80; + config.intr_type = TIMER_INTR_LEVEL; + config.counter_en = TIMER_PAUSE; + + timer_init(groupn, idx, &config); + timer_pause(groupn, idx); + + // Set timer at required frequency + timer_set_counter_value(groupn, idx, 0x00000000ULL); + timer_set_alarm_value(groupn, idx, micros); + + // Enable timer interrupt + timer_enable_intr(groupn, idx); + timer_isr_register(groupn, idx, isr, (void *)((int)unit), ESP_INTR_FLAG_IRAM, &tmr->timer[unit].isrh); + + tmr->timer[unit].setup = 1; + tmr->timer[unit].callback = callback; + + return 0; +} + +void tmr_ll_unsetup(uint8_t unit) { + + if (!tmr->timer[unit].setup) { + return; + } + + tmr->timer[unit].callback = NULL; + tmr->timer[unit].setup = 0; + + // Stop timer + tmr_ll_stop(unit); + + // Remove interrupt + esp_intr_free((intr_handle_t)tmr->timer[unit].isrh); + + // If we not have timers destroy queue and task if + // allocated + if (!have_timers(-1)) { + if (tmr->task) { + vTaskDelete(tmr->task); + } + + if (tmr->queue) { + vQueueDelete(tmr->queue); + } + + free(tmr); + tmr = NULL; + } + +} + +void tmr_ll_start(uint8_t unit) { + int groupn, idx; + get_group_idx(unit, &groupn, &idx); + timer_start(groupn, idx); +} + +void tmr_ll_stop(uint8_t unit) { + int groupn, idx; + get_group_idx(unit, &groupn, &idx); + timer_pause(groupn, idx); +} + +/* + * Operation functions + */ +esp_err_t tmr_setup(int8_t unit, uint32_t micros, void(*callback)(void *)) { + // Sanity checks + if ((unit < CPU_FIRST_TIMER) || (unit > CPU_LAST_TIMER)) { + return ESP_ERR_INVALID_ARG; + } + + if (micros < 5) { + return ESP_ERR_INVALID_ARG; + } + + if (tmr_ll_setup(unit, micros, callback) < 0) { + return ESP_ERR_INVALID_ARG; + } + + return ESP_OK; +} + +esp_err_t tmr_unsetup(int8_t unit) { + // Sanity checks + if ((unit < CPU_FIRST_TIMER) || (unit > CPU_LAST_TIMER)) { + return ESP_ERR_INVALID_ARG; + } + + tmr_ll_unsetup(unit); + + return ESP_OK; +} + +esp_err_t tmr_start(int8_t unit) { + // Sanity checks + if ((unit < CPU_FIRST_TIMER) || (unit > CPU_LAST_TIMER)) { + return ESP_ERR_INVALID_ARG; + } + + if (!tmr->timer[unit].setup) { + return ESP_ERR_INVALID_ARG; + } + + tmr_ll_start(unit); + + return ESP_OK; +} + +esp_err_t tmr_stop(int8_t unit) { + // Sanity checks + if ((unit < CPU_FIRST_TIMER) || (unit > CPU_LAST_TIMER)) { + return ESP_ERR_INVALID_ARG; + } + + if (!tmr->timer[unit].setup) { + return ESP_ERR_INVALID_ARG; + } + + tmr_ll_stop(unit); + + return ESP_OK; +} + diff --git a/Robotito/src/hwTimer/include/hwTimer.h b/Robotito/src/hwTimer/include/hwTimer.h new file mode 100644 index 0000000..99936eb --- /dev/null +++ b/Robotito/src/hwTimer/include/hwTimer.h @@ -0,0 +1,130 @@ +#ifndef TIMER_H +#define TIMER_H + +#include "driver/timer.h" +#include <stdint.h> +#include "esp_err.h" + + +#define CONFIG_HWTIMER_THREAD_STACK_SIZE 8192 +#define CONFIG_HWTIMER_THREAD_PRIORITY 10 +#define CPU_LAST_TIMER 3 +#define CPU_FIRST_TIMER 0 + + +typedef struct{ + int8_t unit; +} tmr_alarm_t; + +typedef struct { + uint8_t setup; + void (*callback)(void *); + timer_isr_handle_t isrh; +} tmr_t; + +typedef void(*tmr_isr_t)(void *); + +/** + * @brief Configures a timer. After timer is configured you must start timer using + * tmr_start function. No sanity checks are done (use only in driver develop). + * + * @param unit Hardware timer, from 0 to 3. + * @param micros Period of timer, in microseconds. + * @param callback Callback function to call every micros period. + * @param deferred If 0, the callback are executed in the isr. If 1, the callback + * is deferred and is called outside the interrupt. Non deferred + * callbacks must reside in IRAM. + * + * @return 0 if success, -1 if error (memory error) + * + */ +int tmr_ll_setup(uint8_t unit, uint32_t micros, void(*callback)(void *)); + +/** + * @brief Removes a timer and the resources that uses. + * tmr_start function. No sanity checks are done (use only in driver develop). + * + * @param unit Hardware timer, from 0 to 3. + */ +void tmr_ll_unsetup(uint8_t unit); + +/** + * @brief Start a previous configured timer. No sanity checks are done (use only in driver develop). + * + * @param unit Hardware timer, from 0 to 3. + */ +void tmr_ll_start(uint8_t unit); + +/** + * @brief Stop a previous configured timer. No sanity checks are done (use only in driver develop). + * + * @param unit Hardware timer, from 0 to 3. + */ +void tmr_ll_stop(uint8_t unit); + +/** + * @brief Configures a timer. After timer is configured you must start timer using + * tmr_start function. + * + * @param unit Hardware timer, from 0 to 3. + * @param micros Period of timer, in microseconds. + * @param callback Callback function to call every micros period. + * @param deferred If 0, the callback are executed in the isr. If 1, the callback + * is deferred and is called outside the interrupt. Non deferred + * callbacks must reside in IRAM. + * + * @return + * - NULL success + * - Pointer to driver_error_t if some error occurs. + * + * TIMER_ERR_INVALID_UNIT + * TIMER_ERR_INVALID_PERIOD + * SPI_ERR_DEVICE_IS_NOT_SELECTED + * SPI_ERR_NOT_ENOUGH_MEMORY + */ +esp_err_t tmr_setup(int8_t unit, uint32_t micros, void(*callback)(void *)); + +/** + * @brief Removes a timer and the resources that uses. + * tmr_start function. No sanity checks are done (use only in driver develop). + * + * @param unit Hardware timer, from 0 to 3. + * + * @return + * - NULL success + * - Pointer to driver_error_t if some error occurs. + * + * TIMER_ERR_INVALID_UNIT + */ +esp_err_t tmr_unsetup(int8_t unit); + +/** + * @brief Start a previous configured timer. + * + * @param unit Hardware timer, from 0 to 3. + * + * @return + * - NULL success + * - Pointer to driver_error_t if some error occurs. + * + * TIMER_ERR_IS_NOT_SETUP + */ +esp_err_t tmr_start(int8_t unit); + +/** + * @brief Stop a previous configured timer. + * + * @param unit Hardware timer, from 0 to 3. + * + * @return + * - NULL success + * - Pointer to driver_error_t if some error occurs. + * + * TIMER_ERR_IS_NOT_SETUP + */ +esp_err_t tmr_stop(int8_t unit); + +void get_group_idx(int8_t unit, int *groupn, int *idx); + +#endif /* TIMER_H */ + diff --git a/Robotito/src/main.c b/Robotito/src/main.c new file mode 100644 index 0000000..359e9dc --- /dev/null +++ b/Robotito/src/main.c @@ -0,0 +1,113 @@ +/* GPIO Example + + This example code is in the Public Domain (or CC0 licensed, at your option.) + + Unless required by applicable law or agreed to in writing, this + software is distributed on an "AS IS" BASIS, WITHOUT WARRANTIES OR + CONDITIONS OF ANY KIND, either express or implied. +*/ +#include <stdio.h> +#include <string.h> +#include <stdlib.h> +#include "freertos/FreeRTOS.h" +#include "freertos/task.h" +#include "freertos/queue.h" +#include "driver/gpio.h" +#include "motors.h" +#include "encoders.h" +#include "hwTimer.h" + +#define OMNI_CTRL_TIMER 0.05 // s +#define MAX_OUTPUT 100.0 +#define NMOTORS 3 +#define OMNI_NRO_TIMER 0 + +static void timer_func() { + printf("ECHO TIMER \n"); +} + +void app_main(void) +{ + + //1. mcpwm gpio initialization + motor_h_t *mot; + motor_install(27,26, MCPWM_UNIT_0, MCPWM0A, MCPWM0B, MCPWM_TIMER_0, &mot); + + //2. initial mcpwm configuration + printf("Configuring Initial Parameters of mcpwm...\n"); + motor_start(mot); //Configure PWM0A & PWM0B with above settings + + + int inc = 25; + while (1) { + if (inc == 20){ + motor_start(mot); + } + printf("Vel %i\n", inc); + motor_set_speed(mot, inc); + vTaskDelay(2000 / portTICK_RATE_MS); + motor_set_speed(mot, -inc); + vTaskDelay(2000 / portTICK_RATE_MS); + + + inc++; + if (inc == 30){ + motor_stop(mot); + inc = 20; + printf("Reseting vel ...\n"); + } + } +} + + + +/* +static void callback_enc_func(int i_callback, int8_t dir, uint32_t counter) { + printf("motor %i, dir %i, counter %i\n", i_callback, dir, counter); +} + +void app_main(void) +{ + encoder_h_t *encoder; + encoder_setup(37,39,&encoder); + encoder_register_callback(encoder, callback_enc_func, 0, 1); + + int cnt = 0; + while(1) { + printf("cnt: %d\n", cnt++); + vTaskDelay(10000 / portTICK_RATE_MS); + if (!(cnt % 10)){ + printf("Minimum free heap size: %d bytes\n", esp_get_minimum_free_heap_size()); + } + } +} + +static void mcpwm_example_brushed_motor_control(void *arg) +{ + //1. mcpwm gpio initialization + motor_h_t *mot; + motor_install(27,26, MCPWM_UNIT_0, MCPWM0A, MCPWM0B, MCPWM_TIMER_0, &mot); + + //2. initial mcpwm configuration + printf("Configuring Initial Parameters of mcpwm...\n"); + motor_start(mot); //Configure PWM0A & PWM0B with above settings + + + int inc = 25; + while (1) { + printf("Vel %i\n", inc); + motor_set_speed(mot, inc); + vTaskDelay(2000 / portTICK_RATE_MS); + motor_set_speed(mot, -inc); + vTaskDelay(2000 / portTICK_RATE_MS); + + + inc++; + if (inc == 10){ + inc = 0; + printf("Reseting vel ...\n"); + + } + } +} +*/ \ No newline at end of file diff --git a/Robotito/src/math_vector_operations/CMakeLists.txt b/Robotito/src/math_vector_operations/CMakeLists.txt new file mode 100644 index 0000000..94d7c36 --- /dev/null +++ b/Robotito/src/math_vector_operations/CMakeLists.txt @@ -0,0 +1,2 @@ +idf_component_register(SRCS "math_vector_operations.c" + INCLUDE_DIRS "include") diff --git a/Robotito/src/math_vector_operations/include/math_vector_operations.h b/Robotito/src/math_vector_operations/include/math_vector_operations.h new file mode 100644 index 0000000..bedbbd4 --- /dev/null +++ b/Robotito/src/math_vector_operations/include/math_vector_operations.h @@ -0,0 +1,65 @@ +#ifndef VECTOR_MATH_H +#define VECTOR_MATH_H + +#include "math.h" + +#define PI 3.1415926535897932384626433832795 +#define PIdiv180 (PI/180.0) +#define SQR(x) (x*x) +#define SGN(x) (x<0?-1:1) +#define ABS(x) (x<0?-x:x) +#define NULL_VECTOR F3dVector(0.0f,0.0f,0.0f) + +///////////////////////////////// +//Note: All angles in degrees // +///////////////////////////////// + +typedef struct { + float x,y,z; +} sF3dVector_t; + +typedef struct { + float x1,y1,z1,x2,y2,z2,x3,y3,z3; +} sF3dMatrix_t; + + +float getLength(sF3dVector_t* v); +void normalize(sF3dVector_t* v); + + +/** + * v = v + v2 +**/ +void sum (sF3dVector_t* v, sF3dVector_t v2); + +/** + * v = v - v2 +**/ + +void difference (sF3dVector_t* v, sF3dVector_t v2); + +/** + * v = v*r +**/ +void float_mul (sF3dVector_t* v, float r); + +/** + * v = v/r +**/ +void float_div (sF3dVector_t* v, float r); + +/** + * ret dot product +**/ +float dotProduct (sF3dVector_t* v, sF3dVector_t v2); + +/** + * ret v = vectorial product +**/ +void crossProduct (sF3dVector_t* v, sF3dVector_t v2); + +/** + * v = M*v +**/ +void vector_mul (sF3dMatrix_t m, sF3dVector_t* v); +#endif /* VECTOR_MATH_H */ \ No newline at end of file diff --git a/Robotito/src/math_vector_operations/math_vector_operations.c b/Robotito/src/math_vector_operations/math_vector_operations.c new file mode 100644 index 0000000..96600a8 --- /dev/null +++ b/Robotito/src/math_vector_operations/math_vector_operations.c @@ -0,0 +1,71 @@ +#include <stdio.h> +#include "math_vector_operations.h" + +float getLength(sF3dVector_t* v) +{ + return (float)(sqrt(SQR(v->x)+SQR(v->y)+SQR(v->z))); + +} + +void normalize(sF3dVector_t* v) +{ + float l = getLength(v); + if (l == 0.0f) { + v->x = v->y = v->z = 0.0; + return; + } + v->x = v->x / l; + v->y = v->y / l; + v->z = v->z / l; +} + +void sum (sF3dVector_t* v, sF3dVector_t v2){ + + v->x = v->x + v2.x; + v->y = v->y + v2.y; + v->z = v->z + v2.z; + +} + +void difference (sF3dVector_t* v, sF3dVector_t v2){ + + v->x = v->x - v2.x; + v->y = v->y - v2.y; + v->z = v->z - v2.z; + +} + +void float_mul (sF3dVector_t* v, float r){ + + v->x = v->x * r; + v->y = v->y * r; + v->z = v->z * r; + +} +void float_div (sF3dVector_t* v, float r){ + + v->x = v->x / r; + v->y = v->y / r; + v->z = v->z / r; + +} +float dotProduct (sF3dVector_t* v, sF3dVector_t v2){ + return v->x*v2.x + v->y*v2.y + v->z*v2.z; +} + +void crossProduct (sF3dVector_t* v, sF3dVector_t v2){ + + v->x = v->y*v2.z - v->z*v2.y; + v->y = v->z*v2.x - v->x*v2.z; + v->z = v->x*v2.y - v->y*v2.x; + +} + + +void vector_mul (sF3dMatrix_t m, sF3dVector_t* v){ + + v->x = m.x1*v->x + m.y1*v->y + m.z1*v->z; + v->y = m.x2*v->x + m.y2*v->y + m.z2*v->z; + v->z = m.x3*v->x + m.y3*v->y + m.z3*v->z; + +} diff --git a/Robotito/src/motors/CMakeLists.txt b/Robotito/src/motors/CMakeLists.txt new file mode 100644 index 0000000..6c7a30b --- /dev/null +++ b/Robotito/src/motors/CMakeLists.txt @@ -0,0 +1,2 @@ +idf_component_register(SRCS "motors.c" + INCLUDE_DIRS "include") diff --git a/Robotito/src/motors/include/motors.h b/Robotito/src/motors/include/motors.h new file mode 100644 index 0000000..b2bfbed --- /dev/null +++ b/Robotito/src/motors/include/motors.h @@ -0,0 +1,31 @@ +/* +Program: Motor Library + +File: Motor.h +*/ +#ifndef DRV8833_h +#define DRV8833_h + +#include <stdint.h> +#include "esp_err.h" +#include "driver/mcpwm.h" + +typedef struct { + int intSpeed; + int8_t pin1; + int8_t pin2; + char info; // bit0: isrunning, bit1: braked + double defaultDuty; + mcpwm_unit_t mcpwm_unit; + mcpwm_io_signals_t mcpwm_a; + mcpwm_io_signals_t mcpwm_b; + mcpwm_timer_t mcpwm_timer; +} motor_h_t; + + +esp_err_t motor_install(int8_t a, int8_t b, mcpwm_unit_t pwm_u, mcpwm_io_signals_t pwm1, mcpwm_io_signals_t pwm2, mcpwm_timer_t t, motor_h_t **m); +esp_err_t motor_set_speed(motor_h_t *m, int intIn); +esp_err_t motor_stop(motor_h_t *m); +esp_err_t motor_start(motor_h_t *m); + +#endif /* DRV8833_h */ \ No newline at end of file diff --git a/Robotito/src/motors/motors.c b/Robotito/src/motors/motors.c new file mode 100644 index 0000000..f55eba1 --- /dev/null +++ b/Robotito/src/motors/motors.c @@ -0,0 +1,117 @@ +#include <stdio.h> +#include "motors.h" +#include "driver/gpio.h" + + +#define GPIO_ALL_OUT 0b0000001100001110111111111111111111111111ULL +#define FRECUENCY 1 + +esp_err_t motor_install(int8_t a, int8_t b, mcpwm_unit_t pwm_unit, mcpwm_io_signals_t pwm_a, mcpwm_io_signals_t pwm_b, mcpwm_timer_t t, motor_h_t **m) +{ + + if ((!GPIO_IS_VALID_GPIO(a)) && ((GPIO_ALL_OUT & (1ULL << a)))) { + return ESP_ERR_INVALID_ARG; + } + + if ((!GPIO_IS_VALID_GPIO(b)) && ((GPIO_ALL_OUT & (1ULL << b)))) { + return ESP_ERR_INVALID_ARG; + } + + motor_h_t *motor = calloc(1, sizeof(motor_h_t)); + + if (!motor) { + return ESP_ERR_NO_MEM; + } + + motor->pin1 = a; + motor->pin2 = b; + motor->info = 0x00; + motor->intSpeed = 0; + motor->defaultDuty = 0; + + motor->mcpwm_unit = pwm_unit; + motor->mcpwm_timer = t; + motor->mcpwm_a = pwm_a; + motor->mcpwm_b = pwm_b; + + mcpwm_gpio_init(pwm_unit, pwm_a, a); + mcpwm_gpio_init(pwm_unit, pwm_b, b); + + *m = motor; + + return ESP_OK; +} + +/** + * @brief motor moves in forward direction, with duty cycle = duty % + */ +void motor_forward(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num , float duty_cycle) +{ + mcpwm_set_signal_low(mcpwm_num, timer_num, MCPWM_OPR_B); + mcpwm_set_duty(mcpwm_num, timer_num, MCPWM_OPR_A, duty_cycle); + mcpwm_set_duty_type(mcpwm_num, timer_num, MCPWM_OPR_A, MCPWM_DUTY_MODE_0); //call this each time, if operator was previously in low/high state +} + +/** + * @brief motor moves in backward direction, with duty cycle = duty % + */ +void motor_backward(mcpwm_unit_t mcpwm_num, mcpwm_timer_t timer_num , float duty_cycle) +{ + mcpwm_set_signal_low(mcpwm_num, timer_num, MCPWM_OPR_A); + mcpwm_set_duty(mcpwm_num, timer_num, MCPWM_OPR_B, duty_cycle); + mcpwm_set_duty_type(mcpwm_num, timer_num, MCPWM_OPR_B, MCPWM_DUTY_MODE_0); //call this each time, if operator was previously in low/high state +} + + + +/** + * @brief set motor Speed with duty cycle = duty % + */ +esp_err_t motor_set_speed(motor_h_t *m, int intIn){ + + if (m->info & 0x01){ + if ((intIn >= -100) && (intIn <= 100)) { + m->intSpeed = intIn; + }else { + return ESP_ERR_INVALID_ARG; + } + + if (intIn >= 0){ + motor_forward(m->mcpwm_unit, m->mcpwm_timer, (intIn*1.0)); + }else{ + motor_backward(m->mcpwm_unit, m->mcpwm_timer, (intIn*-1.0) ); + } + } + + return ESP_OK; +} + +/** + * @brief motor stop + */ +esp_err_t motor_stop(motor_h_t *m) +{ + mcpwm_set_signal_low(m->mcpwm_unit, m->mcpwm_timer, MCPWM_OPR_A); + mcpwm_set_signal_low(m->mcpwm_unit, m->mcpwm_timer, MCPWM_OPR_B); + + return ESP_OK; +} + +/** + * @brief motor start + */ +esp_err_t motor_start(motor_h_t *m) +{ + mcpwm_config_t pwm_config; + pwm_config.frequency = 1000 * FRECUENCY; //frequency = 500Hz, + pwm_config.cmpr_a = 0; //duty cycle of PWMxA = 0 + pwm_config.cmpr_b = 0; //duty cycle of PWMxb = 0 + pwm_config.counter_mode = MCPWM_UP_COUNTER; + pwm_config.duty_mode = MCPWM_DUTY_MODE_0; + mcpwm_init(m->mcpwm_unit, m->mcpwm_timer, &pwm_config); //Configure PWM0A & PWM0B with above settings + + m->info = m->info | 0x01; + + return ESP_OK; +} + diff --git a/Robotito/test/README b/Robotito/test/README new file mode 100644 index 0000000..9b1e87b --- /dev/null +++ b/Robotito/test/README @@ -0,0 +1,11 @@ + +This directory is intended for PlatformIO Test Runner and project tests. + +Unit Testing is a software testing method by which individual units of +source code, sets of one or more MCU program modules together with associated +control data, usage procedures, and operating procedures, are tested to +determine whether they are fit for use. Unit testing finds problems early +in the development cycle. + +More information about PlatformIO Unit Testing: +- https://docs.platformio.org/en/latest/advanced/unit-testing/index.html -- GitLab