Skip to content

Commit

Permalink
chore: run format.sh
Browse files Browse the repository at this point in the history
  • Loading branch information
freasy committed Feb 3, 2024
1 parent 02f8dfc commit cd3af91
Show file tree
Hide file tree
Showing 69 changed files with 1,377 additions and 1,727 deletions.
6 changes: 4 additions & 2 deletions Inc/functions.h
Original file line number Diff line number Diff line change
Expand Up @@ -16,7 +16,9 @@ void delayMicros(uint32_t micros);
void delayMillis(uint32_t millis);
long map(long x, long in_min, long in_max, long out_min, long out_max);
#ifdef ARTERY
void gpio_mode_QUICK(gpio_type* gpio_periph, uint32_t mode, uint32_t pull_up_down, uint32_t pin);
void gpio_mode_set(gpio_type* gpio_periph, uint32_t mode, uint32_t pull_up_down, uint32_t pin);
void gpio_mode_QUICK(gpio_type* gpio_periph, uint32_t mode,
uint32_t pull_up_down, uint32_t pin);
void gpio_mode_set(gpio_type* gpio_periph, uint32_t mode, uint32_t pull_up_down,
uint32_t pin);
#endif
#endif /* FUNCTIONS_H_ */
3 changes: 2 additions & 1 deletion Inc/signal.h
Original file line number Diff line number Diff line change
Expand Up @@ -18,7 +18,8 @@ extern char crawler_mode;

extern uint16_t ADC_raw_volts;
extern uint16_t servo_low_threshold; // anything below this point considered 0
extern uint16_t servo_high_threshold; // anything above this point considered 2000 (max)
extern uint16_t
servo_high_threshold; // anything above this point considered 2000 (max)
extern uint16_t servo_neutral;
extern uint8_t servo_dead_band;
extern char inputSet;
Expand Down
104 changes: 52 additions & 52 deletions Inc/targets.h
Original file line number Diff line number Diff line change
Expand Up @@ -40,18 +40,16 @@
// #define USE_ADC_INPUT
// #define USE_ALKAS_DEBUG_LED


#ifdef REF_G431
#define FIRMWARE_NAME "Ref G431 "
#define FILE_NAME "REF_G431"
#define DEAD_TIME 80
#define HARDWARE_GROUP_G4_A
#define TARGET_STALL_PROTECTION_INTERVAL 20000
//#define PA6_VOLTAGE
//#define USE_SERIAL_TELEMETRY
// #define PA6_VOLTAGE
// #define USE_SERIAL_TELEMETRY
#endif


#ifdef GD32DEV_A_E230
#define FIRMWARE_NAME "GD32 Dev A "
#define FILE_NAME "GD32DEV_A_E230"
Expand Down Expand Up @@ -115,7 +113,8 @@
#define USE_SERIAL_TELEMETRY
#endif

/*********************************************************************AT32F421 targets*********************************************/
/*********************************************************************AT32F421
* targets*********************************************/

#ifdef SWAP_PB0_PA7_F421
#define FIRMWARE_NAME "SWAP PB0 PA7"
Expand Down Expand Up @@ -211,24 +210,24 @@
#define USE_SERIAL_TELEMETRY
#endif

#ifdef NEUTRON_4IN1_F421
#define FIRMWARE_NAME "NEUTRON_4IN1"
#define FILE_NAME "NEUTRON_4IN1_F421"
#define DEAD_TIME 50
#ifdef NEUTRON_4IN1_F421
#define FIRMWARE_NAME "NEUTRON_4IN1"
#define FILE_NAME "NEUTRON_4IN1_F421"
#define DEAD_TIME 50
#define HARDWARE_GROUP_AT_C
#define HARDWARE_GROUP_AT_045
#define USE_SERIAL_TELEMETRY
#endif

#ifdef RR_ROBOT_DUAL_ESC_F421
#define FIRMWARE_NAME "RR DUAL ESC "
#define FILE_NAME "RR_ROBOT_DUAL_ESC_F421"
#define DEAD_TIME 50
#ifdef RR_ROBOT_DUAL_ESC_F421
#define FIRMWARE_NAME "RR DUAL ESC "
#define FILE_NAME "RR_ROBOT_DUAL_ESC_F421"
#define DEAD_TIME 50
#define HARDWARE_GROUP_AT_C
#define HARDWARE_GROUP_AT_045
#define USE_SERIAL_TELEMETRY
#define VOLTAGE_BASED_RAMP
#define MILLIVOLT_PER_AMP 12
#define MILLIVOLT_PER_AMP 12
#endif

