Skip to content

Add serial #54

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

Open
wants to merge 11 commits into
base: develop
Choose a base branch
from
54 changes: 45 additions & 9 deletions .github/workflows/compile-sketch.yml
Original file line number Diff line number Diff line change
Expand Up @@ -22,69 +22,103 @@ jobs:
# Uno
# https://github.com/arduino/ArduinoCore-avr/blob/master/boards.txt
- fqbn: arduino:avr:mega
name: Arduino AVR
platforms: |
- name: arduino:avr
source-url: https://downloads.arduino.cc/packages/package_index.json

# ESP32
# https://github.com/espressif/arduino-esp32/blob/master/boards.txt
- fqbn: esp32:esp32:esp32
- fqbn: esp32:esp32:esp32thing_plus_c
name: ESP32 Thing Plus C
platforms: |
- name: esp32:esp32
source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

# ESP32-S2
# https://github.com/espressif/arduino-esp32/blob/master/boards.txt
- fqbn: esp32:esp32:esp32s2
- fqbn: esp32:esp32:sparkfun_esp32s2_thing_plus
name: ESP32-S2 Thing Plus
platforms: |
- name: esp32:esp32
source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

# ESP32-S3
# https://github.com/espressif/arduino-esp32/blob/master/boards.txt
- fqbn: esp32:esp32:sparkfun_esp32s3_thing_plus
name: ESP32-S3 Thing Plus
platforms: |
- name: esp32:esp32
source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

# ESP32-C3
# https://github.com/espressif/arduino-esp32/blob/master/boards.txt
- fqbn: esp32:esp32:esp32c3
- fqbn: esp32:esp32:sparkfun_pro_micro_esp32c3
name: ESP32-C3 Pro Micro
platforms: |
- name: esp32:esp32
source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

# ESP32-C6
# https://github.com/espressif/arduino-esp32/blob/master/boards.txt
- fqbn: esp32:esp32:sparkfun_esp32c6_thing_plus
name: ESP32-C6 Thing Plus
platforms: |
- name: esp32:esp32
source-url: https://raw.githubusercontent.com/espressif/arduino-esp32/gh-pages/package_esp32_index.json

# Artemis / Apollo3 Feb 25 - there some issue here -- will need to look at
# https://github.com/sparkfun/Arduino_Apollo3/blob/main/boards.txt
# - fqbn: SparkFun:apollo3:sfe_artemis_atp
# platforms: |
# - name: SparkFun:apollo3
# source-url: https://raw.githubusercontent.com/sparkfun/Arduino_Apollo3/master/package_sparkfun_apollo3_index.json
- fqbn: SparkFun:apollo3:sfe_artemis_atp
name: SparkFun Artemis ATP
platforms: |
- name: SparkFun:apollo3
source-url: https://raw.githubusercontent.com/sparkfun/Arduino_Apollo3/master/package_sparkfun_apollo3_index.json

# ESP8266
# https://github.com/esp8266/Arduino/blob/master/boards.txt
- fqbn: esp8266:esp8266:thingdev
name: ESP8266 Thing Dev
platforms: |
- name: esp8266:esp8266
source-url: https://arduino.esp8266.com/stable/package_esp8266com_index.json

# SAMD21
# https://github.com/arduino/ArduinoCore-samd/blob/master/boards.txt
- fqbn: arduino:samd:mkr1000
name: SAMD21 MKR1000
platforms: |
- name: arduino:samd
# source-url: https://downloads.arduino.cc/packages/package_index.json

# Nano BLE 33 / nRF52840
# https://github.com/arduino/ArduinoCore-mbed/blob/master/boards.txt
- fqbn: arduino:mbed:nano33ble
name: Nano BLE 33
platforms: |
- name: arduino:mbed
# source-url: https://downloads.arduino.cc/packages/package_index.json

# RP2040
# https://github.com/arduino/ArduinoCore-mbed/blob/master/boards.txt
- fqbn: rp2040:rp2040:sparkfun_promicrorp2040
name: SparkFun Pro Micro RP2040
platforms: |
- name: rp2040:rp2040
source-url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

