-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Merge pull request #83 from pvginkel/esp-idf
Added support for ESP-IDF projects.
- Loading branch information
Showing
12 changed files
with
275 additions
and
21 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
name: Build ESP-IDF example project | ||
|
||
on: | ||
push: | ||
branches: [main] | ||
pull_request: | ||
branches: [main] | ||
|
||
jobs: | ||
build: | ||
runs-on: ubuntu-latest | ||
|
||
steps: | ||
- name: Checkout | ||
uses: actions/checkout@v4 | ||
- name: esp-idf build | ||
uses: espressif/esp-idf-ci-action@v1 | ||
with: | ||
esp_idf_version: v5.3.2 | ||
target: esp32 | ||
path: examples/ESPIDFExample |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
idf_component_register( | ||
SRC_DIRS "src/TMC2209" | ||
INCLUDE_DIRS "src" | ||
REQUIRES arduino-esp32 | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
/build | ||
/.vscode | ||
/managed_components | ||
/sdkconfig | ||
/dependencies.lock |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# For more information about build system see | ||
# https://docs.espressif.com/projects/esp-idf/en/latest/api-guides/build-system.html | ||
# The following five lines of boilerplate have to be in your project's | ||
# CMakeLists in this exact order for cmake to work correctly | ||
|
||
cmake_minimum_required(VERSION 3.16) | ||
|
||
include($ENV{IDF_PATH}/tools/cmake/project.cmake) | ||
|
||
project(idf_project_example) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,8 @@ | ||
This folder contains a bare bones functional ESP-IDF project. | ||
|
||
You can create one using the **ESP-IDF: New Project** command in | ||
Visual Studio code, or use this one as a basis. If you do use this one | ||
as a basis for your own project, review the `.gitignore` file as it | ||
excludes files you would not want to exclude in a normal project. | ||
Normally only the `managed_components` and `build` folders would be | ||
excluded from version control. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,6 @@ | ||
FILE(GLOB_RECURSE SOURCES ${CMAKE_CURRENT_SOURCE_DIR}/*.c ${CMAKE_CURRENT_SOURCE_DIR}/*.cpp) | ||
|
||
idf_component_register( | ||
SRCS ${SOURCES} | ||
INCLUDE_DIRS "." | ||
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
dependencies: | ||
TMC2209: | ||
path: ../../.. | ||
# Alternatively you can point this directly at the GitHub repository: | ||
# git: https://github.com/janelia-arduino/TMC2209.git |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,129 @@ | ||
#include <TMC2209.h> | ||
|
||
// This example will not work on Arduino boards without HardwareSerial ports, | ||
// such as the Uno, Nano, and Mini. | ||
// | ||
// See this reference for more details: | ||
// https://www.arduino.cc/reference/en/language/functions/communication/serial/ | ||
|
||
HardwareSerial & serial_stream = Serial1; | ||
|
||
const long SERIAL_BAUD_RATE = 115200; | ||
const int DELAY = 2000; | ||
|
||
// Instantiate TMC2209 | ||
TMC2209 stepper_driver; | ||
|
||
extern "C" void app_main() | ||
{ | ||
Serial.begin(SERIAL_BAUD_RATE); | ||
|
||
stepper_driver.setup(serial_stream); | ||
|
||
Serial.println("*************************"); | ||
Serial.println("getSettings()"); | ||
TMC2209::Settings settings = stepper_driver.getSettings(); | ||
Serial.print("settings.is_communicating = "); | ||
Serial.println(settings.is_communicating); | ||
Serial.print("settings.is_setup = "); | ||
Serial.println(settings.is_setup); | ||
Serial.print("settings.software_enabled = "); | ||
Serial.println(settings.software_enabled); | ||
Serial.print("settings.microsteps_per_step = "); | ||
Serial.println(settings.microsteps_per_step); | ||
Serial.print("settings.inverse_motor_direction_enabled = "); | ||
Serial.println(settings.inverse_motor_direction_enabled); | ||
Serial.print("settings.stealth_chop_enabled = "); | ||
Serial.println(settings.stealth_chop_enabled); | ||
Serial.print("settings.standstill_mode = "); | ||
switch (settings.standstill_mode) | ||
{ | ||
case TMC2209::NORMAL: | ||
Serial.println("normal"); | ||
break; | ||
case TMC2209::FREEWHEELING: | ||
Serial.println("freewheeling"); | ||
break; | ||
case TMC2209::STRONG_BRAKING: | ||
Serial.println("strong_braking"); | ||
break; | ||
case TMC2209::BRAKING: | ||
Serial.println("braking"); | ||
break; | ||
} | ||
Serial.print("settings.irun_percent = "); | ||
Serial.println(settings.irun_percent); | ||
Serial.print("settings.irun_register_value = "); | ||
Serial.println(settings.irun_register_value); | ||
Serial.print("settings.ihold_percent = "); | ||
Serial.println(settings.ihold_percent); | ||
Serial.print("settings.ihold_register_value = "); | ||
Serial.println(settings.ihold_register_value); | ||
Serial.print("settings.iholddelay_percent = "); | ||
Serial.println(settings.iholddelay_percent); | ||
Serial.print("settings.iholddelay_register_value = "); | ||
Serial.println(settings.iholddelay_register_value); | ||
Serial.print("settings.automatic_current_scaling_enabled = "); | ||
Serial.println(settings.automatic_current_scaling_enabled); | ||
Serial.print("settings.automatic_gradient_adaptation_enabled = "); | ||
Serial.println(settings.automatic_gradient_adaptation_enabled); | ||
Serial.print("settings.pwm_offset = "); | ||
Serial.println(settings.pwm_offset); | ||
Serial.print("settings.pwm_gradient = "); | ||
Serial.println(settings.pwm_gradient); | ||
Serial.print("settings.cool_step_enabled = "); | ||
Serial.println(settings.cool_step_enabled); | ||
Serial.print("settings.analog_current_scaling_enabled = "); | ||
Serial.println(settings.analog_current_scaling_enabled); | ||
Serial.print("settings.internal_sense_resistors_enabled = "); | ||
Serial.println(settings.internal_sense_resistors_enabled); | ||
Serial.println("*************************"); | ||
Serial.println(); | ||
|
||
Serial.println("*************************"); | ||
Serial.println("hardwareDisabled()"); | ||
bool hardware_disabled = stepper_driver.hardwareDisabled(); | ||
Serial.print("hardware_disabled = "); | ||
Serial.println(hardware_disabled); | ||
Serial.println("*************************"); | ||
Serial.println(); | ||
|
||
Serial.println("*************************"); | ||
Serial.println("getStatus()"); | ||
TMC2209::Status status = stepper_driver.getStatus(); | ||
Serial.print("status.over_temperature_warning = "); | ||
Serial.println(status.over_temperature_warning); | ||
Serial.print("status.over_temperature_shutdown = "); | ||
Serial.println(status.over_temperature_shutdown); | ||
Serial.print("status.short_to_ground_a = "); | ||
Serial.println(status.short_to_ground_a); | ||
Serial.print("status.short_to_ground_b = "); | ||
Serial.println(status.short_to_ground_b); | ||
Serial.print("status.low_side_short_a = "); | ||
Serial.println(status.low_side_short_a); | ||
Serial.print("status.low_side_short_b = "); | ||
Serial.println(status.low_side_short_b); | ||
Serial.print("status.open_load_a = "); | ||
Serial.println(status.open_load_a); | ||
Serial.print("status.open_load_b = "); | ||
Serial.println(status.open_load_b); | ||
Serial.print("status.over_temperature_120c = "); | ||
Serial.println(status.over_temperature_120c); | ||
Serial.print("status.over_temperature_143c = "); | ||
Serial.println(status.over_temperature_143c); | ||
Serial.print("status.over_temperature_150c = "); | ||
Serial.println(status.over_temperature_150c); | ||
Serial.print("status.over_temperature_157c = "); | ||
Serial.println(status.over_temperature_157c); | ||
Serial.print("status.current_scaling = "); | ||
Serial.println(status.current_scaling); | ||
Serial.print("status.stealth_chop_mode = "); | ||
Serial.println(status.stealth_chop_mode); | ||
Serial.print("status.standstill = "); | ||
Serial.println(status.standstill); | ||
Serial.println("*************************"); | ||
Serial.println(); | ||
|
||
Serial.println(); | ||
delay(DELAY); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
# Required by the android-esp32 component. | ||
CONFIG_FREERTOS_HZ=1000 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,5 @@ | ||
dependencies: | ||
idf: | ||
version: ">=5.3.0" | ||
arduino-esp32: | ||
version: "*" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters