makes GPIO_PIN_RST optional for the sx1276
[ExpressLRS.git] / src / variants / GHOST_TX / variant_GHOST_TX.cpp
blobe24d55383e29c483bc084198ac9ad230f90ff881
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 PB_9, //D0 - CAN_TX
39 PB_8, //D1 - CAN_RX
40 PB_7, //D2 - UART1_RX or I2C1_SDC
41 PB_6, //D3 - UART1_TX or I2C1_SCL
42 PB_5, //D4 - LED_RED
43 PB_4, //D5 - LED_BLUE
44 PB_3, //D6
45 PA_15, //D7
46 PA_12, //D8 - USB_DP
47 PA_11, //D9 - USB_DM
48 PA_10, //D10 - SDA MPU-9150
49 PA_9, //D11 - SCL MPU-9150
50 PA_8, //D12
51 PB_15, //D13
52 PB_14, //D14
53 PB_13, //D15
54 PB_12, //D16
55 PC_13, //D17 - LED on Bluepill Board
56 PC_14, //D18
57 PC_15, //D19
58 PA_0, //D20/A0
59 PA_1, //D21/A1
60 PA_2, //D22/A2
61 PA_3, //D23/A3 - RCX
62 PA_4, //D24/A4
63 PA_5, //D25/A5
64 PA_6, //D26/A6
65 PA_7, //D27/A7
66 PB_0, //D28/A8
67 PB_1, //D29/A9
68 PB_10, //D30 - UART3_TX
69 PB_11, //D31 - UART3_RX
70 PB_2, //D32 - BOOT1
71 PA_13, //D33 - SWDI0
72 PA_14, //D34 - SWCLK
75 // If analog pins are not contiguous in the digitalPin array:
76 // Add the analogInputPin array without defining NUM_ANALOG_FIRST
77 // Analog (Ax) pin number array
78 // where x is the index to retrieve the digital pin number
79 const uint32_t analogInputPin[] = {
80 20,
81 21,
82 22,
83 23, // Not sure about this one beecasue NUM is 9 in the header, and this is RCX
84 24,
85 25,
86 26,
87 27,
88 28,
92 #ifdef __cplusplus
94 #endif
96 // ----------------------------------------------------------------------------
98 #ifdef __cplusplus
99 extern "C" {
100 #endif
102 WEAK void SystemClock_Config(void)
105 RCC_OscInitTypeDef RCC_OscInitStruct;
106 RCC_ClkInitTypeDef RCC_ClkInitStruct;
107 // RCC_PeriphCLKInitTypeDef PeriphClkInit;
109 /**Initializes the CPU, AHB and APB busses clocks
111 RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSE;
112 RCC_OscInitStruct.HSEState = RCC_HSE_ON;
113 RCC_OscInitStruct.HSEPredivValue = RCC_HSE_PREDIV_DIV4;
114 RCC_OscInitStruct.HSIState = RCC_HSI_ON;
115 RCC_OscInitStruct.HSICalibrationValue = 16;
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 _Error_Handler(__FILE__, __LINE__);
123 /**Initializes the CPU, AHB and APB busses clocks
125 RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK | RCC_CLOCKTYPE_SYSCLK
126 | RCC_CLOCKTYPE_PCLK1 | RCC_CLOCKTYPE_PCLK2;
127 RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
128 RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
129 RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV2;
130 RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
132 if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_2) != HAL_OK) {
133 _Error_Handler(__FILE__, __LINE__);
136 // PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_USART1 | RCC_PERIPHCLK_USART3
137 // | RCC_PERIPHCLK_I2C1;
138 // PeriphClkInit.Usart1ClockSelection = RCC_USART1CLKSOURCE_PCLK2;
139 // PeriphClkInit.Usart3ClockSelection = RCC_USART3CLKSOURCE_PCLK1;
140 // PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_HSI;
141 // if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK) {
142 // _Error_Handler(__FILE__, __LINE__);
143 // }
146 #ifdef __cplusplus
148 #endif