Re: port I/O abstraction macros




"Tom Torfs" <tomtorfs@xxxxxxxxx> wrote in message
news:1149274847.733281.46970@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx
Everyone,

Earlier I posted some macros that allow you to easily define binary
constants in C (see http://cprog.tomsweb.net/binconst.txt). Playing
similar tricks with the preprocessor, I now created some macros that
allow you to make easy abstraction of port I/O's. It's written for the
MSP430 but the concept can be applied to other embedded architectures.

You simply define your signal location like:
#define LED P1,0
and then use them like:
SETDIR(LED);
CLR(LED);
TOGGLE(LED);

We take on alot of intern students and student projects etc. and I have
always found their ability to do bitwise manipulation in C to be completely
hopeless. What are universities teaching them these days? Its the year 2006
and they still come out knowing how to program an 8051 in assembly but not
knowing what c &= ~(1<<4); does.


.



Relevant Pages

  • Re: Boost Workshop at OOPSLA 2004
    ... > The preprocessor library is a library of headers and macros that allow ... generation via the preprocessor typically yields more type-safe code that is ... specifically to do with function calls or any other language abstraction. ... invocations are not function calls, do not have the semantics of function calls, ...
    (comp.lang.cpp)
  • Re: Index a #define string
    ... This is preprocessor metaprogramming. ... > Not present in the version of Spirit I am using. ... such as "avoid macros" are dangerous. ... > in to the following comment from Joel. ...
    (comp.lang.cpp)
  • Re: Multiboxing Story - a low level, undermanned ragefire chasm run
    ... unmovable windows which I use like tabs in a web browser - ... There are braindead utility macros out there that I still haven't ... Try out playing 4 or 5 trial accounts at the same time, ...
    (alt.games.warcraft)
  • Re: C preprocessor conundrum
    ... C preprocessor conundrum's a cool scene! ... This would need context sensitivity... ... You can do it, given the right macros, as demonstrated ... >>To achive this you might be better off with external tools like awk and sed, ...
    (comp.lang.c)
  • Re: Boost Workshop at OOPSLA 2004
    ... Hard to see how this is going to be about C++ libraries, ... The preprocessor library is a library of headers and macros that allow ... A rich man wanted to buy it, and Pepelea sold it on one ...
    (comp.lang.cpp)