Skip to content

Commit

Permalink
Merge remote-tracking branch 'simplefoc/master' into dev
Browse files Browse the repository at this point in the history
  • Loading branch information
runger1101001 committed May 12, 2024
2 parents 14f6726 + 6fafa35 commit 627c0a8
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 11 deletions.
16 changes: 8 additions & 8 deletions src/current_sense/hardware_specific/teensy/teensy4_mcu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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;
Expand All @@ -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
Expand All @@ -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
}
Expand Down Expand Up @@ -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

Expand Down Expand Up @@ -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
Expand All @@ -241,4 +241,4 @@ void _driverSyncLowSide(void* driver_params, void* cs_params){
}


#endif
#endif
6 changes: 3 additions & 3 deletions src/drivers/hardware_specific/teensy/teensy4_mcu.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -663,4 +663,4 @@ void _writeCenterAligned3PMW(float dc_a, float dc_b, float dc_c, void* params){

#endif

#endif
#endif

0 comments on commit 627c0a8

Please sign in to comment.