From 47ec5636df9667e36a4de0e1914e6989b0b7ed3f Mon Sep 17 00:00:00 2001 From: Manfred Steiner Date: Mon, 28 Oct 2024 09:33:17 +0100 Subject: [PATCH] =?utf8?q?software/x/test=5F2024-07-23=20(CC1101=20f=C3=BC?= =?utf8?q?r=20Nano-1284)?= MIME-Version: 1.0 Content-Type: text/plain; charset=utf8 Content-Transfer-Encoding: 8bit --- software/nano-644/test_2024-07-23/src/main.cpp | 13 ++++++++----- .../nano-644/test_2024-07-23/src/units/cc1101.cpp | 12 ++++++++++++ .../nano-644/test_2024-07-23/src/units/motor.cpp | 2 +- 3 files changed, 21 insertions(+), 6 deletions(-) diff --git a/software/nano-644/test_2024-07-23/src/main.cpp b/software/nano-644/test_2024-07-23/src/main.cpp index 18ee2d3..35f309f 100644 --- a/software/nano-644/test_2024-07-23/src/main.cpp +++ b/software/nano-644/test_2024-07-23/src/main.cpp @@ -155,7 +155,8 @@ uint8_t detectHardwareVersion () { hardwareVersion = 0; // unknown board version // printf("Hardware-Version: ADC7H = %d\n", ADCH); #if defined(__AVR_ATmega644P__) || defined(__AVR_ATmega1284P__) - if (ADCH >= 0xf0) { + + if (ADCH >= 0xf4) { hardwareVersion = 1; } else if (ADCH >= 0xe0) { hardwareVersion = 2; @@ -169,14 +170,16 @@ uint8_t detectHardwareVersion () { } #endif - if (hardwareVersion == 0) { + if (hardwareVersion < 1 || hardwareVersion > 2) { #ifdef __AVR_ATmega644P__ - printf("\nInvalid Hardware-Version: ADC7H = %d (ATmega644P, 3.3V)\n", ADCH); + printf_P(PSTR("\nInvalid Hardware-Version: ADC7H = %d (ATmega644P, 3.3V)\n"), ADCH); #elif __AVR_ATmega1284P__ - printf("\nInvalid Hardware-Version: ADC7H = %d (ATmega1284P, 3.3V)\n", ADCH); + printf_P(PSTR("\nInvalid Hardware-Version: ADC7H = %d (ATmega1284P, 3.3V)\n"), ADCH); #elif __AVR_ATmega328P__ - printf("\nInvalid Hardware-Version: ADC7H = %d (ATmega328P, 5V)\n", ADCH); + printf_P(PSTR("\nInvalid Hardware-Version: ADC7H = %d (ATmega328P, 5V)\n"), ADCH); #endif + } else { + printf_P(PSTR("\n\nHardware %d detected (ADC7H=0x%02X)"), hardwareVersion, ADCH); } ADMUX = 0; diff --git a/software/nano-644/test_2024-07-23/src/units/cc1101.cpp b/software/nano-644/test_2024-07-23/src/units/cc1101.cpp index d53ecf2..aebe713 100644 --- a/software/nano-644/test_2024-07-23/src/units/cc1101.cpp +++ b/software/nano-644/test_2024-07-23/src/units/cc1101.cpp @@ -320,6 +320,12 @@ void Cc1101::init () { + #ifdef __AVR_ATmega1284P__ + // Nano-1284 + DDRC |= (1 << PC6); + PORTC |= (1 << PC6); // modem voltage 3.3V ON + #endif + // trigger for debugging PORTB &= ~(1 << PB0); DDRB |= ( 1 << PB0); @@ -375,6 +381,12 @@ DDRB &= ~((1 << PB7) | (1 << PB6) | (1 << PB5) | (1 << PB4)); DDRA &= ~((1 << PA5) | (1 << PA4)); PORTA &= ~((1 << PA5) | (1 << PA4)); + + #ifdef __AVR_ATmega1284P__ + // Nano-1284 + DDRC &= ~(1 << PC6); + PORTC &= ~(1 << PC6); // modem voltage 3.3V OFF + #endif } void Cc1101::setChipEnableLow () { diff --git a/software/nano-644/test_2024-07-23/src/units/motor.cpp b/software/nano-644/test_2024-07-23/src/units/motor.cpp index 83f0c3b..7f8fbf9 100644 --- a/software/nano-644/test_2024-07-23/src/units/motor.cpp +++ b/software/nano-644/test_2024-07-23/src/units/motor.cpp @@ -182,7 +182,7 @@ int8_t Motor::run (uint8_t subtest) { } float rpm = 60.0 / (float)timer / 0.0001; if (timer > 0) { - printf_P(PSTR(" n= %4d U/min (T=%04x)"), (int)rpm, timer); + printf_P(PSTR(" n= %5d U/min (T=%04x)"), (int)rpm, timer); } else { printf_P(PSTR(" no rotation (T=%04x) "), timer); } -- 2.39.5