Skip to content

Commit

Permalink
intermediate
Browse files Browse the repository at this point in the history
  • Loading branch information
bjarki-andreasen committed Jun 17, 2024
1 parent 7d61e5f commit f49dbf0
Show file tree
Hide file tree
Showing 11 changed files with 73 additions and 19 deletions.
20 changes: 9 additions & 11 deletions drivers/timer/nrf_rtc_timer.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@
#include <zephyr/sys_clock.h>
#include <zephyr/sys/barrier.h>
#include <haly/nrfy_rtc.h>
#include <zephyr/irq.h>
#include <zephyr/sys/irq.h>

#define RTC_PRETICK (IS_ENABLED(CONFIG_SOC_NRF53_RTC_PRETICK) && \
IS_ENABLED(CONFIG_SOC_NRF5340_CPUNET))
Expand All @@ -30,8 +30,8 @@

BUILD_ASSERT(CHAN_COUNT <= CHAN_COUNT_MAX, "Not enough compare channels");
/* Ensure that counter driver for RTC1 is not enabled. */
BUILD_ASSERT(DT_NODE_HAS_STATUS(DT_NODELABEL(RTC_LABEL), disabled),
"Counter for RTC1 must be disabled");
BUILD_ASSERT(DT_NODE_HAS_STATUS(DT_NODELABEL(RTC_LABEL), reserved),
"Counter for RTC1 must be reserved");

#define COUNTER_BIT_WIDTH 24U
#define COUNTER_SPAN BIT(COUNTER_BIT_WIDTH)
Expand Down Expand Up @@ -176,7 +176,7 @@ static void compare_int_unlock(int32_t chan, bool key)
atomic_or(&int_mask, BIT(chan));
nrfy_rtc_int_enable(RTC, NRF_RTC_CHANNEL_INT_MASK(chan));
if (atomic_get(&force_isr_mask) & BIT(chan)) {
NVIC_SetPendingIRQ(RTC_IRQn);
sys_irq_trigger(SYS_DT_IRQN(DT_NODELABEL(RTC_LABEL)));
}
}
}
Expand Down Expand Up @@ -719,9 +719,9 @@ static void int_event_disable_rtc(void)
void sys_clock_disable(void)
{
nrf_rtc_task_trigger(RTC, NRF_RTC_TASK_STOP);
irq_disable(RTC_IRQn);
sys_irq_disable(SYS_DT_IRQN(DT_NODELABEL(RTC_LABEL)));
int_event_disable_rtc();
NVIC_ClearPendingIRQ(RTC_IRQn);
sys_irq_clear(SYS_DT_IRQN(DT_NODELABEL(RTC_LABEL)));
}

static int sys_clock_driver_init(void)
Expand All @@ -744,11 +744,9 @@ static int sys_clock_driver_init(void)

nrfy_rtc_int_enable(RTC, NRF_RTC_INT_OVERFLOW_MASK);

NVIC_ClearPendingIRQ(RTC_IRQn);

IRQ_CONNECT(RTC_IRQn, DT_IRQ(DT_NODELABEL(RTC_LABEL), priority),
rtc_nrf_isr, 0, 0);
irq_enable(RTC_IRQn);
sys_irq_configure(SYS_DT_IRQN(DT_NODELABEL(RTC_LABEL)),
SYS_DT_IRQ_FLAGS(DT_NODELABEL(RTC_LABEL)));
sys_irq_enable(SYS_DT_IRQN(DT_NODELABEL(RTC_LABEL)));

nrfy_rtc_task_trigger(RTC, NRF_RTC_TASK_CLEAR);
nrfy_rtc_task_trigger(RTC, NRF_RTC_TASK_START);
Expand Down
6 changes: 6 additions & 0 deletions tests/kernel/sys_irq/dynamic_irq/boards/b_u585i_iot02a.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (c) 2024 Bjarki Arge Andreasen
# SPDX-License-Identifier: Apache-2.0

