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

IIC_B (I3C in I2C-only mode) peripheral driver – mirrors FSP r_iic_b_peripheral. More...

#include <stdint.h>
#include "ra8_err.h"
Include dependency graph for ra8_i3c_i2c_peripheral.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Data Structures

struct  ra8_i3c_i2c_peripheral_cfg_t
 Configuration descriptor for ra8_i3c_i2c_peripheral_open. More...

Enumerations

enum  ra8_i3c_i2c_peripheral_status_t : uint8_t {
  k_ra8_i3c_i2c_peripheral_status_idle = 0x00U ,
  k_ra8_i3c_i2c_peripheral_status_aas = 0x01U ,
  k_ra8_i3c_i2c_peripheral_status_rx_full = 0x02U ,
  k_ra8_i3c_i2c_peripheral_status_tx_empty = 0x04U ,
  k_ra8_i3c_i2c_peripheral_status_stop = 0x08U ,
  k_ra8_i3c_i2c_peripheral_status_nack = 0x10U
}
 Peripheral-side status mask. More...

Functions

ra8_err_t ra8_i3c_i2c_peripheral_open (uint8_t channel, const ra8_i3c_i2c_peripheral_cfg_t *cfg)
 Open a channel as an IIC_B peripheral.
ra8_err_t ra8_i3c_i2c_peripheral_close (uint8_t channel)
 Close the peripheral channel.
ra8_err_t ra8_i3c_i2c_peripheral_send (uint8_t channel, const uint8_t *data, uint32_t len)
 Push len bytes into NTDTBP0 in response to a controller-read.
ra8_err_t ra8_i3c_i2c_peripheral_receive (uint8_t channel, uint8_t *buf, uint32_t len)
 Drain len bytes from NTDTBP0 after a controller-write.
ra8_err_t ra8_i3c_i2c_peripheral_status (uint8_t channel, uint8_t *out_mask)
 Read latched peripheral-side status mask.

Detailed Description

IIC_B (I3C in I2C-only mode) peripheral driver – mirrors FSP r_iic_b_peripheral.

Tag
[Ring 3 / HAL] {World: NS}

Peripheral-side companion to ra8_i3c_i2c (controller). The IIC_B block is documented in HUM Ch 40 "I3C Bus Interface (I3C)" pages 2445..2701. In peripheral mode the host bus controller addresses this device via its 7-bit MTAR / SDA address; matching transactions raise NTST.RDBFF0 / TDBEF0 and the polling helpers below drain or refill NTDTBP0 accordingly.

Public surface (mirrors FSP R_IIC_B_PERIPHERAL_*):

Definition in file ra8_i3c_i2c_peripheral.h.

Enumeration Type Documentation

◆ ra8_i3c_i2c_peripheral_status_t

Peripheral-side status mask.

Enumerator
k_ra8_i3c_i2c_peripheral_status_idle 

No latched event.

k_ra8_i3c_i2c_peripheral_status_aas 

Address matched.

k_ra8_i3c_i2c_peripheral_status_rx_full 

NTST.RDBFF0 set.

k_ra8_i3c_i2c_peripheral_status_tx_empty 

NTST.TDBEF0 set.

k_ra8_i3c_i2c_peripheral_status_stop 

BST.SPCNDDF set.

k_ra8_i3c_i2c_peripheral_status_nack 

BST.NACKDF set.

Definition at line 60 of file ra8_i3c_i2c_peripheral.h.

Function Documentation

◆ ra8_i3c_i2c_peripheral_close()

ra8_err_t ra8_i3c_i2c_peripheral_close ( uint8_t channel)
nodiscard

Close the peripheral channel.

Parameters
[in]channelChannel index.
Returns
ra8_err_t.
Return values
k_ra8_okChannel torn down.
k_ra8_err_invalid_argChannel out of range.
Since
0.1.0

Definition at line 124 of file ra8_i3c_i2c_peripheral.c.

References r_i3c_i2c_regs_t::BCTL, i3c_i2c_regs(), k_ra8_err_invalid_arg, k_ra8_mstp_i3c, r_i3c_i2c_regs_t::MSDVAD, ra8_mstp_disable(), and r_i3c_i2c_regs_t::SVCTL.

Referenced by ra8_i3c_peripheral_close().

◆ ra8_i3c_i2c_peripheral_open()

ra8_err_t ra8_i3c_i2c_peripheral_open ( uint8_t channel,
const ra8_i3c_i2c_peripheral_cfg_t * cfg )
nodiscard

◆ ra8_i3c_i2c_peripheral_receive()

ra8_err_t ra8_i3c_i2c_peripheral_receive ( uint8_t channel,
uint8_t * buf,
uint32_t len )
nodiscard

Drain len bytes from NTDTBP0 after a controller-write.

Parameters
[in]channelChannel index.
[out]bufDestination buffer (non-NULL when len > 0).
[in]lenByte count.
Returns
ra8_err_t.
Return values
k_ra8_okAll bytes consumed.
k_ra8_err_null_ptrbuf is NULL with non-zero len.
k_ra8_err_invalid_argChannel out of range.
k_ra8_err_hw_timeoutRDBFF0 wait exhausted spin budget.
Since
0.1.0

Definition at line 157 of file ra8_i3c_i2c_peripheral.c.

References i3c_i2c_regs(), internal_wait_ntst(), k_ra8_err_invalid_arg, k_ra8_err_null_ptr, k_ra8_i3c_i2c_peripheral_byte_mask, k_ra8_i3c_i2c_peripheral_msk_ntst_rdbff0, k_ra8_ok, r_i3c_i2c_regs_t::NTDTBP0, ra8_log_error, RA8_RETURN_ON_ERROR, and s_tag.

Referenced by ra8_i3c_peripheral_receive().

◆ ra8_i3c_i2c_peripheral_send()

ra8_err_t ra8_i3c_i2c_peripheral_send ( uint8_t channel,
const uint8_t * data,
uint32_t len )
nodiscard

Push len bytes into NTDTBP0 in response to a controller-read.

Parameters
[in]channelChannel index.
[in]dataBuffer (non-NULL when len > 0).
[in]lenByte count.
Returns
ra8_err_t.
Return values
k_ra8_okAll bytes loaded.
k_ra8_err_null_ptrdata is NULL with non-zero len.
k_ra8_err_invalid_argChannel out of range.
k_ra8_err_hw_timeoutTDBEF0 wait exhausted spin budget.
Since
0.1.0

Definition at line 138 of file ra8_i3c_i2c_peripheral.c.

References i3c_i2c_regs(), internal_wait_ntst(), k_ra8_err_invalid_arg, k_ra8_err_null_ptr, k_ra8_i3c_i2c_peripheral_msk_ntst_tdbef0, k_ra8_ok, r_i3c_i2c_regs_t::NTDTBP0, ra8_log_error, RA8_RETURN_ON_ERROR, and s_tag.

Referenced by ra8_i3c_peripheral_send().

◆ ra8_i3c_i2c_peripheral_status()

ra8_err_t ra8_i3c_i2c_peripheral_status ( uint8_t channel,
uint8_t * out_mask )
nodiscard