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

Realtime Clock (RTC) calendar peripheral-block model for ra8_emulator. More...

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

Go to the source code of this file.

Data Structures

struct  rtc_state_t
 The modelled RTC: a control-register shadow + a binary time mirror. More...

Enumerations

enum  rtc_lit_t : uint32_t {
  k_bcd_base = 10U ,
  k_bcd_shift = 4U ,
  k_nibble_mask = 0x0FU ,
  k_year_mod = 100U ,
  k_year_base = 2000U
}
 BCD packing + calendar constants for the RTC model. More...
enum  rtc_order_t : uint32_t { k_rtc_block_order = 60U }
 Per-tick order slot for the RTC block. More...
enum  rtc_geom_t : uint64_t {
  k_rtc_base = 0x40202000UL ,
  k_rtc_span = 0x80UL
}
 RTC register window geometry (ra8_rtc_regs.h). More...
enum  rtc_off_t : uint64_t {
  k_rtc_off_r64cnt = 0x00UL ,
  k_rtc_off_rseccnt = 0x02UL ,
  k_rtc_off_rmincnt = 0x04UL ,
  k_rtc_off_rhrcnt = 0x06UL ,
  k_rtc_off_rwkcnt = 0x08UL ,
  k_rtc_off_rdaycnt = 0x0AUL ,
  k_rtc_off_rmoncnt = 0x0CUL ,
  k_rtc_off_ryrcnt = 0x0EUL ,
  k_rtc_off_rsecar = 0x10UL ,
  k_rtc_off_rminar = 0x12UL ,
  k_rtc_off_rhrar = 0x14UL ,
  k_rtc_off_rwkar = 0x16UL ,
  k_rtc_off_rdayar = 0x18UL ,
  k_rtc_off_rmonar = 0x1AUL ,
  k_rtc_off_ryrar = 0x1CUL ,
  k_rtc_off_ryraren = 0x1EUL ,
  k_rtc_off_rcr1 = 0x22UL ,
  k_rtc_off_rcr2 = 0x24UL ,
  k_rtc_off_rcr4 = 0x28UL
}
 RTC register byte offsets (subset the driver touches). More...
enum  rtc_bit_t : uint8_t {
  k_rtc_rcr1_aie = 0x01U ,
  k_rtc_rcr1_pie = 0x04U ,
  k_rtc_rcr2_start = 0x01U ,
  k_rtc_alarm_enb = 0x80U ,
  k_rtc_alarm_val = 0x7FU
}
 RCR1 / RCR2 bit masks (ra8_rtc_regs.h, ra8_rtc.h). More...
enum  rtc_calendar_t : uint32_t {
  k_rtc_secs_per_min = 60U ,
  k_rtc_mins_per_hour = 60U ,
  k_rtc_hours_per_day = 24U ,
  k_rtc_days_per_mon = 28U ,
  k_rtc_mons_per_year = 12U ,
  k_rtc_ticks_per_sec = 8U
}
 Calendar moduli + the modelled time:tick ratio. More...
enum  rtc_r64_t : uint8_t { k_rtc_r64_mask = 0x3FU }
 64 Hz counter range (R64CNT is 6 bits). More...
enum  rtc_event_t : uint16_t {
  k_rtc_event_alarm = 0x0BBU ,
  k_rtc_event_periodic = 0x0BCU
}
 RTC alarm / periodic ELC events the model emits (FSP ra8d2 bsp_elc). More...

Functions

static RA8_INTERNAL uint8_t internal_rtc_bin_to_bcd (uint8_t bin)
 Binary 0..99 -> packed BCD.
static RA8_INTERNAL uint8_t internal_rtc_bcd_to_bin (uint8_t bcd)
 Packed BCD -> binary 0..99.
static RA8_INTERNAL void internal_rtc_publish_calendar (void)
 Refresh the BCD calendar shadow registers from the binary mirror.
static RA8_INTERNAL void internal_rtc_latch_calendar (void)
 Load the binary time mirror from a freshly written BCD calendar.
