Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/Duet3D/RepRapFirmware.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorDavid Crocker <dcrocker@eschertech.com>2020-04-21 01:19:48 +0300
committerDavid Crocker <dcrocker@eschertech.com>2020-04-21 01:19:48 +0300
commitd16be9efe85af602b8d34bd4b42b5bb706168a86 (patch)
tree9dd141abe0221a4c0e915623f5bdce067477714e /src/DuetNG
parent64e172adf08f72d766d0abc26002ad9ef3ac0137 (diff)
Fixed to fan handling, more noexcept
Fixed fan handling so that blip time doesn't get randomly extended Added missing noexcept specifiers, including to C functions because doing so eliminates exception table entries for client C++ functions
Diffstat (limited to 'src/DuetNG')
-rw-r--r--src/DuetNG/DueXn.cpp26
-rw-r--r--src/DuetNG/DueXn.h22
-rw-r--r--src/DuetNG/Pins_DuetNG.h40
-rw-r--r--src/DuetNG/SX1509.cpp76
-rw-r--r--src/DuetNG/SX1509.h62
5 files changed, 130 insertions, 96 deletions
diff --git a/src/DuetNG/DueXn.cpp b/src/DuetNG/DueXn.cpp
index 4f23199f..3ac8f139 100644
--- a/src/DuetNG/DueXn.cpp
+++ b/src/DuetNG/DueXn.cpp
@@ -66,7 +66,7 @@ namespace DuetExpansion
// ISR for when the SX1509B on the DueX indicates that the state of an input has changed.
// Note, we must only wake up the DueX task if it is waiting on this specific interrupt.
// Otherwise we might wake it prematurely when it is waiting for an I2C transaction to be completed.
- static void DueXIrq(CallbackParameter p)
+ static void DueXIrq(CallbackParameter p) noexcept
{
inputsChanged = true;
if (taskWaiting)
@@ -76,7 +76,7 @@ namespace DuetExpansion
}
}
- extern "C" [[noreturn]] void DueXTask(void * pvParameters)
+ extern "C" [[noreturn]] void DueXTask(void * pvParameters) noexcept
{
for (;;)
{
@@ -98,7 +98,7 @@ namespace DuetExpansion
}
// Identify which expansion board (if any) is attached and initialise it
- ExpansionBoardType DueXnInit()
+ ExpansionBoardType DueXnInit() noexcept
{
I2C::Init(); // initialise I2C
delay(200); // the SX1509B has an independent power on reset, so give it some time
@@ -142,7 +142,7 @@ namespace DuetExpansion
// Create the DueXn task and enable the associated interrupt from the DueXn.
// This must be called after interrupt priorities have been configured, to comply with FreeRTOS constraints.
- void DueXnTaskInit()
+ void DueXnTaskInit() noexcept
{
if (dueXnBoardType != ExpansionBoardType::none)
{
@@ -158,7 +158,7 @@ namespace DuetExpansion
}
// Look for an additional output pin expander
- void AdditionalOutputInit()
+ void AdditionalOutputInit() noexcept
{
I2C::Init(); // initialise I2C
@@ -181,7 +181,7 @@ namespace DuetExpansion
}
// Return the name of the expansion board, or nullptr if no expansion board
- const char* _ecv_array null GetExpansionBoardName()
+ const char* _ecv_array null GetExpansionBoardName() noexcept
{
switch(dueXnBoardType)
{
@@ -197,13 +197,13 @@ namespace DuetExpansion
}
// Return the name of the additional expansion board, or nullptr if no expansion board
- const char* _ecv_array null GetAdditionalExpansionBoardName()
+ const char* _ecv_array null GetAdditionalExpansionBoardName() noexcept
{
return (additionalIoExpanderPresent) ? "SX1509B expander" : nullptr;
}
// Set the I/O mode of a pin
- void SetPinMode(Pin pin, PinMode mode)
+ void SetPinMode(Pin pin, PinMode mode) noexcept
{
if (pin >= DueXnExpansionStart && pin < DueXnExpansionStart + 16)
{
@@ -247,7 +247,7 @@ namespace DuetExpansion
// Read a pin
// We need to use the SX1509 interrupt to read the data register using interrupts, and just retrieve that value here.
- bool DigitalRead(Pin pin)
+ bool DigitalRead(Pin pin) noexcept
{
if (pin >= DueXnExpansionStart && pin < DueXnExpansionStart + 16)
{
@@ -281,7 +281,7 @@ namespace DuetExpansion
}
// Write a pin
- void DigitalWrite(Pin pin, bool high)
+ void DigitalWrite(Pin pin, bool high) noexcept
{
if (pin >= DueXnExpansionStart && pin < DueXnExpansionStart + 16)
{
@@ -300,7 +300,7 @@ namespace DuetExpansion
}
// Set the PWM value on this pin
- void AnalogOut(Pin pin, float pwm)
+ void AnalogOut(Pin pin, float pwm) noexcept
{
if (pin >= DueXnExpansionStart && pin < DueXnExpansionStart + 16)
{
@@ -320,12 +320,12 @@ namespace DuetExpansion
// Print diagnostic data
// I2C error counts are now reported by Platform, so nothing to report here.
- void Diagnostics(MessageType mtype)
+ void Diagnostics(MessageType mtype) noexcept
{
}
// Diagnose the SX1509 by setting all pins as inputs and reading them
- uint16_t DiagnosticRead()
+ uint16_t DiagnosticRead() noexcept
{
dueXnExpander.pinModeMultiple(AllStopBitsX5 | AllGpioBits | AllFanBits, INPUT); // Initialise the endstop inputs and GPIO pins (no pullups because 5V-tolerant)
delay(1);
diff --git a/src/DuetNG/DueXn.h b/src/DuetNG/DueXn.h
index b98dff53..a0147ff9 100644
--- a/src/DuetNG/DueXn.h
+++ b/src/DuetNG/DueXn.h
@@ -22,17 +22,17 @@ enum class ExpansionBoardType : uint8_t
namespace DuetExpansion
{
- ExpansionBoardType DueXnInit(); // Look for a DueXn, initialise it and return which expansion board is attached
- void AdditionalOutputInit(); // Look for an additional output pin expander
- void DueXnTaskInit(); // Create the DueXn task and enable the associated interrupt from the DueXn
- const char* _ecv_array null GetExpansionBoardName(); // Return the name of the expansion board, or nullptr if no expansion board
- const char* _ecv_array null GetAdditionalExpansionBoardName(); // Return the name of the additional expansion board, or nullptr if no expansion board
- void SetPinMode(Pin pin, PinMode mode); // Set the I/O mode of a pin
- bool DigitalRead(Pin pin); // Read a pin
- void DigitalWrite(Pin pin, bool high); // Write a pin
- void AnalogOut(Pin pin, float pwm); // Set the PWM value on this pin
- uint16_t DiagnosticRead(); // Diagnose the SX1509 by setting all pins as inputs and reading them
- void Diagnostics(MessageType mtype); // Print diagnostic data
+ ExpansionBoardType DueXnInit() noexcept; // Look for a DueXn, initialise it and return which expansion board is attached
+ void AdditionalOutputInit() noexcept; // Look for an additional output pin expander
+ void DueXnTaskInit() noexcept; // Create the DueXn task and enable the associated interrupt from the DueXn
+ const char* _ecv_array null GetExpansionBoardName() noexcept; // Return the name of the expansion board, or nullptr if no expansion board
+ const char* _ecv_array null GetAdditionalExpansionBoardName() noexcept; // Return the name of the additional expansion board, or nullptr if no expansion board
+ void SetPinMode(Pin pin, PinMode mode) noexcept; // Set the I/O mode of a pin
+ bool DigitalRead(Pin pin) noexcept; // Read a pin
+ void DigitalWrite(Pin pin, bool high) noexcept; // Write a pin
+ void AnalogOut(Pin pin, float pwm) noexcept; // Set the PWM value on this pin
+ uint16_t DiagnosticRead() noexcept; // Diagnose the SX1509 by setting all pins as inputs and reading them
+ void Diagnostics(MessageType mtype) noexcept; // Print diagnostic data
};
#endif /* SRC_DUETNG_DUEXN_H_ */
diff --git a/src/DuetNG/Pins_DuetNG.h b/src/DuetNG/Pins_DuetNG.h
index 11d2bdfc..ebf42f39 100644
--- a/src/DuetNG/Pins_DuetNG.h
+++ b/src/DuetNG/Pins_DuetNG.h
@@ -53,7 +53,12 @@ constexpr size_t NumFirmwareUpdateModules = 4; // 3 modules, plus one for manua
// The physical capabilities of the machine
+#if SUPPORT_12864_LCD
+constexpr size_t NumDirectDrivers = 11; // The maximum number of drives supported directly by the electronics
+#else
constexpr size_t NumDirectDrivers = 12; // The maximum number of drives supported directly by the electronics
+#endif
+
constexpr size_t MaxSmartDrivers = 10; // The maximum number of smart drivers
constexpr size_t MaxSensors = 32;
@@ -112,18 +117,27 @@ constexpr Pin ENABLE_PINS[NumDirectDrivers] =
{
PortDPin(14), PortCPin(9), PortCPin(10), PortCPin(17), PortCPin(25), // Duet
PortDPin(23), PortDPin(24), PortDPin(25), PortDPin(26), PortBPin(14), // DueX5
- PortDPin(18), PortCPin(28) // CONN_LCD
+ PortDPin(18), // CONN_LCD
+#if !SUPPORT_12864_LCD
+ PortCPin(28)
+#endif
};
constexpr Pin STEP_PINS[NumDirectDrivers] =
{
PortDPin(6), PortDPin(7), PortDPin(8), PortDPin(5), PortDPin(4), // Duet
PortDPin(2), PortDPin(1), PortDPin(0), PortDPin(3), PortDPin(27), // DueX5
- PortDPin(20), PortDPin(21) // CONN_LCD
+ PortDPin(20), // CONN_LCD
+#if !SUPPORT_12864_LCD
+ PortDPin(21)
+#endif
};
constexpr Pin DIRECTION_PINS[NumDirectDrivers] =
{ PortDPin(11), PortDPin(12), PortDPin(13), PortAPin(1), PortDPin(9), // Duet
PortDPin(28), PortDPin(22), PortDPin(16), PortDPin(17), PortCPin(0), // DueX5
- PortDPin(19), PortAPin(25) // CONN_LCD
+ PortDPin(19), // CONN_LCD
+#if !SUPPORT_12864_LCD
+ PortAPin(25)
+#endif
};
// Pin assignments etc. using USART1 in SPI mode
@@ -187,6 +201,26 @@ constexpr Pin SdWriteProtectPins[NumSdCards] = { NoPin, NoPin };
constexpr Pin SdSpiCSPins[1] = { PortCPin(24) };
constexpr uint32_t ExpectedSdCardSpeed = 20000000;
+#if SUPPORT_12864_LCD
+// The ST7920 datasheet specifies minimum clock cycle time 400ns @ Vdd=4.5V, min. clock width 200ns high and 20ns low.
+// This assumes that the Vih specification is met, which is 0.7 * Vcc = 3.5V @ Vcc=5V
+// The Duet Maestro level shifts all 3 LCD signals to 5V, so we meet the Vih specification and can reliably run at 2MHz.
+// For other electronics, there are reports that operation with 3.3V LCD signals may work if you reduce the clock frequency.
+constexpr uint32_t LcdSpiClockFrequency = 2000000; // 2.0MHz
+constexpr Pin LcdCSPin = PortDPin(21); //connlcd.10 --> gate -> exp2.4
+constexpr Pin LcdBeepPin = PortAPin(8); //connlcd.4 -> exp1.1
+constexpr Pin EncoderPinA = PortAPin(25); //connlcd.8 -> exp2.5
+constexpr Pin EncoderPinB = PortCPin(28); //connlcd.6 -> exp2.3
+constexpr Pin EncoderPinSw = PortAPin(7); //connsd.7 -> exp1.2
+ //adittional spi wiring:
+ //connsd.6 <- exp2.1
+ //connsd.5 --> gate -> exp1.3
+ // `-> -> exp2.6
+ //connsd.4 --> gate -> exp1.5
+ // `-> -> exp2.2
+ //connsd.3 -> exp2.4
+#endif
+
// Enum to represent allowed types of pin access
// We don't have a separate bit for servo, because Duet PWM-capable ports can be used for servos if they are on the Duet main board
enum class PinCapability: uint8_t
diff --git a/src/DuetNG/SX1509.cpp b/src/DuetNG/SX1509.cpp
index a3412874..862dc568 100644
--- a/src/DuetNG/SX1509.cpp
+++ b/src/DuetNG/SX1509.cpp
@@ -11,7 +11,7 @@ https://github.com/sparkfun/SparkFun_SX1509_Arduino_Library
Here you'll find the Arduino code used to interface with the SX1509 I2C
16 I/O expander. There are functions to take advantage of everything the
-SX1509 provides - input/output setting, writing pins high/low, reading
+SX1509 provides - input/output setting, writing pins high/low, reading
the input value of pins, LED driver utilities (blink, breath, pwm), and
keypad engine utilites.
@@ -27,7 +27,7 @@ Distributed as-is; no warranty is given.
#include "SX1509Registers.h"
#include "Hardware/I2C.h"
-SX1509::SX1509() : _clkX(0)
+SX1509::SX1509() noexcept : _clkX(0)
{
}
@@ -35,11 +35,11 @@ SX1509::SX1509() : _clkX(0)
// Any operation requiring multiple I2C transactions must acquire and release the I2C mutex around them.
// Test for the presence of a SX1509B. The I2C subsystem must be initialised before calling this.
-bool SX1509::begin(uint8_t address)
+bool SX1509::begin(uint8_t address) noexcept
{
// Store the received parameters into member variables
deviceAddress = address;
-
+
reset();
delay(2); // not sure this is needed, but it may help
@@ -60,7 +60,7 @@ bool SX1509::begin(uint8_t address)
}
// Reset the SX1509B
-void SX1509::reset()
+void SX1509::reset() noexcept
{
MutexLocker lock(Tasks::GetI2CMutex());
@@ -69,7 +69,7 @@ void SX1509::reset()
writeByte(REG_RESET, 0x34);
}
-void SX1509::pinMode(uint8_t pin, PinMode inOut)
+void SX1509::pinMode(uint8_t pin, PinMode inOut) noexcept
{
pinModeMultiple(1u << pin, inOut);
}
@@ -77,7 +77,7 @@ void SX1509::pinMode(uint8_t pin, PinMode inOut)
// Set the pin mode for multiple pins.
// Once we have enabled LED driver mode, disabling it doesn't seem to work.
// So we track which pins are in PWM (i.e. LED driver) mode, and we never try to switch them back to being ordinary outputs.
-void SX1509::pinModeMultiple(uint16_t pins, PinMode inOut)
+void SX1509::pinModeMultiple(uint16_t pins, PinMode inOut) noexcept
{
MutexLocker lock(Tasks::GetI2CMutex());
@@ -154,7 +154,7 @@ void SX1509::pinModeMultiple(uint16_t pins, PinMode inOut)
}
}
-void SX1509::digitalWrite(uint8_t pin, bool highLow)
+void SX1509::digitalWrite(uint8_t pin, bool highLow) noexcept
{
if (((1u << pin) & pwmPins) != 0)
{
@@ -172,7 +172,7 @@ void SX1509::digitalWrite(uint8_t pin, bool highLow)
}
}
-bool SX1509::digitalRead(uint8_t pin)
+bool SX1509::digitalRead(uint8_t pin) noexcept
{
if (pin >= 8)
{
@@ -184,21 +184,21 @@ bool SX1509::digitalRead(uint8_t pin)
}
}
-uint16_t SX1509::digitalReadAll()
+uint16_t SX1509::digitalReadAll() noexcept
{
return readWord(REG_DATA_B);
}
#if 0 // unused
-void SX1509::ledDriverInit(uint8_t pin, bool log, bool openDrain)
+void SX1509::ledDriverInit(uint8_t pin, bool log, bool openDrain) noexcept
{
ledDriverInitMultiple(1u << pin, log, openDrain);
}
#endif
-void SX1509::ledDriverInitMultiple(uint16_t pins, bool log, bool openDrain)
+void SX1509::ledDriverInitMultiple(uint16_t pins, bool log, bool openDrain) noexcept
{
if (openDrain)
{
@@ -224,17 +224,17 @@ void SX1509::ledDriverInitMultiple(uint16_t pins, bool log, bool openDrain)
tempByte &= ~((1u << 7) | (1u << 3)); // set linear mode bank B and A
}
writeByte(REG_MISC, tempByte);
-
+
// Enable LED driver operation (REG_LED_DRIVER_ENABLE)
setBitsInWord(REG_LED_DRIVER_ENABLE_B, pins);
-
+
// Set REG_DATA bit low ~ LED driver started
clearBitsInWord(REG_DATA_B, pins);
pwmPins |= pins; // record which pins are in LED driver mode
}
-void SX1509::analogWrite(uint8_t pin, uint8_t iOn)
+void SX1509::analogWrite(uint8_t pin, uint8_t iOn) noexcept
{
// Write the on intensity of pin
// Linear mode: Ion = iOn
@@ -244,12 +244,12 @@ void SX1509::analogWrite(uint8_t pin, uint8_t iOn)
writeByte(REG_I_ON[pin], ~iOn);
}
-void SX1509::enableInterrupt(uint8_t pin, uint8_t riseFall)
+void SX1509::enableInterrupt(uint8_t pin, uint8_t riseFall) noexcept
{
enableInterruptMultiple(1u << pin, riseFall);
}
-void SX1509::enableInterruptMultiple(uint16_t pins, uint8_t riseFall)
+void SX1509::enableInterruptMultiple(uint16_t pins, uint8_t riseFall) noexcept
{
// Set REG_SENSE_XXX
// Sensitivity is set as follows:
@@ -289,12 +289,12 @@ void SX1509::enableInterruptMultiple(uint16_t pins, uint8_t riseFall)
clearBitsInWord(REG_INTERRUPT_MASK_B, pins);
}
-uint16_t SX1509::interruptSource()
+uint16_t SX1509::interruptSource() noexcept
{
return readWord(REG_INTERRUPT_SOURCE_B);
}
-uint16_t SX1509::interruptSourceAndClear()
+uint16_t SX1509::interruptSourceAndClear() noexcept
{
MutexLocker lock(Tasks::GetI2CMutex());
@@ -303,14 +303,14 @@ uint16_t SX1509::interruptSourceAndClear()
return intSource;
}
-bool SX1509::checkInterrupt(uint8_t pin)
+bool SX1509::checkInterrupt(uint8_t pin) noexcept
{
return (interruptSource() & (1u << pin)) != 0;
}
//********* Private functions. The I2C mutex must be owned by the caller. ***********
-void SX1509::setBitsInWord(uint8_t registerAddress, uint16_t bits)
+void SX1509::setBitsInWord(uint8_t registerAddress, uint16_t bits) noexcept
{
if (bits != 0)
{
@@ -319,7 +319,7 @@ void SX1509::setBitsInWord(uint8_t registerAddress, uint16_t bits)
}
}
-void SX1509::clearBitsInWord(uint8_t registerAddress, uint16_t bits)
+void SX1509::clearBitsInWord(uint8_t registerAddress, uint16_t bits) noexcept
{
if (bits != 0)
{
@@ -328,7 +328,7 @@ void SX1509::clearBitsInWord(uint8_t registerAddress, uint16_t bits)
}
}
-void SX1509::analogWriteMultiple(uint16_t pins, uint8_t pwm)
+void SX1509::analogWriteMultiple(uint16_t pins, uint8_t pwm) noexcept
{
for (uint8_t pin = 0; pins != 0; ++pin)
{
@@ -340,7 +340,7 @@ void SX1509::analogWriteMultiple(uint16_t pins, uint8_t pwm)
}
}
-void SX1509::clock(uint8_t oscDivider)
+void SX1509::clock(uint8_t oscDivider) noexcept
{
// RegClock constructed as follows:
// 6:5 - Oscillator frequency source
@@ -350,7 +350,7 @@ void SX1509::clock(uint8_t oscDivider)
// 3:0 - Frequency of oscout pin
// 0: LOW, 0xF: high, else fOSCOUT = FoSC/(2^(RegClock[3:0]-1))
writeByte(REG_CLOCK, (2u << 5) | (1u << 4) | (1u << 0)); // internal 2MHz oscillator, OSCIO outputs at that frequency
-
+
// Config RegMisc[6:4] with oscDivider
// 0: off, else ClkX = fOSC / (2^(RegMisc[6:4] - 1))
oscDivider = constrain<uint8_t>(oscDivider, 1, 7);
@@ -361,37 +361,37 @@ void SX1509::clock(uint8_t oscDivider)
writeByte(REG_MISC, regMisc);
}
-uint8_t SX1509::calculateLEDTRegister(int ms)
+uint8_t SX1509::calculateLEDTRegister(int ms) noexcept
{
if (_clkX == 0)
{
return 0;
}
-
+
int regOn1 = (int)(((float)ms / 1000.0) / (64.0 * 255.0 / (float) _clkX));
int regOn2 = regOn1 / 8;
regOn1 = constrain<int>(regOn1, 1, 15);
regOn2 = constrain<int>(regOn2, 16, 31);
-
+
const float timeOn1 = 64.0 * regOn1 * 255.0 / _clkX * 1000.0;
const float timeOn2 = 512.0 * regOn2 * 255.0 / _clkX * 1000.0;
return (abs(timeOn1 - ms) < abs(timeOn2 - ms)) ? regOn1 : regOn2;
}
-uint8_t SX1509::calculateSlopeRegister(int ms, uint8_t onIntensity, uint8_t offIntensity)
+uint8_t SX1509::calculateSlopeRegister(int ms, uint8_t onIntensity, uint8_t offIntensity) noexcept
{
if (_clkX == 0)
{
return 0;
}
-
+
const float tFactor = ((float) onIntensity - (4.0 * (float)offIntensity)) * 255.0 / (float) _clkX;
const float timeS = float(ms) / 1000.0;
-
+
int regSlope1 = timeS / tFactor;
int regSlope2 = regSlope1 / 16;
-
+
regSlope1 = constrain<int>(regSlope1, 1, 15);
regSlope2 = constrain<int>(regSlope2, 16, 31);
@@ -406,7 +406,7 @@ uint8_t SX1509::calculateSlopeRegister(int ms, uint8_t onIntensity, uint8_t offI
// - deviceAddress should already be set by the constructor.
// - Return value is the uint8_t read from registerAddress
// - Currently returns 0 if communication has timed out
-uint8_t SX1509::readByte(uint8_t registerAddress)
+uint8_t SX1509::readByte(uint8_t registerAddress) noexcept
{
uint8_t data[2];
data[0] = registerAddress;
@@ -422,7 +422,7 @@ uint8_t SX1509::readByte(uint8_t registerAddress)
// - A 16-bit unsigned int will be returned.
// - The msb of the return value will contain the value read from registerAddress
// - The lsb of the return value will contain the value read from registerAddress + 1
-uint16_t SX1509::readWord(uint8_t registerAddress)
+uint16_t SX1509::readWord(uint8_t registerAddress) noexcept
{
uint8_t data[3];
data[0] = registerAddress;
@@ -438,7 +438,7 @@ uint16_t SX1509::readWord(uint8_t registerAddress)
// - A 32-bit unsigned int will be returned.
// - The msb of the return value will contain the value read from registerAddress
// - The lsb of the return value will contain the value read from registerAddress + 1
-uint32_t SX1509::readDword(uint8_t registerAddress)
+uint32_t SX1509::readDword(uint8_t registerAddress) noexcept
{
uint8_t data[5];
data[0] = registerAddress;
@@ -454,7 +454,7 @@ uint32_t SX1509::readDword(uint8_t registerAddress)
// - writeValue is written to registerAddress
// - deviceAddress should already be set from the constructor
// - No return value.
-void SX1509::writeByte(uint8_t registerAddress, uint8_t writeValue)
+void SX1509::writeByte(uint8_t registerAddress, uint8_t writeValue) noexcept
{
uint8_t data[2] = { registerAddress, writeValue };
(void)I2C::Transfer(deviceAddress, data, 2, 0);
@@ -465,7 +465,7 @@ void SX1509::writeByte(uint8_t registerAddress, uint8_t writeValue)
// - the upper uint8_t of writeValue is written to registerAddress
// - the lower uint8_t of writeValue is written to registerAddress + 1
// - No return value.
-void SX1509::writeWord(uint8_t registerAddress, uint16_t writeValue)
+void SX1509::writeWord(uint8_t registerAddress, uint16_t writeValue) noexcept
{
uint8_t data[3] = { registerAddress, (uint8_t)(writeValue >> 8), (uint8_t)writeValue };
(void)I2C::Transfer(deviceAddress, data, 3, 0);
@@ -474,7 +474,7 @@ void SX1509::writeWord(uint8_t registerAddress, uint16_t writeValue)
// writeDword(uint8_t registerAddress, uint32_t writeValue)
// This function writes a four-uint8_t word to registerAddress .. registerAddress + 3, msb first
// - No return value.
-void SX1509::writeDword(uint8_t registerAddress, uint32_t writeValue)
+void SX1509::writeDword(uint8_t registerAddress, uint32_t writeValue) noexcept
{
uint8_t data[5] = { registerAddress, (uint8_t)(writeValue >> 24), (uint8_t)(writeValue >> 16), (uint8_t)(writeValue >> 8), (uint8_t)writeValue };
(void)I2C::Transfer(deviceAddress, data, 5, 0);
diff --git a/src/DuetNG/SX1509.h b/src/DuetNG/SX1509.h
index 41ebfe00..c119f012 100644
--- a/src/DuetNG/SX1509.h
+++ b/src/DuetNG/SX1509.h
@@ -11,7 +11,7 @@ https://github.com/sparkfun/SparkFun_SX1509_Arduino_Library
Here you'll find the Arduino code used to interface with the SX1509 I2C
16 I/O expander. There are functions to take advantage of everything the
-SX1509 provides - input/output setting, writing pins high/low, reading
+SX1509 provides - input/output setting, writing pins high/low, reading
the input value of pins, LED driver utilities (blink, breath, pwm), and
keypad engine utilites.
@@ -39,28 +39,28 @@ private:
uint16_t pwmPins; // bitmap of pins configured as PWM output pins
// Read Functions:
- uint8_t readByte(uint8_t registerAddress);
- uint16_t readWord(uint8_t registerAddress);
- uint32_t readDword(uint8_t registerAddress);
+ uint8_t readByte(uint8_t registerAddress) noexcept;
+ uint16_t readWord(uint8_t registerAddress) noexcept;
+ uint32_t readDword(uint8_t registerAddress) noexcept;
// Write functions:
- void writeByte(uint8_t registerAddress, uint8_t writeValue);
- void writeWord(uint8_t registerAddress, uint16_t writeValue);
- void writeDword(uint8_t registerAddress, uint32_t writeValue);
+ void writeByte(uint8_t registerAddress, uint8_t writeValue) noexcept;
+ void writeWord(uint8_t registerAddress, uint16_t writeValue) noexcept;
+ void writeDword(uint8_t registerAddress, uint32_t writeValue) noexcept;
- void setBitsInWord(uint8_t registerAddress, uint16_t bits);
- void clearBitsInWord(uint8_t registerAddress, uint16_t bits);
- void analogWriteMultiple(uint16_t pins, uint8_t pwm);
+ void setBitsInWord(uint8_t registerAddress, uint16_t bits) noexcept;
+ void clearBitsInWord(uint8_t registerAddress, uint16_t bits) noexcept;
+ void analogWriteMultiple(uint16_t pins, uint8_t pwm) noexcept;
// Helper functions:
- // calculateLEDTRegister - Try to estimate an LED on/off duration register,
+ // calculateLEDTRegister - Try to estimate an LED on/off duration register,
// given the number of milliseconds and LED clock frequency.
- uint8_t calculateLEDTRegister(int ms);
+ uint8_t calculateLEDTRegister(int ms) noexcept;
- // calculateSlopeRegister - Try to estimate an LED rise/fall duration
+ // calculateSlopeRegister - Try to estimate an LED rise/fall duration
// register, given the number of milliseconds and LED clock frequency.
- uint8_t calculateSlopeRegister(int ms, uint8_t onIntensity, uint8_t offIntensity);
+ uint8_t calculateSlopeRegister(int ms, uint8_t onIntensity, uint8_t offIntensity) noexcept;
// -----------------------------------------------------------------------------
@@ -70,14 +70,14 @@ private:
// Inputs:
// - oscDivider: Sets the clock divider in REG_MISC. Clock is 2MHz / (1 << (oscDivider - 1). PWM frequency is 1/256 of that.
// -----------------------------------------------------------------------------
- void clock(uint8_t oscDivider);
+ void clock(uint8_t oscDivider) noexcept;
public:
// -----------------------------------------------------------------------------
// Constructor - SX1509: This function sets up the pins connected to the
// SX1509, and sets up the private deviceAddress variable.
// -----------------------------------------------------------------------------
- SX1509();
+ SX1509() noexcept;
// -----------------------------------------------------------------------------
// begin(uint8_t address): This function initializes the SX1509.
@@ -89,14 +89,14 @@ public:
// ADDR0 and ADDR1 pins are set to. This variable is required.
// Output: Returns true if communication is successful, false on error.
// -----------------------------------------------------------------------------
- bool begin(uint8_t address);
+ bool begin(uint8_t address) noexcept;
// -----------------------------------------------------------------------------
// reset(): This function resets the SX1509. A software
// reset writes a 0x12 then 0x34 to the REG_RESET as outlined in the
// datasheet.
// -----------------------------------------------------------------------------
- void reset();
+ void reset() noexcept;
// -----------------------------------------------------------------------------
// pinMode(uint8_t pin, PinMode inOut): This function sets one of the SX1509's 16
@@ -107,7 +107,7 @@ public:
// - inOut: The Core INPUT and OUTPUT constants should be used for the
// inOut parameter. They do what they say!
// -----------------------------------------------------------------------------
- void pinMode(uint8_t pin, PinMode inOut);
+ void pinMode(uint8_t pin, PinMode inOut) noexcept;
// pinModeMultiple(uint16_t pins, PinMode inOut): This function sets several of the SX1509's 16
// outputs to either an INPUT or OUTPUT.
@@ -117,7 +117,7 @@ public:
// - inOut: The Core INPUT and OUTPUT constants should be used for the
// inOut parameter. They do what they say!
// -----------------------------------------------------------------------------
- void pinModeMultiple(uint16_t pins, PinMode inOut);
+ void pinModeMultiple(uint16_t pins, PinMode inOut) noexcept;
// -----------------------------------------------------------------------------
// digitalWrite(uint8_t pin, bool highLow): This function writes a pin to either high
@@ -129,7 +129,7 @@ public:
// - pin: The SX1509 pin number. Should be a value between 0 and 15.
// - highLow: true for HIGH, false for LOW.
// -----------------------------------------------------------------------------
- void digitalWrite(uint8_t pin, bool highLow);
+ void digitalWrite(uint8_t pin, bool highLow) noexcept;
// -----------------------------------------------------------------------------
// digitalRead(uint8_t pin): This function reads the HIGH/LOW status of a pin.
@@ -140,12 +140,12 @@ public:
// Outputs:
// This function returns true if HIGH, false if LOW
// -----------------------------------------------------------------------------
- bool digitalRead(uint8_t pin);
+ bool digitalRead(uint8_t pin) noexcept;
// -----------------------------------------------------------------------------
// digitalReadAll(): This function reads all 16 pins.
// -----------------------------------------------------------------------------
- uint16_t digitalReadAll();
+ uint16_t digitalReadAll() noexcept;
#if 0 // unused
// -----------------------------------------------------------------------------
@@ -159,7 +159,7 @@ public:
// - log defaults to 0, linear mode
// - currently log sets both bank A and B to the same mode
// -----------------------------------------------------------------------------
- void ledDriverInit(uint8_t pin, bool log, bool openDrain);
+ void ledDriverInit(uint8_t pin, bool log, bool openDrain) noexcept;
#endif
// -----------------------------------------------------------------------------
@@ -173,7 +173,7 @@ public:
// - log defaults to 0, linear mode
// - currently log sets both bank A and B to the same mode
// -----------------------------------------------------------------------------
- void ledDriverInitMultiple(uint16_t pins, bool log, bool openDrain);
+ void ledDriverInitMultiple(uint16_t pins, bool log, bool openDrain) noexcept;
// -----------------------------------------------------------------------------
// analogWrite(uint8_t pin, uint8_t iOn): This function can be used to control the intensity
@@ -186,7 +186,7 @@ public:
//
// Note: ledDriverInit should be called on the pin before calling this.
// -----------------------------------------------------------------------------
- void analogWrite(uint8_t pin, uint8_t iOn);
+ void analogWrite(uint8_t pin, uint8_t iOn) noexcept;
// -----------------------------------------------------------------------------
// enableInterrupt(uint8_t pin, uint8_t riseFall): This function sets up an interrupt
@@ -205,7 +205,7 @@ public:
// Note: This function does not set up a pin as an input, or configure its
// pull-up/down resistors! Do that before (or after).
// -----------------------------------------------------------------------------
- void enableInterrupt(uint8_t pin, uint8_t riseFall);
+ void enableInterrupt(uint8_t pin, uint8_t riseFall) noexcept;
// -----------------------------------------------------------------------------
// enableInterruptMultiple(uint16_t pins, uint8_t riseFall): This function sets up an interrupt
@@ -224,7 +224,7 @@ public:
// Note: This function does not set up a pin as an input, or configure its
// pull-up/down resistors! Do that before (or after).
// -----------------------------------------------------------------------------
- void enableInterruptMultiple(uint16_t pins, uint8_t riseFall);
+ void enableInterruptMultiple(uint16_t pins, uint8_t riseFall) noexcept;
// -----------------------------------------------------------------------------
// interruptSource(void): Returns an unsigned int representing which pin caused
@@ -234,8 +234,8 @@ public:
// generated an interrupt. E.g. a return value of 0x0104 would mean pins 8
// and 3 (bits 8 and 3) have generated an interrupt.
// -----------------------------------------------------------------------------
- uint16_t interruptSource();
- uint16_t interruptSourceAndClear();
+ uint16_t interruptSource() noexcept;
+ uint16_t interruptSourceAndClear() noexcept;
// -----------------------------------------------------------------------------
// checkInterrupt(void): Checks if a single pin generated an interrupt.
@@ -244,7 +244,7 @@ public:
// Input:
// - pin: Pin to be checked for generating an input.
// -----------------------------------------------------------------------------
- bool checkInterrupt(uint8_t pin);
+ bool checkInterrupt(uint8_t pin) noexcept;
};
#endif // SX1509_H