Skip to content

Commit

Permalink
add header file for real
Browse files Browse the repository at this point in the history
  • Loading branch information
mcells committed Feb 12, 2024
1 parent cbe9fd0 commit cee79a9
Showing 1 changed file with 27 additions and 0 deletions.
27 changes: 27 additions & 0 deletions src/current_sense/hardware_specific/esp32/esp32_i2s_driver.h
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 */

0 comments on commit cee79a9

Please sign in to comment.