Commit ea2b1ba555128b007a515139e59f5b413e8dd379
receivedThu, 15. Aug 2024, 16:57:36 (by user sx)
Thu, 15 Aug 2024 14:57:36 +0000 (16:57 +0200)
authorManfred Steiner <sx@htl-kaindorf.at>
Thu, 15 Aug 2024 14:57:33 +0000 (16:57 +0200)
committerManfred Steiner <sx@htl-kaindorf.at>
Thu, 15 Aug 2024 14:57:33 +0000 (16:57 +0200)
4 files changed:
examples/simuc/src/main.cpp
examples/simuc/src/sim/sim.cpp
examples/simuc/src/simavr/simavr.cpp
examples/simuc/src/simavr/simavr.h

index f287e242e150f2e4d9e383ca8a620f30770860bb..b607f797ee0308307e74a2f80b01f336c3f5bc0f 100644 (file)
@@ -36,7 +36,7 @@ void printAvailableCommands (struct StartParameters &params) {
     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";
index 969218580a1dad16d144a02296ede5a7f77a39cd..9eee696affa47dc8c230b0e1b2e8b941b9102abe 100644 (file)
@@ -99,9 +99,11 @@ const char * lastError () {
 
 std::vector<uint8_t> gdbFromUartBuffer;
 std::vector<uint8_t> 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);
                }
index 71d4996b0b82de6fbd7f321e106c9f78427ef22a..94c371735df00e5f50fa1cb033acf54dc5110ea7 100644 (file)
@@ -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
index 60c3998df6b08c7e3f087bf927d4abb4f2f853aa..4298ee7f459fe3e3a79aa062a5ec9013e97ab7ae 100644 (file)
@@ -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<struct SimAvrEvent *> events;