Hi, the problem: my code wants to run on a couple disparate microcontrollers (ESP8266, "small" STM32, AVR AtMega). Besides the usual digital I/O which e.g. Arduino supports cross-platform I need stuff like port interrupts, timer interrupts, and letting the controller sleep until something happens. And that's where Arduino support ends, at least without platform specific libraries. The question is: Is something liek that available someplace out there? or do I write that kind of support code on my own (again …)? I've scanned PlatformIO et al.; the only code like what I'm looking for that's listed there is Simba, which looks pretty useable but doesn't do timer interrupts or CPU sleep. Ideas and pointers appreciated.
Hi, Let's take an example : Atmel 328P (Arduino Uno) and TI MSP430G2553 Launchpad (using Energia, an Arduino-derived IDE). They are very different, as MSP430 is 16 bits, has at least 5 low power modes, a watchdog, etc... Basic Arduino code runs on both provided you adapt it, as pins are not in the same place, and these chips don't have the same number of pins. You have to include pure C/C++ or even ASM to get these "non common" features (ex: 'sei' and 'clei' instructions on 328P). When it comes to digging down into chip specific functions (no LPM1 on 328P, for example), nothing is the same between manufacturers. That's the joys of micro-controllers, where you are digging deep into the hardware. The only solution might be an awful lot of '#ifdef' in your code.
laurent wrote: > nothing is the same between manufacturers Correct, but that does not mean that abstraction is not possible. The C++ framework is here https://github.com/KonstantinChizhov/Mcucpp This is C++(17) and it is not arduino-like and it works once you understand it and it is not documented. It is just c++ source code with some avr-based examples.
A. B. wrote: > Correct, but that does not mean that abstraction is not possible How do you abstract a usb interface, which one controller has, the other not? Georg
in general: ********** You write a usb.h for the controller(-family) which does have the usb-interface .. for boards of the same family with different controllers ******************************************************** you distinguish different controllers using concepts. you #include the corresponding pripheral.h
Georg wrote: > A. B. wrote: >> Correct, but that does not mean that abstraction is not possible > > How do you abstract a usb interface, which one controller has, the other > not? Presumably you either write a bit-banging USB driver for the other controller and hide it between a common abstraction. Or you use a serial abstraction and talk on USB if it exists, and some hardware UART if it's not. Or you simply don't use USB in code that's supposed to run on all of these platforms. All of this is not rocket science; the problem is that somebody has to do it, and I'd rather contribute to somebody else's effort than write my own layer. I have too much on my TODO list as it is.
Please log in before posting. Registration is free and takes only a minute.
Existing account
Do you have a Google/GoogleMail account? No registration required!
Log in with Google account
Log in with Google account
No account? Register here.