|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
IIC_B peripheral driver implementation. More...
#include "ra8_i3c_i2c_peripheral.h"#include <stdint.h>#include "ra8_attributes.h"#include "ra8_check.h"#include "ra8_err.h"#include "ra8_i3c_i2c_regs.h"#include "ra8_log.h"#include "ra8_mstp.h"#include "ra8_mstp_regs.h"Go to the source code of this file.
Enumerations | |
| enum | ra8_i3c_i2c_peripheral_internal_t : uint32_t { k_ra8_i3c_i2c_peripheral_spin_budget = 50000U , k_ra8_i3c_i2c_peripheral_max_addr_7b = 0x7FU } |
| Internal tunables. More... | |
| enum | ra8_i3c_i2c_peripheral_bits_t : uint32_t { k_ra8_i3c_i2c_peripheral_msk_ntst_tdbef0 = (uint32_t)(1U << 0U) , k_ra8_i3c_i2c_peripheral_msk_ntst_rdbff0 = (uint32_t)(1U << 1U) , k_ra8_i3c_i2c_peripheral_msk_svctl_gcae = (uint32_t)(1U << 0U) , k_ra8_i3c_i2c_peripheral_msdvad_shift_dvad = 1U , k_ra8_i3c_i2c_peripheral_byte_mask = 0xFFU } |
| Local register-bit positions / masks used by this driver. More... | |
Functions | |
| static ra8_err_t | internal_wait_ntst (volatile const r_i3c_i2c_regs_t *reg, uint32_t mask) |
| Bounded wait until mask bits set in NTST. | |
| 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. | |
Variables | |
| static const char * | s_tag = "IICBP" |
IIC_B peripheral driver implementation.
Polling-mode peripheral companion to ra8_i3c_i2c. Mirrors FSP r_iic_b_peripheral.c:
Citations: HUM Ch 40.2 "I3C / IIC_B Register Reference", pages 2452..2491 (chapter map row 40).
Definition in file ra8_i3c_i2c_peripheral.c.
| enum ra8_i3c_i2c_peripheral_bits_t : uint32_t |
Local register-bit positions / masks used by this driver.
Definition at line 57 of file ra8_i3c_i2c_peripheral.c.
| enum ra8_i3c_i2c_peripheral_internal_t : uint32_t |
Internal tunables.
| Enumerator | |
|---|---|
| k_ra8_i3c_i2c_peripheral_spin_budget | Bounded poll iterations. |
| k_ra8_i3c_i2c_peripheral_max_addr_7b | 7-bit address ceiling. |
Definition at line 48 of file ra8_i3c_i2c_peripheral.c.
|
static |
Bounded wait until mask bits set in NTST.
See the matching header declaration for the full contract; this site adds no behaviour beyond what the public API documents.
| [in] | reg | See header declaration for direction and constraints. |
| [in] | mask | See header declaration for direction and constraints. |
| k_ra8_ok | Success path. |
| k_ra8_err_invalid_arg | Caller violated a precondition. |
Definition at line 83 of file ra8_i3c_i2c_peripheral.c.
References k_ra8_err_hw_timeout, k_ra8_i3c_i2c_peripheral_spin_budget, k_ra8_ok, r_i3c_i2c_regs_t::NTST, and RA8_INTERNAL.
Referenced by ra8_i3c_i2c_peripheral_receive(), and ra8_i3c_i2c_peripheral_send().
|
nodiscard |
Close the peripheral channel.
| [in] | channel | Channel index. |
| k_ra8_ok | Channel torn down. |
| k_ra8_err_invalid_arg | Channel out of range. |
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().
|
nodiscard |
Open a channel as an IIC_B peripheral.
| [in] | channel | Channel index (only 0 valid on RA8D2). |
| [in] | cfg | Configuration descriptor (non-NULL). |
| k_ra8_ok | Channel up; address programmed. |
| k_ra8_err_null_ptr | cfg is NULL. |
| k_ra8_err_invalid_arg | Channel/address out of range. |
Definition at line 94 of file ra8_i3c_i2c_peripheral.c.
References r_i3c_i2c_regs_t::BCTL, ra8_i3c_i2c_peripheral_cfg_t::general_call, i3c_i2c_regs(), k_ra8_err_invalid_arg, k_ra8_i3c_i2c_msk_bctl_buse, k_ra8_i3c_i2c_peripheral_max_addr_7b, k_ra8_i3c_i2c_peripheral_msdvad_shift_dvad, k_ra8_i3c_i2c_peripheral_msk_svctl_gcae, k_ra8_mstp_i3c, k_ra8_ok, r_i3c_i2c_regs_t::MSDVAD, ra8_i3c_i2c_peripheral_cfg_t::peripheral_addr_7b, RA8_CHECK_NULL_PTR, ra8_log_error, ra8_log_info_val, ra8_mstp_enable(), r_i3c_i2c_regs_t::RSTCTL, s_tag, and r_i3c_i2c_regs_t::SVCTL.
Referenced by ra8_i3c_peripheral_open().
|
nodiscard |
Drain len bytes from NTDTBP0 after a controller-write.
| [in] | channel | Channel index. |
| [out] | buf | Destination buffer (non-NULL when len > 0). |
| [in] | len | Byte count. |
| k_ra8_ok | All bytes consumed. |
| k_ra8_err_null_ptr | buf is NULL with non-zero len. |
| k_ra8_err_invalid_arg | Channel out of range. |
| k_ra8_err_hw_timeout | RDBFF0 wait exhausted spin budget. |
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().
|
nodiscard |
Push len bytes into NTDTBP0 in response to a controller-read.
| [in] | channel | Channel index. |
| [in] | data | Buffer (non-NULL when len > 0). |
| [in] | len | Byte count. |
| k_ra8_ok | All bytes loaded. |
| k_ra8_err_null_ptr | data is NULL with non-zero len. |
| k_ra8_err_invalid_arg | Channel out of range. |
| k_ra8_err_hw_timeout | TDBEF0 wait exhausted spin budget. |
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().
|
nodiscard |
Read latched peripheral-side status mask.
| [in] | channel | Channel index. |
| [out] | out_mask | OR of k_ra8_i3c_i2c_peripheral_status_* bits (non-NULL). |
| k_ra8_ok | Snapshot populated. |
| k_ra8_err_null_ptr | out_mask is NULL. |
| k_ra8_err_invalid_arg | Channel out of range. |
Definition at line 176 of file ra8_i3c_i2c_peripheral.c.
References r_i3c_i2c_regs_t::BST, i3c_i2c_regs(), k_ra8_err_invalid_arg, k_ra8_i3c_i2c_msk_bst_nackdf, k_ra8_i3c_i2c_msk_bst_spcnddf, k_ra8_i3c_i2c_peripheral_msk_ntst_rdbff0, k_ra8_i3c_i2c_peripheral_msk_ntst_tdbef0, k_ra8_i3c_i2c_peripheral_status_aas, k_ra8_i3c_i2c_peripheral_status_nack, k_ra8_i3c_i2c_peripheral_status_rx_full, k_ra8_i3c_i2c_peripheral_status_stop, k_ra8_i3c_i2c_peripheral_status_tx_empty, k_ra8_ok, r_i3c_i2c_regs_t::MSDVAD, r_i3c_i2c_regs_t::NTST, RA8_CHECK_NULL_PTR, and s_tag.
Referenced by ra8_i3c_peripheral_status().
|
static |
Definition at line 42 of file ra8_i3c_i2c_peripheral.c.