You cannot select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
66 lines
1.0 KiB
C
66 lines
1.0 KiB
C
![]()
10 years ago
|
/*
|
||
|
* Copyright (C) 2014 Freie Universität Berlin
|
||
|
*
|
||
![]()
9 years ago
|
* 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.
|
||
![]()
10 years ago
|
*/
|
||
|
|
||
|
/**
|
||
|
* @ingroup cpu
|
||
|
* @{
|
||
|
*
|
||
![]()
8 years ago
|
* @file
|
||
![]()
10 years ago
|
* @brief ISR related functions
|
||
|
*
|
||
|
* @author Kaspar Schleiser <kaspar@schleiser.de>
|
||
|
* @author Oliver Hahm <oliver.hahm@inria.fr>
|
||
|
*
|
||
|
* @}
|
||
|
*/
|
||
|
|
||
![]()
10 years ago
|
#include "irq.h"
|
||
|
#include "cpu.h"
|
||
![]()
13 years ago
|
|
||
![]()
8 years ago
|
volatile int __irq_is_in = 0;
|
||
![]()
9 years ago
|
|
||
![]()
7 years ago
|
char __isr_stack[ISR_STACKSIZE];
|
||
![]()
9 years ago
|
|
||
![]()
8 years ago
|
unsigned int irq_disable(void)
|
||
![]()
10 years ago
|
{
|
||
![]()
13 years ago
|
unsigned int state;
|
||
![]()
10 years ago
|
__asm__("mov.w r2,%0" : "=r"(state));
|
||
![]()
13 years ago
|
state &= GIE;
|
||
![]()
10 years ago
|
|
||
![]()
10 years ago
|
if (state) {
|
||
![]()
8 years ago
|
__disable_irq();
|
||
![]()
10 years ago
|
}
|
||
|
|
||
![]()
13 years ago
|
return state;
|
||
|
}
|
||
|
|
||
![]()
8 years ago
|
unsigned int irq_enable(void)
|
||
![]()
10 years ago
|
{
|
||
![]()
13 years ago
|
unsigned int state;
|
||
![]()
10 years ago
|
__asm__("mov.w r2,%0" : "=r"(state));
|
||
![]()
13 years ago
|
state &= GIE;
|
||
![]()
10 years ago
|
|
||
![]()
10 years ago
|
if (!state) {
|
||
![]()
8 years ago
|
__enable_irq();
|
||
![]()
10 years ago
|
}
|
||
|
|
||
![]()
13 years ago
|
return state;
|
||
|
}
|
||
|
|
||
![]()
8 years ago
|
void irq_restore(unsigned int state)
|
||
![]()
10 years ago
|
{
|
||
![]()
10 years ago
|
if (state) {
|
||
![]()
8 years ago
|
__enable_irq();
|
||
![]()
10 years ago
|
}
|
||
![]()
13 years ago
|
}
|
||
![]()
9 years ago
|
|
||
![]()
8 years ago
|
int irq_is_in(void)
|
||
![]()
9 years ago
|
{
|
||
![]()
8 years ago
|
return __irq_is_in;
|
||
![]()
9 years ago
|
}
|