+ case CommandSW1Released: {
+ if (startParameters->board == BoardSure) {
+ uint8_t ddrc = avr->data[0x34]; // Atmega16
+ if ((ddrc & 0x80) == 0) {
+ avr_raise_irq(avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), 7), 0x80);
+ }
+ }
+ nextCommand = ReadyForNewCommand;
+ break;
+ }
+
+ case CommandSW1Pressed: {
+ if (startParameters->board == BoardSure) {
+ uint8_t ddrc = avr->data[0x34]; // Atmega16
+ if ( (ddrc & 0x80) == 0) {
+ avr_raise_irq(avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), 7), 0x00);
+ }
+ }
+ nextCommand = ReadyForNewCommand;
+ break;
+ }
+
+ case CommandSW2Released: {
+ if (startParameters->board == BoardNano644) {
+ uint8_t ddrc = avr->data[0x27]; // Atmega644P
+ uint8_t portc = avr->data[0x28]; // Atmega644P
+ if ( (ddrc & 0x20) == 0 && (portc & 0x20) == 0x20) { // internal pullup needed
+ avr_raise_irq(avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), 5), 0x20);
+ }
+ } else if (startParameters->board == BoardSure) {
+ uint8_t ddrc = avr->data[0x34]; // Atmega16
+ if ( (ddrc & 0x40) == 0) {
+ avr_raise_irq(avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), 6), 0x40);
+ }
+ }
+ nextCommand = ReadyForNewCommand;
+ break;
+ }
+
+ case CommandSW2Pressed: {
+ if (startParameters->board == BoardNano644 || startParameters->board == BoardNano1284) {
+ uint8_t ddrc = avr->data[0x27]; // Atmega644P
+ uint8_t portc = avr->data[0x28]; // Atmega644P
+ if ( (ddrc & 0x20) == 0 && (portc & 0x20) == 0x20) { // internal pullup needed
+ avr_raise_irq(avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), 5), 0x00);
+ }
+ } else if (startParameters->board == BoardSure) {
+ uint8_t ddrc = avr->data[0x34]; // Atmega16
+ if ( (ddrc & 0x80) == 0) { // external pullup on board
+ avr_raise_irq(avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), 6), 0);
+ }
+
+ }
+ nextCommand = ReadyForNewCommand;
+ break;
+ }
+