text
stringlengths
1
24.5M
#pragma once // // FILE: weight.h // AUTHOR: Rob Tillaart // VERSION: 0.3.2 // PURPOSE: Collection weight conversion functions // URL: https://github.com/RobTillaart/weight #include "Arduino.h" #define WEIGHT_LIB_VERSION (F("0.3.2")) ///////////////////////////////////////////////////////////// // ...
// // FILE: unit_test_001.cpp // AUTHOR: Rob Tillaart // DATE: 2021-01-09 // PURPOSE: unit tests for the weight conversion functions // https://github.com/RobTillaart/weight // https://github.com/Arduino-CI/arduino_ci/blob/master/REFERENCE.md // // supported assertions // ---------------------...
// // FILE: X9C10X.cpp // AUTHOR: Rob Tillaart // VERSION: 0.2.4 // PURPOSE: Arduino Library for X9C10X series digital potentiometer. // DATE: 2022-01-26 // URL: https://github.com/RobTillaart/X9C10X #include "X9C10X.h" // minimum pulse width CLOCK = ? us (datasheet); // digitalWrite takes enough time ...
#pragma once // // FILE: X9C10X.h // AUTHOR: Rob Tillaart // VERSION: 0.2.4 // PURPOSE: Arduino Library for X9C10X series digital potentiometer. // DATE: 2022-01-26 // URL: https://github.com/RobTillaart/X9C10X #include "Arduino.h" #define X9C10X_LIB_VERSION (F("0.2.4")) /////////////////////////...
// // FILE: unit_test_001.cpp // AUTHOR: Rob Tillaart // DATE: 2022-02-11 // PURPOSE: unit tests for the X9C10X library // https://github.com/RobTillaart/X9C10X // https://github.com/Arduino-CI/arduino_ci/blob/master/REFERENCE.md // // supported assertions // https://github.com/Arduino-CI/ardu...
// // FILE: XMLWriter.cpp // AUTHOR: Rob Tillaart // VERSION: 0.4.0 // DATE: 2013-11-06 // PURPOSE: Arduino library for creating XML // URL: https://github.com/RobTillaart/XMLWriter #include "XMLWriter.h" XMLWriter::XMLWriter(Print* stream, uint8_t bufferSize) { _bufferSize = constrain(bufferSize, 2, 2...
#pragma once // // FILE: XMLWriter.h // AUTHOR: Rob Tillaart // VERSION: 0.4.0 // DATE: 2013-11-06 // PURPOSE: Arduino library for creating XML // URL: https://github.com/RobTillaart/XMLWriter #include "Arduino.h" #define XMLWRITER_VERSION (F("0.4.0")) // for comment() #define NOMULTILINE ...
// // FILE: unit_test_001.cpp // AUTHOR: Rob Tillaart // DATE: 2021-01-09 // PURPOSE: unit tests for the XMLWriter library // https://github.com/RobTillaart/XMLWriter // https://github.com/Arduino-CI/arduino_ci/blob/master/REFERENCE.md // // supported assertions // ----------------------------...
// Copyright (c) Sandeep Mistry. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. #ifndef CAN_H #define CAN_H #ifdef ARDUINO_ARCH_ESP32 #include "ESP32SJA1000.h" #else #include "MCP2515.h" #endif #endif
// Copyright (c) Sandeep Mistry. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. #include "CANController.h" CANControllerClass::CANControllerClass() : _onReceive(NULL), _packetBegun(false), _txId(-1), _txExtended(-1), _txRtr(false),...
// Copyright (c) Sandeep Mistry. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. #ifndef CAN_CONTROLLER_H #define CAN_CONTROLLER_H #include <Arduino.h> class CANControllerClass : public Stream { public: virtual int begin(long baudRate); ...
// Copyright (c) Sandeep Mistry. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. #ifdef ARDUINO_ARCH_ESP32 #include "esp_intr.h" #include "soc/dport_reg.h" #include "driver/gpio.h" #include "ESP32SJA1000.h" #define REG_BASE ...
// Copyright (c) Sandeep Mistry. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. #ifdef ARDUINO_ARCH_ESP32 #ifndef ESP32_SJA1000_H #define ESP32_SJA1000_H #include "CANController.h" #define DEFAULT_CAN_RX_PIN GPIO_NUM_4 #define DEFAULT_CAN_T...
// Copyright (c) Sandeep Mistry. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. #ifndef ARDUINO_ARCH_ESP32 #include "MCP2515.h" #define REG_BFPCTRL 0x0c #define REG_TXRTSCTRL 0x0d #define REG_CANCTRL ...
// Copyright (c) Sandeep Mistry. All rights reserved. // Licensed under the MIT license. See LICENSE file in the project root for full license information. #ifndef ARDUINO_ARCH_ESP32 #ifndef MCP2515_H #define MCP2515_H #include <SPI.h> #include "CANController.h" #define MCP2515_DEFAULT_CLOCK_FREQUENCY 16e6 #if de...
-DHAL_OPAMP_MODULE_ENABLED
#include "BLDCMotor.h" #include "./communication/SimpleFOCDebug.h" // see https://www.youtube.com/watch?v=InzXA7mWBWE Slide 5 // each is 60 degrees with values for 3 phases of 1=positive -1=negative 0=high-z int trap_120_map[6][3] = { {_HIGH_IMPEDANCE,1,-1}, {-1,1,_HIGH_IMPEDANCE}, {-1,_HIGH_IMPEDANCE,1},...
#ifndef BLDCMotor_h #define BLDCMotor_h #include "Arduino.h" #include "common/base_classes/FOCMotor.h" #include "common/base_classes/Sensor.h" #include "common/base_classes/FOCDriver.h" #include "common/base_classes/BLDCDriver.h" #include "common/foc_utils.h" #include "common/time_utils.h" #include "common/defaults.h"...
#include "HybridStepperMotor.h" #include "./communication/SimpleFOCDebug.h" // HybridStepperMotor(int pp) // - pp - pole pair number // - R - motor phase resistance // - KV - motor kv rating (rmp/v) // - L - motor phase inductance [H] HybridStepperMotor::HybridStepperMotor...
/** * @file HybridStepperMotor.h * */ #ifndef HybridStepperMotor_h #define HybridStepperMotor_h #include "Arduino.h" #include "common/base_classes/FOCMotor.h" #include "common/base_classes/StepperDriver.h" #include "common/base_classes/Sensor.h" #include "common/foc_utils.h" #include "common/time_utils.h" #includ...
/*! * @file SimpleFOC.h * * @mainpage Simple Field Oriented Control BLDC motor control library * * @section intro_sec Introduction * * Proper low-cost and low-power FOC supporting boards are very hard to find these days and even may not exist.<br> Even harder to find is a stable and simple FOC algorithm code cap...
#include "StepperMotor.h" #include "./communication/SimpleFOCDebug.h" // StepperMotor(int pp) // - pp - pole pair number // - R - motor phase resistance // - KV - motor kv rating (rmp/v) // - L - motor phase inductance [H] StepperMotor::StepperMotor(int pp, float _R, floa...
/** * @file StepperMotor.h * */ #ifndef StepperMotor_h #define StepperMotor_h #include "Arduino.h" #include "common/base_classes/FOCMotor.h" #include "common/base_classes/StepperDriver.h" #include "common/base_classes/Sensor.h" #include "common/foc_utils.h" #include "common/time_utils.h" #include "common/default...
// default configuration values // change this file to optimal values for your application #define DEF_POWER_SUPPLY 12.0f //!< default power supply voltage // velocity PI controller params #define DEF_PID_VEL_P 0.5f //!< default PID controller P value #define DEF_PID_VEL_I 10.0f //!< default PID controller I value #d...
#include "foc_utils.h" // function approximating the sine calculation by using fixed size array // uses a 65 element lookup table and interpolation // thanks to @dekutree for his work on optimizing this __attribute__((weak)) float _sin(float a){ // 16bit integer array for sine lookup. interpolation is used for bett...
#ifndef FOCUTILS_LIB_H #define FOCUTILS_LIB_H #include "Arduino.h" // sign function #define _sign(a) ( ( (a) < 0 ) ? -1 : ( (a) > 0 ) ) #ifndef _round #define _round(x) ((x)>=0?(long)((x)+0.5f):(long)((x)-0.5f)) #endif #define _constrain(amt,low,high) ((amt)<(low)?(low):((amt)>(high)?(high):(amt))) #define _sqrt(...
#include "lowpass_filter.h" LowPassFilter::LowPassFilter(float time_constant) : Tf(time_constant) , y_prev(0.0f) { timestamp_prev = _micros(); } float LowPassFilter::operator() (float x) { unsigned long timestamp = _micros(); float dt = (timestamp - timestamp_prev)*1e-6f; if (dt < 0.0f ) dt ...
#ifndef LOWPASS_FILTER_H #define LOWPASS_FILTER_H #include "time_utils.h" #include "foc_utils.h" /** * Low pass filter class */ class LowPassFilter { public: /** * @param Tf - Low pass filter time constant */ LowPassFilter(float Tf); ~LowPassFilter() = default; float operator() (float x...
#include "pid.h" PIDController::PIDController(float P, float I, float D, float ramp, float limit) : P(P) , I(I) , D(D) , output_ramp(ramp) // output derivative limit [volts/second] , limit(limit) // output supply limit [volts] , error_prev(0.0f) , output_prev(0.0f) , inte...
#ifndef PID_H #define PID_H #include "time_utils.h" #include "foc_utils.h" /** * PID controller class */ class PIDController { public: /** * * @param P - Proportional gain * @param I - Integral gain * @param D - Derivative gain * @param ramp - Maximum speed of change of the output...
#include "time_utils.h" // function buffering delay() // arduino uno function doesn't work well with interrupts void _delay(unsigned long ms){ #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega328PB__) || defined(__AVR_ATmega2560__) || defined(__AVR_ATmega32U4__) // if arduino un...
#ifndef TIME_UTILS_H #define TIME_UTILS_H #include "foc_utils.h" /** * Function implementing delay() function in milliseconds * - blocking function * - hardware specific * @param ms number of milliseconds to wait */ void _delay(unsigned long ms); /** * Function implementing timestamp getting function in mi...
#ifndef BLDCDRIVER_H #define BLDCDRIVER_H #include "Arduino.h" #include "FOCDriver.h" class BLDCDriver: public FOCDriver{ public: float dc_a; //!< currently set duty cycle on phaseA float dc_b; //!< currently set duty cycle on phaseB float dc_c; //!< currently set duty cycle on phaseC ...
#include "CurrentSense.h" #include "../../communication/SimpleFOCDebug.h" // get current magnitude // - absolute - if no electrical_angle provided // - signed - if angle provided float CurrentSense::getDCCurrent(float motor_electrical_angle){ // read current phase currents PhaseCurrent_s current = g...
#ifndef CURRENTSENSE_H #define CURRENTSENSE_H #include "FOCDriver.h" #include "../foc_utils.h" #include "../time_utils.h" #include "StepperDriver.h" #include "BLDCDriver.h" /** * Current sensing abstract class defintion * Each current sensing implementation needs to extend this interface */ class CurrentSense{ ...
#ifndef FOCDRIVER_H #define FOCDRIVER_H #include "Arduino.h" enum PhaseState : uint8_t { PHASE_OFF = 0, // both sides of the phase are off PHASE_ON = 1, // both sides of the phase are driven with PWM, dead time is applied in 6-PWM mode PHASE_HI = 2, // only the high side of the phase is driven with PWM (6-PW...
#include "FOCMotor.h" #include "../../communication/SimpleFOCDebug.h" /** * Default constructor - setting all variabels to default values */ FOCMotor::FOCMotor() { // maximum angular velocity to be used for positioning velocity_limit = DEF_VEL_LIM; // maximum voltage to be set to the motor voltage_limit = D...
#ifndef FOCMOTOR_H #define FOCMOTOR_H #include "Arduino.h" #include "Sensor.h" #include "CurrentSense.h" #include "../time_utils.h" #include "../foc_utils.h" #include "../defaults.h" #include "../pid.h" #include "../lowpass_filter.h" // monitoring bitmap #define _MON_TARGET 0b1000000 // monitor target value #define...
#include "Sensor.h" #include "../foc_utils.h" #include "../time_utils.h" void Sensor::update() { float val = getSensorAngle(); if (val<0) // sensor angles are strictly non-negative. Negative values are used to signal errors. return; // TODO signal error, e.g. via a flag and counter angle_prev_ts ...
#ifndef SENSOR_H #define SENSOR_H #include <inttypes.h> /** * Direction structure */ enum Direction : int8_t { CW = 1, // clockwise CCW = -1, // counter clockwise UNKNOWN = 0 // not yet known or invalid state }; /** * Pullup configuration structure */ enum Pullup : uint8_t { USE_IN...
#ifndef STEPPERDRIVER_H #define STEPPERDRIVER_H #include "Arduino.h" #include "FOCDriver.h" class StepperDriver: public FOCDriver{ public: /** * Set phase voltages to the hardware * * @param Ua phase A voltage * @param Ub phase B voltage */ v...
#include "Commander.h" Commander::Commander(Stream& serial, char eol, bool echo){ com_port = &serial; this->eol = eol; this->echo = echo; } Commander::Commander(char eol, bool echo){ this->eol = eol; this->echo = echo; } void Commander::add(char id, CommandCallback onCommand, const char* label ){ call_li...
#ifndef COMMANDS_H #define COMMANDS_H #include "Arduino.h" #include "../common/base_classes/FOCMotor.h" #include "../common/pid.h" #include "../common/lowpass_filter.h" #include "commands.h" #define MAX_COMMAND_LENGTH 20 // Commander verbose display to the user type enum VerboseMode : uint8_t { nothing = 0...
#ifndef COMMANDS_h #define COMMANDS_h // see docs.simplefoc.com for in depth explanation of the commands // list of commands #define CMD_C_D_PID 'D' //!< current d PID & LPF #define CMD_C_Q_PID 'Q' //!< current d PID & LPF #define CMD_V_PID 'V' //!< velocity PID & LPF #define CMD_A_PID 'A' //!< angle...
#include "SimpleFOCDebug.h" #ifndef SIMPLEFOC_DISABLE_DEBUG Print* SimpleFOCDebug::_debugPrint = NULL; void SimpleFOCDebug::enable(Print* debugPrint) { _debugPrint = debugPrint; } void SimpleFOCDebug::println(int val) { if (_debugPrint != NULL) { _debugPrint->println(val); } } void SimpleFO...
#ifndef __SIMPLEFOCDEBUG_H__ #define __SIMPLEFOCDEBUG_H__ #include "Arduino.h" /** * SimpleFOCDebug class * * This class is used to print debug messages to a chosen output. * Currently, Print instances are supported as targets, e.g. serial port. * * Activate debug output globally by calling enable(), option...
#include "StepDirListener.h" StepDirListener::StepDirListener(int _pinStep, int _pinDir, float _counter_to_value){ pin_step = _pinStep; pin_dir = _pinDir; counter_to_value = _counter_to_value; } void StepDirListener::init(){ pinMode(pin_dir, INPUT); pinMode(pin_step, INPUT_PULLUP); count = 0; ...
#ifndef STEPDIR_H #define STEPDIR_H #include "Arduino.h" #include "../common/foc_utils.h" /** * Step/Dir listenner class for easier interraction with this communication interface. */ class StepDirListener { public: /** * Constructor for step/direction interface * @param step - pin ...
#include "GenericCurrentSense.h" // GenericCurrentSense constructor GenericCurrentSense::GenericCurrentSense(PhaseCurrent_s (*readCallback)(), void (*initCallback)()){ // if function provided add it to the if(readCallback != nullptr) this->readCallback = readCallback; if(initCallback != nullptr) this->initCallb...
#ifndef GENERIC_CS_LIB_H #define GENERIC_CS_LIB_H #include "Arduino.h" #include "../common/foc_utils.h" #include "../common/time_utils.h" #include "../common/defaults.h" #include "../common/base_classes/CurrentSense.h" #include "../common/lowpass_filter.h" #include "hardware_api.h" class GenericCurrentSense: public ...
#ifndef HARDWARE_UTILS_CURRENT_H #define HARDWARE_UTILS_CURRENT_H #include "../common/foc_utils.h" #include "../common/time_utils.h" // flag returned if current sense init fails #define SIMPLEFOC_CURRENT_SENSE_INIT_FAILED ((void*)-1) // generic implementation of the hardware specific structure // containing all the ...
#include "InlineCurrentSense.h" #include "communication/SimpleFOCDebug.h" // InlineCurrentSensor constructor // - shunt_resistor - shunt resistor value // - gain - current-sense op-amp gain // - phA - A phase adc pin // - phB - B phase adc pin // - phC - C phase adc pin (optional) InlineCurrentSense::Inlin...
#ifndef INLINE_CS_LIB_H #define INLINE_CS_LIB_H #include "Arduino.h" #include "../common/foc_utils.h" #include "../common/time_utils.h" #include "../common/defaults.h" #include "../common/base_classes/CurrentSense.h" #include "../common/base_classes/StepperDriver.h" #include "../common/base_classes/BLDCDriver.h" #incl...
#include "LowsideCurrentSense.h" #include "communication/SimpleFOCDebug.h" // LowsideCurrentSensor constructor // - shunt_resistor - shunt resistor value // - gain - current-sense op-amp gain // - phA - A phase adc pin // - phB - B phase adc pin // - phC - C phase adc pin (optional) LowsideCurrentSense::Lo...
#ifndef LOWSIDE_CS_LIB_H #define LOWSIDE_CS_LIB_H #include "Arduino.h" #include "../common/foc_utils.h" #include "../common/time_utils.h" #include "../common/defaults.h" #include "../common/base_classes/CurrentSense.h" #include "../common/base_classes/FOCMotor.h" #include "../common/base_classes/StepperDriver.h" #incl...
#include "../hardware_api.h" #if defined(__AVR_ATmega328P__) || defined(__AVR_ATmega168__) || defined(__AVR_ATmega328PB__) #define _ADC_VOLTAGE 5.0f #define _ADC_RESOLUTION 1024.0f #ifndef cbi #define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) #endif #ifndef sbi #define sbi(sfr, bit) (_SFR_BYTE(sfr) |= _BV(bit...
#include "../hardware_api.h" #if defined(__arm__) && defined(__SAM3X8E__) #define _ADC_VOLTAGE 3.3f #define _ADC_RESOLUTION 1024.0f // function reading an ADC value and returning the read voltage void* _configureADCInline(const void* driver_params, const int pinA,const int pinB,const int pinC){ _UNUSED(driver_p...
#include "../hardware_api.h" #include "../../communication/SimpleFOCDebug.h" // function reading an ADC value and returning the read voltage __attribute__((weak)) float _readADCVoltageInline(const int pinA, const void* cs_params){ uint32_t raw_adc = analogRead(pinA); return raw_adc * ((GenericCurrentSenseParams*)...
#include "esp32_mcu.h" #include "esp32_adc_driver.h" #if defined(ESP_H) && defined(ARDUINO_ARCH_ESP32) #define SIMPLEFOC_ADC_ATTEN ADC_11db #define SIMPLEFOC_ADC_RES 12 #if CONFIG_IDF_TARGET_ESP32 // if esp32 variant #include "soc/sens_reg.h" // configure the ADCs in RTC mode // saves about 3us per call // goin...
#ifndef SIMPLEFOC_ESP32_HAL_ADC_DRIVER_H_ #define SIMPLEFOC_ESP32_HAL_ADC_DRIVER_H_ #if defined(ESP_H) && defined(ARDUINO_ARCH_ESP32) /** * Get ADC value for pin * @param pin - pin number * @return ADC value (0 - 4095) * */ uint16_t adcRead(uint8_t pin); /** * Initialize ADC pin * @param pin - pin number * ...
#include "esp32_mcu.h" #if defined(ESP_H) && defined(ARDUINO_ARCH_ESP32) && defined(SOC_MCPWM_SUPPORTED) && !defined(SIMPLEFOC_ESP32_USELEDC) // check the version of the ESP-IDF #include "esp_idf_version.h" #if ESP_IDF_VERSION < ESP_IDF_VERSION_VAL(5, 0, 0) #error SimpleFOC: ESP-IDF version 4 or lower detected. Plea...
#include "esp32_mcu.h" #if defined(ESP_H) && defined(ARDUINO_ARCH_ESP32) /** * Inline adc reading implementation */ // function reading an ADC value and returning the read voltage float _readADCVoltageInline(const int pinA, const void* cs_params){ uint32_t raw_adc = adcRead(pinA); return raw_adc * ((ESP32Curre...
#ifndef ESP32_MCU_CURRENT_SENSING_H #define ESP32_MCU_CURRENT_SENSING_H #include "../../hardware_api.h" #if defined(ESP_H) && defined(ARDUINO_ARCH_ESP32) #include "../../../drivers/hardware_api.h" #include "esp32_adc_driver.h" // esp32 current sense parameters typedef struct ESP32CurrentSenseParams { int pins[...
#if defined(TARGET_RP2040) || defined(TARGET_RP2350) #include "../../hardware_api.h" #include "./rp2040_mcu.h" #include "../../../drivers/hardware_specific/rp2040/rp2040_mcu.h" #include "communication/SimpleFOCDebug.h" #include "hardware/dma.h" #include "hardware/irq.h" #include "hardware/pwm.h" #include "hardware/...
#pragma once /* * RP2040 ADC features are very weak :-( * - only 4 inputs * - only 9 bit effective resolution * - read only 1 input at a time * - 2 microseconds conversion time! * - no triggers from PWM / events, only DMA * * So to read 3 phases takes 6 microseconds. :-( * * The RP2040 ADC engine tak...
#include "samd21_mcu.h" #if defined(_SAMD21_) #include "../../hardware_api.h" #include "../../../drivers/hardware_specific/samd/samd_mcu.h" static int _pinA = NOT_SET, _pinB = NOT_SET, _pinC = NOT_SET; static uint16_t adc_raw[3] = {0, 0, 0}; static uint8_t current_phase = 0; // which phase we're sampling static bo...
#include "Arduino.h" #if defined(_SAMD21_) #ifndef CURRENT_SENSE_SAMD21_H #define CURRENT_SENSE_SAMD21_H #define SIMPLEFOC_SAMD_DEBUG #if !defined(SIMPLEFOC_SAMD_DEBUG_SERIAL) #define SIMPLEFOC_SAMD_DEBUG_SERIAL Serial #endif #include "../../hardware_api.h" #endif #endif
#include "../../hardware_api.h" #if defined(_SAMD21_)|| defined(_SAMD51_) || defined(_SAME51_) #define _ADC_VOLTAGE 3.3f #define _ADC_RESOLUTION 1024.0f // function reading an ADC value and returning the read voltage void* _configureADCInline(const void* driver_params, const int pinA,const int pinB,const int pinC){...
#include "stm32_adc_utils.h" #include "stm32_mcu.h" #if defined(_STM32_DEF_) int _adcToIndex(ADC_TypeDef *AdcHandle){ if(AdcHandle == ADC1) return 0; #ifdef ADC2 // if ADC2 exists else if(AdcHandle == ADC2) return 1; #endif #ifdef ADC3 // if ADC3 exists else if(AdcHandle == ADC3) return 2; #endif #ifdef ADC4...
#ifndef STM32_ADC_UTILS_HAL #define STM32_ADC_UTILS_HAL #include "Arduino.h" #if defined(_STM32_DEF_) #define _TRGO_NOT_AVAILABLE 12345 // for searching the best ADCs, we need to know the number of ADCs // it might be better to use some HAL variable for example ADC_COUNT // here I've assumed the maximum number of...
#include "../../hardware_api.h" #if defined(_STM32_DEF_) and !defined(ARDUINO_B_G431B_ESC1) #include "stm32_mcu.h" #define _ADC_VOLTAGE 3.3f #define _ADC_RESOLUTION 1024.0f // function reading an ADC value and returning the read voltage void* _configureADCInline(const void* driver_params, const int pinA,const int...
#ifndef STM32_CURRENTSENSE_MCU_DEF #define STM32_CURRENTSENSE_MCU_DEF #include "../../hardware_api.h" #include "../../../common/foc_utils.h" #include "../../../drivers/hardware_specific/stm32/stm32_mcu.h" #include "../../../drivers/hardware_specific/stm32/stm32_timerutils.h" #if defined(_STM32_DEF_) // generic impl...
#include "../../../hardware_api.h" #if defined(ARDUINO_B_G431B_ESC1) #include "communication/SimpleFOCDebug.h" #include "stm32g4xx_hal.h" #include "stm32g4xx_ll_pwr.h" #include "stm32g4xx_hal_adc.h" #include "b_g431_hal.h" // From STM32 cube IDE /** *****************************************************************...
#ifndef B_G431_ESC1_HAL #define B_G431_ESC1_HAL #if defined(ARDUINO_B_G431B_ESC1) #include <stm32g4xx_hal_adc.h> #include <stm32g4xx_hal_opamp.h> void MX_GPIO_Init(void); void MX_DMA_Init(void); void MX_ADC1_Init(ADC_HandleTypeDef* hadc1); void MX_ADC2_Init(ADC_HandleTypeDef* hadc2); void MX_OPAMP1_Init(OPAMP_Handle...
#include "../../../hardware_api.h" #if defined(ARDUINO_B_G431B_ESC1) #include "b_g431_hal.h" #include "Arduino.h" #include "../stm32_mcu.h" #include "../../../../drivers/hardware_specific/stm32/stm32_mcu.h" #include "communication/SimpleFOCDebug.h" #define _ADC_VOLTAGE 3.3f #define _ADC_RESOLUTION 4096.0f #define A...
#include "stm32f1_hal.h" #if defined(STM32F1xx) #include "../../../../communication/SimpleFOCDebug.h" #include "../stm32_adc_utils.h" #define _TRGO_NOT_AVAILABLE 12345 ADC_HandleTypeDef hadc; /** * Function initializing the ADC and the injected channels for the low-side current sensing * * @param cs_params - ...
#ifndef STM32F1_LOWSIDE_HAL #define STM32F1_LOWSIDE_HAL #include "Arduino.h" #if defined(STM32F1xx) #include "stm32f1xx_hal.h" #include "../stm32_mcu.h" int _adc_init(Stm32CurrentSenseParams* cs_params, const STM32DriverParams* driver_params); int _adc_gpio_init(Stm32CurrentSenseParams* cs_params, const int pinA, c...
#include "../../../hardware_api.h" #if defined(STM32F1xx) #include "../../../../common/foc_utils.h" #include "../../../../drivers/hardware_api.h" #include "../../../../drivers/hardware_specific/stm32/stm32_mcu.h" #include "../../../hardware_api.h" #include "../stm32_adc_utils.h" #include "../stm32_mcu.h" #include "st...
#include "../stm32_adc_utils.h" #if defined(STM32F1xx) // timer to injected TRGO // https://github.com/stm32duino/Arduino_Core_STM32/blob/e156c32db24d69cb4818208ccc28894e2f427cfa/system/Drivers/STM32F1xx_HAL_Driver/Inc/stm32f1xx_hal_adc_ex.h#L215 uint32_t _timerToInjectedTRGO(TIM_HandleTypeDef* timer){ if(timer->I...
#include "stm32f4_hal.h" #if defined(STM32F4xx) //#define SIMPLEFOC_STM32_DEBUG #include "../../../../communication/SimpleFOCDebug.h" #define _TRGO_NOT_AVAILABLE 12345 ADC_HandleTypeDef hadc; /** * Function initializing the ADC and the injected channels for the low-side current sensing * * @param cs_params - c...
#ifndef STM32F4_LOWSIDE_HAL #define STM32F4_LOWSIDE_HAL #include "Arduino.h" #if defined(STM32F4xx) #include "stm32f4xx_hal.h" #include "../stm32_mcu.h" #include "../stm32_adc_utils.h" int _adc_init(Stm32CurrentSenseParams* cs_params, const STM32DriverParams* driver_params); int _adc_gpio_init(Stm32CurrentSenseParam...
#include "../../../hardware_api.h" #if defined(STM32F4xx) #include "../../../../common/foc_utils.h" #include "../../../../drivers/hardware_api.h" #include "../../../../drivers/hardware_specific/stm32/stm32_mcu.h" #include "../../../hardware_api.h" #include "../stm32_mcu.h" #include "../stm32_adc_utils.h" #include "stm...
#include "../stm32_adc_utils.h" #if defined(STM32F4xx) // timer to injected TRGO // https://github.com/stm32duino/Arduino_Core_STM32/blob/e156c32db24d69cb4818208ccc28894e2f427cfa/system/Drivers/STM32F4xx_HAL_Driver/Inc/stm32f4xx_hal_adc_ex.h#L179 uint32_t _timerToInjectedTRGO(TIM_HandleTypeDef* timer){ if(timer->In...
#include "stm32f7_hal.h" #if defined(STM32F7xx) //#define SIMPLEFOC_STM32_DEBUG #include "../../../../communication/SimpleFOCDebug.h" #define _TRGO_NOT_AVAILABLE 12345 ADC_HandleTypeDef hadc; /** * Function initializing the ADC and the injected channels for the low-side current sensing * * @param cs_params - c...
#ifndef STM32F7_LOWSIDE_HAL #define STM32F7_LOWSIDE_HAL #include "Arduino.h" #if defined(STM32F7xx) #include "stm32f7xx_hal.h" #include "../stm32_mcu.h" #include "../stm32_adc_utils.h" int _adc_init(Stm32CurrentSenseParams* cs_params, const STM32DriverParams* driver_params); int _adc_gpio_init(Stm32CurrentSensePara...
#include "../../../hardware_api.h" #if defined(STM32F7xx) #include "../../../../common/foc_utils.h" #include "../../../../drivers/hardware_api.h" #include "../../../../drivers/hardware_specific/stm32/stm32_mcu.h" #include "../../../hardware_api.h" #include "../stm32_mcu.h" #include "../stm32_adc_utils.h" #include "stm...
#include "../stm32_adc_utils.h" #if defined(STM32F7xx) /* TIM1 TIM2 TIM3 TIM4 TIM5 TIM6 TIM7 TIM12 TIM13 TIM14 ADC_EXTERNALTRIGINJECCONV_T1_TRGO ADC_EXTERNALTRIGINJECCONV_T2_TRGO ADC_EXTERNALTRIGINJECCONV_T4_TRGO ADC_EXTERNALTRIGINJECCONV_T1_TRGO2 ADC_EXTERNALTRIGINJECCONV_T8_TRGO2...
#include "stm32g4_hal.h" #if defined(STM32G4xx) && !defined(ARDUINO_B_G431B_ESC1) #include "../../../../communication/SimpleFOCDebug.h" #define SIMPLEFOC_STM32_DEBUG ADC_HandleTypeDef hadc; /** * Function initializing the ADC and the injected channels for the low-side current sensing * * @param cs_params - cur...
#ifndef STM32G4_LOWSIDE_HAL #define STM32G4_LOWSIDE_HAL #include "Arduino.h" #if defined(STM32G4xx) && !defined(ARDUINO_B_G431B_ESC1) #include "stm32g4xx_hal.h" #include "../stm32_mcu.h" #include "../stm32_adc_utils.h" int _adc_init(Stm32CurrentSenseParams* cs_params, const STM32DriverParams* driver_params); int _a...
#include "../../../hardware_api.h" #if defined(STM32G4xx) && !defined(ARDUINO_B_G431B_ESC1) #include "../../../../common/foc_utils.h" #include "../../../../drivers/hardware_api.h" #include "../../../../drivers/hardware_specific/stm32/stm32_mcu.h" #include "../../../hardware_api.h" #include "../stm32_mcu.h" #include "...
#include "../stm32_adc_utils.h" #if defined(STM32G4xx) && !defined(ARDUINO_B_G431B_ESC1) // timer to injected TRGO // https://github.com/stm32duino/Arduino_Core_STM32/blob/6588dee03382e73ed42c4a5e473900ab3b79d6e4/system/Drivers/STM32G4xx_HAL_Driver/Inc/stm32g4xx_hal_adc_ex.h#L217 uint32_t _timerToInjectedTRGO(TIM_Han...
#include "stm32h7_hal.h" #if defined(STM32H7xx) //#define SIMPLEFOC_STM32_DEBUG #include "../../../../communication/SimpleFOCDebug.h" ADC_HandleTypeDef hadc; /** * Function initializing the ADC and the injected channels for the low-side current sensing * * @param cs_params - current sense parameters * @param ...
#pragma once #include "Arduino.h" #if defined(STM32H7xx) #include "stm32h7xx_hal.h" #include "../stm32_adc_utils.h" #include "../stm32_mcu.h" int _adc_init(Stm32CurrentSenseParams* cs_params, const STM32DriverParams* driver_params); int _adc_gpio_init(Stm32CurrentSenseParams* cs_params, const int pinA, const int pin...
#include "../../../hardware_api.h" #if defined(STM32H7xx) #include "../../../../common/foc_utils.h" #include "../../../../drivers/hardware_api.h" #include "../../../../drivers/hardware_specific/stm32/stm32_mcu.h" #include "../../../hardware_api.h" #include "../stm32_mcu.h" #include "../stm32_adc_utils.h" #include "stm...
#include "../stm32_adc_utils.h" #if defined(STM32H7xx) /* Exported Functions */ // timer to injected TRGO // https://github.com/stm32duino/Arduino_Core_STM32/blob/e156c32db24d69cb4818208ccc28894e2f427cfa/system/Drivers/STM32H7xx_HAL_Driver/Inc/stm32h7xx_hal_adc_ex.h#L235 uint32_t _timerToInjectedTRGO(TIM_HandleType...
#include "stm32l4_hal.h" #if defined(STM32L4xx) #include "../../../../communication/SimpleFOCDebug.h" #define SIMPLEFOC_STM32_DEBUG ADC_HandleTypeDef hadc; /** * Function initializing the ADC and the injected channels for the low-side current sensing * * @param cs_params - current sense parameters * @param dr...
#ifndef STM32L4_LOWSIDE_HAL #define STM32L4_LOWSIDE_HAL #include "Arduino.h" #if defined(STM32L4xx) #include "stm32l4xx_hal.h" #include "../stm32_mcu.h" #include "../stm32_adc_utils.h" int _adc_init(Stm32CurrentSenseParams* cs_params, const STM32DriverParams* driver_params); int _adc_gpio_init(Stm32CurrentSensePar...
#include "../../../hardware_api.h" #if defined(STM32L4xx) #include "../../../../common/foc_utils.h" #include "../../../../drivers/hardware_api.h" #include "../../../../drivers/hardware_specific/stm32/stm32_mcu.h" #include "../../../hardware_api.h" #include "../stm32_mcu.h" #include "../stm32_adc_utils.h" #include "st...
#include "../stm32_adc_utils.h" #if defined(STM32L4xx) // timer to injected TRGO // https://github.com/stm32duino/Arduino_Core_STM32/blob/e156c32db24d69cb4818208ccc28894e2f427cfa/system/Drivers/STM32L4xx_HAL_Driver/Inc/stm32l4xx_hal_adc_ex.h#L210 uint32_t _timerToInjectedTRGO(TIM_HandleTypeDef* timer){ if(timer->I...
#include "teensy4_mcu.h" #include "../../../drivers/hardware_specific/teensy/teensy4_mcu.h" // #include "../../../common/lowpass_filter.h" #include "../../../common/foc_utils.h" #include "../../../communication/SimpleFOCDebug.h" // if defined // - Teensy 4.0 // - Teensy 4.1 #if defined(__arm__) && defined(CORE_TEEN...