2014-02-02 16:48:18 +01:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2014 Freie Universität Berlin
|
|
|
|
*
|
2014-07-31 19:45:27 +02:00
|
|
|
* This file is subject to the terms and conditions of the GNU Lesser
|
|
|
|
* General Public License v2.1. See the file LICENSE in the top level
|
|
|
|
* directory for more details.
|
2014-02-02 16:48:18 +01:00
|
|
|
*/
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @ingroup cpu
|
|
|
|
* @{
|
|
|
|
*
|
2015-05-22 07:34:41 +02:00
|
|
|
* @file
|
2014-02-02 16:48:18 +01:00
|
|
|
* @brief ISR related functions
|
|
|
|
*
|
|
|
|
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
|
|
|
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
|
|
|
*
|
|
|
|
* @}
|
|
|
|
*/
|
|
|
|
|
2013-12-09 11:12:39 +01:00
|
|
|
#include "irq.h"
|
|
|
|
#include "cpu.h"
|
2010-09-22 15:10:42 +02:00
|
|
|
|
2015-03-10 13:20:04 +01:00
|
|
|
volatile int __inISR = 0;
|
|
|
|
|
|
|
|
char __isr_stack[MSP430_ISR_STACK_SIZE];
|
|
|
|
|
2014-05-07 12:36:32 +02:00
|
|
|
unsigned int disableIRQ(void)
|
2013-06-21 03:52:57 +02:00
|
|
|
{
|
2010-09-22 15:10:42 +02:00
|
|
|
unsigned int state;
|
2013-06-21 03:52:57 +02:00
|
|
|
__asm__("mov.w r2,%0" : "=r"(state));
|
2010-09-22 15:10:42 +02:00
|
|
|
state &= GIE;
|
2013-06-21 03:52:57 +02:00
|
|
|
|
2013-06-24 22:37:35 +02:00
|
|
|
if (state) {
|
2015-09-14 15:36:36 +02:00
|
|
|
__disable_irq();
|
2013-06-21 03:52:57 +02:00
|
|
|
}
|
|
|
|
|
2010-09-22 15:10:42 +02:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2014-05-07 12:36:32 +02:00
|
|
|
unsigned int enableIRQ(void)
|
2013-06-21 03:52:57 +02:00
|
|
|
{
|
2010-09-22 15:10:42 +02:00
|
|
|
unsigned int state;
|
2013-06-21 03:52:57 +02:00
|
|
|
__asm__("mov.w r2,%0" : "=r"(state));
|
2010-09-22 15:10:42 +02:00
|
|
|
state &= GIE;
|
2013-06-21 03:52:57 +02:00
|
|
|
|
2013-06-24 22:37:35 +02:00
|
|
|
if (!state) {
|
2015-09-14 15:36:36 +02:00
|
|
|
__enable_irq();
|
2013-06-21 03:52:57 +02:00
|
|
|
}
|
|
|
|
|
2010-09-22 15:10:42 +02:00
|
|
|
return state;
|
|
|
|
}
|
|
|
|
|
2013-06-21 03:52:57 +02:00
|
|
|
void restoreIRQ(unsigned int state)
|
|
|
|
{
|
2013-06-24 22:37:35 +02:00
|
|
|
if (state) {
|
2015-09-14 15:36:36 +02:00
|
|
|
__enable_irq();
|
2013-06-21 03:52:57 +02:00
|
|
|
}
|
2010-09-22 15:10:42 +02:00
|
|
|
}
|
2015-03-10 13:20:04 +01:00
|
|
|
|
|
|
|
int inISR(void)
|
|
|
|
{
|
|
|
|
return __inISR;
|
|
|
|
}
|