Skip to content

Commit cc3eb2b

Browse files
Fix code style issues with clang_format
1 parent 4991963 commit cc3eb2b

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

46 files changed

+19238
-19770
lines changed

embedded/ESP32S3/gimbal_motor_testing/src/main.cpp

Lines changed: 26 additions & 51 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,5 @@
1-
//UNCOMMENTED CODE REQUIRES DEBUGGING AND IS CURRENTLY ON PAUSE DUE TO POWER DISTRIBUTION ISSUES ON MOTOR CONTROLLER HUB
1+
// UNCOMMENTED CODE REQUIRES DEBUGGING AND IS CURRENTLY ON PAUSE DUE TO POWER
2+
// DISTRIBUTION ISSUES ON MOTOR CONTROLLER HUB
23

34
// #include <SimpleFOC.h>
45
// #include <Wire.h>
@@ -15,30 +16,28 @@
1516
// BLDCMotor motor = BLDCMotor(7);
1617
// BLDCMotor motor2 = BLDCMotor(7);
1718

18-
// // BLDCDriver3PWM driver = BLDCDriver3PWM(pwmA, pwmB, pwmC, Enable(optional));
19+
// // BLDCDriver3PWM driver = BLDCDriver3PWM(pwmA, pwmB, pwmC,
20+
// Enable(optional));
1921
// // BLDCDriver3PWM driver = BLDCDriver3PWM(33,32,25,12);
2022
// BLDCDriver3PWM driver = BLDCDriver3PWM(7,8,9);
2123
// BLDCDriver3PWM driver2 = BLDCDriver3PWM(1,2,3);
2224

23-
// //TO RE-FLASH ESP32-S3: esptool.py --chip esp32s3 --port /dev/ttyACM0 erase_flash
24-
25+
// //TO RE-FLASH ESP32-S3: esptool.py --chip esp32s3 --port /dev/ttyACM0
26+
// erase_flash
2527

2628
// MagneticSensorI2C magnetic_encoder = MagneticSensorI2C(AS5600_I2C);
2729

28-
2930
// // Stepper motor & driver instance
3031

31-
32-
3332
// //target variable
3433
// float target_velocity = 0;
3534
// float target_angle = 0;
3635

3736
// // instantiate the commander
3837
// Commander command = Commander(Serial);
39-
// void doTarget(char* cmd) {
38+
// void doTarget(char* cmd) {
4039
// // command.scalar(&target_velocity, cmd);
41-
// // motor.controller = MotionControlType::velocity_openloop;
40+
// // motor.controller = MotionControlType::velocity_openloop;
4241
// target_velocity = target_velocity;
4342
// }
4443
// void doLimit(char* cmd) { command.scalar(&motor.voltage_limit, cmd); }
@@ -49,20 +48,15 @@
4948
// // target_velocity = target_angle;
5049
// }
5150

52-
53-
54-
5551
// void setup() {
5652

57-
// // use monitoring with serial
53+
// // use monitoring with serial
5854
// Serial.begin(115200);
5955
// WiFi.mode(WIFI_STA);
6056
// WiFi.setHostname("ESP32-BLDC");
6157

6258
// WiFi.begin(ssid, password);
6359

64-
65-
6660
// while (WiFi.status() != WL_CONNECTED) {
6761
// delay(100);
6862
// Serial.println("CONNECTING");
@@ -73,7 +67,7 @@
7367
// String type;
7468
// if (ArduinoOTA.getCommand() == U_FLASH) {
7569
// type = "sketch";
76-
// } else {
70+
// } else {
7771

7872
// type = "filesystem";
7973
// }
@@ -85,13 +79,10 @@
8579
// Serial.print("IP address: ");
8680
// Serial.println(WiFi.localIP());
8781

88-
89-
9082
// motor.useMonitoring(Serial);
91-
83+
9284
// motor2.useMonitoring(Serial);
9385

94-
9586
// // Serial.println("CHECKING FOR ADDRESS");
9687

9788
// // for (byte i=0;i<127;i++) {
@@ -101,10 +92,9 @@
10192
// // }
10293
// // }
10394

104-
10595
// motor.monitor_variables = _MON_TARGET | _MON_VEL | _MON_ANGLE;
106-
// motor2.monitor_variables = _MON_TARGET | _MON_VEL | _MON_VOLT_D | _MON_VOLT_Q | _MON_CURR_D;
107-
96+
// motor2.monitor_variables = _MON_TARGET | _MON_VEL | _MON_VOLT_D |
97+
// _MON_VOLT_Q | _MON_CURR_D;
10898

