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

CAN-FD controller peripheral-block model for the board emulator. More...

#include <stdint.h>
#include <stdio.h>
#include <string.h>
#include "board_console.h"
#include "board_periph_block.h"
#include "emu_host_io_internal.h"
Include dependency graph for board_periph_canfd.c:

Go to the source code of this file.

Data Structures

struct  canfd_inst_t
 One CANFD instance: flat register backing store. More...

Enumerations

enum  canfd_map_t : uint64_t {
  k_canfd0_base = 0x40380000UL ,
  k_canfd1_base = 0x40382000UL ,
  k_canfd_span = 0x1920UL ,
  k_canfd_count = 2UL ,
  k_canfd_words = 0x1920UL / 4UL ,
  k_canfd_off_cnctr = 0x004UL ,
  k_canfd_off_cnsts = 0x008UL ,
  k_canfd_off_gctr = 0x018UL ,
  k_canfd_off_gsts = 0x01CUL ,
  k_canfd_off_rfsts0 = 0x044UL ,
  k_canfd_off_rfpctr0 = 0x04CUL ,
  k_canfd_off_tmc0 = 0x070UL ,
  k_canfd_off_tmsts0 = 0x074UL ,
  k_canfd_off_rf0 = 0x520UL ,
  k_canfd_off_tm0 = 0x604UL ,
  k_canfd_frame_words = 0x4CUL / 4UL ,
  k_canfd_off_afl = 0x120UL ,
  k_canfd_afl_stride = 0x10UL ,
  k_canfd_afl_count = 16UL
}
 CANFD block geometry (ra8_canfd_regs.h, FSP R_CANFD_Type). More...
enum  canfd_gsts_t : uint32_t {
  k_gsts_grststs = 1UL << 0U ,
  k_gsts_ghltsts = 1UL << 1U ,
  k_gsts_graminit = 1UL << 3U
}
 Global status (CFDGSTS) bit masks the model drives. More...
enum  canfd_cnsts_t : uint32_t {
  k_cnsts_crstst = 1UL << 0U ,
  k_cnsts_chltst = 1UL << 1U
}
 Channel status (CFDC[0].STS) bit masks the model drives. More...
enum  canfd_id_mask_t : uint32_t {
  k_canfd_id_std = 0x000007FFUL ,
  k_canfd_id_ext = 0x1FFFFFFFUL
}
 Message-ID field masks (CFDRF.ID / CFDTM.ID), for trace + report. More...
enum  canfd_ptr_t : uint32_t {
  k_canfd_ptr_word = 1UL ,
  k_canfd_ptr_dlc_shift = 28UL ,
  k_canfd_ptr_dlc_mask = 0xFUL
}
 CFDTM/CFDRF.PTR frame fields (PTR layout: [15:0] timestamp, [31:28] DLC). More...
enum  canfd_mode_t : uint32_t {
  k_mode_mask = 0x3UL ,
  k_mode_operation = 0x0UL ,
  k_mode_reset = 0x1UL ,
  k_mode_halt = 0x2UL
}
 Global / channel mode-control field (GMDC / CHMDC, bits [1:0]). More...
enum  canfd_rfsts_t : uint32_t {
  k_rfsts_empty = 1UL << 0U ,
  k_rfsts_if = 1UL << 3U
}
 RX FIFO status (CFDRFSTS[0]) bit masks. More...
enum  canfd_tmc_t : uint8_t {
  k_tmc_txreq = 1U << 0U ,
  k_tmsts_done = 0x04U
}
 TX MB control / status byte bits. More...
enum  canfd_elc_event_t : uint16_t { k_event_can0_rxf = 0x33DU }
 CANFD0 RX-FIFO (RXF) ELC event the model pends on loopback delivery. More...

Functions

static RA8_INTERNAL uint32_t internal_canfd_instance (uint64_t addr)
 Resolve an absolute address to its instance index (0/1) or count.
static RA8_INTERNAL uint64_t internal_canfd_offset (uint32_t inst, uint64_t addr)
 In-window byte offset of addr for instance inst.
static RA8_INTERNAL uint32_t internal_canfd_word (uint64_t off)
 Word index into the backing store for an in-window offset.
