Skip to content

Commit dcae5c0

Browse files
committed
Add Phoque1 and Phoque2 brushless driver variants
1 parent 36a8f85 commit dcae5c0

8 files changed

Lines changed: 884 additions & 0 deletions

File tree

‎variants/STM32G4xx/G431C(6-8-B)U_G441CBU/CMakeLists.txt‎

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -20,9 +20,11 @@ target_link_libraries(variant INTERFACE variant_usage)
2020

2121
add_library(variant_bin STATIC EXCLUDE_FROM_ALL
2222
generic_clock.c
23+
generic_clock_PHOQUE2.c
2324
PeripheralPins.c
2425
PeripheralPins_B_G431B_ESC1.c
2526
variant_B_G431B_ESC1.cpp
27+
variant_PHOQUE2.cpp
2628
variant_generic.cpp
2729
)
2830
target_link_libraries(variant_bin PUBLIC variant_usage)
Lines changed: 70 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,70 @@
1+
#if defined(ARDUINO_PHOQUE2)
2+
3+
#include "pins_arduino.h"
4+
#include <stm32g4xx_hal.h>
5+
6+
__weak void SystemClock_Config(void)
7+
{
8+
RCC_OscInitTypeDef RCC_OscInitStruct = {0};
9+
RCC_ClkInitTypeDef RCC_ClkInitStruct = {0};
10+
11+
/** Configure the main internal regulator output voltage
12+
*/
13+
HAL_PWREx_ControlVoltageScaling(PWR_REGULATOR_VOLTAGE_SCALE1_BOOST);
14+
15+
/** Initializes the RCC Oscillators according to the specified parameters
16+
* in the RCC_OscInitTypeDef structure.
17+
*/
18+
RCC_OscInitStruct.OscillatorType = RCC_OSCILLATORTYPE_HSI|RCC_OSCILLATORTYPE_HSI48|RCC_OSCILLATORTYPE_HSE;
19+
RCC_OscInitStruct.HSIState = RCC_HSI_ON;
20+
RCC_OscInitStruct.HSEState = RCC_HSE_ON;
21+
RCC_OscInitStruct.HSICalibrationValue = RCC_HSICALIBRATION_DEFAULT;
22+
RCC_OscInitStruct.HSI48State = RCC_HSI48_ON;
23+
RCC_OscInitStruct.PLL.PLLState = RCC_PLL_ON;
24+
#if 0
25+
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSI;
26+
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV4;
27+
#else
28+
RCC_OscInitStruct.PLL.PLLSource = RCC_PLLSOURCE_HSE;
29+
RCC_OscInitStruct.PLL.PLLM = RCC_PLLM_DIV2;
30+
#endif
31+
RCC_OscInitStruct.PLL.PLLN = 85;
32+
RCC_OscInitStruct.PLL.PLLP = RCC_PLLP_DIV2;
33+
RCC_OscInitStruct.PLL.PLLQ = RCC_PLLQ_DIV2;
34+
RCC_OscInitStruct.PLL.PLLR = RCC_PLLR_DIV2;
35+
if (HAL_RCC_OscConfig(&RCC_OscInitStruct) != HAL_OK)
36+
{
37+
Error_Handler();
38+
}
39+
40+
/** Initializes the CPU, AHB and APB buses clocks
41+
*/
42+
RCC_ClkInitStruct.ClockType = RCC_CLOCKTYPE_HCLK|RCC_CLOCKTYPE_SYSCLK
43+
|RCC_CLOCKTYPE_PCLK1|RCC_CLOCKTYPE_PCLK2;
44+
RCC_ClkInitStruct.SYSCLKSource = RCC_SYSCLKSOURCE_PLLCLK;
45+
RCC_ClkInitStruct.AHBCLKDivider = RCC_SYSCLK_DIV1;
46+
RCC_ClkInitStruct.APB1CLKDivider = RCC_HCLK_DIV1;
47+
RCC_ClkInitStruct.APB2CLKDivider = RCC_HCLK_DIV1;
48+
49+
if (HAL_RCC_ClockConfig(&RCC_ClkInitStruct, FLASH_LATENCY_4) != HAL_OK)
50+
{
51+
Error_Handler();
52+
}
53+
54+
#if 1
55+
RCC_PeriphCLKInitTypeDef PeriphClkInit;
56+
PeriphClkInit.PeriphClockSelection = RCC_PERIPHCLK_FDCAN | RCC_PERIPHCLK_USB | RCC_PERIPHCLK_RNG | RCC_PERIPHCLK_LPUART1 | RCC_PERIPHCLK_I2C1;
57+
PeriphClkInit.Lpuart1ClockSelection = RCC_LPUART1CLKSOURCE_PCLK1;
58+
PeriphClkInit.FdcanClockSelection = RCC_FDCANCLKSOURCE_PLL; //CAN will run at 170MHz (PLLQ)
59+
PeriphClkInit.I2c1ClockSelection = RCC_I2C1CLKSOURCE_PCLK1; //I2C1 at 170MHz
60+
PeriphClkInit.UsbClockSelection = RCC_USBCLKSOURCE_HSI48;
61+
PeriphClkInit.RngClockSelection = RCC_RNGCLKSOURCE_HSI48;
62+
if (HAL_RCCEx_PeriphCLKConfig(&PeriphClkInit) != HAL_OK)
63+
{
64+
Error_Handler();
65+
}
66+
//__HAL_RCC_RNG_CLK_ENABLE();
67+
#endif
68+
HAL_SYSCFG_EnableVREFBUF();
69+
}
70+
#endif
Lines changed: 85 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,85 @@
1+
/*
2+
*******************************************************************************
3+
* Copyright (c) 2020, STMicroelectronics
4+
* All rights reserved.
5+
*
6+
* This software component is licensed by ST under BSD 3-Clause license,
7+
* the "License"; You may not use this file except in compliance with the
8+
* License. You may obtain a copy of the License at:
9+
* opensource.org/licenses/BSD-3-Clause
10+
*
11+
*******************************************************************************
12+
*/
13+
#if defined(ARDUINO_PHOQUE2)
14+
#include "pins_arduino.h"
15+
#include "pinmap.h"
16+
17+
// Digital PinName array
18+
extern "C" const PinName digitalPin[] = {
19+
PA_0, // D0/A0
20+
PA_1, // D1/A1
21+
PA_2, // D2/A2
22+
PA_3, // D3/A3
23+
PA_4, // D4/A4
24+
PA_5, // D5/A5
25+
PA_6, // D6/A6
26+
PA_7, // D7/A7
27+
PA_8, // D8
28+
PA_9, // D9
29+
PA_10, // D10
30+
PA_11, // D11
31+
PA_12, // D12
32+
PA_13, // D13
33+
PA_14, // D14
34+
PA_15, // D15
35+
PB_0, // D16/A8
36+
PB_1, // D17/A9
37+
PB_2, // D18/A10
38+
PB_3, // D19
39+
PB_4, // D20
40+
PB_5, // D21
41+
PB_6, // D22
42+
PB_7, // D23
43+
PB_8, // D24
44+
PB_9, // D25
45+
PB_10, // D26
46+
PB_11, // D27/A11
47+
PB_12, // D28/A12
48+
PB_13, // D29
49+
PB_14, // D30/A13
50+
PB_15, // D31/A14
51+
PC_4, // D32/A15
52+
PC_6, // D33
53+
PC_10, // D34
54+
PC_11, // D35
55+
PC_13, // D36
56+
PC_14, // D37
57+
PC_15, // D38
58+
PF_0, // D39/A16
59+
PF_1, // D40/A17
60+
PG_10 // D41
61+
};
62+
63+
// Analog (Ax) pin number array
64+
extern "C" const uint32_t analogInputPin[] = {
65+
0, // A0, PA0
66+
1, // A1, PA1
67+
2, // A2, PA2
68+
3, // A3, PA3
69+
4, // A4, PA4
70+
5, // A5, PA5
71+
6, // A6, PA6
72+
7, // A7, PA7
73+
16, // A8, PB0
74+
17, // A9, PB1
75+
18, // A10, PB2
76+
27, // A11, PB11
77+
28, // A12, PB12
78+
30, // A13, PB14
79+
31, // A14, PB15
80+
32, // A15, PC4
81+
39, // A16, PF0
82+
40 // A17, PF1
83+
};
84+
85+
#endif /* ARDUINO_GENERIC_* */

0 commit comments

Comments
 (0)