aboutsummaryrefslogtreecommitdiffstats
path: root/src/avr/irq.h
blob: 33172c0f77b4accea8f5c77e86423a0e2a1e3049 (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
#ifndef __AVR_IRQ_H
#define __AVR_IRQ_H
// Definitions for irq enable/disable on AVR

#include <avr/interrupt.h> // cli
#include "compiler.h" // barrier

static inline void irq_disable(void) {
    cli();
    barrier();
}

static inline void irq_enable(void) {
    barrier();
    sei();
}

typedef uint8_t irqstatus_t;

static inline irqstatus_t irq_save(void) {
    uint8_t flag = SREG;
    irq_disable();
    return flag;
}

static inline void irq_restore(irqstatus_t flag) {
    barrier();
    SREG = flag;
}

static inline void irq_poll(void) {
}

#endif // irq.h