BaseCode for T-Motor_AK80

Dependencies:   mbed-dev-f303 FastPWM3

Revision:
57:d18e3d25ed8a
Parent:
56:fe5056ac6740
--- a/main.cpp	Thu Oct 10 15:03:12 2019 +0000
+++ b/main.cpp	Wed Dec 09 06:33:30 2020 +0000
@@ -178,6 +178,7 @@
   if (TIM1->SR & TIM_SR_UIF ) {
         //gpio.led->write(1);
         ///Sample current always ///
+        gpio.led->write(!gpio.led->read());
         ADC1->CR2  |= 0x40000000;                                               // Begin sample and conversion
         //volatile int delay;   
         //for (delay = 0; delay < 55; delay++);
@@ -447,6 +448,14 @@
     wait_us(100);
     drv.write_CSACR(0x0, 0x1, 0x0, CSA_GAIN_40, 0x0, 0x1, 0x1, 0x1, SEN_LVL_1_0);   // calibrate shunt amplifiers
     wait_us(100);
+    
+        
+    drv.write_HSR(LOCK_OFF, IDRIVEP_HS_330MA, IDRIVEN_HS_660MA);
+    wait_us(100);
+    drv.write_LSR(0x1, TDRIVE_4000NS, IDRIVEP_LS_330MA, IDRIVEN_LS_660MA);
+    wait_us(100);
+    
+    
     zero_current(&controller.adc1_offset, &controller.adc2_offset); 
     wait_us(100);
     drv.write_CSACR(0x0, 0x1, 0x0, CSA_GAIN_40, 0x1, 0x0, 0x0, 0x0, SEN_LVL_1_0);
@@ -523,7 +532,7 @@
         //drv.print_faults();
         wait(.1);
         //printf("%.3f  %.3f\n\r" , observer.temperature, observer.q_in);
-        if(controller.otw_flag){gpio.led->write(!gpio.led->read());}
+        //if(controller.otw_flag){gpio.led->write(!gpio.led->read());}
              /*
         if(state == MOTOR_MODE)
         {