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/>.
29 #include "drivers/io.h"
32 void mcoInit(const mcoConfig_t
*mcoConfig
)
34 // Only configure MCO2 with PLLI2SCLK as source for now.
35 // Other MCO1 and other sources can easily be added.
36 // For all F4 and F7 varianets, MCO1 is on PA8 and MCO2 is on PC9.
38 if (mcoConfig
->enabled
[1]) {
39 IO_t io
= IOGetByTag(DEFIO_TAG_E(PC9
));
40 IOInit(io
, OWNER_MCO
, 2);
42 HAL_RCC_MCOConfig(RCC_MCO2
, RCC_MCO2SOURCE_PLLI2SCLK
, RCC_MCODIV_4
);
43 IOConfigGPIOAF(io
, IO_CONFIG(GPIO_MODE_AF_PP
, GPIO_SPEED_FREQ_VERY_HIGH
, GPIO_NOPULL
), GPIO_AF0_MCO
);
44 #elif defined(STM32F40_41xxx) || defined(STM32F411xE) || defined(STM32F446xx)
45 RCC_MCO2Config(RCC_MCO2Source_PLLI2SCLK
, RCC_MCO2Div_4
);
46 IOConfigGPIOAF(io
, IO_CONFIG(GPIO_Mode_AF
, GPIO_Speed_50MHz
, GPIO_OType_PP
, GPIO_PuPd_NOPULL
), GPIO_AF_MCO
);
48 #error Unsupported MCU