static RA8_INTERNAL void internal_canfd_apply_global_mode (canfd_inst_t *c, uint32_t gctr)
 Apply a mode-control write to its matching status register bits.
static RA8_INTERNAL void internal_canfd_apply_channel_mode (canfd_inst_t *c, uint32_t ctr)
 Apply a channel mode-control write to its matching status bits.
static RA8_INTERNAL bool internal_canfd_frame_accepted (const canfd_inst_t *c, uint32_t tx_id)
 Decide whether tx_id passes the programmed acceptance filter.
static RA8_INTERNAL void internal_canfd_console_frame (uint32_t inst, uint32_t tx_id, uint32_t dlc, const char *outcome)
 Push a one-line CAN-FD frame summary to the board console CAN lane.
static RA8_INTERNAL void internal_canfd_loopback_deliver (uc_engine *uc, uint32_t inst)
 Copy TX MB 0 into RX FIFO 0 and flag the frame available.
static RA8_INTERNAL uint64_t internal_canfd_read (uc_engine *uc, uint64_t addr, unsigned size)
 MMIO read inside a CANFD window: read back the latched register.
static RA8_INTERNAL void internal_canfd_write (uc_engine *uc, uint64_t addr, unsigned size, uint64_t value)
 Handle a write to a CANFD register with side effects, else latch it.
static RA8_INTERNAL void internal_canfd_reset (void)
 Reset both CANFD instances to a coherent power-on state.
static RA8_INTERNAL void internal_canfd_report (void)
 Print one line per CANFD instance that looped a frame back.
static RA8_INTERNAL void internal_board_periph_canfd_register (void)
 Self-register both CANFD windows before main runs (decentralized).

Variables

static canfd_inst_t s_canfd [k_canfd_count]
static const board_periph_block_t s_k_canfd0_block
 CANFD0 register window + the shared loopback reset / report.
static const board_periph_block_t s_k_canfd1_block
 CANFD1 register window (reset / report handled by the CANFD0 block).

Detailed Description

CAN-FD controller peripheral-block model for the board emulator.

Models the two RA8D2 CANFD instances (ra8_canfd_regs.h / ra8_canfd.c) at 0x40380000 (CANFD0) and 0x40382000 (CANFD1), each a 0x1920-byte channel window, so the internal-loopback demo round-trips a frame instead of timing out in the sparse fallback. Two behaviours are modelled on top of a flat read-back register store:

  • Mode handshakes. The driver (built without RA8_OFF_TARGET for the real cross-compiled .elf) polls the global / channel state machine after each mode write and treats a stuck poll as a timeout. So a write to CFDGCTR.GMDC is reflected into CFDGSTS (reset -> GRSTSTS, halt -> GHLTSTS, operation -> both clear) and a write to CFDC[0].CTR.CHMDC into CFDC[0].STS (reset -> CRSTSTS, halt -> CHLTSTS, operation -> both clear). CFDGSTS powers up with GRAMINIT already clear so the init RAM-ready poll completes.
  • Internal loopback. RX FIFO 0 powers up empty (CFDRFSTS[0].RFEMP = 1). Asserting CFDTMC[0].TMTR (the transmit request) copies the TX message buffer CFDTM[0].{ID,PTR,FDCTR,DF[]} into RX FIFO slot CFDRF[0].{ID,PTR, FDSTS,DF[]}, clears RFEMP (and sets RFIF, the RX-available flag), and marks the TX done (CFDTMSTS[0].TMTRF = 10b). The firmware then polls RFEMP clear, reads the mirrored frame back, and pops it by writing CFDRFPCTR[0] = 0xFF, which re-arms RFEMP. The delivered frame is byte-identical to the transmitted one, so the demo's RX == TX check passes.

Self-registers its descriptor with the board_periph core from a file-scope constructor; the core keeps no central block list – see board_periph_block.h.

Since
0.1.0

Definition in file board_periph_canfd.c.

Enumeration Type Documentation

◆ canfd_cnsts_t

enum canfd_cnsts_t : uint32_t

Channel status (CFDC[0].STS) bit masks the model drives.

Enumerator
k_cnsts_crstst 

Channel reset status.

k_cnsts_chltst 

Channel halt status.

Definition at line 76 of file board_periph_canfd.c.

