|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
SMBus 3.2 protocol-layer demo + HIL over IIC_B (#128). More...
#include <stddef.h>#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_bus_ops.h"#include "ra8_i3c.h"#include "ra8_io_i2c_bus.h"#include "ra8_io_i2c_bus_i3c_compat.h"#include "ra8_isr.h"#include "ra8_mstp.h"#include "ra8_port_utils.h"#include "ra8_smbus.h"#include "ra8_time.h"Go to the source code of this file.
Enumerations | |
| enum | sd_consts_t : uint32_t { k_sd_uart_baud = 115200U , k_sd_bus_hz = 100000U , k_sd_iic_chan = (uint32_t)k_ra8_board_mikrobus_iic_b_channel , k_sd_lsm_addr = 0x6BU , k_sd_reg_whoami = 0x0FU , k_sd_whoami_val = 0x6CU , k_sd_hex_shift = 4U , k_sd_hex_mask = 0x0FU , k_sd_dec_ten = 10U } |
| Console / bus / device knobs (no magic numbers). More... | |
Functions | |
| static void | sd_print (const uint8_t *msg, uint32_t len) |
| Emit a byte run on the SCI8 console. | |
| static void | sd_panic_halt (const uint8_t *msg, uint32_t len) |
| Print the fail banner and trap (ra8_emulator halts on the BKPT). | |
| static void | sd_print_hex8 (uint8_t value) |
| Print one byte as two upper-case hex digits. | |
| static ra8_err_t | sd_pins_init (void) |
| Route the MikroBUS IIC SCL/SDA via PFS. | |
| static void | sd_setup_or_halt (uint32_t *out_pclka_hz) |
| Bring up clocks/MSTP/time + the SCI8 console; halt on failure. | |
| static void | sd_read_whoami_or_halt (uint8_t *out_a, uint8_t *out_b) |
| Read WHO_AM_I two ways over SMBus; halt on any failure. | |
| void | main (void) |
| App entry: bring up SMBus, read WHO_AM_I two ways, print the banner. | |
Variables | |
| static const ra8_port_pin_t | k_sd_pin_scl = (ra8_port_pin_t)k_ra8_board_mikrobus_i2c_scl |
| MikroBUS SCL routed through the Pmod1 I2C side (SCL1). | |
| static const ra8_port_pin_t | k_sd_pin_sda = (ra8_port_pin_t)k_ra8_board_mikrobus_i2c_sda |
| MikroBUS SDA routed through the Pmod1 I2C side (SDA1). | |
| static ra8_io_i2c_bus_t | s_sd_bus |
| Bound I2C bus handle the SMBus layer's injected seam points at. | |
| static const uint8_t | k_msg_boot [] = "smbus-demo: boot\r\n" |
| static const uint8_t | k_msg_fail [] = "smbus-demo: FAIL init\r\n" |
| static const uint8_t | k_msg_open [] = "smbus: FAIL open\r\n" |
| static const uint8_t | k_msg_nak [] = "smbus: NAK (no LSM6DSO)\r\n" |
| static const uint8_t | k_msg_bad [] = "smbus: mismatch\r\n" |
| static const uint8_t | k_msg_pre [] = "smbus: whoami=" |
| static const uint8_t | k_msg_mid [] = " sendrecv=" |
| static const uint8_t | k_msg_ok [] = " PASS\r\n" |
SMBus 3.2 protocol-layer demo + HIL over IIC_B (#128).
ra8_smbus is the SMBus 3.2 protocol layer on top of the IIC_B (I3C-in- I2C-mode) controller – it frames Send Byte / Receive Byte / Read Byte Data / ... transactions and delegates the raw byte movement to ra8_i3c. It had no example and no CI gate. This app is that gate: it drives real SMBus byte transactions against an I2C register-file device and checks the decoded bytes.
The target is the ST LSM6DSO 6-DoF IMU (MikroBUS / IMU 12 Click on the Pmod1 I2C side, 7-bit address 0x6B) – a plain register-indexed I2C device, so it answers the SMBus byte protocols natively (SMBus is electrically I2C). Two independent reads of the WHO_AM_I register (0x0F, fixed 0x6C) exercise three protocol shapes:
smbus: whoami=6C sendrecv=6C PASS
Under ra8_emulator the modelled LSM6DSO answers on the modelled IIC_B bus, so the banner is deterministic; on the bench it needs the IMU 12 Click fitted (same prerequisite as imu_lsm6dso_demo).
[Ring 7 / App] {World: NS}
Definition in file main.c.
| enum sd_consts_t : uint32_t |
Console / bus / device knobs (no magic numbers).
| void main | ( | void | ) |
App entry: bring up SMBus, read WHO_AM_I two ways, print the banner.
The application entry point Reset_Handler hands control to.
Definition at line 194 of file main.c.
References k_msg_boot, k_msg_mid, k_msg_ok, k_msg_open, k_msg_pre, k_ra8_i3c_mode_i2c, k_ra8_ok, k_sd_bus_hz, k_sd_iic_chan, ra8_i3c_init(), ra8_io_i2c_bus_as_ops(), ra8_io_i2c_bus_bind_i3c_compat(), ra8_isr_globals_enable(), ra8_smbus_init(), s_sd_bus, sd_panic_halt(), sd_print(), sd_print_hex8(), sd_read_whoami_or_halt(), and sd_setup_or_halt().
|
static |
Print the fail banner and trap (ra8_emulator halts on the BKPT).
Definition at line 103 of file main.c.
References sd_print().
Referenced by main(), sd_read_whoami_or_halt(), and sd_setup_or_halt().
|
staticnodiscard |
Route the MikroBUS IIC SCL/SDA via PFS.
Definition at line 124 of file main.c.
References k_ra8_err_hw_init_failed, k_ra8_ok, k_ra8_psel_iic, k_sd_pin_scl, k_sd_pin_sda, and ra8_pfs_route_peripheral().
Referenced by sd_setup_or_halt().
|
static |
Emit a byte run on the SCI8 console.
Definition at line 97 of file main.c.
References ra8_board_uart_console_write().
Referenced by main(), sd_panic_halt(), and sd_print_hex8().
|
static |
Print one byte as two upper-case hex digits.
Definition at line 113 of file main.c.
References k_sd_dec_ten, k_sd_hex_mask, k_sd_hex_shift, and sd_print().
Referenced by main().
|
static |
Read WHO_AM_I two ways over SMBus; halt on any failure.
(1) Read Byte Data(0x0F) -> a, (2) Send Byte(0x0F) then Receive Byte -> b. Both must equal 0x6C. A NAK (no IMU fitted) prints the NAK banner; a wrong value prints the mismatch banner; either halts on a BKPT before the PASS line so the gate is exact.
| [out] | out_a | Receives the Read-Byte-Data WHO_AM_I. |
| [out] | out_b | Receives the Send-Byte + Receive-Byte WHO_AM_I. |
Definition at line 166 of file main.c.
References k_msg_bad, k_msg_nak, k_ra8_ok, k_sd_lsm_addr, k_sd_reg_whoami, k_sd_whoami_val, ra8_smbus_read_byte_data(), ra8_smbus_receive_byte(), ra8_smbus_send_byte(), and sd_panic_halt().
Referenced by main().
|
static |
Bring up clocks/MSTP/time + the SCI8 console; halt on failure.
Definition at line 133 of file main.c.
References k_msg_fail, k_ra8_clock_id_cpuclk0, k_ra8_clock_id_pclka, k_ra8_ok, k_sd_uart_baud, ra8_board_uart_console_init(), ra8_cgc_get_clock_hz(), ra8_cgc_init(), ra8_mstp_init(), ra8_time_init(), sd_panic_halt(), and sd_pins_init().
Referenced by main().
|
static |
Definition at line 91 of file main.c.
Referenced by sd_read_whoami_or_halt().
|
static |
|
static |
|
static |
|
static |
MikroBUS SCL routed through the Pmod1 I2C side (SCL1).
Definition at line 70 of file main.c.
Referenced by sd_pins_init().
|
static |
MikroBUS SDA routed through the Pmod1 I2C side (SDA1).
Definition at line 72 of file main.c.
Referenced by sd_pins_init().
|
static |
Bound I2C bus handle the SMBus layer's injected seam points at.
File-scope because the seam's ctx references it for the whole run.
Definition at line 85 of file main.c.
Referenced by main().