Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Backport 2.16: Add ARK 4IN1 #119

Closed
Closed
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
24 changes: 24 additions & 0 deletions Inc/targets.h
Original file line number Diff line number Diff line change
Expand Up @@ -1180,6 +1180,28 @@
#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
#define TARGET_MIN_BEMF_COUNTS 3
#endif

#ifdef RHINO80A_F051
#define FILE_NAME "RHINO80A_F051"
#define FIRMWARE_NAME "RHINO80A_F0 "
Expand Down Expand Up @@ -3151,7 +3173,9 @@
#define APPLICATION_ADDRESS 0x08001000
#define MAIN_COMP COMP1
#define EXTI_LINE LL_EXTI_LINE_21
#ifndef TARGET_MIN_BEMF_COUNTS
#define TARGET_MIN_BEMF_COUNTS 2
#endif
#define COMPARATOR_IRQ ADC1_COMP_IRQn
#define USE_ADC
#ifndef CURRENT_ADC_PIN
Expand Down
37 changes: 37 additions & 0 deletions Mcu/f051/Src/peripherals.c
Original file line number Diff line number Diff line change
Expand Up @@ -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);
Expand Down Expand Up @@ -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);
Expand Down
Loading