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/>.
22 #include "drivers/bus_i2c.h"
23 #include "drivers/bus_spi.h"
24 #include "hardware_revision.h"
25 #include "config/config_master.h"
26 #include "drivers/io.h"
27 #include "config/feature.h"
29 void targetPreInit(void)
31 switch (hardwareRevision
) {
40 IO_t inverter
= IOGetByTag(IO_TAG(UART1_INVERTER
));
41 IOInit(inverter
, OWNER_INVERTER
, 1);
42 IOConfigGPIO(inverter
, IOCFG_OUT_PP
);
45 serialPortConfig_t
*portConfig
= serialFindPortConfiguration(SERIAL_PORT_USART1
);
47 bool smartportEnabled
= (portConfig
->functionMask
& FUNCTION_TELEMETRY_SMARTPORT
);
48 if (smartportEnabled
&& (telemetryConfig()->telemetry_inversion
) && (feature(FEATURE_TELEMETRY
))) {
52 /* reverse this for rev4, as it does not use the XOR gate */
53 if (hardwareRevision
== BJF4_REV4
) {
56 IOWrite(inverter
, high
);
58 /* ensure the CS pin for the flash is pulled hi so any SD card initialisation does not impact the chip */
59 if (hardwareRevision
== BJF4_REV3
) {
60 IO_t io
= IOGetByTag(IO_TAG(M25P16_CS_PIN
));
61 IOConfigGPIO(io
, IOCFG_OUT_PP
);