#ifdef DARWIN_F421
Expand Down Expand Up @@ -276,7 +275,8 @@
#define USE_SERIAL_TELEMETRY
#endif

/***************************************End Generic *****************************************/
/***************************************End Generic
* *****************************************/

#ifdef GIPSY_F421
#define FIRMWARE_NAME "GiPSy F421 "
Expand All @@ -291,7 +291,6 @@
#define ADC_CHANNEL_VOLTAGE ADC_CHANNEL_6
#endif


#ifdef TEKKO32_F421
#define FIRMWARE_NAME "Tekko32 F4 "
#define FILE_NAME "TEKKO32_F421"
Expand Down Expand Up @@ -437,7 +436,8 @@
#define USE_SERIAL_TELEMETRY
#endif

/*****************************************************AT32F415 targets ************************************************/
/*****************************************************AT32F415 targets
* ************************************************/

#ifdef PB450_F051
#define FILE_NAME "PB450_F051"
Expand Down Expand Up @@ -466,7 +466,6 @@
#define HARDWARE_GROUP_F0_405
#endif


#ifdef FD6288_F051
#define FILE_NAME "FD6288_F051"
#define FIRMWARE_NAME "FD6288_PA2 "
Expand Down Expand Up @@ -739,7 +738,8 @@
#define HARDWARE_GROUP_F0_A
#define USE_SERIAL_TELEMETRY
#endif
/******************************* G071 Targets *********************************/
/******************************* G071 Targets
* *********************************/

#ifdef GEN_64K_G071
#define FILE_NAME "GEN_64K_G071"
Expand Down Expand Up @@ -780,7 +780,6 @@
#define USE_LED_STRIP
#endif


#ifdef SEQURE_12S_G071
#define FILE_NAME "SEQURE_12S_G071"
#define FIRMWARE_NAME "SEQURE PRO "
Expand Down Expand Up @@ -822,7 +821,7 @@
#define SIXTY_FOUR_KB_MEMORY
#endif

#ifdef FLYCOLOR_HV3_G071
#ifdef FLYCOLOR_HV3_G071
#define FILE_NAME "FLYCOLOR_HV3_G071"
#define FIRMWARE_NAME "Flycolor HV3"
#define DEAD_TIME 80
Expand Down Expand Up @@ -928,7 +927,8 @@
#define SIXTY_FOUR_KB_MEMORY
#endif

/********************************** F031 Targets ***********************************/
/********************************** F031 Targets
* ***********************************/

#ifdef REF_F031
#define FILE_NAME "REF_F031"
Expand All @@ -945,7 +945,8 @@
#define VOLTAGE_ADC_CHANNEL LL_ADC_CHANNEL_7
#endif

/********************************** defaults if not set ***************************/
/********************************** defaults if not set
* ***************************/

#ifndef TARGET_VOLTAGE_DIVIDER
#define TARGET_VOLTAGE_DIVIDER 110
Expand Down Expand Up @@ -979,7 +980,8 @@
#define RAMP_SPEED_HIGH_RPM 40
#endif

/************************************ F051 Hardware Groups ****************************/
/************************************ F051 Hardware Groups
* ****************************/

#ifdef HARDWARE_GROUP_F0_A

Expand Down Expand Up @@ -1222,7 +1224,6 @@

#endif


#ifdef HARDWARE_GROUP_F0_U

#define MCU_F051
Expand Down Expand Up @@ -1253,12 +1254,12 @@

#endif

#ifdef HARDWARE_GROUP_F0_045 // tried B
#ifdef HARDWARE_GROUP_F0_045 // tried B
#define PHASE_A_COMP COMP_PA0 // pa0 // works for polling mode
#define PHASE_B_COMP COMP_PA4 // pa4
#define PHASE_C_COMP COMP_PA5 // pa5
#endif
#ifdef HARDWARE_GROUP_F0_504 // tried F
#ifdef HARDWARE_GROUP_F0_504 // tried F
#define PHASE_A_COMP COMP_PA5 // pa5 // works for polling mode
#define PHASE_B_COMP COMP_PA0 // pa0
#define PHASE_C_COMP COMP_PA4 // pa4
Expand All @@ -1278,14 +1279,14 @@
#define PHASE_B_COMP COMP_PA0 // pa0
#define PHASE_C_COMP COMP_PA5 // pa5
#endif
#ifdef HARDWARE_GROUP_F0_540 // tried H
#ifdef HARDWARE_GROUP_F0_540 // tried H
#define PHASE_A_COMP COMP_PA5 // pa5 // works for polling mode
#define PHASE_B_COMP COMP_PA4 // pa4
#define PHASE_C_COMP COMP_PA0 // pa0
#endif


