Implemented TactilityKernel and DevicetreeCompiler, updated licenses & copyrights (#452)
**New features** - Created a devicetree DTS and YAML parser in Python - Created new modules: - TactilityKernel (LGPL v3.0 license) - Platforms/PlatformEsp32 (LGPL v3.0 license) - Platforms/PlatformPosix (LGPL v3.0 license) - Tests/TactilityKernelTests Most boards have a placeholder DTS file, while T-Lora Pager has a few devices attached. **Licenses** Clarified licenses and copyrights better. - Add explanation about the intent behind them. - Added explanation about licenses for past and future subprojects - Added more details explanations with regards to the logo usage - Copied licenses to subprojects to make it more explicit
This commit is contained in:
committed by
GitHub
parent
0d16eb606f
commit
4b6ed871a9
@@ -0,0 +1,157 @@
|
||||
# GNU LESSER GENERAL PUBLIC LICENSE
|
||||
|
||||
Version 3, 29 June 2007
|
||||
|
||||
Copyright (C) 2007 Free Software Foundation, Inc.
|
||||
<https://fsf.org/>
|
||||
|
||||
Everyone is permitted to copy and distribute verbatim copies of this
|
||||
license document, but changing it is not allowed.
|
||||
|
||||
This version of the GNU Lesser General Public License incorporates the
|
||||
terms and conditions of version 3 of the GNU General Public License,
|
||||
supplemented by the additional permissions listed below.
|
||||
|
||||
## 0. Additional Definitions.
|
||||
|
||||
As used herein, "this License" refers to version 3 of the GNU Lesser
|
||||
General Public License, and the "GNU GPL" refers to version 3 of the
|
||||
GNU General Public License.
|
||||
|
||||
"The Library" refers to a covered work governed by this License, other
|
||||
than an Application or a Combined Work as defined below.
|
||||
|
||||
An "Application" is any work that makes use of an interface provided
|
||||
by the Library, but which is not otherwise based on the Library.
|
||||
Defining a subclass of a class defined by the Library is deemed a mode
|
||||
of using an interface provided by the Library.
|
||||
|
||||
A "Combined Work" is a work produced by combining or linking an
|
||||
Application with the Library. The particular version of the Library
|
||||
with which the Combined Work was made is also called the "Linked
|
||||
Version".
|
||||
|
||||
The "Minimal Corresponding Source" for a Combined Work means the
|
||||
Corresponding Source for the Combined Work, excluding any source code
|
||||
for portions of the Combined Work that, considered in isolation, are
|
||||
based on the Application, and not on the Linked Version.
|
||||
|
||||
The "Corresponding Application Code" for a Combined Work means the
|
||||
object code and/or source code for the Application, including any data
|
||||
and utility programs needed for reproducing the Combined Work from the
|
||||
Application, but excluding the System Libraries of the Combined Work.
|
||||
|
||||
## 1. Exception to Section 3 of the GNU GPL.
|
||||
|
||||
You may convey a covered work under sections 3 and 4 of this License
|
||||
without being bound by section 3 of the GNU GPL.
|
||||
|
||||
## 2. Conveying Modified Versions.
|
||||
|
||||
If you modify a copy of the Library, and, in your modifications, a
|
||||
facility refers to a function or data to be supplied by an Application
|
||||
that uses the facility (other than as an argument passed when the
|
||||
facility is invoked), then you may convey a copy of the modified
|
||||
version:
|
||||
|
||||
- a) under this License, provided that you make a good faith effort
|
||||
to ensure that, in the event an Application does not supply the
|
||||
function or data, the facility still operates, and performs
|
||||
whatever part of its purpose remains meaningful, or
|
||||
- b) under the GNU GPL, with none of the additional permissions of
|
||||
this License applicable to that copy.
|
||||
|
||||
## 3. Object Code Incorporating Material from Library Header Files.
|
||||
|
||||
The object code form of an Application may incorporate material from a
|
||||
header file that is part of the Library. You may convey such object
|
||||
code under terms of your choice, provided that, if the incorporated
|
||||
material is not limited to numerical parameters, data structure
|
||||
layouts and accessors, or small macros, inline functions and templates
|
||||
(ten or fewer lines in length), you do both of the following:
|
||||
|
||||
- a) Give prominent notice with each copy of the object code that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
- b) Accompany the object code with a copy of the GNU GPL and this
|
||||
license document.
|
||||
|
||||
## 4. Combined Works.
|
||||
|
||||
You may convey a Combined Work under terms of your choice that, taken
|
||||
together, effectively do not restrict modification of the portions of
|
||||
the Library contained in the Combined Work and reverse engineering for
|
||||
debugging such modifications, if you also do each of the following:
|
||||
|
||||
- a) Give prominent notice with each copy of the Combined Work that
|
||||
the Library is used in it and that the Library and its use are
|
||||
covered by this License.
|
||||
- b) Accompany the Combined Work with a copy of the GNU GPL and this
|
||||
license document.
|
||||
- c) For a Combined Work that displays copyright notices during
|
||||
execution, include the copyright notice for the Library among
|
||||
these notices, as well as a reference directing the user to the
|
||||
copies of the GNU GPL and this license document.
|
||||
- d) Do one of the following:
|
||||
- 0) Convey the Minimal Corresponding Source under the terms of
|
||||
this License, and the Corresponding Application Code in a form
|
||||
suitable for, and under terms that permit, the user to
|
||||
recombine or relink the Application with a modified version of
|
||||
the Linked Version to produce a modified Combined Work, in the
|
||||
manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.
|
||||
- 1) Use a suitable shared library mechanism for linking with
|
||||
the Library. A suitable mechanism is one that (a) uses at run
|
||||
time a copy of the Library already present on the user's
|
||||
computer system, and (b) will operate properly with a modified
|
||||
version of the Library that is interface-compatible with the
|
||||
Linked Version.
|
||||
- e) Provide Installation Information, but only if you would
|
||||
otherwise be required to provide such information under section 6
|
||||
of the GNU GPL, and only to the extent that such information is
|
||||
necessary to install and execute a modified version of the
|
||||
Combined Work produced by recombining or relinking the Application
|
||||
with a modified version of the Linked Version. (If you use option
|
||||
4d0, the Installation Information must accompany the Minimal
|
||||
Corresponding Source and Corresponding Application Code. If you
|
||||
use option 4d1, you must provide the Installation Information in
|
||||
the manner specified by section 6 of the GNU GPL for conveying
|
||||
Corresponding Source.)
|
||||
|
||||
## 5. Combined Libraries.
|
||||
|
||||
You may place library facilities that are a work based on the Library
|
||||
side by side in a single library together with other library
|
||||
facilities that are not Applications and are not covered by this
|
||||
License, and convey such a combined library under terms of your
|
||||
choice, if you do both of the following:
|
||||
|
||||
- a) Accompany the combined library with a copy of the same work
|
||||
based on the Library, uncombined with any other library
|
||||
facilities, conveyed under the terms of this License.
|
||||
- b) Give prominent notice with the combined library that part of it
|
||||
is a work based on the Library, and explaining where to find the
|
||||
accompanying uncombined form of the same work.
|
||||
|
||||
## 6. Revised Versions of the GNU Lesser General Public License.
|
||||
|
||||
The Free Software Foundation may publish revised and/or new versions
|
||||
of the GNU Lesser General Public License from time to time. Such new
|
||||
versions will be similar in spirit to the present version, but may
|
||||
differ in detail to address new problems or concerns.
|
||||
|
||||
Each version is given a distinguishing version number. If the Library
|
||||
as you received it specifies that a certain numbered version of the
|
||||
GNU Lesser General Public License "or any later version" applies to
|
||||
it, you have the option of following the terms and conditions either
|
||||
of that published version or of any later version published by the
|
||||
Free Software Foundation. If the Library as you received it does not
|
||||
specify a version number of the GNU Lesser General Public License, you
|
||||
may choose any version of the GNU Lesser General Public License ever
|
||||
published by the Free Software Foundation.
|
||||
|
||||
If the Library as you received it specifies that a proxy can decide
|
||||
whether future versions of the GNU Lesser General Public License shall
|
||||
apply, that proxy's public statement of acceptance of any version is
|
||||
permanent authorization for you to choose that version for the
|
||||
Library.
|
||||
@@ -0,0 +1,5 @@
|
||||
description: ESP32 GPIO Controller
|
||||
|
||||
compatible: "espressif,esp32-gpio"
|
||||
|
||||
include: ["gpio-controller.yaml"]
|
||||
@@ -0,0 +1,12 @@
|
||||
description: ESP32 I2C Controller
|
||||
|
||||
include: ["i2c-controller.yaml"]
|
||||
|
||||
compatible: "espressif,esp32-i2c"
|
||||
|
||||
properties:
|
||||
port:
|
||||
type: int
|
||||
description: |
|
||||
The port number, defined by i2c_port_t.
|
||||
Depending on the hardware, these values are available: I2C_NUM_0, I2C_NUM_1, LP_I2C_NUM_0
|
||||
@@ -0,0 +1,20 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
file(GLOB_RECURSE SOURCES "Source/*.c**")
|
||||
|
||||
if (DEFINED ENV{ESP_IDF_VERSION})
|
||||
|
||||
idf_component_register(
|
||||
SRCS ${SOURCES}
|
||||
INCLUDE_DIRS "Include/"
|
||||
REQUIRES TactilityKernel driver
|
||||
)
|
||||
|
||||
else ()
|
||||
|
||||
add_library(PlatformEsp32 OBJECT)
|
||||
target_sources(PlatformEsp32 PRIVATE ${SOURCES})
|
||||
target_include_directories(PlatformEsp32 PUBLIC Include/)
|
||||
target_link_libraries(PlatformEsp32 PUBLIC TactilityKernel)
|
||||
|
||||
endif ()
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/bindings/bindings.h>
|
||||
#include <Tactility/drivers/Esp32Gpio.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
DEFINE_DEVICETREE(esp32_gpio, struct Esp32GpioConfig)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,14 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/bindings/bindings.h>
|
||||
#include <Tactility/drivers/Esp32I2c.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
DEFINE_DEVICETREE(esp32_i2c, struct Esp32I2cConfig)
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,15 @@
|
||||
#pragma once
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
#include <stdint.h>
|
||||
|
||||
struct Esp32GpioConfig {
|
||||
uint8_t gpio_count;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,19 @@
|
||||
#pragma once
|
||||
|
||||
#include <Tactility/drivers/Gpio.h>
|
||||
#include <hal/i2c_types.h>
|
||||
|
||||
#ifdef __cplusplus
|
||||
extern "C" {
|
||||
#endif
|
||||
|
||||
struct Esp32I2cConfig {
|
||||
uint32_t clock_frequency;
|
||||
struct GpioPinConfig pin_sda;
|
||||
struct GpioPinConfig pin_scl;
|
||||
const i2c_port_t port;
|
||||
};
|
||||
|
||||
#ifdef __cplusplus
|
||||
}
|
||||
#endif
|
||||
@@ -0,0 +1,116 @@
|
||||
#include <driver/gpio.h>
|
||||
|
||||
#include <Tactility/Driver.h>
|
||||
#include <Tactility/drivers/Esp32Gpio.h>
|
||||
#include <Tactility/drivers/GpioController.h>
|
||||
#include <Tactility/drivers/Gpio.h>
|
||||
#include <Tactility/Log.h>
|
||||
|
||||
#define TAG LOG_TAG(esp32_gpio)
|
||||
|
||||
#define GET_CONFIG(device) ((struct Esp32GpioConfig*)device->internal.driver_data)
|
||||
|
||||
extern "C" {
|
||||
|
||||
static bool set_level(Device* device, gpio_pin_t pin, bool high) {
|
||||
return gpio_set_level(static_cast<gpio_num_t>(pin), high) == ESP_OK;
|
||||
}
|
||||
|
||||
static bool get_level(Device* device, gpio_pin_t pin, bool* high) {
|
||||
*high = gpio_get_level(static_cast<gpio_num_t>(pin)) != 0;
|
||||
return true;
|
||||
}
|
||||
|
||||
static bool set_options(Device* device, gpio_pin_t pin, gpio_flags_t options) {
|
||||
const Esp32GpioConfig* config = GET_CONFIG(device);
|
||||
|
||||
if (pin >= config->gpio_count) {
|
||||
return false;
|
||||
}
|
||||
|
||||
gpio_mode_t mode;
|
||||
if ((options & GPIO_DIRECTION_INPUT_OUTPUT) == GPIO_DIRECTION_INPUT_OUTPUT) {
|
||||
mode = GPIO_MODE_INPUT_OUTPUT;
|
||||
} else if (options & GPIO_DIRECTION_INPUT) {
|
||||
mode = GPIO_MODE_INPUT;
|
||||
} else if (options & GPIO_DIRECTION_OUTPUT) {
|
||||
mode = GPIO_MODE_OUTPUT;
|
||||
} else {
|
||||
ESP_LOGE(TAG, "set_options: no direction flag specified for pin %d", pin);
|
||||
return false;
|
||||
}
|
||||
|
||||
const gpio_config_t esp_config = {
|
||||
.pin_bit_mask = 1ULL << pin,
|
||||
.mode = mode,
|
||||
.pull_up_en = (options & GPIO_PULL_UP) ? GPIO_PULLUP_ENABLE : GPIO_PULLUP_DISABLE,
|
||||
.pull_down_en = (options & GPIO_PULL_DOWN) ? GPIO_PULLDOWN_ENABLE : GPIO_PULLDOWN_DISABLE,
|
||||
.intr_type = GPIO_INTERRUPT_FROM_OPTIONS(options),
|
||||
#if SOC_GPIO_SUPPORT_PIN_HYS_FILTER
|
||||
.hys_ctrl_mode = GPIO_HYS_SOFT_DISABLE
|
||||
#endif
|
||||
};
|
||||
|
||||
return gpio_config(&esp_config) == ESP_OK;
|
||||
}
|
||||
|
||||
static bool get_options(Device* device, gpio_pin_t pin, gpio_flags_t* options) {
|
||||
gpio_io_config_t esp_config;
|
||||
if (gpio_get_io_config((gpio_num_t)pin, &esp_config) != ESP_OK) {
|
||||
return false;
|
||||
}
|
||||
|
||||
gpio_flags_t output = 0;
|
||||
|
||||
if (esp_config.pu) {
|
||||
output |= GPIO_PULL_UP;
|
||||
}
|
||||
|
||||
if (esp_config.pd) {
|
||||
output |= GPIO_PULL_DOWN;
|
||||
}
|
||||
|
||||
if (esp_config.ie) {
|
||||
output |= GPIO_DIRECTION_INPUT;
|
||||
}
|
||||
|
||||
if (esp_config.oe) {
|
||||
output |= GPIO_DIRECTION_OUTPUT;
|
||||
}
|
||||
|
||||
if (esp_config.oe_inv) {
|
||||
output |= GPIO_ACTIVE_LOW;
|
||||
}
|
||||
|
||||
*options = output;
|
||||
return true;
|
||||
}
|
||||
|
||||
static int start(Device* device) {
|
||||
ESP_LOGI(TAG, "start %s", device->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stop(Device* device) {
|
||||
ESP_LOGI(TAG, "stop %s", device->name);
|
||||
return 0;
|
||||
}
|
||||
|
||||
const static GpioControllerApi esp32_gpio_api = {
|
||||
.set_level = set_level,
|
||||
.get_level = get_level,
|
||||
.set_options = set_options,
|
||||
.get_options = get_options
|
||||
};
|
||||
|
||||
Driver esp32_gpio_driver = {
|
||||
.name = "esp32_gpio",
|
||||
.compatible = (const char*[]) { "espressif,esp32-gpio", nullptr },
|
||||
.start_device = start,
|
||||
.stop_device = stop,
|
||||
.api = (void*)&esp32_gpio_api,
|
||||
.device_type = nullptr,
|
||||
.internal = { 0 }
|
||||
};
|
||||
|
||||
} // extern "C"
|
||||
@@ -0,0 +1,91 @@
|
||||
#include <driver/i2c.h>
|
||||
|
||||
#include <Tactility/Driver.h>
|
||||
#include <Tactility/drivers/Esp32I2c.h>
|
||||
#include <Tactility/drivers/I2cController.h>
|
||||
#include <Tactility/Log.h>
|
||||
|
||||
#define TAG LOG_TAG(esp32_i2c)
|
||||
|
||||
struct InternalData {
|
||||
Mutex mutex { 0 };
|
||||
|
||||
InternalData() {
|
||||
mutex_construct(&mutex);
|
||||
}
|
||||
|
||||
~InternalData() {
|
||||
mutex_destruct(&mutex);
|
||||
}
|
||||
};
|
||||
|
||||
#define GET_CONFIG(device) ((Esp32I2cConfig*)device->config)
|
||||
#define GET_DATA(device) ((InternalData*)device->internal.driver_data)
|
||||
|
||||
#define lock(data) mutex_lock(&data->mutex);
|
||||
#define unlock(data) mutex_unlock(&data->mutex);
|
||||
|
||||
extern "C" {
|
||||
|
||||
static bool read(Device* device, uint8_t address, uint8_t* data, size_t data_size, TickType_t timeout) {
|
||||
vPortAssertIfInISR();
|
||||
auto* driver_data = GET_DATA(device);
|
||||
lock(driver_data);
|
||||
const esp_err_t result = i2c_master_read_from_device(GET_CONFIG(device)->port, address, data, data_size, timeout);
|
||||
unlock(driver_data);
|
||||
ESP_ERROR_CHECK_WITHOUT_ABORT(result);
|
||||
return result == ESP_OK;
|
||||
}
|
||||
|
||||
static bool write(Device* device, uint8_t address, const uint8_t* data, uint16_t dataSize, TickType_t timeout) {
|
||||
vPortAssertIfInISR();
|
||||
auto* driver_data = GET_DATA(device);
|
||||
lock(driver_data);
|
||||
const esp_err_t result = i2c_master_write_to_device(GET_CONFIG(device)->port, address, data, dataSize, timeout);
|
||||
unlock(driver_data);
|
||||
ESP_ERROR_CHECK_WITHOUT_ABORT(result);
|
||||
return result == ESP_OK;
|
||||
}
|
||||
|
||||
static bool write_read(Device* device, uint8_t address, const uint8_t* write_data, size_t write_data_size, uint8_t* read_data, size_t read_data_size, TickType_t timeout) {
|
||||
vPortAssertIfInISR();
|
||||
auto* driver_data = GET_DATA(device);
|
||||
lock(driver_data);
|
||||
const esp_err_t result = i2c_master_write_read_device(GET_CONFIG(device)->port, address, write_data, write_data_size, read_data, read_data_size, timeout);
|
||||
unlock(driver_data);
|
||||
ESP_ERROR_CHECK_WITHOUT_ABORT(result);
|
||||
return result == ESP_OK;
|
||||
}
|
||||
|
||||
static int start(Device* device) {
|
||||
ESP_LOGI(TAG, "start %s", device->name);
|
||||
auto* data = new InternalData();
|
||||
device_set_driver_data(device, data);
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int stop(Device* device) {
|
||||
ESP_LOGI(TAG, "stop %s", device->name);
|
||||
auto* driver_data = static_cast<InternalData*>(device_get_driver_data(device));
|
||||
device_set_driver_data(device, nullptr);
|
||||
delete driver_data;
|
||||
return 0;
|
||||
}
|
||||
|
||||
const I2cControllerApi esp32_i2c_api = {
|
||||
.read = read,
|
||||
.write = write,
|
||||
.write_read = write_read
|
||||
};
|
||||
|
||||
Driver esp32_i2c_driver = {
|
||||
.name = "esp32_i2c",
|
||||
.compatible = (const char*[]) { "espressif,esp32-i2c", nullptr },
|
||||
.start_device = start,
|
||||
.stop_device = stop,
|
||||
.api = (void*)&esp32_i2c_api,
|
||||
.device_type = &I2C_CONTROLLER_TYPE,
|
||||
.internal = { 0 }
|
||||
};
|
||||
|
||||
} // extern "C"
|
||||
@@ -0,0 +1,12 @@
|
||||
#include <Tactility/Driver.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
extern void register_platform_drivers() {
|
||||
extern Driver esp32_gpio_driver;
|
||||
driver_construct(&esp32_gpio_driver);
|
||||
extern Driver esp32_i2c_driver;
|
||||
driver_construct(&esp32_i2c_driver);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,3 @@
|
||||
dependencies:
|
||||
- TactilityKernel
|
||||
bindings: Bindings
|
||||
@@ -0,0 +1,20 @@
|
||||
cmake_minimum_required(VERSION 3.20)
|
||||
|
||||
file(GLOB_RECURSE SOURCES "Source/*.c**")
|
||||
|
||||
if (DEFINED ENV{ESP_IDF_VERSION})
|
||||
|
||||
idf_component_register(
|
||||
SRCS ${SOURCES}
|
||||
# INCLUDE_DIRS "Include/"
|
||||
REQUIRES TactilityKernel driver
|
||||
)
|
||||
|
||||
else ()
|
||||
|
||||
add_library(PlatformPosix OBJECT)
|
||||
target_sources(PlatformPosix PRIVATE ${SOURCES})
|
||||
# target_include_directories(PlatformPosix PUBLIC Include/)
|
||||
target_link_libraries(PlatformPosix PUBLIC TactilityKernel)
|
||||
|
||||
endif ()
|
||||
@@ -0,0 +1,9 @@
|
||||
#include <Tactility/Driver.h>
|
||||
|
||||
extern "C" {
|
||||
|
||||
extern void register_platform_drivers() {
|
||||
/* Placeholder */
|
||||
}
|
||||
|
||||
}
|
||||
@@ -0,0 +1,2 @@
|
||||
dependencies:
|
||||
- TactilityKernel
|
||||
Reference in New Issue
Block a user