Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add ATtiny Support #1382

Open
fabyte opened this issue Jan 9, 2020 · 3 comments
Open

Add ATtiny Support #1382

fabyte opened this issue Jan 9, 2020 · 3 comments

Comments

@fabyte
Copy link

fabyte commented Jan 9, 2020

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:

  1. 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)
  2. Some register names had to be redefined and a function had to be defined to be able to compile MySensors for ATtiny.
  3. Fix hwCPUFrequency() in MyHwAVR.cpp

I want to discuss these issues:

  1. 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?

  1. 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?

@garudaonekh
Copy link

garudaonekh commented Apr 13, 2021

More than 1 years since your post but noone replies or pay attention to it. How is it going at your end regarding this. I am also trying to get Attiny167 to work with Mysensors but failed. Even though attiny is small(16KB) but it's enough for many single sensor device.

@fabyte
Copy link
Author

fabyte commented Apr 14, 2021

Unfortunately there is not much support from the project. You can try and use my attiny branch. It contains changes to address number 1. and 3. of this issue.

@garudaonekh
Copy link

thanks, your approach works. now I got my Attiny167+Sht30 working with Mysensors and Mysensor gateway. Next step will be formatting the data for Thingsboard cloud.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants