/usr/include/simavr/avr_extint.h is in libsimavr-dev 1.5+dfsg1-2.
This file is owned by root:root, with mode 0o644.
The actual contents of the file can be viewed below.
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 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 | /*
avr_extint.h
External Interrupt Handling (for INT0-3)
Copyright 2008, 2009 Michel Pollet <buserror@gmail.com>
Copyright 2014 Doug Szumski <d.s.szumski@gmail.com>
This file is part of simavr.
simavr is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
simavr is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with simavr. If not, see <http://www.gnu.org/licenses/>.
*/
#ifndef __AVR_EXTINT_H__
#define __AVR_EXTINT_H__
#ifdef __cplusplus
extern "C" {
#endif
#include "sim_avr.h"
enum {
EXTINT_IRQ_OUT_INT0 = 0,
EXTINT_IRQ_OUT_INT1, EXTINT_IRQ_OUT_INT2, EXTINT_IRQ_OUT_INT3,
EXTINT_IRQ_OUT_INT4, EXTINT_IRQ_OUT_INT5, EXTINT_IRQ_OUT_INT6,
EXTINT_IRQ_OUT_INT7,
EXTINT_COUNT
};
// Get the internal IRQ corresponding to the INT
#define AVR_IOCTL_EXTINT_GETIRQ() AVR_IOCTL_DEF('i','n','t',' ')
/*
* This module is just a "relay" for the pin change IRQ in the IO port
* module. We hook up to their IRQ and raise out interrupt vectors as needed
*
* "isc" is handled, apart from the "level" mode that doesn't make sense here (?)
*/
typedef struct avr_extint_t {
avr_io_t io;
struct {
avr_regbit_t isc[2]; // interrupt sense control bits
avr_int_vector_t vector; // interrupt vector
uint32_t port_ioctl; // ioctl to use to get port
uint8_t port_pin; // pin number in said port
uint8_t strict_lvl_trig;// enforces a repetitive interrupt triggering while the pin is held low
} eint[EXTINT_COUNT];
} avr_extint_t;
void avr_extint_init(avr_t * avr, avr_extint_t * p);
int avr_extint_is_strict_lvl_trig(avr_t * avr, uint8_t extint_no);
void avr_extint_set_strict_lvl_trig(avr_t * avr, uint8_t extint_no, uint8_t strict);
// Declares a typical INT into a avr_extint_t in a core.
// this is a shortcut since INT declarations are pretty standard.
// The Tinies as well as the atmega1280 are slightly different.
// See sim_tinyx5.h and sim_mega1280.h
#define AVR_EXTINT_DECLARE(_index, _portname, _portpin) \
.eint[_index] = { \
.port_ioctl = AVR_IOCTL_IOPORT_GETIRQ(_portname), \
.port_pin = _portpin, \
.isc = { AVR_IO_REGBIT(EICRA, ISC##_index##0), AVR_IO_REGBIT(EICRA, ISC##_index##1) },\
.vector = { \
.enable = AVR_IO_REGBIT(EIMSK, INT##_index), \
.raised = AVR_IO_REGBIT(EIFR, INTF##_index), \
.vector = INT##_index##_vect, \
},\
}
// Asynchronous External Interrupt, for example INT2 on the m16 and m32
// Uses only 1 interrupt sense control bit
#define AVR_ASYNC_EXTINT_DECLARE(_index, _portname, _portpin) \
.eint[_index] = { \
.port_ioctl = AVR_IOCTL_IOPORT_GETIRQ(_portname), \
.port_pin = _portpin, \
.isc = { AVR_IO_REGBIT(MCUCSR, ISC##_index) },\
.vector = { \
.enable = AVR_IO_REGBIT(GICR, INT##_index), \
.raised = AVR_IO_REGBIT(GIFR, INTF##_index), \
.vector = INT##_index##_vect, \
},\
}
#define AVR_EXTINT_MEGA_DECLARE(_index, _portname, _portpin, _EICR) \
.eint[_index] = { \
.port_ioctl = AVR_IOCTL_IOPORT_GETIRQ(_portname), \
.port_pin = _portpin, \
.isc = { AVR_IO_REGBIT(EICR##_EICR, ISC##_index##0), AVR_IO_REGBIT(EICR##_EICR, ISC##_index##1) },\
.vector = { \
.enable = AVR_IO_REGBIT(EIMSK, INT##_index), \
.raised = AVR_IO_REGBIT(EIFR, INTF##_index), \
.vector = INT##_index##_vect, \
},\
}
#define AVR_EXTINT_TINY_DECLARE(_index, _portname, _portpin, _IFR) \
.eint[_index] = { \
.port_ioctl = AVR_IOCTL_IOPORT_GETIRQ(_portname), \
.port_pin = _portpin, \
.isc = { AVR_IO_REGBIT(MCUCR, ISC##_index##0), AVR_IO_REGBIT(MCUCR, ISC##_index##1) }, \
.vector = { \
.enable = AVR_IO_REGBIT(GIMSK, INT##_index), \
.raised = AVR_IO_REGBIT(_IFR, INTF##_index), \
.vector = INT##_index##_vect, \
}, \
}
#ifdef __cplusplus
};
#endif
#endif /*__AVR_EXTINT_H__*/
|