static RA8_INTERNAL uint64_t internal_rtc_read (uc_engine *uc, uint64_t addr, unsigned size)
 Read size bytes little-endian from the RTC shadow at off.
static RA8_INTERNAL bool internal_rtc_is_calendar_off (uint64_t off)
 True iff offset off is a calendar-count register (BCD value).
static RA8_INTERNAL void internal_rtc_write (uc_engine *uc, uint64_t addr, unsigned size, uint64_t value)
 Write size bytes little-endian into the RTC shadow at off.
static RA8_INTERNAL void internal_rtc_advance_one_second (void)
 Advance the binary time mirror by one modelled second.
static RA8_INTERNAL bool internal_rtc_alarm_matches (void)
 True iff the running time matches the armed (ENB) alarm fields.
static RA8_INTERNAL void internal_rtc_raise_events (uc_engine *uc)
 Raise alarm / periodic ELC events for one elapsed modelled second.
static RA8_INTERNAL void internal_rtc_tick (uc_engine *uc)
 Advance the RTC each chunk while running; raise its events.
static RA8_INTERNAL void internal_rtc_reset (void)
 Clear the RTC register shadow and the time mirror.
static RA8_INTERNAL void internal_rtc_report (void)
 Print the RTC's final time and its alarm / periodic event totals.
static RA8_INTERNAL void internal_board_periph_rtc_register (void)
 Self-register the RTC window before main runs (decentralized).

Variables

static rtc_state_t s_rtc
static const board_periph_block_t s_k_rtc_block
 RTC register window + the calendar tick / reset / report.

Detailed Description

Realtime Clock (RTC) calendar peripheral-block model for ra8_emulator.

Models the RA8D2 RTC (ra8_rtc_regs.h, ra8_rtc.c) in 24-hour BCD calendar mode with a real, advancing time base plus the alarm and periodic interrupt sources, so an example such as rtc_alarm (waits for the alarm flag) and rtc_periodic_demo (waits for the alarm-or-periodic flag) run to their log line and the alarm / periodic ELC events actually fire.

Control registers are a faithful shadow so the driver's bring-up poll loops complete deterministically: ra8_rtc_init clears RCR2 then waits for CNTMD to read 0, sets RCR2.HR24 and waits for it to read back, then sets RCR2.START and waits for it; it also clears RCR1 and waits for 0. The model honours every such readback. The driver's status surface is unusual – ra8_rtc_get_status returns RCR1 & (AIE|CIE|PIE), i.e. the enable bits double as the polled "fired" flags – so reflecting RCR1 exactly is what lets the demos' poll loops make progress.

On top of that faithful shadow the model adds genuine RTC behaviour:

  • Time advance. While RCR2.START is set, a binary mirror of the second/minute/hour/day/month/year advances one RTC second every few ticks (a fixed tick:second ratio keeps a multi-second alarm reachable inside the headless chunk budget). Calendar-count reads (RSECCNT..RYRCNT) and R64CNT are produced from that mirror in BCD, so ra8_rtc_get reports a clock that moves – the time register advances, exactly as the verification asks.
  • Alarm match. A write to RSECAR / RMINAR / RHRAR with the ENB bit set arms the alarm; when the running time reaches the armed hh:mm:ss the model latches the alarm and, if RCR1.AIE is set, raises the RTC alarm ELC event through the core's ICU -> NVIC path so an interrupt-driven alarm also fires.
  • Periodic. While RCR1.PIE is set the model raises the RTC periodic ELC event once per modelled second, the coarsest of the RCR1.PES intervals, so a periodic-interrupt firmware path is exercised.

The RTC is a single register window (0x40202000, 0x80 bytes); the block carries a tick that advances the calendar and raises the two events.

Since
0.1.0

Definition in file board_periph_rtc.c.

Enumeration Type Documentation

◆ rtc_bit_t

enum rtc_bit_t : uint8_t

RCR1 / RCR2 bit masks (ra8_rtc_regs.h, ra8_rtc.h).

Enumerator
k_rtc_rcr1_aie 

