include ../AeroFox-PMU/hwdef.inc

# SERIAL
SERIAL_ORDER USART1 EMPTY USART3

# ESC 
PB10  USART3_TX USART3 SPEED_HIGH
PB11  USART3_RX USART3 SPEED_HIGH

# USART2
#PA2 USART2_TX USART2 SPEED_HIGH
#PA3 USART2_RX USART2 SPEED_HIGH

# DEBUG 
PB6  USART1_TX USART1 SPEED_HIGH
PB7  USART1_RX USART1 SPEED_HIGH

# BATTERY
define HAL_PERIPH_ENABLE_BATTERY

define HAL_USE_ADC TRUE
define STM32_ADC_USE_ADC1 TRUE

PB0 BATT_VOLTAGE_SENS  ADC1 SCALE(1)
PB1 BATT_CURRENT_SENS  ADC1 SCALE(1)

define HAL_BATT_MONITOR_DEFAULT  0
define HAL_BATT_VOLT_PIN 5
define HAL_BATT_VOLT_SCALE 21.0
define HAL_BATT_CURR_PIN 6
define HAL_BATT_CURR_SCALE 40.0

#PWM
PA8   TIM1_CH1  TIM1 PWM(1) GPIO(50)
PA9   TIM1_CH2  TIM1 PWM(2) GPIO(51)
PA10  TIM1_CH3  TIM1 PWM(3) GPIO(52)
PA11  TIM1_CH4  TIM1 PWM(4) GPIO(53)
PA15  TIM2_CH1  TIM2 PWM(5) GPIO(54)
PA2   TIM2_CH3  TIM2 PWM(6) GPIO(55)
PA3   TIM2_CH4  TIM2 PWM(7) GPIO(56)
PA1   TIM2_CH2  TIM2 PWM(8) GPIO(57)
PA6   TIM16_CH1 TIM16  PWM(9)  GPIO(58) NODMA

define HAL_PERIPH_ENABLE_RC_OUT
define HAL_PERIPH_ENABLE_NOTIFY

# enable ESC control
define HAL_SUPPORT_RCOUT_SERIAL 1
define HAL_WITH_ESC_TELEM 1

#GPIO LED
define HAL_HAVE_PIXRACER_LED 
PB2 LED_RED OUTPUT OPENDRAIN HIGH GPIO(0) 
PB4 LED_GREEN OUTPUT OPENDRAIN LOW GPIO(1) 
PB5 LED_BLUE OUTPUT OPENDRAIN LOW GPIO(2) 
define HAL_GPIO_A_LED_PIN 0 
define HAL_GPIO_B_LED_PIN 1 
define HAL_GPIO_C_LED_PIN 2 
define HAL_GPIO_LED_ON 0 
define HAL_GPIO_LED_OFF 1