avr->gdb_port = params->gdbPort > 0 ? params->gdbPort : 1234;
avr_gdb_init(avr);
+ switch (params->board) {
+ case BoardSure: {
+ // SW1 and SW2 have external pullup resistors
+ avr_ioport_external_t io_ext = { 'C', 0xc0, 0xc0 }; // PC6 ... SW2, PC7...SW1
+ avr_ioctl(avr, AVR_IOCTL_IOPORT_SET_EXTERNAL('C'), &io_ext);
+ break;
+ }
+ default: break;
+
+ }
+
+
+
pthread_mutex_unlock(&lock);
} catch (std::exception& e) {
case CommandSW1Released: {
if (startParameters->board == BoardSure) {
uint8_t ddrc = avr->data[0x34]; // Atmega16
- uint8_t pinc1 = avr->data[0x33];
- if ((ddrc & 0x80) == 0) { // external pullup on board
- avr_ioport_external_t io_ext = { 'C', 0x80, 0x80 }; // PC7 ... SW1
- avr_ioctl(avr, AVR_IOCTL_IOPORT_SET_EXTERNAL('C'), &io_ext);
+ if ((ddrc & 0x80) == 0) {
+ avr_raise_irq(avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), 7), 0x80);
}
- uint8_t pinc2 = avr->data[0x33];
- printf("SW1 released, DDRC = 0x%02x, PINC 0x%02x -> 0x%02x\n", ddrc, pinc1, pinc2);
}
nextCommand = ReadyForNewCommand;
break;
case CommandSW1Pressed: {
if (startParameters->board == BoardSure) {
uint8_t ddrc = avr->data[0x34]; // Atmega16
- uint8_t pinc1 = avr->data[0x33];
- if ( (ddrc & 0x80) == 0) { // external pullup on board
- avr_ioport_external_t io_ext = { 'C', 0x80, 0x00 }; // PC7 ... SW1
- avr_ioctl(avr, AVR_IOCTL_IOPORT_SET_EXTERNAL('C'), &io_ext);
+ if ( (ddrc & 0x80) == 0) {
+ avr_raise_irq(avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), 7), 0x00);
}
- uint8_t pinc2 = avr->data[0x33];
- printf("SW1 pressed, DDRC = 0x%02x, PINC 0x%02x -> 0x%02x\n", ddrc, pinc1, pinc2);
-
}
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_ioport_external_t io_ext = { 'C', 0x20, 0x20 }; // PC5 ... SW2
- avr_ioctl(avr, AVR_IOCTL_IOPORT_SET_EXTERNAL('C'), &io_ext);
+ 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) { // external pullup on board
- avr_ioport_external_t io_ext = { 'C', 0x40, 0x40 }; // PC6 ... SW2
- avr_ioctl(avr, AVR_IOCTL_IOPORT_SET_EXTERNAL('C'), &io_ext);
+ if ( (ddrc & 0x40) == 0) {
+ avr_raise_irq(avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), 6), 0x40);
}
}
nextCommand = ReadyForNewCommand;
uint8_t ddrc = avr->data[0x27]; // Atmega644P
uint8_t portc = avr->data[0x28]; // Atmega644P
if ( (ddrc & 0x20) == 0 && (portc & 0x20) == 0x20) { // internal pullup needed
- // vr_ioport_external_t p;
- avr_ioport_external_t io_ext = { 'C', 0x20, 0x0 }; // PC5 ... SW2
- avr_ioctl(avr, AVR_IOCTL_IOPORT_SET_EXTERNAL('C'), &io_ext);
+ 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_ioport_external_t io_ext = { 'C', 0x40, 0x00 }; // PC6 ... SW2
- avr_ioctl(avr, AVR_IOCTL_IOPORT_SET_EXTERNAL('C'), &io_ext);
+ avr_raise_irq(avr_io_getirq(avr, AVR_IOCTL_IOPORT_GETIRQ('C'), 6), 0);
}
}