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,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"
|
||||
Reference in New Issue
Block a user