Skip to content

Commit

Permalink
Use the TASK method to run the callback if _ISR is not supported
Browse files Browse the repository at this point in the history
  • Loading branch information
pjsg committed Apr 23, 2024
1 parent cc436d8 commit 4b99535
Showing 1 changed file with 12 additions and 9 deletions.
21 changes: 12 additions & 9 deletions components/modules/stepper.c
Original file line number Diff line number Diff line change
Expand Up @@ -13,10 +13,16 @@
#endif
#include <esp_timer.h>

#ifdef CONFIG_NODEMCU_CMODULE_STEPPER

#define MAX_PINS 8

#ifdef CONFIG_ESP_TIMER_SUPPORTS_ISR_DISPATCH_METHOD
// ESP_TIMER_ISR is the preferred dispatch method for the timer and is
// enabled by the Kconfig when you select the Stepper module.
#define TIMER_TO_USE ESP_TIMER_ISR
#else
#define TIMER_TO_USE ESP_TIMER_TASK
#endif

typedef unsigned char uint8;

typedef struct {
Expand Down Expand Up @@ -285,12 +291,10 @@ static int stepper_init(lua_State *L) {
}

// Create the timer
esp_timer_create_args_t timer_args = {
.callback = timer_interrupt,
.arg = motor,
.dispatch_method = ESP_TIMER_ISR,
.name = "stepper"
};
esp_timer_create_args_t timer_args = {.callback = timer_interrupt,
.arg = motor,
.dispatch_method = TIMER_TO_USE,
.name = "stepper"};

esp_timer_create(&timer_args, &motor->timer);

Expand Down Expand Up @@ -568,4 +572,3 @@ LUALIB_API int luaopen_stepper (lua_State *L) {

NODEMCU_MODULE(STEPPER, "stepper", stepper, luaopen_stepper);

#endif

0 comments on commit 4b99535

Please sign in to comment.