diff --git a/Inc/targets.h b/Inc/targets.h index 6563a122..1d5516a0 100644 --- a/Inc/targets.h +++ b/Inc/targets.h @@ -1169,6 +1169,27 @@ #define TARGET_STALL_PROTECTION_INTERVAL 9000 #endif +#ifdef ARK_4IN1_F051 +#define FILE_NAME "ARK_4IN1_F051" +#define FIRMWARE_NAME "ARK 4IN1" +#define DEAD_TIME 45 +#define HARDWARE_GROUP_F0_B +#define MILLIVOLT_PER_AMP 10 +#define CURRENT_OFFSET 25 // millivolts +#define TARGET_VOLTAGE_DIVIDER 210 +#define VOLTAGE_ADC_CHANNEL LL_ADC_CHANNEL_6 +#define VOLTAGE_ADC_PIN LL_GPIO_PIN_6 +#define CURRENT_ADC_CHANNEL LL_ADC_CHANNEL_3 +#define CURRENT_ADC_PIN LL_GPIO_PIN_3 +#define USE_SERIAL_TELEMETRY +#define USE_DRV8328_NSLEEP +#define NSLEEP_PORT GPIOA +#define NSLEEP_PIN LL_GPIO_PIN_15 +#define USE_DRV8328_NFAULT +#define NFAULT_PORT GPIOB +#define NFAULT_PIN LL_GPIO_PIN_5 +#endif + #ifdef RHINO80A_F051 #define FILE_NAME "RHINO80A_F051" #define FIRMWARE_NAME "RHINO80A_F0 " diff --git a/Mcu/f051/Src/peripherals.c b/Mcu/f051/Src/peripherals.c index fb3fd66d..f0ec5ad7 100644 --- a/Mcu/f051/Src/peripherals.c +++ b/Mcu/f051/Src/peripherals.c @@ -495,6 +495,31 @@ void initLed() } #endif +#ifdef USE_DRV8328_NSLEEP // Disable gate driver when disarmed +void initnSleep() +{ + LL_GPIO_InitTypeDef GPIO_InitStruct = { 0 }; + GPIO_InitStruct.Pin = NSLEEP_PIN; + GPIO_InitStruct.Mode = LL_GPIO_MODE_OUTPUT; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_HIGH; + GPIO_InitStruct.Pull = LL_GPIO_PULL_NO; + LL_GPIO_Init(NSLEEP_PORT, &GPIO_InitStruct); + NSLEEP_PORT->BSRR = NSLEEP_PIN; +} +#endif + +#ifdef USE_DRV8328_NFAULT +void initnFault() +{ + LL_GPIO_InitTypeDef GPIO_InitStruct = { 0 }; + GPIO_InitStruct.Pin = NFAULT_PIN; + GPIO_InitStruct.Mode = LL_GPIO_MODE_INPUT; + GPIO_InitStruct.Speed = LL_GPIO_SPEED_FREQ_LOW; + GPIO_InitStruct.Pull = LL_GPIO_PULL_UP; + LL_GPIO_Init(NFAULT_PORT, &GPIO_InitStruct); +} +#endif + void reloadWatchDogCounter() { LL_IWDG_ReloadCounter(IWDG); @@ -585,6 +610,18 @@ void enableCorePeripherals() initLed(); #endif +#ifdef USE_DRV8328_NSLEEP + initnSleep(); +#endif + +#ifdef USE_DRV8328_NFAULT + initnFault(); +#endif + +#ifdef USE_DRVOFF + initDrvoff(); +#endif + #ifndef BRUSHED_MODE LL_TIM_EnableCounter(COM_TIMER); // commutation_timer priority 0 LL_TIM_GenerateEvent_UPDATE(COM_TIMER);