mirror of https://github.com/rusefi/bldc.git
Added 60_mk6 hw
This commit is contained in:
parent
9862fa0347
commit
3c2d330283
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2012-2020 Benjamin Vedder benjamin@vedder.se
|
||||
Copyright 2012-2022 Benjamin Vedder benjamin@vedder.se
|
||||
|
||||
This program is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
|
@ -28,7 +28,7 @@
|
|||
|
||||
// Variables
|
||||
static volatile bool i2c_running = false;
|
||||
#if defined(HW60_IS_MK3) || defined(HW60_IS_MK4) || defined(HW60_IS_MK5)
|
||||
#if defined(HW60_IS_MK3) || defined(HW60_IS_MK4) || defined(HW60_IS_MK5) || defined(HW60_IS_MK6)
|
||||
static mutex_t shutdown_mutex;
|
||||
static float bt_diff = 0.0;
|
||||
#endif
|
||||
|
@ -40,13 +40,13 @@ static const I2CConfig i2cfg = {
|
|||
STD_DUTY_CYCLE
|
||||
};
|
||||
|
||||
#if defined(HW60_IS_MK3) || defined(HW60_IS_MK4) || defined(HW60_IS_MK5)
|
||||
#if defined(HW60_IS_MK3) || defined(HW60_IS_MK4) || defined(HW60_IS_MK5) || defined(HW60_IS_MK6)
|
||||
static void terminal_shutdown_now(int argc, const char **argv);
|
||||
static void terminal_button_test(int argc, const char **argv);
|
||||
#endif
|
||||
|
||||
void hw_init_gpio(void) {
|
||||
#if defined(HW60_IS_MK3) || defined(HW60_IS_MK4) || defined(HW60_IS_MK5)
|
||||
#if defined(HW60_IS_MK3) || defined(HW60_IS_MK4) || defined(HW60_IS_MK5) || defined(HW60_IS_MK6)
|
||||
chMtxObjectInit(&shutdown_mutex);
|
||||
#endif
|
||||
|
||||
|
@ -118,6 +118,13 @@ void hw_init_gpio(void) {
|
|||
PHASE_FILTER_OFF();
|
||||
#endif
|
||||
|
||||
// Sensor port voltage
|
||||
#if defined(HW60_IS_MK6)
|
||||
SENSOR_PORT_3V3();
|
||||
palSetPadMode(SENSOR_VOLTAGE_GPIO, SENSOR_VOLTAGE_PIN,
|
||||
PAL_MODE_OUTPUT_PUSHPULL | PAL_STM32_OSPEED_HIGHEST);
|
||||
#endif
|
||||
|
||||
// Fault pin
|
||||
palSetPadMode(GPIOB, 7, PAL_MODE_INPUT_PULLUP);
|
||||
|
||||
|
@ -134,13 +141,13 @@ void hw_init_gpio(void) {
|
|||
palSetPadMode(GPIOC, 2, PAL_MODE_INPUT_ANALOG);
|
||||
palSetPadMode(GPIOC, 3, PAL_MODE_INPUT_ANALOG);
|
||||
palSetPadMode(GPIOC, 4, PAL_MODE_INPUT_ANALOG);
|
||||
#if !defined(HW60_IS_MK3) && !defined(HW60_IS_MK4) && !defined(HW60_IS_MK5)
|
||||
#if !defined(HW60_IS_MK3) && !defined(HW60_IS_MK4) && !defined(HW60_IS_MK5) && !defined(HW60_IS_MK6)
|
||||
palSetPadMode(GPIOC, 5, PAL_MODE_INPUT_ANALOG);
|
||||
#endif
|
||||
|
||||
drv8301_init();
|
||||
|
||||
#if defined(HW60_IS_MK3) || defined(HW60_IS_MK4) || defined(HW60_IS_MK5)
|
||||
#if defined(HW60_IS_MK3) || defined(HW60_IS_MK4) || defined(HW60_IS_MK5) || defined(HW60_IS_MK6)
|
||||
terminal_register_command_callback(
|
||||
"shutdown",
|
||||
"Shutdown VESC now.",
|
||||
|
@ -292,7 +299,7 @@ void hw_try_restore_i2c(void) {
|
|||
}
|
||||
}
|
||||
|
||||
#if defined(HW60_IS_MK3) || defined(HW60_IS_MK4) || defined(HW60_IS_MK5)
|
||||
#if defined(HW60_IS_MK3) || defined(HW60_IS_MK4) || defined(HW60_IS_MK5) || defined(HW60_IS_MK6)
|
||||
bool hw_sample_shutdown_button(void) {
|
||||
chMtxLock(&shutdown_mutex);
|
||||
|
||||
|
|
|
@ -1,5 +1,5 @@
|
|||
/*
|
||||
Copyright 2016 - 2020 Benjamin Vedder benjamin@vedder.se
|
||||
Copyright 2016 - 2022 Benjamin Vedder benjamin@vedder.se
|
||||
|
||||
This file is part of the VESC firmware.
|
||||
|
||||
|
@ -26,6 +26,8 @@
|
|||
#define HW_NAME "60_MK4"
|
||||
#elif defined(HW60_IS_MK5)
|
||||
#define HW_NAME "60_MK5"
|
||||
#elif defined(HW60_IS_MK6)
|
||||
#define HW_NAME "60_MK6"
|
||||
#elif defined(HW60_IS_MK1)
|
||||
#define HW_NAME "60"
|
||||
#else
|
||||
|
@ -39,7 +41,7 @@
|
|||
#define HW_HAS_DRV8301
|
||||
#define HW_HAS_3_SHUNTS
|
||||
#define HW_HAS_PHASE_SHUNTS
|
||||
#if !defined(HW60_IS_MK3) && !defined(HW60_IS_MK4) && !defined(HW60_IS_MK5)
|
||||
#if !defined(HW60_IS_MK3) && !defined(HW60_IS_MK4) && !defined(HW60_IS_MK5) && !defined(HW60_IS_MK6)
|
||||
#define HW_HAS_PERMANENT_NRF
|
||||
#endif
|
||||
|
||||
|
@ -63,7 +65,7 @@
|
|||
#define CURRENT_FILTER_ON() palSetPad(GPIOD, 2)
|
||||
#define CURRENT_FILTER_OFF() palClearPad(GPIOD, 2)
|
||||
|
||||
#ifdef HW60_IS_MK5
|
||||
#if defined(HW60_IS_MK5) || defined(HW60_IS_MK6)
|
||||
#define HW_HAS_PHASE_FILTERS
|
||||
#define PHASE_FILTER_GPIO GPIOC
|
||||
#define PHASE_FILTER_PIN 13
|
||||
|
@ -71,7 +73,15 @@
|
|||
#define PHASE_FILTER_OFF() palClearPad(PHASE_FILTER_GPIO, PHASE_FILTER_PIN)
|
||||
#endif
|
||||
|
||||
#if defined(HW60_IS_MK3) || defined(HW60_IS_MK4) || defined(HW60_IS_MK5)
|
||||
// Sensor port voltage control
|
||||
#if defined(HW60_IS_MK6)
|
||||
#define SENSOR_VOLTAGE_GPIO GPIOA
|
||||
#define SENSOR_VOLTAGE_PIN 4
|
||||
#define SENSOR_PORT_5V() palSetPad(SENSOR_VOLTAGE_GPIO, SENSOR_VOLTAGE_PIN)
|
||||
#define SENSOR_PORT_3V3() palClearPad(SENSOR_VOLTAGE_GPIO, SENSOR_VOLTAGE_PIN)
|
||||
#endif
|
||||
|
||||
#if defined(HW60_IS_MK3) || defined(HW60_IS_MK4) || defined(HW60_IS_MK5) || defined(HW60_IS_MK6)
|
||||
// Shutdown pin
|
||||
#define HW_SHUTDOWN_GPIO GPIOC
|
||||
#define HW_SHUTDOWN_PIN 5
|
||||
|
@ -135,7 +145,7 @@
|
|||
#define ADC_IND_TEMP_MOS 8
|
||||
#define ADC_IND_TEMP_MOTOR 9
|
||||
#define ADC_IND_VREFINT 12
|
||||
#if defined(HW60_IS_MK3) || defined(HW60_IS_MK4) || defined(HW60_IS_MK5)
|
||||
#if defined(HW60_IS_MK3) || defined(HW60_IS_MK4) || defined(HW60_IS_MK5) || defined(HW60_IS_MK6)
|
||||
#define ADC_IND_SHUTDOWN 10
|
||||
#endif
|
||||
|
||||
|
@ -228,7 +238,7 @@
|
|||
#define HW_UART_RX_PORT GPIOB
|
||||
#define HW_UART_RX_PIN 11
|
||||
|
||||
#if defined(HW60_IS_MK3) || defined(HW60_IS_MK4) || defined(HW60_IS_MK5)
|
||||
#if defined(HW60_IS_MK3) || defined(HW60_IS_MK4) || defined(HW60_IS_MK5) || defined(HW60_IS_MK6)
|
||||
// Permanent UART Peripheral (for NRF51)
|
||||
#define HW_UART_P_BAUD 115200
|
||||
#define HW_UART_P_DEV SD4
|
||||
|
@ -276,7 +286,7 @@
|
|||
#define HW_ENC_TIM_ISR_CH TIM3_IRQn
|
||||
#define HW_ENC_TIM_ISR_VEC TIM3_IRQHandler
|
||||
|
||||
#if !defined(HW60_IS_MK3) && !defined(HW60_IS_MK4) && !defined(HW60_IS_MK5)
|
||||
#if !defined(HW60_IS_MK3) && !defined(HW60_IS_MK4) && !defined(HW60_IS_MK5) || defined(HW60_IS_MK6)
|
||||
// NRF pins
|
||||
#define NRF_PORT_CSN GPIOB
|
||||
#define NRF_PIN_CSN 12
|
||||
|
@ -289,7 +299,7 @@
|
|||
#endif
|
||||
|
||||
// SPI pins
|
||||
#if !defined(HW60_IS_MK5)
|
||||
#if !defined(HW60_IS_MK5) && !defined(HW60_IS_MK6)
|
||||
#define HW_SPI_DEV SPID1
|
||||
#define HW_SPI_GPIO_AF GPIO_AF_SPI1
|
||||
#define HW_SPI_PORT_NSS GPIOA
|
||||
|
@ -314,7 +324,7 @@
|
|||
#endif
|
||||
|
||||
// SPI for DRV8301
|
||||
#if !defined(HW60_IS_MK3) && !defined(HW60_IS_MK4) && !defined(HW60_IS_MK5)
|
||||
#if !defined(HW60_IS_MK3) && !defined(HW60_IS_MK4) && !defined(HW60_IS_MK5) && !defined(HW60_IS_MK6)
|
||||
#define DRV8301_MOSI_GPIO GPIOC
|
||||
#define DRV8301_MOSI_PIN 12
|
||||
#define DRV8301_MISO_GPIO GPIOC
|
||||
|
@ -335,12 +345,23 @@
|
|||
#endif
|
||||
|
||||
// MPU9250
|
||||
#if !defined(HW60_IS_MK4) && !defined(HW60_IS_MK5)
|
||||
#if !defined(HW60_IS_MK4) && !defined(HW60_IS_MK5) && !defined(HW60_IS_MK6)
|
||||
#define MPU9X50_SDA_GPIO GPIOB
|
||||
#define MPU9X50_SDA_PIN 2
|
||||
#define MPU9X50_SCL_GPIO GPIOA
|
||||
#define MPU9X50_SCL_PIN 15
|
||||
#define IMU_FLIP
|
||||
#elif defined(HW60_IS_MK6)
|
||||
#define BMI160_SPI_PORT_NSS GPIOA
|
||||
#define BMI160_SPI_PIN_NSS 15
|
||||
#define BMI160_SPI_PORT_SCK GPIOC
|
||||
#define BMI160_SPI_PIN_SCK 15
|
||||
#define BMI160_SPI_PORT_MOSI GPIOB
|
||||
#define BMI160_SPI_PIN_MOSI 2
|
||||
#define BMI160_SPI_PORT_MISO GPIOB
|
||||
#define BMI160_SPI_PIN_MISO 12
|
||||
#define IMU_FLIP
|
||||
#define IMU_ROT_180
|
||||
#else
|
||||
#define BMI160_SDA_GPIO GPIOB
|
||||
#define BMI160_SDA_PIN 2
|
||||
|
@ -391,7 +412,7 @@
|
|||
#define HW_LIM_TEMP_FET -40.0, 110.0
|
||||
|
||||
// Functions
|
||||
#if defined(HW60_IS_MK3) || defined(HW60_IS_MK4) || defined(HW60_IS_MK5)
|
||||
#if defined(HW60_IS_MK3) || defined(HW60_IS_MK4) || defined(HW60_IS_MK5) || defined(HW60_IS_MK6)
|
||||
bool hw_sample_shutdown_button(void);
|
||||
#endif
|
||||
|
||||
|
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
Copyright 2016 - 2022 Benjamin Vedder benjamin@vedder.se
|
||||
|
||||
This file is part of the VESC firmware.
|
||||
|
||||
The VESC firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The VESC firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef HW_60_MK5_H_
|
||||
#define HW_60_MK5_H_
|
||||
|
||||
#define HW60_IS_MK6
|
||||
|
||||
#include "hw_60_core.h"
|
||||
|
||||
#endif /* HW_60_MK5_H_ */
|
|
@ -0,0 +1,27 @@
|
|||
/*
|
||||
Copyright 2016 - 2022 Benjamin Vedder benjamin@vedder.se
|
||||
|
||||
This file is part of the VESC firmware.
|
||||
|
||||
The VESC firmware is free software: you can redistribute it and/or modify
|
||||
it under the terms of the GNU General Public License as published by
|
||||
the Free Software Foundation, either version 3 of the License, or
|
||||
(at your option) any later version.
|
||||
|
||||
The VESC firmware is distributed in the hope that it will be useful,
|
||||
but WITHOUT ANY WARRANTY; without even the implied warranty of
|
||||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
||||
GNU General Public License for more details.
|
||||
|
||||
You should have received a copy of the GNU General Public License
|
||||
along with this program. If not, see <http://www.gnu.org/licenses/>.
|
||||
*/
|
||||
|
||||
#ifndef HW_60_MK5_NO_LIMITS_H_
|
||||
#define HW_60_MK5_NO_LIMITS_H_
|
||||
|
||||
#define DISABLE_HW_LIMITS
|
||||
|
||||
#include "hw_60_mk6.h"
|
||||
|
||||
#endif /* HW_60_MK5_NO_LIMITS_H_ */
|
|
@ -35,6 +35,8 @@ package_dict["60_MK4"] = [['60_mk4', default_name],
|
|||
['60_mk4_no_limits', no_limits_name]]
|
||||
package_dict["60_MK5"] = [['60_mk5', default_name],
|
||||
['60_mk5_no_limits', no_limits_name]]
|
||||
package_dict["60_MK6"] = [['60_mk6', default_name],
|
||||
['60_mk6_no_limits', no_limits_name]]
|
||||
package_dict["DAS_RS"] = [['das_rs', default_name]]
|
||||
package_dict["75_300"] = [['75_300', default_name],
|
||||
['75_300_no_limits', no_limits_name]]
|
||||
|
|
Loading…
Reference in New Issue