diff options
| author | Your Name <you@example.com> | 2026-05-18 22:44:37 +0530 |
|---|---|---|
| committer | Your Name <you@example.com> | 2026-05-18 22:44:37 +0530 |
| commit | f2c4b15c72a2fa89caed5d8a11a4ea9832c48be6 (patch) | |
| tree | 4cfaa400b1bddcd6cff2a5e53f3789256c40700d /tests/unit/stubs/driver | |
| parent | 7820837d79ebc8e00221b5206bdd8e3ca0ae4c15 (diff) | |
feat: add AXS15231B touch driver with coordinate parsing tests
Diffstat (limited to 'tests/unit/stubs/driver')
| -rw-r--r-- | tests/unit/stubs/driver/gpio.h | 44 | ||||
| -rw-r--r-- | tests/unit/stubs/driver/i2c_master.h | 39 | ||||
| -rw-r--r-- | tests/unit/stubs/driver/i2c_types.h | 45 |
3 files changed, 128 insertions, 0 deletions
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 @@ | |||
| 1 | #ifndef STUBS_DRIVER_GPIO_H | ||
| 2 | #define STUBS_DRIVER_GPIO_H | ||
| 3 | |||
| 4 | #include <stdint.h> | ||
| 5 | |||
| 6 | typedef enum { | ||
| 7 | GPIO_MODE_DISABLE = 0, | ||
| 8 | GPIO_MODE_INPUT, | ||
| 9 | GPIO_MODE_OUTPUT, | ||
| 10 | GPIO_MODE_OUTPUT_OD, | ||
| 11 | GPIO_MODE_INPUT_OUTPUT_OD, | ||
| 12 | GPIO_MODE_INPUT_OUTPUT, | ||
| 13 | } gpio_mode_t; | ||
| 14 | |||
| 15 | typedef enum { | ||
| 16 | GPIO_INTR_DISABLE = 0, | ||
| 17 | } gpio_int_type_t; | ||
| 18 | |||
| 19 | typedef enum { | ||
| 20 | GPIO_PULLUP_DISABLE = 0, | ||
| 21 | GPIO_PULLUP_ENABLE, | ||
| 22 | } gpio_pullup_t; | ||
| 23 | |||
| 24 | typedef enum { | ||
| 25 | GPIO_PULLDOWN_DISABLE = 0, | ||
| 26 | GPIO_PULLDOWN_ENABLE, | ||
| 27 | } gpio_pulldown_t; | ||
| 28 | |||
| 29 | typedef struct { | ||
| 30 | uint64_t pin_bit_mask; | ||
| 31 | gpio_mode_t mode; | ||
| 32 | gpio_pullup_t pull_up_en; | ||
| 33 | gpio_pulldown_t pull_down_en; | ||
| 34 | gpio_int_type_t intr_type; | ||
| 35 | } gpio_config_t; | ||
| 36 | |||
| 37 | static inline int gpio_config(const gpio_config_t *cfg) { (void)cfg; return 0; } | ||
| 38 | static inline int gpio_set_level(uint32_t gpio_num, uint32_t level) { (void)gpio_num; (void)level; return 0; } | ||
| 39 | |||
| 40 | #define GPIO_INTR_DISABLE 0 | ||
| 41 | #define GPIO_PULLUP_DISABLE 0 | ||
| 42 | #define GPIO_PULLDOWN_DISABLE 0 | ||
| 43 | |||
| 44 | #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 @@ | |||
| 1 | #ifndef STUBS_DRIVER_I2C_MASTER_H | ||
| 2 | #define STUBS_DRIVER_I2C_MASTER_H | ||
| 3 | |||
| 4 | #include "driver/i2c_types.h" | ||
| 5 | #include "esp_err.h" | ||
| 6 | #include <stdint.h> | ||
| 7 | #include <stddef.h> | ||
| 8 | |||
| 9 | static inline esp_err_t i2c_new_master_bus(const i2c_master_bus_config_t *cfg, i2c_master_bus_handle_t *ret) { | ||
| 10 | (void)cfg; (void)ret; | ||
| 11 | return ESP_OK; | ||
| 12 | } | ||
| 13 | |||
| 14 | 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) { | ||
| 15 | (void)bus; (void)cfg; (void)ret; | ||
| 16 | return ESP_OK; | ||
| 17 | } | ||
| 18 | |||
| 19 | static inline esp_err_t i2c_master_transmit(i2c_master_dev_handle_t dev, const uint8_t *buf, size_t len, int timeout_ms) { | ||
| 20 | (void)dev; (void)buf; (void)len; (void)timeout_ms; | ||
| 21 | return ESP_OK; | ||
| 22 | } | ||
| 23 | |||
| 24 | static inline esp_err_t i2c_master_receive(i2c_master_dev_handle_t dev, uint8_t *buf, size_t len, int timeout_ms) { | ||
| 25 | (void)dev; (void)buf; (void)len; (void)timeout_ms; | ||
| 26 | return ESP_OK; | ||
| 27 | } | ||
| 28 | |||
| 29 | static inline esp_err_t i2c_master_bus_rm_device(i2c_master_dev_handle_t dev) { | ||
| 30 | (void)dev; | ||
| 31 | return ESP_OK; | ||
| 32 | } | ||
| 33 | |||
| 34 | static inline esp_err_t i2c_del_master_bus(i2c_master_bus_handle_t bus) { | ||
| 35 | (void)bus; | ||
| 36 | return ESP_OK; | ||
| 37 | } | ||
| 38 | |||
| 39 | #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 @@ | |||
| 1 | #ifndef STUBS_DRIVER_I2C_TYPES_H | ||
| 2 | #define STUBS_DRIVER_I2C_TYPES_H | ||
| 3 | |||
| 4 | #include <stdint.h> | ||
| 5 | #include <stddef.h> | ||
| 6 | |||
| 7 | typedef int i2c_port_num_t; | ||
| 8 | #define I2C_NUM_0 0 | ||
| 9 | |||
| 10 | typedef enum { | ||
| 11 | I2C_ADDR_BIT_LEN_7 = 0, | ||
| 12 | } i2c_addr_bit_len_t; | ||
| 13 | |||
| 14 | typedef enum { | ||
| 15 | I2C_CLK_SRC_DEFAULT = 0, | ||
| 16 | } i2c_clock_source_t; | ||
| 17 | |||
| 18 | typedef struct i2c_master_bus_t *i2c_master_bus_handle_t; | ||
| 19 | typedef struct i2c_master_dev_t *i2c_master_dev_handle_t; | ||
| 20 | |||
| 21 | typedef struct { | ||
| 22 | i2c_port_num_t i2c_port; | ||
| 23 | int sda_io_num; | ||
| 24 | int scl_io_num; | ||
| 25 | i2c_clock_source_t clk_source; | ||
| 26 | uint8_t glitch_ignore_cnt; | ||
| 27 | int intr_priority; | ||
| 28 | size_t trans_queue_depth; | ||
| 29 | struct { | ||
| 30 | uint32_t enable_internal_pullup : 1; | ||
| 31 | uint32_t allow_pd : 1; | ||
| 32 | } flags; | ||
| 33 | } i2c_master_bus_config_t; | ||
| 34 | |||
| 35 | typedef struct { | ||
| 36 | i2c_addr_bit_len_t dev_addr_length; | ||
| 37 | uint16_t device_address; | ||
| 38 | uint32_t scl_speed_hz; | ||
| 39 | uint32_t scl_wait_us; | ||
| 40 | struct { | ||
| 41 | uint32_t disable_ack_check : 1; | ||
| 42 | } flags; | ||
| 43 | } i2c_device_config_t; | ||
| 44 | |||
| 45 | #endif | ||