STM32corecm3内核程序.docx

上传人:b****6 文档编号:5952582 上传时间:2023-01-02 格式:DOCX 页数:24 大小:17.46KB
下载 相关 举报
STM32corecm3内核程序.docx_第1页
第1页 / 共24页
STM32corecm3内核程序.docx_第2页
第2页 / 共24页
STM32corecm3内核程序.docx_第3页
第3页 / 共24页
STM32corecm3内核程序.docx_第4页
第4页 / 共24页
STM32corecm3内核程序.docx_第5页
第5页 / 共24页
点击查看更多>>
下载资源
资源描述

STM32corecm3内核程序.docx

《STM32corecm3内核程序.docx》由会员分享,可在线阅读,更多相关《STM32corecm3内核程序.docx(24页珍藏版)》请在冰豆网上搜索。

STM32corecm3内核程序.docx

STM32corecm3内核程序

/**************************************************************************//**

*@filecore_cm3.c

*@briefCMSISCortex-M3CorePeripheralAccessLayerSourceFile

*@versionV1.30

*@date30.October2009

*

*@note

*Copyright(C)2009ARMLimited.Allrightsreserved.

*

*@par

*ARMLimited(ARM)issupplyingthissoftwareforusewithCortex-M

*processorbasedmicrocontrollers.Thisfilecanbefreelydistributed

*withindevelopmenttoolsthataresupportingsuchARMbasedprocessors.

*

*@par

*THISSOFTWAREISPROVIDED"ASIS".NOWARRANTIES,WHETHEREXPRESS,IMPLIED

*ORSTATUTORY,INCLUDING,BUTNOTLIMITEDTO,IMPLIEDWARRANTIESOF

*MERCHANTABILITYANDFITNESSFORAPARTICULARPURPOSEAPPLYTOTHISSOFTWARE.

*ARMSHALLNOT,INANYCIRCUMSTANCES,BELIABLEFORSPECIAL,INCIDENTAL,OR

*CONSEQUENTIALDAMAGES,FORANYREASONWHATSOEVER.

*

******************************************************************************/

#include

/*definecompilerspecificsymbols*/

#ifdefined(__CC_ARM)

#define__ASM__asm/*!

#define__INLINE__inline/*!

#elifdefined(__ICCARM__)

#define__ASM__asm/*!

#define__INLINEinline/*!

*/

#elifdefined(__GNUC__)

#define__ASM__asm/*!

#define__INLINEinline/*!

#elifdefined(__TASKING__)

#define__ASM__asm/*!

#define__INLINEinline/*!

#endif

/*###################CompilerspecificIntrinsics###########################*/

#ifdefined(__CC_ARM)/*------------------RealViewCompiler-----------------*/

/*ARMarmccspecificfunctions*/

/**

*@briefReturntheProcessStackPointer

*

*@returnProcessStackPointer

*

*Returntheactualprocessstackpointer

*/

__ASMuint32_t__get_PSP(void)

{

mrsr0,psp

bxlr

}

/**

*@briefSettheProcessStackPointer

*

*@paramtopOfProcStackProcessStackPointer

*

*AssignthevalueProcessStackPointertotheMSP

*(processstackpointer)Cortexprocessorregister

*/

__ASMvoid__set_PSP(uint32_ttopOfProcStack)

{

msrpsp,r0

bxlr

}

/**

*@briefReturntheMainStackPointer

*

*@returnMainStackPointer

*

*ReturnthecurrentvalueoftheMSP(mainstackpointer)

*Cortexprocessorregister

*/

__ASMuint32_t__get_MSP(void)

{

mrsr0,msp

bxlr

}

/**

*@briefSettheMainStackPointer

*

*@paramtopOfMainStackMainStackPointer

*

*AssignthevaluemainStackPointertotheMSP

*(mainstackpointer)Cortexprocessorregister

*/

__ASMvoid__set_MSP(uint32_tmainStackPointer)

{

msrmsp,r0

bxlr

}

/**

*@briefReversebyteorderinunsignedshortvalue

*

*@paramvaluevaluetoreverse

*@returnreversedvalue

*

*Reversebyteorderinunsignedshortvalue

*/

__ASMuint32_t__REV16(uint16_tvalue)

{

rev16r0,r0

bxlr

}

