Skip to content

Commit

Permalink
Merge pull request #414 from simplefoc/408-feature-support-for-arduin…
Browse files Browse the repository at this point in the history
…o-esp32-v301-current_sensing

408 feature support for arduino esp32 v301 current sensing
  • Loading branch information
askuric authored Jun 23, 2024
2 parents 3c3e9c8 + a734d0d commit 538e59d
Show file tree
Hide file tree
Showing 30 changed files with 1,650 additions and 1,830 deletions.
5 changes: 5 additions & 0 deletions .github/workflows/esp32.yml
Original file line number Diff line number Diff line change
Expand Up @@ -19,6 +19,7 @@ jobs:
- esp32:esp32:esp32doit-devkit-v1 # esp32
- esp32:esp32:esp32s2 # esp32s2
- esp32:esp32:esp32s3 # esp32s3
- esp32:esp32:esp32c3 # esp32c3

include:

Expand All @@ -30,6 +31,10 @@ jobs:
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
sketch-names: esp32_position_control.ino, esp32_i2c_dual_bus_example.ino

- arduino-boards-fqbn: esp32:esp32:esp32c3 # esp32c3
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
sketch-names: esp32_position_control.ino, esp32_i2c_dual_bus_example.ino, stepper_driver_2pwm_standalone.ino, stepper_driver_4pwm_standalone.ino

- arduino-boards-fqbn: esp32:esp32:esp32doit-devkit-v1 # esp32
platform-url: https://espressif.github.io/arduino-esp32/package_esp32_index.json
sketch-names: esp32_position_control.ino, esp32_i2c_dual_bus_example.ino, esp32_current_control_low_side.ino, esp32_spi_alt_example.ino
Expand Down
15 changes: 15 additions & 0 deletions src/communication/SimpleFOCDebug.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -38,6 +38,7 @@ void SimpleFOCDebug::println(const __FlashStringHelper* str) {
}
}


void SimpleFOCDebug::println(const char* str, float val) {
if (_debugPrint != NULL) {
_debugPrint->print(str);
Expand Down Expand Up @@ -86,6 +87,20 @@ void SimpleFOCDebug::print(const __FlashStringHelper* str) {
}
}

void SimpleFOCDebug::print(const StringSumHelper str) {
if (_debugPrint != NULL) {
_debugPrint->print(str.c_str());
}
}


void SimpleFOCDebug::println(const StringSumHelper str) {
if (_debugPrint != NULL) {
_debugPrint->println(str.c_str());
}
}



void SimpleFOCDebug::print(int val) {
if (_debugPrint != NULL) {
Expand Down
4 changes: 3 additions & 1 deletion src/communication/SimpleFOCDebug.h
Original file line number Diff line number Diff line change
Expand Up @@ -33,13 +33,14 @@
**/


#ifndef SIMPLEFOC_DISABLE_DEBUG
#ifndef SIMPLEFOC_DISABLE_DEBUG

class SimpleFOCDebug {
public:
static void enable(Print* debugPrint = &Serial);

static void println(const __FlashStringHelper* msg);
static void println(const StringSumHelper msg);
static void println(const char* msg);
static void println(const __FlashStringHelper* msg, float val);
static void println(const char* msg, float val);
Expand All @@ -52,6 +53,7 @@ class SimpleFOCDebug {

static void print(const char* msg);
static void print(const __FlashStringHelper* msg);
static void print(const StringSumHelper msg);
static void print(int val);
static void print(float val);

Expand Down
3 changes: 2 additions & 1 deletion src/current_sense/LowsideCurrentSense.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -47,7 +47,8 @@ int LowsideCurrentSense::init(){
// if init failed return fail
if (params == SIMPLEFOC_CURRENT_SENSE_INIT_FAILED) return 0;
// sync the driver
_driverSyncLowSide(driver->params, params);
void* r = _driverSyncLowSide(driver->params, params);
if(r == SIMPLEFOC_CURRENT_SENSE_INIT_FAILED) return 0;
// calibrate zero offsets
calibrateOffsets();
// set the initialized flag
Expand Down
5 changes: 4 additions & 1 deletion src/current_sense/hardware_api.h
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,10 @@ float _readADCVoltageLowSide(const int pinA, const void* cs_params);
* function syncing the Driver with the ADC for the LowSide Sensing
* @param driver_params - driver parameter structure - hardware specific
* @param cs_params - current sense parameter structure - hardware specific
*
* @return void* - returns the pointer to the current sense parameter structure (unchanged)
* - returns SIMPLEFOC_CURRENT_SENSE_INIT_FAILED if the init fails
*/
void _driverSyncLowSide(void* driver_params, void* cs_params);
void* _driverSyncLowSide(void* driver_params, void* cs_params);

#endif
Loading

0 comments on commit 538e59d

Please sign in to comment.