porttran.h File Reference

Port translations. More...

Go to the source code of this file.

Defines

#define GPIO_SET_LO(b)
#define GPIO_SET_HI(b)
#define GPIO_IS_HI(b)
#define GPIO_GET(b)
#define GPIO_ENABLE(b)
#define GPIO_OUTPUT(b)
#define GPIO_INPUT(b)
#define GPIO_PULLUP_ON(b)
#define GPIO_PULLUP_OFF(b)
#define GPIO_FILTER_ON(b)
#define GPIO_FILTER_OFF(b)
#define GPIO_OPENDRAIN(b)
#define GPIO_PUSHPULL(b)

Detailed Description

Port translations.

This header file determines the target specific GPIO register names by a simple configured port identifier. In addition it provides several macros to configure, set, clear or query GPIO bits.

Unlike most other header files, this one may be included several times within a single source file, typically once for each configured identifier.

 #undef GPIO_ID
 #define GPIO_ID MY_PORT1_ID
 #include <cfg/arch/porttran.h>
 static INLINE void MY_PORT1_SET(int bit) { GPIO_SET_HI(bit); }
 static INLINE void MY_PORT1_CLR(int bit) { GPIO_SET_LO(bit); }

 #undef GPIO_ID
 #define GPIO_ID MY_PORT2_ID
 #include <cfg/arch/porttran.h>
 static INLINE void MY_PORT2_SET(int bit) { GPIO_SET_HI(bit); }
 static INLINE void MY_PORT2_CLR(int bit) { GPIO_SET_LO(bit); }

 void Out1(int bit, int val)
 {
   if (val)
     MY_PORT1_SET(bit);
   else
     MY_PORT1_CLR(bit);
 }

 void Toogle2(int bit)
 {
   MY_PORT2_SET(bit);
   MY_PORT2_CLR(bit);
 }

In contrast to the routines in dev/gpio.h, these macros do not require any function call and will therefore produce faster and smaller code. The following macros are currently available:

Note:
All listed macros will be available for any port identifier on any target, even if the related function is not available. You should check the target's datasheet.
We use capital letters for the inline attribute to refer to a preprocessor macro. If the compiler doesn't support inlined function, then the macro will be empty. In this case a function call may be used, depending on the compiler's optimization strategy. Even if the compiler supports the inline keyword, it may decide to generate a callable function.

Definition in file porttran.h.


© 2000-2007 by egnite Software GmbH - visit http://www.ethernut.de/