Skip to content

quick fix for the toolkit UART compile/builds issues on some platforms #50

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged
merged 3 commits into from
Apr 4, 2025
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion library.properties
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
name=SparkFun Toolkit
version=1.1.0
version=1.1.1
author=SparkFun Electronics
maintainer=SparkFun Electronics
sentence=A utility library that other SparkFun libraries can take advantage of.
Expand Down
2 changes: 1 addition & 1 deletion src/sfTk/sfTkIUART.h
Original file line number Diff line number Diff line change
Expand Up @@ -68,7 +68,7 @@ typedef enum _sfTkUARTDataBits
kUARTDataBitsEight = 0x400ul,
} sfTkUARTDataBits_t;

inline const uint8_t dataBitsToValue(sfTkUARTDataBits_t dataBits)
inline uint8_t dataBitsToValue(sfTkUARTDataBits_t dataBits)
{
static const uint8_t dataBitsArray[] = {5, 6, 7, 8};

Expand Down
21 changes: 16 additions & 5 deletions src/sfTkArdUART.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -48,16 +48,23 @@ sfTkError_t sfTkArdUART::init(HardwareSerial &hwSerial, uint32_t baudRate, bool

sfTkError_t sfTkArdUART::init(uint32_t baudRate, bool bInit)
{
// issues here on some devices - $defineing out for now
#ifdef _THIS_IS_BROKEN
// if we don't have a port already, use the default Arduino Serial.
if (!_hwSerial)
return init(Serial, baudRate, bInit);

// We already have a UART setup, so it's already initialized. Change the baud rate.
return setBaudRate(baudRate); // set the baud rate
#else
return ksfTkErrFail;
#endif
}

sfTkError_t sfTkArdUART::init(sfTkIUART::UARTConfig_t config, bool bInit)
{
// issues here on some devices - $defineing out for now
#ifdef _THIS_IS_BROKEN
// if we don't have a port already, use the default Arduino Serial.
if (!_hwSerial)
return init(Serial, config, bInit);
Expand All @@ -67,6 +74,9 @@ sfTkError_t sfTkArdUART::init(sfTkIUART::UARTConfig_t config, bool bInit)

// We already have a UART setup, so it's already initialized.
return ksfTkErrOk;
#else
return ksfTkErrFail;
#endif
}

sfTkError_t sfTkArdUART::init()
Expand Down Expand Up @@ -103,11 +113,11 @@ sfTkError_t sfTkArdUART::read(uint8_t *data, size_t length, size_t &bytesRead)

bytesRead = 0; // zero out value

// #ifdef ARDUINO_ARCH_AVR
// #ifdef ARDUINO_ARCH_AVR
bytesRead = _hwSerial->readBytes(data, length);
// #else
// bytesRead = readBytes(data, length);
// #endif
// #else
// bytesRead = readBytes(data, length);
// #endif

if (bytesRead == 0)
return ksfTkErrFail;
Expand Down Expand Up @@ -187,7 +197,8 @@ sfTkError_t sfTkArdUART::_start(void)
// ESP8266 does not support setting stop bits, parity, and data bits in a stanard manner.
_hwSerial->begin(_config.baudRate);
#else
_hwSerial->begin(_config.baudRate, _config.stopBits | _config.parity | _config.dataBits);
_hwSerial->begin(_config.baudRate,
(uint32_t)_config.stopBits | (uint32_t)_config.parity | (uint32_t)_config.dataBits);
#endif
if (!availableForWrite())
return ksfTkErrSerialNotInit; // check if the port is available
Expand Down