From abda7543c78006cde7ae84fc76678bd4a56c1ca2 Mon Sep 17 00:00:00 2001 From: Antun Skuric <36178713+askuric@users.noreply.github.com> Date: Sun, 21 Apr 2024 16:54:28 +0200 Subject: [PATCH 1/2] Update teensy4_mcu.cpp --- src/drivers/hardware_specific/teensy/teensy4_mcu.cpp | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/drivers/hardware_specific/teensy/teensy4_mcu.cpp b/src/drivers/hardware_specific/teensy/teensy4_mcu.cpp index 7c4d0dbb..47108447 100644 --- a/src/drivers/hardware_specific/teensy/teensy4_mcu.cpp +++ b/src/drivers/hardware_specific/teensy/teensy4_mcu.cpp @@ -10,7 +10,7 @@ #pragma message("SimpleFOC: compiling for Teensy 4.x") #pragma message("") -// #define TEENSY4_FORCE_CENTER_ALIGNED_3PWM +// #define SIMPLEFOC_TEENSY4_FORCE_CENTER_ALIGNED_3PWM // function finding the TRIG event given the flexpwm timer and the submodule @@ -569,7 +569,7 @@ void write_pwm_on_pin(IMXRT_FLEXPWM_t *p, unsigned int submodule, uint8_t channe p->MCTRL |= FLEXPWM_MCTRL_LDOK(mask); } -#ifdef TEENSY4_FORCE_CENTER_ALIGNED_3PWM +#ifdef SIMPLEFOC_TEENSY4_FORCE_CENTER_ALIGNED_3PWM // function setting the high pwm frequency to the supplied pins // - BLDC motor - 3PWM setting @@ -663,4 +663,4 @@ void _writeCenterAligned3PMW(float dc_a, float dc_b, float dc_c, void* params){ #endif -#endif \ No newline at end of file +#endif From 6fafa35b73e9c5ba6f5d9259640a5ed328dc2750 Mon Sep 17 00:00:00 2001 From: Antun Skuric <36178713+askuric@users.noreply.github.com> Date: Sun, 21 Apr 2024 16:55:11 +0200 Subject: [PATCH 2/2] Update teensy4_mcu.cpp --- .../hardware_specific/teensy/teensy4_mcu.cpp | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/src/current_sense/hardware_specific/teensy/teensy4_mcu.cpp b/src/current_sense/hardware_specific/teensy/teensy4_mcu.cpp index 564f4f46..70815d0f 100644 --- a/src/current_sense/hardware_specific/teensy/teensy4_mcu.cpp +++ b/src/current_sense/hardware_specific/teensy/teensy4_mcu.cpp @@ -9,7 +9,7 @@ // - Teensy 4.1 #if defined(__arm__) && defined(CORE_TEENSY) && ( defined(__IMXRT1062__) || defined(ARDUINO_TEENSY40) || defined(ARDUINO_TEENSY41) || defined(ARDUINO_TEENSY_MICROMOD) ) -// #define TEENSY4_ADC_INTERRUPT_DEBUG +// #define SIMPLEFOC_TEENSY4_ADC_INTERRUPT_DEBUG volatile uint32_t val0, val1, val2; @@ -28,7 +28,7 @@ void read_currents(uint32_t *a, uint32_t*b, uint32_t *c=nullptr){ // interrupt service routine for the ADC_ETC0 // reading the ADC values and clearing the interrupt void adcetc0_isr() { -#ifdef TEENSY4_ADC_INTERRUPT_DEBUG +#ifdef SIMPLEFOC_TEENSY4_ADC_INTERRUPT_DEBUG digitalWrite(30,HIGH); #endif // page 3509 , section 66.5.1.3.3 @@ -37,21 +37,21 @@ void adcetc0_isr() { val0 = (ADC_ETC_TRIG0_RESULT_1_0 & 4095); // val1 = lp2((ADC_ETC_TRIG0_RESULT_1_0 >> 16) & 4095); val1 = (ADC_ETC_TRIG0_RESULT_1_0 >> 16) & 4095; -#ifdef TEENSY4_ADC_INTERRUPT_DEBUG +#ifdef SIMPLEFOC_TEENSY4_ADC_INTERRUPT_DEBUG digitalWrite(30,LOW); #endif } void adcetc1_isr() { -#ifdef TEENSY4_ADC_INTERRUPT_DEBUG +#ifdef SIMPLEFOC_TEENSY4_ADC_INTERRUPT_DEBUG digitalWrite(30,HIGH); #endif // page 3509 , section 66.5.1.3.3 ADC_ETC_DONE0_1_IRQ |= 1 << 16; // clear Done1 for trg0 at 16th bit val2 = ADC_ETC_TRIG0_RESULT_3_2 & 4095; // val2 = lp3( ADC_ETC_TRIG0_RESULT_3_2 & 4095); -#ifdef TEENSY4_ADC_INTERRUPT_DEBUG +#ifdef SIMPLEFOC_TEENSY4_ADC_INTERRUPT_DEBUG digitalWrite(30,LOW); #endif } @@ -167,7 +167,7 @@ void* _configureADCLowSide(const void* driver_params, const int pinA,const int p SIMPLEFOC_DEBUG("TEENSY-CS: Configuring low side current sense!"); -#ifdef TEENSY4_ADC_INTERRUPT_DEBUG +#ifdef SIMPLEFOC_TEENSY4_ADC_INTERRUPT_DEBUG pinMode(30,OUTPUT); #endif @@ -228,7 +228,7 @@ void _driverSyncLowSide(void* driver_params, void* cs_params){ // flexpwm->SM[submodule].VAL4 = int(flexpwm->SM[submodule].VAL1*(1.0f - 2.5e-6*par->pwm_frequency)) ; // 2.5us before center -#ifdef TEENSY4_ADC_INTERRUPT_DEBUG +#ifdef SIMPLEFOC_TEENSY4_ADC_INTERRUPT_DEBUG // pin 4 observes out trigger line for 'scope xbar_connect (xbar_trig_pwm, XBARA1_OUT_IOMUX_XBAR_INOUT08) ; IOMUXC_GPR_GPR6 |= IOMUXC_GPR_GPR6_IOMUXC_XBAR_DIR_SEL_8 ; // select output mode for INOUT8 @@ -241,4 +241,4 @@ void _driverSyncLowSide(void* driver_params, void* cs_params){ } -#endif \ No newline at end of file +#endif