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;
}
#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;
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);
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 () {
}
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);
}