2 * This file is part of Cleanflight and 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/>.
27 #include "build/build_config.h"
29 #include "drivers/io.h"
30 #include "drivers/time.h"
32 #include "hardware_revision.h"
34 uint8_t hardwareRevision
= UNKNOWN
;
36 void detectHardwareRevision(void)
38 IO_t pin1
= IOGetByTag(IO_TAG(PC13
));
39 IOInit(pin1
, OWNER_SYSTEM
, 1);
40 IOConfigGPIO(pin1
, IOCFG_IPU
);
42 IO_t pin2
= IOGetByTag(IO_TAG(PC14
));
43 IOInit(pin2
, OWNER_SYSTEM
, 1);
44 IOConfigGPIO(pin2
, IOCFG_IPU
);
46 IO_t pin3
= IOGetByTag(IO_TAG(PC15
));
47 IOInit(pin3
, OWNER_SYSTEM
, 1);
48 IOConfigGPIO(pin3
, IOCFG_IPU
);
50 // Check hardware revision
51 delayMicroseconds(10); // allow configuration to settle
54 Hardware pins : Pin1 = PC13 / Pin2 = PC14 / Pin3 = PC15
55 no Hardware pins tied to ground => Race V1
56 if Pin 1 is the only one tied to ground => Mini
57 if Pin 2 is the only one tied to ground => Race V2
58 if Pin 2 and Pin 1 are tied to ground => Race V3
59 if Pin 3 is the only one tied to ground => Navigation
60 Other combinations available for potential evolutions
62 if (!IORead(pin1
) && IORead(pin2
)) {
63 hardwareRevision
= YUPIF4_MINI
;
64 } else if (IORead(pin1
) && !IORead(pin2
)) {
65 hardwareRevision
= YUPIF4_RACE2
;
66 } else if (!IORead(pin1
) && !IORead(pin2
)) {
67 hardwareRevision
= YUPIF4_RACE3
;
68 } else if (!IORead(pin3
)) {
69 hardwareRevision
= YUPIF4_NAV
;
71 hardwareRevision
= YUPIF4_RACE1
;
75 void updateHardwareRevision(void) {