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

Named Time Unit Constants for Delay / Timeout / Tick Math. More...

#include <stdint.h>
Include dependency graph for ra8_time_constants.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Enumerations

enum  ra8_time_unit_t : uint32_t {
  k_ra8_ns_per_us = 1000UL ,
  k_ra8_us_per_ms = 1000UL ,
  k_ra8_ms_per_sec = 1000UL ,
  k_ra8_ns_per_ms = 1000000UL ,
  k_ra8_us_per_sec = 1000000UL ,
  k_ra8_ns_per_sec = 1000000000UL ,
  k_ra8_sec_per_min = 60UL ,
  k_ra8_min_per_hour = 60UL ,
  k_ra8_hour_per_day = 24UL ,
  k_ra8_sec_per_hour = 3600UL ,
  k_ra8_sec_per_day = 86400UL
}
 Integer conversion factors between common time units. More...
enum  ra8_clock_hz_t : uint32_t {
  k_ra8_xtal_hz = 24000000UL ,
  k_ra8_loco_hz = 32768UL ,
  k_ra8_moco_hz = 8000000UL ,
  k_ra8_hoco_hz = 20000000UL ,
  k_ra8_pll1p_hz = 1000000000UL ,
  k_ra8_pll1q_hz = 333333333UL ,
  k_ra8_pll1r_hz = 400000000UL ,
  k_ra8_cpuclk0_hz = 1000000000UL ,
  k_ra8_cpuclk1_hz = 250000000UL ,
  k_ra8_iclk_hz = 250000000UL ,
  k_ra8_pclka_hz = 125000000UL ,
  k_ra8_pclkb_hz = 62500000UL ,
  k_ra8_pclkc_hz = 125000000UL ,
  k_ra8_pclkd_hz = 250000000UL ,
  k_ra8_pclke_hz = 250000000UL ,
  k_ra8_bclk_hz = 125000000UL ,
  k_ra8_fclk_hz = 125000000UL ,
  k_ra8_mriclk_hz = 250000000UL ,
  k_ra8_iclk_max_hz = 250000000UL
}
 Expected clock frequencies after PLL bring-up. More...
enum  ra8_timeout_ms_t : uint32_t {
  k_ra8_timeout_none_ms = 0UL ,
  k_ra8_timeout_short_ms = 10UL ,
  k_ra8_timeout_default_ms = 100UL ,
  k_ra8_timeout_long_ms = 1000UL ,
  k_ra8_timeout_very_long_ms = 10000UL
}
 Canonical timeouts used across drivers. More...

Detailed Description

Named Time Unit Constants for Delay / Timeout / Tick Math.

Collects every magic number related to time (microseconds, milliseconds, Hz) into a single typed-enum vocabulary so firmware code never writes a raw 1000, 1000000, or 0.001f.

Example rewrite:

// BAD: reader has to decode the arithmetic
for (uint32_t i = 0; i < 240 * 1000; i++) { ... }
// GOOD: the intent is in the constant names
for (uint32_t i = 0; i < k_ra8_cpu_mhz * k_ra8_us_per_ms; i++) { ... }
@ k_ra8_us_per_ms
Microseconds per millisecond.

Definition in file ra8_time_constants.h.

Enumeration Type Documentation

◆ ra8_clock_hz_t

enum ra8_clock_hz_t : uint32_t

Expected clock frequencies after PLL bring-up.

These are the target values the CGC driver programmes. Real-world values are measured at runtime via the CAC (Clock Accuracy Check) and validated to be within +/- 0.1% before any time-critical peripheral is enabled. Adjust here and the CGC driver will follow.

Note
The main Cortex-M85 core runs at k_ra8_cpuclk0_hz; the secondary Cortex-M33 runs at k_ra8_cpuclk1_hz from the same PLL. All peripheral clocks are derived dividers of the PLL.
Enumerator
k_ra8_xtal_hz 

24 MHz main crystal on EK-RA8D2.

k_ra8_loco_hz 

Low-speed on-chip oscillator.

k_ra8_moco_hz 

Middle-speed on-chip oscillator.

k_ra8_hoco_hz 

High-speed on-chip oscillator.

k_ra8_pll1p_hz 

PLL1P = (24/3)*250/2 = 1000 MHz.

k_ra8_pll1q_hz 

PLL1Q = (24/3)*250/6 ~= 333 MHz.

k_ra8_pll1r_hz 

PLL1R = (24/3)*250/5 = 400 MHz.

k_ra8_cpuclk0_hz 

CPUCLK0 = PLL1P/1 = 1 GHz.

k_ra8_cpuclk1_hz 

CPUCLK1 = PLL1P/4 = 250 MHz.

k_ra8_iclk_hz 

ICLK = PLL1P/4 = 250 MHz.

k_ra8_pclka_hz 

PCLKA = PLL1P/8 = 125 MHz.

k_ra8_pclkb_hz 

PCLKB = PLL1P/16 = 62.5 MHz.

k_ra8_pclkc_hz 

PCLKC = PLL1P/8 = 125 MHz.

k_ra8_pclkd_hz 

PCLKD = PLL1P/4 = 250 MHz.

k_ra8_pclke_hz 

PCLKE = PLL1P/4 = 250 MHz.

k_ra8_bclk_hz 

BCLK = PLL1P/8 = 125 MHz.

k_ra8_fclk_hz 

FCK (MRPCLK) = PLL1P/8 = 125 MHz.

k_ra8_mriclk_hz 

MRICLK = PLL1P/4 = 250 MHz (MRAM I/F).

k_ra8_iclk_max_hz 

Highest ICLK the part is rated for.

This is a DEVICE LIMIT, not the configured rate: it is the denominator in HUM Ch 58.3.7 "Wait State" p 3540, where SRAMWTSC.WTEN must be set once ICLK exceeds half of it. R7KA8D2KFLCAC is a 250 MHz-ICLK part; the 200 MHz and 150 MHz classes in that section belong to other RA8 variants.

Definition at line 74 of file ra8_time_constants.h.

◆ ra8_time_unit_t

enum ra8_time_unit_t : uint32_t

Integer conversion factors between common time units.

Enumerator
k_ra8_ns_per_us 

Nanoseconds per microsecond.

k_ra8_us_per_ms 

Microseconds per millisecond.

k_ra8_ms_per_sec 

Milliseconds per second.

k_ra8_ns_per_ms 

Nanoseconds per millisecond.

k_ra8_us_per_sec 

Microseconds per second.

k_ra8_ns_per_sec 

Nanoseconds per second.

k_ra8_sec_per_min 

Seconds per minute.

k_ra8_min_per_hour 

Minutes per hour.

k_ra8_hour_per_day 

Hours per day.

k_ra8_sec_per_hour 

Seconds per hour.

k_ra8_sec_per_day 

Seconds per day.

Definition at line 41 of file ra8_time_constants.h.

◆ ra8_timeout_ms_t

enum ra8_timeout_ms_t : uint32_t

Canonical timeouts used across drivers.

Centralised so the whole firmware agrees on "short", "default", "long" timeouts. Individual drivers may override for good reason but the default should come from here.

Enumerator
k_ra8_timeout_none_ms 

Poll once, never block.

k_ra8_timeout_short_ms 

10 ms – quick bus op.

k_ra8_timeout_default_ms 

100 ms – default.

k_ra8_timeout_long_ms 

1 s – slow devices.

k_ra8_timeout_very_long_ms 

10 s – boot / recovery.

Definition at line 115 of file ra8_time_constants.h.