10999
// // enable more verbose output for debugging
110100
// // comment out if not needed
@@ -130,7 +120,6 @@
130120
// motor.linkDriver(&driver);
131121
// motor.linkSensor(&magnetic_encoder);
132122

133-
134123
// motor2.linkDriver(&driver2);
135124

136125
// //motor.linkSensor(&magnetic_encoder);
@@ -140,16 +129,14 @@
140129
// // current = voltage / resistance, so try to be well under 1Amp
141130
// motor.voltage_limit = 4; // [V]
142131
// motor.current_limit = 0.2;
143-
132+
144133
// // open loop control config
145134
// motor.controller = MotionControlType::velocity_openloop;
146135

147136
// motor2.voltage_limit = 4; // [V]
148137
// motor2.current_limit = 0.2;
149-
150138

151139
// //motor.initFOC();
152-
153140

154141
// // open loop control config
155142
// motor2.controller = MotionControlType::velocity_openloop;
@@ -159,35 +146,28 @@
159146
// Serial.println("Motor init failed!");
160147
// return;
161148
// }
162-
163149

164150
// // add target command T
165151
// command.add('T', doTarget, "target velocity");
166152
// command.add('L', doLimit, "voltage limit");
167153
// command.add('M',doMotor,"motor");
168154
// command.add('A',doAngleTarget,"angle");
169155

170-
171156
// Serial.println("Motor ready!");
172157

173-
174158
// Serial.println("Set target velocity [rad/s]");
175159

176-
177160
// // Serial.println(motor.enabled);
178161
// }
179162

180163
// void loop() {
181164

182-
183165
// // open loop velocity movement
184166
// // using motor.voltage_limit and motor.velocity_limit
185167
// // to turn the motor "backwards", just set a negative target_velocity
186168

187-
188-
189169
// // Serial.println("AAA");
190-
170+
191171
// //analogWrite(26, 128); // 50% duty cycle (speed control)
192172
// // delay(5000); // Run for 5 seconds
193173

@@ -205,7 +185,6 @@
205185

206186
// //Serial.println(magnetic_encoder.getVelocity());
207187

208-
209188
// // analogWrite(26, 0); // Stop the motor
210189
// // delay(5000); // Wait 5 seconds
211190

@@ -217,29 +196,27 @@
217196
// Open loop motor control example
218197
#include <SimpleFOC.h>
219198

220-
221199
// BLDC motor & driver instance
222200
// BLDCMotor motor = BLDCMotor(pole pair number);
223201
BLDCMotor motor = BLDCMotor(7);
224202
// BLDCDriver3PWM driver = BLDCDriver3PWM(pwmA, pwmB, pwmC, Enable(optional));
225-
BLDCDriver3PWM driver = BLDCDriver3PWM(8,9,7);
203+
BLDCDriver3PWM driver = BLDCDriver3PWM(8, 9, 7);
226204

227205
// Stepper motor & driver instance
228-
//StepperMotor motor = StepperMotor(50);
229-
//StepperDriver4PWM driver = StepperDriver4PWM(9, 5, 10, 6, 8);
230-
206+
// StepperMotor motor = StepperMotor(50);
207+
// StepperDriver4PWM driver = StepperDriver4PWM(9, 5, 10, 6, 8);
231208

232-
//target variable
209+
// target variable
233210
float target_velocity = 1;
234211

235212
// instantiate the commander
236213
Commander command = Commander(Serial);
237-
void doTarget(char* cmd) { command.scalar(&target_velocity, cmd); }
238-
void doLimit(char* cmd) { command.scalar(&motor.voltage_limit, cmd); }
214+
void doTarget(char *cmd) { command.scalar(&target_velocity, cmd); }
215+
void doLimit(char *cmd) { command.scalar(&motor.voltage_limit, cmd); }
239216

