Loading...
Searching...
No Matches
ARM Cortex-M common

Common implementations and headers for Cortex-M family based micro-controllers. More...

Detailed Description

Common implementations and headers for Cortex-M family based micro-controllers.

Files

file  architecture_arch.h
 Architecture details.
 
file  atomic_utils_arch.h
 Implementation of fast atomic utility functions.
 
file  cpu.h
 Basic definitions for the Cortex-M common module.
 
file  cpu_conf_common.h
 Common CPU definitione for Cortex-M family based MCUs.
 
file  irq_arch.h
 Implementation of the kernels irq interface.
 
file  mpu.h
 Cortex-M Memory Protection Unit (MPU) Driver Header File.
 
file  thread_arch.h
 Implementation of the kernels thread interface.
 
file  vectors_cortexm.h
 Default interrupt vectors shared by Cortex-M based CPUs.
 

Macros

#define STACK_CANARY_WORD   (0xE7FEE7FEu)
 Interrupt stack canary value.
 
#define PROVIDES_PM_SET_LOWEST
 All Cortex-m-based CPUs provide pm_set_lowest.
 
#define CORTEXM_SCB_CPACR_FPU_ACCESS_FULL   (0x00f00000)
 Pattern to write into the co-processor Access Control Register to allow full FPU access.
 

Functions

void cortexm_init (void)
 Initialize Cortex-M specific core parts of the CPU.
 
static void cortexm_init_fpu (void)
 Initialize Cortex-M FPU.
 
void cortexm_init_isr_priorities (void)
 Initialize Cortex-M interrupt priorities.
 
void cortexm_init_misc (void)
 Initialize Cortex-M misc functions.
 
static uintptr_t cpu_get_caller_pc (void)
 Returns the current content of the link register (lr)
 
static void cortexm_sleep_until_event (void)
 Put the CPU into the 'wait for event' sleep mode.
 
static void cortexm_sleep (int deep)
 Put the CPU into (deep) sleep mode, using the WFI instruction.
 
static void cortexm_isr_end (void)
 Trigger a conditional context scheduler run / context switch.
 
static void cpu_jump_to_image (uint32_t image_address)
 Jumps to another image in flash.
 
bool cpu_check_address (volatile const char *address)
 Checks is memory address valid or not.
 

Macro Definition Documentation

◆ CORTEXM_SCB_CPACR_FPU_ACCESS_FULL

#define CORTEXM_SCB_CPACR_FPU_ACCESS_FULL   (0x00f00000)

Pattern to write into the co-processor Access Control Register to allow full FPU access.

Used in the cortexm_init_fpu inline function below.

Definition at line 65 of file cpu.h.

◆ PROVIDES_PM_SET_LOWEST

#define PROVIDES_PM_SET_LOWEST

All Cortex-m-based CPUs provide pm_set_lowest.

The pm_set_lowest is provided either by the pm_layered module if used, or alternatively as fallback by the cortexm's own implementation.

Definition at line 57 of file cpu.h.

◆ STACK_CANARY_WORD

#define STACK_CANARY_WORD   (0xE7FEE7FEu)

Interrupt stack canary value.

Note
0xe7fe is the ARM Thumb machine code equivalent of asm("bl #-2\n") or 'while (1);', i.e. an infinite loop.

Definition at line 49 of file cpu.h.

Function Documentation

◆ cortexm_init()

void cortexm_init ( void  )

Initialize Cortex-M specific core parts of the CPU.

cortexm_init calls, in a default order, cortexm_init_fpu, cortexm_init_isr_priorities, and cortexm_init_misc. Also performs other default initialisations, including ones which you may or may not want.

Unless you have special requirements (like nRF52 with SD has), it is sufficient to call just cortexm_init and the cortexm_init_* functions do not need to (and should not) be called separately. If you have conflicting requirements, you may want to have a look cpu/nrft/cpu.c for an example of a non-default approach.

◆ cortexm_init_fpu()

static void cortexm_init_fpu ( void  )
inlinestatic

Initialize Cortex-M FPU.

Called from cpu/nrf52/cpu.c, since it cannot use the whole cortexm_init due to conflicting requirements.

Defined here as a static inline function to allow all callers to optimise this away if the FPU is not used.

Definition at line 92 of file cpu.h.

◆ cortexm_init_isr_priorities()

void cortexm_init_isr_priorities ( void  )

Initialize Cortex-M interrupt priorities.

Called from cpu/nrf52/cpu.c, since it cannot use the whole cortexm_init due to conflicting requirements.

Define CPU_CORTEXM_INIT_SUBFUNCTIONS to make this function publicly available.

◆ cortexm_init_misc()

void cortexm_init_misc ( void  )

Initialize Cortex-M misc functions.

Called from cpu/nrf52/cpu.c, since it cannot use the whole cortexm_init due to conflicting requirements.

Define CPU_CORTEXM_INIT_SUBFUNCTIONS to make this function publicly available.

◆ cortexm_isr_end()

static void cortexm_isr_end ( void  )
inlinestatic

Trigger a conditional context scheduler run / context switch.

This function is supposed to be called in the end of each ISR.

Definition at line 180 of file cpu.h.

◆ cortexm_sleep()

static void cortexm_sleep ( int  deep)
inlinestatic

Put the CPU into (deep) sleep mode, using the WFI instruction.

Parameters
[in]deep!=0 for deep sleep, 0 for light sleep

Definition at line 155 of file cpu.h.

◆ cortexm_sleep_until_event()

static void cortexm_sleep_until_event ( void  )
inlinestatic

Put the CPU into the 'wait for event' sleep mode.

This function is meant to be used for short periods of time, where it is not feasible to switch to the idle thread and back.

Definition at line 145 of file cpu.h.

◆ cpu_check_address()

bool cpu_check_address ( volatile const char *  address)

Checks is memory address valid or not.

This function can be used to check for memory size, peripherals availability, etc.

Parameters
[in]addressAddress to check
Returns
true if address is valid

◆ cpu_get_caller_pc()

static uintptr_t cpu_get_caller_pc ( void  )
inlinestatic

Returns the current content of the link register (lr)

Returns
content of the link register (lr)

Definition at line 132 of file cpu.h.

◆ cpu_jump_to_image()

static void cpu_jump_to_image ( uint32_t  image_address)
inlinestatic

Jumps to another image in flash.

This function is supposed to be called by a bootloader application.

Parameters
[in]image_addressaddress in flash of other image

Definition at line 194 of file cpu.h.