Skip to content

Commit

Permalink
cores: Use correct extint control register
Browse files Browse the repository at this point in the history
The atmega1280/atmega1281/atmega128/90usb162
have two external interrupt control registers;
EICRA for ISC[0-3]x, and EICRB for ISC[4-7]x.
  • Loading branch information
schuay committed Aug 31, 2012
1 parent 026ea0a commit ead3953
Show file tree
Hide file tree
Showing 5 changed files with 46 additions and 33 deletions.
16 changes: 8 additions & 8 deletions simavr/cores/sim_90usb162.c
Original file line number Diff line number Diff line change
Expand Up @@ -63,14 +63,14 @@ const struct mcu_t {
AVR_SELFPROG_DECLARE(SPMCSR, SPMEN, SPM_READY_vect),
AVR_WATCHDOG_DECLARE(WDTCSR, WDT_vect),
.extint = {
AVR_EXTINT_DECLARE(0, 'D', PD0),
AVR_EXTINT_DECLARE(1, 'D', PD1),
AVR_EXTINT_DECLARE(2, 'D', PD2),
AVR_EXTINT_DECLARE(3, 'D', PD3),
AVR_EXTINT_DECLARE(4, 'C', PC7),
AVR_EXTINT_DECLARE(5, 'D', PD4),
AVR_EXTINT_DECLARE(6, 'D', PD6),
AVR_EXTINT_DECLARE(7, 'D', PD7),
AVR_EXTINT_MEGA_DECLARE(0, 'D', PD0, A),
AVR_EXTINT_MEGA_DECLARE(1, 'D', PD1, A),
AVR_EXTINT_MEGA_DECLARE(2, 'D', PD2, A),
AVR_EXTINT_MEGA_DECLARE(3, 'D', PD3, A),
AVR_EXTINT_MEGA_DECLARE(4, 'C', PC7, B),
AVR_EXTINT_MEGA_DECLARE(5, 'D', PD4, B),
AVR_EXTINT_MEGA_DECLARE(6, 'D', PD6, B),
AVR_EXTINT_MEGA_DECLARE(7, 'D', PD7, B),
},
.portb = {
.name = 'B', .r_port = PORTB, .r_ddr = DDRB, .r_pin = PINB,
Expand Down
16 changes: 8 additions & 8 deletions simavr/cores/sim_mega128.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ const struct mcu_t {
AVR_SELFPROG_DECLARE(SPMCSR, SPMEN, SPM_READY_vect),
AVR_WATCHDOG_DECLARE_128(WDTCR, _VECTOR(0)),
.extint = {
AVR_EXTINT_DECLARE(0, 'D', PD0),
AVR_EXTINT_DECLARE(1, 'D', PD1),
AVR_EXTINT_DECLARE(2, 'D', PD2),
AVR_EXTINT_DECLARE(3, 'D', PD3),
AVR_EXTINT_DECLARE(4, 'E', PE4),
AVR_EXTINT_DECLARE(5, 'E', PE5),
AVR_EXTINT_DECLARE(6, 'E', PE6),
AVR_EXTINT_DECLARE(7, 'E', PE7),
AVR_EXTINT_MEGA_DECLARE(0, 'D', PD0, A),
AVR_EXTINT_MEGA_DECLARE(1, 'D', PD1, A),
AVR_EXTINT_MEGA_DECLARE(2, 'D', PD2, A),
AVR_EXTINT_MEGA_DECLARE(3, 'D', PD3, A),
AVR_EXTINT_MEGA_DECLARE(4, 'E', PE4, B),
AVR_EXTINT_MEGA_DECLARE(5, 'E', PE5, B),
AVR_EXTINT_MEGA_DECLARE(6, 'E', PE6, B),
AVR_EXTINT_MEGA_DECLARE(7, 'E', PE7, B),
},
.porta = { // no PCINTs in atmega128
.name = 'A', .r_port = PORTA, .r_ddr = DDRA, .r_pin = PINA,
Expand Down
16 changes: 8 additions & 8 deletions simavr/cores/sim_mega1280.c
Original file line number Diff line number Diff line change
Expand Up @@ -73,14 +73,14 @@ const struct mcu_t {
AVR_SELFPROG_DECLARE(SPMCSR, SPMEN, SPM_READY_vect),
AVR_WATCHDOG_DECLARE(WDTCSR, WDT_vect),
.extint = {
AVR_EXTINT_DECLARE(0, 'D', PD0),
AVR_EXTINT_DECLARE(1, 'D', PD1),
AVR_EXTINT_DECLARE(2, 'D', PD2),
AVR_EXTINT_DECLARE(3, 'D', PD3),
AVR_EXTINT_DECLARE(4, 'E', PE4),
AVR_EXTINT_DECLARE(5, 'E', PE5),
AVR_EXTINT_DECLARE(6, 'E', PE6),
AVR_EXTINT_DECLARE(7, 'E', PE7),
AVR_EXTINT_MEGA_DECLARE(0, 'D', PD0, A),
AVR_EXTINT_MEGA_DECLARE(1, 'D', PD1, A),
AVR_EXTINT_MEGA_DECLARE(2, 'D', PD2, A),
AVR_EXTINT_MEGA_DECLARE(3, 'D', PD3, A),
AVR_EXTINT_MEGA_DECLARE(4, 'E', PE4, B),
AVR_EXTINT_MEGA_DECLARE(5, 'E', PE5, B),
AVR_EXTINT_MEGA_DECLARE(6, 'E', PE6, B),
AVR_EXTINT_MEGA_DECLARE(7, 'E', PE7, B),
},
.porta = {
.name = 'A', .r_port = PORTA, .r_ddr = DDRA, .r_pin = PINA,
Expand Down
16 changes: 8 additions & 8 deletions simavr/cores/sim_mega1281.c
Original file line number Diff line number Diff line change
Expand Up @@ -69,14 +69,14 @@ const struct mcu_t {
AVR_SELFPROG_DECLARE(SPMCSR, SPMEN, SPM_READY_vect),
AVR_WATCHDOG_DECLARE(WDTCSR, WDT_vect),
.extint = {
AVR_EXTINT_DECLARE(0, 'D', PD0),
AVR_EXTINT_DECLARE(1, 'D', PD1),
AVR_EXTINT_DECLARE(2, 'D', PD2),
AVR_EXTINT_DECLARE(3, 'D', PD3),
AVR_EXTINT_DECLARE(4, 'E', PE4),
AVR_EXTINT_DECLARE(5, 'E', PE5),
AVR_EXTINT_DECLARE(6, 'E', PE6),
AVR_EXTINT_DECLARE(7, 'E', PE7),
AVR_EXTINT_MEGA_DECLARE(0, 'D', PD0, A),
AVR_EXTINT_MEGA_DECLARE(1, 'D', PD1, A),
AVR_EXTINT_MEGA_DECLARE(2, 'D', PD2, A),
AVR_EXTINT_MEGA_DECLARE(3, 'D', PD3, A),
AVR_EXTINT_MEGA_DECLARE(4, 'E', PE4, B),
AVR_EXTINT_MEGA_DECLARE(5, 'E', PE5, B),
AVR_EXTINT_MEGA_DECLARE(6, 'E', PE6, B),
AVR_EXTINT_MEGA_DECLARE(7, 'E', PE7, B),
},
.porta = {
.name = 'A', .r_port = PORTA, .r_ddr = DDRA, .r_pin = PINA,
Expand Down
15 changes: 14 additions & 1 deletion simavr/sim/avr_extint.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,7 +65,8 @@ void avr_extint_init(avr_t * avr, avr_extint_t * p);

// Declares a typical INT into a avr_extint_t in a core.
// this is a shortcut since INT declarations are pretty standard.
// The Tinies are slightly different. see sim_tinyx5.h
// 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), \
Expand All @@ -78,6 +79,18 @@ void avr_extint_init(avr_t * avr, avr_extint_t * p);
},\
}

#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), \
Expand Down

0 comments on commit ead3953

Please sign in to comment.