📄 core_cm3.h
字号:
/*********************************************************************************************************
* @brief Set the Process Stack Pointer
*
* @param uint32_t Process Stack Pointer
* @return none
*
* Assign the value ProcessStackPointer to the MSP
* (process stack pointer) Cortex processor register
********************************************************************************************************/
extern void __set_PSP(uint32_t topOfProcStack);
/*********************************************************************************************************
* @brief Return the Main Stack Pointer
*
* @param none
* @return uint32_t Main Stack Pointer
*
* Return the current value of the MSP (main stack pointer)
* Cortex processor register
********************************************************************************************************/
extern uint32_t __get_MSP(void);
/*********************************************************************************************************
* @brief Set the Main Stack Pointer
*
* @param uint32_t Main Stack Pointer
* @return none
*
* Assign the value mainStackPointer to the MSP
* (main stack pointer) Cortex processor register
********************************************************************************************************/
extern void __set_MSP(uint32_t topOfMainStack);
/*********************************************************************************************************
* @brief Return the Base Priority value
*
* @param none
* @return uint32_t BasePriority
*
* Return the content of the base priority register
********************************************************************************************************/
extern uint32_t __get_BASEPRI(void);
/*********************************************************************************************************
* @brief Set the Base Priority value
*
* @param uint32_t BasePriority
* @return none
*
* Set the base priority register
********************************************************************************************************/
extern void __set_BASEPRI(uint32_t basePri);
/*********************************************************************************************************
* @brief Return the Priority Mask value
*
* @param none
* @return uint32_t PriMask
*
* Return the state of the priority mask bit from the priority mask
* register
********************************************************************************************************/
extern uint32_t __get_PRIMASK(void);
/*********************************************************************************************************
* @brief Set the Priority Mask value
*
* @param uint32_t PriMask
* @return none
*
* Set the priority mask bit in the priority mask register
********************************************************************************************************/
extern void __set_PRIMASK(uint32_t priMask);
/*********************************************************************************************************
* @brief Return the Fault Mask value
*
* @param none
* @return uint32_t FaultMask
*
* Return the content of the fault mask register
********************************************************************************************************/
extern uint32_t __get_FAULTMASK(void);
/*********************************************************************************************************
* @brief Set the Fault Mask value
*
* @param uint32_t faultMask value
* @return none
*
* Set the fault mask register
********************************************************************************************************/
extern void __set_FAULTMASK(uint32_t faultMask);
/*********************************************************************************************************
* @brief Return the Control Register value
*
* @param none
* @return uint32_t Control value
*
* Return the content of the control register
********************************************************************************************************/
extern uint32_t __get_CONTROL(void);
/*********************************************************************************************************
* @brief Set the Control Register value
*
* @param uint32_t Control value
* @return none
*
* Set the control register
********************************************************************************************************/
extern void __set_CONTROL(uint32_t control);
/*********************************************************************************************************
* @brief Reverse byte order in integer value
*
* @param uint32_t value to reverse
* @return uint32_t reversed value
*
* Reverse byte order in integer value
********************************************************************************************************/
extern uint32_t __REV(uint32_t value);
/*********************************************************************************************************
* @brief Reverse byte order in unsigned short value
*
* @param uint16_t value to reverse
* @return uint32_t reversed value
*
* Reverse byte order in unsigned short value
********************************************************************************************************/
extern uint32_t __REV16(uint16_t value);
/********************************************************************************************************
* Reverse byte order in signed short value with sign extension to integer
*
* @param int16_t value to reverse
* @return int32_t reversed value
*
* @brief Reverse byte order in signed short value with sign extension to integer
********************************************************************************************************/
extern int32_t __REVSH(int16_t value);
/*********************************************************************************************************
* @brief Reverse bit order of value
*
* @param uint32_t value to reverse
* @return uint32_t reversed value
*
* Reverse bit order of value
********************************************************************************************************/
extern uint32_t __RBIT(uint32_t value);
/*********************************************************************************************************
* @brief LDR Exclusive
*
* @param uint8_t* address
* @return uint8_t value of (*address)
*
* Exclusive LDR command
********************************************************************************************************/
extern uint8_t __LDREXB(uint8_t *addr);
/*********************************************************************************************************
* @brief LDR Exclusive
*
* @param uint16_t* address
* @return uint16_t value of (*address)
*
* Exclusive LDR command
********************************************************************************************************/
extern uint16_t __LDREXH(uint16_t *addr);
/*********************************************************************************************************
* @brief LDR Exclusive
*
* @param uint32_t* address
* @return uint32_t value of (*address)
*
* Exclusive LDR command
********************************************************************************************************/
extern uint32_t __LDREXW(uint32_t *addr);
/*********************************************************************************************************
* @brief STR Exclusive
*
* @param uint8_t *address
* @param uint8_t value to store
* @return uint32_t successful / failed
*
* Exclusive STR command
********************************************************************************************************/
extern uint32_t __STREXB(uint8_t value, uint8_t *addr);
/*********************************************************************************************************
* @brief STR Exclusive
*
* @param uint16_t *address
* @param uint16_t value to store
* @return uint32_t successful / failed
*
* Exclusive STR command
********************************************************************************************************/
extern uint32_t __STREXH(uint16_t value, uint16_t *addr);
/*********************************************************************************************************
* @brief STR Exclusive
*
* @param uint32_t *address
* @param uint32_t value to store
* @return uint32_t successful / failed
*
* Exclusive STR command
********************************************************************************************************/
extern uint32_t __STREXW(uint32_t value, uint32_t *addr);
#elif (defined (__TASKING__))
/*------------------------------------------- TASKING Compiler -----------------------------------------*/
/*
* TASKING carm specific functions
*/
/********************************************************************************************************
* The CMSIS functions have been implemented as intrinsics in the compiler.
* Please use "carm -?i" to get an up to date list of all instrinsics,
* Including the CMSIS ones.
********************************************************************************************************/
#endif
/* ####################################### NVIC functions ######################################### */
/*********************************************************************************************************
* @brief Set the Priority Grouping in NVIC Interrupt Controller
*
* @param uint32_t priority_grouping is priority grouping field
* @return none
*
* Set the priority grouping field using the required unlock sequence.
* The parameter priority_grouping is assigned to the field
* SCB->AIRCR [10:8] PRIGROUP field. Only values from 0..7 are used.
* In case of a conflict between priority grouping and available
* priority bits (__NVIC_PRIO_BITS) the smallest possible priority group is set.
********************************************************************************************************/
static __INLINE void NVIC_SetPriorityGrouping(uint32_t PriorityGroup)
{
uint32_t reg_value;
uint32_t PriorityGroupTmp = (PriorityGroup & 0x07); /* only values 0..7 are used */
reg_value = SCB->AIRCR; /* read old register configuration */
reg_value &= ~((0xFFFFU << 16) | (0x0F << 8)); /* clear bits to change */
reg_value = ((reg_value | NVIC_AIRCR_VECTKEY | (PriorityGroupTmp << 8)));
/* Insert write key and priorty group*/
SCB->AIRCR = reg_value;
}
/*********************************************************************************************************
* @brief Get the Priority Grouping from NVIC Interrupt Controller
*
* @param none
* @return uint32_t priority grouping field
*
* Get the priority grouping from NVIC Interrupt Controller.
* priority grouping is SCB->AIRCR [10:8] PRIGROUP field.
********************************************************************************************************/
static __INLINE uint32_t NVIC_GetPriorityGrouping(void)
{
return ((SCB->AIRCR >> 8) & 0x07); /* read priority grouping field */
}
/*********************************************************************************************************
* @brief Enable Interrupt in NVIC Interrupt Controller
*
* @param IRQn_Type IRQn specifies the interrupt number
* @return none
*
* Enable a device specific interupt in the NVIC interrupt controller.
* The interrupt number cannot be a negative value.
********************************************************************************************************/
static __INLINE void NVIC_EnableIRQ(IRQn_Type IRQn)
{
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -