Skip to content

Commit 7dc25f4

Browse files
Release: v4.0
Highlights: - UART interrupt support - Program memory optimisation - Support for ztest and twister - Context switch refignment - Kernel and thread test cases - Samples support - UART: Echo bot, native tty, passthrough - Blinky - Philosophers - Hello world - Pin control driver - New board support (sdPIC33AK512MPS512) Fixes: - Context switch fixes - System timer fixes - Build fixes Signed-off-by: Muhammed Zamroodh <[email protected]>
1 parent a3720e4 commit 7dc25f4

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

63 files changed

+2177
-166
lines changed

arch/Kconfig

Lines changed: 0 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -183,8 +183,6 @@ config DSPIC
183183
select STACK_SENTINAL
184184
select ATOMIC_OPERATIONS_C
185185
select ARCH_HAS_VECTOR_TABLE_RELOCATION
186-
select CPU_HAS_ICACHE
187-
select CACHE_MANAGEMENT
188186
select TICKLESS_CAPABLE
189187
help
190188
dspic architecture

arch/dspic/CMakeLists.txt

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,6 @@ if(CONFIG_BIG_ENDIAN)
33
else()
44
set_property(GLOBAL PROPERTY PROPERTY_OUTPUT_FORMAT elf32-little)
55
endif()
6-
zephyr_include_directories(${XCDSC_TOOLCHAIN_PATH}/support/generic/h/)
6+
zephyr_include_directories(${DFP_ROOT}/support/generic/h/)
77
zephyr_include_directories(include)
88
add_subdirectory(core)

arch/dspic/Kconfig

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,4 +20,11 @@ config NUM_IRQS
2020
config GEN_IRQ_START_VECTOR
2121
default 0
2222

23+
config DSPIC33_IRQ_OFFLOAD_IRQ
24+
int "IRQ number for irq_offload()"
25+
default 34
26+
help
27+
Select the interrupt number used by irq_offload().
28+
This must be a valid, software-triggerable interrupt on the dsPIC33.
29+
2330
endmenu

arch/dspic/core/CMakeLists.txt

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@ zephyr_library_sources(
44
cpu_idle.c
55
fatal.c
66
irq_manage.c
7-
isr_wrapper.c
7+
isr_wrapper.S
88
prep_c.c
99
thread.c
1010
swap.c
@@ -13,6 +13,7 @@ zephyr_library_sources(
1313
init.S
1414
vector_table.S
1515
reset1.S
16+
irq_offload.c
1617
)
1718

1819
zephyr_linker_sources(ROM_START SORT_KEY 0x00 vector_table.ld)

arch/dspic/core/fatal.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,7 @@ LOG_MODULE_REGISTER(dspic, 4);
1616

1717
volatile uint32_t reason, address;
1818

19-
#define EXCEPTION_HANDLER __attribute__((interrupt, no_auto_psv, weak))
19+
#define EXCEPTION_HANDLER __attribute__((interrupt, no_auto_psv, weak, naked))
2020
#define BUS_ERROR_MASK 0xF
2121
#define MATH_ERROR_MASK 0x1F
2222
#define GENERAL_TRAP_MASK 0x8000000Fu

arch/dspic/core/irq_manage.c

Lines changed: 27 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,6 @@ void z_irq_spurious(const void *unused)
1818
ARG_UNUSED(unused);
1919
while (1) {
2020
}
21-
return;
2221
}
2322

2423
void arch_irq_enable(unsigned int irq)
@@ -31,8 +30,6 @@ void arch_irq_enable(unsigned int irq)
3130

3231
/* Enable the interrupt by setting it's bit in interrupt enable register*/
3332
*int_enable_reg[reg_index] |= (uint32_t)(1u << bit_pos);
34-
35-
return;
3633
}
3734

3835
int arch_irq_is_enabled(unsigned int irq)
@@ -56,8 +53,34 @@ void arch_irq_disable(unsigned int irq)
5653

5754
/* Disable the interrupt by clearing it's bit in interrupt enable register*/
5855
*int_enable_reg[reg_index] &= (uint32_t)(~(1u << bit_pos));
56+
}
57+
58+
bool arch_dspic_irq_isset(unsigned int irq)
59+
{
60+
volatile uint32_t *int_ifs_reg[] = {&IFS0, &IFS1, &IFS2, &IFS3, &IFS4,
61+
&IFS5, &IFS6, &IFS7, &IFS8};
62+
volatile int ret_ifs = false;
63+
unsigned int reg_index = irq / (sizeof(uint32_t) << 3);
64+
unsigned int bit_pos = irq % (sizeof(uint32_t) << 3);
5965

60-
return;
66+
if ((bool)(void *)(*int_ifs_reg[reg_index] & (uint32_t)(1U << bit_pos))) {
67+
ret_ifs = true;
68+
}
69+
return ret_ifs;
70+
}
71+
72+
73+
74+
void z_dspic_enter_irq(int irq)
75+
{
76+
volatile uint32_t *int_ifs_reg[] = {&IFS0, &IFS1, &IFS2, &IFS3, &IFS4,
77+
&IFS5, &IFS6, &IFS7, &IFS8};
78+
79+
unsigned int reg_index = (unsigned int)irq / (sizeof(uint32_t) << 3);
80+
unsigned int bit_pos = (unsigned int)irq % (sizeof(uint32_t) << 3);
81+
82+
/* Enable the interrupt by setting it's bit in interrupt enable register*/
83+
*int_ifs_reg[reg_index] |= (uint32_t)(1u << bit_pos);
6184
}
6285

6386
#ifdef __cplusplus

arch/dspic/core/irq_offload.c

Lines changed: 48 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,48 @@
1+
/*
2+
* Copyright (c) 2025, Microchip Technology Inc.
3+
* SPDX-License-Identifier: Apache-2.0
4+
*/
5+
6+
#include <zephyr/kernel.h>
7+
#include <zephyr/kernel_structs.h>
8+
#include <kernel_internal.h>
9+
#include <zephyr/irq.h>
10+
#include <zephyr/irq_offload.h>
11+
#include <xc.h>
12+
13+
static irq_offload_routine_t _offload_routine;
14+
static const void *offload_param;
15+
16+
void z_irq_do_offload(void)
17+
{
18+
irq_offload_routine_t tmp;
19+
20+
if (_offload_routine != NULL) {
21+
22+
tmp = _offload_routine;
23+
_offload_routine = NULL;
24+
25+
tmp((const void *)offload_param);
26+
}
27+
}
28+
29+
void handler(void)
30+
{
31+
z_irq_do_offload();
32+
}
33+
34+
void arch_irq_offload_init(void)
35+
{
36+
IRQ_CONNECT(CONFIG_DSPIC33_IRQ_OFFLOAD_IRQ, 1, handler, NULL, 0);
37+
}
38+
39+
void arch_irq_offload(irq_offload_routine_t routine, const void *parameter)
40+
{
41+
uint32_t key = irq_lock();
42+
43+
_offload_routine = routine;
44+
offload_param = parameter;
45+
irq_enable(CONFIG_DSPIC33_IRQ_OFFLOAD_IRQ);
46+
z_dspic_enter_irq(CONFIG_DSPIC33_IRQ_OFFLOAD_IRQ);
47+
irq_unlock(key);
48+
}

0 commit comments

Comments
 (0)