240217
void setup() {
241218

242-
// use monitoring with serial
219+
// use monitoring with serial
243220
Serial.begin(115200);
244221
// enable more verbose output for debugging
245222
// comment out if not needed
@@ -252,7 +229,7 @@ void setup() {
252229
// as a protection measure for the low-resistance motors
253230
// this value is fixed on startup
254231
driver.voltage_limit = 6;
255-
if(!driver.init()){
232+
if (!driver.init()) {
256233
Serial.println("Driver init failed!");
257234
return;
258235
}
@@ -263,13 +240,13 @@ void setup() {
263240
// limit the voltage to be set to the motor
264241
// start very low for high resistance motors
265242
// current = voltage / resistance, so try to be well under 1Amp
266-
motor.voltage_limit = 3; // [V]
267-
243+
motor.voltage_limit = 3; // [V]
244+
268245
// open loop control config
269246
motor.controller = MotionControlType::velocity_openloop;
270247

271248
// init motor hardware
272-
if(!motor.init()){
249+
if (!motor.init()) {
273250
Serial.println("Motor init failed!");
274251
return;
275252
}
@@ -293,5 +270,3 @@ void loop() {
293270
// user communication
294271
command.run();
295272
}
296-
297-
Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,7 +1,7 @@
11
#ifndef COMMON_DEFINES_H
22
#define COMMON_DEFINES_H
33

4-
#include <stdint.h>
54
#include <stdbool.h>
5+
#include <stdint.h>
66

77
#endif

embedded/STM32/app/inc/system.h

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,11 +3,10 @@
33

44
#include "common_defines.h"
55

6-
#define CPU_FREQ (8400000)
7-
#define SYSTICK_FREQ (1000)
6+
#define CPU_FREQ (8400000)
7+
#define SYSTICK_FREQ (1000)
88

99
void system_setup(void);
1010
uint64_t system_get_ticks(void);
1111

12-
1312
#endif

embedded/STM32/app/src/firmware.c

Lines changed: 32 additions & 35 deletions
Original file line numberDiff line numberDiff line change
@@ -1,48 +1,45 @@
11

22
#include "../inc/common_defines.h"
33
#include "../inc/system.h"
4-
#include "stm32g4xx.h"
54
#include "FreeRTOS.h"
5+
#include "stm32g4xx.h"
66
#include "task.h"
77

8-
#define BOOTLOADER_SIZE (0x08008000U)
8+
#define BOOTLOADER_SIZE (0x08008000U)
99

10-
//set the vector table offset of app firmware image
11-
static void vector_setup(void) {
12-
SCB->VTOR = BOOTLOADER_SIZE;
13-
}
10+
// set the vector table offset of app firmware image
11+
static void vector_setup(void) { SCB->VTOR = BOOTLOADER_SIZE; }
1412

15-
16-
//thread for blinking led
13+
// thread for blinking led
1714
void blink_led(void *pvParams) {
18-
while(1) {
19-
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
20-
//vTaskDelay(pdMS_TO_TICKS(500));
21-
HAL_Delay(500);
22-
}
15+
while (1) {
16+
HAL_GPIO_TogglePin(GPIOA, GPIO_PIN_5);
17+
// vTaskDelay(pdMS_TO_TICKS(500));
18+
HAL_Delay(500);
19+
}
2320
}
2421

25-
2622
int main() {
27-
vector_setup();
28-
HAL_Init();
29-
system_setup();
30-
31-
__HAL_RCC_GPIOA_CLK_ENABLE();
32-
33-
//Configure GPIO PIN5;
34-
GPIO_InitTypeDef GPIO_InitStruct;
35-
GPIO_InitStruct.Pin = GPIO_PIN_5;
36-
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
37-
GPIO_InitStruct.Pull = GPIO_NOPULL;
38-
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
39-
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
40-
41-
//create blinking led task
42-
xTaskCreate(blink_led, "BLINK_LED", 128, NULL, 1, NULL);
43-
44-
//start FreeRTOS Scheduler
45-
vTaskStartScheduler();
46-
47-
while(1);
23+
vector_setup();
24+
HAL_Init();
25+
system_setup();
26+
27+
__HAL_RCC_GPIOA_CLK_ENABLE();
28+
29+
// Configure GPIO PIN5;
30+
GPIO_InitTypeDef GPIO_InitStruct;
31+
GPIO_InitStruct.Pin = GPIO_PIN_5;
32+
GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
33+
GPIO_InitStruct.Pull = GPIO_NOPULL;
34+
GPIO_InitStruct.Speed = GPIO_SPEED_FREQ_LOW;
35+
HAL_GPIO_Init(GPIOA, &GPIO_InitStruct);
36+
37+
// create blinking led task
38+
xTaskCreate(blink_led, "BLINK_LED", 128, NULL, 1, NULL);
39+
40+
// start FreeRTOS Scheduler
41+
vTaskStartScheduler();
42+
43+
while (1)
44+
;
4845
}

0 commit comments

Comments
 (0)