◆ canfd_elc_event_t

enum canfd_elc_event_t : uint16_t

CANFD0 RX-FIFO (RXF) ELC event the model pends on loopback delivery.

RA8D2 ELC event signal table (HUM Ch 19 Table 19.3) groups the CANFD0 interrupts together; the global RX-FIFO event (CAN0_RXF) is the RX-available interrupt source. The canfd_loopback demo is purely POLLED – it registers no CAN ISR and links no IELSR slot to this event – so pending it is a no-op for that demo and is done only so an interrupt-driven receiver would also be exercised. The numeric value is not verified against a local FSP bsp_elc.h (FSP is not installed here); it is unused on the demo's success path, which rests entirely on the RFEMP / RFIF status modelling above.

Enumerator
k_event_can0_rxf 

CANFD0 RXF RX-FIFO event (best-effort).

Definition at line 127 of file board_periph_canfd.c.

◆ canfd_gsts_t

enum canfd_gsts_t : uint32_t

Global status (CFDGSTS) bit masks the model drives.

Enumerator
k_gsts_grststs 

Global reset status.

k_gsts_ghltsts 

Global halt status.

k_gsts_graminit 

Global RAM-init in progress.

Definition at line 69 of file board_periph_canfd.c.

◆ canfd_id_mask_t

enum canfd_id_mask_t : uint32_t

Message-ID field masks (CFDRF.ID / CFDTM.ID), for trace + report.

Enumerator
k_canfd_id_std 

11-bit standard ID.

k_canfd_id_ext 

29-bit extended ID.

Definition at line 82 of file board_periph_canfd.c.

◆ canfd_map_t

enum canfd_map_t : uint64_t

CANFD block geometry (ra8_canfd_regs.h, FSP R_CANFD_Type).

Enumerator
k_canfd0_base 

CANFD0 channel-window base.

k_canfd1_base 

CANFD1 channel-window base.

k_canfd_span 

Full FSP R_CANFD_Type window size.

k_canfd_count 

CANFD0 / CANFD1.

k_canfd_words 

CANFD words.

k_canfd_off_cnctr 

CFDC[0].CTR channel control.

k_canfd_off_cnsts 

CFDC[0].STS channel status.

k_canfd_off_gctr 

CFDGCTR global control.

k_canfd_off_gsts 

CFDGSTS global status.

k_canfd_off_rfsts0 

CFDRFSTS[0] RX FIFO 0 status.

k_canfd_off_rfpctr0 

CFDRFPCTR[0] RX FIFO 0 pointer ctrl.

k_canfd_off_tmc0 

CFDTMC[0] TX MB 0 control byte.

k_canfd_off_tmsts0 

CFDTMSTS[0] TX MB 0 status byte.

k_canfd_off_rf0 

CFDRF[0] RX FIFO 0 access window.

k_canfd_off_tm0 

CFDTM[0] TX MB 0 access window.

k_canfd_frame_words 

ID+PTR+FDSTS+DF[64] = 19 words.

k_canfd_off_afl 

CFDGAFL[] acceptance-filter window.

k_canfd_afl_stride 

Bytes per CFDGAFL entry (ID/M/P0/P1).

k_canfd_afl_count 

Entries in one CFDGAFL page window.

Definition at line 46 of file board_periph_canfd.c.

◆ canfd_mode_t

enum canfd_mode_t : uint32_t

Global / channel mode-control field (GMDC / CHMDC, bits [1:0]).

Enumerator
k_mode_mask 

2-bit mode field.

k_mode_operation 

Operation mode.

k_mode_reset 

Reset mode.

k_mode_halt 

Halt mode.

Definition at line 95 of file board_periph_canfd.c.

◆ canfd_ptr_t

enum canfd_ptr_t : uint32_t

CFDTM/CFDRF.PTR frame fields (PTR layout: [15:0] timestamp, [31:28] DLC).

Enumerator
k_canfd_ptr_word 

PTR is the 2nd word of a frame window.

k_canfd_ptr_dlc_shift 

DLC occupies PTR bits [31:28].

k_canfd_ptr_dlc_mask 

4-bit DLC code mask (0..15).

Definition at line 88 of file board_periph_canfd.c.

