Skip to content

Commit be28260

Browse files
authored
Merge pull request stylesuxx#56 from giacomo892/giacomo892_clean
Cleanup
2 parents e1a9f82 + 8bfb754 commit be28260

File tree

11 files changed

+26
-93
lines changed

11 files changed

+26
-93
lines changed

Inc/signal.h

-1
Original file line numberDiff line numberDiff line change
@@ -14,7 +14,6 @@ extern int adjusted_input;
1414
extern int newinput;
1515
extern char inputSet;
1616
extern char dshot;
17-
extern char oneshot125;
1817
extern char servoPwm;
1918
extern uint32_t gcr[];
2019
extern int armed_count_threshold;

Mcu/f051/Inc/IO.h

-1
Original file line numberDiff line numberDiff line change
@@ -26,7 +26,6 @@ extern int adjusted_input;
2626
extern int newinput;
2727
extern char inputSet;
2828
extern char dshot;
29-
extern char oneshot125;
3029
extern char servoPwm;
3130
extern uint32_t gcr[];
3231
extern int armed_count_threshold;

Mcu/f051/Src/IO.c

-4
Original file line numberDiff line numberDiff line change
@@ -152,10 +152,6 @@ void detectInput(){
152152
smallestnumber = 20000;
153153
average_signal_pulse = 0;
154154
dshot = 0;
155-
// proshot = 0;
156-
// multishot = 0;
157-
// oneshot42 = 0;
158-
oneshot125 = 0;
159155
servoPwm = 0;
160156
int lastnumber = dma_buffer[0];
161157

Mcu/f350/Inc/IO.h

-1
Original file line numberDiff line numberDiff line change
@@ -24,7 +24,6 @@ extern int input;
2424
extern int newinput;
2525
extern char inputSet;
2626
extern char dshot;
27-
extern char oneshot125;
2827
extern char servoPwm;
2928
extern uint32_t gcr[];
3029
extern int armed_count_threshold;

Mcu/f350/Src/IO.c

-4
Original file line numberDiff line numberDiff line change
@@ -155,10 +155,6 @@ void sendDshotDma(){
155155
void detectInput(){
156156
smallestnumber = 20000;
157157
dshot = 0;
158-
// proshot = 0;
159-
// multishot = 0;
160-
// oneshot42 = 0;
161-
// oneshot125 = 0;
162158
servoPwm = 0;
163159
int lastnumber = dma_buffer[0];
164160
for ( int j = 1 ; j < 31; j++){

Mcu/g071/Src/IO.c

-11
Original file line numberDiff line numberDiff line change
@@ -103,10 +103,6 @@ void sendDshotDma(){
103103
void detectInput(){
104104
smallestnumber = 20000;
105105
dshot = 0;
106-
// proshot = 0;
107-
// multishot = 0;
108-
// oneshot42 = 0;
109-
// oneshot125 = 0;
110106
servoPwm = 0;
111107
int lastnumber = dma_buffer[0];
112108
for ( int j = 1 ; j < 31; j++){
@@ -138,16 +134,9 @@ void detectInput(){
138134
buffersize = 32;
139135
}
140136
if ((smallestnumber > 100 )&&(smallestnumber < 400)){
141-
// multishot = 1;
142137
armed_count_threshold = 1000;
143138
buffersize = 4;
144139
}
145-
// if ((smallestnumber > 2000 )&&(smallestnumber < 3000)){
146-
// oneshot42 = 1;
147-
// }
148-
//// if ((smallestnumber > 3000 )&&(smallestnumber < 7000)){
149-
//// oneshot125 = 1;
150-
//// }
151140
if (smallestnumber > 1500){
152141
servoPwm = 1;
153142
ic_timer_prescaler=63;

Src/dshot.c

-3
Original file line numberDiff line numberDiff line change
@@ -239,6 +239,3 @@ for (int i = 15; i >= 9 ; i--){
239239

240240

241241
}
242-
243-
244-

Src/functions.c

+1-1
Original file line numberDiff line numberDiff line change
@@ -46,4 +46,4 @@ void delayMillis(uint32_t millis){
4646
}
4747
UTILITY_TIMER->PSC = CPU_FREQUENCY_MHZ; // back to micros
4848
LL_TIM_GenerateEvent_UPDATE(UTILITY_TIMER);
49-
}
49+
}

Src/main.c

+23-44
Original file line numberDiff line numberDiff line change
@@ -64,7 +64,7 @@
6464
*-- increase max change a low rpm x10
6565
*-- set low limit of throttle ramp to a lower point and increase upper range
6666
*-- change desync event from full restart to just lower throttle.
67-
67+
6868
*1.64
6969
* --added startup check for continuous high signal, reboot to enter bootloader.
7070
*-- added brake on stop from eeprom
@@ -152,13 +152,11 @@ uint16_t desired_angle = 90;
152152
uint32_t MCU_Id = 0;
153153
uint32_t REV_Id = 0;
154154

155-
uint16_t loop_time = 0;
156-
uint16_t last_loop_time = 0;
157155
uint16_t armed_timeout_count;
158156

159157
uint8_t desync_happened = 0;
160158
char maximum_throttle_change_ramp = 1;
161-
char sine_mode_changeover_thottle_level = 5;
159+
char sine_mode_changeover_thottle_level = 5;
162160
char drag_brake_strength = 10;
163161

164162
char crawler_mode = 0; // no longer used //
@@ -209,7 +207,6 @@ char startup_boost = 35;
209207
char stall_protection = 0;
210208
char reversing_dead_band = 1;
211209

212-
uint16_t oneKhz_timer = 0;
213210
int checkcount = 0;
214211
uint16_t low_pin_count = 0;
215212

@@ -299,9 +296,7 @@ int filter_level = 5;
299296
int running = 0;
300297
int advance = 0;
301298
int advancedivisor = 6;
302-
//int START_ARR=800;
303299
char rising = 1;
304-
int count = 0;
305300

306301
////Space Vector PWM ////////////////
307302
//const int pwmSin[] ={128, 132, 136, 140, 143, 147, 151, 155, 159, 162, 166, 170, 174, 178, 181, 185, 189, 192, 196, 200, 203, 207, 211, 214, 218, 221, 225, 228, 232, 235, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 249, 250, 250, 251, 252, 252, 253, 253, 253, 254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 254, 254, 253, 253, 253, 252, 252, 251, 250, 250, 249, 248, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 239, 240, 241, 242, 243, 244, 245, 246, 247, 248, 248, 249, 250, 250, 251, 252, 252, 253, 253, 253, 254, 254, 254, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 255, 254, 254, 254, 253, 253, 253, 252, 252, 251, 250, 250, 249, 248, 248, 247, 246, 245, 244, 243, 242, 241, 240, 239, 238, 235, 232, 228, 225, 221, 218, 214, 211, 207, 203, 200, 196, 192, 189, 185, 181, 178, 174, 170, 166, 162, 159, 155, 151, 147, 143, 140, 136, 132, 128, 124, 120, 116, 113, 109, 105, 101, 97, 94, 90, 86, 82, 78, 75, 71, 67, 64, 60, 56, 53, 49, 45, 42, 38, 35, 31, 28, 24, 21, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 8, 7, 6, 6, 5, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 17, 16, 15, 14, 13, 12, 11, 10, 9, 8, 8, 7, 6, 6, 5, 4, 4, 3, 3, 3, 2, 2, 2, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 5, 6, 6, 7, 8, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18, 21, 24, 28, 31, 35, 38, 42, 45, 49, 53, 56, 60, 64, 67, 71, 75, 78, 82, 86, 90, 94, 97, 101, 105, 109, 113, 116, 120, 124};
@@ -381,10 +376,6 @@ int input = 0;
381376
int newinput =0;
382377
char inputSet = 0;
383378
char dshot = 0;
384-
char proshot = 0;
385-
char multishot = 0;
386-
char oneshot42 = 0;
387-
char oneshot125 = 0;
388379
char servoPwm = 0;
389380
int zero_crosses;
390381

@@ -489,7 +480,7 @@ void loadEEpromSettings(){
489480

490481
motor_kv = (eepromBuffer[26] * 40) + 20;
491482
motor_poles = eepromBuffer[27];
492-
483+
493484
if(eepromBuffer[28] == 0x01){
494485
brake_on_stop = 1;
495486
}else{
@@ -531,7 +522,7 @@ void loadEEpromSettings(){
531522
RC_CAR_REVERSE = 0;
532523
}
533524
if(eepromBuffer[39] == 0x01){
534-
#ifdef HAS_HALL_SENSORS
525+
#ifdef HAS_HALL_SENSORS
535526
USE_HALL_SENSOR = 1;
536527
#else
537528
USE_HALL_SENSOR = 0;
@@ -553,7 +544,7 @@ void loadEEpromSettings(){
553544
}
554545
low_rpm_level = motor_kv / 200 / (16 / motor_poles);
555546
high_rpm_level = (40 + (motor_kv / 100)) / (16/motor_poles);
556-
547+
557548
if(!comp_pwm){
558549
bi_direction = 0;
559550
}
@@ -852,10 +843,10 @@ if(!armed){
852843
}
853844
}
854845
if (RC_CAR_REVERSE && prop_brake_active) {
855-
#ifndef PWM_ENABLE_BRIDGE
846+
#ifndef PWM_ENABLE_BRIDGE
856847
duty_cycle = getAbsDif(1000, newinput) + 1000;
857848
proportionalBrake();
858-
#endif
849+
#endif
859850
}
860851

861852

@@ -866,8 +857,8 @@ if(!armed){
866857
zero_crosses = 0;
867858
bad_count = 0;
868859
if(brake_on_stop){
869-
if(!use_sin_start){
870-
duty_cycle = 1980 + drag_brake_strength*2;
860+
if(!use_sin_start){
861+
duty_cycle = 1980 + drag_brake_strength*2;
871862
proportionalBrake();
872863
prop_brake_active = 1;
873864
}
@@ -986,7 +977,7 @@ if(desync_check && zero_crosses > 10){
986977
last_average_interval = average_interval;
987978
}
988979
if(send_telemetry){
989-
#ifdef USE_SERIAL_TELEMETRY
980+
#ifdef USE_SERIAL_TELEMETRY
990981
makeTelemPackage(degrees_celsius,
991982
battery_voltage,
992983
actual_current,
@@ -1122,8 +1113,6 @@ int main(void)
11221113

11231114
initCorePeripherals();
11241115

1125-
//
1126-
11271116
LL_TIM_CC_EnableChannel(TIM1, LL_TIM_CHANNEL_CH1);
11281117
LL_TIM_CC_EnableChannel(TIM1, LL_TIM_CHANNEL_CH2);
11291118
LL_TIM_CC_EnableChannel(TIM1, LL_TIM_CHANNEL_CH3);
@@ -1140,7 +1129,7 @@ int main(void)
11401129
#ifdef USE_ADC_INPUT
11411130

11421131
#else
1143-
//
1132+
//
11441133
LL_TIM_CC_EnableChannel(IC_TIMER_REGISTER, IC_TIMER_CHANNEL); // input capture and output compare
11451134
LL_TIM_EnableCounter(IC_TIMER_REGISTER);
11461135
#endif
@@ -1177,7 +1166,7 @@ int main(void)
11771166

11781167
__IO uint32_t wait_loop_index = 0;
11791168
/* Enable comparator */
1180-
1169+
11811170
LL_COMP_Enable(MAIN_COMP);
11821171

11831172
wait_loop_index = ((LL_COMP_DELAY_STARTUP_US * (SystemCoreClock / (100000 * 2))) / 10);
@@ -1256,11 +1245,11 @@ if (GIMBAL_MODE){
12561245
checkForHighSignal(); // will reboot if signal line is high for 10ms
12571246
receiveDshotDma();
12581247
#endif
1259-
1248+
12601249
#ifdef MCU_F051
12611250
MCU_Id = DBGMCU->IDCODE &= 0xFFF;
12621251
REV_Id = DBGMCU->IDCODE >> 16;
1263-
1252+
12641253
if(REV_Id >= 4096){
12651254
temperature_offset = 0;
12661255
}else{
@@ -1271,17 +1260,7 @@ if (GIMBAL_MODE){
12711260
{
12721261

12731262
LL_IWDG_ReloadCounter(IWDG);
1274-
count++;
12751263

1276-
// if(count>10){
1277-
//
1278-
//
1279-
// if(loop_time>=last_loop_time){
1280-
// loop_time = (10*loop_time + (UTILITY_TIMER->CNT - last_loop_time))/11;
1281-
// }
1282-
// last_loop_time = UTILITY_TIMER->CNT;
1283-
// count = 0;
1284-
// }
12851264
adc_counter++;
12861265
if(adc_counter>100){ // for testing adc and telemetry
12871266
ADC_raw_temp = ADC_raw_temp - (temperature_offset);
@@ -1318,8 +1297,8 @@ LL_IWDG_ReloadCounter(IWDG);
13181297
}
13191298
#endif
13201299
}
1321-
1322-
1300+
1301+
13231302
#ifdef USE_ADC_INPUT
13241303

13251304
signaltimeout = 0;
@@ -1330,8 +1309,8 @@ if(newinput > 2000){
13301309
}
13311310
#endif
13321311
stuckcounter = 0;
1333-
1334-
if (bi_direction == 1 && proshot == 0 && dshot == 0){
1312+
1313+
if (bi_direction == 1 && dshot == 0){
13351314
if(RC_CAR_REVERSE){
13361315
if (newinput > (1000 + (servo_dead_band<<1))) {
13371316
if (forward == dir_reversed) {
@@ -1402,7 +1381,7 @@ if(newinput > 2000){
14021381
brushed_direction_set = 0;
14031382
}
14041383
}
1405-
}else if ((proshot || dshot) && bi_direction) {
1384+
}else if (dshot && bi_direction) {
14061385
if (newinput > 1047) {
14071386

14081387
if (forward == dir_reversed) {
@@ -1631,7 +1610,7 @@ if (old_routine && running){
16311610
if(input > 48 && armed){
16321611

16331612
if (input > 48 && input < 137){// sine wave stepper
1634-
1613+
16351614
maskPhaseInterrupts();
16361615
allpwm();
16371616
advanceincrement();
@@ -1652,7 +1631,7 @@ if(input > 48 && armed){
16521631
old_routine = 1;
16531632
commutation_interval = 9000;
16541633
average_interval = 9000;
1655-
last_average_interval = average_interval;
1634+
last_average_interval = average_interval;
16561635
// minimum_duty_cycle = ;
16571636
INTERVAL_TIMER->CNT = 9000;
16581637
zero_crosses = 0;
@@ -1666,7 +1645,7 @@ if(input > 48 && armed){
16661645

16671646
}else{
16681647
if(brake_on_stop){
1669-
duty_cycle = 1980 + drag_brake_strength*2;
1648+
duty_cycle = 1980 + drag_brake_strength*2;
16701649
adjusted_duty_cycle = TIMER1_MAX_ARR - ((duty_cycle * tim1_arr)/TIMER1_MAX_ARR)+1;
16711650
TIM1->ARR = tim1_arr;
16721651
TIM1->CCR1 = adjusted_duty_cycle;
@@ -1706,7 +1685,7 @@ void Error_Handler(void)
17061685
* @retval None
17071686
*/
17081687
void assert_failed(uint8_t *file, uint32_t line)
1709-
{
1688+
{
17101689
/* USER CODE BEGIN 6 */
17111690
/* User can add his own implementation to report the file name and line number,
17121691
tex: printf("Wrong parameters value: file %s on line %d\r\n", file, line) */

Src/signal.c

-21
Original file line numberDiff line numberDiff line change
@@ -126,24 +126,3 @@ if(!armed){
126126
}
127127
}
128128
}
129-
130-
131-
132-
133-
134-
135-
136-
137-
138-
139-
140-
141-
142-
143-
144-
145-
146-
147-
148-
149-

f051makefile.mk

+2-2
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@ CC = $(ARM_SDK_PREFIX)gcc
22
CP = $(ARM_SDK_PREFIX)objcopy
33
MCU := -mcpu=cortex-m0 -mthumb
44
LDSCRIPT := Mcu/f051/STM32F051K6TX_FLASH.ld
5-
LIBS := -lc -lm -lnosys
5+
LIBS := -lc -lm -lnosys
66
LDFLAGS := -specs=nano.specs -T$(LDSCRIPT) $(LIBS) -Wl,--gc-sections -Wl,--print-memory-usage
77
MAIN_SRC_DIR := Src
88
SRC_DIR := Mcu/f051/Startup \
@@ -15,7 +15,7 @@ INCLUDES := \
1515
-IMcu/f051/Inc \
1616
-IMcu/f051/Drivers/STM32F0xx_HAL_Driver/Inc \
1717
-IMcu/f051/Drivers/CMSIS/Include \
18-
-IMcu/f051/Drivers/CMSIS/Device/ST/STM32F0xx/Include
18+
-IMcu/f051/Drivers/CMSIS/Device/ST/STM32F0xx/Include
1919
VALUES := \
2020
-DUSE_MAKE \
2121
-DHSE_VALUE=8000000 \

0 commit comments

Comments
 (0)