Sunday, December 8, 2013

C++ hardware library for (small) 32-bit micro-controllers

Newsgroup: comp.lang.c++

Subject: C++ hardware library for (small) 32-bit micro-controllers

From: Wouter van Ooijen <wouter@...>

Date: Wed, 04 Dec 2013 19:45:34 +0100



(posted to comp.lang.c++, comp.arch.embedded, yahoo-groups/lpc2000)



I am working on a portable C++ hardware library for real-time

applications on small (but still 32-bit) micro-controllers. My typical

(and current only) target is the Cortex M0 LPC1114FN28 (4k RAM, 32K

Flash) using GCC. Efficiency is very important, in run-time, RAM use,

and ROM use. The typical restrictions for small microcontrollers apply:

no RTTI, no exceptions, and no heap (or at most just an allocate-only heap).



So far I have found nice and efficient abstractions for I/O pins and I/O

ports (using static class templates), implemented those on the LPC1114,

and used these abstractions to implement protocols (I2C, SPI) and

interfaces for some external chips like 74HC595 and MCP23017.



Like any would-be author of a serious piece of work I am looking for an

adience to read, test, critisize (ridicule if necessary), maybe even

contribute, and eventually use my work.



To get a idea of what I want to make, a very initial version can be

found at http://www.voti.nl/hwlib



Any takers?



If this is all too abstract, I have a more concrete question, mainly for

C++ architects. For I/O pins and ports I use class templates with (only)

static functions. This matches well with reality (the hardware circuit

is generally fixed), and is much more efficient than using inheritance

and virtual functions.



However, I am now working on graphics for small LCD screens. At the

lowest level (configuring an LCD driver for the size of the LCD and the

pins used) the static-class-template approach is fine. But at some level

the higher abstractions using the screen (for instance a subscreen,

button, etc.) must be more dynamic and created ad-hoc. So somewhere

(probably at multiple levels in the abstraction tree) I must make a

transition from static class templates to the classic objects in an

inheritance tree with virtual functions. Does anyone have any experience

with such a dual hierarchy? One very stupid but basic problem is naming:

a template and a class can't have te same name, so when the natural name

would for instance be 'subframe', who gets that name, the template, the

class, or neither?



Wouter van Ooijen











via Usenet Forums - Usenet Search,Free Usenet - comp.lang.c++ http://www.pocketbinaries.com/usenet-forums/showthread.php?143091-C-hardware-library-for-(small)-32-bit-micro-controllers&goto=newpost

View all the progranning help forums at:

http://www.pocketbinaries.com/usenet-forums/forumdisplay.php?128-Coding-forums

No comments:

Post a Comment