|
ra8-firmware 0.1.0
Bare-metal firmware for the Renesas RA8 family (RA8D2 / RA8P1)
|
SysTick-based tick counter, delay and timestamp helpers. More...
Go to the source code of this file.
Functions | |
| ra8_err_t | ra8_time_init (uint32_t cpu_hz) |
| Initialise SysTick for a 1 kHz tick interrupt. | |
| uint32_t | ra8_time_ms (void) |
| Get the current 1 kHz tick count. | |
| void | ra8_delay_ms (uint32_t ms) |
| Busy-wait for at least ms milliseconds. | |
| void | ra8_time_on_tick (void) |
| SysTick IRQ handler – called from the vector table. | |
| uint32_t | ra8_now_ms (void) |
| Short-form alias for ra8_time_ms(). | |
| void | ra8_sleep_ms (uint32_t ms) |
| Short-form alias for ra8_delay_ms(). | |
Variables | |
| const ra8_time_interface_t | g_ra8_time_interface_systick |
| Production ra8_time_interface_t that forwards to the SysTick-backed ra8_time_ms / ra8_delay_ms helpers. | |
SysTick-based tick counter, delay and timestamp helpers.
Uses the Cortex-M SysTick peripheral (architectural, always present) as a 1 kHz tick source. Exposes three entry points:
The tick counter is a 32-bit uint32_t and wraps every ~49.7 days. Code that compares timestamps should use subtraction so the comparison stays monotonic across wrap.
Definition in file ra8_time.h.
| void ra8_delay_ms | ( | uint32_t | ms | ) |
Busy-wait for at least ms milliseconds.
Loops on ra8_time_ms() and issues wfi between checks.
| [in] | ms | Milliseconds to wait. Zero returns immediately. |
Busy-wait for at least ms milliseconds.
Loops on s_tick_ms and issues wfi between checks.
| [in] | ms | Milliseconds to wait. Zero returns immediately. |
Busy-wait for at least ms milliseconds.
ra8_usb calls ra8_delay_ms(1) once during device bring-up. The NS image must NOT link ra8_time.c: its ra8_time_init reprograms the SysTick that ThreadX owns, and its delay else-branch waits on a tick counter the ThreadX SysTick handler never advances. ThreadX's 1 ms tick makes one sleep tick == 1 ms here. Called only from thread context.
| [in] | ms | Milliseconds to block (0 is rounded up to one tick). |
Definition at line 129 of file ra8_time.c.
References ra8_dwt_cyccnt_read(), s_cycles_per_ms, and s_tick_ms.
Referenced by app_bringup_panel(), c6_cam_camera_init(), c6_fwver_worker_entry(), c6_hosted_worker_entry(), c6_join_worker_entry(), c6_probe_sweep_mode(), c6_wifi_worker_entry(), cam_bringup(), cdc_enum_hunt(), cdc_enum_set_address(), cm_bringup_panel(), demo_emit_measurement(), dfu_enum_hunt(), dfu_enum_set_address(), dfu_wait_state(), ez_bringup_panel(), gptp_measure(), hid_enum_hunt(), hid_enum_hunt(), hid_enum_set_address(), hid_enum_set_address(), internal_bring_up_sensor(), internal_c6_cam_worker_entry(), internal_ceu_wait_for_frame(), internal_cs(), internal_cs_try(), internal_dac_demo_one_triangle_period(), internal_enum_assign_addr(), internal_enum_hunt(), internal_enum_hunt(), internal_kick_net(), internal_lcd_bringup_panel(), internal_lcd_bringup_panel(), internal_lpm_demo_one_wake(), internal_pdm_prepare_hardware(), internal_poeg_demo_cycle(), internal_pull_read(), internal_ra8_epaper_pulse_reset(), internal_reset_phase_1s(), internal_reset_phase_8d(), internal_run(), internal_run_one(), internal_set_address(), internal_start_count_source(), internal_transfer(), internal_usbhs_try_clksel(), internal_wait_for_autoneg(), internal_wait_ready(), internal_wait_state(), main(), mg_bringup_panel(), ns_host_enum_hunt(), ns_host_set_address(), ra8_board_camera_delay_ms(), ra8_board_camera_reset(), ra8_board_lcd_panel_power_on(), ra8_board_xspi_pins_init(), ra8_rtc_clock_init(), ra8_sleep_ms(), sfr_bringup_panel(), sh_run(), timer_demo_one_capture(), tsn_check_time_base(), wdt_rr_arm_and_wait_for_reset(), and wifi_hal_worker_entry().
| uint32_t ra8_now_ms | ( | void | ) |
Short-form alias for ra8_time_ms().
Convenience wrapper used by code that prefers a "now" verb.
| 0..UINT32_MAX | See ra8_time_ms(). |
Definition at line 19 of file timer.c.
References ra8_time_ms().
Referenced by ep_run_refresh_cycle(), and modem_now_ms().
| void ra8_sleep_ms | ( | uint32_t | ms | ) |
Short-form alias for ra8_delay_ms().
Convenience wrapper that forwards to ra8_delay_ms().
| [in] | ms | Milliseconds to sleep. Zero returns immediately. |
Definition at line 24 of file timer.c.
References ra8_delay_ms().
|
nodiscard |
Initialise SysTick for a 1 kHz tick interrupt.
| [in] | cpu_hz | Current CPU clock in Hz. Used to compute the SysTick reload value (cpu_hz / 1000 - 1). |
Initialise SysTick for a 1 kHz tick interrupt.
Computes the reload as cpu_hz / 1000 - 1, programmes SYST_RVR/CVR/CSR. On the off-target host the SCS writes are skipped.
| [in] | cpu_hz | Current CPU clock in Hz. |
| k_ra8_ok | SysTick programmed; tick interrupt active. |
| k_ra8_err_invalid_arg | cpu_hz is zero or yields a zero reload. |
Definition at line 59 of file ra8_time.c.
References k_ra8_err_invalid_arg, k_ra8_ms_per_sec, k_ra8_ok, k_ra8_systick_clk_cpu, ra8_dwt_cyccnt_enable(), ra8_log_error, ra8_log_info_val, ra8_systick_configure(), s_cycles_per_ms, s_tag, and s_tick_ms.
Referenced by adc_diag_setup_or_halt(), al_setup_or_halt(), app_bringup_clocks(), blc_setup_or_halt(), bm_setup_or_halt(), bs_setup_or_halt(), c6_fwver_setup_or_halt(), c6_hosted_setup_or_halt(), c6_join_setup_or_halt(), c6_probe_clocks_or_halt(), c6_wifi_setup_or_halt(), cam_bringup(), cdc_setup_or_halt(), ch_setup_or_halt(), cm_bringup_clocks(), combo_clocks_or_halt(), crc_demo_setup_or_halt(), demo_setup_or_halt(), demo_setup_or_halt(), dfu_setup_or_halt(), drw_blend_setup_or_halt(), drw_demo_setup_or_halt(), dtc_arm_setup_or_halt(), dtc_demo_setup_or_halt(), ec_setup_or_halt(), ef_setup_or_halt(), ehb_setup_or_halt(), eoh_setup_or_halt(), eop_setup_or_halt(), ep_bringup_core(), ep_setup_or_halt(), erb_setup_or_halt(), es_setup_or_halt(), est_setup_or_halt(), etoc_setup_or_halt(), ez_bringup_clocks(), fileops_setup_or_halt(), flash_journal_setup_or_halt(), fs_fmt_setup_or_halt(), gh_setup_or_halt(), gpt_ecc_clocks_or_halt(), gptp_setup_or_halt(), hid_setup_or_halt(), i3c_demo_clocks_or_halt(), iic_setup_or_halt(), imp_setup_or_halt(), imu_demo_clocks_or_halt(), internal_acmphs_demo_setup(), internal_agt_periodic_setup_or_halt(), internal_audio_loopback_init_clocks_and_led(), internal_bkup_demo_setup_or_halt(), internal_c6_cam_setup_or_halt(), internal_can_demo_setup_or_halt(), internal_canfd_demo_setup_or_halt(), internal_canfd_filter_setup_or_halt(), internal_clocks_or_halt(), internal_clocks_or_halt(), internal_dac_b_demo_setup_or_halt(), internal_dac_demo_setup_or_halt(), internal_demo_clocks_or_halt(), internal_demo_setup_or_halt(), internal_dotf_demo_setup_or_halt(), internal_eth_loopback_setup_or_halt(), internal_gpio_demo_setup_or_halt(), internal_gpt_3p_demo_setup_or_halt(), internal_gpt_irq_demo_setup_or_halt(), internal_gpt_pwm_demo_setup_or_halt(), internal_icu_extint_demo_setup_or_halt(), internal_iic_peripheral_setup_or_halt(), internal_kat_setup_or_halt(), internal_kint_demo_setup_or_halt(), internal_lcd_bringup_clocks(), internal_lpm_deep_setup_or_halt(), internal_lpm_demo_setup_or_halt(), internal_lpm_dpsby1_setup_or_halt(), internal_lpm_dpsby2_setup_or_halt(), internal_lpm_dpsby3_setup_or_halt(), internal_lpm_swstd_setup_or_halt(), internal_lpm_wake_setup_or_halt(), internal_lus_setup_or_halt(), internal_lvd_demo_setup_or_halt(), internal_mecc_setup_or_halt(), internal_motor_3phase_init_clocks_and_led(), internal_mpu_simple_setup_or_halt(), internal_pc_setup_or_halt(), internal_pdg_demo_setup_or_halt(), internal_poeg_demo_setup_or_halt(), internal_rc_setup_or_halt(), internal_rcs_setup_or_halt(), internal_rng_demo_setup_or_halt(), internal_rtc_demo_setup_or_halt(), internal_sd_demo_setup_or_halt(), internal_setup_or_halt(), internal_ssie_loop_setup_or_halt(), internal_tc_setup_or_halt(), internal_td_setup_or_halt(), internal_uart_hello_setup_or_halt(), internal_usb_audio_clocks_or_halt(), internal_wdt_demo_setup_or_halt(), ipc_demo_setup_or_halt(), iu_setup_or_halt(), iv_setup_or_halt(), kat_setup_or_halt(), kb_setup_or_halt(), l3_setup_or_halt(), lcd_bringup_clocks(), lin_hil_setup_or_halt(), lk_setup_or_halt(), lpi_setup_or_halt(), main(), mem_setup_or_halt(), mg_bringup_clocks(), microsd_setup_or_halt(), mlun_setup_or_halt(), modem_clocks_or_halt(), ospirw_setup_or_halt(), pdm_demo_clocks_or_halt(), pp_demo_clocks_or_halt(), riic_target_clocks_or_halt(), rot_setup_or_halt(), sb_setup_or_halt(), scb_demo_setup_or_halt(), sd_demo_setup_or_halt(), sd_setup_or_halt(), sdhi_card_setup_or_halt(), sdhi_demo_setup_or_halt(), sdmsc_setup_or_halt(), sdram_demo_setup_or_halt(), selftest_setup_or_halt(), sfr_bringup_clocks(), sh_setup_or_halt(), tb_setup_or_halt(), timer_demo_setup_or_halt(), tsn_setup_or_halt(), uart_irq_setup_or_halt(), wa_setup_or_halt(), wc_setup_or_halt(), wd_setup_or_halt(), wdt_rr_setup_or_halt(), wdt_window_demo_setup_or_halt(), webp_demo_setup_or_halt(), wifi_hal_setup_or_halt(), wk_setup_or_halt(), and wlun_setup_or_halt().
| uint32_t ra8_time_ms | ( | void | ) |
Get the current 1 kHz tick count.
Returns the SysTick-incremented s_tick_ms counter. Wraps every ~49.7 days; compare via subtraction.
| 0..UINT32_MAX | Monotonically increasing modulo 2^32. |
Get the current 1 kHz tick count.
Returns the SysTick-incremented s_tick_ms counter.
| 0..UINT32_MAX | Current tick count. |
Get the current 1 kHz tick count.
The polled host ladder (cdc_enum_hunt) uses ra8_time_ms for its attach timeout. ThreadX's tick is 1 ms here, so tx_time_get (ticks since boot) is already a millisecond count. Replaces ra8_time.c (dropped from the NS link – see ra8_delay_ms).
| 0 | Immediately after the kernel starts. |
Definition at line 108 of file ra8_time.c.
References s_tick_ms.
Referenced by c6_cam_camera_capture_jpeg(), cdc_enum_hunt(), dfu_enum_hunt(), ez_poll_touch(), gptp_measure(), hid_enum_hunt(), hid_enum_hunt(), internal_enum_hunt(), internal_enum_hunt(), internal_pdm_capture(), internal_pdm_stream_data(), main(), ns_host_enum_hunt(), pp_demo_now_us(), ra8_now_ms(), sdram_demo_read_check(), sdram_demo_write_pass(), selftest_verify_mram_raw(), selftest_verify_mram_raw(), selftest_verify_mram_raw(), selftest_verify_mram_raw(), selftest_verify_ospi_raw(), sh_cover_gesture(), sh_loupe_held(), sh_run(), and tsn_check_time_base().
| void ra8_time_on_tick | ( | void | ) |
SysTick IRQ handler – called from the vector table.
Override the weak SysTick_Handler alias with ra8_time_on_tick by declaring void SysTick_Handler(void) { ra8_time_on_tick(); } somewhere in the application, OR link ra8_time.c with the already-provided SysTick_Handler implementation in this file.
SysTick IRQ handler – called from the vector table.
Increments s_tick_ms. Invoked from SysTick IRQ.
Definition at line 170 of file ra8_time.c.
References s_tick_ms.
Referenced by SysTick_Handler().
|
extern |
Production ra8_time_interface_t that forwards to the SysTick-backed ra8_time_ms / ra8_delay_ms helpers.