⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 core_cm3.h

📁 LPC1700在线升级方案V1.00
💻 H
📖 第 1 页 / 共 5 页
字号:


/*
 * Memory mapping of Cortex-M3 Hardware
 */
#define SCS_BASE            (0xE000E000)                         /*!< System Control Space Base Address */
#define ITM_BASE            (0xE0000000)                         /*!< ITM Base Address                  */
#define CoreDebug_BASE      (0xE000EDF0)                         /*!< Core Debug Base Address           */
#define SysTick_BASE        (SCS_BASE +  0x0010)                 /*!< SysTick Base Address              */
#define NVIC_BASE           (SCS_BASE +  0x0100)                 /*!< NVIC Base Address                 */
#define SCB_BASE            (SCS_BASE +  0x0D00)                 /*!< System Control Block Base Address */

#define InterruptType       ((InterruptType_Type *) SCS_BASE)    /*!< Interrupt Type Register           */
#define SCB                 ((SCB_Type *)           SCB_BASE)    /*!< SCB configuration struct          */
#define SysTick             ((SysTick_Type *)       SysTick_BASE)/*!< SysTick configuration struct      */
#define NVIC                ((NVIC_Type *)          NVIC_BASE)   /*!< NVIC configuration struct         */
#define ITM                 ((ITM_Type *)           ITM_BASE)    /*!< ITM configuration struct          */
#define CoreDebug           ((CoreDebug_Type *)     CoreDebug_BASE)/*!< Core Debug configuration struct */

#if defined (__MPU_PRESENT) && (__MPU_PRESENT == 1)
  #define MPU_BASE          (SCS_BASE +  0x0D90)                 /*!< Memory Protection Unit            */
  #define MPU               ((MPU_Type*)            MPU_BASE)    /*!< Memory Protection Unit            */
#endif

/*********************************************************************************************************
 * Hardware Abstraction Layer
 ********************************************************************************************************/


#if defined ( __CC_ARM   )
  #define __ASM            __asm                                 /*!< asm keyword for ARM Compiler      */
  #define __INLINE         __inline                              /*!< inline keyword for ARM Compiler   */

#elif defined ( __ICCARM__ )
  #define __ASM           __asm                                  /*!< asm keyword for IAR Compiler      */
  #define __INLINE        inline                                 /*!< inline keyword for IAR Compiler.  */
                                                                 /*   Only avaiable in High optimization*/
                                                                 /*   mode!                             */

#elif defined   (  __GNUC__  )
  #define __ASM            __asm                                 /*!< asm keyword for GNU Compiler      */
  #define __INLINE         inline                                /*!< inline keyword for GNU Compiler   */

#elif defined   (  __TASKING__  )
  #define __ASM            __asm                                 /*!< asm keyword for TASKING Compiler   */
  #define __INLINE         inline                                /*!< inline keyword for TASKING Compiler*/

#endif


/* #####################################  Compiler specific Intrinsics  #################################*/

#if defined ( __CC_ARM   )
/*---------------------------------------- RealView Compiler --------------------------------------------*/
/********************************************************************************************************
 * ARM armcc specific functions
 ********************************************************************************************************/

#define __enable_fault_irq                __enable_fiq
#define __disable_fault_irq               __disable_fiq

#define __NOP                             __nop
#define __WFI                             __wfi
#define __WFE                             __wfe
#define __SEV                             __sev
#define __ISB()                           __isb(0)
#define __DSB()                           __dsb(0)
#define __DMB()                           __dmb(0)
#define __REV                             __rev
#define __RBIT                            __rbit
#define __LDREXB(ptr)                     ((unsigned char ) __ldrex(ptr))
#define __LDREXH(ptr)                     ((unsigned short) __ldrex(ptr))
#define __LDREXW(ptr)                     ((unsigned int  ) __ldrex(ptr))
#define __STREXB(value, ptr)              __strex(value, ptr)
#define __STREXH(value, ptr)              __strex(value, ptr)
#define __STREXW(value, ptr)              __strex(value, ptr)


/*
 * intrinsic unsigned long long __ldrexd(volatile void *ptr)
 */
/*
 * intrinsic int __strexd(unsigned long long val, volatile void *ptr)
 */
/*
 * intrinsic void __enable_irq();
 */
/*
 * intrinsic void __disable_irq();
 */


/*********************************************************************************************************
 * @brief  Return the Process Stack Pointer
 *
 * @param  none
 * @return uint32_t ProcessStackPointer
 *
 * Return the actual process stack pointer
 ********************************************************************************************************/
extern uint32_t __get_PSP(void);

/*********************************************************************************************************
 * @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  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);

/********************************************************************************************************
 * @brief  Reverse byte order in signed short value with sign extension to integer
 *
 * @param  int16_t value to reverse
 * @return int32_t reversed value
 *
 * Reverse byte order in signed short value with sign extension to integer
 ********************************************************************************************************/
extern int32_t __REVSH(int16_t value);


#if (__ARMCC_VERSION < 400000)

/*********************************************************************************************************
 * @brief  Remove the exclusive lock created by ldrex
 *
 * @param  none
 * @return none
 *
 * Removes the exclusive lock which is created by ldrex.
 ********************************************************************************************************/
extern void __CLREX(void);

/*********************************************************************************************************
 * @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);

#else                                                                   /* (__ARMCC_VERSION >= 400000)  */


/*********************************************************************************************************
 * @brief  Remove the exclusive lock created by ldrex
 *
 * @param  none
 * @return none
 *
 * Removes the exclusive lock which is created by ldrex.
 ********************************************************************************************************/
#define __CLREX       clrex

/*********************************************************************************************************
 * @brief  Return the Base Priority value
 *
 * @param  none
 * @return uint32_t BasePriority
 *
 * Return the content of the base priority register
 ********************************************************************************************************/
static __INLINE uint32_t  __get_BASEPRI(void)
{
  register uint32_t __regBasePri         __ASM("basepri");
  return(__regBasePri);
}

/*********************************************************************************************************
 * @brief  Set the Base Priority value
 *
 * @param  uint32_t BasePriority
 * @return none
 *
 * Set the base priority register
 ********************************************************************************************************/
static __INLINE void __set_BASEPRI(uint32_t basePri)

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -