diff --git a/build_all/rebuild_all b/build_all/rebuild_all index 09a9aa31..b2b1bb9e 100755 --- a/build_all/rebuild_all +++ b/build_all/rebuild_all @@ -371,6 +371,25 @@ make -j8 build_args='-DDISABLE_HW_LIMITS -DHW_SOURCE=\"hw_stormcore_60d.c\" -DHW cd $DIR cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_default_no_hw_limits.bin +#################### STORMCORE_60D+ ######################## + +COPYDIR='STORMCORE_60D+' +rm -f $COPYDIR/* + +# default +cd $FWPATH +touch conf_general.h +make -j8 build_args='-DHW_SOURCE=\"hw_stormcore_60d.c\" -DHW_HEADER=\"hw_stormcore_60d.h\" -DHW_VER_IS_60D_PLUS' USE_VERBOSE_COMPILE=no +cd $DIR +cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_default.bin + +# default with HW limits disabled +cd $FWPATH +touch conf_general.h +make -j8 build_args='-DDISABLE_HW_LIMITS -DHW_SOURCE=\"hw_stormcore_60d.c\" -DHW_HEADER=\"hw_stormcore_60d.h\" -DHW_VER_IS_60D_PLUS' USE_VERBOSE_COMPILE=no +cd $DIR +cp $FWPATH/build/BLDC_4_ChibiOS.bin $COPYDIR/VESC_default_no_hw_limits.bin + #################### STORMCORE_100D ######################## COPYDIR=STORMCORE_100D diff --git a/conf_general.h b/conf_general.h index 1ac8b0a7..4f337e85 100644 --- a/conf_general.h +++ b/conf_general.h @@ -148,6 +148,7 @@ //#define HW_SOURCE "hw_stormcore_100d.c" //#define HW_HEADER "hw_stormcore_100d.h" +//#define HW_VER_IS_60D_PLUS //#define HW_SOURCE "hw_stormcore_60d.c" //#define HW_HEADER "hw_stormcore_60d.h" diff --git a/hwconf/hw_stormcore_60d.c b/hwconf/hw_stormcore_60d.c index 79ac74d9..09fd5a86 100644 --- a/hwconf/hw_stormcore_60d.c +++ b/hwconf/hw_stormcore_60d.c @@ -61,6 +61,18 @@ void hw_init_gpio(void) { RCC_AHB1PeriphClockCmd(RCC_AHB1Periph_GPIOE, ENABLE); +#ifdef HW_VER_IS_60D_PLUS + mc_interface_select_motor_thread(2); + palSetPadMode(PHASE_FILTER_GPIO, PHASE_FILTER_PIN, + PAL_MODE_OUTPUT_PUSHPULL | + PAL_STM32_OSPEED_HIGHEST); + PHASE_FILTER_OFF(); + mc_interface_select_motor_thread(1); + palSetPadMode(PHASE_FILTER_GPIO, PHASE_FILTER_PIN, + PAL_MODE_OUTPUT_PUSHPULL | + PAL_STM32_OSPEED_HIGHEST); + PHASE_FILTER_OFF(); +#endif // LEDs diff --git a/hwconf/hw_stormcore_60d.h b/hwconf/hw_stormcore_60d.h index 38d5497b..bc02b39a 100644 --- a/hwconf/hw_stormcore_60d.h +++ b/hwconf/hw_stormcore_60d.h @@ -17,7 +17,11 @@ #ifndef HW_STORMCORE_60D_H_ #define HW_STORMCORE_60D_H_ +#ifdef HW_VER_IS_60D_PLUS +#define HW_NAME "STORMCORE_60D+" +#else #define HW_NAME "STORMCORE_60D" +#endif #define HW_HAS_DUAL_MOTORS #include "drv8323s.h" @@ -27,8 +31,8 @@ #define HW_HAS_3_SHUNTS #define DRV8323S_CUSTOM_SETTINGS(); drv8323s_set_current_amp_gain(CURRENT_AMP_GAIN); \ - drv8323s_write_reg(3,0x3af); \ - drv8323s_write_reg(4,0x7af); + drv8323s_write_reg(3,0x3af); \ + drv8323s_write_reg(4,0x7af); @@ -60,26 +64,34 @@ #define SMART_SWITCH_MSECS_PRESSED_OFF 2000 +#ifdef HW_VER_IS_60D_PLUS +// Depending on current motor selected for the thread select different phase filter +#define PHASE_FILTER_GPIO (mc_interface_motor_now() == 1 ? GPIOE : GPIOE) +#define PHASE_FILTER_PIN (mc_interface_motor_now() == 1 ? 4 : 1) +#define PHASE_FILTER_ON() palSetPad(PHASE_FILTER_GPIO, PHASE_FILTER_PIN) +#define PHASE_FILTER_OFF() palClearPad(PHASE_FILTER_GPIO, PHASE_FILTER_PIN) +#endif + #define HW_SHUTDOWN_HOLD_ON(); #define HW_SAMPLE_SHUTDOWN() 1 #define HW_SHUTDOWN_HOLD_OFF() palClearPad(SWITCH_OUT_GPIO, SWITCH_OUT_PIN); \ - palClearPad(SWITCH_PRECHARGED_GPIO, SWITCH_PRECHARGED_PIN); + palClearPad(SWITCH_PRECHARGED_GPIO, SWITCH_PRECHARGED_PIN); #define DCCAL_ON() //drv8323s_dccal_on() #define DCCAL_OFF() //drv8323s_dccal_off() #define HW_EARLY_INIT() smart_switch_pin_init(); \ - smart_switch_thread_start(); + smart_switch_thread_start(); //Pins for BLE UART -//#define USE_ALT_UART_PORT #define HW_UART_P_BAUD 115200 + #define HW_UART_P_DEV SD1 #define HW_UART_P_GPIO_AF GPIO_AF_USART1 #define HW_UART_P_TX_PORT GPIOA @@ -87,6 +99,18 @@ #define HW_UART_P_RX_PORT GPIOA #define HW_UART_P_RX_PIN 10 +#ifdef HW_VER_IS_60D_PLUS +//Pins for Third UART +#define HW_UART_3_BAUD 115200 +#define HW_UART_3_DEV SD2 +#define HW_UART_3_GPIO_AF GPIO_AF_USART2 +#define HW_UART_3_TX_PORT GPIOD +#define HW_UART_3_TX_PIN 6 +#define HW_UART_3_RX_PORT GPIOD +#define HW_UART_3_RX_PIN 5 +#endif + + // SPI for DRV8301 #define DRV8323S_MOSI_GPIO GPIOC #define DRV8323S_MOSI_PIN 12 @@ -217,12 +241,23 @@ #ifndef VIN_R2 #define VIN_R2 2200.0 #endif + +#ifdef HW_VER_IS_60D_PLUS #ifndef CURRENT_AMP_GAIN -#define CURRENT_AMP_GAIN 10.0 +#define CURRENT_AMP_GAIN 20.0 #endif #ifndef CURRENT_SHUNT_RES -#define CURRENT_SHUNT_RES 0.001 +#define CURRENT_SHUNT_RES 0.0005 #endif +#else +#ifndef CURRENT_AMP_GAIN +#define CURRENT_AMP_GAIN 10.0 +#endif +#ifndef CURRENT_SHUNT_RES +#define CURRENT_SHUNT_RES 0.001 +#endif +#endif + // Input voltage #define GET_INPUT_VOLTAGE() ((V_REG / 4095.0) * (float)ADC_Value[ADC_IND_VIN_SENS] * ((VIN_R1 + VIN_R2) / VIN_R2)) @@ -323,10 +358,20 @@ #define NRF_PIN_MISO 10 // NRF SWD -#define NRF5x_SWDIO_GPIO GPIOD -#define NRF5x_SWDIO_PIN 6 -#define NRF5x_SWCLK_GPIO GPIOD -#define NRF5x_SWCLK_PIN 5 + +#ifdef HW_VER_IS_60D_PLUS +#define NRF5x_SWDIO_GPIO GPIOD +#define NRF5x_SWDIO_PIN 9 +#define NRF5x_SWCLK_GPIO GPIOD +#define NRF5x_SWCLK_PIN 8 +#else +#define NRF5x_SWDIO_GPIO GPIOD +#define NRF5x_SWDIO_PIN 6 +#define NRF5x_SWCLK_GPIO GPIOD +#define NRF5x_SWCLK_PIN 5 +#endif + + #ifndef MCCONF_DEFAULT_MOTOR_TYPE #define MCCONF_DEFAULT_MOTOR_TYPE MOTOR_TYPE_FOC