RCR1.AIE alarm interrupt enable.

k_rtc_rcr1_pie 

RCR1.PIE periodic interrupt enable.

k_rtc_rcr2_start 

RCR2.START 0=stop, 1=run.

k_rtc_alarm_enb 

RxxAR bit7 alarm-field enable.

k_rtc_alarm_val 

RxxAR lower BCD match value.

Definition at line 105 of file board_periph_rtc.c.

◆ rtc_calendar_t

enum rtc_calendar_t : uint32_t

Calendar moduli + the modelled time:tick ratio.

Enumerator
k_rtc_secs_per_min 

Rtc secs per minimum.

k_rtc_mins_per_hour 

Rtc mins per hour.

k_rtc_hours_per_day 

Rtc hours per day.

k_rtc_days_per_mon 

Conservative roll-over (model only).

k_rtc_mons_per_year 

Rtc mons per year.

k_rtc_ticks_per_sec 

Emulation chunks per modelled second.

Definition at line 114 of file board_periph_rtc.c.

◆ rtc_event_t

enum rtc_event_t : uint16_t

RTC alarm / periodic ELC events the model emits (FSP ra8d2 bsp_elc).

The RA8D2 ELC signal table (HUM Ch 19) places the RTC alarm interrupt (RTC_ALM) at 0x0BB and the RTC periodic interrupt (RTC_PRD) at 0x0BC, matching FSP bsp_elc.h. A firmware that routes either through ra8_isr_register writes the same number into an IELSR slot, so the ICU model links the raised event to that slot.

Enumerator
k_rtc_event_alarm 

RTC_ALM alarm-match event.

k_rtc_event_periodic 

RTC_PRD periodic event.

Definition at line 138 of file board_periph_rtc.c.

◆ rtc_geom_t

enum rtc_geom_t : uint64_t

RTC register window geometry (ra8_rtc_regs.h).

Enumerator
k_rtc_base 

RTC block base.

k_rtc_span 

FSP R_RTC_Type size.

Definition at line 76 of file board_periph_rtc.c.

◆ rtc_lit_t

enum rtc_lit_t : uint32_t

BCD packing + calendar constants for the RTC model.

Enumerator
k_bcd_base 

Decimal radix for BCD packing.

k_bcd_shift 

Tens nibble shift.

k_nibble_mask 

Low BCD nibble.

k_year_mod 

Two-digit year wrap.

k_year_base 

Calendar epoch base year.

Definition at line 52 of file board_periph_rtc.c.

◆ rtc_off_t

enum rtc_off_t : uint64_t

RTC register byte offsets (subset the driver touches).

Enumerator
k_rtc_off_r64cnt 

64 Hz counter (read-only).

k_rtc_off_rseccnt 

Second counter (BCD).

k_rtc_off_rmincnt 

Minute counter (BCD).

k_rtc_off_rhrcnt 

Hour counter (BCD).

k_rtc_off_rwkcnt 

Day-of-week counter.

k_rtc_off_rdaycnt 

Day counter (BCD).

k_rtc_off_rmoncnt 

Month counter (BCD).

k_rtc_off_ryrcnt 

Year counter (BCD, 16-bit).

k_rtc_off_rsecar 

Second alarm (BCD + ENB).

k_rtc_off_rminar 

Minute alarm (BCD + ENB).

k_rtc_off_rhrar 

Hour alarm (BCD + ENB).

k_rtc_off_rwkar 

Day-of-week alarm.

k_rtc_off_rdayar 

Day alarm.

k_rtc_off_rmonar 

Month alarm.

k_rtc_off_ryrar 

Year alarm.

k_rtc_off_ryraren 

Year alarm enable.

k_rtc_off_rcr1 

Control 1 (AIE/CIE/PIE, PES).

k_rtc_off_rcr2 

Control 2 (START/RESET/HR24/...).

k_rtc_off_rcr4 

Control 4 (count source / mode).

Definition at line 82 of file board_periph_rtc.c.

◆ rtc_order_t

