Change sed search regex to be compatible with BSD sed (#14233)
[betaflight.git] / src / main / drivers / io_preinit.c
blob81ca43d42081ccb4957526195a8248dfcbb65504
1 /*
2 * This file is part of Betaflight.
4 * Betaflight is free software. You can redistribute this software
5 * and/or modify this software under the terms of the GNU General
6 * Public License as published by the Free Software Foundation,
7 * either version 3 of the License, or (at your option) any later
8 * version.
10 * Betaflight is distributed in the hope that it will be useful,
11 * but WITHOUT ANY WARRANTY; without even the implied warranty of
12 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.
14 * See the GNU General Public License for more details.
16 * You should have received a copy of the GNU General Public
17 * License along with this software.
19 * If not, see <http://www.gnu.org/licenses/>.
22 #include <stdbool.h>
23 #include <stdint.h>
25 #include "platform.h"
27 #include "drivers/io.h"
28 #include "drivers/resource.h"
29 #include "drivers/system.h"
31 static unsigned preinitIndex = 0;
33 void ioPreinitByIO(const IO_t io, uint8_t iocfg, ioPreinitPinState_e init)
35 if (!io) {
36 return;
38 preinitIndex++;
40 IOInit(io, OWNER_PREINIT, preinitIndex);
41 IOConfigGPIO(io, iocfg);
43 switch(init) {
44 case PREINIT_PIN_STATE_LOW:
45 IOLo(io);
46 break;
47 case PREINIT_PIN_STATE_HIGH:
48 IOHi(io);
49 break;
50 default:
51 // Do nothing
55 void ioPreinitByTag(ioTag_t tag, uint8_t iocfg, ioPreinitPinState_e init)
57 ioPreinitByIO(IOGetByTag(tag), iocfg, init);