mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-08-30 17:49:56 +02:00
Fixed a few more bugs in machine config. This should be test-able.
This commit is contained in:
@@ -373,11 +373,6 @@ void MachineConfig::afterParse() {
|
|||||||
_coolant = new CoolantControl();
|
_coolant = new CoolantControl();
|
||||||
}
|
}
|
||||||
|
|
||||||
if (_spi == nullptr) {
|
|
||||||
log_info("SPI config missing; building default SPI bus.");
|
|
||||||
_spi = new SPIBus();
|
|
||||||
}
|
|
||||||
|
|
||||||
if (_probe == nullptr) {
|
if (_probe == nullptr) {
|
||||||
log_info("Probe config missing; building default probe.");
|
log_info("Probe config missing; building default probe.");
|
||||||
_probe = new Probe();
|
_probe = new Probe();
|
||||||
|
@@ -91,32 +91,36 @@ namespace Motors {
|
|||||||
config_message();
|
config_message();
|
||||||
|
|
||||||
auto spiConfig = MachineConfig::instance()->_spi;
|
auto spiConfig = MachineConfig::instance()->_spi;
|
||||||
|
if (spiConfig != nullptr) {
|
||||||
|
auto ssPin = spiConfig->_ss.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native);
|
||||||
|
auto mosiPin = spiConfig->_mosi.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native);
|
||||||
|
auto sckPin = spiConfig->_sck.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native);
|
||||||
|
auto misoPin = spiConfig->_miso.getNative(Pin::Capabilities::Input | Pin::Capabilities::Native);
|
||||||
|
|
||||||
auto ssPin = spiConfig->_ss.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native);
|
SPI.begin(sckPin, misoPin, mosiPin, ssPin); // this will get called for each motor, but does not seem to hurt anything
|
||||||
auto mosiPin = spiConfig->_mosi.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native);
|
|
||||||
auto sckPin = spiConfig->_sck.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native);
|
|
||||||
auto misoPin = spiConfig->_miso.getNative(Pin::Capabilities::Input | Pin::Capabilities::Native);
|
|
||||||
|
|
||||||
SPI.begin(sckPin, misoPin, mosiPin, ssPin); // this will get called for each motor, but does not seem to hurt anything
|
tmcstepper->begin();
|
||||||
|
|
||||||
tmcstepper->begin();
|
_has_errors = !test(); // Try communicating with motor. Prints an error if there is a problem.
|
||||||
|
|
||||||
_has_errors = !test(); // Try communicating with motor. Prints an error if there is a problem.
|
read_settings(); // pull info from settings
|
||||||
|
set_mode(false);
|
||||||
|
|
||||||
read_settings(); // pull info from settings
|
// After initializing all of the TMC drivers, create a task to
|
||||||
set_mode(false);
|
// display StallGuard data. List == this for the final instance.
|
||||||
|
if (List == this) {
|
||||||
// After initializing all of the TMC drivers, create a task to
|
xTaskCreatePinnedToCore(readSgTask, // task
|
||||||
// display StallGuard data. List == this for the final instance.
|
"readSgTask", // name for task
|
||||||
if (List == this) {
|
4096, // size of task stack
|
||||||
xTaskCreatePinnedToCore(readSgTask, // task
|
NULL, // parameters
|
||||||
"readSgTask", // name for task
|
1, // priority
|
||||||
4096, // size of task stack
|
NULL,
|
||||||
NULL, // parameters
|
0 // core
|
||||||
1, // priority
|
);
|
||||||
NULL,
|
}
|
||||||
0 // core
|
} else {
|
||||||
);
|
grbl_msg_sendf(CLIENT_SERIAL, MsgLevel::Info, "SPI bus is not available; cannot initialize TMC driver.");
|
||||||
|
_has_errors = true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@@ -133,40 +133,44 @@ uint8_t get_sd_state(bool refresh) {
|
|||||||
// fortunately doesn't change any of the settings.
|
// fortunately doesn't change any of the settings.
|
||||||
auto spiConfig = MachineConfig::instance()->_spi;
|
auto spiConfig = MachineConfig::instance()->_spi;
|
||||||
|
|
||||||
auto ssPin = spiConfig->_ss.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native);
|
if (spiConfig != nullptr) {
|
||||||
auto mosiPin = spiConfig->_mosi.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native);
|
auto ssPin = spiConfig->_ss.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native);
|
||||||
auto sckPin = spiConfig->_sck.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native);
|
auto mosiPin = spiConfig->_mosi.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native);
|
||||||
auto misoPin = spiConfig->_miso.getNative(Pin::Capabilities::Input | Pin::Capabilities::Native);
|
auto sckPin = spiConfig->_sck.getNative(Pin::Capabilities::Output | Pin::Capabilities::Native);
|
||||||
|
auto misoPin = spiConfig->_miso.getNative(Pin::Capabilities::Input | Pin::Capabilities::Native);
|
||||||
|
|
||||||
SPI.begin(sckPin, misoPin, mosiPin, ssPin); // this will get called for each motor, but does not seem to hurt anything
|
SPI.begin(sckPin, misoPin, mosiPin, ssPin); // this will get called for each motor, but does not seem to hurt anything
|
||||||
|
|
||||||
//no need to go further if SD detect is not correct
|
//no need to go further if SD detect is not correct
|
||||||
if (SDCardDetPin->get() != Pin::UNDEFINED) {
|
if (SDCardDetPin->get() != Pin::UNDEFINED) {
|
||||||
if (!((SDCardDetPin->get().read() == SDCARD_DET_VAL) ? true : false)) {
|
if (!((SDCardDetPin->get().read() == SDCARD_DET_VAL) ? true : false)) {
|
||||||
sd_state = SDCARD_NOT_PRESENT;
|
sd_state = SDCARD_NOT_PRESENT;
|
||||||
|
return sd_state;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
//if busy doing something return state
|
||||||
|
if (!((sd_state == SDCARD_NOT_PRESENT) || (sd_state == SDCARD_IDLE))) {
|
||||||
return sd_state;
|
return sd_state;
|
||||||
}
|
}
|
||||||
}
|
if (!refresh) {
|
||||||
|
return sd_state; //to avoid refresh=true + busy to reset SD and waste time
|
||||||
//if busy doing something return state
|
|
||||||
if (!((sd_state == SDCARD_NOT_PRESENT) || (sd_state == SDCARD_IDLE))) {
|
|
||||||
return sd_state;
|
|
||||||
}
|
|
||||||
if (!refresh) {
|
|
||||||
return sd_state; //to avoid refresh=true + busy to reset SD and waste time
|
|
||||||
}
|
|
||||||
|
|
||||||
//SD is idle or not detected, let see if still the case
|
|
||||||
SD.end();
|
|
||||||
sd_state = SDCARD_NOT_PRESENT;
|
|
||||||
//using default value for speed ? should be parameter
|
|
||||||
//refresh content if card was removed
|
|
||||||
if (SD.begin((GRBL_SPI_SS == -1) ? SS : GRBL_SPI_SS, SPI, GRBL_SPI_FREQ, "/sd", 2)) {
|
|
||||||
if (SD.cardSize() > 0) {
|
|
||||||
sd_state = SDCARD_IDLE;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
//SD is idle or not detected, let see if still the case
|
||||||
|
SD.end();
|
||||||
|
sd_state = SDCARD_NOT_PRESENT;
|
||||||
|
//using default value for speed ? should be parameter
|
||||||
|
//refresh content if card was removed
|
||||||
|
if (SD.begin((GRBL_SPI_SS == -1) ? SS : GRBL_SPI_SS, SPI, GRBL_SPI_FREQ, "/sd", 2)) {
|
||||||
|
if (SD.cardSize() > 0) {
|
||||||
|
sd_state = SDCARD_IDLE;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return sd_state;
|
||||||
|
} else {
|
||||||
|
return SDCARD_NOT_PRESENT;
|
||||||
}
|
}
|
||||||
return sd_state;
|
|
||||||
}
|
}
|
||||||
|
|
||||||
uint8_t set_sd_state(uint8_t flag) {
|
uint8_t set_sd_state(uint8_t flag) {
|
||||||
|
Reference in New Issue
Block a user