2 * This file is part of Cleanflight.
4 * Cleanflight is free software: you can redistribute it and/or modify
5 * it under the terms of the GNU General Public License as published by
6 * the Free Software Foundation, either version 3 of the License, or
7 * (at your option) any later version.
9 * Cleanflight is distributed in the hope that it will be useful,
10 * but WITHOUT ANY WARRANTY; without even the implied warranty of
11 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
12 * GNU General Public License for more details.
14 * You should have received a copy of the GNU General Public License
15 * along with Cleanflight. If not, see <http://www.gnu.org/licenses/>.
20 #include "common/utils.h"
22 // return ioTag_t for given pinid
23 // tag for NONE must be false
24 #define DEFIO_TAG(pinid) CONCAT(DEFIO_TAG__, pinid)
25 #define DEFIO_TAG__NONE 0
26 #define DEFIO_TAG_E(pinid) CONCAT(DEFIO_TAG_E__, pinid)
27 #define DEFIO_TAG_E__NONE 0
30 // return ioRec_t or NULL for given pinid
31 // tags should be preferred, possibly removing it in future
32 // io_impl.h must be included when this macro is used
33 #define DEFIO_REC(pinid) CONCAT(DEFIO_REC__, pinid)
34 #define DEFIO_REC__NONE NULL
36 #define DEFIO_IO(pinid) (IO_t)DEFIO_REC(pinid)
37 // TODO - macro to check for pinid NONE (fully in preprocessor)
40 #define DEFIO_REC_INDEXED(idx) (ioRecs + (idx))
42 // ioTag_t accessor macros
43 #define DEFIO_TAG_MAKE(gpioid, pin) ((ioTag_t)((((gpioid) + 1) << 4) | (pin)))
44 #define DEFIO_TAG_ISEMPTY(tag) (!(tag))
45 #define DEFIO_TAG_GPIOID(tag) (((tag) >> 4) - 1)
46 #define DEFIO_TAG_PIN(tag) ((tag) & 0x0f)
48 // TARGET must define used pins
50 // include template-generated macros for IO pins
51 #include "io_def_generated.h"