|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
Bounded wait-flag primitives for RA8D2 HAL drivers. More...
Go to the source code of this file.
Enumerations | |
| enum | ra8_hw_err_budget_t : uint32_t { k_ra8_hw_budget_short = 0x00000400U , k_ra8_hw_budget_medium = 0x00004000U , k_ra8_hw_budget_long = 0x00040000U , k_ra8_hw_budget_xlong = 0x00400000U } |
| Default polling budgets for ra8_hw_wait_flag_*. More... | |
Functions | |
| static ra8_err_t | ra8_hw_wait_flag_set8 (volatile const uint8_t *reg, uint8_t mask, uint32_t budget) |
| Spin until (*reg & mask) != 0 or budget runs out. | |
| static ra8_err_t | ra8_hw_wait_flag_clear8 (volatile const uint8_t *reg, uint8_t mask, uint32_t budget) |
| Spin until (*reg & mask) == 0 or budget runs out. | |
| static ra8_err_t | ra8_hw_wait_flag_set32 (volatile const uint32_t *reg, uint32_t mask, uint32_t budget) |
| Spin until (*reg & mask) != 0 or budget runs out. | |
| static ra8_err_t | ra8_hw_wait_flag_clear32 (volatile const uint32_t *reg, uint32_t mask, uint32_t budget) |
| Spin until (*reg & mask) == 0 or budget runs out. | |
Bounded wait-flag primitives for RA8D2 HAL drivers.
Ring 3 / HAL substrate. Header-only because every helper here is a single short loop that the compiler should inline at the call site – making them static inline keeps the symbol weight to zero in the cross-build.
Driver code on the RA8D2 is full of "spin until this status bit changes" sequences:
Every one of those loops needs:
The four helpers below cover every flavour the existing 29 driver shells need:
Each takes a pointer to a volatile register, a mask, and a spin budget. The spin budget is a uint32_t so callers can pick from a typed enum without needing yet another wrapper.
On success the helper returns k_ra8_ok. On budget exhaustion it returns k_ra8_err_hw_timeout. There is no other failure mode.
The implementation does NOT issue __WFE, __DSB or any other Cortex-M intrinsic – those are bring-up-time decisions that belong in the calling driver. The barrier here is just the volatile qualifier on the register pointer, which is sufficient to keep the compiler from hoisting the load.
Definition in file ra8_hw_err.h.
| enum ra8_hw_err_budget_t : uint32_t |
Default polling budgets for ra8_hw_wait_flag_*.
Drivers SHOULD use one of these named budgets rather than inventing their own integer literal. Each value is set so that a worst-case Cortex-M85 at 1 GHz spends a comfortable margin over the longest documented stabilisation time for the relevant peripheral, multiplied by ~4 for safety.
| Enumerator | |
|---|---|
| k_ra8_hw_budget_short | RA8 hw budget short. |
| k_ra8_hw_budget_medium | RA8 hw budget medium. |
| k_ra8_hw_budget_long | RA8 hw budget long. |
| k_ra8_hw_budget_xlong | RA8 hw budget xlong. |
Definition at line 171 of file ra8_hw_err.h.
|
inlinestatic |
Spin until (*reg & mask) == 0 or budget runs out.
| [in] | reg | Pointer to the volatile 32-bit register to poll. |
| [in] | mask | Bit mask to test for "clear". |
| [in] | budget | Spin budget. |
| k_ra8_ok | The flag was observed as clear within the budget. |
| k_ra8_err_hw_timeout | The budget ran out without the flag observed. |
| k_ra8_err_null_ptr | reg was NULL. |
See implementation.
Definition at line 351 of file ra8_hw_err.h.
References k_ra8_err_hw_timeout, k_ra8_err_null_ptr, and k_ra8_ok.
Referenced by internal_lin_wait_break_done(), internal_mdio_drain(), internal_set_global_mode(), internal_set_vscr_not_high_v(), internal_tas_learn_entry(), internal_wait_fifo_reset_clear(), internal_wait_ssirst_clear(), priv_ra8_canfd_internal_set_channel_mode(), ra8_dotf_run_self_test(), ra8_eth_gwca_reload_queue(), ra8_etha_read_tas_entry(), ra8_vin_capture_disarm(), and ra8_xspi_calibrate_dqs().
|
inlinestatic |
Spin until (*reg & mask) == 0 or budget runs out.
| [in] | reg | Pointer to the volatile 8-bit register to poll. |
| [in] | mask | Bit mask to test for "clear". |
| [in] | budget | Spin budget. See ra8_hw_err_budget_t. |
| k_ra8_ok | The flag was observed as clear. |
| k_ra8_err_hw_timeout | Budget exhausted. |
| k_ra8_err_null_ptr | reg was NULL. |
See implementation.
Definition at line 262 of file ra8_hw_err.h.
References k_ra8_err_hw_timeout, k_ra8_err_null_ptr, and k_ra8_ok.
Referenced by internal_route_sciclk(), internal_wait_canfdcksrdy(), internal_wait_cksrdy(), internal_wait_octacksrdy(), internal_wait_pdctreswm_clear(), internal_wait_usb60cksrdy(), internal_wait_usbcksrdy(), priv_ra8_cgc_wait_oscsf_clear(), and ra8_ulpt_stop().
|
inlinestatic |
Spin until (*reg & mask) != 0 or budget runs out.
| [in] | reg | Pointer to the volatile 32-bit register to poll. |
| [in] | mask | Bit mask to test for "set". |
| [in] | budget | Spin budget. |
| k_ra8_ok | The flag was observed as set within the budget. |
| k_ra8_err_hw_timeout | The budget ran out without the flag observed. |
| k_ra8_err_null_ptr | reg was NULL. |
See implementation.
Definition at line 309 of file ra8_hw_err.h.
References k_ra8_err_hw_timeout, k_ra8_err_null_ptr, and k_ra8_ok.
Referenced by internal_set_global_mode(), internal_target_wait_spsr(), internal_wait_spsr(), internal_wait_status_bit(), internal_wait_tx_end(), ra8_eth_coma_bringup(), ra8_eth_gwca_axi_init(), ra8_etha_tas_ram_reset(), ra8_sci_getc_polling(), ra8_sci_lin_wait_break(), ra8_sci_putc_polling(), and ra8_sci_spi_xfer8().
|
inlinestatic |
Spin until (*reg & mask) != 0 or budget runs out.
| [in] | reg | Pointer to the volatile 8-bit register to poll. Must not be NULL. |
| [in] | mask | Bit mask within *reg to test for "set". Must be non-zero or the function returns immediately with success. |
| [in] | budget | Maximum loop iterations before declaring a timeout. Pass one of the k_ra8_hw_budget_* values. |
| k_ra8_ok | The flag was observed as set within the budget. |
| k_ra8_err_hw_timeout | The budget ran out without the flag being observed. |
| k_ra8_err_null_ptr | reg was NULL. |
See implementation.
Definition at line 219 of file ra8_hw_err.h.
References k_ra8_err_hw_timeout, k_ra8_err_null_ptr, and k_ra8_ok.
Referenced by internal_route_sciclk(), internal_wait_canfdcksrdy(), internal_wait_cksrdy(), internal_wait_octacksrdy(), internal_wait_usb60cksrdy(), internal_wait_usbcksrdy(), and priv_ra8_cgc_wait_oscsf_set().