1
0
mirror of https://github.com/bdring/Grbl_Esp32.git synced 2025-09-01 18:32:37 +02:00

Better - but not perfect - pin number error checking

This commit is contained in:
Mitch Bradley
2021-06-15 12:32:40 -10:00
parent db123311fa
commit ea1e0e9563
2 changed files with 3 additions and 1 deletions

View File

@@ -104,7 +104,8 @@ namespace Pins {
// that were allocated by the constructor up to that point _MUST_ be freed! Otherwise, you
// WILL get into trouble.
Assert(_capabilities != PinCapabilities::None, "Bad GPIO number");
Assert(index < nGPIOPins, "Pin number is greater than max %d", nGPIOPins - 1);
Assert(_capabilities != PinCapabilities::None, "Unavailable GPIO");
Assert(!_claimed[index], "Pin is already used.");
// User defined pin capabilities

View File

@@ -30,6 +30,7 @@ namespace Pins {
I2SOPinDetail::I2SOPinDetail(uint8_t index, const PinOptionsParser& options) :
PinDetail(index), _capabilities(PinCapabilities::Output | PinCapabilities::I2S), _attributes(Pins::PinAttributes::Undefined),
_readWriteMask(0) {
Assert(index < nI2SOPins, "Pin number is greater than max %d", nI2SOPins - 1);
Assert(!_claimed[index], "Pin is already used.");
// User defined pin capabilities
for (auto opt : options) {