LV8548 Motor Driver Stepper Motor Dc MOtor

Dependents:   LV8548_ON_MD_Modlle_kit_DCMtr_And_STEPMtr

Files at this revision

API Documentation at this revision

Comitter:
yamasho
Date:
Sat Nov 17 05:05:13 2018 +0000
Parent:
0:04db82da014d
Child:
2:627825272d30
Commit message:
Dc /Step #define Supported.; Ctm:For Stepper Noraml Port /Pwm Port Select ;

Changed in this revision

LV8548.cpp Show annotated file Show diff for this revision Revisions of this file
LV8548.h Show annotated file Show diff for this revision Revisions of this file
--- a/LV8548.cpp	Fri Nov 16 16:45:46 2018 +0000
+++ b/LV8548.cpp	Sat Nov 17 05:05:13 2018 +0000
@@ -250,8 +250,10 @@
     {
         SetDcMotorStop(MOTOR_A);
         _PwmPeriod[MOTOR_A] = 1/Freq;
+#if USE_PWM_PORT
         _in1.period( _PwmPeriod[MOTOR_A] );
         _in2.period( _PwmPeriod[MOTOR_A] );        
+#endif
         SetDcMotor(MOTOR_A);
  #if _DEBUG_
           printf("freq0 : %f ",_PwmPeriod[MOTOR_A]);
@@ -261,8 +263,10 @@
     {
         SetDcMotorStop(MOTOR_B);
         _PwmPeriod[MOTOR_B] = 1/Freq;
-        _in2.period( _PwmPeriod[MOTOR_B] );
-        _in3.period( _PwmPeriod[MOTOR_B] );        
+#if USE_PWM_PORT
+       _in3.period( _PwmPeriod[MOTOR_B] );
+       _in4.period( _PwmPeriod[MOTOR_B] );        
+#endif
 #if _DEBUG_
           printf("freq1 : %f ",_PwmPeriod[MOTOR_B]);
 #endif
@@ -559,7 +563,7 @@
 #if _DEBUG_
             printf("Ot:%x %x %x\n",OutputImage,_StepPhase,_TargetStepMode);    
 #endif
-    
+#if USE_PWM_PORT
             if( OutputImage &  COIL_A )      _in1.write(1.0f);
             else                             _in1.write(0.0f);
             if( OutputImage &  COIL_B )      _in2.write(1.0f);
@@ -568,8 +572,12 @@
             else                             _in3.write(0.0f);
             if( OutputImage &  COIL_D )      _in4.write(1.0f);
             else                             _in4.write(0.0f);
-    
-    
+#else
+            _in1 =  (( OutputImage &  COIL_A ) != 0);
+            _in2 =  (( OutputImage &  COIL_B ) != 0);
+            _in3 =  (( OutputImage &  COIL_C ) != 0);
+            _in4 =  (( OutputImage &  COIL_D ) != 0);
+ #endif    
             if(_NowStepDirection)   _StepPhase --;
             else                    _StepPhase ++;
             _StepPhase = _StepPhase & (STEPPHASEMAX -1);
--- a/LV8548.h	Fri Nov 16 16:45:46 2018 +0000
+++ b/LV8548.h	Sat Nov 17 05:05:13 2018 +0000
@@ -13,6 +13,7 @@
 #define MAXCH   (2)
 
 #define STEPMAX_FREQ (4800)
+#define USE_PWM_PORT       (FALSE)
 
 /** Motor Use  */
  enum DriverType {
@@ -71,7 +72,11 @@
 class LV8548 {
 public:
     LV8548(PinName in1, PinName in2, PinName in3, PinName in4, DriverType drivertype = DCMOTOR ,uint16_t baseus = 64);
+#if USE_PWM_PORT
     PwmOut _in1,_in2,_in3,_in4;
+#else
+    DigitalOut _in1,_in2,_in3,_in4;
+#endif
     DriverType   _Drivertype;
     uint16_t     _baseus; 
 /***************************************************************************************************/