diff options
Diffstat (limited to '.pio/libdeps/esp32-s3-n16r8/RF24/utility')
17 files changed, 791 insertions, 0 deletions
diff --git a/.pio/libdeps/esp32-s3-n16r8/RF24/utility/ATTiny/RF24_arch_config.h b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/ATTiny/RF24_arch_config.h new file mode 100644 index 0000000..40e5399 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/ATTiny/RF24_arch_config.h @@ -0,0 +1,53 @@ +/* + TMRh20 2015 + ATTiny Configuration File +*/ + +#ifndef RF24_UTILITY_ATTINY_RF24_ARCH_CONFIG_H_ +#define RF24_UTILITY_ATTINY_RF24_ARCH_CONFIG_H_ + +/*** USER DEFINES: ***/ +//#define FAILURE_HANDLING +//#define MINIMAL +/**********************/ + +#define rf24_max(a, b) (a > b ? a : b) +#define rf24_min(a, b) (a < b ? a : b) + +#if ARDUINO < 100 + #include <WProgram.h> +#else + #include <Arduino.h> +#endif + +#include <stddef.h> + +#include <SPI.h> + +#define _SPI SPI +typedef uint8_t rf24_gpio_pin_t; +#define RF24_PIN_INVALID 0xFF + +#if !defined(RF24_CSN_SETTLE_LOW_DELAY) + #define RF24_CSN_SETTLE_LOW_DELAY 11 +#endif + +#if !defined(RF24_CSN_SETTLE_HIGH_DELAY) + #define RF24_CSN_SETTLE_HIGH_DELAY 100 +#endif + +#ifdef RF24_DEBUG + #define IF_RF24_DEBUG(x) ({ x; }) +#else + #define IF_RF24_DEBUG(x) + + #if defined(RF24_TINY) + #define printf_P(...) + #endif +#endif // !defined(RF24_DEBUG) + +#include <avr/pgmspace.h> + +#define PRIPSTR "%S" + +#endif // RF24_UTILITY_ATTINY_RF24_ARCH_CONFIG_H_ diff --git a/.pio/libdeps/esp32-s3-n16r8/RF24/utility/Teensy/RF24_arch_config.h b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/Teensy/RF24_arch_config.h new file mode 100644 index 0000000..6e4a836 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/Teensy/RF24_arch_config.h @@ -0,0 +1,34 @@ +#ifndef RF24_UTILITY_TEENSY_RF24_ARCH_CONFIG_H_ +#define RF24_UTILITY_TEENSY_RF24_ARCH_CONFIG_H_ +#if ARDUINO < 100 + + #include <WProgram.h> + +#else + #include <Arduino.h> +#endif + +#include <stddef.h> + +#include <stdint.h> +#include <stdio.h> +#include <string.h> + +#include <SPI.h> + +#define _SPI SPIClass +#define RF24_SPI_PTR +typedef uint8_t rf24_gpio_pin_t; +#define RF24_PIN_INVALID 0xFF + +#define printf Serial.printf + +#ifdef RF24_DEBUG + #define IF_RF24_DEBUG(x) ({ x; }) +#else + #define IF_RF24_DEBUG(x) +#endif + +#define PRIPSTR "%s" + +#endif // RF24_UTILITY_TEENSY_RF24_ARCH_CONFIG_H_ diff --git a/.pio/libdeps/esp32-s3-n16r8/RF24/utility/Template/RF24_arch_config.h b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/Template/RF24_arch_config.h new file mode 100644 index 0000000..2cfd75a --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/Template/RF24_arch_config.h @@ -0,0 +1,76 @@ +/* + * Copyright (C) 2011 J. Coliz <maniacbug@ymail.com> + * + * This program is free software; you can redistribute it and/or + * modify it under the terms of the GNU General Public License + * version 2 as published by the Free Software Foundation. + */ + +/** + * @file RF24_arch_config.h + * General defines and includes for RF24/Linux + */ + +/** + * Example of RF24_arch_config.h for RF24 portability + * + * @defgroup Porting_General Porting: General + * @{ + */ + +#ifndef RF24_UTILITY_TEMPLATE_RF24_ARCH_CONFIG_H_ +#define RF24_UTILITY_TEMPLATE_RF24_ARCH_CONFIG_H_ + +#define RF24_LINUX + +#include <stddef.h> +#include "spi.h" +#include "gpio.h" +#include "compatibility.h" +#include <stdint.h> +#include <stdio.h> +#include <time.h> +#include <string.h> +#include <sys/time.h> + +#define _BV(x) (1 << (x)) +#define _SPI spi + +#ifdef RF24_DEBUG + #define IF_RF24_DEBUG(x) ({ x; }) +#else + #define IF_RF24_DEBUG(x) +#endif + +// Avoid spurious warnings +#if !defined(NATIVE) && defined(ARDUINO) + #undef PROGMEM + #define PROGMEM __attribute__((section(".progmem.data"))) + #undef PSTR + #define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); &__c[0]; })) +#endif + +typedef uint16_t prog_uint16_t; +typedef uint16_t rf24_gpio_pin_t; +#define PSTR(x) (x) +#define printf_P printf +#define strlen_P strlen +#define PROGMEM +#define pgm_read_word(p) (*(const unsigned short*)(p)) +#define PRIPSTR "%s" +#define pgm_read_byte(p) (*(const unsigned char*)(p)) + +// Function, constant map as a result of migrating from Arduino +#define LOW GPIO::OUTPUT_LOW +#define HIGH GPIO::OUTPUT_HIGH +#define INPUT GPIO::DIRECTION_IN +#define OUTPUT GPIO::DIRECTION_OUT +#define digitalWrite(pin, value) GPIO::write(pin, value) +#define pinMode(pin, direction) GPIO::open(pin, direction) +#define delay(millisec) __msleep(millisec) +#define delayMicroseconds(usec) __usleep(usec) +#define millis() __millis() + +/**@}*/ + +#endif // RF24_UTILITY_TEMPLATE_RF24_ARCH_CONFIG_H_ diff --git a/.pio/libdeps/esp32-s3-n16r8/RF24/utility/Template/compatibility.h b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/Template/compatibility.h new file mode 100644 index 0000000..49c33e1 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/Template/compatibility.h @@ -0,0 +1,36 @@ +/** + * @file compatibility.h + * Class declaration for SPI helper files + */ + +/** + * Example of compatibility.h class declaration for timing functions portability + * + * @defgroup Porting_Timing Porting: Timing + * @{ + */ + +#ifndef RF24_UTILITY_TEMPLATE_COMPATIBLITY_H_ +#define RF24_UTILITY_TEMPLATE_COMPATIBLITY_H_ + +#ifdef __cplusplus +extern "C" { +#endif + +#include <stdint.h> + +void __msleep(int millisec); + +void __usleep(int microsec); + +void __start_timer(); + +uint32_t __millis(); + +#ifdef __cplusplus +} +#endif + +/**@}*/ + +#endif // RF24_UTILITY_TEMPLATE_COMPATIBLITY_H_ diff --git a/.pio/libdeps/esp32-s3-n16r8/RF24/utility/Template/gpio.h b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/Template/gpio.h new file mode 100644 index 0000000..9164646 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/Template/gpio.h @@ -0,0 +1,67 @@ +/** + * @file gpio.h + * Class declaration for SPI helper files + */ + +/** + * Example of gpio.h class declaration for GPIO portability + * + * @defgroup Porting_GPIO Porting: GPIO + * @{ + */ +#ifndef RF24_UTILITY_TEMPLATE_GPIO_H_ +#define RF24_UTILITY_TEMPLATE_GPIO_H_ + +#include <cstdio> + +#ifndef DOXYGEN_FORCED +// exclude this line from the docs to prevent displaying in the list of classes +class GPIO +#endif +{ + +public: + /* Constants */ + static const int DIRECTION_OUT = 1; + static const int DIRECTION_IN = 0; + + static const int OUTPUT_HIGH = 1; + static const int OUTPUT_LOW = 0; + + GPIO(); + + /** + * Similar to Arduino pinMode(pin,mode); + * @param port + * @param DDR + */ + static void open(int port, int DDR); + + /** + * + * @param port + */ + static void close(int port); + + /** + * Similar to Arduino digitalRead(pin); + * @param port + */ + static int read(int port); + + /** + * Similar to Arduino digitalWrite(pin,state); + * @param port + * @param value + */ + static void write(int port, int value); + +#ifndef DOXYGEN_FORCED + // exclude this line from the docs to prevent warnings docs generators + virtual ~GPIO(); +#endif +}; + +/**@}*/ + +#endif // RF24_UTILITY_TEMPLATE_GPIO_H_ diff --git a/.pio/libdeps/esp32-s3-n16r8/RF24/utility/Template/includes.h b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/Template/includes.h new file mode 100644 index 0000000..2dd2412 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/Template/includes.h @@ -0,0 +1,28 @@ +/** + * @file includes.h + * Configuration defines for RF24/Linux + */ + +/** + * Example of includes.h for RF24 Linux portability + * + * @defgroup Porting_Includes Porting: Includes + * @{ + */ + +#ifndef RF24_UTILITY_INCLUDES_H_ +#define RF24_UTILITY_INCLUDES_H_ + +/** + * Define a specific platform for this configuration + */ +#define RF24_TEMPLATE + +/** + * Load the correct configuration for this platform + */ +#include "Template/RF24_arch_config.h" + +/**@}*/ + +#endif // RF24_UTILITY_INCLUDES_H_ diff --git a/.pio/libdeps/esp32-s3-n16r8/RF24/utility/Template/spi.h b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/Template/spi.h new file mode 100644 index 0000000..c4432a3 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/Template/spi.h @@ -0,0 +1,74 @@ +/** + * @file spi.h + * Class declaration for SPI helper files + */ + +/** + * Example of spi.h class declaration for SPI portability + * + * @defgroup Porting_SPI Porting: SPI + * @{ + */ +#ifndef RF24_UTILITY_TEMPLATE_SPI_H_ +#define RF24_UTILITY_TEMPLATE_SPI_H_ + +#include <stdint.h> + +#ifndef DOXYGEN_FORCED +// exclude this line from the docs to prevent displaying in the list of classes +class SPI +#endif +{ + +public: + /** + * SPI constructor + */ + SPI(); + + /** + * Start SPI + */ + void begin(int busNo); + + /** + * Transfer a single byte + * @param tx_ Byte to send + * @return Data returned via spi + */ + uint8_t transfer(uint8_t tx_); + + /** + * Transfer a buffer of data + * @param txBuf Transmit buffer + * @param rxBuf Receive buffer + * @param len Length of the data + */ + void transfernb(char* txBuf, char* rxBuf, uint32_t len); + + /** + * Transfer a buffer of data without an rx buffer + * @param buf Pointer to a buffer of data + * @param len Length of the data + */ + void transfern(char* buf, uint32_t len); + +#ifndef DOXYGEN_FORCED + // exclude this line from the docs to prevent warnings docs generators + virtual ~SPI(); +#endif + +private: + /** SPI bus */ + int bus; + /** SPI Mode set */ + uint8_t mode; + /** SPI word size */ + uint8_t bits; + /** SPI speed */ + uint32_t speed; +}; + +/**@}*/ + +#endif // RF24_UTILITY_TEMPLATE_SPI_H_ diff --git a/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/RF24_arch_config.h b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/RF24_arch_config.h new file mode 100644 index 0000000..3d05c09 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/RF24_arch_config.h @@ -0,0 +1,71 @@ +/* + Copyright (C) 2011 J. Coliz <maniacbug@ymail.com> + + This program is free software; you can redistribute it and/or + modify it under the terms of the GNU General Public License + version 2 as published by the Free Software Foundation. + + */ +#ifndef RF24_UTILITY_PIGPIO_RF24_ARCH_CONFIG_H_ +#define RF24_UTILITY_PIGPIO_RF24_ARCH_CONFIG_H_ + +#define RF24_LINUX + +#include <stdint.h> // uint16_t +#include <stdio.h> // printf +#include <string.h> // strlen +#include "spi.h" +#include "gpio.h" +#include "compatibility.h" + +//#define RF24_SPI_SPEED RF24_SPIDEV_SPEED + +#define _BV(x) (1 << (x)) +#define _SPI spi + +#ifdef RF24_DEBUG + #define IF_RF24_DEBUG(x) ({ x; }) +#else + #define IF_RF24_DEBUG(x) +#endif + +// Avoid spurious warnings +#if 1 + #if !defined(NATIVE) && defined(ARDUINO) + #undef PROGMEM + #define PROGMEM __attribute__((section(".progmem.data"))) + #undef PSTR + #define PSTR(s) (__extension__({static const char __c[] PROGMEM = (s); &__c[0]; })) + #endif +#endif + +#if RF24_SPI_SPEED > 1000000 + #undef RF24_SPI_SPEED + #define RF24_SPI_SPEED 1000000 +#endif + +typedef uint16_t prog_uint16_t; +typedef uint8_t rf24_gpio_pin_t; +#define RF24_PIN_INVALID 0xFF + +#define PSTR(x) (x) +#define printf_P printf +#define strlen_P strlen +#define PROGMEM +#define pgm_read_word(p) (*(const unsigned short*)(p)) +#define PRIPSTR "%s" +#define pgm_read_byte(p) (*(const unsigned char*)(p)) +#define pgm_read_ptr(p) (*(void* const*)(p)) + +// Function, constant map as a result of migrating from Arduino +#define LOW GPIO::OUTPUT_LOW +#define HIGH GPIO::OUTPUT_HIGH +#define INPUT GPIO::DIRECTION_IN +#define OUTPUT GPIO::DIRECTION_OUT +#define digitalWrite(pin, value) GPIO::write(pin, value) +#define pinMode(pin, direction) GPIO::open(pin, direction) +#define delay(millisec) __msleep(millisec) +#define delayMicroseconds(usec) __usleep(usec) +#define millis() __millis() + +#endif // RF24_UTILITY_PIGPIO_RF24_ARCH_CONFIG_H_ diff --git a/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/compatibility.cpp b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/compatibility.cpp new file mode 100644 index 0000000..f28cf3d --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/compatibility.cpp @@ -0,0 +1,45 @@ +#include <time.h> +#include <chrono> +#include "compatibility.h" + +long long mtime, seconds, useconds; +//static struct timeval start, end; +//struct timespec start, end; + +void __msleep(int millisec) +{ + struct timespec req; // = {0}; + req.tv_sec = (time_t)millisec / 1000; + req.tv_nsec = (millisec % 1000) * 1000000L; + //nanosleep(&req, (struct timespec *)NULL); + clock_nanosleep(CLOCK_REALTIME, 0, &req, NULL); +} + +void __usleep(int microsec) +{ + struct timespec req; // = {0}; + req.tv_sec = (time_t)microsec / 1000000; + req.tv_nsec = (microsec % 1000000) * 1000; + //nanosleep(&req, (struct timespec *)NULL); + clock_nanosleep(CLOCK_REALTIME, 0, &req, NULL); +} + +/** + * This function is added in order to simulate arduino millis() function + */ + +bool timerStarted = false; + +void __start_timer() +{ +} + +auto start = std::chrono::steady_clock::now(); + +uint32_t __millis() +{ + + auto end = std::chrono::steady_clock::now(); + + return std::chrono::duration_cast<std::chrono::milliseconds>(end - start).count(); +} diff --git a/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/compatibility.h b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/compatibility.h new file mode 100644 index 0000000..b94c571 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/compatibility.h @@ -0,0 +1,25 @@ +/* + * Time keeping functions + */ +#ifndef RF24_UTILITY_PIGPIO_COMPATIBLITY_H_ +#define RF24_UTILITY_PIGPIO_COMPATIBLITY_H_ + +#include <stdint.h> // for uintXX_t types + +#ifdef __cplusplus +extern "C" { +#endif + +void __msleep(int millisec); + +void __usleep(int microsec); + +void __start_timer(); + +uint32_t __millis(); + +#ifdef __cplusplus +} +#endif + +#endif /* RF24_UTILITY_PIGPIO_COMPATIBLITY_H_ */ diff --git a/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/gpio.cpp b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/gpio.cpp new file mode 100644 index 0000000..3c9a63e --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/gpio.cpp @@ -0,0 +1,39 @@ +/* + * GPIO Functions + */ +#include <pigpio.h> +#include "gpio.h" + +bool initialized = 0; + +GPIO::GPIO() +{ +} + +GPIO::~GPIO() +{ + gpioTerminate(); +} + +void GPIO::open(int port, int DDR) +{ + if (!initialized) { + gpioInitialise(); + } + initialized = true; + gpioSetMode(port, PI_OUTPUT); +} + +void GPIO::close(int port) +{ +} + +int GPIO::read(int port) +{ + return gpioRead(port); +} + +void GPIO::write(int port, int value) +{ + gpioWrite(port, value); +} diff --git a/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/gpio.h b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/gpio.h new file mode 100644 index 0000000..8fe245c --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/gpio.h @@ -0,0 +1,63 @@ +/* + * + */ + +#ifndef RF24_UTILITY_PIGPIO_GPIO_H_ +#define RF24_UTILITY_PIGPIO_GPIO_H_ + +#include <stdexcept> + +/** Specific exception for GPIO errors */ +class GPIOException : public std::runtime_error +{ +public: + explicit GPIOException(const std::string& msg) + : std::runtime_error(msg) + { + } +}; + +class GPIO +{ +public: + /* Constants */ + static const int DIRECTION_OUT = 1; + static const int DIRECTION_IN = 0; + + static const int OUTPUT_HIGH = 1; + static const int OUTPUT_LOW = 0; + + GPIO(); + + /** + * Similar to Arduino pinMode(pin,mode); + * @param port + * @param DDR + */ + static void open(int port, int DDR); + + /** + * + * @param port + */ + static void close(int port); + + /** + * Similar to Arduino digitalRead(pin); + * @param port + */ + static int read(int port); + + /** + * Similar to Arduino digitalWrite(pin,state); + * @param port + * @param value + */ + static void write(int port, int value); + + virtual ~GPIO(); + +private: +}; + +#endif /* RF24_UTILITY_PIGPIO_GPIO_H_ */ diff --git a/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/includes.h b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/includes.h new file mode 100644 index 0000000..9f4c2e8 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/includes.h @@ -0,0 +1,10 @@ +#ifndef RF24_UTILITY_INCLUDES_H_ +#define RF24_UTILITY_INCLUDES_H_ + +#define RF24_PIGPIO + +#include <cstring> // memcpy() used in RF24.cpp +#include "pigpio/RF24_arch_config.h" +#include "pigpio/interrupt.h" + +#endif diff --git a/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/interrupt.cpp b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/interrupt.cpp new file mode 100644 index 0000000..ad89af4 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/interrupt.cpp @@ -0,0 +1,32 @@ +/** + * Interrupt implementation wrapped from pigpio library + */ +#include <pigpio.h> +#include "interrupt.h" + +#ifdef __cplusplus +extern "C" { +#endif + +int attachInterrupt(int pin, int mode, void (*function)(void)) +{ + gpioInitialise(); + return gpioSetISRFunc(pin, mode, 0, (gpioISRFunc_t)function); +} + +int detachInterrupt(int pin) +{ + return gpioSetISRFunc(pin, 0, 0, NULL); +} + +void rfNoInterrupts() +{ +} + +void rfInterrupts() +{ +} + +#ifdef __cplusplus +} +#endif diff --git a/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/interrupt.h b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/interrupt.h new file mode 100644 index 0000000..80272cd --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/interrupt.h @@ -0,0 +1,30 @@ +/** + * Interrupt functions wrapped from pigpio library + */ +#ifndef RF24_UTILITY_PIGPIO_INTERRUPT_H_ +#define RF24_UTILITY_PIGPIO_INTERRUPT_H_ + +#include <pigpio.h> + +#define INT_EDGE_FALLING FALLING_EDGE +#define INT_EDGE_RISING RISING_EDGE +#define INT_EDGE_BOTH EITHER_EDGE + +#ifdef __cplusplus +extern "C" { +#endif + +int attachInterrupt(int pin, int mode, void (*function)(void)); + +int detachInterrupt(int pin); + +/* Deprecated, no longer functional */ +void rfNoInterrupts(); + +/* Deprecated, no longer functional */ +void rfInterrupts(); + +#ifdef __cplusplus +} +#endif +#endif // RF24_UTILITY_PIGPIO_INTERRUPT_H_
\ No newline at end of file diff --git a/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/spi.cpp b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/spi.cpp new file mode 100644 index 0000000..8698a14 --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/spi.cpp @@ -0,0 +1,40 @@ +/* + * + */ + +#include <pigpio.h> +#include "spi.h" + +SPI::SPI() +{ +} + +void SPI::begin(int busNo, uint32_t spi_speed) +{ + if (this->spiIsInitialized) { + return; + } + spiIsInitialized = true; + gpioInitialise(); + spiHandle = spiOpen((unsigned int)(busNo & 2), spi_speed, (unsigned int)((busNo / 10) << 7)); +} + +void SPI::init(uint32_t speed) +{ +} + +uint8_t SPI::transfer(char tx) +{ + char rbuf = 0; + spiXfer(spiHandle, &tx, &rbuf, 1); + return rbuf; +} + +void SPI::transfernb(char* txBuf, char* rxBuf, uint32_t len) +{ + spiXfer(spiHandle, txBuf, rxBuf, len); +} + +SPI::~SPI() +{ +} diff --git a/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/spi.h b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/spi.h new file mode 100644 index 0000000..9c5fa2a --- /dev/null +++ b/.pio/libdeps/esp32-s3-n16r8/RF24/utility/pigpio/spi.h @@ -0,0 +1,68 @@ +/* + * + */ + +#ifndef RF24_UTILITY_PIGPIO_SPI_H_ +#define RF24_UTILITY_PIGPIO_SPI_H_ + +#include <cstdint> +#include <stdexcept> + +/** Specific exception for SPI errors */ +class SPIException : public std::runtime_error +{ +public: + explicit SPIException(const std::string& msg) + : std::runtime_error(msg) + { + } +}; + +class SPI +{ + +public: + /** + * SPI constructor + */ + SPI(); + + /** + * Start SPI + */ + void begin(int busNo, uint32_t spi_speed); + + /** + * Transfer a single byte + * @param tx Byte to send + * @return Data returned via spi + */ + uint8_t transfer(char tx); + + /** + * Transfer a buffer of data + * @param txBuf Transmit buffer + * @param rxBuf Receive buffer + * @param len Length of the data + */ + void transfernb(char* txBuf, char* rxBuf, uint32_t len); + + /** + * Transfer a buffer of data without an rx buffer + * @param buf Pointer to a buffer of data + * @param len Length of the data + */ + void transfern(char* buf, uint32_t len) + { + transfernb(buf, buf, len); + } + + ~SPI(); + +private: + unsigned spiHandle; + bool spiIsInitialized = false; + void init(uint32_t spi_speed); +}; + +#endif /* RF24_UTILITY_PIGPIO_SPI_H_ */ |
