mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-08-27 00:05:06 +02:00
Updates from PWM_ISR_Fix branch (#755)
- $Message/Level - ISR safe ledcWrite
This commit is contained in:
@@ -47,7 +47,7 @@ Some features should not be changed. See notes below.
|
||||
// that the machine file might choose to undefine.
|
||||
|
||||
// Note: HOMING_CYCLES are now settings
|
||||
#define SUPPORT_TASK_CORE 1 // Reference: CONFIG_ARDUINO_RUNNING_CORE = 1
|
||||
#define SUPPORT_TASK_CORE 1 // Reference: CONFIG_ARDUINO_RUNNING_CORE = 1
|
||||
|
||||
// Inverts pin logic of the control command pins based on a mask. This essentially means you can use
|
||||
// normally-closed switches on the specified pins, rather than the default normally-open switches.
|
||||
@@ -87,8 +87,6 @@ const int MAX_N_AXIS = 6;
|
||||
# define LIMIT_MASK B0
|
||||
#endif
|
||||
|
||||
#define GRBL_MSG_LEVEL MsgLevel::Info // what level of [MSG:....] do you want to see 0=all off
|
||||
|
||||
// Serial baud rate
|
||||
// OK to change, but the ESP32 boot text is 115200, so you will not see that is your
|
||||
// serial monitor, sender, etc uses a different value than 115200
|
||||
|
@@ -23,7 +23,7 @@
|
||||
// Grbl versioning system
|
||||
|
||||
const char* const GRBL_VERSION = "1.3a";
|
||||
const char* const GRBL_VERSION_BUILD = "20210129";
|
||||
const char* const GRBL_VERSION_BUILD = "20210203";
|
||||
|
||||
//#include <sdkconfig.h>
|
||||
#include <Arduino.h>
|
||||
|
@@ -111,9 +111,13 @@ void grbl_msg_sendf(uint8_t client, MsgLevel level, const char* format, ...) {
|
||||
if (client == CLIENT_INPUT) {
|
||||
return;
|
||||
}
|
||||
if (level > GRBL_MSG_LEVEL) {
|
||||
return;
|
||||
|
||||
if (message_level != NULL) { // might be null before messages are setup
|
||||
if (level > static_cast<MsgLevel>(message_level->get())) {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
char loc_buf[100];
|
||||
char* temp = loc_buf;
|
||||
va_list arg;
|
||||
|
@@ -52,8 +52,8 @@ enum class Message : uint8_t {
|
||||
#define CLIENT_ALL 0xFF
|
||||
#define CLIENT_COUNT 5 // total number of client types regardless if they are used
|
||||
|
||||
enum class MsgLevel : uint8_t {
|
||||
None = 0, // set GRBL_MSG_LEVEL in config.h to the level you want to see
|
||||
enum class MsgLevel : int8_t { // Use $Message/Level
|
||||
None = 0,
|
||||
Error = 1,
|
||||
Warning = 2,
|
||||
Info = 3,
|
||||
@@ -128,4 +128,4 @@ char* reportAxisLimitsMsg(uint8_t axis);
|
||||
char* reportAxisNameMsg(uint8_t axis);
|
||||
char* reportAxisNameMsg(uint8_t axis, uint8_t dual_axis);
|
||||
|
||||
void reportTaskStackSize(UBaseType_t& saved);
|
||||
void reportTaskStackSize(UBaseType_t& saved);
|
||||
|
@@ -57,6 +57,8 @@ IntSetting* spindle_pwm_bit_precision;
|
||||
|
||||
EnumSetting* spindle_type;
|
||||
|
||||
EnumSetting* message_level;
|
||||
|
||||
enum_opt_t spindleTypes = {
|
||||
// clang-format off
|
||||
{ "NONE", int8_t(SpindleType::NONE) },
|
||||
@@ -71,6 +73,17 @@ enum_opt_t spindleTypes = {
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
enum_opt_t messageLevels = {
|
||||
// clang-format off
|
||||
{ "None", int8_t(MsgLevel::None) },
|
||||
{ "Error", int8_t(MsgLevel::Error) },
|
||||
{ "Warning", int8_t(MsgLevel::Warning) },
|
||||
{ "Info", int8_t(MsgLevel::Info) },
|
||||
{ "Debug", int8_t(MsgLevel::Debug) },
|
||||
{ "Verbose", int8_t(MsgLevel::Verbose) },
|
||||
// clang-format on
|
||||
};
|
||||
|
||||
AxisSettings* x_axis_settings;
|
||||
AxisSettings* y_axis_settings;
|
||||
AxisSettings* z_axis_settings;
|
||||
@@ -256,16 +269,16 @@ void make_settings() {
|
||||
b_axis_settings = axis_settings[B_AXIS];
|
||||
c_axis_settings = axis_settings[C_AXIS];
|
||||
for (axis = MAX_N_AXIS - 1; axis >= 0; axis--) {
|
||||
def = &axis_defaults[axis];
|
||||
auto setting =
|
||||
new IntSetting(EXTENDED, WG, makeGrblName(axis, 170), makename(def->name, "StallGuard"), def->stallguard, -64, 255, postMotorSetting);
|
||||
def = &axis_defaults[axis];
|
||||
auto setting = new IntSetting(
|
||||
EXTENDED, WG, makeGrblName(axis, 170), makename(def->name, "StallGuard"), def->stallguard, -64, 255, postMotorSetting);
|
||||
setting->setAxis(axis);
|
||||
axis_settings[axis]->stallguard = setting;
|
||||
}
|
||||
for (axis = MAX_N_AXIS - 1; axis >= 0; axis--) {
|
||||
def = &axis_defaults[axis];
|
||||
auto setting =
|
||||
new IntSetting(EXTENDED, WG, makeGrblName(axis, 160), makename(def->name, "Microsteps"), def->microsteps, 0, 256, postMotorSetting);
|
||||
def = &axis_defaults[axis];
|
||||
auto setting = new IntSetting(
|
||||
EXTENDED, WG, makeGrblName(axis, 160), makename(def->name, "Microsteps"), def->microsteps, 0, 256, postMotorSetting);
|
||||
setting->setAxis(axis);
|
||||
axis_settings[axis]->microsteps = setting;
|
||||
}
|
||||
@@ -395,4 +408,6 @@ void make_settings() {
|
||||
user_macro2 = new StringSetting(EXTENDED, WG, NULL, "User/Macro2", DEFAULT_USER_MACRO2);
|
||||
user_macro1 = new StringSetting(EXTENDED, WG, NULL, "User/Macro1", DEFAULT_USER_MACRO1);
|
||||
user_macro0 = new StringSetting(EXTENDED, WG, NULL, "User/Macro0", DEFAULT_USER_MACRO0);
|
||||
|
||||
message_level = +new EnumSetting(NULL, EXTENDED, WG, NULL, "Message/Level", static_cast<int8_t>(MsgLevel::Info), &messageLevels, NULL);
|
||||
}
|
||||
|
@@ -65,3 +65,5 @@ extern StringSetting* user_macro0;
|
||||
extern StringSetting* user_macro1;
|
||||
extern StringSetting* user_macro2;
|
||||
extern StringSetting* user_macro3;
|
||||
|
||||
extern EnumSetting* message_level;
|
||||
|
@@ -20,6 +20,7 @@
|
||||
|
||||
*/
|
||||
#include "PWMSpindle.h"
|
||||
#include "soc/ledc_struct.h"
|
||||
|
||||
// ======================= PWM ==============================
|
||||
/*
|
||||
@@ -222,7 +223,15 @@ namespace Spindles {
|
||||
duty = (1 << _pwm_precision) - duty;
|
||||
}
|
||||
|
||||
ledcWrite(_pwm_chan_num, duty);
|
||||
//ledcWrite(_pwm_chan_num, duty);
|
||||
|
||||
// This was ledcWrite, but this is called from an ISR
|
||||
// and ledcWrite uses RTOS features not compatible with ISRs
|
||||
LEDC.channel_group[0].channel[0].duty.duty = duty << 4;
|
||||
bool on = !!duty;
|
||||
LEDC.channel_group[0].channel[0].conf0.sig_out_en = on;
|
||||
LEDC.channel_group[0].channel[0].conf1.duty_start = on;
|
||||
LEDC.channel_group[0].channel[0].conf0.clk_en = on;
|
||||
}
|
||||
|
||||
void PWM::set_enable_pin(bool enable) {
|
||||
|
Reference in New Issue
Block a user