|
2 | 2 | #include "../../../drivers/hardware_specific/teensy/teensy4_mcu.h" |
3 | 3 | // #include "../../../common/lowpass_filter.h" |
4 | 4 | #include "../../../common/foc_utils.h" |
| 5 | +#include "../../../communication/SimpleFOCDebug.h" |
5 | 6 |
|
6 | 7 | // if defined |
7 | 8 | // - Teensy 4.0 |
@@ -158,7 +159,13 @@ float _readADCVoltageLowSide(const int pinA, const void* cs_params){ |
158 | 159 | // Configure low side for generic mcu |
159 | 160 | // cannot do much but |
160 | 161 | void* _configureADCLowSide(const void* driver_params, const int pinA,const int pinB,const int pinC){ |
161 | | - _UNUSED(driver_params); |
| 162 | + Teensy4DriverParams* par = (Teensy4DriverParams*) ((TeensyDriverParams*)driver_params)->additional_params; |
| 163 | + if(par == nullptr){ |
| 164 | + SIMPLEFOC_DEBUG("TEENSY-CS: Low side current sense failed, driver not supported!"); |
| 165 | + return SIMPLEFOC_CURRENT_SENSE_INIT_FAILED; |
| 166 | + } |
| 167 | + |
| 168 | + SIMPLEFOC_DEBUG("TEENSY-CS: Configuring low side current sense!"); |
162 | 169 |
|
163 | 170 | #ifdef TEENSY4_ADC_INTERRUPT_DEBUG |
164 | 171 | pinMode(30,OUTPUT); |
@@ -191,10 +198,15 @@ void* _configureADCLowSide(const void* driver_params, const int pinA,const int p |
191 | 198 |
|
192 | 199 | // sync driver and the adc |
193 | 200 | void _driverSyncLowSide(void* driver_params, void* cs_params){ |
194 | | - Teensy4DriverParams* par = (Teensy4DriverParams*) driver_params; |
| 201 | + Teensy4DriverParams* par = (Teensy4DriverParams*) ((TeensyDriverParams*)driver_params)->additional_params; |
195 | 202 | IMXRT_FLEXPWM_t* flexpwm = par->flextimers[0]; |
196 | 203 | int submodule = par->submodules[0]; |
197 | 204 |
|
| 205 | + SIMPLEFOC_DEBUG("TEENSY-CS: Syncing low side current sense!"); |
| 206 | + char buff[50]; |
| 207 | + sprintf(buff, "TEENSY-CS: Syncing to FlexPWM: %d, Submodule: %d", flexpwm_to_index(flexpwm), submodule); |
| 208 | + SIMPLEFOC_DEBUG(buff); |
| 209 | + |
198 | 210 | // find the xbar trigger for the flexpwm |
199 | 211 | int xbar_trig_pwm = flexpwm_submodule_to_trig(flexpwm, submodule); |
200 | 212 | if(xbar_trig_pwm<0) return; |
|
0 commit comments