123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442 |
- //*****************************************************************************
- //
- // cpu.c - Instruction wrappers for special CPU instructions needed by the
- // drivers.
- //
- // Copyright (c) 2006-2011 Texas Instruments Incorporated. All rights reserved.
- // Software License Agreement
- //
- // Texas Instruments (TI) is supplying this software for use solely and
- // exclusively on TI's microcontroller products. The software is owned by
- // TI and/or its suppliers, and is protected under applicable copyright
- // laws. You may not combine this software with "viral" open-source
- // software in order to form a larger program.
- //
- // THIS SOFTWARE IS PROVIDED "AS IS" AND WITH ALL FAULTS.
- // NO WARRANTIES, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING, BUT
- // NOT LIMITED TO, IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR
- // A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE. TI SHALL NOT, UNDER ANY
- // CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR CONSEQUENTIAL
- // DAMAGES, FOR ANY REASON WHATSOEVER.
- //
- // This is part of revision 8264 of the Stellaris Peripheral Driver Library.
- //
- //*****************************************************************************
- #include "driverlib/cpu.h"
- //*****************************************************************************
- //
- // Wrapper function for the CPSID instruction. Returns the state of PRIMASK
- // on entry.
- //
- //*****************************************************************************
- #if defined(codered) || defined(gcc) || defined(sourcerygxx)
- unsigned long __attribute__((naked))
- CPUcpsid(void)
- {
- unsigned long ulRet;
- //
- // Read PRIMASK and disable interrupts.
- //
- __asm(" mrs r0, PRIMASK\n"
- " cpsid i\n"
- " bx lr\n"
- : "=r" (ulRet));
- //
- // The return is handled in the inline assembly, but the compiler will
- // still complain if there is not an explicit return here (despite the fact
- // that this does not result in any code being produced because of the
- // naked attribute).
- //
- return(ulRet);
- }
- #endif
- #if defined(ewarm)
- unsigned long
- CPUcpsid(void)
- {
- //
- // Read PRIMASK and disable interrupts.
- //
- __asm(" mrs r0, PRIMASK\n"
- " cpsid i\n");
- //
- // "Warning[Pe940]: missing return statement at end of non-void function"
- // is suppressed here to avoid putting a "bx lr" in the inline assembly
- // above and a superfluous return statement here.
- //
- #pragma diag_suppress=Pe940
- }
- #pragma diag_default=Pe940
- #endif
- #if defined(rvmdk) || defined(__ARMCC_VERSION)
- __asm unsigned long
- CPUcpsid(void)
- {
- //
- // Read PRIMASK and disable interrupts.
- //
- mrs r0, PRIMASK;
- cpsid i;
- bx lr
- }
- #endif
- #if defined(ccs)
- unsigned long
- CPUcpsid(void)
- {
- //
- // Read PRIMASK and disable interrupts.
- //
- __asm(" mrs r0, PRIMASK\n"
- " cpsid i\n"
- " bx lr\n");
- //
- // The following keeps the compiler happy, because it wants to see a
- // return value from this function. It will generate code to return
- // a zero. However, the real return is the "bx lr" above, so the
- // return(0) is never executed and the function returns with the value
- // you expect in R0.
- //
- return(0);
- }
- #endif
- //*****************************************************************************
- //
- // Wrapper function returning the state of PRIMASK (indicating whether
- // interrupts are enabled or disabled).
- //
- //*****************************************************************************
- #if defined(codered) || defined(gcc) || defined(sourcerygxx)
- unsigned long __attribute__((naked))
- CPUprimask(void)
- {
- unsigned long ulRet;
- //
- // Read PRIMASK and disable interrupts.
- //
- __asm(" mrs r0, PRIMASK\n"
- " bx lr\n"
- : "=r" (ulRet));
- //
- // The return is handled in the inline assembly, but the compiler will
- // still complain if there is not an explicit return here (despite the fact
- // that this does not result in any code being produced because of the
- // naked attribute).
- //
- return(ulRet);
- }
- #endif
- #if defined(ewarm)
- unsigned long
- CPUprimask(void)
- {
- //
- // Read PRIMASK and disable interrupts.
- //
- __asm(" mrs r0, PRIMASK\n");
- //
- // "Warning[Pe940]: missing return statement at end of non-void function"
- // is suppressed here to avoid putting a "bx lr" in the inline assembly
- // above and a superfluous return statement here.
- //
- #pragma diag_suppress=Pe940
- }
- #pragma diag_default=Pe940
- #endif
- #if defined(rvmdk) || defined(__ARMCC_VERSION)
- __asm unsigned long
- CPUprimask(void)
- {
- //
- // Read PRIMASK and disable interrupts.
- //
- mrs r0, PRIMASK;
- bx lr
- }
- #endif
- #if defined(ccs)
- unsigned long
- CPUprimask(void)
- {
- //
- // Read PRIMASK and disable interrupts.
- //
- __asm(" mrs r0, PRIMASK\n"
- " bx lr\n");
- //
- // The following keeps the compiler happy, because it wants to see a
- // return value from this function. It will generate code to return
- // a zero. However, the real return is the "bx lr" above, so the
- // return(0) is never executed and the function returns with the value
- // you expect in R0.
- //
- return(0);
- }
- #endif
- //*****************************************************************************
- //
- // Wrapper function for the CPSIE instruction. Returns the state of PRIMASK
- // on entry.
- //
- //*****************************************************************************
- #if defined(codered) || defined(gcc) || defined(sourcerygxx)
- unsigned long __attribute__((naked))
- CPUcpsie(void)
- {
- unsigned long ulRet;
- //
- // Read PRIMASK and enable interrupts.
- //
- __asm(" mrs r0, PRIMASK\n"
- " cpsie i\n"
- " bx lr\n"
- : "=r" (ulRet));
- //
- // The return is handled in the inline assembly, but the compiler will
- // still complain if there is not an explicit return here (despite the fact
- // that this does not result in any code being produced because of the
- // naked attribute).
- //
- return(ulRet);
- }
- #endif
- #if defined(ewarm)
- unsigned long
- CPUcpsie(void)
- {
- //
- // Read PRIMASK and enable interrupts.
- //
- __asm(" mrs r0, PRIMASK\n"
- " cpsie i\n");
- //
- // "Warning[Pe940]: missing return statement at end of non-void function"
- // is suppressed here to avoid putting a "bx lr" in the inline assembly
- // above and a superfluous return statement here.
- //
- #pragma diag_suppress=Pe940
- }
- #pragma diag_default=Pe940
- #endif
- #if defined(rvmdk) || defined(__ARMCC_VERSION)
- __asm unsigned long
- CPUcpsie(void)
- {
- //
- // Read PRIMASK and enable interrupts.
- //
- mrs r0, PRIMASK;
- cpsie i;
- bx lr
- }
- #endif
- #if defined(ccs)
- unsigned long
- CPUcpsie(void)
- {
- //
- // Read PRIMASK and enable interrupts.
- //
- __asm(" mrs r0, PRIMASK\n"
- " cpsie i\n"
- " bx lr\n");
- //
- // The following keeps the compiler happy, because it wants to see a
- // return value from this function. It will generate code to return
- // a zero. However, the real return is the "bx lr" above, so the
- // return(0) is never executed and the function returns with the value
- // you expect in R0.
- //
- return(0);
- }
- #endif
- //*****************************************************************************
- //
- // Wrapper function for the WFI instruction.
- //
- //*****************************************************************************
- #if defined(codered) || defined(gcc) || defined(sourcerygxx)
- void __attribute__((naked))
- CPUwfi(void)
- {
- //
- // Wait for the next interrupt.
- //
- __asm(" wfi\n"
- " bx lr\n");
- }
- #endif
- #if defined(ewarm)
- void
- CPUwfi(void)
- {
- //
- // Wait for the next interrupt.
- //
- __asm(" wfi\n");
- }
- #endif
- #if defined(rvmdk) || defined(__ARMCC_VERSION)
- __asm void
- CPUwfi(void)
- {
- //
- // Wait for the next interrupt.
- //
- wfi;
- bx lr
- }
- #endif
- #if defined(ccs)
- void
- CPUwfi(void)
- {
- //
- // Wait for the next interrupt.
- //
- __asm(" wfi\n");
- }
- #endif
- //*****************************************************************************
- //
- // Wrapper function for writing the BASEPRI register.
- //
- //*****************************************************************************
- #if defined(codered) || defined(gcc) || defined(sourcerygxx)
- void __attribute__((naked))
- CPUbasepriSet(unsigned long ulNewBasepri)
- {
- //
- // Set the BASEPRI register
- //
- __asm(" msr BASEPRI, r0\n"
- " bx lr\n");
- }
- #endif
- #if defined(ewarm)
- void
- CPUbasepriSet(unsigned long ulNewBasepri)
- {
- //
- // Set the BASEPRI register
- //
- __asm(" msr BASEPRI, r0\n");
- }
- #endif
- #if defined(rvmdk) || defined(__ARMCC_VERSION)
- __asm void
- CPUbasepriSet(unsigned long ulNewBasepri)
- {
- //
- // Set the BASEPRI register
- //
- msr BASEPRI, r0;
- bx lr
- }
- #endif
- #if defined(ccs)
- void
- CPUbasepriSet(unsigned long ulNewBasepri)
- {
- //
- // Set the BASEPRI register
- //
- __asm(" msr BASEPRI, r0\n");
- }
- #endif
- //*****************************************************************************
- //
- // Wrapper function for reading the BASEPRI register.
- //
- //*****************************************************************************
- #if defined(codered) || defined(gcc) || defined(sourcerygxx)
- unsigned long __attribute__((naked))
- CPUbasepriGet(void)
- {
- unsigned long ulRet;
- //
- // Read BASEPRI
- //
- __asm(" mrs r0, BASEPRI\n"
- " bx lr\n"
- : "=r" (ulRet));
- //
- // The return is handled in the inline assembly, but the compiler will
- // still complain if there is not an explicit return here (despite the fact
- // that this does not result in any code being produced because of the
- // naked attribute).
- //
- return(ulRet);
- }
- #endif
- #if defined(ewarm)
- unsigned long
- CPUbasepriGet(void)
- {
- //
- // Read BASEPRI
- //
- __asm(" mrs r0, BASEPRI\n");
- //
- // "Warning[Pe940]: missing return statement at end of non-void function"
- // is suppressed here to avoid putting a "bx lr" in the inline assembly
- // above and a superfluous return statement here.
- //
- #pragma diag_suppress=Pe940
- }
- #pragma diag_default=Pe940
- #endif
- #if defined(rvmdk) || defined(__ARMCC_VERSION)
- __asm unsigned long
- CPUbasepriGet(void)
- {
- //
- // Read BASEPRI
- //
- mrs r0, BASEPRI;
- bx lr
- }
- #endif
- #if defined(ccs)
- unsigned long
- CPUbasepriGet(void)
- {
- //
- // Read BASEPRI
- //
- __asm(" mrs r0, BASEPRI\n"
- " bx lr\n");
- //
- // The following keeps the compiler happy, because it wants to see a
- // return value from this function. It will generate code to return
- // a zero. However, the real return is the "bx lr" above, so the
- // return(0) is never executed and the function returns with the value
- // you expect in R0.
- //
- return(0);
- }
- #endif
|