ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
Loading...
Searching...
No Matches
main.c File Reference

RIIC + I3C(I2C-mode) coexistence self-test for the EK-RA8D2. 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_gpio_constants.h"
#include "ra8_i2c.h"
#include "ra8_i3c.h"
#include "ra8_isr.h"
#include "ra8_mpc.h"
#include "ra8_mstp.h"
#include "ra8_port_utils.h"
#include "ra8_time.h"
Include dependency graph for main.c:

Go to the source code of this file.

Enumerations

enum  combo_const_t : uint32_t {
  k_combo_baud = 115200U ,
  k_combo_period_ms = 1000U ,
  k_combo_bus_hz = 100000U ,
  k_combo_i2c_channel = 1U ,
  k_combo_i3c_channel = 0U
}
 App-wide tunables. More...
enum  combo_byte_t : uint8_t { k_combo_probe_addr = 0x43U }
 Probe address: U15 on RIIC ch1; reused as the I3C scan target. More...

Functions

static void combo_panic_halt (void)
 Park forever after a fatal init failure.
static void combo_clocks_or_halt (uint32_t *out_pclka_hz)
 Bring CGC + SysTick + MSTP up; return PCLKA via out_pclka_hz.
static void combo_pfs_or_halt (void)
 Route I3C ch0 SCL0/SDA0 (open-drain) via PFS.
static void combo_setup_or_halt (void)
 Bring up CGC + console + RIIC(ch1,U15) + I3C(ch0,i2c-mode).
void main (void)
 Application entry.

Variables

static const ra8_port_pin_t k_combo_pin_i3c_scl = (ra8_port_pin_t)k_ra8_board_i3c0_pin_scl
 I3C ch0 pins (P400 SCL0 / P401 SDA0).
static const ra8_port_pin_t k_combo_pin_i3c_sda = (ra8_port_pin_t)k_ra8_board_i3c0_pin_sda
static const uint8_t k_combo_msg_ok [] = "combo: i2c ack=1 i3c initok\r\n"
static const uint8_t k_combo_msg_i2c [] = "combo: i2c ack=0 i3c initok\r\n"
static const uint8_t k_combo_msg_err [] = "combo: i2c ERROR i3c initok\r\n"

Detailed Description

RIIC + I3C(I2C-mode) coexistence self-test for the EK-RA8D2.

Tag
[Ring 6 / APP] {World: S}

Brings up BOTH I2C-capable controllers in one firmware and proves they coexist on real silicon:

  • ra8_i2c (RIIC) channel 1 -> the on-board PI4IOE5V6408 expander (U15) at 0x43 (P512/P511), via the board's validated U15 bring-up. U15 ACKs, so this is a real controller<->device round-trip.
  • ra8_i3c (I3C) channel 0 in I2C-compatibility mode -> the J27 header (P400/P401). No on-board device there, so this is a controller bring-up self-test (init + a scan attempt).

Each second the J-Link console prints a single combined banner; the gate matches combo: i2c ack=1 i3c initok – emitted only when RIIC ACKed U15 AND the I3C controller initialised (init failure panic-halts first).

Since
0.1.0

Definition in file main.c.

Enumeration Type Documentation

◆ combo_byte_t

enum combo_byte_t : uint8_t

Probe address: U15 on RIIC ch1; reused as the I3C scan target.

Enumerator
k_combo_probe_addr 

Combo probe address.

Definition at line 53 of file main.c.

◆ combo_const_t

enum combo_const_t : uint32_t

App-wide tunables.

Enumerator
k_combo_baud 

Combo baud.

k_combo_period_ms 

Combo period ms.

k_combo_bus_hz 

Combo bus Hz.

k_combo_i2c_channel 

RIIC ch1 – U15 (P512/P511).

k_combo_i3c_channel 

I3C ch0 – J27 (P400/P401).

Definition at line 44 of file main.c.

Function Documentation

◆ combo_clocks_or_halt()

void combo_clocks_or_halt ( uint32_t * out_pclka_hz)
static

Bring CGC + SysTick + MSTP up; return PCLKA via out_pclka_hz.

Parameters
[out]out_pclka_hzReceives the live PCLKA frequency.
Precondition
IRQs masked or single-threaded init context.
Postcondition
On success *out_pclka_hz is non-zero and CGC is live.
Since
0.1.0

Definition at line 88 of file main.c.

