123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189 |
- //*****************************************************************************
- //
- // cpu.c - Instruction wrappers for special CPU instructions needed by the
- // drivers.
- //
- // Copyright (c) 2006-2009 Luminary Micro, Inc. All rights reserved.
- // Software License Agreement
- //
- // Luminary Micro, Inc. (LMI) is supplying this software for use solely and
- // exclusively on LMI's microcontroller products.
- //
- // The software is owned by LMI and/or its suppliers, and is protected under
- // applicable copyright laws. All rights are reserved. You may not combine
- // this software with "viral" open-source software in order to form a larger
- // program. Any use in violation of the foregoing restrictions may subject
- // the user to criminal sanctions under applicable laws, as well as to civil
- // liability for the breach of the terms and conditions of this license.
- //
- // THIS SOFTWARE IS PROVIDED "AS IS". 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.
- // LMI SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL, OR
- // CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
- //
- // This is part of revision 4694 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 %0, 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
- //*****************************************************************************
- //
- // 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 %0, 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
- //*****************************************************************************
- //
- // 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
|