Add missing wifi targets for some DIY modules (#1210)
[ExpressLRS.git] / src / variants / FM30 / variant.cpp
blob8924a396134d3dcad8b77b2ada1a47b43b084185
1 /*
2 *******************************************************************************
3 * Copyright (c) 2018, STMicroelectronics
4 * All rights reserved.
6 * Redistribution and use in source and binary forms, with or without
7 * modification, are permitted provided that the following conditions are met:
9 * 1. Redistributions of source code must retain the above copyright notice,
10 * this list of conditions and the following disclaimer.
11 * 2. Redistributions in binary form must reproduce the above copyright notice,
12 * this list of conditions and the following disclaimer in the documentation
13 * and/or other materials provided with the distribution.
14 * 3. Neither the name of STMicroelectronics nor the names of its contributors
15 * may be used to endorse or promote products derived from this software
16 * without specific prior written permission.
18 * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
19 * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
20 * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
21 * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
22 * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
23 * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
24 * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
25 * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
26 * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
27 * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
28 *******************************************************************************
30 #include "pins_arduino.h"
32 #ifdef __cplusplus
33 extern "C" {
34 #endif
36 // Pin number
37 const PinName digitalPin[] = {
38 /* USB connector on the top, MCU side */
39 /* Left Side */
40 PB_9, //D0
41 PB_8, //D1
42 PB_7, //D2
43 PB_6, //D3
44 PB_5, //D4
45 PB_4, //D5
46 PB_3, //D6
47 PA_15, //D7
48 PA_12, //D8 - USB DP
49 PA_11, //D9 - USB DM
50 PA_10, //D10
51 PA_9, //D11
52 PA_8, //D12
53 PB_15, //D13
54 PB_14, //D14
55 PB_13, //D15
56 PB_12, //D16 - LED Blackpill
57 /* Right side */
58 PC_13, //D17 - LED Bluepill
59 PC_14, //D18
60 PC_15, //D19
61 PA_0, //D20/A0
62 PA_1, //D21/A1
63 PA_2, //D22/A2
64 PA_3, //D23/A3
65 PA_4, //D24/A4
66 PA_5, //D25/A5
67 PA_6, //D26/A6
68 PA_7, //D27/A7
69 PB_0, //D28/A8
70 PB_1, //D29/A9
71 PB_10, //D30
72 PB_11, //D31
73 PB_2, //D32 - BOOT1
74 PA_13, //D33 - SWDI0
75 PA_14, //D34 - SWCLK
78 #ifdef __cplusplus
80 #endif
82 // ----------------------------------------------------------------------------
84 #ifdef __cplusplus
85 extern "C" {
86 #endif
88 /**
89 * @brief System Clock Configuration
90 * The system Clock is configured as follow :
91 * System Clock source = PLL (HSE)
92 * SYSCLK(Hz) = 72000000
93 * HCLK(Hz) = 72000000
94 * AHB Prescaler = 1
95 * APB1 Prescaler = 2
96 * APB2 Prescaler = 1
97 * PLL_Source = HSE
98 * PLL_Mul = 9
99 * Flash Latency(WS) = 2
100 * ADC Prescaler = 6
101 * USB Prescaler = 1.5
102 * @param None
103 * @retval None
105 WEAK void SystemClock_Config(void)
107 RCC_OscInitTypeDef RCC_OscInitStruct;
108 RCC_ClkInitTypeDef RCC_ClkInitStruct;
109 RCC_PeriphCLKInitTypeDef PeriphClkInit;
111 /* Initializes the CPU, AHB and APB busses clocks */
112 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
113 RCC_OscInitStruct.HSEState = RCC_HSE_ON;
114 RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV2;
115 RCC_OscInitStruct.HSIState = RCC_HSI_ON;
116 RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
117 RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
118 RCC_OscInitStruct.PLL.PLLMUL = RCC_PLL_MUL9;
119 if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK) {
120 while (1);
123 /* Initializes the CPU, AHB and APB busses clocks */
124 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
125 | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
126 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
127 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
128 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
129 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
131 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) {
132 while (1);
135 PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_ADC | RCC_PERIPHCLK_USB;
136 PeriphClkInit.AdcClockSelection = RCC_ADCPCLK2_DIV6;
137 PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_PLL_DIV1_5;
138 if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) {
139 while (1);
143 #ifdef __cplusplus
145 #endif