enum rtc_order_t : uint32_t

Per-tick order slot for the RTC block.

Placed above the existing board_periph_block_order_t slots (gpio 10, timer 20, sci 30, i2c 40) and above the DMAC block, so the RTC ticks and reports after them. Spacing is deliberate; only the relative order matters and the RTC shares no state with another block, so the absolute value is free. A local enum keeps the value typed without editing the shared header the conflict-free rule forbids touching.

Enumerator
k_rtc_block_order 

RTC tick / reset / report order slot.

Definition at line 71 of file board_periph_rtc.c.

◆ rtc_r64_t

enum rtc_r64_t : uint8_t

64 Hz counter range (R64CNT is 6 bits).

Enumerator
k_rtc_r64_mask 

R64CNT counts 0..63.

Definition at line 124 of file board_periph_rtc.c.

Function Documentation

◆ internal_board_periph_rtc_register()

RA8_INTERNAL void internal_board_periph_rtc_register ( void )
static

Self-register the RTC window before main runs (decentralized).

Definition at line 509 of file board_periph_rtc.c.

References board_periph_register_block(), RA8_INTERNAL, and s_k_rtc_block.

◆ internal_rtc_advance_one_second()

RA8_INTERNAL void internal_rtc_advance_one_second ( void )
static

Advance the binary time mirror by one modelled second.

Advance the binary time mirror by one modelled second; this step is contained within the board periph RTC model and uses bounded caller or module-owned storage.

Precondition
Arguments satisfy the ranges documented for RTC advance one second.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph RTC 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 336 of file board_periph_rtc.c.

References k_rtc_days_per_mon, k_rtc_hours_per_day, k_rtc_mins_per_hour, k_rtc_mons_per_year, k_rtc_secs_per_min, RA8_INTERNAL, and s_rtc.

Referenced by internal_rtc_tick().

◆ internal_rtc_alarm_matches()

RA8_INTERNAL bool internal_rtc_alarm_matches ( void )
static

True iff the running time matches the armed (ENB) alarm fields.

True iff the running time matches the armed (enb) alarm fields; this step is contained within the board periph RTC model and uses bounded caller or module-owned storage.

Returns
The RTC alarm matches result produced by the board periph RTC model.
Return values
trueThe RTC alarm matches condition holds or completed successfully; false otherwise.
Precondition
Arguments satisfy the ranges documented for RTC alarm matches.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph RTC 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 376 of file board_periph_rtc.c.

References internal_rtc_bcd_to_bin(), k_rtc_alarm_enb, k_rtc_alarm_val, k_rtc_off_rhrar, k_rtc_off_rminar, k_rtc_off_rsecar, RA8_INTERNAL, and s_rtc.

Referenced by internal_rtc_raise_events().

◆ internal_rtc_bcd_to_bin()

RA8_INTERNAL uint8_t internal_rtc_bcd_to_bin ( uint8_t bcd)
static

Packed BCD -> binary 0..99.

Packed bcd -> binary 0..99; this step is contained within the board periph RTC model and uses bounded caller or module-owned storage.

Parameters
[in]bcdBcd input used by the operation.
Returns
The RTC bcd to bin result produced by the board periph RTC model.
Return values
valueThe operation-specific RTC bcd to bin value.
Precondition
Arguments satisfy the ranges documented for RTC bcd to bin.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph RTC 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 193 of file board_periph_rtc.c.

References k_bcd_base, k_bcd_shift, k_nibble_mask, and RA8_INTERNAL.

Referenced by internal_rtc_alarm_matches(), and internal_rtc_latch_calendar().

◆ internal_rtc_bin_to_bcd()

RA8_INTERNAL uint8_t internal_rtc_bin_to_bcd ( uint8_t bin)
static

Binary 0..99 -> packed BCD.

Binary 0..99 -> packed bcd; this step is contained within the board periph RTC model and uses bounded caller or module-owned storage.

