-
Notifications
You must be signed in to change notification settings - Fork 33
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Cortex-M: NVIC and SCB code duplication cleanup
JIRA: RTOS-886
- Loading branch information
1 parent
fa2cb46
commit 2040e21
Showing
42 changed files
with
571 additions
and
1,221 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,10 @@ | ||
# | ||
# Makefile for HAL ARM common functions | ||
# | ||
# Copyright 2023 Phoenix Systems | ||
# | ||
|
||
# TODO handle other common ARM stuff (e.g GIC) and | ||
# select relevant components here | ||
|
||
OBJS += $(addprefix $(PREFIX_O)hal/arm/, nvic.o scb.o) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
/* | ||
* Phoenix-RTOS | ||
* | ||
* Operating system kernel | ||
* | ||
* Nested Vector Interrupt Controller | ||
* | ||
* Copyright 2017, 2020, 2022, 2024 Phoenix Systems | ||
* Author: Pawel Pisarczyk, Hubert Buczynski, Damian Loewnau, Aleksander Kaminski | ||
* | ||
* This file is part of Phoenix-RTOS. | ||
* | ||
* %LICENSE% | ||
*/ | ||
|
||
|
||
#include <arch/cpu.h> | ||
#include "nvic.h" | ||
|
||
|
||
static struct { | ||
volatile u32 *nvic; | ||
} nvic_common; | ||
|
||
|
||
/* clang-format off */ | ||
enum { nvic_iser = 0, nvic_icer = 32, nvic_ispr = 64, nvic_icpr = 96, nvic_iabr = 128, | ||
nvic_ip = 192 }; | ||
/* clang-format on */ | ||
|
||
|
||
void _hal_nvicSetIRQ(s8 irqn, u8 state) | ||
{ | ||
volatile u32 *ptr = nvic_common.nvic + ((u8)irqn >> 5) + ((state != 0) ? nvic_iser : nvic_icer); | ||
*ptr = 1u << (irqn & 0x1f); | ||
|
||
hal_cpuDataSyncBarrier(); | ||
hal_cpuInstrBarrier(); | ||
} | ||
|
||
|
||
void _hal_nvicSetPriority(s8 irqn, u32 priority) | ||
{ | ||
volatile u8 *ptr; | ||
|
||
ptr = ((u8*)(nvic_common.nvic + nvic_ip)) + irqn; | ||
|
||
*ptr = (priority << 4) & 0xff; | ||
} | ||
|
||
|
||
void _hal_nvicSetPending(s8 irqn) | ||
{ | ||
volatile u32 *ptr = nvic_common.nvic + ((u8)irqn >> 5) + nvic_ispr; | ||
|
||
*ptr = 1u << (irqn & 0x1f); | ||
|
||
hal_cpuDataSyncBarrier(); | ||
} | ||
|
||
|
||
void _hal_nvicInit(void) | ||
{ | ||
nvic_common.nvic = (void *)0xe000e100; | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,36 @@ | ||
/* | ||
* Phoenix-RTOS | ||
* | ||
* Operating system kernel | ||
* | ||
* Nested Vector Interrupt Controller | ||
* | ||
* Copyright 2017, 2020, 2022, 2024 Phoenix Systems | ||
* Author: Pawel Pisarczyk, Hubert Buczynski, Damian Loewnau, Aleksander Kaminski | ||
* | ||
* This file is part of Phoenix-RTOS. | ||
* | ||
* %LICENSE% | ||
*/ | ||
|
||
|
||
#ifndef HAL_ARMV_NVIC_H_ | ||
#define HAL_ARMV_NVIC_H_ | ||
|
||
|
||
#include "hal/types.h" | ||
|
||
|
||
void _hal_nvicSetIRQ(s8 irqn, u8 state); | ||
|
||
|
||
void _hal_nvicSetPriority(s8 irqn, u32 priority); | ||
|
||
|
||
void _hal_nvicSetPending(s8 irqn); | ||
|
||
|
||
void _hal_nvicInit(void); | ||
|
||
|
||
#endif |
Oops, something went wrong.