29 #define ENABLE_GATE() palSetPad(GPIOC, 10)
30 #define DISABLE_GATE() palClearPad(GPIOC, 10)
31 #define DCCAL_ON() palSetPad(GPIOB, 12)
32 #define DCCAL_OFF() palClearPad(GPIOB, 12)
33 #define IS_DRV_FAULT() (!palReadPad(GPIOC, 12))
35 #define LED_GREEN_ON() palSetPad(GPIOC, 4)
36 #define LED_GREEN_OFF() palClearPad(GPIOC, 4)
37 #define LED_RED_ON() palSetPad(GPIOA, 7)
38 #define LED_RED_OFF() palClearPad(GPIOA, 7)
57 #define HW_ADC_CHANNELS 12
58 #define HW_ADC_NBR_CONV 4
61 #define ADC_IND_SENS1 2
62 #define ADC_IND_SENS2 1
63 #define ADC_IND_SENS3 0
64 #define ADC_IND_CURR1 4
65 #define ADC_IND_CURR2 3
66 #define ADC_IND_VIN_SENS 8
67 #define ADC_IND_EXT 10
68 #define ADC_IND_VREFINT 6
77 #define VIN_R1 33000.0
82 #ifndef CURRENT_AMP_GAIN
83 #define CURRENT_AMP_GAIN 10.0
85 #ifndef CURRENT_SHUNT_RES
86 #define CURRENT_SHUNT_RES 0.001
90 #define GET_INPUT_VOLTAGE() ((V_REG / 4095.0) * (float)ADC_Value[ADC_IND_VIN_SENS] * ((VIN_R1 + VIN_R2) / VIN_R2))
93 #define ADC_VOLTS(ch) ((float)ADC_Value[ch] / 4095.0 * V_REG)
96 #define NTC_RES(adc_val) (0.0)
97 #define NTC_TEMP(adc_ind) hw45_get_temp()
101 #ifndef CURR1_DOUBLE_SAMPLE
102 #define CURR1_DOUBLE_SAMPLE 1
104 #ifndef CURR2_DOUBLE_SAMPLE
105 #define CURR2_DOUBLE_SAMPLE 0
109 #define HW_SERVO_NUM 2
112 #define HW_UART_DEV UARTD6
113 #define HW_UART_GPIO_AF GPIO_AF_USART6
114 #define HW_UART_TX_PORT GPIOC
115 #define HW_UART_TX_PIN 6
116 #define HW_UART_RX_PORT GPIOC
117 #define HW_UART_RX_PIN 7
120 #define HW_ICU_CHANNEL ICU_CHANNEL_2
121 #define HW_ICU_GPIO_AF GPIO_AF_TIM3
122 #define HW_ICU_GPIO GPIOB
126 #define HW_I2C_DEV I2CD2
127 #define HW_I2C_GPIO_AF GPIO_AF_I2C2
128 #define HW_I2C_SCL_PORT GPIOB
129 #define HW_I2C_SCL_PIN 10
130 #define HW_I2C_SDA_PORT GPIOB
131 #define HW_I2C_SDA_PIN 11
134 #define HW_HALL_ENC_GPIO1 GPIOB
135 #define HW_HALL_ENC_PIN1 6
136 #define HW_HALL_ENC_GPIO2 GPIOB
137 #define HW_HALL_ENC_PIN2 7
138 #define HW_HALL_ENC_GPIO3 GPIOC
139 #define HW_HALL_ENC_PIN3 11
140 #define HW_ENC_TIM TIM4
141 #define HW_ENC_TIM_AF GPIO_AF_TIM4
142 #define HW_ENC_TIM_CLK_EN() RCC_APB1PeriphClockCmd(RCC_APB1Periph_TIM4, ENABLE)
143 #define HW_ENC_EXTI_PORTSRC EXTI_PortSourceGPIOC
144 #define HW_ENC_EXTI_PINSRC EXTI_PinSource11
145 #define HW_ENC_EXTI_CH EXTI15_10_IRQn
146 #define HW_ENC_EXTI_LINE EXTI_Line11
147 #define HW_ENC_EXTI_ISR_VEC EXTI15_10_IRQHandler
150 #define NRF_PORT_CSN HW_ICU_GPIO
151 #define NRF_PIN_CSN HW_ICU_PIN
152 #define NRF_PORT_SCK GPIOC
153 #define NRF_PIN_SCK 5
154 #define NRF_PORT_MOSI HW_I2C_SDA_PORT
155 #define NRF_PIN_MOSI HW_I2C_SDA_PIN
156 #define NRF_PORT_MISO HW_I2C_SCL_PORT
157 #define NRF_PIN_MISO HW_I2C_SCL_PIN
160 #define ADC_V_L1 ADC_Value[ADC_IND_SENS1]
161 #define ADC_V_L2 ADC_Value[ADC_IND_SENS2]
162 #define ADC_V_L3 ADC_Value[ADC_IND_SENS3]
163 #define ADC_V_ZERO (ADC_Value[ADC_IND_VIN_SENS] / 2)
166 #define READ_HALL1() palReadPad(HW_HALL_ENC_GPIO1, HW_HALL_ENC_PIN1)
167 #define READ_HALL2() palReadPad(HW_HALL_ENC_GPIO2, HW_HALL_ENC_PIN2)
168 #define READ_HALL3() palReadPad(HW_HALL_ENC_GPIO3, HW_HALL_ENC_PIN3)
float hw45_get_temp(void)