From cb86bb7e5100081521167d78e67a7d12c3c79429 Mon Sep 17 00:00:00 2001 From: Roman Belov Date: Fri, 16 Feb 2024 22:16:07 +0300 Subject: [PATCH] Renamed VESC hardware files, enabled USB debug logging. --- doc/HardwareVESC.md | 24 +++---- phobia/phobia.c | 3 - src/cherry/usb_config.h | 2 +- src/epcan.c | 6 +- src/hal/hw/FSESC67.h | 86 ++++++++++++++++++++++++++ src/hal/hw/{VESC6B.h => FSESC67PRO.h} | 2 +- src/hal/hw/{VESC75A.h => FSESC75100.h} | 0 src/hal/hw/{VESC6H.h => HBESC6FOC.h} | 0 src/hal/hw/{VESC6A.h => MKESC60100.h} | 3 +- src/hal/hw/{VESC6C.h => VESC6MK5.h} | 2 +- src/hal/hw/{VESC75C.h => VESC75300.h} | 0 src/hal/mk/{VESC6A.d => FSESC67.d} | 0 src/hal/mk/{VESC6B.d => FSESC67PRO.d} | 0 src/hal/mk/{VESC75A.d => FSESC75100.d} | 0 src/hal/mk/{VESC6H.d => HBESC6FOC.d} | 0 src/hal/mk/{VESC6C.d => MKESC60100.d} | 0 src/hal/mk/VESC6MK5.d | 7 +++ src/hal/mk/{VESC75C.d => VESC75300.d} | 0 src/hal/usb.c | 2 +- 19 files changed, 113 insertions(+), 24 deletions(-) create mode 100644 src/hal/hw/FSESC67.h rename src/hal/hw/{VESC6B.h => FSESC67PRO.h} (97%) rename src/hal/hw/{VESC75A.h => FSESC75100.h} (100%) rename src/hal/hw/{VESC6H.h => HBESC6FOC.h} (100%) rename src/hal/hw/{VESC6A.h => MKESC60100.h} (97%) rename src/hal/hw/{VESC6C.h => VESC6MK5.h} (98%) rename src/hal/hw/{VESC75C.h => VESC75300.h} (100%) rename src/hal/mk/{VESC6A.d => FSESC67.d} (100%) rename src/hal/mk/{VESC6B.d => FSESC67PRO.d} (100%) rename src/hal/mk/{VESC75A.d => FSESC75100.d} (100%) rename src/hal/mk/{VESC6H.d => HBESC6FOC.d} (100%) rename src/hal/mk/{VESC6C.d => MKESC60100.d} (100%) create mode 100644 src/hal/mk/VESC6MK5.d rename src/hal/mk/{VESC75C.d => VESC75300.d} (100%) diff --git a/doc/HardwareVESC.md b/doc/HardwareVESC.md index a4db2f5..0f81302 100644 --- a/doc/HardwareVESC.md +++ b/doc/HardwareVESC.md @@ -4,16 +4,16 @@ This page gives you an overview of VESC hardware supported by PMC. ## Hardware -| Item | HWREV | Notes | -|:--------------------------------------|:---------:|:------------------| -| FLIPSKY FSESC 6.7 | VESC6A | Bad PCB design | -| Makerbase VESC 60100 V2 | VESC6A | | -| FLIPSKY MINI FSESC 6.7 PRO | VESC6B | Low side shunts | -| VESC 6 MkVI | VESC6C | | -| Holybro Mini FOC ESC Based on VESC6 | VESC6H | | -| FLIPSKY 75100 V202 ESC | VESC75A | Low side shunts | -| Makerbase VESC 75200 V2 84V 200A | VESC75A | Low side shunts | -| VESC 75/300 R3 | VESC75C | | +| Item | HWREV | Notes | +|:--------------------------------------|:-----------:|:------------------| +| FLIPSKY FSESC 6.7 | FSESC67 | Bad PCB design | +| FLIPSKY MINI FSESC 6.7 PRO | FSESC67PRO | Low side shunts | +| FLIPSKY 75100 V202 ESC | FSESC75100 | Low side shunts | +| Makerbase VESC 75200 V2 84V 200A | FSESC75100 | Low side shunts | +| Holybro Mini FOC ESC Based on VESC6 | HBESC6FOC | | +| Makerbase VESC 60100 V2 | MKESC60100 | | +| VESC 6 MkVI | VESC6MK5 | | +| VESC 75/300 R3 | VESC75300 | | Note that some of VESC clone have bad PCB design that causes distorted current measurement and total malfunction at high load. Also prefer to use PCB with @@ -26,12 +26,12 @@ You can build the firmware binary yourself from sources or get it from the bundle release. $ cd phobia/src - $ make HWREV=VESC6A + $ make HWREV=MKESC60100 To load the firmware into the MCU first time you will need SWD probe. Next time to upgrade the firmware you can use USB DFU or serial bootloader. - $ make HWREV=VESC6A stlink + $ make HWREV=MKESC60100 stlink Also check [GettingStarted](GettingStarted.md) page howto build and load the firmware to MCU. diff --git a/phobia/phobia.c b/phobia/phobia.c index 228ad85..963485c 100644 --- a/phobia/phobia.c +++ b/phobia/phobia.c @@ -4562,9 +4562,6 @@ page_lu_eabi(struct public *pub) static void page_lu_sincos(struct public *pub) { - struct nk_sdl *nk = pub->nk; - struct nk_context *ctx = &nk->ctx; - /* TODO */ } diff --git a/src/cherry/usb_config.h b/src/cherry/usb_config.h index a8e0a62..8e530e8 100644 --- a/src/cherry/usb_config.h +++ b/src/cherry/usb_config.h @@ -13,7 +13,7 @@ #endif #ifndef CONFIG_USB_DBG_LEVEL -#define CONFIG_USB_DBG_LEVEL -1 +#define CONFIG_USB_DBG_LEVEL USB_DBG_ERROR #endif #ifndef CONFIG_USB_ALIGN_SIZE diff --git a/src/epcan.c b/src/epcan.c index 6b758ef..b40ebc4 100644 --- a/src/epcan.c +++ b/src/epcan.c @@ -676,8 +676,8 @@ LD_TASK void task_EPCAN_TX(void *pData) EPCAN_send_msg(&msg); - /* Do not send messages too frequently especially if - * you were asked to. + /* Do not send messages too frequently + * especially if you were asked to. * */ if (local.flow_tx_paused != 0) { @@ -719,7 +719,7 @@ void EPCAN_startup() local.tx_queue = xQueueCreate(80, sizeof(char)); local.remote_queue = xQueueCreate(40, sizeof(char)); local.log_queue = xQueueCreate(320, sizeof(char)); - local.net_queue = xQueueCreate(1, sizeof(int)); + local.net_queue = xQueueCreate(10, sizeof(int)); /* Allocate semaphore. * */ diff --git a/src/hal/hw/FSESC67.h b/src/hal/hw/FSESC67.h new file mode 100644 index 0000000..4a02469 --- /dev/null +++ b/src/hal/hw/FSESC67.h @@ -0,0 +1,86 @@ +#define HW_MCU_STM32F405 + +/* Tested on FLIPSKY FSESC 6.7 + * */ + +#define HW_HAVE_DRV_ON_PCB +#define HW_HAVE_ANALOG_KNOB +#define HW_HAVE_BRAKE_KNOB +#define HW_HAVE_STEP_DIR_KNOB +#define HW_HAVE_NTC_ON_PCB +#define HW_HAVE_NTC_MACHINE +#define HW_HAVE_USB_CDC_ACM +#define HW_HAVE_NETWORK_EPCAN + +#define HW_CLOCK_CRYSTAL_HZ 8000000U + +#define HW_PWM_FREQUENCY_HZ 28571.f +#define HW_PWM_DEADTIME_NS 400.f /* NVMFS5C612NL */ + +#define HW_PWM_MINIMAL_PULSE 0.4f +#define HW_PWM_CLEARANCE_ZONE 9.0f +#define HW_PWM_SKIP_ZONE 2.0f +#define HW_PWM_BOOTSTRAP_RETENTION 100.f /* DRV8301 */ + +#define HW_DRV_ID_ON_PCB BUS_ID_SPI3 + +#define HW_DRV_PARTNO DRV_PART_DRV8301 +#define HW_DRV_GATE_CURRENT 2 +#define HW_DRV_OCP_LEVEL 32 + +#define HW_ADC_SAMPLING_SEQUENCE ADC_SEQUENCE__ABC_UTT_TXX + +#define HW_ADC_REFERENCE_VOLTAGE 3.3f +#define HW_ADC_SHUNT_RESISTANCE 0.0005f +#define HW_ADC_AMPLIFIER_GAIN 20.f /* AD8418 */ + +#define HW_ADC_VOLTAGE_R1 39000.f +#define HW_ADC_VOLTAGE_R2 2200.f +#define HW_ADC_VOLTAGE_R3 1000000000000.f /* have no bias */ + +#define HW_ADC_KNOB_R1 0.f /* have no */ +#define HW_ADC_KNOB_R2 1000.f + +#define HW_NTC_PCB_TYPE NTC_VCC +#define HW_NTC_PCB_BALANCE 10000.f +#define HW_NTC_PCB_NTC0 10000.f +#define HW_NTC_PCB_TA0 25.f +#define HW_NTC_PCB_BETTA 3380.f /* unknown part */ + +#define HW_NTC_EXT_BALANCE 10000.f + +#define GPIO_ADC_CURRENT_A XGPIO_DEF3('C', 0, 10) +#define GPIO_ADC_CURRENT_B XGPIO_DEF3('C', 1, 11) +#define GPIO_ADC_CURRENT_C XGPIO_DEF3('C', 2, 12) +#define GPIO_ADC_VOLTAGE_U XGPIO_DEF3('C', 3, 13) +#define GPIO_ADC_VOLTAGE_A XGPIO_DEF3('A', 0, 0) +#define GPIO_ADC_VOLTAGE_B XGPIO_DEF3('A', 1, 1) +#define GPIO_ADC_VOLTAGE_C XGPIO_DEF3('A', 2, 2) +#define GPIO_ADC_NTC_PCB XGPIO_DEF3('A', 3, 3) +#define GPIO_ADC_NTC_EXT XGPIO_DEF3('C', 4, 14) +#define GPIO_ADC_KNOB_ANG XGPIO_DEF3('A', 5, 5) +#define GPIO_ADC_KNOB_BRK XGPIO_DEF3('A', 6, 6) + +#define GPIO_STEP XGPIO_DEF2('A', 5) +#define GPIO_DIR XGPIO_DEF2('A', 6) + +#define GPIO_DRV_GATE_EN XGPIO_DEF2('B', 5) +#define GPIO_DRV_FAULT XGPIO_DEF2('B', 7) + +#define GPIO_SPI3_NSS XGPIO_DEF2('C', 9) +#define GPIO_SPI3_SCK XGPIO_DEF4('C', 10, 0, 6) +#define GPIO_SPI3_MISO XGPIO_DEF4('C', 11, 0, 6) +#define GPIO_SPI3_MOSI XGPIO_DEF4('C', 12, 0, 6) + +#define GPIO_USART3_TX XGPIO_DEF4('B', 10, 0, 7) +#define GPIO_USART3_RX XGPIO_DEF4('B', 11, 0, 7) + +#define GPIO_OTG_FS_DM XGPIO_DEF4('A', 11, 0, 10) +#define GPIO_OTG_FS_DP XGPIO_DEF4('A', 12, 0, 10) + +#define GPIO_CAN_RX XGPIO_DEF4('B', 8, 0, 9) +#define GPIO_CAN_TX XGPIO_DEF4('B', 9, 0, 9) + +#define GPIO_LED_ALERT XGPIO_DEF2('B', 1) +#define GPIO_LED_MODE XGPIO_DEF2('B', 0) + diff --git a/src/hal/hw/VESC6B.h b/src/hal/hw/FSESC67PRO.h similarity index 97% rename from src/hal/hw/VESC6B.h rename to src/hal/hw/FSESC67PRO.h index 0a6e95c..4d774ad 100644 --- a/src/hal/hw/VESC6B.h +++ b/src/hal/hw/FSESC67PRO.h @@ -16,7 +16,7 @@ #define HW_CLOCK_CRYSTAL_HZ 8000000U #define HW_PWM_FREQUENCY_HZ 28571.f -#define HW_PWM_DEADTIME_NS 330.f /* NVMFS5C612NL */ +#define HW_PWM_DEADTIME_NS 400.f /* NVMFS5C612NL */ #define HW_PWM_MINIMAL_PULSE 0.4f #define HW_PWM_CLEARANCE_ZONE 5.0f diff --git a/src/hal/hw/VESC75A.h b/src/hal/hw/FSESC75100.h similarity index 100% rename from src/hal/hw/VESC75A.h rename to src/hal/hw/FSESC75100.h diff --git a/src/hal/hw/VESC6H.h b/src/hal/hw/HBESC6FOC.h similarity index 100% rename from src/hal/hw/VESC6H.h rename to src/hal/hw/HBESC6FOC.h diff --git a/src/hal/hw/VESC6A.h b/src/hal/hw/MKESC60100.h similarity index 97% rename from src/hal/hw/VESC6A.h rename to src/hal/hw/MKESC60100.h index ddfb842..b629abb 100644 --- a/src/hal/hw/VESC6A.h +++ b/src/hal/hw/MKESC60100.h @@ -1,7 +1,6 @@ #define HW_MCU_STM32F405 -/* Tested on FLIPSKY FSESC 6.7 - * Tested on Makerbase VESC 60100 V2 +/* Tested on Makerbase VESC 60100 V2 * */ #define HW_HAVE_DRV_ON_PCB diff --git a/src/hal/hw/VESC6C.h b/src/hal/hw/VESC6MK5.h similarity index 98% rename from src/hal/hw/VESC6C.h rename to src/hal/hw/VESC6MK5.h index 8cc78a9..446a1b8 100644 --- a/src/hal/hw/VESC6C.h +++ b/src/hal/hw/VESC6MK5.h @@ -15,7 +15,7 @@ #define HW_CLOCK_CRYSTAL_HZ 8000000U #define HW_PWM_FREQUENCY_HZ 28571.f -#define HW_PWM_DEADTIME_NS 330.f /* IRF7749 */ +#define HW_PWM_DEADTIME_NS 400.f /* IRF7749 */ #define HW_PWM_MINIMAL_PULSE 0.4f #define HW_PWM_CLEARANCE_ZONE 5.0f diff --git a/src/hal/hw/VESC75C.h b/src/hal/hw/VESC75300.h similarity index 100% rename from src/hal/hw/VESC75C.h rename to src/hal/hw/VESC75300.h diff --git a/src/hal/mk/VESC6A.d b/src/hal/mk/FSESC67.d similarity index 100% rename from src/hal/mk/VESC6A.d rename to src/hal/mk/FSESC67.d diff --git a/src/hal/mk/VESC6B.d b/src/hal/mk/FSESC67PRO.d similarity index 100% rename from src/hal/mk/VESC6B.d rename to src/hal/mk/FSESC67PRO.d diff --git a/src/hal/mk/VESC75A.d b/src/hal/mk/FSESC75100.d similarity index 100% rename from src/hal/mk/VESC75A.d rename to src/hal/mk/FSESC75100.d diff --git a/src/hal/mk/VESC6H.d b/src/hal/mk/HBESC6FOC.d similarity index 100% rename from src/hal/mk/VESC6H.d rename to src/hal/mk/HBESC6FOC.d diff --git a/src/hal/mk/VESC6C.d b/src/hal/mk/MKESC60100.d similarity index 100% rename from src/hal/mk/VESC6C.d rename to src/hal/mk/MKESC60100.d diff --git a/src/hal/mk/VESC6MK5.d b/src/hal/mk/VESC6MK5.d new file mode 100644 index 0000000..103d7ee --- /dev/null +++ b/src/hal/mk/VESC6MK5.d @@ -0,0 +1,7 @@ +HWMCU = STM32F405 +OBJ_HAL_DRV = 1 +OBJ_HAL_STEP = 1 +OBJ_CHERRY = 1 +OBJ_HAL_USB = 1 +OBJ_EPCAN = 1 +OBJ_HAL_CAN = 1 diff --git a/src/hal/mk/VESC75C.d b/src/hal/mk/VESC75300.d similarity index 100% rename from src/hal/mk/VESC75C.d rename to src/hal/mk/VESC75300.d diff --git a/src/hal/usb.c b/src/hal/usb.c index b43c923..7179c1c 100644 --- a/src/hal/usb.c +++ b/src/hal/usb.c @@ -266,7 +266,7 @@ void USB_putc(int c) if (xQueueSendToBack(priv_USB.tx_queue, &xbyte, (TickType_t) 100) != pdTRUE) { - log_TRACE("USB queue reset" EOL); + log_TRACE("USB queue overflow" EOL); xQueueReset(priv_USB.tx_queue); }