◆ canfd_rfsts_t

enum canfd_rfsts_t : uint32_t

RX FIFO status (CFDRFSTS[0]) bit masks.

Enumerator
k_rfsts_empty 

RFEMP: FIFO empty flag.

k_rfsts_if 

RFIF: RX interrupt flag.

Definition at line 103 of file board_periph_canfd.c.

◆ canfd_tmc_t

enum canfd_tmc_t : uint8_t

TX MB control / status byte bits.

Enumerator
k_tmc_txreq 

CFDTMC.TMTR transmit request.

k_tmsts_done 

CFDTMSTS.TMTRF = 10b complete.

Definition at line 109 of file board_periph_canfd.c.

Function Documentation

◆ internal_board_periph_canfd_register()

RA8_INTERNAL void internal_board_periph_canfd_register ( void )
static

Self-register both CANFD windows before main runs (decentralized).

Definition at line 513 of file board_periph_canfd.c.

References board_periph_register_block(), RA8_INTERNAL, s_k_canfd0_block, and s_k_canfd1_block.

◆ internal_canfd_apply_channel_mode()

RA8_INTERNAL void internal_canfd_apply_channel_mode ( canfd_inst_t * c,
uint32_t ctr )
static

Apply a channel mode-control write to its matching status bits.

Apply a channel mode-control write to its matching status bits; this step is contained within the board periph canfd model and uses bounded caller or module-owned storage.

Parameters
[in,out]cActive controller, card, or command state processed by the operation.
[in]ctrCtr input used by the operation.
Precondition
Arguments satisfy the ranges documented for canfd apply channel mode.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph canfd model and documented output objects.
Ownership of caller-supplied storage is unchanged.
Note
The operation is synchronous and does not transfer heap ownership.
Since
0.1.0

Definition at line 230 of file board_periph_canfd.c.

References internal_canfd_word(), k_canfd_off_cnsts, k_cnsts_chltst, k_cnsts_crstst, k_mode_halt, k_mode_mask, k_mode_reset, RA8_INTERNAL, and canfd_inst_t::reg.

Referenced by internal_canfd_write().

◆ internal_canfd_apply_global_mode()

RA8_INTERNAL void internal_canfd_apply_global_mode ( canfd_inst_t * c,
uint32_t gctr )
static

Apply a mode-control write to its matching status register bits.

Apply a mode-control write to its matching status register bits; this step is contained within the board periph canfd model and uses bounded caller or module-owned storage.

Parameters
[in,out]cActive controller, card, or command state processed by the operation.
[in]gctrGctr input used by the operation.
Precondition
Arguments satisfy the ranges documented for canfd apply global mode.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph canfd model and documented output objects.
Ownership of caller-supplied storage is unchanged.
Note
The operation is synchronous and does not transfer heap ownership.
Since
0.1.0

Definition at line 207 of file board_periph_canfd.c.

References internal_canfd_word(), k_canfd_off_gsts, k_gsts_ghltsts, k_gsts_graminit, k_gsts_grststs, k_mode_halt, k_mode_mask, k_mode_reset, RA8_INTERNAL, and canfd_inst_t::reg.

Referenced by internal_canfd_write().

◆ internal_canfd_console_frame()

RA8_INTERNAL void internal_canfd_console_frame ( uint32_t inst,
uint32_t tx_id,
uint32_t dlc,
const char * outcome )
static

Push a one-line CAN-FD frame summary to the board console CAN lane.

Formats a short, human-readable record of a single transmitted CAN-FD frame – the originating controller instance, the identifier in hex, the 4-bit DLC code, and the outcome note – into a bounded stack buffer and appends it to k_board_console_ch_can via board_console_push. This is the console-tab tap only: it performs no register access and writes nothing to injected output sink/injected error sink, so the smoke/golden output stays byte-identical. It is invoked once per transmit request (one logical CAN frame), never per byte, so the ring does not flood.

