From ea2b1ba555128b007a515139e59f5b413e8dd379 Mon Sep 17 00:00:00 2001 From: Manfred Steiner Date: Thu, 15 Aug 2024 16:57:33 +0200 Subject: [PATCH] add board nano-1284 --- examples/simuc/src/main.cpp | 14 +++++++++++--- examples/simuc/src/sim/sim.cpp | 10 ++++++---- examples/simuc/src/simavr/simavr.cpp | 4 ++-- examples/simuc/src/simavr/simavr.h | 3 ++- 4 files changed, 21 insertions(+), 10 deletions(-) diff --git a/examples/simuc/src/main.cpp b/examples/simuc/src/main.cpp index f287e24..b607f79 100644 --- a/examples/simuc/src/main.cpp +++ b/examples/simuc/src/main.cpp @@ -36,7 +36,7 @@ void printAvailableCommands (struct StartParameters ¶ms) { printf("available commands:\n"); printf(" h (help)\n"); printf(" b (break), n (stepi), c (continue), s (stack), r (reset), p (power), q (quit)\n"); - if (params.board == BoardNano644) { + if (params.board == BoardNano644 || params.board == BoardNano1284) { printf(" 1 (SW2 not pressed), 2 (SW2 pressed)\n"); } else if (params.board == BoardSure) { printf(" 1 (SW1 not pressed), 2 (SW1 pressed), 3 (SW2 not pressed), 4 (SW2 pressed)\n"); @@ -57,14 +57,14 @@ EnumSimAvrCommand parseSimAvrCommand (struct StartParameters& params, char c) { case '1': { switch (params.board) { case BoardSure: return CommandSW1Released; - case BoardNano644: return CommandSW2Released; + case BoardNano644: case BoardNano1284: return CommandSW2Released; default: break; } } case '2': { switch (params.board) { case BoardSure: return CommandSW1Pressed; - case BoardNano644: return CommandSW2Pressed; + case BoardNano644: case BoardNano1284: return CommandSW2Pressed; default: break; } } @@ -176,6 +176,14 @@ int main (int argc, char **argv) { params.avcc = 3300; params.aref = 1100; + } else if (strcmp("nano-1284", argv[i]) == 0) { + params.board = BoardNano1284; + params.mmcu = "atmega1284p"; + params.frequency = 12000000; + params.vcc = 3300; + params.avcc = 3300; + params.aref = 1100; + } else if (strcmp("sure", argv[i]) == 0) { params.board = BoardSure; params.mmcu = "atmega16"; diff --git a/examples/simuc/src/sim/sim.cpp b/examples/simuc/src/sim/sim.cpp index 9692185..9eee696 100644 --- a/examples/simuc/src/sim/sim.cpp +++ b/examples/simuc/src/sim/sim.cpp @@ -99,9 +99,11 @@ const char * lastError () { std::vector gdbFromUartBuffer; std::vector gdbToUartBuffer; +unsigned long gdbUartOutByteCount = 0; +unsigned long gdbUartInByteCount = 0; __attribute__((unused)) static void fromGdbUart (uint8_t b) { - printf("\n\rgdb-uart OUT -> %02X", b); + printf("\n\r(%lu) gdb-uart OUT -> %02X", gdbUartOutByteCount++, b); if (b > 32 && b < 127) { printf(" %c\n", b); } else { @@ -118,7 +120,7 @@ __attribute__((unused)) static void fromGdbUart (uint8_t b) { gdbFromUartBuffer.push_back(b); if (cnt <= -3 || (cnt == 0 && b == '+')) { - printf("\n\rgdb-uart OUT -> "); + printf("\n\r(%lu) gdb-uart OUT -> ", gdbUartOutByteCount); for (uint8_t c : gdbFromUartBuffer) { putchar(c); } @@ -128,7 +130,7 @@ __attribute__((unused)) static void fromGdbUart (uint8_t b) { } __attribute__((unused)) static void toGdbUart (uint8_t b) { - printf("\n\rgdb-uart IN <-- %02X", b); + printf("\n\r(%lu) gdb-uart IN <-- %02X", gdbUartInByteCount++, b); if (b > 32 && b < 127) { printf(" %c\n", b); } else { @@ -146,7 +148,7 @@ __attribute__((unused)) static void toGdbUart (uint8_t b) { gdbToUartBuffer.push_back(b); if (cnt <= -3 || (cnt == 0 && b == '+')) { - printf("\n\rgdb-uart IN <-- "); + printf("\n\r(%lu) gdb-uart IN <-- ", gdbUartInByteCount); for (uint8_t c : gdbToUartBuffer) { putchar(c); } diff --git a/examples/simuc/src/simavr/simavr.cpp b/examples/simuc/src/simavr/simavr.cpp index 71d4996..94c3717 100644 --- a/examples/simuc/src/simavr/simavr.cpp +++ b/examples/simuc/src/simavr/simavr.cpp @@ -536,7 +536,7 @@ bool SimAvr::sprintfLedStatus (char *s, size_t size, bool onlyOnChange) { } break; } - case BoardNano644: { + case BoardNano644: case BoardNano1284: { static int8_t led[3] = { -1, -1, -1 }; // pin floating static int8_t sw2 = -1; static uint8_t mask[3] = { 0x04, 0x08, 0x10 }; // Bitmask for LED Red, Yellow, Green @@ -1039,7 +1039,7 @@ void SimAvr::avrRun () { } case CommandSW2Pressed: { - if (startParameters->board == BoardNano644) { + 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 diff --git a/examples/simuc/src/simavr/simavr.h b/examples/simuc/src/simavr/simavr.h index 60c3998..4298ee7 100644 --- a/examples/simuc/src/simavr/simavr.h +++ b/examples/simuc/src/simavr/simavr.h @@ -16,6 +16,7 @@ typedef enum { BoardUnknown = 0, BoardNano, BoardNano644, + BoardNano1284, BoardSure, BoardEWS1 } EnumStartParameterBoard; @@ -123,7 +124,7 @@ public: private: elf_firmware_t *firmware = NULL; - avr_t *avr = NULL;; + avr_t *avr = NULL; StartParameters *startParameters = NULL;; pthread_mutex_t lock; std::list events; -- 2.39.5