/**

*@briefReversebyteorderinsignedshortvaluewithsignextensiontointeger

*

*@paramvaluevaluetoreverse

*@returnreversedvalue

*

*Reversebyteorderinsignedshortvaluewithsignextensiontointeger

*/

__ASMint32_t__REVSH(int16_tvalue)

{

revshr0,r0

bxlr

}

#if(__ARMCC_VERSION<400000)

/**

*@briefRemovetheexclusivelockcreatedbyldrex

*

*Removestheexclusivelockwhichiscreatedbyldrex.

*/

__ASMvoid__CLREX(void)

{

clrex

}

/**

*@briefReturntheBasePriorityvalue

*

*@returnBasePriority

*

*Returnthecontentofthebasepriorityregister

*/

__ASMuint32_t__get_BASEPRI(void)

{

mrsr0,basepri

bxlr

}

/**

*@briefSettheBasePriorityvalue

*

*@parambasePriBasePriority

*

*Setthebasepriorityregister

*/

__ASMvoid__set_BASEPRI(uint32_tbasePri)

{

msrbasepri,r0

bxlr

}

/**

*@briefReturnthePriorityMaskvalue

*

*@returnPriMask

*

*Returnstateoftheprioritymaskbitfromtheprioritymaskregister

*/

__ASMuint32_t__get_PRIMASK(void)

{

mrsr0,primask

bxlr

}

/**

*@briefSetthePriorityMaskvalue

*

*@parampriMaskPriMask

*

*Settheprioritymaskbitintheprioritymaskregister

*/

__ASMvoid__set_PRIMASK(uint32_tpriMask)

{

msrprimask,r0

bxlr

}

/**

*@briefReturntheFaultMaskvalue

*

*@returnFaultMask

*

*Returnthecontentofthefaultmaskregister

*/

__ASMuint32_t__get_FAULTMASK(void)

{

mrsr0,faultmask

bxlr

}

/**

*@briefSettheFaultMaskvalue

*

*@paramfaultMaskfaultMaskvalue

*

*Setthefaultmaskregister

*/

__ASMvoid__set_FAULTMASK(uint32_tfaultMask)

{

msrfaultmask,r0

bxlr

}

/**

*@briefReturntheControlRegistervalue

*

*@returnControlvalue

*

*Returnthecontentofthecontrolregister

*/

__ASMuint32_t__get_CONTROL(void)

{

mrsr0,control

bxlr

}

/**

*@briefSettheControlRegistervalue

*

*@paramcontrolControlvalue

*

*Setthecontrolregister

*/

__ASMvoid__set_CONTROL(uint32_tcontrol)

{

msrcontrol,r0

bxlr

}

#endif/*__ARMCC_VERSION*/

#elif(defined(__ICCARM__))/*------------------ICCCompiler-------------------*/

/*IARiccarmspecificfunctions*/

#pragmadiag_suppress=Pe940

/**

*@briefReturntheProcessStackPointer

*

*@returnProcessStackPointer

*

*Returntheactualprocessstackpointer

*/

uint32_t__get_PSP(void)

{

__ASM("mrsr0,psp");

__ASM("bxlr");

}

/**

*@briefSettheProcessStackPointer

*

*@paramtopOfProcStackProcessStackPointer

*

*AssignthevalueProcessStackPointertotheMSP

*(processstackpointer)Cortexprocessorregister

*/

void__set_PSP(uint32_ttopOfProcStack)

{

__ASM("msrpsp,r0");

__ASM("bxlr");

}

/**

*@briefReturntheMainStackPointer

*

*@returnMainStackPointer

*

*ReturnthecurrentvalueoftheMSP(mainstackpointer)

*Cortexprocessorregister

*/

uint32_t__get_MSP(void)

{

__ASM("mrsr0,msp");

__ASM("bxlr");

}

/**

*@briefSettheMainStackPointer

*

*@paramtopOfMainStackMainStackPointer

*

*AssignthevaluemainStackPointertotheMSP

*(mainstackpointer)Cortexprocessorregister

*/

void__set_MSP(uint32_ttopOfMainStack)

{

__ASM("msrmsp,r0");

__ASM("bxlr");

}

/**

*@briefReversebyteorderinunsignedshortvalue

*

*@paramvaluevaluetoreverse

*@returnreversedvalue

*

*Reversebyteorderinunsignedshortvalue

*/