Parameters
[in]instCANFD instance index (0 = CANFD0, 1 = CANFD1).
[in]tx_idTransmitted identifier, already masked to 29 bits.
[in]dlc4-bit data-length code from CFDTM.PTR[31:28] (0..15).
[in]outcomeBorrowed NUL-terminated delivery note (e.g. "-> RXF0").
Returns
Nothing.
Precondition
outcome is a valid NUL-terminated string.
inst is a valid CANFD instance index (< k_canfd_count).
Postcondition
Exactly one line is appended to the CAN console lane.
No register, injected output sink, or injected error sink state is modified.
Note
Not thread-safe; ra8_emulator is single-threaded.
Since
0.1.0

< Max chars in a "CANFD<n> TX id=.." line.

Definition at line 308 of file board_periph_canfd.c.

References board_console_push(), and k_board_console_ch_can.

Referenced by internal_canfd_loopback_deliver().

◆ internal_canfd_frame_accepted()

RA8_INTERNAL bool internal_canfd_frame_accepted ( const canfd_inst_t * c,
uint32_t tx_id )
static

Decide whether tx_id passes the programmed acceptance filter.

Scans the CFDGAFL page-0 entry window (the demos use filter ids < one page, so paging does not apply). An entry is active when its mask (CFDGAFL.M) is non-zero; a frame is accepted if it matches any active entry, (tx_id & mask) == (accept_id & mask). With no active entry the filter is open – internal loopback that programs no filters (canfd_loopback) keeps delivering every frame, while canfd_filter_demo's programmed slots drop the non-matching id.

Parameters
[in]cChannel instance whose CFDGAFL window to read.
[in]tx_idTransmitted frame id (29-bit field, IDE/RTR masked off).
Returns
true if the frame is accepted (deliver), false if filtered out.
Return values
trueThe canfd frame accepted condition holds or completed successfully; false otherwise.
Precondition
Arguments satisfy the ranges documented for canfd frame accepted.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph canfd model and documented output objects.
Ownership of caller-supplied storage is unchanged.
Note
The operation is synchronous and does not transfer heap ownership.
Since
0.1.0

Definition at line 264 of file board_periph_canfd.c.

References internal_canfd_word(), k_canfd_afl_count, k_canfd_afl_stride, k_canfd_id_ext, k_canfd_off_afl, RA8_INTERNAL, and canfd_inst_t::reg.

Referenced by internal_canfd_loopback_deliver().

◆ internal_canfd_instance()

RA8_INTERNAL uint32_t internal_canfd_instance ( uint64_t addr)
static

Resolve an absolute address to its instance index (0/1) or count.

Resolve an absolute address to its instance index (0/1) or count; this step is contained within the board periph canfd model and uses bounded caller or module-owned storage.

Parameters
[in]addrGuest address involved in the operation.
Returns
The canfd instance result produced by the board periph canfd model.
Return values
valueThe operation-specific canfd instance value.
Precondition
Arguments satisfy the ranges documented for canfd instance.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph canfd model and documented output objects.
Ownership of caller-supplied storage is unchanged.
Note
The operation is synchronous and does not transfer heap ownership.
Since
0.1.0

Definition at line 150 of file board_periph_canfd.c.

References k_canfd0_base, k_canfd1_base, k_canfd_count, k_canfd_span, and RA8_INTERNAL.

Referenced by internal_canfd_read(), and internal_canfd_write().

◆ internal_canfd_loopback_deliver()

RA8_INTERNAL void internal_canfd_loopback_deliver ( uc_engine * uc,
uint32_t inst )
static

Copy TX MB 0 into RX FIFO 0 and flag the frame available.

Copy tx mb 0 into rx fifo 0 and flag the frame available; this step is contained within the board periph canfd model and uses bounded caller or module-owned storage.

Parameters
[in,out]ucUnicorn engine whose emulated state is read or updated.
[in]instInst input used by the operation.
Precondition
Arguments satisfy the ranges documented for canfd loopback deliver.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph canfd model and documented output objects.
Ownership of caller-supplied storage is unchanged.
Note
The operation is synchronous and does not transfer heap ownership.
Since
0.1.0

Definition at line 328 of file board_periph_canfd.c.

