mirror of
https://github.com/bdring/Grbl_Esp32.git
synced 2025-09-02 19:02:35 +02:00
Added I2S test to test_drive machine.. Fixed multiple I2S bugs
This commit is contained in:
@@ -22,6 +22,10 @@
|
||||
# include "src/Grbl.h"
|
||||
|
||||
void setup() {
|
||||
# ifdef PIN_DEBUG
|
||||
sleep(1000);
|
||||
# endif
|
||||
|
||||
Serial.begin(115200);
|
||||
grbl_init();
|
||||
}
|
||||
|
@@ -55,10 +55,18 @@
|
||||
// Output devices:
|
||||
// - I2S
|
||||
|
||||
// #define USE_I2S_OUT
|
||||
// #define USE_I2S_STEPS
|
||||
// #define I2S_OUT_BCK GPIO_NUM_22
|
||||
// #define I2S_OUT_WS GPIO_NUM_17
|
||||
// #define I2S_OUT_DATA GPIO_NUM_21
|
||||
//
|
||||
// #define COOLANT_MIST_PIN "i2s.24"
|
||||
|
||||
// x CoolantControl
|
||||
|
||||
// #define COOLANT_MIST_PIN "gpio.2" // labeled Mist
|
||||
// #define COOLANT_FLOOD_PIN "gpio.4" // labeled Flood
|
||||
// #define COOLANT_MIST_PIN "gpio.2"
|
||||
// #define COOLANT_FLOOD_PIN "gpio.4"
|
||||
|
||||
// x StandardStepper
|
||||
|
||||
|
@@ -76,6 +76,10 @@ bool Pin::parse(String str, Pins::PinDetail*& pinImplementation) {
|
||||
// Build an options parser:
|
||||
Pins::PinOptionsParser parser(options.begin(), options.end());
|
||||
|
||||
#if defined PIN_DEBUG && defined ESP32
|
||||
grbl_sendf(CLIENT_ALL, "Attempting to set up pin: %s, index %d\r\n", prefix.c_str(), int(pinNumber));
|
||||
#endif
|
||||
|
||||
// Build this pin:
|
||||
if (prefix == "gpio") {
|
||||
pinImplementation = new Pins::GPIOPinDetail(uint8_t(pinNumber), parser);
|
||||
|
@@ -97,7 +97,7 @@ namespace Pins {
|
||||
} else if (opt.is("high")) {
|
||||
// Default: Active HIGH.
|
||||
} else {
|
||||
Assert(false, "Bad GPIO option passed to pin: %s", opt());
|
||||
Assert(false, "Bad GPIO option passed to pin %d: %s", int(index), opt());
|
||||
}
|
||||
}
|
||||
|
||||
|
@@ -12,28 +12,27 @@ namespace Pins {
|
||||
_readWriteMask(0) {
|
||||
// User defined pin capabilities
|
||||
for (auto opt : options) {
|
||||
if (opt.is("pu")) {
|
||||
_attributes = _attributes | PinAttributes::PullUp;
|
||||
} else if (opt.is("pd")) {
|
||||
_attributes = _attributes | PinAttributes::PullDown;
|
||||
} else if (opt.is("low")) {
|
||||
if (opt.is("low")) {
|
||||
_attributes = _attributes | PinAttributes::ActiveLow;
|
||||
} else if (opt.is("high")) {
|
||||
// Default: Active HIGH.
|
||||
} else {
|
||||
Assert(false, "Bad I2S option passed to pin %d: %s", int(index), opt());
|
||||
}
|
||||
}
|
||||
|
||||
// Update the R/W mask for ActiveLow setting
|
||||
if (_attributes.has(PinAttributes::ActiveLow)) {
|
||||
_readWriteMask = 1;
|
||||
_readWriteMask = HIGH;
|
||||
} else {
|
||||
_readWriteMask = 0;
|
||||
_readWriteMask = LOW;
|
||||
}
|
||||
}
|
||||
|
||||
PinCapabilities I2SPinDetail::capabilities() const { return PinCapabilities::Input | PinCapabilities::Output | PinCapabilities::I2S; }
|
||||
PinCapabilities I2SPinDetail::capabilities() const { return PinCapabilities::Output | PinCapabilities::I2S; }
|
||||
|
||||
void I2SPinDetail::write(int high) {
|
||||
Assert(_attributes.has(PinAttributes::Output), "Pin has no output attribute defined. Cannot write to it.");
|
||||
int value = _readWriteMask ^ high;
|
||||
i2s_out_write(_index, value);
|
||||
}
|
||||
@@ -45,7 +44,7 @@ namespace Pins {
|
||||
|
||||
void I2SPinDetail::setAttr(PinAttributes value) {
|
||||
// Check the attributes first:
|
||||
Assert(!value.validateWith(this->_capabilities), "The requested attributes don't match the pin capabilities");
|
||||
Assert(value.validateWith(this->_capabilities), "The requested attributes don't match the pin capabilities");
|
||||
Assert(!_attributes.conflictsWith(value), "Attributes on this pin have been set before, and there's a conflict.");
|
||||
|
||||
_attributes = value;
|
||||
@@ -55,10 +54,14 @@ namespace Pins {
|
||||
// just check for conflicts above...
|
||||
|
||||
// If the pin is ActiveLow, we should take that into account here:
|
||||
write(value.has(PinAttributes::InitialOn) ? HIGH : LOW);
|
||||
if (value.has(PinAttributes::InitialOn)) {
|
||||
i2s_out_write(_index, HIGH ^ _readWriteMask);
|
||||
} else {
|
||||
i2s_out_write(_index, LOW ^ _readWriteMask);
|
||||
}
|
||||
}
|
||||
|
||||
String I2SPinDetail::toString() const { return String("I2S_") + int(_index); }
|
||||
String I2SPinDetail::toString() const { return String("I2S.") + int(_index); }
|
||||
}
|
||||
|
||||
#endif
|
||||
|
@@ -5,7 +5,6 @@
|
||||
|
||||
namespace Pins {
|
||||
class I2SPinDetail : public PinDetail {
|
||||
uint8_t _index;
|
||||
PinCapabilities _capabilities;
|
||||
PinAttributes _attributes;
|
||||
int _readWriteMask;
|
||||
|
@@ -150,9 +150,9 @@ Error list_grbl_names(const char* value, WebUI::AuthenticationLevel auth_level,
|
||||
Error list_settings(const char* value, WebUI::AuthenticationLevel auth_level, WebUI::ESPResponseStream* out) {
|
||||
for (Setting* s = Setting::List; s; s = s->next()) {
|
||||
const char* displayValue = auth_failed(s, value, auth_level) ? "<Authentication required>" : s->getStringValue();
|
||||
if (s->getType() != PIN) {
|
||||
show_setting(s->getName(), displayValue, NULL, out);
|
||||
}
|
||||
if (s->getType() != PIN) {
|
||||
show_setting(s->getName(), displayValue, NULL, out);
|
||||
}
|
||||
}
|
||||
return Error::Ok;
|
||||
}
|
||||
|
Reference in New Issue
Block a user