|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
RIIC (ra8_i2c) target/peripheral responder driven by an external controller. More...
#include <stdint.h>#include "ra8_board_ek_ra8d2.h"#include "ra8_boot_entry.h"#include "ra8_cgc.h"#include "ra8_err.h"#include "ra8_i2c.h"#include "ra8_isr.h"#include "ra8_mstp.h"#include "ra8_time.h"Go to the source code of this file.
Data Structures | |
| struct | riic_target_ctx_t |
| Callback context: the channel and the last controller-write payload. More... | |
Enumerations | |
| enum | riic_target_u32_t : uint32_t { k_riic_target_baud = 115200U , k_riic_target_bus_hz = 100000U } |
| 32-bit app tunables (baud, bus rate). More... | |
| enum | riic_target_u8_t : uint8_t { k_riic_target_channel = 1U , k_riic_target_own_addr = 0x42U , k_riic_target_buf_len = 8U , k_riic_target_seed_byte = 0xA5U , k_riic_target_seed_len = 1U } |
| 8-bit app tunables (channel, own address, buffer, reply). More... | |
Functions | |
| static void | riic_target_panic_halt (void) |
| Park forever after a fatal init failure. | |
| static void | riic_target_on_event (void *vctx, ra8_i2c_peripheral_event_t event) |
| Address-match callback: service the controller-driven transfer. | |
| static void | riic_target_clocks_or_halt (void) |
| Bring CGC + SysTick + MSTP up. | |
| static void | riic_target_setup_or_halt (void) |
| Bring CGC + console + RIIC1 up. | |
| static ra8_err_t | riic_target_arm (riic_target_ctx_t *ctx) |
| Arm the RIIC1 target at 0x42 with a clock-stretched callback. | |
| void | main (void) |
| Application entry. | |
Variables | |
| static const uint8_t | k_riic_target_msg_armed [] = "riic-target: armed 0x42 poll-dispatch\r\n" |
| SCI8 status strings emitted per target event. | |
| static const uint8_t | k_riic_target_msg_rx [] = "riic-target: write serviced\r\n" |
| static const uint8_t | k_riic_target_msg_tx [] = "riic-target: read serviced\r\n" |
RIIC (ra8_i2c) target/peripheral responder driven by an external controller.
Standalone EVM-tier app that exercises the ra8_i2c (RIIC) target (peripheral) role added for issue #189 – the own-address match, the attached-callback dispatch (ra8_i2c_peripheral_attach_handler / ra8_i2c_peripheral_dispatch) and the clock-stretched target TX/RX path.
The RA8D2 answers as an I2C target at 7-bit own address 0x42 on RIIC channel 1 (P512 SCL1 / P511 SDA1 – the board's Grove / Pmod / mikroBUS / Arduino I2C bus, per issue #46). An external I2C controller (a second board running i2c_loopback, a Raspberry Pi i2cset / i2cget, a bench host, ...) drives the bus; a single RA8D2 core cannot both clock a blocking controller transfer and service its own target at once, so the controller lives off-board. The flow:
Hardware: EK-RA8D2 v1 + an external I2C controller wired to RIIC1 (SDA1/SCL1) with bus pull-ups. hw_pending: the on-wire target role is UNVERIFIED on silicon – ra8_emulator models RIIC only as a controller.
Definition in file main.c.
| enum riic_target_u32_t : uint32_t |
| enum riic_target_u8_t : uint8_t |
8-bit app tunables (channel, own address, buffer, reply).
| void main | ( | void | ) |
Application entry.
The application entry point Reset_Handler hands control to.
Arms the RIIC1 target and polls the dispatcher.
Definition at line 239 of file main.c.
References k_ra8_ok, k_riic_target_channel, k_riic_target_msg_armed, k_riic_target_seed_byte, k_riic_target_seed_len, ra8_board_uart_console_write(), ra8_i2c_peripheral_dispatch(), ra8_isr_globals_enable(), riic_target_arm(), riic_target_panic_halt(), riic_target_setup_or_halt(), and s_ctx.
|
staticnodiscard |
Arm the RIIC1 target at 0x42 with a clock-stretched callback.
| [in,out] | ctx | Callback context to register (channel pre-filled). |
| k_ra8_ok | Target armed and the callback attached. |
Definition at line 210 of file main.c.
References k_ra8_err_null_ptr, k_ra8_i2c_peripheral_slot_0, k_ra8_ok, k_riic_target_channel, k_riic_target_own_addr, ra8_i2c_peripheral_attach_handler(), ra8_i2c_peripheral_init(), and riic_target_on_event().
Referenced by main().
|
static |
Bring CGC + SysTick + MSTP up.
Panic-halts on any failure.
Definition at line 152 of file main.c.
References k_ra8_clock_id_cpuclk0, k_ra8_ok, ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_mstp_init(), ra8_time_init(), and riic_target_panic_halt().
Referenced by riic_target_setup_or_halt().
|
static |
Address-match callback: service the controller-driven transfer.
Runs in polled ra8_i2c_peripheral_dispatch context (not an ISR), so the blocking target transfers and console writes here are safe. A controller write is drained into ctx->rx; a controller read is answered by echoing the last captured write (or the seed byte before any write arrives).
| [in] | vctx | Opaque riic_target_ctx_t* context. |
| [in] | event | Decoded target event from the dispatcher. |
Definition at line 121 of file main.c.
References riic_target_ctx_t::channel, k_ra8_board_led1, k_ra8_i2c_peripheral_event_read, k_ra8_i2c_peripheral_event_write, k_riic_target_buf_len, k_riic_target_msg_rx, k_riic_target_msg_tx, ra8_board_led_toggle(), ra8_board_uart_console_write(), ra8_i2c_peripheral_receive(), ra8_i2c_peripheral_transmit(), riic_target_ctx_t::rx, and riic_target_ctx_t::rx_len.
Referenced by riic_target_arm().
|
static |
Park forever after a fatal init failure.
Definition at line 98 of file main.c.
Referenced by main(), riic_target_clocks_or_halt(), and riic_target_setup_or_halt().
|
static |
Bring CGC + console + RIIC1 up.
Panic-halts on any failure.
Reuses the board's bench-validated RIIC1 bring-up (ra8_board_io_expander_apply_project_sw4_defaults) exactly as i2c_loopback does, then brings up LED1.
Definition at line 181 of file main.c.
References k_ra8_board_led1, k_ra8_ok, k_riic_target_baud, ra8_board_io_expander_apply_project_sw4_defaults(), ra8_board_led_init(), ra8_board_uart_console_init(), riic_target_clocks_or_halt(), and riic_target_panic_halt().
Referenced by main().
|
static |
|
static |
Definition at line 88 of file main.c.
Referenced by riic_target_on_event().
|
static |
Definition at line 89 of file main.c.
Referenced by riic_target_on_event().