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> #define MY_PORT1_SET(bit) GPIO_SET_HI(bit) #define MY_PORT1_CLR(bit) GPIO_SET_LO(bit) #undef GPIO_ID #define GPIO_ID MY_PORT2_ID #include <cfg/arch/porttran.h> #define MY_PORT2_SET(bit) GPIO_SET_HI(bit) #define MY_PORT2_CLR(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:
Definition in file porttran.h.
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_CFG_OUTPUT(b) |
#define | GPIO_CFG_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) |