Create GPIO HAL (#344)

This commit is contained in:
Ken Van Hoeylandt
2025-09-22 23:24:01 +02:00
committed by GitHub
parent bab3eb19bc
commit 7ad0a3cb04
16 changed files with 234 additions and 62 deletions
+39
View File
@@ -0,0 +1,39 @@
#pragma once
#include <stdint.h>
#include <stdbool.h>
#ifdef __cplusplus
extern "C" {
#endif
typedef unsigned int GpioPin;
#define GPIO_NO_PIN -1
/** @warning The order must match tt::hal::gpio::Mode */
enum class GpioMode {
Disable = 0,
Input,
Output,
OutputOpenDrain,
InputOutput,
InputOutputOpenDrain
};
/** Configure a single pin */
bool tt_hal_gpio_configure(GpioPin pin, GpioMode mode, bool pullUp, bool pullDown);
/** Configure a set of pins defined by their bit index */
bool tt_hal_gpio_configure_with_pin_bitmask(uint64_t pinBitMask, GpioMode mode, bool pullUp, bool pullDown);
bool tt_hal_gpio_set_mode(GpioPin pin, GpioMode mode);
bool tt_hal_gpio_get_level(GpioPin pin);
bool tt_hal_gpio_set_level(GpioPin pin, bool level);
int tt_hal_gpio_get_pin_count();
#ifdef __cplusplus
}
#endif
+32
View File
@@ -0,0 +1,32 @@
#include "tt_hal_gpio.h"
#include <Tactility/hal/gpio/Gpio.h>
extern "C" {
using namespace tt::hal;
bool tt_hal_gpio_configure(GpioPin pin, GpioMode mode, bool pullUp, bool pullDown) {
return gpio::configure(pin, static_cast<gpio::Mode>(mode), pullUp, pullDown);
}
bool tt_hal_gpio_configure_with_pin_bitmask(uint64_t pinBitMask, GpioMode mode, bool pullUp, bool pullDown) {
return gpio::configureWithPinBitmask(pinBitMask, static_cast<gpio::Mode>(mode), pullUp, pullDown);
}
bool tt_hal_gpio_set_mode(GpioPin pin, GpioMode mode) {
return gpio::setMode(pin, static_cast<gpio::Mode>(mode));
}
bool tt_hal_gpio_get_level(GpioPin pin) {
return gpio::getLevel(pin);
}
bool tt_hal_gpio_set_level(GpioPin pin, bool level) {
return gpio::setLevel(pin, level);
}
int tt_hal_gpio_get_pin_count() {
return gpio::getPinCount();
}
}
+7
View File
@@ -8,6 +8,7 @@
#include "tt_gps.h"
#include "tt_hal_device.h"
#include "tt_hal_display.h"
#include "tt_hal_gpio.h"
#include "tt_hal_i2c.h"
#include "tt_hal_touch.h"
#include "tt_kernel.h"
@@ -205,6 +206,12 @@ const esp_elfsym elf_symbols[] {
ESP_ELFSYM_EXPORT(tt_hal_display_driver_lock),
ESP_ELFSYM_EXPORT(tt_hal_display_driver_unlock),
ESP_ELFSYM_EXPORT(tt_hal_display_driver_supported),
ESP_ELFSYM_EXPORT(tt_hal_gpio_configure),
ESP_ELFSYM_EXPORT(tt_hal_gpio_configure_with_pin_bitmask),
ESP_ELFSYM_EXPORT(tt_hal_gpio_set_mode),
ESP_ELFSYM_EXPORT(tt_hal_gpio_get_level),
ESP_ELFSYM_EXPORT(tt_hal_gpio_set_level),
ESP_ELFSYM_EXPORT(tt_hal_gpio_get_pin_count),
ESP_ELFSYM_EXPORT(tt_hal_i2c_start),
ESP_ELFSYM_EXPORT(tt_hal_i2c_stop),
ESP_ELFSYM_EXPORT(tt_hal_i2c_is_started),