References combo_panic_halt(), k_ra8_clock_id_cpuclk0, k_ra8_clock_id_pclka, k_ra8_ok, ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_mstp_init(), and ra8_time_init().

Referenced by combo_setup_or_halt().

◆ combo_panic_halt()

void combo_panic_halt ( void )
static

Park forever after a fatal init failure.

Precondition
Called only after a fatal error in boot.
Postcondition
CPU is parked; only a debugger or external reset wakes it.
Since
0.1.0

Definition at line 74 of file main.c.

Referenced by combo_clocks_or_halt(), combo_pfs_or_halt(), combo_setup_or_halt(), and main().

◆ combo_pfs_or_halt()

void combo_pfs_or_halt ( void )
static

Route I3C ch0 SCL0/SDA0 (open-drain) via PFS.

Precondition
ra8_mstp_init already ran so PFS writes land.
Postcondition
Both I3C pins are in their peripheral PSEL on success.
Since
0.1.0

Definition at line 114 of file main.c.

References combo_panic_halt(), k_combo_pin_i3c_scl, k_combo_pin_i3c_sda, k_ra8_ok, k_ra8_pin_0, k_ra8_pin_1, k_ra8_port_4, k_ra8_psel_iic, ra8_mpc_set_open_drain(), and ra8_pfs_route_peripheral().

Referenced by combo_setup_or_halt().

◆ combo_setup_or_halt()

void combo_setup_or_halt ( void )
static

Bring up CGC + console + RIIC(ch1,U15) + I3C(ch0,i2c-mode).

Panic-halts on any fatal init error. RIIC ch1 comes up via the board U15 helper (its own pins/pull-ups); the I3C controller via ra8_i3c_init in I2C-compatibility mode.

Since
0.1.0

Definition at line 137 of file main.c.

References combo_clocks_or_halt(), combo_panic_halt(), combo_pfs_or_halt(), k_combo_baud, k_combo_bus_hz, k_combo_i3c_channel, k_ra8_board_led1, k_ra8_i3c_mode_i2c, k_ra8_ok, ra8_board_io_expander_apply_project_sw4_defaults(), ra8_board_led_init(), ra8_board_uart_console_init(), and ra8_i3c_init().

Referenced by main().

◆ main()

void main ( void )

Application entry.

The application entry point Reset_Handler hands control to.

Brings up both controllers then scans each.

Precondition
Reset_Handler has copied .data and zeroed .bss.
SystemInit has set VTOR, FPU, and priority grouping.
Postcondition
On clean entry the CPU stays in the scan + blink loop forever.
On any HAL hard error the CPU parks.
Since
0.1.0

Definition at line 172 of file main.c.

References combo_panic_halt(), combo_setup_or_halt(), k_combo_i2c_channel, k_combo_i3c_channel, k_combo_msg_err, k_combo_msg_i2c, k_combo_msg_ok, k_combo_period_ms, k_combo_probe_addr, k_ra8_board_led1, k_ra8_ok, ra8_board_led_toggle(), ra8_board_uart_console_write(), ra8_delay_ms(), ra8_i2c_scan(), ra8_i3c_scan(), and ra8_isr_globals_enable().

Variable Documentation

◆ k_combo_msg_err

const uint8_t k_combo_msg_err[] = "combo: i2c ERROR i3c initok\r\n"
static

Definition at line 66 of file main.c.

Referenced by main().

◆ k_combo_msg_i2c

const uint8_t k_combo_msg_i2c[] = "combo: i2c ack=0 i3c initok\r\n"
static

Definition at line 65 of file main.c.

Referenced by main().

◆ k_combo_msg_ok

const uint8_t k_combo_msg_ok[] = "combo: i2c ack=1 i3c initok\r\n"
static

Definition at line 64 of file main.c.

Referenced by main().

◆ k_combo_pin_i3c_scl

const ra8_port_pin_t k_combo_pin_i3c_scl = (ra8_port_pin_t)k_ra8_board_i3c0_pin_scl
static

I3C ch0 pins (P400 SCL0 / P401 SDA0).

RIIC ch1 pins are routed by the board U15 bring-up.

Definition at line 59 of file main.c.

Referenced by combo_pfs_or_halt().

◆ k_combo_pin_i3c_sda

const ra8_port_pin_t k_combo_pin_i3c_sda = (ra8_port_pin_t)k_ra8_board_i3c0_pin_sda
static

Definition at line 60 of file main.c.

Referenced by combo_pfs_or_halt().