52typedef enum : uint32_t {
71typedef enum : uint32_t {
76typedef enum : uint64_t {
82typedef enum : uint64_t {
105typedef enum : uint8_t {
114typedef enum : uint32_t {
124typedef enum : uint8_t {
138typedef enum : uint16_t {
259 const uint64_t off = addr - (uint64_t)
k_rtc_base;
261 for (
unsigned i = 0U; i < size; i++) {
262 const uint64_t b = off + (uint64_t)i;
264 v |= (uint64_t)
s_rtc.reg[b] << (8U * i);
304 const uint64_t off = addr - (uint64_t)
k_rtc_base;
305 bool touched_cal =
false;
306 for (
unsigned i = 0U; i < size; i++) {
307 const uint64_t b = off + (uint64_t)i;
311 s_rtc.reg[b] = (uint8_t)(value >> (8U * i));
394 return sec_ok && min_ok && hr_ok;
447 s_rtc.tick_frac = 0U;
481 if ((
s_rtc.alarms == 0U) && (
s_rtc.periodics == 0U)) {
484 (void)
priv_emu_io_errf(
" RTC : %04u-%02u-%02u %02u:%02u:%02u alarms=%u periodics=%u\n",
Decentralized peripheral-block registry for the board emulator core.
void board_periph_icu_raise_event(uc_engine *uc, uint16_t event)
Raise a peripheral ELC event through the core's ICU -> NVIC path.
void board_periph_register_block(const board_periph_block_t *block)
Register a peripheral block's descriptor with the core registry.
bool board_periph_trace(void)
Whether –trace is active (blocks log transitions when true).
static const board_periph_block_t s_k_rtc_block
RTC register window + the calendar tick / reset / report.
rtc_bit_t
RCR1 / RCR2 bit masks (ra8_rtc_regs.h, ra8_rtc.h).
@ k_rtc_rcr1_pie
RCR1.PIE periodic interrupt enable.
@ k_rtc_rcr1_aie
RCR1.AIE alarm interrupt enable.
@ k_rtc_rcr2_start
RCR2.START 0=stop, 1=run.
@ k_rtc_alarm_val
RxxAR lower BCD match value.
@ k_rtc_alarm_enb
RxxAR bit7 alarm-field enable.
static RA8_INTERNAL bool internal_rtc_is_calendar_off(uint64_t off)
True iff offset off is a calendar-count register (BCD value).
rtc_calendar_t
Calendar moduli + the modelled time:tick ratio.
@ k_rtc_mons_per_year
Rtc mons per year.
@ k_rtc_mins_per_hour
Rtc mins per hour.
@ k_rtc_secs_per_min
Rtc secs per minimum.
@ k_rtc_days_per_mon
Conservative roll-over (model only).
@ k_rtc_ticks_per_sec
Emulation chunks per modelled second.
@ k_rtc_hours_per_day
Rtc hours per day.
static RA8_INTERNAL void internal_rtc_advance_one_second(void)
Advance the binary time mirror by one modelled second.
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.
rtc_r64_t
64 Hz counter range (R64CNT is 6 bits).
@ k_rtc_r64_mask
R64CNT counts 0..63.
rtc_off_t
RTC register byte offsets (subset the driver touches).
@ k_rtc_off_ryrcnt
Year counter (BCD, 16-bit).
@ k_rtc_off_rseccnt
Second counter (BCD).
@ k_rtc_off_ryraren
Year alarm enable.
@ k_rtc_off_rwkcnt
Day-of-week counter.
@ k_rtc_off_ryrar
Year alarm.
@ k_rtc_off_rmincnt
Minute counter (BCD).
@ k_rtc_off_rminar
Minute alarm (BCD + ENB).
@ k_rtc_off_rcr4
Control 4 (count source / mode).
@ k_rtc_off_rhrcnt
Hour counter (BCD).
@ k_rtc_off_rmoncnt
Month counter (BCD).
@ k_rtc_off_rsecar
Second alarm (BCD + ENB).
@ k_rtc_off_rwkar
Day-of-week alarm.
@ k_rtc_off_r64cnt
64 Hz counter (read-only).
@ k_rtc_off_rhrar
Hour alarm (BCD + ENB).
@ k_rtc_off_rdayar
Day alarm.
@ k_rtc_off_rcr1
Control 1 (AIE/CIE/PIE, PES).
@ k_rtc_off_rmonar
Month alarm.
@ k_rtc_off_rcr2
Control 2 (START/RESET/HR24/...).
@ k_rtc_off_rdaycnt
Day counter (BCD).
rtc_lit_t
BCD packing + calendar constants for the RTC model.
@ k_bcd_shift
Tens nibble shift.
@ k_year_base
Calendar epoch base year.
@ k_bcd_base
Decimal radix for BCD packing.
@ k_year_mod
Two-digit year wrap.
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_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_board_periph_rtc_register(void)
Self-register the RTC window before main runs (decentralized).
rtc_event_t
RTC alarm / periodic ELC events the model emits (FSP ra8d2 bsp_elc).
@ k_rtc_event_alarm
RTC_ALM alarm-match event.
@ k_rtc_event_periodic
RTC_PRD periodic event.
static RA8_INTERNAL uint8_t internal_rtc_bin_to_bcd(uint8_t bin)
Binary 0..99 -> packed BCD.
static RA8_INTERNAL void internal_rtc_latch_calendar(void)
Load the binary time mirror from a freshly written BCD calendar.
static RA8_INTERNAL uint8_t internal_rtc_bcd_to_bin(uint8_t bcd)
Packed BCD -> binary 0..99.
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_publish_calendar(void)
Refresh the BCD calendar shadow registers from the binary mirror.
static RA8_INTERNAL bool internal_rtc_alarm_matches(void)
True iff the running time matches the armed (ENB) alarm fields.
rtc_geom_t
RTC register window geometry (ra8_rtc_regs.h).
@ 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.
rtc_order_t
Per-tick order slot for the RTC block.
@ k_rtc_block_order
RTC tick / reset / report order slot.
Bounded raw-descriptor I/O seam for the RA8 emulator.
emu_io_result_t priv_emu_io_errf(const char *format,...)
Format bounded text and write it to the injected error descriptor.
#define RA8_INTERNAL
Marker that a function is intended to be static (file-local).
@ k_nibble_mask
Nibble mask.
A modelled peripheral block's self-description for the core registry.
The modelled RTC: a control-register shadow + a binary time mirror.
uint32_t tick_frac
Ticks accumulated toward the next second.
uint16_t year
Binary year mirror (2000-based BCD low).
uint8_t reg[k_rtc_span]
Faithful register shadow (BCD on reads).
uint8_t day
Binary day mirror.
uint8_t hour
Binary hour mirror.
uint8_t min
Binary minute mirror.
uint32_t periodics
Periodic events raised (report).
uint32_t alarms
Alarm events raised (report).
uint8_t sec
Binary second mirror.
uint8_t mon
Binary month mirror.
uint8_t r64
64 Hz sub-second counter.