SimpleFOClibrary 2.4.0
Loading...
Searching...
No Matches
esp32_mcu.h
Go to the documentation of this file.
1#ifndef ESP32_MCU_CURRENT_SENSING_H
2#define ESP32_MCU_CURRENT_SENSING_H
3
4#include "../../hardware_api.h"
5
6#if defined(ESP_H) && defined(ARDUINO_ARCH_ESP32)
7
8
9#include "../../../drivers/hardware_api.h"
10#include "esp32_adc_driver.h"
11
12
13// esp32 current sense parameters
14typedef struct ESP32CurrentSenseParams {
15 int pins[3];
16 float adc_voltage_conv;
17 int adc_buffer[3] = {};
18 int buffer_index = 0;
19 int no_adc_channels = 0;
20 void* pretrig_comparator = nullptr; // MCPWM comparator handle for ADC pre-trigger
21} ESP32CurrentSenseParams;
22
23// macros for debugging wuing the simplefoc debug system
24#ifndef SIMPLEFOC_DISABLE_DEBUG
25#define SIMPLEFOC_ESP32_CS_DEBUG(str)\
26 SimpleFOCDebug::println( "ESP32-CS: "+ String(str));
27#else
28#define SIMPLEFOC_ESP32_CS_DEBUG(str)
29#endif
30
31
32#define CHECK_CS_ERR(func_call, message) \
33 if ((func_call) != ESP_OK) { \
34 SIMPLEFOC_ESP32_CS_DEBUG("ERROR - " + String(message)); \
35 return SIMPLEFOC_CURRENT_SENSE_INIT_FAILED; \
36 }
37
38
39#define _ADC_VOLTAGE 3.3f
40#define _ADC_RESOLUTION 4095.0f
41
42#endif // ESP_H && ARDUINO_ARCH_ESP32
43#endif
return raw_adc *GenericCurrentSenseParams *cs_params adc_voltage_conv