CONFIG_GEN_ISR_TABLES=n
CONFIG_GEN_IRQ_VECTOR_TABLE=n
CONFIG_LTO=y
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
test-intd0 = &spi1;
test-intd1 = &spi2;
};

soc
};

&spi1 {
Expand All @@ -24,3 +22,7 @@
&nvic {
interrupt-lines = <128>;
};

&exti {
interrupt-lines = <16>;
};
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (c) 2024 Bjarki Arge Andreasen
# SPDX-License-Identifier: Apache-2.0

CONFIG_GEN_ISR_TABLES=n
CONFIG_GEN_IRQ_VECTOR_TABLE=n
CONFIG_LTO=y
28 changes: 28 additions & 0 deletions tests/kernel/sys_irq/dynamic_irq/boards/nrf9160dk_nrf9160.overlay
Original file line number Diff line number Diff line change
@@ -0,0 +1,28 @@
/*
* Copyright (c) 2024 Bjarki Arge Andreasen
*
* SPDX-License-Identifier: Apache-2.0
*/

/ {
aliases {
test-intd0 = &spi1;
test-intd1 = &spi2;
};
};

&spi1 {
status = "reserved";
};

&spi2 {
status = "reserved";
};

&rtc1 {
status = "reserved";
};

&nvic {
interrupt-lines = <65>;
};
2 changes: 0 additions & 2 deletions tests/kernel/sys_irq/dynamic_irq/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -4,8 +4,6 @@
CONFIG_ZTEST=y
CONFIG_ZTEST_FAIL_FAST=y
CONFIG_INTC=y
CONFIG_GEN_ISR_TABLES=n
CONFIG_GEN_IRQ_VECTOR_TABLE=n
CONFIG_SYS_IRQ=y
CONFIG_SYS_IRQ_DYNAMIC=y
CONFIG_LOG=y
Expand Down
5 changes: 5 additions & 0 deletions tests/kernel/sys_irq/dynamic_irq/testcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,5 @@
tests:
kernel.sys_irq.dynamic_irq:
platform_allow:
- b_u585i_iot02a
- nrf9160dk/nrf9160
6 changes: 6 additions & 0 deletions tests/kernel/sys_irq/irq/boards/b_u585i_iot02a.conf
Original file line number Diff line number Diff line change
@@ -0,0 +1,6 @@
# Copyright (c) 2024 Bjarki Arge Andreasen
# SPDX-License-Identifier: Apache-2.0

CONFIG_GEN_ISR_TABLES=n
CONFIG_GEN_IRQ_VECTOR_TABLE=n
CONFIG_LTO=y
6 changes: 4 additions & 2 deletions tests/kernel/sys_irq/irq/boards/b_u585i_iot02a.overlay
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,6 @@
test-intd0 = &spi1;
test-intd1 = &spi2;
};

soc
};

&spi1 {
Expand All @@ -24,3 +22,7 @@
&nvic {
interrupt-lines = <128>;
};

&exti {
interrupt-lines = <16>;
};
3 changes: 1 addition & 2 deletions tests/kernel/sys_irq/irq/prj.conf
Original file line number Diff line number Diff line change
Expand Up @@ -2,9 +2,8 @@
# SPDX-License-Identifier: Apache-2.0

CONFIG_ZTEST=y
CONFIG_ZTEST_FAIL_FAST=y
CONFIG_INTC=y
CONFIG_GEN_ISR_TABLES=n
CONFIG_GEN_IRQ_VECTOR_TABLE=n
CONFIG_SYS_IRQ=y
CONFIG_LOG=y
CONFIG_SYS_IRQ_LOG_SPURIOUS=y
4 changes: 4 additions & 0 deletions tests/kernel/sys_irq/irq/testcase.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,4 @@
tests:
kernel.sys_irq.irq:
platform_allow:
- b_u585i_iot02a

0 comments on commit f49dbf0

Please sign in to comment.