References board_periph_icu_raise_event(), board_periph_trace(), internal_canfd_console_frame(), internal_canfd_frame_accepted(), internal_canfd_word(), k_canfd_frame_words, k_canfd_id_ext, k_canfd_off_rf0, k_canfd_off_rfsts0, k_canfd_off_tm0, k_canfd_off_tmsts0, k_canfd_ptr_dlc_mask, k_canfd_ptr_dlc_shift, k_canfd_ptr_word, k_event_can0_rxf, k_rfsts_empty, k_rfsts_if, k_tmsts_done, canfd_inst_t::loopbacks, priv_emu_io_errf(), RA8_INTERNAL, canfd_inst_t::reg, and s_canfd.

Referenced by internal_canfd_write().

◆ internal_canfd_offset()

RA8_INTERNAL uint64_t internal_canfd_offset ( uint32_t inst,
uint64_t addr )
static

In-window byte offset of addr for instance inst.

In-window byte offset of addr for instance inst; this step is contained within the board periph canfd model and uses bounded caller or module-owned storage.

Parameters
[in]instInst input used by the operation.
[in]addrGuest address involved in the operation.
Returns
The canfd offset result produced by the board periph canfd model.
Return values
valueThe operation-specific canfd offset value.
Precondition
Arguments satisfy the ranges documented for canfd offset.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph canfd model and documented output objects.
Ownership of caller-supplied storage is unchanged.
Note
The operation is synchronous and does not transfer heap ownership.
Since
0.1.0

Definition at line 175 of file board_periph_canfd.c.

References k_canfd0_base, k_canfd1_base, and RA8_INTERNAL.

Referenced by internal_canfd_read(), and internal_canfd_write().

◆ internal_canfd_read()

RA8_INTERNAL uint64_t internal_canfd_read ( uc_engine * uc,
uint64_t addr,
unsigned size )
static

MMIO read inside a CANFD window: read back the latched register.

MMIO read inside a canfd window: read back the latched register; this step is contained within the board periph canfd model and uses bounded caller or module-owned storage.

Parameters
[in,out]ucUnicorn engine whose emulated state is read or updated.
[in]addrGuest address involved in the operation.
[in]sizeSize of the requested region or access in bytes.
Returns
The canfd read result produced by the board periph canfd model.
Return values
valueThe operation-specific canfd read value.
Precondition
Arguments satisfy the ranges documented for canfd read.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph canfd model and documented output objects.
Ownership of caller-supplied storage is unchanged.
Note
The operation is synchronous and does not transfer heap ownership.
Since
0.1.0

Definition at line 382 of file board_periph_canfd.c.

References internal_canfd_instance(), internal_canfd_offset(), internal_canfd_word(), k_canfd_count, k_canfd_span, RA8_INTERNAL, and s_canfd.

◆ internal_canfd_report()

RA8_INTERNAL void internal_canfd_report ( void )
static

Print one line per CANFD instance that looped a frame back.

Print one line per canfd instance that looped a frame back; this step is contained within the board periph canfd model and uses bounded caller or module-owned storage.

Precondition
Arguments satisfy the ranges documented for canfd report.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph canfd model and documented output objects.
Ownership of caller-supplied storage is unchanged.
Note
The operation is synchronous and does not transfer heap ownership.
Since
0.1.0

Definition at line 472 of file board_periph_canfd.c.

References internal_canfd_word(), k_canfd_count, k_canfd_id_std, k_canfd_off_rf0, priv_emu_io_errf(), RA8_INTERNAL, and s_canfd.

◆ internal_canfd_reset()

RA8_INTERNAL void internal_canfd_reset ( void )
static

Reset both CANFD instances to a coherent power-on state.

Reset both canfd instances to a coherent power-on state; this step is contained within the board periph canfd model and uses bounded caller or module-owned storage.

Precondition
Arguments satisfy the ranges documented for canfd reset.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph canfd model and documented output objects.
Ownership of caller-supplied storage is unchanged.
Note
The operation is synchronous and does not transfer heap ownership.
Since
0.1.0

Definition at line 455 of file board_periph_canfd.c.

References internal_canfd_word(), k_canfd_count, k_canfd_off_rfsts0, k_rfsts_empty, memset(), RA8_INTERNAL, and s_canfd.

◆ internal_canfd_word()

RA8_INTERNAL uint32_t internal_canfd_word ( uint64_t off)
static

Word index into the backing store for an in-window offset.

