On 2006-07-04, David Brown <[email protected]> wrote:

> However you do it, I agree entirely that you want to use a single name for
> your pins rather than explicitly using both a port address and bit reference
> in the main code.
>
> Personally, I have used a set of macros for many years.  They sometimes need
> modification when I start with a new micro or a new compiler, but I have
> used the same API for over a decade with something like twenty different
> compilers and assemblers.
>
>
> #define ledGreen MakeBit(P3OUT, 3)
> #define inputSwitch MakeBit(P3IN, 5)
>
>
> void foo(void) {
>     SetBit(ledGreen);
>     OutputEnable(ledGreen);
>
>     while (1) {
>         if (GetBit(inputSwitch)) {
>             ResetBit(ledGreen);
>         };
>     };
> }

I like that approach.  Having to define more than one macro
for a ping always seemed "wrong".

-- 
Grant Edwards                   grante             Yow!  I have the power
                                  at               to HALT PRODUCTION on all
                               visi.com            TEENAGE SEX COMEDIES!!


Reply via email to