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