1234567891011121314151617181920212223242526272829303132333435363738394041 |
- #ifndef __BOARD_H
- #define __BOARD_H
- /* MACROs for SET, RESET or TOGGLE Output port */
- #define GPIO_HIGH(a,b) a->ODR |= b
- #define GPIO_LOW(a,b) a->ODR &= ~b
- #define GPIO_TOGGLE(a,b) a->ODR ^= b
- /* ADC */
- #define ADC_PORTU GPIOD
- #define ADC_PINU GPIO_PIN_3
- #define ADC_CHNLU ADC1_CHANNEL_4
- #define ADC_SCHTU (uint8_t)ADC1_SCHMITTTRIG_CHANNEL4
- #define ADC_PORTI GPIOC
- #define ADC_PINI GPIO_PIN_4
- #define ADC_CHNLI ADC1_CHANNEL_2
- #define ADC_SCHTI (uint8_t)ADC1_SCHMITTTRIG_CHANNEL2
- #define ADC_SMPLS 64
- // Supply voltage in mili volts
- #define ADC_VREF 3333UL
- // Сопротивление резисторов делителя входного напряжения, кОм/100
- #define VOLTAGE_MULT_TOP 383UL
- #define VOLTAGE_MULT_BOT 100UL
- #define VOLT_MUL_MUL 1000UL
- #define VOLTAGE_MUL_DIV (1024UL * VOLTAGE_MULT_BOT)
- #define VOLTAGE_MUL (uint32_t)((VOLT_MUL_MUL * ADC_VREF * (VOLTAGE_MULT_TOP+VOLTAGE_MULT_BOT)) / VOLTAGE_MUL_DIV)
- // shunt resistance in Ohms
- #define CURRENT_SHUNT (1/0.01)
- // Сопротивление резисторов ОУ усилителя сигнала шунта, кОм/100
- #define CURRENT_MULT_TOP 180UL
- #define CURRENT_MULT_BOT 12UL
- #define CURR_MUL_MUL 1000UL
- #define CURRENT_MUL_DIV (1024UL * (CURRENT_MULT_TOP + CURRENT_MULT_BOT))
- #define CURRENT_MUL (uint32_t)(((CURR_MUL_MUL * ADC_VREF * CURRENT_SHUNT * CURRENT_MULT_BOT)) / CURRENT_MUL_DIV)
- // Current commutator
- #define SWITCH_PORT GPIOD
- #define SWITCH_PIN GPIO_PIN_6
- #define SWITCH_ON SWITCH_PORT->ODR |= SWITCH_PIN
- #define SWITCH_OFF SWITCH_PORT->ODR &= ~SWITCH_PIN
- #endif /* __BOARD_H */
|