|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
IIC_B (I3C unified IP) control-plane + diagnostics implementation. More...
#include <stdint.h>#include "ra8_attributes.h"#include "ra8_check.h"#include "ra8_err.h"#include "ra8_hw_err.h"#include "ra8_i3c_i2c.h"#include "ra8_i3c_i2c_internal.h"#include "ra8_i3c_i2c_regs.h"Go to the source code of this file.
Enumerations | |
| enum | internal_i3c_i2c_control_t : uint32_t { k_ra8_i3c_i2c_ctrl_poll_limit = 200000U , k_ra8_i3c_i2c_ctrl_addr_shift = 1U , k_ra8_i3c_i2c_ctrl_addr_rw_write = 0U } |
| Implementation constants for the control-plane TU. More... | |
Functions | |
| static uint8_t | internal_i3c_i2c_decode_errors (uint32_t bst) |
| Decode latched BST error bits into a k_ra8_i3c_i2c_err_* mask. | |
| ra8_err_t | ra8_i3c_i2c_abort (uint8_t channel) |
| Cancel any in-flight transaction and return the channel to idle. | |
| ra8_err_t | ra8_i3c_i2c_scan (uint8_t channel, uint8_t target_7b, bool *out_acked) |
| Probe whether a 7-bit address ACKs. | |
| ra8_err_t | ra8_i3c_i2c_get_errors (uint8_t channel, uint8_t *out_mask) |
| Read latched error flags from BST (AL / NACKDF / TODF). | |
| ra8_err_t | ra8_i3c_i2c_clear_errors (uint8_t channel) |
| Clear latched error flags in BST. | |
| ra8_err_t | ra8_i3c_i2c_attach_handler (uint8_t channel, ra8_i3c_i2c_complete_fn_t fn, void *ctx) |
| Attach a completion / error callback for the channel. | |
| void | ra8_i3c_i2c_dispatch_eri (uint8_t channel) |
| Dispatch the bus-error IRQ source. | |
Variables | |
| static const char * | s_tag = "IIC_B" |
| Log tag for this driver's control-plane TU. | |
IIC_B (I3C unified IP) control-plane + diagnostics implementation.
Control-plane companion translation unit to ra8_i3c_i2c.c. Holds the non-data-path operations of the polling IIC_B driver:
These functions share the s_iic_b_state channel table and the promoted START / STOP / clear-BST / send-address helpers with the transaction engine in ra8_i3c_i2c.c via ra8_i3c_i2c_internal.h. Each TU keeps its own read-only s_tag log-tag copy.
Owns its writes to the I3C register block. See HUM Ch 40 "I3C Bus Interface (I3C)", p 2445-2701.
Definition in file ra8_i3c_i2c_control.c.
| enum internal_i3c_i2c_control_t : uint32_t |
Implementation constants for the control-plane TU.
Definition at line 51 of file ra8_i3c_i2c_control.c.
|
static |
Decode latched BST error bits into a k_ra8_i3c_i2c_err_* mask.
See the matching header declaration for the full contract; this site adds no behaviour beyond what the public API documents.
| [in] | bst | See header declaration for direction and constraints. |
| k_ra8_ok | Success path. |
| k_ra8_err_invalid_arg | Caller violated a precondition. |
Definition at line 79 of file ra8_i3c_i2c_control.c.
References k_ra8_i3c_i2c_err_arb_lost, k_ra8_i3c_i2c_err_nack, k_ra8_i3c_i2c_err_none, k_ra8_i3c_i2c_err_timeout, k_ra8_i3c_i2c_msk_bst_alf, k_ra8_i3c_i2c_msk_bst_nackdf, k_ra8_i3c_i2c_msk_bst_todf, and RA8_INTERNAL.
Referenced by ra8_i3c_i2c_get_errors().
|
nodiscard |
Cancel any in-flight transaction and return the channel to idle.
Mirrors FSP's R_IIC_B_MASTER_Abort controller abort-sequence helper for the polling driver. Steps:
| [in] | channel | Channel index. |
| k_ra8_ok | Abort issued. |
| k_ra8_err_invalid_arg | Channel out of range. |
Definition at line 99 of file ra8_i3c_i2c_control.c.
References r_i3c_i2c_regs_t::BIE, i3c_i2c_regs(), k_ra8_err_invalid_arg, k_ra8_ok, r_i3c_i2c_regs_t::NTIE, priv_i3c_i2c_clear_bst(), priv_i3c_i2c_stop(), and s_iic_b_state.
Referenced by ra8_i3c_abort().
|
nodiscard |
Attach a completion / error callback for the channel.
| [in] | channel | Channel index. |
| [in] | fn | Callback fired from the dispatch helpers, or NULL to detach. |
| [in] | ctx | Context pointer passed to the callback. |
| k_ra8_ok | Callback registered. |
| k_ra8_err_invalid_arg | Channel out of range. |
Definition at line 201 of file ra8_i3c_i2c_control.c.
References r_i3c_i2c_regs_t::BIE, i3c_i2c_regs(), k_ra8_err_invalid_arg, k_ra8_i3c_i2c_msk_bie_alie, k_ra8_i3c_i2c_msk_bie_nackdie, k_ra8_i3c_i2c_msk_bie_tendie, k_ra8_i3c_i2c_msk_bie_todie, k_ra8_i3c_i2c_msk_ntie_rdbfie0, k_ra8_i3c_i2c_msk_ntie_tdbeie0, k_ra8_ok, r_i3c_i2c_regs_t::NTIE, and s_iic_b_state.
|
nodiscard |
Clear latched error flags in BST.
| [in] | channel | Channel index. |
| k_ra8_ok | Error bits W0C cleared. |
| k_ra8_err_invalid_arg | Channel out of range. |
< RA8 I3C I2C error clear mask.
Definition at line 181 of file ra8_i3c_i2c_control.c.
References r_i3c_i2c_regs_t::BST, i3c_i2c_regs(), k_ra8_err_invalid_arg, k_ra8_i3c_i2c_msk_bst_alf, k_ra8_i3c_i2c_msk_bst_nackdf, k_ra8_i3c_i2c_msk_bst_todf, and k_ra8_ok.
Referenced by ra8_i3c_clear_errors(), ra8_i3c_dispatch(), and ra8_i3c_i2c_dispatch_eri().
| void ra8_i3c_i2c_dispatch_eri | ( | uint8_t | channel | ) |
Dispatch the bus-error IRQ source.
Test-callable shim that mirrors the ERI handler in FSP's r_iic_b_master: it samples BST, masks the latched error bits back to k_ra8_i3c_i2c_err_*, clears them, and fires the registered callback with that mask if it is non-zero.
| [in] | channel | Channel index. |
Definition at line 228 of file ra8_i3c_i2c_control.c.
References k_ra8_i3c_i2c_channel_count, priv_i3c_i2c_should_dispatch(), ra8_i3c_i2c_clear_errors(), ra8_i3c_i2c_get_errors(), and s_iic_b_state.
|
nodiscard |
Read latched error flags from BST (AL / NACKDF / TODF).
| [in] | channel | Channel index. |
| [out] | out_mask | OR of k_ra8_i3c_i2c_err_* bits. |
| k_ra8_ok | out_mask populated. |
| k_ra8_err_null_ptr | out_mask is NULL. |
| k_ra8_err_invalid_arg | channel out of range. |
Definition at line 170 of file ra8_i3c_i2c_control.c.
References r_i3c_i2c_regs_t::BST, i3c_i2c_regs(), internal_i3c_i2c_decode_errors(), k_ra8_err_invalid_arg, k_ra8_ok, RA8_CHECK_NULL_PTR, and s_tag.
Referenced by ra8_i3c_dispatch(), ra8_i3c_get_errors(), and ra8_i3c_i2c_dispatch_eri().
|
nodiscard |
Probe whether a 7-bit address ACKs.
Issues START, writes the address byte, waits for the ACK / NACK status, and issues STOP. Equivalent to a single i2cdetect sweep entry.
| [in] | channel | Channel index. |
| [in] | target_7b | 7-bit peripheral address. |
| [out] | out_acked | Set to true when the peripheral ACKs, false on NACK. |
| k_ra8_ok | Probe completed (ACK or NACK). |
| k_ra8_err_null_ptr | out_acked is NULL or channel invalid. |
| k_ra8_err_hw_timeout | Status poll timed out. |
Definition at line 122 of file ra8_i3c_i2c_control.c.
References r_i3c_i2c_regs_t::BST, i3c_i2c_regs(), k_ra8_err_hw_timeout, k_ra8_i3c_i2c_ctrl_addr_rw_write, k_ra8_i3c_i2c_ctrl_addr_shift, k_ra8_i3c_i2c_ctrl_poll_limit, k_ra8_i3c_i2c_msk_bst_nackdf, k_ra8_i3c_i2c_msk_bst_tendf, k_ra8_ok, priv_i3c_i2c_clear_bst(), priv_i3c_i2c_send_address(), priv_i3c_i2c_start(), priv_i3c_i2c_stop(), RA8_CHECK_NULL_PTR, and s_tag.
Referenced by ra8_i3c_scan().
|
static |
Log tag for this driver's control-plane TU.
Definition at line 45 of file ra8_i3c_i2c_control.c.