From 334a46274c0bfbecca00d80b507191a25c9ac3e0 Mon Sep 17 00:00:00 2001 From: Meco Man <920369182@qq.com> Date: Sat, 27 Aug 2022 15:22:27 -0400 Subject: [PATCH] =?UTF-8?q?=E7=A7=BB=E9=99=A4fork=E6=96=87=E4=BB=B6?= =?UTF-8?q?=E5=A4=B9=EF=BC=8C=E8=BD=AC=E7=A7=BB=E5=88=B0RTduino-libraries?= =?UTF-8?q?=E7=BB=84=E7=BB=87?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- README.md | 12 +- examples/MsTimer2/FlashLED.cpp | 41 -- .../Adafruit_BusIO_Register.cpp | 385 ------------- .../Adafruit_BusIO/Adafruit_BusIO_Register.h | 120 ----- .../Adafruit_BusIO/Adafruit_I2CDevice.cpp | 167 ------ .../Adafruit_BusIO/Adafruit_I2CDevice.h | 45 -- .../Adafruit_BusIO/Adafruit_I2CRegister.h | 23 - .../Adafruit_BusIO/Adafruit_SPIDevice.cpp | 505 ------------------ .../Adafruit_BusIO/Adafruit_SPIDevice.h | 74 --- .../fork/Adafruit/Adafruit_BusIO/LICENSE | 21 - .../fork/Adafruit/Adafruit_BusIO/README.md | 9 - .../fork/Adafruit/Adafruit_BusIO/SConscript | 13 - .../Adafruit_Sensor/Adafruit_Sensor.cpp | 88 --- .../Adafruit_Sensor/Adafruit_Sensor.h | 204 ------- .../fork/Adafruit/Adafruit_Sensor/LICENSE.txt | 202 ------- .../fork/Adafruit/Adafruit_Sensor/README.md | 231 -------- .../fork/Adafruit/Adafruit_Sensor/SConscript | 13 - libraries/fork/Adafruit/SConscript | 12 - libraries/fork/MsTimer2/MsTimer2.cpp | 28 - libraries/fork/MsTimer2/MsTimer2.h | 22 - libraries/fork/MsTimer2/SConscript | 9 - libraries/fork/README.md | 3 - libraries/fork/SConscript | 12 - 23 files changed, 1 insertion(+), 2238 deletions(-) delete mode 100644 examples/MsTimer2/FlashLED.cpp delete mode 100644 libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_BusIO_Register.cpp delete mode 100644 libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_BusIO_Register.h delete mode 100644 libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_I2CDevice.cpp delete mode 100644 libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_I2CDevice.h delete mode 100644 libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_I2CRegister.h delete mode 100644 libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_SPIDevice.cpp delete mode 100644 libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_SPIDevice.h delete mode 100644 libraries/fork/Adafruit/Adafruit_BusIO/LICENSE delete mode 100644 libraries/fork/Adafruit/Adafruit_BusIO/README.md delete mode 100644 libraries/fork/Adafruit/Adafruit_BusIO/SConscript delete mode 100644 libraries/fork/Adafruit/Adafruit_Sensor/Adafruit_Sensor.cpp delete mode 100644 libraries/fork/Adafruit/Adafruit_Sensor/Adafruit_Sensor.h delete mode 100644 libraries/fork/Adafruit/Adafruit_Sensor/LICENSE.txt delete mode 100644 libraries/fork/Adafruit/Adafruit_Sensor/README.md delete mode 100644 libraries/fork/Adafruit/Adafruit_Sensor/SConscript delete mode 100644 libraries/fork/Adafruit/SConscript delete mode 100644 libraries/fork/MsTimer2/MsTimer2.cpp delete mode 100644 libraries/fork/MsTimer2/MsTimer2.h delete mode 100644 libraries/fork/MsTimer2/SConscript delete mode 100644 libraries/fork/README.md delete mode 100644 libraries/fork/SConscript diff --git a/README.md b/README.md index 3b1fa87..5397a65 100644 --- a/README.md +++ b/README.md @@ -77,8 +77,6 @@ RTduino软件包包含有两个主要的文件夹:core和libraries。 - buildin文件夹下存放着Arduino内置的一些库,例如Servo舵机驱动库,Wire I2C驱动库等等; - - fork文件夹是保存着一些Arduino社区比较重要的第三方库,这些库不能直接移植到RT-Thread上来,需要进行一些适配,因此保存在这里; - - user文件夹是用户文件夹,这是对用户来说很重要的一个文件夹,里边默认是空的,用户可以把下载好的Arduino库拖入到此文件夹中来,在下个章节会细说这个操作。 ### 2.4 Arduino经典的setup和loop函数在哪里? @@ -158,15 +156,7 @@ void loop(void) | Servo | 舵机库 | RTDUINO_USING_SERVO | 所有支持PWM功能的BSP均会默认开启该库 | | SPI | SPI库 | RTDUINO_USING_SPI | 正在开发中 | | Wire | I2C库 | RTDUINO_USING_WIRE | 所有支持I2C功能的BSP均会默认开启该库 | -| USBSerial | USB虚拟串口库 | RTDUINO_USING_USBSERIAL | 自动依赖[TinyUSB for RT-Thread](https://github.com/RT-Thread-packages/tinyusb)软件包 | - -另一类是Arduino社区比较重要的第三方库,且该第三方库不能直接在RTduino上运行,需要进行重新适配到RTduino,存放于 `libraries/fork` 文件夹内。具体如下表所示: - -| 库名称 | 说明 | 使能宏 | 备注 | -| -------------------------------------------------------------- | ------------------ | ---------------------- | ------------------------- | -| [Adafruit_BusIO](https://github.com/adafruit/Adafruit_BusIO) | Adafruit社区总线库 | RTDUINO_USING_ADAFRUIT | 所有支持I2C、SPI功能的BSP均会默认开启该库 | -| [Adafruit_Sensor](https://github.com/adafruit/Adafruit_Sensor) | Adafruit社区传感器统一驱动库 | RTDUINO_USING_ADAFRUIT | 所有支持I2C、SPI功能的BSP均会默认开启该库 | -| [MsTimer2](https://github.com/PaulStoffregen/MsTimer2) | 1ms级定时器库 | RTDUINO_USING_MSTIMER2 | 所有BSP默认开启该库 | +| USBSerial | USB虚拟串口库 | RTDUINO_USING_USBSERIAL | 自动依赖[TinyUSB for RT-Thread](https://github.com/RT-Thread-packages/tinyusb)软件包 | | ## 4 如何给某个BSP适配RTduino diff --git a/examples/MsTimer2/FlashLED.cpp b/examples/MsTimer2/FlashLED.cpp deleted file mode 100644 index 19c0cbd..0000000 --- a/examples/MsTimer2/FlashLED.cpp +++ /dev/null @@ -1,41 +0,0 @@ -/* - * Copyright (c) 2021-2022, RTduino Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2022-08-07 Meco Man port to RTduino - */ -/* - MsTimer2 is a small and very easy to use library to interface Timer2 with - humans. It's called MsTimer2 because it "hardcodes" a resolution of 1 - millisecond on timer2 - For Details see: http://www.arduino.cc/playground/Main/MsTimer2 -*/ - -#include - -// Switch on LED on and off each half second -const int led_pin = LED_BUILTIN; - -void flash() -{ - static boolean output = HIGH; - - digitalWrite(led_pin, output); - output = !output; -} - -void setup() -{ - pinMode(led_pin, OUTPUT); - - MsTimer2::set(500, flash); // 500ms period - MsTimer2::start(); -} - -void loop() -{ - delay(1000); -} diff --git a/libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_BusIO_Register.cpp b/libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_BusIO_Register.cpp deleted file mode 100644 index 3270cea..0000000 --- a/libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_BusIO_Register.cpp +++ /dev/null @@ -1,385 +0,0 @@ -/* - * Copyright (c) 2021-2022, RTduino Development Team - * - * SPDX-License-Identifier: MIT - * - * Change Logs: - * Date Author Notes - * 2022-02-19 Meco Man port to RTduino - */ - -#include - -#ifdef RTDUINO_USING_WIRE -/*! - * @brief Create a register we access over an I2C Device (which defines the - * bus and address) - * @param i2cdevice The I2CDevice to use for underlying I2C access - * @param reg_addr The address pointer value for the I2C/SMBus register, can - * be 8 or 16 bits - * @param width The width of the register data itself, defaults to 1 byte - * @param byteorder The byte order of the register (used when width is > 1), - * defaults to LSBFIRST - * @param address_width The width of the register address itself, defaults - * to 1 byte - */ -Adafruit_BusIO_Register::Adafruit_BusIO_Register(Adafruit_I2CDevice *i2cdevice, - uint16_t reg_addr, - uint8_t width, - uint8_t byteorder, - uint8_t address_width) { - _i2cdevice = i2cdevice; -#ifdef RTDUINO_USING_SPI - _spidevice = NULL; -#endif /* RTDUINO_USING_SPI */ - _addrwidth = address_width; - _address = reg_addr; - _byteorder = byteorder; - _width = width; - _cached = 0; -} -#endif /* RTDUINO_USING_WIRE */ - -#ifdef RTDUINO_USING_SPI -/*! - * @brief Create a register we access over an SPI Device (which defines the - * bus and CS pin) - * @param spidevice The SPIDevice to use for underlying SPI access - * @param reg_addr The address pointer value for the SPI register, can - * be 8 or 16 bits - * @param type The method we use to read/write data to SPI (which is not - * as well defined as I2C) - * @param width The width of the register data itself, defaults to 1 byte - * @param byteorder The byte order of the register (used when width is > 1), - * defaults to LSBFIRST - * @param address_width The width of the register address itself, defaults - * to 1 byte - */ -Adafruit_BusIO_Register::Adafruit_BusIO_Register(Adafruit_SPIDevice *spidevice, - uint16_t reg_addr, - Adafruit_BusIO_SPIRegType type, - uint8_t width, - uint8_t byteorder, - uint8_t address_width) { - _spidevice = spidevice; - _spiregtype = type; - _i2cdevice = NULL; - _addrwidth = address_width; - _address = reg_addr; - _byteorder = byteorder; - _width = width; - _cached = 0; -} - -/*! - * @brief Create a register we access over an I2C or SPI Device. This is a - * handy function because we can pass in nullptr for the unused interface, - * allowing libraries to mass-define all the registers - * @param i2cdevice The I2CDevice to use for underlying I2C access, if - * nullptr we use SPI - * @param spidevice The SPIDevice to use for underlying SPI access, if - * nullptr we use I2C - * @param reg_addr The address pointer value for the I2C/SMBus/SPI register, - * can be 8 or 16 bits - * @param type The method we use to read/write data to SPI (which is not - * as well defined as I2C) - * @param width The width of the register data itself, defaults to 1 byte - * @param byteorder The byte order of the register (used when width is > 1), - * defaults to LSBFIRST - * @param address_width The width of the register address itself, defaults - * to 1 byte - */ -Adafruit_BusIO_Register::Adafruit_BusIO_Register( - Adafruit_I2CDevice *i2cdevice, Adafruit_SPIDevice *spidevice, - Adafruit_BusIO_SPIRegType type, uint16_t reg_addr, uint8_t width, - uint8_t byteorder, uint8_t address_width) { - _spidevice = spidevice; - _i2cdevice = i2cdevice; - _spiregtype = type; - _addrwidth = address_width; - _address = reg_addr; - _byteorder = byteorder; - _width = width; - _cached = 0; -} -#endif /* RTDUINO_USING_SPI */ - -/*! - * @brief Write a buffer of data to the register location - * @param buffer Pointer to data to write - * @param len Number of bytes to write - * @return True on successful write (only really useful for I2C as SPI is - * uncheckable) - */ -bool Adafruit_BusIO_Register::write(uint8_t *buffer, uint8_t len) { - - uint8_t addrbuffer[2] = {(uint8_t)(_address & 0xFF), - (uint8_t)(_address >> 8)}; -#ifdef RTDUINO_USING_WIRE - if (_i2cdevice) { - return _i2cdevice->write(buffer, len, true, addrbuffer, _addrwidth); - } -#endif /* RTDUINO_USING_WIRE */ -#ifdef RTDUINO_USING_SPI - if (_spidevice) { - if (_spiregtype == ADDRESSED_OPCODE_BIT0_LOW_TO_WRITE) { - // very special case! - - // pass the special opcode address which we set as the high byte of the - // regaddr - addrbuffer[0] = - (uint8_t)(_address >> 8) & ~0x01; // set bottom bit low to write - // the 'actual' reg addr is the second byte then - addrbuffer[1] = (uint8_t)(_address & 0xFF); - // the address appears to be a byte longer - return _spidevice->write(buffer, len, addrbuffer, _addrwidth + 1); - } - - if (_spiregtype == ADDRBIT8_HIGH_TOREAD) { - addrbuffer[0] &= ~0x80; - } - if (_spiregtype == ADDRBIT8_HIGH_TOWRITE) { - addrbuffer[0] |= 0x80; - } - if (_spiregtype == AD8_HIGH_TOREAD_AD7_HIGH_TOINC) { - addrbuffer[0] &= ~0x80; - addrbuffer[0] |= 0x40; - } - return _spidevice->write(buffer, len, addrbuffer, _addrwidth); - } -#endif /* RTDUINO_USING_SPI */ - return false; -} - -/*! - * @brief Write up to 4 bytes of data to the register location - * @param value Data to write - * @param numbytes How many bytes from 'value' to write - * @return True on successful write (only really useful for I2C as SPI is - * uncheckable) - */ -bool Adafruit_BusIO_Register::write(uint32_t value, uint8_t numbytes) { - if (numbytes == 0) { - numbytes = _width; - } - if (numbytes > 4) { - return false; - } - - // store a copy - _cached = value; - - for (int i = 0; i < numbytes; i++) { - if (_byteorder == LSBFIRST) { - _buffer[i] = value & 0xFF; - } else { - _buffer[numbytes - i - 1] = value & 0xFF; - } - value >>= 8; - } - return write(_buffer, numbytes); -} - -/*! - * @brief Read data from the register location. This does not do any error - * checking! - * @return Returns 0xFFFFFFFF on failure, value otherwise - */ -uint32_t Adafruit_BusIO_Register::read(void) { - if (!read(_buffer, _width)) { - return (uint32_t)-1; - } - - uint32_t value = 0; - - for (int i = 0; i < _width; i++) { - value <<= 8; - if (_byteorder == LSBFIRST) { - value |= _buffer[_width - i - 1]; - } else { - value |= _buffer[i]; - } - } - - return value; -} - -/*! - * @brief Read cached data from last time we wrote to this register - * @return Returns 0xFFFFFFFF on failure, value otherwise - */ -uint32_t Adafruit_BusIO_Register::readCached(void) { return _cached; } - -/*! - * @brief Read a buffer of data from the register location - * @param buffer Pointer to data to read into - * @param len Number of bytes to read - * @return True on successful write (only really useful for I2C as SPI is - * uncheckable) - */ -bool Adafruit_BusIO_Register::read(uint8_t *buffer, uint8_t len) { - uint8_t addrbuffer[2] = {(uint8_t)(_address & 0xFF), - (uint8_t)(_address >> 8)}; -#ifdef RTDUINO_USING_WIRE - if (_i2cdevice) { - return _i2cdevice->write_then_read(addrbuffer, _addrwidth, buffer, len); - } -#endif /* RTDUINO_USING_WIRE */ -#ifdef RTDUINO_USING_SPI - if (_spidevice) { - if (_spiregtype == ADDRESSED_OPCODE_BIT0_LOW_TO_WRITE) { - // very special case! - - // pass the special opcode address which we set as the high byte of the - // regaddr - addrbuffer[0] = - (uint8_t)(_address >> 8) | 0x01; // set bottom bit high to read - // the 'actual' reg addr is the second byte then - addrbuffer[1] = (uint8_t)(_address & 0xFF); - // the address appears to be a byte longer - return _spidevice->write_then_read(addrbuffer, _addrwidth + 1, buffer, - len); - } - if (_spiregtype == ADDRBIT8_HIGH_TOREAD) { - addrbuffer[0] |= 0x80; - } - if (_spiregtype == ADDRBIT8_HIGH_TOWRITE) { - addrbuffer[0] &= ~0x80; - } - if (_spiregtype == AD8_HIGH_TOREAD_AD7_HIGH_TOINC) { - addrbuffer[0] |= 0x80 | 0x40; - } - return _spidevice->write_then_read(addrbuffer, _addrwidth, buffer, len); - } -#endif /* RTDUINO_USING_SPI */ - return false; -} - -/*! - * @brief Read 2 bytes of data from the register location - * @param value Pointer to uint16_t variable to read into - * @return True on successful write (only really useful for I2C as SPI is - * uncheckable) - */ -bool Adafruit_BusIO_Register::read(uint16_t *value) { - if (!read(_buffer, 2)) { - return false; - } - - if (_byteorder == LSBFIRST) { - *value = _buffer[1]; - *value <<= 8; - *value |= _buffer[0]; - } else { - *value = _buffer[0]; - *value <<= 8; - *value |= _buffer[1]; - } - return true; -} - -/*! - * @brief Read 1 byte of data from the register location - * @param value Pointer to uint8_t variable to read into - * @return True on successful write (only really useful for I2C as SPI is - * uncheckable) - */ -bool Adafruit_BusIO_Register::read(uint8_t *value) { - if (!read(_buffer, 1)) { - return false; - } - - *value = _buffer[0]; - return true; -} - -/*! - * @brief Pretty printer for this register - * @param s The Stream to print to, defaults to &Serial - */ -void Adafruit_BusIO_Register::print(Stream *s) { - uint32_t val = read(); - s->print("0x"); - s->print(val, HEX); -} - -/*! - * @brief Pretty printer for this register - * @param s The Stream to print to, defaults to &Serial - */ -void Adafruit_BusIO_Register::println(Stream *s) { - print(s); - s->println(); -} - -/*! - * @brief Create a slice of the register that we can address without - * touching other bits - * @param reg The Adafruit_BusIO_Register which defines the bus/register - * @param bits The number of bits wide we are slicing - * @param shift The number of bits that our bit-slice is shifted from LSB - */ -Adafruit_BusIO_RegisterBits::Adafruit_BusIO_RegisterBits( - Adafruit_BusIO_Register *reg, uint8_t bits, uint8_t shift) { - _register = reg; - _bits = bits; - _shift = shift; -} - -/*! - * @brief Read 4 bytes of data from the register - * @return data The 4 bytes to read - */ -uint32_t Adafruit_BusIO_RegisterBits::read(void) { - uint32_t val = _register->read(); - val >>= _shift; - return val & ((1 << (_bits)) - 1); -} - -/*! - * @brief Write 4 bytes of data to the register - * @param data The 4 bytes to write - * @return True on successful write (only really useful for I2C as SPI is - * uncheckable) - */ -bool Adafruit_BusIO_RegisterBits::write(uint32_t data) { - uint32_t val = _register->read(); - - // mask off the data before writing - uint32_t mask = (1 << (_bits)) - 1; - data &= mask; - - mask <<= _shift; - val &= ~mask; // remove the current data at that spot - val |= data << _shift; // and add in the new data - - return _register->write(val, _register->width()); -} - -/*! - * @brief The width of the register data, helpful for doing calculations - * @returns The data width used when initializing the register - */ -uint8_t Adafruit_BusIO_Register::width(void) { return _width; } - -/*! - * @brief Set the default width of data - * @param width the default width of data read from register - */ -void Adafruit_BusIO_Register::setWidth(uint8_t width) { _width = width; } - -/*! - * @brief Set register address - * @param address the address from register - */ -void Adafruit_BusIO_Register::setAddress(uint16_t address) { - _address = address; -} - -/*! - * @brief Set the width of register address - * @param address_width the width for register address - */ -void Adafruit_BusIO_Register::setAddressWidth(uint16_t address_width) { - _addrwidth = address_width; -} diff --git a/libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_BusIO_Register.h b/libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_BusIO_Register.h deleted file mode 100644 index a5d3ed2..0000000 --- a/libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_BusIO_Register.h +++ /dev/null @@ -1,120 +0,0 @@ -/* - * Copyright (c) 2021-2022, RTduino Development Team - * - * SPDX-License-Identifier: MIT - * - * Change Logs: - * Date Author Notes - * 2022-02-19 Meco Man port to RTduino - */ - -#ifndef Adafruit_BusIO_Register_h -#define Adafruit_BusIO_Register_h - -#include - -#ifdef RTDUINO_USING_WIRE -#include -#endif /* RTDUINO_USING_WIRE */ -#ifdef RTDUINO_USING_SPI -#include -#endif /* RTDUINO_USING_SPI */ - -typedef enum _Adafruit_BusIO_SPIRegType { - ADDRBIT8_HIGH_TOREAD = 0, - /*!< - * ADDRBIT8_HIGH_TOREAD - * When reading a register you must actually send the value 0x80 + register - * address to the device. e.g. To read the register 0x0B the register value - * 0x8B is sent and to write 0x0B is sent. - */ - AD8_HIGH_TOREAD_AD7_HIGH_TOINC = 1, - - /*!< - * ADDRBIT8_HIGH_TOWRITE - * When writing to a register you must actually send the value 0x80 + - * the register address to the device. e.g. To write to the register 0x19 the - * register value 0x99 is sent and to read 0x19 is sent. - */ - ADDRBIT8_HIGH_TOWRITE = 2, - - /*!< - * ADDRESSED_OPCODE_LOWBIT_TO_WRITE - * Used by the MCP23S series, we send 0x40 |'rd with the opcode - * Then set the lowest bit to write - */ - ADDRESSED_OPCODE_BIT0_LOW_TO_WRITE = 3, - -} Adafruit_BusIO_SPIRegType; - -/*! - * @brief The class which defines a device register (a location to read/write - * data from) - */ -class Adafruit_BusIO_Register { -public: -#ifdef RTDUINO_USING_WIRE - Adafruit_BusIO_Register(Adafruit_I2CDevice *i2cdevice, uint16_t reg_addr, - uint8_t width = 1, uint8_t byteorder = LSBFIRST, - uint8_t address_width = 1); -#endif /* RTDUINO_USING_WIRE */ -#ifdef RTDUINO_USING_SPI - Adafruit_BusIO_Register(Adafruit_SPIDevice *spidevice, uint16_t reg_addr, - Adafruit_BusIO_SPIRegType type, uint8_t width = 1, - uint8_t byteorder = LSBFIRST, - uint8_t address_width = 1); - - Adafruit_BusIO_Register(Adafruit_I2CDevice *i2cdevice, - Adafruit_SPIDevice *spidevice, - Adafruit_BusIO_SPIRegType type, uint16_t reg_addr, - uint8_t width = 1, uint8_t byteorder = LSBFIRST, - uint8_t address_width = 1); -#endif /* RTDUINO_USING_SPI */ - bool read(uint8_t *buffer, uint8_t len); - bool read(uint8_t *value); - bool read(uint16_t *value); - uint32_t read(void); - uint32_t readCached(void); - bool write(uint8_t *buffer, uint8_t len); - bool write(uint32_t value, uint8_t numbytes = 0); - - uint8_t width(void); - - void setWidth(uint8_t width); - void setAddress(uint16_t address); - void setAddressWidth(uint16_t address_width); - - void print(Stream *s = &Serial); - void println(Stream *s = &Serial); - -private: -#ifdef RTDUINO_USING_WIRE - Adafruit_I2CDevice *_i2cdevice; -#endif /* RTDUINO_USING_WIRE */ -#ifdef RTDUINO_USING_SPI - Adafruit_SPIDevice *_spidevice; - Adafruit_BusIO_SPIRegType _spiregtype; -#endif /* RTDUINO_USING_SPI */ - uint16_t _address; - uint8_t _width, _addrwidth, _byteorder; - uint8_t _buffer[4]; // we won't support anything larger than uint32 for non-buffered read - uint32_t _cached; -}; - -/*! - * @brief The class which defines a slice of bits from within a device register - * (a location to read/write data from) - */ -class Adafruit_BusIO_RegisterBits { -public: - Adafruit_BusIO_RegisterBits(Adafruit_BusIO_Register *reg, uint8_t bits, - uint8_t shift); - bool write(uint32_t value); - uint32_t read(void); - -private: - Adafruit_BusIO_Register *_register; - uint8_t _bits, _shift; -}; - -#endif // BusIO_Register_h diff --git a/libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_I2CDevice.cpp b/libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_I2CDevice.cpp deleted file mode 100644 index bf7ad66..0000000 --- a/libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_I2CDevice.cpp +++ /dev/null @@ -1,167 +0,0 @@ -/* - * Copyright (c) 2021-2022, RTduino Development Team - * - * SPDX-License-Identifier: MIT - * - * Change Logs: - * Date Author Notes - * 2022-02-19 Meco Man port to RTduino - */ - -#include "Adafruit_I2CDevice.h" - -#ifdef RTDUINO_USING_WIRE -/*! - * @brief Create an I2C device at a given address - * @param addr The 7-bit I2C address for the device - * @param theWire The I2C bus to use, defaults to &Wire - */ -Adafruit_I2CDevice::Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire) -{ - _wire = theWire; - _addr = addr; - _begun = false; - _i2c_bus_dev = RT_NULL; -} - -/*! - * @brief Initializes and does basic address detection - * @param addr_detect Whether we should attempt to detect the I2C address - * with a scan. 99% of sensors/devices don't mind but once in a while, they spaz - * on a scan! - * @return True if I2C initialized and a device with the addr found - */ -bool Adafruit_I2CDevice::begin(bool addr_detect) -{ - bool rst = true; - - _wire->begin(); - - if(addr_detect) - { - rst = detected(); - } - - if(rst == true) - { - _begun = true; - _i2c_bus_dev = _wire->_i2c_bus_dev; - return true; - } - else - { - return false; - } -} - -/*! - * @brief De-initialize device, turn off the Wire interface - */ -void Adafruit_I2CDevice::end(void) -{ - _i2c_bus_dev = RT_NULL; - _addr = 0x00; - _begun = false; -} - -/*! - * @brief Scans I2C for the address - note will give a false-positive - * if there's no pullups on I2C - * @return True if I2C initialized and a device with the addr found - */ -bool Adafruit_I2CDevice::detected(void) -{ - - return true; -} - -/*! - * @brief Write a buffer or two to the I2C device. Cannot be more than - * maxBufferSize() bytes. - * @param buffer Pointer to buffer of data to write. This is const to - * ensure the content of this buffer doesn't change. - * @param len Number of bytes from buffer to write - * @param prefix_buffer Pointer to optional array of data to write before - * buffer. Cannot be more than maxBufferSize() bytes. This is const to - * ensure the content of this buffer doesn't change. - * @param prefix_len Number of bytes from prefix buffer to write - * @param stop Whether to send an I2C STOP signal on write - * @return True if write was successful, otherwise false. - */ -bool Adafruit_I2CDevice::write(const uint8_t *buffer, size_t len, bool stop, - const uint8_t *prefix_buffer, - size_t prefix_len) -{ - rt_uint16_t flag = RT_NULL; - - if(stop == false) - { - flag |= RT_I2C_NO_STOP; - } - - rt_i2c_master_send(_i2c_bus_dev, _addr, RT_I2C_NO_STOP, prefix_buffer, prefix_len); - rt_i2c_master_send(_i2c_bus_dev, _addr, flag | RT_I2C_NO_START, buffer, len); - - return true; -} - -/*! - * @brief Read from I2C into a buffer from the I2C device. - * Cannot be more than maxBufferSize() bytes. - * @param buffer Pointer to buffer of data to read into - * @param len Number of bytes from buffer to read. - * @param stop Whether to send an I2C STOP signal on read - * @return True if read was successful, otherwise false. - */ -bool Adafruit_I2CDevice::read(uint8_t *buffer, size_t len, bool stop) -{ - rt_uint16_t flag = RT_NULL; - - if(stop == false) - { - flag |= RT_I2C_NO_STOP; - } - rt_i2c_master_recv(_i2c_bus_dev, _addr, flag, buffer, len); - return true; -} - -/*! - * @brief Write some data, then read some data from I2C into another buffer. - * Cannot be more than maxBufferSize() bytes. The buffers can point to - * same/overlapping locations. - * @param write_buffer Pointer to buffer of data to write from - * @param write_len Number of bytes from buffer to write. - * @param read_buffer Pointer to buffer of data to read into. - * @param read_len Number of bytes from buffer to read. - * @param stop Whether to send an I2C STOP signal between the write and read - * @return True if write & read was successful, otherwise false. - */ -bool Adafruit_I2CDevice::write_then_read(const uint8_t *write_buffer, - size_t write_len, uint8_t *read_buffer, - size_t read_len, bool stop) { - if (!write(write_buffer, write_len, stop)) { - return false; - } - - return read(read_buffer, read_len); -} - -/*! - * @brief Returns the 7-bit address of this device - * @return The 7-bit address of this device - */ -uint8_t Adafruit_I2CDevice::address(void) { return _addr; } - -/*! - * @brief Change the I2C clock speed to desired (relies on - * underlying Wire support! - * @param desiredclk The desired I2C SCL frequency - * @return True if this platform supports changing I2C speed. - * Not necessarily that the speed was achieved! - */ -bool Adafruit_I2CDevice::setSpeed(uint32_t desiredclk) { - (void)desiredclk; - return false; -} - -#endif /* RTDUINO_USING_WIRE */ diff --git a/libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_I2CDevice.h b/libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_I2CDevice.h deleted file mode 100644 index 1253df6..0000000 --- a/libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_I2CDevice.h +++ /dev/null @@ -1,45 +0,0 @@ -/* - * Copyright (c) 2021-2022, RTduino Development Team - * - * SPDX-License-Identifier: MIT - * - * Change Logs: - * Date Author Notes - * 2022-02-19 Meco Man port to RTduino - */ - -#ifndef Adafruit_I2CDevice_h -#define Adafruit_I2CDevice_h - -#include - -#ifdef RTDUINO_USING_WIRE -#include -#include "Wire.h" - -///< The class which defines how we will talk to this device over I2C -class Adafruit_I2CDevice -{ - private: - TwoWire *_wire; - uint8_t _addr; - bool _begun; - struct rt_i2c_bus_device *_i2c_bus_dev; - - public: - Adafruit_I2CDevice(uint8_t addr, TwoWire *theWire = &Wire); - uint8_t address(void); - bool begin(bool addr_detect = true); - void end(void); - bool detected(void); - bool read(uint8_t *buffer, size_t len, bool stop = true); - bool write(const uint8_t *buffer, size_t len, bool stop = true, - const uint8_t *prefix_buffer = NULL, size_t prefix_len = 0); - bool write_then_read(const uint8_t *write_buffer, size_t write_len, - uint8_t *read_buffer, size_t read_len, - bool stop = false); - bool setSpeed(uint32_t desiredclk); -}; - -#endif /* RTDUINO_USING_WIRE */ -#endif // Adafruit_I2CDevice_h diff --git a/libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_I2CRegister.h b/libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_I2CRegister.h deleted file mode 100644 index 5ecb31f..0000000 --- a/libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_I2CRegister.h +++ /dev/null @@ -1,23 +0,0 @@ -/* - * Copyright (c) 2021-2022, RTduino Development Team - * - * SPDX-License-Identifier: MIT - * - * Change Logs: - * Date Author Notes - * 2022-02-19 Meco Man port to RTduino - */ - -#ifndef _ADAFRUIT_I2C_REGISTER_H_ -#define _ADAFRUIT_I2C_REGISTER_H_ - -#include - -#ifdef RTDUINO_USING_WIRE -#include - -typedef Adafruit_BusIO_Register Adafruit_I2CRegister; -typedef Adafruit_BusIO_RegisterBits Adafruit_I2CRegisterBits; - -#endif /* RTDUINO_USING_WIRE */ -#endif /* _ADAFRUIT_I2C_REGISTER_H_ */ diff --git a/libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_SPIDevice.cpp b/libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_SPIDevice.cpp deleted file mode 100644 index 7a58354..0000000 --- a/libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_SPIDevice.cpp +++ /dev/null @@ -1,505 +0,0 @@ -/* - * Copyright (c) 2021-2022, RTduino Development Team - * - * SPDX-License-Identifier: MIT - * - * Change Logs: - * Date Author Notes - * 2022-02-19 Meco Man port to RTduino - */ - -#include "Adafruit_SPIDevice.h" - -#ifdef RTDUINO_USING_SPI -#if !defined(SPI_INTERFACES_COUNT) || \ - (defined(SPI_INTERFACES_COUNT) && (SPI_INTERFACES_COUNT > 0)) - -//#define DEBUG_SERIAL Serial - -/*! - * @brief Create an SPI device with the given CS pin and settings - * @param cspin The arduino pin number to use for chip select - * @param freq The SPI clock frequency to use, defaults to 1MHz - * @param dataOrder The SPI data order to use for bits within each byte, - * defaults to SPI_BITORDER_MSBFIRST - * @param dataMode The SPI mode to use, defaults to SPI_MODE0 - * @param theSPI The SPI bus to use, defaults to &theSPI - */ -Adafruit_SPIDevice::Adafruit_SPIDevice(int8_t cspin, uint32_t freq, - BusIOBitOrder dataOrder, - uint8_t dataMode, SPIClass *theSPI) { - _cs = cspin; - _sck = _mosi = _miso = -1; - _spi = theSPI; - _begun = false; - _spiSetting = new SPISettings(freq, dataOrder, dataMode); - _freq = freq; - _dataOrder = dataOrder; - _dataMode = dataMode; -} - -/*! - * @brief Create an SPI device with the given CS pin and settings - * @param cspin The arduino pin number to use for chip select - * @param sckpin The arduino pin number to use for SCK - * @param misopin The arduino pin number to use for MISO, set to -1 if not - * used - * @param mosipin The arduino pin number to use for MOSI, set to -1 if not - * used - * @param freq The SPI clock frequency to use, defaults to 1MHz - * @param dataOrder The SPI data order to use for bits within each byte, - * defaults to SPI_BITORDER_MSBFIRST - * @param dataMode The SPI mode to use, defaults to SPI_MODE0 - */ -Adafruit_SPIDevice::Adafruit_SPIDevice(int8_t cspin, int8_t sckpin, - int8_t misopin, int8_t mosipin, - uint32_t freq, BusIOBitOrder dataOrder, - uint8_t dataMode) { - _cs = cspin; - _sck = sckpin; - _miso = misopin; - _mosi = mosipin; - -#ifdef BUSIO_USE_FAST_PINIO - csPort = (BusIO_PortReg *)portOutputRegister(digitalPinToPort(cspin)); - csPinMask = digitalPinToBitMask(cspin); - if (mosipin != -1) { - mosiPort = (BusIO_PortReg *)portOutputRegister(digitalPinToPort(mosipin)); - mosiPinMask = digitalPinToBitMask(mosipin); - } - if (misopin != -1) { - misoPort = (BusIO_PortReg *)portInputRegister(digitalPinToPort(misopin)); - misoPinMask = digitalPinToBitMask(misopin); - } - clkPort = (BusIO_PortReg *)portOutputRegister(digitalPinToPort(sckpin)); - clkPinMask = digitalPinToBitMask(sckpin); -#endif - - _freq = freq; - _dataOrder = dataOrder; - _dataMode = dataMode; - _begun = false; - _spiSetting = new SPISettings(freq, dataOrder, dataMode); - _spi = NULL; -} - -/*! - * @brief Release memory allocated in constructors - */ -Adafruit_SPIDevice::~Adafruit_SPIDevice() { delete _spiSetting; } - -/*! - * @brief Initializes SPI bus and sets CS pin high - * @return Always returns true because there's no way to test success of SPI - * init - */ -bool Adafruit_SPIDevice::begin(void) { - if (_cs != -1) { - pinMode(_cs, OUTPUT); - digitalWrite(_cs, HIGH); - } - - if (_spi) { // hardware SPI - _spi->begin(); - } else { - pinMode(_sck, OUTPUT); - - if ((_dataMode == SPI_MODE0) || (_dataMode == SPI_MODE1)) { - // idle low on mode 0 and 1 - digitalWrite(_sck, LOW); - } else { - // idle high on mode 2 or 3 - digitalWrite(_sck, HIGH); - } - if (_mosi != -1) { - pinMode(_mosi, OUTPUT); - digitalWrite(_mosi, HIGH); - } - if (_miso != -1) { - pinMode(_miso, INPUT); - } - } - - _begun = true; - return true; -} - -/*! - * @brief Transfer (send/receive) a buffer over hard/soft SPI, without - * transaction management - * @param buffer The buffer to send and receive at the same time - * @param len The number of bytes to transfer - */ -void Adafruit_SPIDevice::transfer(uint8_t *buffer, size_t len) { - if (_spi) { - // hardware SPI is easy - -#if defined(SPARK) - _spi->transfer(buffer, buffer, len, NULL); -#elif defined(STM32) - for (size_t i = 0; i < len; i++) { - _spi->transfer(buffer[i]); - } -#else - _spi->transfer(buffer, len); -#endif - return; - } - - uint8_t startbit; - if (_dataOrder == SPI_BITORDER_LSBFIRST) { - startbit = 0x1; - } else { - startbit = 0x80; - } - - bool towrite, lastmosi = !(buffer[0] & startbit); - uint8_t bitdelay_us = (1000000 / _freq) / 2; - - // for softSPI we'll do it by hand - for (size_t i = 0; i < len; i++) { - // software SPI - uint8_t reply = 0; - uint8_t send = buffer[i]; - - /* - Serial.print("\tSending software SPI byte 0x"); - Serial.print(send, HEX); - Serial.print(" -> 0x"); - */ - - // Serial.print(send, HEX); - for (uint8_t b = startbit; b != 0; - b = (_dataOrder == SPI_BITORDER_LSBFIRST) ? b << 1 : b >> 1) { - - if (bitdelay_us) { - delayMicroseconds(bitdelay_us); - } - - if (_dataMode == SPI_MODE0 || _dataMode == SPI_MODE2) { - towrite = send & b; - if ((_mosi != -1) && (lastmosi != towrite)) { -#ifdef BUSIO_USE_FAST_PINIO - if (towrite) - *mosiPort |= mosiPinMask; - else - *mosiPort &= ~mosiPinMask; -#else - digitalWrite(_mosi, towrite); -#endif - lastmosi = towrite; - } - -#ifdef BUSIO_USE_FAST_PINIO - *clkPort |= clkPinMask; // Clock high -#else - digitalWrite(_sck, HIGH); -#endif - - if (bitdelay_us) { - delayMicroseconds(bitdelay_us); - } - - if (_miso != -1) { -#ifdef BUSIO_USE_FAST_PINIO - if (*misoPort & misoPinMask) { -#else - if (digitalRead(_miso)) { -#endif - reply |= b; - } - } - -#ifdef BUSIO_USE_FAST_PINIO - *clkPort &= ~clkPinMask; // Clock low -#else - digitalWrite(_sck, LOW); -#endif - } else { // if (_dataMode == SPI_MODE1 || _dataMode == SPI_MODE3) - -#ifdef BUSIO_USE_FAST_PINIO - *clkPort |= clkPinMask; // Clock high -#else - digitalWrite(_sck, HIGH); -#endif - - if (bitdelay_us) { - delayMicroseconds(bitdelay_us); - } - - if (_mosi != -1) { -#ifdef BUSIO_USE_FAST_PINIO - if (send & b) - *mosiPort |= mosiPinMask; - else - *mosiPort &= ~mosiPinMask; -#else - digitalWrite(_mosi, send & b); -#endif - } - -#ifdef BUSIO_USE_FAST_PINIO - *clkPort &= ~clkPinMask; // Clock low -#else - digitalWrite(_sck, LOW); -#endif - - if (_miso != -1) { -#ifdef BUSIO_USE_FAST_PINIO - if (*misoPort & misoPinMask) { -#else - if (digitalRead(_miso)) { -#endif - reply |= b; - } - } - } - if (_miso != -1) { - buffer[i] = reply; - } - } - } - return; -} - -/*! - * @brief Transfer (send/receive) one byte over hard/soft SPI, without - * transaction management - * @param send The byte to send - * @return The byte received while transmitting - */ -uint8_t Adafruit_SPIDevice::transfer(uint8_t send) { - uint8_t data = send; - transfer(&data, 1); - return data; -} - -/*! - * @brief Manually begin a transaction (calls beginTransaction if hardware - * SPI) - */ -void Adafruit_SPIDevice::beginTransaction(void) { - if (_spi) { - _spi->beginTransaction(*_spiSetting); - } -} - -/*! - * @brief Manually end a transaction (calls endTransaction if hardware SPI) - */ -void Adafruit_SPIDevice::endTransaction(void) { - if (_spi) { - _spi->endTransaction(); - } -} - -/*! - * @brief Assert/Deassert the CS pin if it is defined - * @param value The state the CS is set to - */ -void Adafruit_SPIDevice::setChipSelect(int value) { - if (_cs != -1) { - digitalWrite(_cs, value); - } -} - -/*! - * @brief Write a buffer or two to the SPI device, with transaction - * management. - * @brief Manually begin a transaction (calls beginTransaction if hardware - * SPI) with asserting the CS pin - */ -void Adafruit_SPIDevice::beginTransactionWithAssertingCS() { - beginTransaction(); - setChipSelect(LOW); -} - -/*! - * @brief Manually end a transaction (calls endTransaction if hardware SPI) - * with deasserting the CS pin - */ -void Adafruit_SPIDevice::endTransactionWithDeassertingCS() { - setChipSelect(HIGH); - endTransaction(); -} - -/*! - * @brief Write a buffer or two to the SPI device, with transaction - * management. - * @param buffer Pointer to buffer of data to write - * @param len Number of bytes from buffer to write - * @param prefix_buffer Pointer to optional array of data to write before - * buffer. - * @param prefix_len Number of bytes from prefix buffer to write - * @return Always returns true because there's no way to test success of SPI - * writes - */ -bool Adafruit_SPIDevice::write(const uint8_t *buffer, size_t len, - const uint8_t *prefix_buffer, - size_t prefix_len) { - beginTransactionWithAssertingCS(); - - // do the writing -#if defined(ARDUINO_ARCH_ESP32) - if (_spi) { - if (prefix_len > 0) { - _spi->transferBytes(prefix_buffer, NULL, prefix_len); - } - if (len > 0) { - _spi->transferBytes(buffer, NULL, len); - } - } else -#endif - { - for (size_t i = 0; i < prefix_len; i++) { - transfer(prefix_buffer[i]); - } - for (size_t i = 0; i < len; i++) { - transfer(buffer[i]); - } - } - endTransactionWithDeassertingCS(); - -#ifdef DEBUG_SERIAL - DEBUG_SERIAL.print(F("\tSPIDevice Wrote: ")); - if ((prefix_len != 0) && (prefix_buffer != NULL)) { - for (uint16_t i = 0; i < prefix_len; i++) { - DEBUG_SERIAL.print(F("0x")); - DEBUG_SERIAL.print(prefix_buffer[i], HEX); - DEBUG_SERIAL.print(F(", ")); - } - } - for (uint16_t i = 0; i < len; i++) { - DEBUG_SERIAL.print(F("0x")); - DEBUG_SERIAL.print(buffer[i], HEX); - DEBUG_SERIAL.print(F(", ")); - if (i % 32 == 31) { - DEBUG_SERIAL.println(); - } - } - DEBUG_SERIAL.println(); -#endif - - return true; -} - -/*! - * @brief Read from SPI into a buffer from the SPI device, with transaction - * management. - * @param buffer Pointer to buffer of data to read into - * @param len Number of bytes from buffer to read. - * @param sendvalue The 8-bits of data to write when doing the data read, - * defaults to 0xFF - * @return Always returns true because there's no way to test success of SPI - * writes - */ -bool Adafruit_SPIDevice::read(uint8_t *buffer, size_t len, uint8_t sendvalue) { - memset(buffer, sendvalue, len); // clear out existing buffer - - beginTransactionWithAssertingCS(); - transfer(buffer, len); - endTransactionWithDeassertingCS(); - -#ifdef DEBUG_SERIAL - DEBUG_SERIAL.print(F("\tSPIDevice Read: ")); - for (uint16_t i = 0; i < len; i++) { - DEBUG_SERIAL.print(F("0x")); - DEBUG_SERIAL.print(buffer[i], HEX); - DEBUG_SERIAL.print(F(", ")); - if (len % 32 == 31) { - DEBUG_SERIAL.println(); - } - } - DEBUG_SERIAL.println(); -#endif - - return true; -} - -/*! - * @brief Write some data, then read some data from SPI into another buffer, - * with transaction management. The buffers can point to same/overlapping - * locations. This does not transmit-receive at the same time! - * @param write_buffer Pointer to buffer of data to write from - * @param write_len Number of bytes from buffer to write. - * @param read_buffer Pointer to buffer of data to read into. - * @param read_len Number of bytes from buffer to read. - * @param sendvalue The 8-bits of data to write when doing the data read, - * defaults to 0xFF - * @return Always returns true because there's no way to test success of SPI - * writes - */ -bool Adafruit_SPIDevice::write_then_read(const uint8_t *write_buffer, - size_t write_len, uint8_t *read_buffer, - size_t read_len, uint8_t sendvalue) { - beginTransactionWithAssertingCS(); - // do the writing -#if defined(ARDUINO_ARCH_ESP32) - if (_spi) { - if (write_len > 0) { - _spi->transferBytes(write_buffer, NULL, write_len); - } - } else -#endif - { - for (size_t i = 0; i < write_len; i++) { - transfer(write_buffer[i]); - } - } - -#ifdef DEBUG_SERIAL - DEBUG_SERIAL.print(F("\tSPIDevice Wrote: ")); - for (uint16_t i = 0; i < write_len; i++) { - DEBUG_SERIAL.print(F("0x")); - DEBUG_SERIAL.print(write_buffer[i], HEX); - DEBUG_SERIAL.print(F(", ")); - if (write_len % 32 == 31) { - DEBUG_SERIAL.println(); - } - } - DEBUG_SERIAL.println(); -#endif - - // do the reading - for (size_t i = 0; i < read_len; i++) { - read_buffer[i] = transfer(sendvalue); - } - -#ifdef DEBUG_SERIAL - DEBUG_SERIAL.print(F("\tSPIDevice Read: ")); - for (uint16_t i = 0; i < read_len; i++) { - DEBUG_SERIAL.print(F("0x")); - DEBUG_SERIAL.print(read_buffer[i], HEX); - DEBUG_SERIAL.print(F(", ")); - if (read_len % 32 == 31) { - DEBUG_SERIAL.println(); - } - } - DEBUG_SERIAL.println(); -#endif - - endTransactionWithDeassertingCS(); - - return true; -} - -/*! - * @brief Write some data and read some data at the same time from SPI - * into the same buffer, with transaction management. This is basicaly a wrapper - * for transfer() with CS-pin and transaction management. This /does/ - * transmit-receive at the same time! - * @param buffer Pointer to buffer of data to write/read to/from - * @param len Number of bytes from buffer to write/read. - * @return Always returns true because there's no way to test success of SPI - * writes - */ -bool Adafruit_SPIDevice::write_and_read(uint8_t *buffer, size_t len) { - beginTransactionWithAssertingCS(); - transfer(buffer, len); - endTransactionWithDeassertingCS(); - - return true; -} - -#endif // SPI exists -#endif /* RTDUINO_USING_SPI */ diff --git a/libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_SPIDevice.h b/libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_SPIDevice.h deleted file mode 100644 index 7d0901f..0000000 --- a/libraries/fork/Adafruit/Adafruit_BusIO/Adafruit_SPIDevice.h +++ /dev/null @@ -1,74 +0,0 @@ -/* - * Copyright (c) 2021-2022, RTduino Development Team - * - * SPDX-License-Identifier: MIT - * - * Change Logs: - * Date Author Notes - * 2022-02-19 Meco Man port to RTduino - */ - -#ifndef Adafruit_SPIDevice_h -#define Adafruit_SPIDevice_h - -#include - -#ifdef RTDUINO_USING_SPI -#if !defined(SPI_INTERFACES_COUNT) || \ - (defined(SPI_INTERFACES_COUNT) && (SPI_INTERFACES_COUNT > 0)) - -#include - -typedef enum _BitOrder { - SPI_BITORDER_MSBFIRST = MSBFIRST, - SPI_BITORDER_LSBFIRST = LSBFIRST, -} BusIOBitOrder; - -/**! The class which defines how we will talk to this device over SPI **/ -class Adafruit_SPIDevice { -public: - Adafruit_SPIDevice(int8_t cspin, uint32_t freq = 1000000, - BusIOBitOrder dataOrder = SPI_BITORDER_MSBFIRST, - uint8_t dataMode = SPI_MODE0, SPIClass *theSPI = &SPI); - - Adafruit_SPIDevice(int8_t cspin, int8_t sck, int8_t miso, int8_t mosi, - uint32_t freq = 1000000, - BusIOBitOrder dataOrder = SPI_BITORDER_MSBFIRST, - uint8_t dataMode = SPI_MODE0); - ~Adafruit_SPIDevice(); - - bool begin(void); - bool read(uint8_t *buffer, size_t len, uint8_t sendvalue = 0xFF); - bool write(const uint8_t *buffer, size_t len, - const uint8_t *prefix_buffer = NULL, size_t prefix_len = 0); - bool write_then_read(const uint8_t *write_buffer, size_t write_len, - uint8_t *read_buffer, size_t read_len, - uint8_t sendvalue = 0xFF); - bool write_and_read(uint8_t *buffer, size_t len); - - uint8_t transfer(uint8_t send); - void transfer(uint8_t *buffer, size_t len); - void beginTransaction(void); - void endTransaction(void); - void beginTransactionWithAssertingCS(); - void endTransactionWithDeassertingCS(); - -private: - SPIClass *_spi; - SPISettings *_spiSetting; - uint32_t _freq; - BusIOBitOrder _dataOrder; - uint8_t _dataMode; - void setChipSelect(int value); - - int8_t _cs, _sck, _mosi, _miso; -#ifdef BUSIO_USE_FAST_PINIO - BusIO_PortReg *mosiPort, *clkPort, *misoPort, *csPort; - BusIO_PortMask mosiPinMask, misoPinMask, clkPinMask, csPinMask; -#endif - bool _begun; -}; - -#endif // has SPI defined -#endif /* RTDUINO_USING_SPI */ -#endif // Adafruit_SPIDevice_h diff --git a/libraries/fork/Adafruit/Adafruit_BusIO/LICENSE b/libraries/fork/Adafruit/Adafruit_BusIO/LICENSE deleted file mode 100644 index 860e3e2..0000000 --- a/libraries/fork/Adafruit/Adafruit_BusIO/LICENSE +++ /dev/null @@ -1,21 +0,0 @@ -The MIT License (MIT) - -Copyright (c) 2017 Adafruit Industries - -Permission is hereby granted, free of charge, to any person obtaining a copy -of this software and associated documentation files (the "Software"), to deal -in the Software without restriction, including without limitation the rights -to use, copy, modify, merge, publish, distribute, sublicense, and/or sell -copies of the Software, and to permit persons to whom the Software is -furnished to do so, subject to the following conditions: - -The above copyright notice and this permission notice shall be included in all -copies or substantial portions of the Software. - -THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR -IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, -FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE -AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER -LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, -OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE -SOFTWARE. \ No newline at end of file diff --git a/libraries/fork/Adafruit/Adafruit_BusIO/README.md b/libraries/fork/Adafruit/Adafruit_BusIO/README.md deleted file mode 100644 index 817ab44..0000000 --- a/libraries/fork/Adafruit/Adafruit_BusIO/README.md +++ /dev/null @@ -1,9 +0,0 @@ -# Adafruit Bus IO Library - -https://github.com/adafruit/Adafruit_BusIO (v1.11.6) - -This is a helper library to abstract away I2C & SPI transactions and registers - -Adafruit invests time and resources providing this open source code, please support Adafruit and open-source hardware by purchasing products from Adafruit! - -MIT license, all text above must be included in any redistribution diff --git a/libraries/fork/Adafruit/Adafruit_BusIO/SConscript b/libraries/fork/Adafruit/Adafruit_BusIO/SConscript deleted file mode 100644 index a4073bd..0000000 --- a/libraries/fork/Adafruit/Adafruit_BusIO/SConscript +++ /dev/null @@ -1,13 +0,0 @@ -from building import * - -cwd = GetCurrentDir() -src = [] -inc = [] - -if GetDepend('RTDUINO_USING_WIRE') or GetDepend('RTDUINO_USING_SPI'): - src += Glob('*.cpp') - inc += [cwd] - -group = DefineGroup('Arduino-Adafruit', src, depend = ['PKG_USING_RTDUINO', 'RTDUINO_USING_ADAFRUIT'], CPPPATH = inc) - -Return('group') diff --git a/libraries/fork/Adafruit/Adafruit_Sensor/Adafruit_Sensor.cpp b/libraries/fork/Adafruit/Adafruit_Sensor/Adafruit_Sensor.cpp deleted file mode 100644 index adb5b58..0000000 --- a/libraries/fork/Adafruit/Adafruit_Sensor/Adafruit_Sensor.cpp +++ /dev/null @@ -1,88 +0,0 @@ -/* - * Copyright (c) 2021-2022, RTduino Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2022-02-19 Meco Man port to RTduino - */ - -#include "Adafruit_Sensor.h" - -/**************************************************************************/ -/*! - @brief Prints sensor information to serial console -*/ -/**************************************************************************/ -void Adafruit_Sensor::printSensorDetails(void) { - sensor_t sensor; - getSensor(&sensor); - Serial.println(F("------------------------------------")); - Serial.print(F("Sensor: ")); - Serial.println(sensor.name); - Serial.print(F("Type: ")); - switch ((sensors_type_t)sensor.type) { - case SENSOR_TYPE_ACCELEROMETER: - Serial.print(F("Acceleration (m/s2)")); - break; - case SENSOR_TYPE_MAGNETIC_FIELD: - Serial.print(F("Magnetic (uT)")); - break; - case SENSOR_TYPE_ORIENTATION: - Serial.print(F("Orientation (degrees)")); - break; - case SENSOR_TYPE_GYROSCOPE: - Serial.print(F("Gyroscopic (rad/s)")); - break; - case SENSOR_TYPE_LIGHT: - Serial.print(F("Light (lux)")); - break; - case SENSOR_TYPE_PRESSURE: - Serial.print(F("Pressure (hPa)")); - break; - case SENSOR_TYPE_PROXIMITY: - Serial.print(F("Distance (cm)")); - break; - case SENSOR_TYPE_GRAVITY: - Serial.print(F("Gravity (m/s2)")); - break; - case SENSOR_TYPE_LINEAR_ACCELERATION: - Serial.print(F("Linear Acceleration (m/s2)")); - break; - case SENSOR_TYPE_ROTATION_VECTOR: - Serial.print(F("Rotation vector")); - break; - case SENSOR_TYPE_RELATIVE_HUMIDITY: - Serial.print(F("Relative Humidity (%)")); - break; - case SENSOR_TYPE_AMBIENT_TEMPERATURE: - Serial.print(F("Ambient Temp (C)")); - break; - case SENSOR_TYPE_OBJECT_TEMPERATURE: - Serial.print(F("Object Temp (C)")); - break; - case SENSOR_TYPE_VOLTAGE: - Serial.print(F("Voltage (V)")); - break; - case SENSOR_TYPE_CURRENT: - Serial.print(F("Current (mA)")); - break; - case SENSOR_TYPE_COLOR: - Serial.print(F("Color (RGBA)")); - break; - } - - Serial.println(); - Serial.print(F("Driver Ver: ")); - Serial.println(sensor.version); - Serial.print(F("Unique ID: ")); - Serial.println(sensor.sensor_id); - Serial.print(F("Min Value: ")); - Serial.println(sensor.min_value); - Serial.print(F("Max Value: ")); - Serial.println(sensor.max_value); - Serial.print(F("Resolution: ")); - Serial.println(sensor.resolution); - Serial.println(F("------------------------------------\n")); -} diff --git a/libraries/fork/Adafruit/Adafruit_Sensor/Adafruit_Sensor.h b/libraries/fork/Adafruit/Adafruit_Sensor/Adafruit_Sensor.h deleted file mode 100644 index e7807e6..0000000 --- a/libraries/fork/Adafruit/Adafruit_Sensor/Adafruit_Sensor.h +++ /dev/null @@ -1,204 +0,0 @@ -/* - * Copyright (c) 2021-2022, RTduino Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2022-02-19 Meco Man port to RTduino - */ - -/* - * Copyright (C) 2008 The Android Open Source Project - * - * Licensed under the Apache License, Version 2.0 (the "License"); - * you may not use this file except in compliance with the License. - * You may obtain a copy of the License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software< /span> - * distributed under the License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the License for the specific language governing permissions and - * limitations under the License. - */ - -/* Update by K. Townsend (Adafruit Industries) for lighter typedefs, and - * extended sensor support to include color, voltage and current */ - -#ifndef _ADAFRUIT_SENSOR_H -#define _ADAFRUIT_SENSOR_H - -#ifndef ARDUINO -#include -#elif ARDUINO >= 100 -#include "Arduino.h" -#include "Print.h" -#else -#include "WProgram.h" -#endif - -/* Constants */ -#define SENSORS_GRAVITY_EARTH (9.80665F) /**< Earth's gravity in m/s^2 */ -#define SENSORS_GRAVITY_MOON (1.6F) /**< The moon's gravity in m/s^2 */ -#define SENSORS_GRAVITY_SUN (275.0F) /**< The sun's gravity in m/s^2 */ -#define SENSORS_GRAVITY_STANDARD (SENSORS_GRAVITY_EARTH) -#define SENSORS_MAGFIELD_EARTH_MAX \ - (60.0F) /**< Maximum magnetic field on Earth's surface */ -#define SENSORS_MAGFIELD_EARTH_MIN \ - (30.0F) /**< Minimum magnetic field on Earth's surface */ -#define SENSORS_PRESSURE_SEALEVELHPA \ - (1013.25F) /**< Average sea level pressure is 1013.25 hPa */ -#define SENSORS_DPS_TO_RADS \ - (0.017453293F) /**< Degrees/s to rad/s multiplier \ - */ -#define SENSORS_RADS_TO_DPS \ - (57.29577793F) /**< Rad/s to degrees/s multiplier */ -#define SENSORS_GAUSS_TO_MICROTESLA \ - (100) /**< Gauss to micro-Tesla multiplier */ - -/** Sensor types */ -typedef enum { - SENSOR_TYPE_ACCELEROMETER = (1), /**< Gravity + linear acceleration */ - SENSOR_TYPE_MAGNETIC_FIELD = (2), - SENSOR_TYPE_ORIENTATION = (3), - SENSOR_TYPE_GYROSCOPE = (4), - SENSOR_TYPE_LIGHT = (5), - SENSOR_TYPE_PRESSURE = (6), - SENSOR_TYPE_PROXIMITY = (8), - SENSOR_TYPE_GRAVITY = (9), - SENSOR_TYPE_LINEAR_ACCELERATION = - (10), /**< Acceleration not including gravity */ - SENSOR_TYPE_ROTATION_VECTOR = (11), - SENSOR_TYPE_RELATIVE_HUMIDITY = (12), - SENSOR_TYPE_AMBIENT_TEMPERATURE = (13), - SENSOR_TYPE_OBJECT_TEMPERATURE = (14), - SENSOR_TYPE_VOLTAGE = (15), - SENSOR_TYPE_CURRENT = (16), - SENSOR_TYPE_COLOR = (17) -} sensors_type_t; - -#ifdef __ARMCC_VERSION -#pragma anon_unions -#endif -/** struct sensors_vec_s is used to return a vector in a common format. */ -typedef struct { - union { - float v[3]; ///< 3D vector elements - struct { - float x; ///< X component of vector - float y; ///< Y component of vector - float z; ///< Z component of vector - }; ///< Struct for holding XYZ component - /* Orientation sensors */ - struct { - float roll; /**< Rotation around the longitudinal axis (the plane body, 'X - axis'). Roll is positive and increasing when moving - downward. -90 degrees <= roll <= 90 degrees */ - float pitch; /**< Rotation around the lateral axis (the wing span, 'Y - axis'). Pitch is positive and increasing when moving - upwards. -180 degrees <= pitch <= 180 degrees) */ - float heading; /**< Angle between the longitudinal axis (the plane body) - and magnetic north, measured clockwise when viewing from - the top of the device. 0-359 degrees */ - }; ///< Struct for holding roll/pitch/heading - }; ///< Union that can hold 3D vector array, XYZ components or - ///< roll/pitch/heading - int8_t status; ///< Status byte - uint8_t reserved[3]; ///< Reserved -} sensors_vec_t; - -/** struct sensors_color_s is used to return color data in a common format. */ -typedef struct { - union { - float c[3]; ///< Raw 3-element data - /* RGB color space */ - struct { - float r; /**< Red component */ - float g; /**< Green component */ - float b; /**< Blue component */ - }; ///< RGB data in floating point notation - }; ///< Union of various ways to describe RGB colorspace - uint32_t rgba; /**< 24-bit RGBA value */ -} sensors_color_t; - -/* Sensor event (36 bytes) */ -/** struct sensor_event_s is used to provide a single sensor event in a common - * format. */ -typedef struct { - int32_t version; /**< must be sizeof(struct sensors_event_t) */ - int32_t sensor_id; /**< unique sensor identifier */ - int32_t type; /**< sensor type */ - int32_t reserved0; /**< reserved */ - int32_t timestamp; /**< time is in milliseconds */ - union { - float data[4]; ///< Raw data - sensors_vec_t acceleration; /**< acceleration values are in meter per second - per second (m/s^2) */ - sensors_vec_t - magnetic; /**< magnetic vector values are in micro-Tesla (uT) */ - sensors_vec_t orientation; /**< orientation values are in degrees */ - sensors_vec_t gyro; /**< gyroscope values are in rad/s */ - float temperature; /**< temperature is in degrees centigrade (Celsius) */ - float distance; /**< distance in centimeters */ - float light; /**< light in SI lux units */ - float pressure; /**< pressure in hectopascal (hPa) */ - float relative_humidity; /**< relative humidity in percent */ - float current; /**< current in milliamps (mA) */ - float voltage; /**< voltage in volts (V) */ - sensors_color_t color; /**< color in RGB component values */ - }; ///< Union for the wide ranges of data we can carry -} sensors_event_t; - -/* Sensor details (40 bytes) */ -/** struct sensor_s is used to describe basic information about a specific - * sensor. */ -typedef struct { - char name[12]; /**< sensor name */ - int32_t version; /**< version of the hardware + driver */ - int32_t sensor_id; /**< unique sensor identifier */ - int32_t type; /**< this sensor's type (ex. SENSOR_TYPE_LIGHT) */ - float max_value; /**< maximum value of this sensor's value in SI units */ - float min_value; /**< minimum value of this sensor's value in SI units */ - float resolution; /**< smallest difference between two values reported by this - sensor */ - int32_t min_delay; /**< min delay in microseconds between events. zero = not a - constant rate */ -} sensor_t; -#ifdef __ARMCC_VERSION -#pragma no_anon_unions -#endif - -/** @brief Common sensor interface to unify various sensors. - * Intentionally modeled after sensors.h in the Android API: - * https://github.com/android/platform_hardware_libhardware/blob/master/include/hardware/sensors.h - */ -class Adafruit_Sensor { -public: - // Constructor(s) - Adafruit_Sensor() {} - virtual ~Adafruit_Sensor() {} - - // These must be defined by the subclass - - /*! @brief Whether we should automatically change the range (if possible) for - higher precision - @param enabled True if we will try to autorange */ - virtual void enableAutoRange(bool enabled) { - (void)enabled; /* suppress unused warning */ - }; - - /*! @brief Get the latest sensor event - @returns True if able to fetch an event */ - virtual bool getEvent(sensors_event_t *) = 0; - /*! @brief Get info about the sensor itself */ - virtual void getSensor(sensor_t *) = 0; - - void printSensorDetails(void); - -private: - bool _autoRange; -}; - -#endif diff --git a/libraries/fork/Adafruit/Adafruit_Sensor/LICENSE.txt b/libraries/fork/Adafruit/Adafruit_Sensor/LICENSE.txt deleted file mode 100644 index d645695..0000000 --- a/libraries/fork/Adafruit/Adafruit_Sensor/LICENSE.txt +++ /dev/null @@ -1,202 +0,0 @@ - - Apache License - Version 2.0, January 2004 - http://www.apache.org/licenses/ - - TERMS AND CONDITIONS FOR USE, REPRODUCTION, AND DISTRIBUTION - - 1. Definitions. - - "License" shall mean the terms and conditions for use, reproduction, - and distribution as defined by Sections 1 through 9 of this document. - - "Licensor" shall mean the copyright owner or entity authorized by - the copyright owner that is granting the License. - - "Legal Entity" shall mean the union of the acting entity and all - other entities that control, are controlled by, or are under common - control with that entity. For the purposes of this definition, - "control" means (i) the power, direct or indirect, to cause the - direction or management of such entity, whether by contract or - otherwise, or (ii) ownership of fifty percent (50%) or more of the - outstanding shares, or (iii) beneficial ownership of such entity. - - "You" (or "Your") shall mean an individual or Legal Entity - exercising permissions granted by this License. - - "Source" form shall mean the preferred form for making modifications, - including but not limited to software source code, documentation - source, and configuration files. - - "Object" form shall mean any form resulting from mechanical - transformation or translation of a Source form, including but - not limited to compiled object code, generated documentation, - and conversions to other media types. - - "Work" shall mean the work of authorship, whether in Source or - Object form, made available under the License, as indicated by a - copyright notice that is included in or attached to the work - (an example is provided in the Appendix below). - - "Derivative Works" shall mean any work, whether in Source or Object - form, that is based on (or derived from) the Work and for which the - editorial revisions, annotations, elaborations, or other modifications - represent, as a whole, an original work of authorship. For the purposes - of this License, Derivative Works shall not include works that remain - separable from, or merely link (or bind by name) to the interfaces of, - the Work and Derivative Works thereof. - - "Contribution" shall mean any work of authorship, including - the original version of the Work and any modifications or additions - to that Work or Derivative Works thereof, that is intentionally - submitted to Licensor for inclusion in the Work by the copyright owner - or by an individual or Legal Entity authorized to submit on behalf of - the copyright owner. For the purposes of this definition, "submitted" - means any form of electronic, verbal, or written communication sent - to the Licensor or its representatives, including but not limited to - communication on electronic mailing lists, source code control systems, - and issue tracking systems that are managed by, or on behalf of, the - Licensor for the purpose of discussing and improving the Work, but - excluding communication that is conspicuously marked or otherwise - designated in writing by the copyright owner as "Not a Contribution." - - "Contributor" shall mean Licensor and any individual or Legal Entity - on behalf of whom a Contribution has been received by Licensor and - subsequently incorporated within the Work. - - 2. Grant of Copyright License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - copyright license to reproduce, prepare Derivative Works of, - publicly display, publicly perform, sublicense, and distribute the - Work and such Derivative Works in Source or Object form. - - 3. Grant of Patent License. Subject to the terms and conditions of - this License, each Contributor hereby grants to You a perpetual, - worldwide, non-exclusive, no-charge, royalty-free, irrevocable - (except as stated in this section) patent license to make, have made, - use, offer to sell, sell, import, and otherwise transfer the Work, - where such license applies only to those patent claims licensable - by such Contributor that are necessarily infringed by their - Contribution(s) alone or by combination of their Contribution(s) - with the Work to which such Contribution(s) was submitted. If You - institute patent litigation against any entity (including a - cross-claim or counterclaim in a lawsuit) alleging that the Work - or a Contribution incorporated within the Work constitutes direct - or contributory patent infringement, then any patent licenses - granted to You under this License for that Work shall terminate - as of the date such litigation is filed. - - 4. Redistribution. You may reproduce and distribute copies of the - Work or Derivative Works thereof in any medium, with or without - modifications, and in Source or Object form, provided that You - meet the following conditions: - - (a) You must give any other recipients of the Work or - Derivative Works a copy of this License; and - - (b) You must cause any modified files to carry prominent notices - stating that You changed the files; and - - (c) You must retain, in the Source form of any Derivative Works - that You distribute, all copyright, patent, trademark, and - attribution notices from the Source form of the Work, - excluding those notices that do not pertain to any part of - the Derivative Works; and - - (d) If the Work includes a "NOTICE" text file as part of its - distribution, then any Derivative Works that You distribute must - include a readable copy of the attribution notices contained - within such NOTICE file, excluding those notices that do not - pertain to any part of the Derivative Works, in at least one - of the following places: within a NOTICE text file distributed - as part of the Derivative Works; within the Source form or - documentation, if provided along with the Derivative Works; or, - within a display generated by the Derivative Works, if and - wherever such third-party notices normally appear. The contents - of the NOTICE file are for informational purposes only and - do not modify the License. You may add Your own attribution - notices within Derivative Works that You distribute, alongside - or as an addendum to the NOTICE text from the Work, provided - that such additional attribution notices cannot be construed - as modifying the License. - - You may add Your own copyright statement to Your modifications and - may provide additional or different license terms and conditions - for use, reproduction, or distribution of Your modifications, or - for any such Derivative Works as a whole, provided Your use, - reproduction, and distribution of the Work otherwise complies with - the conditions stated in this License. - - 5. Submission of Contributions. Unless You explicitly state otherwise, - any Contribution intentionally submitted for inclusion in the Work - by You to the Licensor shall be under the terms and conditions of - this License, without any additional terms or conditions. - Notwithstanding the above, nothing herein shall supersede or modify - the terms of any separate license agreement you may have executed - with Licensor regarding such Contributions. - - 6. Trademarks. This License does not grant permission to use the trade - names, trademarks, service marks, or product names of the Licensor, - except as required for reasonable and customary use in describing the - origin of the Work and reproducing the content of the NOTICE file. - - 7. Disclaimer of Warranty. Unless required by applicable law or - agreed to in writing, Licensor provides the Work (and each - Contributor provides its Contributions) on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or - implied, including, without limitation, any warranties or conditions - of TITLE, NON-INFRINGEMENT, MERCHANTABILITY, or FITNESS FOR A - PARTICULAR PURPOSE. You are solely responsible for determining the - appropriateness of using or redistributing the Work and assume any - risks associated with Your exercise of permissions under this License. - - 8. Limitation of Liability. In no event and under no legal theory, - whether in tort (including negligence), contract, or otherwise, - unless required by applicable law (such as deliberate and grossly - negligent acts) or agreed to in writing, shall any Contributor be - liable to You for damages, including any direct, indirect, special, - incidental, or consequential damages of any character arising as a - result of this License or out of the use or inability to use the - Work (including but not limited to damages for loss of goodwill, - work stoppage, computer failure or malfunction, or any and all - other commercial damages or losses), even if such Contributor - has been advised of the possibility of such damages. - - 9. Accepting Warranty or Additional Liability. While redistributing - the Work or Derivative Works thereof, You may choose to offer, - and charge a fee for, acceptance of support, warranty, indemnity, - or other liability obligations and/or rights consistent with this - License. However, in accepting such obligations, You may act only - on Your own behalf and on Your sole responsibility, not on behalf - of any other Contributor, and only if You agree to indemnify, - defend, and hold each Contributor harmless for any liability - incurred by, or claims asserted against, such Contributor by reason - of your accepting any such warranty or additional liability. - - END OF TERMS AND CONDITIONS - - APPENDIX: How to apply the Apache License to your work. - - To apply the Apache License to your work, attach the following - boilerplate notice, with the fields enclosed by brackets "[]" - replaced with your own identifying information. (Don't include - the brackets!) The text should be enclosed in the appropriate - comment syntax for the file format. We also recommend that a - file or class name and description of purpose be included on the - same "printed page" as the copyright notice for easier - identification within third-party archives. - - Copyright [yyyy] [name of copyright owner] - - Licensed under the Apache License, Version 2.0 (the "License"); - you may not use this file except in compliance with the License. - You may obtain a copy of the License at - - http://www.apache.org/licenses/LICENSE-2.0 - - Unless required by applicable law or agreed to in writing, software - distributed under the License is distributed on an "AS IS" BASIS, - WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - See the License for the specific language governing permissions and - limitations under the License. diff --git a/libraries/fork/Adafruit/Adafruit_Sensor/README.md b/libraries/fork/Adafruit/Adafruit_Sensor/README.md deleted file mode 100644 index af193d7..0000000 --- a/libraries/fork/Adafruit/Adafruit_Sensor/README.md +++ /dev/null @@ -1,231 +0,0 @@ -# Adafruit Unified Sensor Driver # - -https://github.com/adafruit/Adafruit_Sensor (v1.1.5 2022-03-07) - -Many small embedded systems exist to collect data from sensors, analyse the data, and either take an appropriate action or send that sensor data to another system for processing. - -One of the many challenges of embedded systems design is the fact that parts you used today may be out of production tomorrow, or system requirements may change and you may need to choose a different sensor down the road. - -Creating new drivers is a relatively easy task, but integrating them into existing systems is both error prone and time consuming since sensors rarely use the exact same units of measurement. - -By reducing all data to a single **sensors\_event\_t** 'type' and settling on specific, **standardised SI units** for each sensor family the same sensor types return values that are comparable with any other similar sensor. This enables you to switch sensor models with very little impact on the rest of the system, which can help mitigate some of the risks and problems of sensor availability and code reuse. - -The unified sensor abstraction layer is also useful for data-logging and data-transmission since you only have one well-known type to log or transmit over the air or wire. - -## Unified Sensor Drivers ## - -The following drivers are based on the Adafruit Unified Sensor Driver: - -**Accelerometers** - - [Adafruit\_ADXL345](https://github.com/adafruit/Adafruit_ADXL345) - - [Adafruit\_LSM303DLHC](https://github.com/adafruit/Adafruit_LSM303DLHC) - - [Adafruit\_MMA8451\_Library](https://github.com/adafruit/Adafruit_MMA8451_Library) - -**Gyroscope** - - [Adafruit\_L3GD20\_U](https://github.com/adafruit/Adafruit_L3GD20_U) - -**Light** - - [Adafruit\_TSL2561](https://github.com/adafruit/Adafruit_TSL2561) - - [Adafruit\_TSL2591\_Library](https://github.com/adafruit/Adafruit_TSL2591_Library) - -**Magnetometers** - - [Adafruit\_LSM303DLHC](https://github.com/adafruit/Adafruit_LSM303DLHC) - - [Adafruit\_HMC5883\_Unified](https://github.com/adafruit/Adafruit_HMC5883_Unified) - -**Barometric Pressure** - - [Adafruit\_BMP085\_Unified](https://github.com/adafruit/Adafruit_BMP085_Unified) - - [Adafruit\_BMP183\_Unified\_Library](https://github.com/adafruit/Adafruit_BMP183_Unified_Library) - -**Humidity & Temperature** - - [DHT-sensor-library](https://github.com/adafruit/DHT-sensor-library) - -**Humidity, Temperature, & Barometric Pressure** - - [Adafruit_BME280_Library](https://github.com/adafruit/Adafruit_BME280_Library/) - -**Orientation** - - [Adafruit_BNO055](https://github.com/adafruit/Adafruit_BNO055) - -**All in one device** -- [Adafruit_LSM9DS0](https://github.com/adafruit/Adafruit_LSM9DS0_Library) (accelerometer, gyroscope, magnetometer) -- [Adafruit_LSM9DS1](https://github.com/adafruit/Adafruit_LSM9DS1/) (accelerometer, gyroscope, magnetometer) - - -## How Does it Work? ## - -Any driver that supports the Adafruit unified sensor abstraction layer will implement the Adafruit\_Sensor base class. There are two main typedefs and one enum defined in Adafruit_Sensor.h that are used to 'abstract' away the sensor details and values: - -## Sensor Types (`sensors_type_t`) - -These pre-defined sensor types are used to properly handle the two related typedefs below, and allows us determine what types of units the sensor uses, etc. - -```c++ -/** Sensor types */ -typedef enum -{ - SENSOR_TYPE_ACCELEROMETER = (1), - SENSOR_TYPE_MAGNETIC_FIELD = (2), - SENSOR_TYPE_ORIENTATION = (3), - SENSOR_TYPE_GYROSCOPE = (4), - SENSOR_TYPE_LIGHT = (5), - SENSOR_TYPE_PRESSURE = (6), - SENSOR_TYPE_PROXIMITY = (8), - SENSOR_TYPE_GRAVITY = (9), - SENSOR_TYPE_LINEAR_ACCELERATION = (10), - SENSOR_TYPE_ROTATION_VECTOR = (11), - SENSOR_TYPE_RELATIVE_HUMIDITY = (12), - SENSOR_TYPE_AMBIENT_TEMPERATURE = (13), - SENSOR_TYPE_VOLTAGE = (15), - SENSOR_TYPE_CURRENT = (16), - SENSOR_TYPE_COLOR = (17) -} sensors_type_t; -``` - -## Sensor Details (`sensor_t`) - -This typedef describes the specific capabilities of this sensor, and allows us to know what sensor we are using beneath the abstraction layer. - -```c++ -/* Sensor details (40 bytes) */ -/** struct sensor_s is used to describe basic information about a specific sensor. */ -typedef struct -{ - char name[12]; - int32_t version; - int32_t sensor_id; - int32_t type; - float max_value; - float min_value; - float resolution; - int32_t min_delay; -} sensor_t; -``` - -The individual fields are intended to be used as follows: - -- **name**: The sensor name or ID, up to a maximum of twelve characters (ex. "MPL115A2") -- **version**: The version of the sensor HW and the driver to allow us to differentiate versions of the board or driver -- **sensor\_id**: A unique sensor identifier that is used to differentiate this specific sensor instance from any others that are present on the system or in the sensor network -- **type**: The sensor type, based on **sensors\_type\_t** in sensors.h -- **max\_value**: The maximum value that this sensor can return (in the appropriate SI unit) -- **min\_value**: The minimum value that this sensor can return (in the appropriate SI unit) -- **resolution**: The smallest difference between two values that this sensor can report (in the appropriate SI unit) -- **min\_delay**: The minimum delay in microseconds between two sensor events, or '0' if there is no constant sensor rate - -## Sensor Data/Events (`sensors_event_t`) - -This typedef is used to return sensor data from any sensor supported by the abstraction layer, using standard SI units and scales. - -```c++ -/* Sensor event (36 bytes) */ -/** struct sensor_event_s is used to provide a single sensor event in a common format. */ -typedef struct -{ - int32_t version; - int32_t sensor_id; - int32_t type; - int32_t reserved0; - int32_t timestamp; - union - { - float data[4]; - sensors_vec_t acceleration; - sensors_vec_t magnetic; - sensors_vec_t orientation; - sensors_vec_t gyro; - float temperature; - float distance; - float light; - float pressure; - float relative_humidity; - float current; - float voltage; - sensors_color_t color; - }; -} sensors_event_t; -``` -It includes the following fields: - -- **version**: Contain 'sizeof(sensors\_event\_t)' to identify which version of the API we're using in case this changes in the future -- **sensor\_id**: A unique sensor identifier that is used to differentiate this specific sensor instance from any others that are present on the system or in the sensor network (must match the sensor\_id value in the corresponding sensor\_t enum above!) -- **type**: the sensor type, based on **sensors\_type\_t** in sensors.h -- **timestamp**: time in milliseconds when the sensor value was read -- **data[4]**: An array of four 32-bit values that allows us to encapsulate any type of sensor data via a simple union (further described below) - -## Required Functions - -In addition to the two standard types and the sensor type enum, all drivers based on Adafruit_Sensor must also implement the following two functions: - -```c++ -bool getEvent(sensors_event_t*); -``` -Calling this function will populate the supplied sensors\_event\_t reference with the latest available sensor data. You should call this function as often as you want to update your data. - -```c++ -void getSensor(sensor_t*); -``` -Calling this function will provide some basic information about the sensor (the sensor name, driver version, min and max values, etc. - -## Standardised SI values for `sensors_event_t` - -A key part of the abstraction layer is the standardisation of values on SI units of a particular scale, which is accomplished via the data[4] union in sensors\_event\_t above. This 16 byte union includes fields for each main sensor type, and uses the following SI units and scales: - -- **acceleration**: values are in **meter per second per second** (m/s^2) -- **magnetic**: values are in **micro-Tesla** (uT) -- **orientation**: values are in **degrees** -- **gyro**: values are in **rad/s** -- **temperature**: values in **degrees centigrade** (Celsius) -- **distance**: values are in **centimeters** -- **light**: values are in **SI lux** units -- **pressure**: values are in **hectopascal** (hPa) -- **relative\_humidity**: values are in **percent** -- **current**: values are in **milliamps** (mA) -- **voltage**: values are in **volts** (V) -- **color**: values are in 0..1.0 RGB channel luminosity and 32-bit RGBA format - -## The Unified Driver Abstraction Layer in Practice ## - -Using the unified sensor abstraction layer is relatively easy once a compliant driver has been created. - -Every compliant sensor can now be read using a single, well-known 'type' (sensors\_event\_t), and there is a standardised way of interrogating a sensor about its specific capabilities (via sensor\_t). - -An example of reading the [TSL2561](https://github.com/adafruit/Adafruit_TSL2561) light sensor can be seen below: - -```c++ - Adafruit_TSL2561 tsl = Adafruit_TSL2561(TSL2561_ADDR_FLOAT, 12345); - ... - /* Get a new sensor event */ - sensors_event_t event; - tsl.getEvent(&event); - - /* Display the results (light is measured in lux) */ - if (event.light) - { - Serial.print(event.light); Serial.println(" lux"); - } - else - { - /* If event.light = 0 lux the sensor is probably saturated - and no reliable data could be generated! */ - Serial.println("Sensor overload"); - } -``` - -Similarly, we can get the basic technical capabilities of this sensor with the following code: - -```c++ - sensor_t sensor; - - sensor_t sensor; - tsl.getSensor(&sensor); - - /* Display the sensor details */ - Serial.println("------------------------------------"); - Serial.print ("Sensor: "); Serial.println(sensor.name); - Serial.print ("Driver Ver: "); Serial.println(sensor.version); - Serial.print ("Unique ID: "); Serial.println(sensor.sensor_id); - Serial.print ("Max Value: "); Serial.print(sensor.max_value); Serial.println(" lux"); - Serial.print ("Min Value: "); Serial.print(sensor.min_value); Serial.println(" lux"); - Serial.print ("Resolution: "); Serial.print(sensor.resolution); Serial.println(" lux"); - Serial.println("------------------------------------"); - Serial.println(""); -``` diff --git a/libraries/fork/Adafruit/Adafruit_Sensor/SConscript b/libraries/fork/Adafruit/Adafruit_Sensor/SConscript deleted file mode 100644 index a4073bd..0000000 --- a/libraries/fork/Adafruit/Adafruit_Sensor/SConscript +++ /dev/null @@ -1,13 +0,0 @@ -from building import * - -cwd = GetCurrentDir() -src = [] -inc = [] - -if GetDepend('RTDUINO_USING_WIRE') or GetDepend('RTDUINO_USING_SPI'): - src += Glob('*.cpp') - inc += [cwd] - -group = DefineGroup('Arduino-Adafruit', src, depend = ['PKG_USING_RTDUINO', 'RTDUINO_USING_ADAFRUIT'], CPPPATH = inc) - -Return('group') diff --git a/libraries/fork/Adafruit/SConscript b/libraries/fork/Adafruit/SConscript deleted file mode 100644 index ecd0e51..0000000 --- a/libraries/fork/Adafruit/SConscript +++ /dev/null @@ -1,12 +0,0 @@ -from building import * -import os - -cwd = GetCurrentDir() -group = [] - -list = os.listdir(cwd) -for item in list: - if os.path.isfile(os.path.join(cwd, item, 'SConscript')): - group = group + SConscript(os.path.join(item, 'SConscript')) - -Return('group') diff --git a/libraries/fork/MsTimer2/MsTimer2.cpp b/libraries/fork/MsTimer2/MsTimer2.cpp deleted file mode 100644 index 83f0f1e..0000000 --- a/libraries/fork/MsTimer2/MsTimer2.cpp +++ /dev/null @@ -1,28 +0,0 @@ -/* - * Copyright (c) 2021-2022, RTduino Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2022-05-23 Meco Man first version - */ - -#include "MsTimer2.h" -#include - -static struct rt_timer mstimer2; - -void MsTimer2::set(unsigned long ms, void (*f)(void)) { - rt_timer_init(&mstimer2, "mstimer2", (void (*)(void *parameter))f, - RT_NULL, ms, RT_TIMER_FLAG_PERIODIC|RT_TIMER_FLAG_SOFT_TIMER); -} - -void MsTimer2::start() { - rt_timer_start(&mstimer2); -} - -void MsTimer2::stop() { - rt_timer_stop(&mstimer2); - rt_timer_detach(&mstimer2); -} diff --git a/libraries/fork/MsTimer2/MsTimer2.h b/libraries/fork/MsTimer2/MsTimer2.h deleted file mode 100644 index 63b22eb..0000000 --- a/libraries/fork/MsTimer2/MsTimer2.h +++ /dev/null @@ -1,22 +0,0 @@ -/* - * Copyright (c) 2021-2022, RTduino Development Team - * - * SPDX-License-Identifier: Apache-2.0 - * - * Change Logs: - * Date Author Notes - * 2022-05-23 Meco Man first version - */ - -#ifndef MsTimer2_h -#define MsTimer2_h - -#include - -namespace MsTimer2{ - void set(unsigned long ms, void (*f)(void)); - void start(); - void stop(); -} - -#endif diff --git a/libraries/fork/MsTimer2/SConscript b/libraries/fork/MsTimer2/SConscript deleted file mode 100644 index 33128ea..0000000 --- a/libraries/fork/MsTimer2/SConscript +++ /dev/null @@ -1,9 +0,0 @@ -from building import * - -cwd = GetCurrentDir() -src = Glob('*.cpp') -inc = [cwd] - -group = DefineGroup('Arduino-MsTimer2', src, depend = ['PKG_USING_RTDUINO', 'RTDUINO_USING_MSTIMER2'], CPPPATH = inc) - -Return('group') diff --git a/libraries/fork/README.md b/libraries/fork/README.md deleted file mode 100644 index d6d04e8..0000000 --- a/libraries/fork/README.md +++ /dev/null @@ -1,3 +0,0 @@ -此文件夹内存放一些**非常重要**的Arduino社区的库,但是这些库不能直接无缝移植到RT-Thread上,需要二次适配。因此需要fork下来,二次适配(对接)到RT-Thread。 - -其他二次适配的Arduino库都放在:https://github.com/orgs/RTduino-libraries/repositories diff --git a/libraries/fork/SConscript b/libraries/fork/SConscript deleted file mode 100644 index ecd0e51..0000000 --- a/libraries/fork/SConscript +++ /dev/null @@ -1,12 +0,0 @@ -from building import * -import os - -cwd = GetCurrentDir() -group = [] - -list = os.listdir(cwd) -for item in list: - if os.path.isfile(os.path.join(cwd, item, 'SConscript')): - group = group + SConscript(os.path.join(item, 'SConscript')) - -Return('group')