Skip to content

Commit

Permalink
Update teensy4_mcu.cpp
Browse files Browse the repository at this point in the history
  • Loading branch information
askuric authored Apr 21, 2024
1 parent abda754 commit 6fafa35
Showing 1 changed file with 8 additions and 8 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

0 comments on commit 6fafa35

Please sign in to comment.