From f2c4b15c72a2fa89caed5d8a11a4ea9832c48be6 Mon Sep 17 00:00:00 2001 From: Your Name Date: Mon, 18 May 2026 22:44:37 +0530 Subject: feat: add AXS15231B touch driver with coordinate parsing tests --- tests/unit/stubs/driver/gpio.h | 44 +++++++++++++++++++++++++++++++++++ tests/unit/stubs/driver/i2c_master.h | 39 +++++++++++++++++++++++++++++++ tests/unit/stubs/driver/i2c_types.h | 45 ++++++++++++++++++++++++++++++++++++ 3 files changed, 128 insertions(+) create mode 100644 tests/unit/stubs/driver/gpio.h create mode 100644 tests/unit/stubs/driver/i2c_master.h create mode 100644 tests/unit/stubs/driver/i2c_types.h (limited to 'tests/unit/stubs') diff --git a/tests/unit/stubs/driver/gpio.h b/tests/unit/stubs/driver/gpio.h new file mode 100644 index 0000000..d8dda0a --- /dev/null +++ b/tests/unit/stubs/driver/gpio.h @@ -0,0 +1,44 @@ +#ifndef STUBS_DRIVER_GPIO_H +#define STUBS_DRIVER_GPIO_H + +#include + +typedef enum { + GPIO_MODE_DISABLE = 0, + GPIO_MODE_INPUT, + GPIO_MODE_OUTPUT, + GPIO_MODE_OUTPUT_OD, + GPIO_MODE_INPUT_OUTPUT_OD, + GPIO_MODE_INPUT_OUTPUT, +} gpio_mode_t; + +typedef enum { + GPIO_INTR_DISABLE = 0, +} gpio_int_type_t; + +typedef enum { + GPIO_PULLUP_DISABLE = 0, + GPIO_PULLUP_ENABLE, +} gpio_pullup_t; + +typedef enum { + GPIO_PULLDOWN_DISABLE = 0, + GPIO_PULLDOWN_ENABLE, +} gpio_pulldown_t; + +typedef struct { + uint64_t pin_bit_mask; + gpio_mode_t mode; + gpio_pullup_t pull_up_en; + gpio_pulldown_t pull_down_en; + gpio_int_type_t intr_type; +} gpio_config_t; + +static inline int gpio_config(const gpio_config_t *cfg) { (void)cfg; return 0; } +static inline int gpio_set_level(uint32_t gpio_num, uint32_t level) { (void)gpio_num; (void)level; return 0; } + +#define GPIO_INTR_DISABLE 0 +#define GPIO_PULLUP_DISABLE 0 +#define GPIO_PULLDOWN_DISABLE 0 + +#endif diff --git a/tests/unit/stubs/driver/i2c_master.h b/tests/unit/stubs/driver/i2c_master.h new file mode 100644 index 0000000..f49eaad --- /dev/null +++ b/tests/unit/stubs/driver/i2c_master.h @@ -0,0 +1,39 @@ +#ifndef STUBS_DRIVER_I2C_MASTER_H +#define STUBS_DRIVER_I2C_MASTER_H + +#include "driver/i2c_types.h" +#include "esp_err.h" +#include +#include + +static inline esp_err_t i2c_new_master_bus(const i2c_master_bus_config_t *cfg, i2c_master_bus_handle_t *ret) { + (void)cfg; (void)ret; + return ESP_OK; +} + +static inline esp_err_t i2c_master_bus_add_device(i2c_master_bus_handle_t bus, const i2c_device_config_t *cfg, i2c_master_dev_handle_t *ret) { + (void)bus; (void)cfg; (void)ret; + return ESP_OK; +} + +static inline esp_err_t i2c_master_transmit(i2c_master_dev_handle_t dev, const uint8_t *buf, size_t len, int timeout_ms) { + (void)dev; (void)buf; (void)len; (void)timeout_ms; + return ESP_OK; +} + +static inline esp_err_t i2c_master_receive(i2c_master_dev_handle_t dev, uint8_t *buf, size_t len, int timeout_ms) { + (void)dev; (void)buf; (void)len; (void)timeout_ms; + return ESP_OK; +} + +static inline esp_err_t i2c_master_bus_rm_device(i2c_master_dev_handle_t dev) { + (void)dev; + return ESP_OK; +} + +static inline esp_err_t i2c_del_master_bus(i2c_master_bus_handle_t bus) { + (void)bus; + return ESP_OK; +} + +#endif diff --git a/tests/unit/stubs/driver/i2c_types.h b/tests/unit/stubs/driver/i2c_types.h new file mode 100644 index 0000000..3590a8b --- /dev/null +++ b/tests/unit/stubs/driver/i2c_types.h @@ -0,0 +1,45 @@ +#ifndef STUBS_DRIVER_I2C_TYPES_H +#define STUBS_DRIVER_I2C_TYPES_H + +#include +#include + +typedef int i2c_port_num_t; +#define I2C_NUM_0 0 + +typedef enum { + I2C_ADDR_BIT_LEN_7 = 0, +} i2c_addr_bit_len_t; + +typedef enum { + I2C_CLK_SRC_DEFAULT = 0, +} i2c_clock_source_t; + +typedef struct i2c_master_bus_t *i2c_master_bus_handle_t; +typedef struct i2c_master_dev_t *i2c_master_dev_handle_t; + +typedef struct { + i2c_port_num_t i2c_port; + int sda_io_num; + int scl_io_num; + i2c_clock_source_t clk_source; + uint8_t glitch_ignore_cnt; + int intr_priority; + size_t trans_queue_depth; + struct { + uint32_t enable_internal_pullup : 1; + uint32_t allow_pd : 1; + } flags; +} i2c_master_bus_config_t; + +typedef struct { + i2c_addr_bit_len_t dev_addr_length; + uint16_t device_address; + uint32_t scl_speed_hz; + uint32_t scl_wait_us; + struct { + uint32_t disable_ack_check : 1; + } flags; +} i2c_device_config_t; + +#endif -- cgit v1.2.3