Word index into the backing store for an in-window offset; this step is contained within the board periph canfd model and uses bounded caller or module-owned storage.

Parameters
[in]offRegister or byte offset addressed by the operation.
Returns
The canfd word result produced by the board periph canfd model.
Return values
valueThe operation-specific canfd word value.
Precondition
Arguments satisfy the ranges documented for canfd word.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph canfd model and documented output objects.
Ownership of caller-supplied storage is unchanged.
Note
The operation is synchronous and does not transfer heap ownership.
Since
0.1.0

Definition at line 192 of file board_periph_canfd.c.

References RA8_INTERNAL.

Referenced by internal_canfd_apply_channel_mode(), internal_canfd_apply_global_mode(), internal_canfd_frame_accepted(), internal_canfd_loopback_deliver(), internal_canfd_read(), internal_canfd_report(), internal_canfd_reset(), and internal_canfd_write().

◆ internal_canfd_write()

RA8_INTERNAL void internal_canfd_write ( uc_engine * uc,
uint64_t addr,
unsigned size,
uint64_t value )
static

Handle a write to a CANFD register with side effects, else latch it.

Handle a write to a canfd register with side effects, else latch it; this step is contained within the board periph canfd model and uses bounded caller or module-owned storage.

Parameters
[in,out]ucUnicorn engine whose emulated state is read or updated.
[in]addrGuest address involved in the operation.
[in]sizeSize of the requested region or access in bytes.
[in]valueRegister or payload value involved in the operation.
Precondition
Arguments satisfy the ranges documented for canfd write.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph canfd model and documented output objects.
Ownership of caller-supplied storage is unchanged.
Note
The operation is synchronous and does not transfer heap ownership.
Since
0.1.0

Definition at line 410 of file board_periph_canfd.c.

References internal_canfd_apply_channel_mode(), internal_canfd_apply_global_mode(), internal_canfd_instance(), internal_canfd_loopback_deliver(), internal_canfd_offset(), internal_canfd_word(), k_canfd_count, k_canfd_off_cnctr, k_canfd_off_gctr, k_canfd_off_rfpctr0, k_canfd_off_rfsts0, k_canfd_off_tmc0, k_canfd_span, k_rfsts_empty, k_rfsts_if, k_tmc_txreq, canfd_inst_t::reg, and s_canfd.

Variable Documentation

◆ s_canfd

◆ s_k_canfd0_block

const board_periph_block_t s_k_canfd0_block
static
Initial value:
= {
.base = (uint64_t)k_canfd0_base,
.span = (uint64_t)k_canfd_span,
.order = (uint32_t)k_block_order_i2c,
.tick = nullptr,
.name = "CANFD0",
}
@ k_block_order_i2c
I3C/I2C + GT911 (no tick today).
static RA8_INTERNAL void internal_canfd_report(void)
Print one line per CANFD instance that looped a frame back.
@ k_canfd_span
Full FSP R_CANFD_Type window size.
@ k_canfd0_base
CANFD0 channel-window base.
static RA8_INTERNAL void internal_canfd_write(uc_engine *uc, uint64_t addr, unsigned size, uint64_t value)
Handle a write to a CANFD register with side effects, else latch it.
static RA8_INTERNAL uint64_t internal_canfd_read(uc_engine *uc, uint64_t addr, unsigned size)
MMIO read inside a CANFD window: read back the latched register.
static RA8_INTERNAL void internal_canfd_reset(void)
Reset both CANFD instances to a coherent power-on state.
-proof

CANFD0 register window + the shared loopback reset / report.

Definition at line 487 of file board_periph_canfd.c.

Referenced by internal_board_periph_canfd_register().

◆ s_k_canfd1_block

const board_periph_block_t s_k_canfd1_block
static
Initial value:
= {
.base = (uint64_t)k_canfd1_base,
.span = (uint64_t)k_canfd_span,
.order = (uint32_t)k_block_order_i2c,
.tick = nullptr,
.reset = nullptr,
.report = nullptr,
.name = "CANFD1",
}
@ k_canfd1_base
CANFD1 channel-window base.

CANFD1 register window (reset / report handled by the CANFD0 block).

Definition at line 500 of file board_periph_canfd.c.

Referenced by internal_board_periph_canfd_register().