diff options
author | Steven Gotthardt <gotthardt@gmail.com> | 2022-12-18 15:05:51 -0700 |
---|---|---|
committer | Kevin O'Connor <kevin@koconnor.net> | 2023-02-13 12:12:27 -0500 |
commit | 72b6bd7efa1ae282220b4bdcfb789075807ebfd2 (patch) | |
tree | d420a1b2f33e41868662ec4d5f9cc6b9e794ebe4 /src/hc32f460/interrupts.c | |
parent | 94cbf5ff48199f4652450fbb8de682f662a2cc5a (diff) | |
download | kutter-72b6bd7efa1ae282220b4bdcfb789075807ebfd2.tar.gz kutter-72b6bd7efa1ae282220b4bdcfb789075807ebfd2.tar.xz kutter-72b6bd7efa1ae282220b4bdcfb789075807ebfd2.zip |
hc32f460: Add support for hc32f460 micro-controllers
Signed-off-by: Steven Gotthardt <gotthardt@gmail.com>
Diffstat (limited to 'src/hc32f460/interrupts.c')
-rw-r--r-- | src/hc32f460/interrupts.c | 29 |
1 files changed, 29 insertions, 0 deletions
diff --git a/src/hc32f460/interrupts.c b/src/hc32f460/interrupts.c new file mode 100644 index 00000000..fb93648f --- /dev/null +++ b/src/hc32f460/interrupts.c @@ -0,0 +1,29 @@ +// Interrupt support for HC32F460 +// The library interrupt support is huge and redefines systick +// +// Copyright (C) 2022 Steven Gotthardt <gotthardt@gmail.com> +// +// This file may be distributed under the terms of the GNU GPLv3 license. + +#include "hc32f460.h" + +#define IRQ_PRIORITY_DEFAULT 15u + +/* the interrupts on the hc32f460 can be 're-assigned' + The author can choose the irqType (IRQ000_Handler, etc...) + that the source (irqSrc) triggers + */ + +void IrqRegistration(en_int_src_t irqSrc, IRQn_Type irqType) +{ + stc_intc_sel_field_t *stcIntSel = (stc_intc_sel_field_t *) + ((uint32_t)(&M4_INTC->SEL0) + (4u * irqType)); + + // what is the source of the selected interrupt? (USART, etc...) + stcIntSel->INTSEL = irqSrc; + + // set priority and enable + NVIC_SetPriority(irqType, IRQ_PRIORITY_DEFAULT); + NVIC_ClearPendingIRQ(irqType); + NVIC_EnableIRQ(irqType); +} |