# RP2350
# https://github.com/arduino/ArduinoCore-mbed/blob/master/boards.txt
- fqbn: rp2040:rp2040:sparkfun_iotredboard_rp2350
name: SparkFun IoT RedBoard RP2350
platforms: |
- name: rp2040:rp2040
source-url: https://github.com/earlephilhower/arduino-pico/releases/download/global/package_rp2040_index.json

# STM32
# https://github.com/arduino/ArduinoCore-mbed/blob/master/boards.txt
- fqbn: STMicroelectronics:stm32:GenF4
name: STM32 GenF4
platforms: |
- name: STMicroelectronics:stm32
source-url: https://github.com/stm32duino/BoardManagerFiles/raw/main/package_stmicroelectronics_index.json
Expand All @@ -93,8 +127,10 @@ jobs:
- name: Checkout
uses: actions/checkout@v3

- name: Branch name
run: echo running on branch ${GITHUB_REF##*/}
- name: Branch name and details
run: |
echo "running on branch ${{ github.ref_name }}"
echo "Board: ${{matrix.board.name}}, fqbn: ${{ matrix.board.fqbn }}"

- name: Compile Sketch
uses: arduino/[email protected]
Expand Down
3 changes: 1 addition & 2 deletions examples/Example_01_TestCompile/Example_01_TestCompile.ino
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,7 @@

sfTkArdI2C myI2C;
sfTkArdSPI mySPI;
sfTkArdUART myUART;
sfTkArdUARTBus myUARTBus(myUART);
sfTkArdSerial mySerial;

void setup()
{
Expand Down
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/SparkFun_Toolkit.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,5 +21,5 @@
// Just include the toolkit headers
#include "sfTkArdI2C.h"
#include "sfTkArdSPI.h"
#include "sfTkArdUART.h"
#include "sfTkArdSerial.h"
#include "sfTkArduino.h"
39 changes: 38 additions & 1 deletion src/sfTk/sfTkISerial.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,11 +59,21 @@ const sfTkError_t ksfTkErrSerialNullSettings = ksfTkErrFail * (ksfTkErrBaseSeria
const sfTkError_t ksfTkErrSerialNullBuffer = ksfTkErrFail * (ksfTkErrBaseSerial + 6);

/**
* @brief Returned when the bus is under read. Warning.
* @brief Returned when the serial is under read. Warning.
*
*/
const sfTkError_t ksfTkErrSerialUnderRead = ksfTkErrBaseSerial + 7;

/**
* @brief Returned when the serial is not enabled. Warning
*/
const sfTkError_t ksfTkErrSerialNotEnabled = ksfTkErrBaseSerial + 8;

/**
* @brief Returned when the serial data is bad or corrupted.
*/
const sfTkError_t ksfTkErrSerialBadData = ksfTkErrFail * (ksfTkErrBaseSerial + 9);

class sfTkISerial
{
public:
Expand Down Expand Up @@ -112,4 +122,31 @@ class sfTkISerial

return read(&data, sizeof(data), nRead);
}

/**
* @brief Check if there are bytes available to read
*
* @return int Returns the number of bytes available to read in the read buffer
*/
virtual int available() = 0;

/**
* @brief Check if the serial interface is available for writing
*
* @return int Returns the number of bytes available to write
*/
virtual int availableForWrite() = 0;

/**
* @brief Peek at the next byte available to read without removing it from the buffer
*
* @return int Returns the next byte available to read, or -1 if no bytes are available
*/
virtual int peek() = 0;

/**
* @brief Flush the serial interface's write buffer
*
*/
virtual void flush() = 0;
};
2 changes: 1 addition & 1 deletion src/sfTk/sfTkISerialBus.h
Original file line number Diff line number Diff line change
Expand Up @@ -21,7 +21,7 @@

const uint8_t ksfTkBusTypeSerialBus = 0x03;

class sfTkISerialBus : sfTkIBus
class sfTkISerialBus : public sfTkIBus
{
public:
/**
Expand Down
Loading
Loading