5 #include "dt/dt_rv_timer.h"
6 #include "external/freertos/include/FreeRTOS.h"
7 #include "external/freertos/include/task.h"
8 #include "external/freertos/portable/GCC/RISC-V/portmacro.h"
11 #include "sw/device/lib/runtime/irq.h"
13 #include "sw/device/lib/testing/test_framework/FreeRTOSConfig.h"
14 #include "sw/device/lib/testing/test_framework/check.h"
32 #
if configUSE_PREEMPTION
34 static dif_rv_timer_t timer;
35 static const uint32_t kTimerHartId = (uint32_t)0;
36 static const uint32_t kTimerComparatorId = 0;
37 static const uint64_t kTimerDeadline =
41 void ottf_timer_isr(uint32_t *exc_info) {
43 dif_rv_timer_irq_enable_snapshot_t irq_enable_snapshot;
45 dif_rv_timer_irq_disable_all(&timer, kTimerHartId, &irq_enable_snapshot));
47 CHECK_DIF_OK(dif_rv_timer_irq_acknowledge(
48 &timer, kDifRvTimerIrqTimerExpiredHart0Timer0));
51 dif_rv_timer_irq_restore_all(&timer, kTimerHartId, &irq_enable_snapshot));
55 void vPortSetupTimerInterrupt(
void) {
56 LOG_INFO(
"Configuring timer interrupt ...");
59 CHECK_DIF_OK(dif_rv_timer_init_from_dt(kDtRvTimer, &timer));
67 LOG_INFO(
"Tick Freq. (Hz): %u, Prescale: %u; Tick Step: %u",
73 CHECK_DIF_OK(dif_rv_timer_irq_set_enabled(
87 extern void xPortStartFirstTask(
void);
89 BaseType_t xPortStartScheduler(
void) {
90 #if configUSE_PREEMPTION
91 vPortSetupTimerInterrupt();
94 irq_external_ctrl(
true);
95 irq_software_ctrl(
true);
99 xPortStartFirstTask();