-
Notifications
You must be signed in to change notification settings - Fork 39
Expand file tree
/
Copy pathirq_connect.c
More file actions
124 lines (99 loc) · 3.29 KB
/
irq_connect.c
File metadata and controls
124 lines (99 loc) · 3.29 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
/*
* Copyright (c) 2024 Nordic Semiconductor ASA
*
* SPDX-License-Identifier: LicenseRef-Nordic-5-Clause
*/
#include <zephyr/init.h>
#include <zephyr/kernel.h>
#include <zephyr/irq.h>
#include <zephyr/storage/flash_map.h>
#include <zephyr/logging/log.h>
#include <zephyr/logging/log_ctrl.h>
#include <bm/bm_irq.h>
LOG_MODULE_DECLARE(nrf_sdh, CONFIG_NRF_SDH_LOG_LEVEL);
#include "irq_connect.h"
/* Handlers provided by the SoftDevice */
extern void CLOCK_POWER_SD_IRQHandler(void);
extern void RADIO_0_IRQHandler(void);
extern void TIMER10_IRQHandler(void);
extern void GRTC_3_IRQHandler(void);
extern void ECB00_IRQHandler(void);
extern void AAR00_CCM00_IRQHandler(void);
extern void SWI00_IRQHandler(void);
/* In irq_forward.s */
extern void SVC_Handler(void);
extern void CallSoftDeviceResetHandler(void);
uint32_t irq_forwarding_enabled_magic_number_holder;
uint32_t softdevice_vector_forward_address;
static void sd_enable_irq_forwarding(void)
{
softdevice_vector_forward_address = FIXED_PARTITION_OFFSET(softdevice_partition);
#ifdef CONFIG_BOOTLOADER_MCUBOOT
softdevice_vector_forward_address += CONFIG_ROM_START_OFFSET;
#endif
LOG_INF("SoftDevice forward address: %#x", softdevice_vector_forward_address);
log_flush();
CallSoftDeviceResetHandler();
irq_forwarding_enabled_magic_number_holder = IRQ_FORWARDING_ENABLED_MAGIC_NUMBER;
}
static int irq_init(void)
{
#define PRIO_IGNORE 0 /* Priority setting used when IRQ_ZERO_LATENCY is enabled
* This priority value will be ignored
*/
#define PRIO_LOW 4 /* SoftDevice low priority interrupt */
/* IRQ_ZERO_LATENCY with CONFIG_ZERO_LATENCY_LEVELS equal to 1 (default) forces the
* priority level to 0, ignoring the specified priority.
* On `sd_softdevice_enable()`, the SoftDevice will override the necessary interrupts
* it uses internally with the priority levels it needs.
*/
BM_IRQ_DIRECT_CONNECT(RADIO_0_IRQn, PRIO_IGNORE, RADIO_0_IRQHandler, IRQ_ZERO_LATENCY);
BM_IRQ_DIRECT_CONNECT(TIMER10_IRQn, PRIO_IGNORE, TIMER10_IRQHandler, IRQ_ZERO_LATENCY);
BM_IRQ_DIRECT_CONNECT(GRTC_3_IRQn, PRIO_IGNORE, GRTC_3_IRQHandler, IRQ_ZERO_LATENCY);
/* These are not zero latency. */
BM_IRQ_DIRECT_CONNECT(AAR00_CCM00_IRQn, PRIO_LOW, AAR00_CCM00_IRQHandler, 0);
BM_IRQ_DIRECT_CONNECT(CLOCK_POWER_IRQn, PRIO_LOW, CLOCK_POWER_SD_IRQHandler, 0);
BM_IRQ_DIRECT_CONNECT(ECB00_IRQn, PRIO_LOW, ECB00_IRQHandler, 0);
BM_IRQ_DIRECT_CONNECT(SWI00_IRQn, PRIO_LOW, SWI00_IRQHandler, 0);
BM_IRQ_SET_PRIORITY(SVCall_IRQn, PRIO_LOW);
sd_enable_irq_forwarding();
return 0;
}
__attribute__((weak)) void C_HardFault_Handler(void)
{
__asm__("SVC 255");
}
__attribute__((weak)) void C_TIMER10_Handler(void)
{
__asm__("SVC 255");
}
__attribute__((weak)) void C_GRTC_3_Handler(void)
{
__asm__("SVC 255");
}
__attribute__((weak)) void C_SWI00_Handler(void)
{
__asm__("SVC 255");
}
__attribute__((weak)) void C_RADIO_0_Handler(void)
{
__asm__("SVC 255");
}
__attribute__((weak)) void C_ECB00_Handler(void)
{
__asm__("SVC 255");
}
__attribute__((weak)) void C_AAR00_CCM00_Handler(void)
{
__asm__("SVC 255");
}
__attribute__((weak)) void C_CLOCK_POWER_SD_Handler(void)
{
#if defined(CONFIG_NRFX_POWER) || defined(CONFIG_NRFX_CLOCK)
extern void nrfx_power_clock_irq_handler(void);
nrfx_power_clock_irq_handler();
#else
__asm__("SVC 255");
#endif
}
SYS_INIT(irq_init, APPLICATION, 0);