/************************************* G071 Hardware Groups **********************************/
/************************************* G071 Hardware Groups
* **********************************/

#ifdef HARDWARE_GROUP_G0_A

Expand Down Expand Up @@ -1682,9 +1683,9 @@
#define PHASE_C_GPIO_HIGH LL_GPIO_PIN_8
#define PHASE_C_GPIO_PORT_HIGH GPIOA

#define PHASE_A_COMP LL_COMP_INPUT_MINUS_IO1 //
#define PHASE_B_COMP LL_COMP_INPUT_MINUS_IO1 //
#define PHASE_C_COMP LL_COMP_INPUT_MINUS_IO2 //
#define PHASE_A_COMP LL_COMP_INPUT_MINUS_IO1 //
#define PHASE_B_COMP LL_COMP_INPUT_MINUS_IO1 //
#define PHASE_C_COMP LL_COMP_INPUT_MINUS_IO2 //

#define PHASE_A_EXTI_LINE LL_EXTI_LINE_22
#define PHASE_A_COMP_NUMBER COMP2
Expand All @@ -1703,7 +1704,8 @@

#endif

/************************************ G031 Hardware Groups ************************************************/
/************************************ G031 Hardware Groups
* ************************************************/

#ifdef HARDWARE_GROUP_F031_A

Expand Down Expand Up @@ -2015,7 +2017,7 @@

#define MCU_AT421
#define USE_TIMER_15_CHANNEL_1
//#define USE_PA14_TELEMETRY
// #define USE_PA14_TELEMETRY
#define USE_PA6_TEMP
#define INPUT_PIN GPIO_PINS_2
#define INPUT_PIN_SOURCE GPIO_PINS_SOURCE2
Expand Down Expand Up @@ -2122,7 +2124,8 @@
#define PHASE_C_COMP 0x400000D1 // pa5
#endif

/************************************ MCU COMMON PERIPHERALS **********************************************/
/************************************ MCU COMMON PERIPHERALS
* **********************************************/

#ifdef MCU_F051
#define STMICRO
Expand Down Expand Up @@ -2202,8 +2205,6 @@
#define COM_TIMER_IRQ TIM14_IRQn
#endif



#ifdef MCU_G431
#define STMICRO
#define CPU_FREQUENCY_MHZ 150
Expand All @@ -2218,24 +2219,23 @@
#define EXTI_LINE LL_EXTI_LINE_22
#define TARGET_MIN_BEMF_COUNTS 3
#define COMPARATOR_IRQ COMP1_2_3_IRQn
//#define USE_ADC
//#ifndef CURRENT_ADC_CHANNEL
//#define CURRENT_ADC_CHANNEL LL_ADC_CHANNEL_5
//#endif
//#ifndef VOLTAGE_ADC_CHANNEL
//#define VOLTAGE_ADC_CHANNEL LL_ADC_CHANNEL_6
//#endif
//#ifndef CURRENT_ADC_PIN
//#define CURRENT_ADC_PIN LL_GPIO_PIN_5
//#endif
//#ifndef VOLTAGE_ADC_PIN
//#define VOLTAGE_ADC_PIN LL_GPIO_PIN_6
//#endif
// #define USE_ADC
// #ifndef CURRENT_ADC_CHANNEL
// #define CURRENT_ADC_CHANNEL LL_ADC_CHANNEL_5
// #endif
// #ifndef VOLTAGE_ADC_CHANNEL
// #define VOLTAGE_ADC_CHANNEL LL_ADC_CHANNEL_6
// #endif
// #ifndef CURRENT_ADC_PIN
// #define CURRENT_ADC_PIN LL_GPIO_PIN_5
// #endif
// #ifndef VOLTAGE_ADC_PIN
// #define VOLTAGE_ADC_PIN LL_GPIO_PIN_6
// #endif
#define DSHOT_PRIORITY_THRESHOLD 60
#define COM_TIMER_IRQ TIM1_UP_TIM16_IRQn
#endif