uint32_t__REV16(uint16_tvalue)

{

__ASM("rev16r0,r0");

__ASM("bxlr");

}

/**

*@briefReversebitorderofvalue

*

*@paramvaluevaluetoreverse

*@returnreversedvalue

*

*Reversebitorderofvalue

*/

uint32_t__RBIT(uint32_tvalue)

{

__ASM("rbitr0,r0");

__ASM("bxlr");

}

/**

*@briefLDRExclusive(8bit)

*

*@param*addraddresspointer

*@returnvalueof(*address)

*

*ExclusiveLDRcommandfor8bitvalues)

*/

uint8_t__LDREXB(uint8_t*addr)

{

__ASM("ldrexbr0,[r0]");

__ASM("bxlr");

}

/**

*@briefLDRExclusive(16bit)

*

*@param*addraddresspointer

*@returnvalueof(*address)

*

*ExclusiveLDRcommandfor16bitvalues

*/

uint16_t__LDREXH(uint16_t*addr)

{

__ASM("ldrexhr0,[r0]");

__ASM("bxlr");

}

/**

*@briefLDRExclusive(32bit)

*

*@param*addraddresspointer

*@returnvalueof(*address)

*

*ExclusiveLDRcommandfor32bitvalues

*/

uint32_t__LDREXW(uint32_t*addr)

{

__ASM("ldrexr0,[r0]");

__ASM("bxlr");

}

/**

*@briefSTRExclusive(8bit)

*

*@paramvaluevaluetostore

*@param*addraddresspointer

*@returnsuccessful/failed

*

*ExclusiveSTRcommandfor8bitvalues

*/

uint32_t__STREXB(uint8_tvalue,uint8_t*addr)

{

__ASM("strexbr0,r0,[r1]");

__ASM("bxlr");

}

/**

*@briefSTRExclusive(16bit)

*

*@paramvaluevaluetostore

*@param*addraddresspointer

*@returnsuccessful/failed

*

*ExclusiveSTRcommandfor16bitvalues

*/

uint32_t__STREXH(uint16_tvalue,uint16_t*addr)

{

__ASM("strexhr0,r0,[r1]");

__ASM("bxlr");

}

/**

*@briefSTRExclusive(32bit)

*

*@paramvaluevaluetostore

*@param*addraddresspointer

*@returnsuccessful/failed

*

*ExclusiveSTRcommandfor32bitvalues

*/

uint32_t__STREXW(uint32_tvalue,uint32_t*addr)

{

__ASM("strexr0,r0,[r1]");

__ASM("bxlr");

}

#pragmadiag_default=Pe940

#elif(defined(__GNUC__))/*------------------GNUCompiler---------------------*/

/*GNUgccspecificfunctions*/

/**

*@briefReturntheProcessStackPointer

*

*@returnProcessStackPointer

*

*Returntheactualprocessstackpointer

*/

uint32_t__get_PSP(void)__attribute__((naked));

uint32_t__get_PSP(void)

{

uint32_tresult=0;

__ASMvolatile("MRS%0,psp\n\t"

"MOVr0,%0\n\t"

"BXlr\n\t":

"=r"(result));

return(result);

}

/**

*@briefSettheProcessStackPointer

*

*@paramtopOfProcStackProcessStackPointer

*

*AssignthevalueProcessStackPointertotheMSP

*(processstackpointer)Cortexprocessorregister

*/

void__set_PSP(uint32_ttopOfProcStack)__attribute__((naked));

void__set_PSP(uint32_ttopOfProcStack)

{

__ASMvolatile("MSRpsp,%0\n\t"

"BXlr\n\t":

:

"r"(topOfProcStack));

}

/**

*@briefReturntheMainStackPointer

*

*@returnMainStackPointer

*

*ReturnthecurrentvalueoftheMSP(mainstackpointer)

*Cortexprocessorregister

*/

uint32_t__get_MSP(void)__attribute__((naked));

uint32_t__get_MSP(void)

{

uint32_tresult=0;

__ASMvolatile("MRS%0,msp\n\t"

"MOVr0,%0\n\t"

"BXlr\n\t"

展开阅读全文
相关资源
猜你喜欢
相关搜索

当前位置:首页 > 表格模板 > 调查报告

copyright@ 2008-2022 冰豆网网站版权所有

经营许可证编号:鄂ICP备2022015515号-1