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 File Reference

EK-RA8D2 BSP – GoodIX GT911 bring-up on the board's own I2C wiring. More...

#include "ra8_board_ek_ra8d2_touch.h"
#include <stdint.h>
#include "ra8_board_ek_ra8d2.h"
#include "ra8_cgc.h"
#include "ra8_check.h"
#include "ra8_err.h"
#include "ra8_i2c_bus_ops.h"
#include "ra8_i3c.h"
#include "ra8_io_i2c_bus.h"
#include "ra8_io_i2c_bus_i3c_compat.h"
#include "ra8_touch.h"
Include dependency graph for ra8_board_ek_ra8d2_touch.c:

Go to the source code of this file.

Functions

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.

Variables

static const char *const s_tag = "ra8_board.touch"
 Module log tag.
static ra8_io_i2c_bus_t s_touch_bus = {}
 Bound bus handle the touch driver's injected seam points at.

Detailed Description

EK-RA8D2 BSP – GoodIX GT911 bring-up on the board's own I2C wiring.

Tag
[Ring 5 / BSP] {World: S}

Spends the three board facts in ra8_board_touch_wiring_t plus the live PCLKA on the four-call sequence eight applications used to write out by hand. Like the rest of the BSP it touches no MCU registers itself: ra8_i3c owns the IIC_B / I3C citations and ra8_touch owns the GT911 protocol.

Compiled into an application only when it declares ra8_io or ra8_io_bus in LIBS (see cmake/ra8_app/sources.cmake): the bus facade this unit binds through lives in libs/ra8_io.

Since
0.1.0

Definition in file ra8_board_ek_ra8d2_touch.c.

Function Documentation

◆ ra8_board_touch_open()

ra8_err_t ra8_board_touch_open ( const ra8_board_touch_cfg_t * cfg)
nodiscard

Bring the on-board GT911 up and open the touch driver against it.

Reads PCLKA from ra8_cgc_get_clock_hz and initialises the board's I3C channel in I2C-compatibility mode at k_ra8_board_touch_bus_hz against that live rate, binds the channel through the ra8_io_i2c_bus facade, projects it as an ra8_i2c_bus_ops_t, and opens ra8_touch at k_ra8_board_touch_target_7b.

Parameters
[in]cfgApplication-side settings; see ra8_board_touch_cfg_t. Must not be null. max_points must be 0 or at most k_ra8_touch_max_points.
Returns
ra8_err_t Error code.
Return values
k_ra8_okThe GT911 answered and the driver is open.
k_ra8_err_null_ptrcfg was null.
k_ra8_err_invalid_argmax_points exceeds the GT911's capacity.
k_ra8_err_invalid_statera8_touch_open was already called.
k_ra8_err_hw_timeoutThe I3C block did not come out of module stop, or the GT911 did not answer.
k_ra8_err_*Any other code propagated unchanged from ra8_i3c_init or ra8_touch_open.
Precondition
ra8_cgc_init() has run, so PCLKA reflects the application's clock tree rather than the reset default.
SW4-5 selects the I3C routing for P400 / P401 (UM Table 20 p 28), and the Parallel Graphics Expansion Board is fitted.
Postcondition
On success the touch driver is open and ra8_touch_read may be called; the board's I3C channel is initialised in I2C-compat mode.
On any non-ok return the touch driver is left closed. The I3C channel may already have been initialised, which is harmless and idempotent.
Note
Not thread-safe; call once from the single-threaded bring-up path.
Warning
The bus rate is only as accurate as PCLKA at the moment of the call. An application that retunes CGC afterwards must re-open, or call ra8_i3c_set_clock with the new rate.
See also
ra8_board_touch_wiring_t The board facts this call spends.
ra8_touch_read Reading contacts once this has succeeded.
Since
0.1.0

Definition at line 60 of file ra8_board_ek_ra8d2_touch.c.

References ra8_board_touch_cfg_t::irq_pin, k_ra8_board_touch_bus_hz, k_ra8_board_touch_i3c_channel, k_ra8_board_touch_target_7b, k_ra8_clock_id_pclka, k_ra8_err_invalid_arg, k_ra8_i3c_mode_i2c, k_ra8_ok, k_ra8_touch_max_points, ra8_board_touch_cfg_t::max_points, ra8_cgc_get_clock_hz(), RA8_CHECK_NULL_PTR, ra8_i3c_init(), ra8_io_i2c_bus_as_ops(), ra8_io_i2c_bus_bind_i3c_compat(), ra8_touch_open(), s_tag, and s_touch_bus.

Referenced by app_bringup_touch(), cm_bringup_touch(), ez_bringup_touch(), internal_tc_touch_bringup(), main(), mg_bringup_touch(), and sh_input_init().

Variable Documentation

◆ s_tag

const char* const s_tag = "ra8_board.touch"
static

Module log tag.

Definition at line 39 of file ra8_board_ek_ra8d2_touch.c.

◆ s_touch_bus

ra8_io_i2c_bus_t s_touch_bus = {}
static

Bound bus handle the touch driver's injected seam points at.

ra8_touch keeps the ra8_i2c_bus_ops_t it is handed, and those ops carry a pointer back to this handle, so the handle must out-live the open driver. There is one GT911 on one board, so one module-owned handle is the whole requirement – which is what lets ra8_board_touch_open take no bus argument.

Note
Written only by ra8_board_touch_open, from a single-threaded bring-up context.
Warning
Never rebind this while the touch driver is open; the driver would keep issuing transfers through the handle as it changed underneath.
Since
0.1.0

Definition at line 58 of file ra8_board_ek_ra8d2_touch.c.

Referenced by ra8_board_touch_open().