Skip to content

ARK 12S CAN ESC#36

Draft
AlexKlimaj wants to merge 7 commits into
ark-releasefrom
feat/12s-can-esc
Draft

ARK 12S CAN ESC#36
AlexKlimaj wants to merge 7 commits into
ark-releasefrom
feat/12s-can-esc

Conversation

@AlexKlimaj

Copy link
Copy Markdown
Member

Summary

Rebased from AlexKlimaj:jake/12s-can-esc (upstream am32-firmware/AM32#340) onto ark-release.

Adds the ARK_G431_CAN target for the ARK 12S CAN ESC:

  • Target definition with DroneCAN, current sense, RGB LED, HSE clock, and CAN termination pin
  • Configurable FDCAN1 TX/RX pins (ARK routes TX to PB9)
  • Configurable ADC GPIO ports for voltage (PB11) and current (PC3)
  • Input capture on TIM16_CH1 (PB4); commutation moved to TIM7
  • Current-sense ADC sequencer length / DMA size fixes
  • Dead time set to 90

Related

Test plan

  • Build ARK_G431_CAN target
  • Flash and verify DroneCAN enumeration
  • Verify voltage/current telemetry
  • Verify DShot input on PB4 / TIM16
  • Verify motor spin / commutation
  • Confirm other G431 targets still build (TIM15 path unchanged)

AlexKlimaj and others added 7 commits July 16, 2026 09:55
Update firmware definitions and add RGB LED control functions for G431

Add CAN termination pin definitions and setup function for GPIO control

Make FDCAN1 TX/RX pins configurable for ARK CAN ESC

The ARK CAN ESC routes FDCAN1_TX to PB9 instead of PA12 used by all
other G431 DroneCAN targets. Add CAN_TX_PIN/PORT and CAN_RX_PIN/PORT
defines with defaults matching existing PA11/PA12 behavior, and set
the ARK target to use PB9 for TX.

Make ADC GPIO ports configurable for ARK CAN ESC

The ARK CAN ESC has voltage on PB11 (GPIOB) and current on PC3 (GPIOC),
unlike other G431 targets which use GPIOA for both. Add VOLTAGE_ADC_PORT
and CURRENT_ADC_PORT defines with GPIOA defaults, and use them in
ADC_Init() instead of the hardcoded GPIOA.

Enable current sensing for ARK CAN ESC
Add USE_CURRENT_SENSE to the target definition so the ADC scan sequence
includes the current channel. Fix the ADC sequencer length to 3 ranks
when USE_CURRENT_SENSE is defined, and set DMA transfer length to match.
Without this, only temperature and voltage were scanned, and current
telemetry would report garbage.

Switch ARK CAN ESC input capture to TIM16_CH1 on PB4

The ARK CAN ESC routes MTR_INPUT to PB4, which cannot be TIM15_CH1
(only PA2 supports that). PB4 AF1 = TIM16_CH1, so switch the G4_E
hardware group to USE_TIMER_16_CHANNEL_1.

Since TIM16 was the commutation timer (COM_TIMER) for all G431
targets, reassign COM_TIMER to TIM7 for the ARK target using the
existing #ifndef override pattern. Add MX_TIM7_Init() and
TIM7_IRQHandler for commutation, and wrap the existing TIM15/TIM16
init paths with appropriate #ifdefs.

Existing G431 targets are unaffected — they continue using TIM15 for
input capture and TIM16 as COM_TIMER.

Add CURRENT_OFFSET definition for improved current sensing accuracy

Refactor timer reset logic for Dshot DMA functions to improve clarity and maintainability

Add EEPROM_START_ADD definition for EEPROM memory management

Add RAMP_SPEED definitions and RAMP_DIVIDER macro for improved RPM control

dead time 65
Co-authored-by: Jacob Dahl <37091262+dakejahl@users.noreply.github.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant