forked from simplefoc/Arduino-FOC
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
1 changed file
with
27 additions
and
0 deletions.
There are no files selected for viewing
27 changes: 27 additions & 0 deletions
27
src/current_sense/hardware_specific/esp32/esp32_i2s_driver.h
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,27 @@ | ||
#ifndef SIMPLEFOC_ESP32_HAL_I2S_DRIVER_H_ | ||
#define SIMPLEFOC_ESP32_HAL_I2S_DRIVER_H_ | ||
|
||
#include "Arduino.h" | ||
|
||
#if defined(ESP_H) && defined(ARDUINO_ARCH_ESP32) && defined(SOC_MCPWM_SUPPORTED) | ||
|
||
// This function reads data from the I2S FIFO and processes it to obtain average readings for each channel. | ||
// The ADC counts get saved in uint32_t i2s_adc_buffer[]. | ||
static void IRAM_ATTR readFiFo(); | ||
|
||
static void IRAM_ATTR i2s_isr(void *arg); | ||
|
||
// Contrary to its name (so it can be called by the library), this function reads the already converted values from fifo | ||
// and prints optional debug information. | ||
// When using interrupt driven sampling, it only prints debug information. | ||
void IRAM_ATTR _startADC3PinConversionLowSide(); | ||
void IRAM_ATTR _startADC3PinConversionInline(); | ||
|
||
// Takes the buffered adc counts and returns the coresponding float voltage for a pin. | ||
float IRAM_ATTR _readADCVoltageI2S(const int pin, const void *cs_params); | ||
|
||
// Sets up the I2S peripheral and ADC. Can be run multiple times to configure multiple motors. | ||
void* IRAM_ATTR _configureI2S(const bool lowside, const void* driver_params, const int pinA, const int pinB, const int pinC); | ||
|
||
#endif /* SIMPLEFOC_ESP32_HAL_I2S_DRIVER_H_ */ | ||
#endif /* ESP32 */ |