Parameters
[in]binBin input used by the operation.
Returns
The RTC bin to bcd result produced by the board periph RTC model.
Return values
valueThe operation-specific RTC bin to bcd value.
Precondition
Arguments satisfy the ranges documented for RTC bin to bcd.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph RTC 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 176 of file board_periph_rtc.c.

References k_bcd_base, k_bcd_shift, and RA8_INTERNAL.

Referenced by internal_rtc_publish_calendar().

◆ internal_rtc_is_calendar_off()

RA8_INTERNAL bool internal_rtc_is_calendar_off ( uint64_t off)
static

True iff offset off is a calendar-count register (BCD value).

True iff offset off is a calendar-count register (bcd value); this step is contained within the board periph RTC model and uses bounded caller or module-owned storage.

Parameters
[in]offRegister or byte offset addressed by the operation.
Returns
The RTC is calendar off result produced by the board periph RTC model.
Return values
trueThe RTC is calendar off condition holds or completed successfully; false otherwise.
Precondition
Arguments satisfy the ranges documented for RTC is calendar off.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph RTC 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 281 of file board_periph_rtc.c.

References k_rtc_off_rdaycnt, k_rtc_off_rhrcnt, k_rtc_off_rmincnt, k_rtc_off_rmoncnt, k_rtc_off_rseccnt, k_rtc_off_ryrcnt, and RA8_INTERNAL.

Referenced by internal_rtc_write().

◆ internal_rtc_latch_calendar()

RA8_INTERNAL void internal_rtc_latch_calendar ( void )
static

Load the binary time mirror from a freshly written BCD calendar.

Load the binary time mirror from a freshly written bcd calendar; this step is contained within the board periph RTC model and uses bounded caller or module-owned storage.

Precondition
Arguments satisfy the ranges documented for RTC latch calendar.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph RTC 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 228 of file board_periph_rtc.c.

References internal_rtc_bcd_to_bin(), k_rtc_off_rdaycnt, k_rtc_off_rhrcnt, k_rtc_off_rmincnt, k_rtc_off_rmoncnt, k_rtc_off_rseccnt, k_rtc_off_ryrcnt, RA8_INTERNAL, and s_rtc.

Referenced by internal_rtc_write().

◆ internal_rtc_publish_calendar()

RA8_INTERNAL void internal_rtc_publish_calendar ( void )
static

Refresh the BCD calendar shadow registers from the binary mirror.

Refresh the bcd calendar shadow registers from the binary mirror; this step is contained within the board periph RTC model and uses bounded caller or module-owned storage.

Precondition
Arguments satisfy the ranges documented for RTC publish calendar.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph RTC 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 208 of file board_periph_rtc.c.

References internal_rtc_bin_to_bcd(), k_rtc_off_r64cnt, k_rtc_off_rdaycnt, k_rtc_off_rhrcnt, k_rtc_off_rmincnt, k_rtc_off_rmoncnt, k_rtc_off_rseccnt, k_rtc_off_ryrcnt, k_rtc_r64_mask, k_year_mod, RA8_INTERNAL, and s_rtc.

Referenced by internal_rtc_tick().

◆ internal_rtc_raise_events()

RA8_INTERNAL void internal_rtc_raise_events ( uc_engine * uc)
static

Raise alarm / periodic ELC events for one elapsed modelled second.

Raise alarm / periodic elc events for one elapsed modelled second; this step is contained within the board periph RTC model and uses bounded caller or module-owned storage.

Parameters
[in,out]ucUnicorn engine whose emulated state is read or updated.
Precondition
Arguments satisfy the ranges documented for RTC raise events.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph RTC 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 406 of file board_periph_rtc.c.

References board_periph_icu_raise_event(), board_periph_trace(), internal_rtc_alarm_matches(), k_rtc_event_alarm, k_rtc_event_periodic, k_rtc_off_rcr1, k_rtc_rcr1_aie, k_rtc_rcr1_pie, priv_emu_io_errf(), RA8_INTERNAL, and s_rtc.

Referenced by internal_rtc_tick().

◆ internal_rtc_read()

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

Read size bytes little-endian from the RTC shadow at off.

