Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add NVIC_DisableAll and Cortex_DisableAll functions #3318

Merged
merged 10 commits into from
Nov 5, 2024

Conversation

kasjer
Copy link
Contributor

@kasjer kasjer commented Oct 4, 2024

Function NVIC_DisableAll() disable all interrupts on NVIC controller.
Cortex_DisableAll() disables all NVIC interrupts and stops SytTick that also can generate interrupt.

Call to Cortex_DisableAll() is added to all hal_bsp_deinit() functions that are executed before control is passed from the bootloader ot the application.

In some cases hal_bsp_deinit was added.

hal_system_init() was added to platforms that did not have this function.
Now hal_system_init() calls NVIC_Relocate() (previously NVIC_Relocate was often called from SystemInit() that is usually provided by MCU manufacturer. So mynewt had copies of those files with local modifications that made it harder to maintain in case of upgrade.

Same prototypes

void NVIC_Relocate(void);
void NVIC_SetVector(IRQn_Type IRQn, uint32_t vector);
uint32_t NVIC_GetVector(IRQn_Type IRQn);

were placed in many headers and now are put in just one.

NXP MK8xF now uses common startup code with auto-generated linker script like ST and Nordic chips.

Signed-off-by: Jerzy Kasenberg [email protected]

@github-actions github-actions bot added Nordic Nordic related STM STM32 related BSP size/m labels Oct 4, 2024
@kasjer kasjer force-pushed the kasjer/cortexm-cleanup branch from 1a45350 to 4ccc855 Compare October 4, 2024 12:37
Copy link
Contributor

@sjanc sjanc left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

but please rebase before merge to trigger CI

NVIC_Relocate, NVIC_SetVector, NVIC_GetVector prototypes
were defined in a lot of places.
Now they are put in one header.

Signed-off-by: Jerzy Kasenberg <[email protected]>
New function NVIC_DisableAll() disables all interrupts
on NVIC.

Cortex_DisableAll() disables all interrupts and SysTick

Those function are intended to be called from hal_bsp_deinit
to disable interrupts before application code
reconfigures them from what boot loader set up.

Signed-off-by: Jerzy Kasenberg <[email protected]>
For CortexM devices add call to Cortex_DisableAll() that
will disable all interrupts before control is passed from
bootloader to application

Signed-off-by: Jerzy Kasenberg <[email protected]>
Function NVIC_Relocate() was called in SystemInit() which
is in file from Nordic.

Now call is moved to mynewt specific function hal_system_init
that is called just after SystemInit finishes.
This is done to leave file from external source as close to
origin as possible in case of future update.

Signed-off-by: Jerzy Kasenberg <[email protected]>
After NVIC_Relocate() was moved to different header
all hal_system_init needs additional include

Some leftover code was also cleaned.

Signed-off-by: Jerzy Kasenberg <[email protected]>
NVIC_Relocate call was placed in NXP generated file.
Now it is moved to hal_system_init function that
is way it's done in mynewt

Startup code for usbmkw41z now calls hal_system_init
as is the case for all mynewt platforms

Signed-off-by: Jerzy Kasenberg <[email protected]>
This switches to autogenerated linker scripts for CortexM.

Signed-off-by: Jerzy Kasenberg <[email protected]>
NVIC_Relocate call was placed in Ambiq generated file.
Now it is moved to hal_system_init function that
is way it's done in mynewt

hal_bsp_deinit() disable NVIC interrupts as well.

Signed-off-by: Jerzy Kasenberg <[email protected]>
NVIC_Relocate call was in two places
Now it is only in hal_system_init function that
is way it's done in mynewt

Signed-off-by: Jerzy Kasenberg <[email protected]>
@kasjer kasjer force-pushed the kasjer/cortexm-cleanup branch from 4ccc855 to 0136ea9 Compare November 4, 2024 17:58
External repository switched to master branch for now.

Signed-off-by: Jerzy Kasenberg <[email protected]>
@kasjer kasjer merged commit d6534df into apache:master Nov 5, 2024
20 checks passed
@kasjer kasjer deleted the kasjer/cortexm-cleanup branch November 5, 2024 09:19
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
BSP Nordic Nordic related size/m STM STM32 related
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants