2 * This file is part of Betaflight.
4 * Cleanflight and Betaflight are free software. You can redistribute
5 * this software and/or modify this software under the terms of the
6 * GNU General Public License as published by the Free Software
7 * Foundation, either version 3 of the License, or (at your option)
10 * Cleanflight and Betaflight are distributed in the hope that they
11 * will be useful, but WITHOUT ANY WARRANTY; without even the implied
12 * warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
13 * See the GNU General Public License for more details.
15 * You should have received a copy of the GNU General Public License
16 * along with this software.
18 * If not, see <http://www.gnu.org/licenses/>.
25 #ifdef USE_PIN_PULL_UP_DOWN
27 #include "build/debug.h"
28 #include "drivers/io.h"
29 #include "pg/pin_pull_up_down.h"
30 #include "pin_pull_up_down.h"
33 static void initPin(const pinPullUpDownConfig_t
* config
, resourceOwner_e owner
, uint8_t index
)
35 IO_t io
= IOGetByTag(config
->ioTag
);
40 IOInit(io
, owner
, RESOURCE_INDEX(index
));
42 if (owner
== OWNER_PULLUP
) {
43 IOConfigGPIO(io
, IOCFG_IPU
);
44 } else if (owner
== OWNER_PULLDOWN
) {
45 IOConfigGPIO(io
, IOCFG_IPD
);
49 void pinPullupPulldownInit()
51 for (uint8_t i
= 0; i
< PIN_PULL_UP_DOWN_COUNT
; i
++) {
52 initPin(pinPullupConfig(i
), OWNER_PULLUP
, i
);
53 initPin(pinPulldownConfig(i
), OWNER_PULLDOWN
, i
);