Open
Description
Hi,
I want to contribute my changes to MySensors in order to support ATtiny MCUs (see the project page).
Three issues had to be addressed:
- Make RF24 driver be able to handle CE pin pulled up to VCC (already created PR RF24: Add 4-pin configuration support #1381 for this)
- Some register names had to be redefined and a function had to be defined to be able to compile MySensors for ATtiny.
- Fix hwCPUFrequency() in MyHwAVR.cpp
I want to discuss these issues:
- The missing defines are:
#define SIGRD RSIG // Signature Row from Store Program Memory Control and Status Register
#define EIFR GIFR // External/General Interrupt Flag Register
#define WDTCSR WDTCR // WDT Control Register
// #define TCCR1A TCCR1 // optional
// #define TIFR1 TIFR // optional
extern void serialEventRun(void) __attribute__((weak));
Where should these definitions be places? Is there some kind of compatiblity.h header in the project for different MCUs?
- The hwCPUFrequency() seems to dynamically measure the CPU frequency and for this all timers are suspended. Since ATtiny supports not that much timers, the more simple approach for a fix would be like for other hardware platforms:
@@ -309,6 +309,11 @@ uint16_t hwCPUVoltage(void)
uint16_t hwCPUFrequency(void)
{
+#if defined (__AVR_ATtiny24__) || defined(__AVR_ATtiny44__) || defined(__AVR_ATtiny84__) || \
+ defined (__AVR_ATtiny25__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny85__)
+ // reporting compile time frequency (in 1/10MHz)
+ return F_CPU / 100000UL;
+#else
cli();
// save WDT & timer settings
const uint8_t WDTsave = WDTCSR;
@@ -343,6 +348,7 @@ uint16_t hwCPUFrequency(void)
TCCR1C = TCCR1Csave;
// return frequency in 1/10MHz (accuracy +- 10%)
return result;
+#endif
}
What do you think?
Metadata
Metadata
Assignees
Labels
No labels