ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
ra8_board_ek_ra8d2_touch.c
Go to the documentation of this file.
1
23
25
26#include <stdint.h>
27
28#include "ra8_board_ek_ra8d2.h"
29#include "ra8_cgc.h"
30#include "ra8_check.h"
31#include "ra8_err.h"
32#include "ra8_i2c_bus_ops.h"
33#include "ra8_i3c.h"
34#include "ra8_io_i2c_bus.h"
36#include "ra8_touch.h"
37
39static const char* const s_tag = "ra8_board.touch";
40
59
61{
62 RA8_CHECK_NULL_PTR(cfg, s_tag, "cfg must not be nullptr");
63 if (cfg->max_points > (uint8_t)k_ra8_touch_max_points) {
65 }
66
67 /* The bit-rate divider is solved against the LIVE PCLKA, not a constant.
68 * Eight copies of this block fed it 60 MHz while the project's CGC tree
69 * publishes 125 MHz, so none of them ran at the 400 kHz they asked for. */
70 uint32_t pclka_hz = 0U;
71 const ra8_err_t clk_err = ra8_cgc_get_clock_hz(k_ra8_clock_id_pclka, &pclka_hz);
72 if (clk_err != k_ra8_ok) { /* GCOVR_EXCL_BR_LINE -- const channel/handle cannot fail post-bind */
73 /* ra8_cgc_get_clock_hz with a valid clock-id and non-null out always
74 * returns k_ra8_ok; kept so a future id change cannot pass silently. */
75 return clk_err; /* GCOVR_EXCL_LINE -- const channel/handle cannot fail post-bind */
76 }
77
78 const ra8_i3c_cfg_t bus_cfg = {
79 .mode = k_ra8_i3c_mode_i2c,
80 .bus_hz = (uint32_t)k_ra8_board_touch_bus_hz,
81 .pclka_hz = pclka_hz,
82 };
83 const ra8_err_t bus_err = ra8_i3c_init((uint8_t)k_ra8_board_touch_i3c_channel, &bus_cfg);
84 if (bus_err != k_ra8_ok) {
85 return bus_err;
86 }
87
88 const ra8_err_t bind_err =
90 if (bind_err != k_ra8_ok) { /* GCOVR_EXCL_BR_LINE -- const channel/handle cannot fail post-bind */
91 /* Rejects only a null handle or an out-of-range channel, and both are
92 * compile-time constants here. */
93 return bind_err; /* GCOVR_EXCL_LINE -- const channel/handle cannot fail post-bind */
94 }
95
96 ra8_i2c_bus_ops_t bus_ops = {};
97 const ra8_err_t ops_err = ra8_io_i2c_bus_as_ops(&s_touch_bus, &bus_ops);
98 if (ops_err != k_ra8_ok) { /* GCOVR_EXCL_BR_LINE -- const channel/handle cannot fail post-bind */
99 /* Rejects only an unbound or null handle; the bind above just succeeded. */
100 return ops_err; /* GCOVR_EXCL_LINE -- const channel/handle cannot fail post-bind */
101 }
102
103 const ra8_touch_cfg_t touch_cfg = {
104 .bus = bus_ops,
105 .target_7b = (uint8_t)k_ra8_board_touch_target_7b,
106 .irq_pin = cfg->irq_pin,
107 .max_points = (cfg->max_points == 0U) ? (uint8_t)k_ra8_touch_max_points : cfg->max_points,
108 };
109 return ra8_touch_open(&touch_cfg);
110}
static const char * s_tag
Logging / check tag.
Definition ra8_app.c:17
Board-support layer for the Renesas EK-RA8D2 v1 evaluation kit.
@ k_ra8_board_touch_target_7b
GT911 default 7-bit target address.
@ k_ra8_board_touch_bus_hz
Fast-mode I2C rate for the touch bus.
@ k_ra8_board_touch_i3c_channel
IIC_B / I3C channel 0 carries the GT911.
static ra8_io_i2c_bus_t s_touch_bus
Bound bus handle the touch driver's injected seam points at.
ra8_err_t ra8_board_touch_open(const ra8_board_touch_cfg_t *cfg)
Bring the on-board GT911 up and open the touch driver against it.
One-call bring-up of the EK-RA8D2 panel's GoodIX GT911 touch controller.
High-level Clock Generation Circuit driver.
ra8_err_t ra8_cgc_get_clock_hz(ra8_clock_id_t id, uint32_t *out_hz)
Query the current frequency of a clock-tree domain.
Definition ra8_cgc.c:132
@ k_ra8_clock_id_pclka
PCLKA.
Definition ra8_cgc.h:73
Validation and Error-Checking Macros for ra8-firmware.
#define RA8_CHECK_NULL_PTR(ptr, tag, message)
Reject nullptr pointer, returning k_ra8_err_null_ptr.
Definition ra8_check.h:243
Error Code Definitions for ra8-firmware.
@ k_ra8_err_invalid_arg
Invalid function argument.
Definition ra8_err.h:152
@ k_ra8_ok
Success – operation completed with all postconditions satisfied.
Definition ra8_err.h:119
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.
I3C Bus Interface driver – unified native-I3C + I2C-compat modes.
@ k_ra8_i3c_mode_i2c
Legacy I2C-compatibility controller.
Definition ra8_i3c.h:69
ra8_err_t ra8_i3c_init(uint8_t channel, const ra8_i3c_cfg_t *cfg)
Initialise an I3C channel in the configured mode.
Definition ra8_i3c.c:311
ra8_io I2C-bus facade – one controller-transfer vtable over thechip's two I2C implementations.
ra8_err_t ra8_io_i2c_bus_as_ops(const ra8_io_i2c_bus_t *bus, ra8_i2c_bus_ops_t *out)
Expose a bound bus through the Ring-3 seam ra8_i2c_bus_ops_t.
I3C I2C-compatibility backend binder for the ra8_io I2C-bus facade.
ra8_err_t ra8_io_i2c_bus_bind_i3c_compat(ra8_io_i2c_bus_t *bus, uint8_t channel)
Bind bus to I3C channel channel in I2C-compatibility mode.
Multi-touch input driver – GoodIX GT911 backend.
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
@ k_ra8_touch_max_points
Hard cap (matches GT911 capacity).
Definition ra8_touch.h:71
The two touch settings that are an APPLICATION choice, not a board fact.
uint8_t irq_pin
Attention pin, or k_ra8_touch_irq_pin_unset for a polled controller.
uint8_t max_points
Cap on reported contacts; 0 selects the board default (the GT911's full k_ra8_touch_max_points capaci...
Caller-filled I2C controller-transfer seam (write / read / write-then-read).
Per-channel bring-up configuration for ra8_i3c_init.
Definition ra8_i3c.h:90
Caller-allocated I2C-bus handle binding a backend to its context.
Configuration descriptor for ra8_touch_open.
Definition ra8_touch.h:109