Read size bytes little-endian from the rtc shadow at off; this step is contained within the board periph RTC 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 RTC read result produced by the board periph RTC model.
Return values
valueThe operation-specific RTC read value.
Precondition
Arguments satisfy the ranges documented for RTC read.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph RTC 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 256 of file board_periph_rtc.c.

References k_rtc_base, k_rtc_span, RA8_INTERNAL, and s_rtc.

◆ internal_rtc_report()

RA8_INTERNAL void internal_rtc_report ( void )
static

Print the RTC's final time and its alarm / periodic event totals.

Print the rtc's final time and its alarm / periodic event totals; this step is contained within the board periph RTC model and uses bounded caller or module-owned storage.

Precondition
Arguments satisfy the ranges documented for RTC report.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph RTC 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 479 of file board_periph_rtc.c.

References k_year_base, priv_emu_io_errf(), RA8_INTERNAL, and s_rtc.

◆ internal_rtc_reset()

RA8_INTERNAL void internal_rtc_reset ( void )
static

Clear the RTC register shadow and the time mirror.

Clear the rtc register shadow and the time mirror; this step is contained within the board periph RTC model and uses bounded caller or module-owned storage.

Precondition
Arguments satisfy the ranges documented for RTC reset.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph RTC 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 466 of file board_periph_rtc.c.

References RA8_INTERNAL, and s_rtc.

◆ internal_rtc_tick()

RA8_INTERNAL void internal_rtc_tick ( uc_engine * uc)
static

Advance the RTC each chunk while running; raise its events.

Advance the rtc each chunk while running; raise its events; this step is contained within the board periph RTC model and uses bounded caller or module-owned storage.

Parameters
[in,out]ucUnicorn engine whose emulated state is read or updated.
Precondition
Arguments satisfy the ranges documented for RTC tick.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph RTC 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 436 of file board_periph_rtc.c.

References internal_rtc_advance_one_second(), internal_rtc_publish_calendar(), internal_rtc_raise_events(), k_rtc_off_rcr2, k_rtc_rcr2_start, k_rtc_ticks_per_sec, RA8_INTERNAL, and s_rtc.

◆ internal_rtc_write()

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

Write size bytes little-endian into the RTC shadow at off.

Write size bytes little-endian into the rtc shadow at off; this step is contained within the board periph RTC 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 RTC write.
The call executes on the emulator's single owning thread.
Postcondition
State changes remain confined to the board periph RTC 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 301 of file board_periph_rtc.c.

References internal_rtc_is_calendar_off(), internal_rtc_latch_calendar(), k_rtc_base, k_rtc_span, and s_rtc.

Variable Documentation

◆ s_k_rtc_block

const board_periph_block_t s_k_rtc_block
static
Initial value:
= {
.base = (uint64_t)k_rtc_base,
.span = (uint64_t)k_rtc_span,
.order = (uint32_t)k_rtc_block_order,
.name = "RTC",
}
static RA8_INTERNAL void internal_rtc_reset(void)
Clear the RTC register shadow and the time mirror.
static RA8_INTERNAL void internal_rtc_report(void)
Print the RTC's final time and its alarm / periodic event totals.
static RA8_INTERNAL void internal_rtc_write(uc_engine *uc, uint64_t addr, unsigned size, uint64_t value)
Write size bytes little-endian into the RTC shadow at off.
static RA8_INTERNAL void internal_rtc_tick(uc_engine *uc)
Advance the RTC each chunk while running; raise its events.
@ k_rtc_base
RTC block base.
@ k_rtc_span
FSP R_RTC_Type size.
static RA8_INTERNAL uint64_t internal_rtc_read(uc_engine *uc, uint64_t addr, unsigned size)
Read size bytes little-endian from the RTC shadow at off.
@ k_rtc_block_order
RTC tick / reset / report order slot.
-proof

RTC register window + the calendar tick / reset / report.

Definition at line 496 of file board_periph_rtc.c.

Referenced by internal_board_periph_rtc_register().

◆ s_rtc