ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_touch.h
Go to the documentation of this file.
1
47
48#pragma once
49
50#ifdef __cplusplus
51extern "C" {
52#endif
53
54#include <stddef.h>
55#include <stdint.h>
56
57#include "ra8_attributes.h"
58#include "ra8_err.h"
59#include "ra8_i2c_bus_ops.h"
60
61/* ===========================================================================
62 * Compile-time limits
63 * ===========================================================================
64 */
65
74
75/* ===========================================================================
76 * Public types
77 * ===========================================================================
78 */
79
93typedef struct {
94 uint16_t x;
95 uint16_t y;
96 uint8_t track_id;
97 uint8_t pressure;
99
109typedef struct {
111 uint8_t target_7b;
112 uint8_t irq_pin;
114 uint8_t max_points;
116
130typedef void (*ra8_touch_event_fn_t)(void* ctx);
131
132/* ===========================================================================
133 * Lifecycle
134 * ===========================================================================
135 */
136
175[[nodiscard]] ra8_err_t ra8_touch_open(const ra8_touch_cfg_t* cfg);
176
190[[nodiscard]] ra8_err_t ra8_touch_close(void);
191
192/* ===========================================================================
193 * Event handler attach / dispatch
194 * ===========================================================================
195 */
196
211[[nodiscard]] ra8_err_t ra8_touch_attach_handler(ra8_touch_event_fn_t fn, void* ctx);
212
229void ra8_touch_dispatch_irq(void);
230
231/* ===========================================================================
232 * Touch-point read
233 * ===========================================================================
234 */
235
268[[nodiscard]] ra8_err_t
269ra8_touch_read(ra8_touch_point_t* out_points, uint8_t max_count, uint8_t* got_count);
270
283[[nodiscard]] ra8_err_t ra8_touch_calibrate(void);
284
285#ifdef UNIT_TEST
307RA8_TEST_HELPER [[nodiscard]] ra8_err_t ra8_touch_test_decode(const uint8_t* raw,
308 uint8_t n_points,
309 ra8_touch_point_t* out_points,
310 uint8_t max_count,
311 uint8_t* got_count);
312#endif /* UNIT_TEST */
313
314#ifdef __cplusplus
315}
316#endif
Annotation-attribute framework macros for ra8-firmware.
#define RA8_TEST_HELPER
Mark a symbol as externally-linked but only callable from tests.
Error Code Definitions for ra8-firmware.
ra8_err_codes_t ra8_err_t
Canonical error-return type used by every ra8-firmware API.
Definition ra8_err.h:546
Injected I2C-bus seam consumed by Ring-3 I2C device drivers.
void(* ra8_touch_event_fn_t)(void *ctx)
Touch-event callback signature.
Definition ra8_touch.h:130
ra8_err_t ra8_touch_close(void)
Tear the driver down and detach any registered handler.
Definition ra8_touch.c:408
ra8_err_t ra8_touch_open(const ra8_touch_cfg_t *cfg)
Bring up the touch IC over the injected I2C bus seam.
Definition ra8_touch.c:387
ra8_err_t ra8_touch_read(ra8_touch_point_t *out_points, uint8_t max_count, uint8_t *got_count)
Drain the current touch frame.
Definition ra8_touch.c:551
void ra8_touch_dispatch_irq(void)
Test-callable IRQ dispatch shim.
Definition ra8_touch.c:434
ra8_err_t ra8_touch_attach_handler(ra8_touch_event_fn_t fn, void *ctx)
Register a touch event callback.
Definition ra8_touch.c:424
ra8_touch_limits_t
Static-allocation caps for the touch driver.
Definition ra8_touch.h:70
@ k_ra8_touch_irq_pin_unset
Sentinel for "no IRQ pin attached".
Definition ra8_touch.h:72
@ k_ra8_touch_max_points
Hard cap (matches GT911 capacity).
Definition ra8_touch.h:71
ra8_err_t ra8_touch_calibrate(void)
Run any backend-specific calibration routine.
Definition ra8_touch.c:566
Caller-filled I2C controller-transfer seam (write / read / write-then-read).
Configuration descriptor for ra8_touch_open.
Definition ra8_touch.h:109
uint8_t max_points
Cap on touches reported (clamped to 5).
Definition ra8_touch.h:114
ra8_i2c_bus_ops_t bus
Injected I2C transfer seam (app-bound).
Definition ra8_touch.h:110
uint8_t target_7b
7-bit GT911 address (0x5D or 0x14).
Definition ra8_touch.h:111
uint8_t irq_pin
IRQ pin 0..31, or k_ra8_touch_irq_pin_unset for polling-only.
Definition ra8_touch.h:112
One decoded touch contact.
Definition ra8_touch.h:93
uint16_t x
Panel X coordinate.
Definition ra8_touch.h:94
uint16_t y
Panel Y coordinate.
Definition ra8_touch.h:95
uint8_t track_id
Persistent contact id (0..15).
Definition ra8_touch.h:96
uint8_t pressure
Approximate pressure / contact-area, 0..255.
Definition ra8_touch.h:97