SimpleFOClibrary 2.4.0
Loading...
Searching...
No Matches
current_sense/hardware_specific/stm32/stm32_mcu.h
Go to the documentation of this file.
1
2#ifndef STM32_CURRENTSENSE_MCU_DEF
3#define STM32_CURRENTSENSE_MCU_DEF
4#include "../../hardware_api.h"
5#include "../../../common/foc_utils.h"
6#include "../../../drivers/hardware_specific/stm32/stm32_mcu.h"
7#include "../../../drivers/hardware_specific/stm32/stm32_timerutils.h"
8
9#if defined(_STM32_DEF_)
10
11// generic implementation of the hardware specific structure
12// containing all the necessary current sense parameters
13// will be returned as a void pointer from the _configureADCx functions
14// will be provided to the _readADCVoltageX() as a void pointer
15typedef struct Stm32CurrentSenseParams {
16 int pins[3] = {(int)NOT_SET};
17 float adc_voltage_conv;
18 ADC_HandleTypeDef* adc_handle = NP;
19 TIM_HandleTypeDef* timer_handle = NP;
20} Stm32CurrentSenseParams;
21
22
23/**
24 * Read a regular ADC channel while injected channels are running for current sensing.
25 * Injected conversions have hardware priority and will pre-empt regular conversions.
26 *
27 * This funciton performs a one-shot regular conversion on either on the same ADC as the one
28 * used for injected current sensing, or on another ADC if the pin belongs to a different ADC.
29 * The funciton will initialize the ADC for regular conversion if not already initialized.
30 *
31 * NOTE:
32 * The low-side current sensing code already initializes the ADC for injected conversions and regullar conversions
33 * so if the same ADC is used for regular reading, no re-configuration is needed.
34 *
35 * NOTE:
36 * This function will be relatively slow >10us in comparision to the injected reading.
37 * But it is much better than analogRead though.
38 *
39 * @param pin - the Arduino pin to be read (must be an ADC pin on the same ADC)
40 * @return float - the voltage read from the pin, or -1.0f on error
41 */
42float _readRegularADCVoltage(const int pin);
43
44#endif
45#endif
return raw_adc *GenericCurrentSenseParams *cs_params adc_voltage_conv
#define NOT_SET
Definition foc_utils.h:34