#ifdef MCU_GDE23
#define GIGADEVICES
#define CPU_FREQUENCY_MHZ 72
Expand Down
17 changes: 4 additions & 13 deletions Mcu/e230/Src/IO.c
Original file line number Diff line number Diff line change
Expand Up @@ -36,8 +36,7 @@ void receiveDshotDma()
TIMER_DMAINTEN(IC_TIMER_REGISTER) |= (uint32_t)TIMER_DMA_CH0D;
TIMER_CHCTL2(IC_TIMER_REGISTER) |= (uint32_t)TIMER_CCX_ENABLE;
TIMER_CTL0(IC_TIMER_REGISTER) |= (uint32_t)TIMER_CTL0_CEN;
DMA_CHCTL(INPUT_DMA_CHANNEL)
= 0x0000098b; // just set the whole reg in one go to enable
DMA_CHCTL(INPUT_DMA_CHANNEL) = 0x0000098b; // just set the whole reg in one go to enable
}

void sendDshotDma()
Expand All @@ -51,20 +50,15 @@ void sendDshotDma()
out_put = 1;
TIMER_SWEVG(IC_TIMER_REGISTER) |= (uint32_t)TIMER_EVENT_SRC_UPG;
DMA_CHMADDR(INPUT_DMA_CHANNEL) = (uint32_t)&gcr;
DMA_CHCNT(INPUT_DMA_CHANNEL)
= ((23 + buffer_padding) & DMA_CHANNEL_CNT_MASK);
DMA_CHCNT(INPUT_DMA_CHANNEL) = ((23 + buffer_padding) & DMA_CHANNEL_CNT_MASK);
DMA_CHCTL(INPUT_DMA_CHANNEL) = 0x0000099b;
TIMER_DMAINTEN(IC_TIMER_REGISTER) |= (uint32_t)TIMER_DMA_CH0D;
TIMER_CHCTL2(IC_TIMER_REGISTER) |= (uint32_t)TIMER_CCX_ENABLE;
TIMER_CCHP(IC_TIMER_REGISTER) |= (uint32_t)TIMER_CCHP_POEN;
TIMER_CTL0(IC_TIMER_REGISTER) |= (uint32_t)TIMER_CTL0_CEN;
}

uint8_t
getInputPinState()
{
return GPIO_ISTAT(INPUT_PIN_PORT) & (INPUT_PIN);
}
uint8_t getInputPinState() { return GPIO_ISTAT(INPUT_PIN_PORT) & (INPUT_PIN); }

void setInputPolarityRising()
{
Expand All @@ -81,10 +75,7 @@ void setInputPullUp()
gpio_mode_set(GPIOB, GPIO_MODE_AF, GPIO_PUPD_PULLUP, INPUT_PIN);
}

void enableHalfTransferInt()
{
DMA_CHCTL(INPUT_DMA_CHANNEL) |= DMA_INT_HTF;
}
void enableHalfTransferInt() { DMA_CHCTL(INPUT_DMA_CHANNEL) |= DMA_INT_HTF; }
void setInputPullNone()
{
gpio_mode_set(GPIOB, GPIO_MODE_AF, GPIO_PUPD_NONE, INPUT_PIN);
Expand Down
6 changes: 1 addition & 5 deletions Mcu/e230/Src/comparator.c
Original file line number Diff line number Diff line change
Expand Up @@ -9,11 +9,7 @@

#include "targets.h"

uint8_t
getCompOutputLevel()
{
return cmp_output_level_get();
}
uint8_t getCompOutputLevel() { return cmp_output_level_get(); }

void maskPhaseInterrupts()
{
Expand Down
3 changes: 1 addition & 2 deletions Mcu/e230/Src/eeprom.c
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,7 @@ void save_flash_nolib(uint8_t* data, int length, uint32_t add)
uint32_t data_to_FLASH[length / 4];
memset(data_to_FLASH, 0, length / 4);
for (int i = 0; i < length / 4; i++) {
data_to_FLASH[i] = data[i * 4 + 3] << 24 | data[i * 4 + 2] << 16
| data[i * 4 + 1] << 8 | data[i * 4]; // make 16 bit
data_to_FLASH[i] = data[i * 4 + 3] << 24 | data[i * 4 + 2] << 16 | data[i * 4 + 1] << 8 | data[i * 4]; // make 16 bit
}
volatile uint32_t data_length = length / 4;

Expand Down
Loading

0 comments on commit cd3af91

Please sign in to comment.