Controlls of IHM01A1 by Joystick shield

Dependencies:   ST_INTERFACES X_NUCLEO_COMMON

Fork of X_NUCLEO_IHM01A1 by ST

Files at this revision

API Documentation at this revision

Comitter:
Davidroid
Date:
Fri Jan 15 16:42:39 2016 +0000
Parent:
19:5f0b00a1e38d
Child:
21:83138e702683
Commit message:
+ Added comments within the "L6474_class.h" header file.

Changed in this revision

Components/Interfaces/Component_class.h Show annotated file Show diff for this revision Revisions of this file
Components/Interfaces/StepperMotor_class.h Show annotated file Show diff for this revision Revisions of this file
Components/l6474/l6474_class.h Show annotated file Show diff for this revision Revisions of this file
--- a/Components/Interfaces/Component_class.h	Wed Jan 13 14:59:19 2016 +0000
+++ b/Components/Interfaces/Component_class.h	Fri Jan 15 16:42:39 2016 +0000
@@ -1,7 +1,7 @@
 /**
  ******************************************************************************
  * @file    Component_class.h
- * @author  Davide Aliprandi, STMicrolectronics
+ * @author  Davide Aliprandi, STMicroelectronics
  * @version V1.0.0
  * @date    April 13th, 2015
  * @brief   This file contains the abstract class describing the interface of a
--- a/Components/Interfaces/StepperMotor_class.h	Wed Jan 13 14:59:19 2016 +0000
+++ b/Components/Interfaces/StepperMotor_class.h	Fri Jan 15 16:42:39 2016 +0000
@@ -1,7 +1,7 @@
 /**
  ******************************************************************************
  * @file    StepperMotor_class.h
- * @author  Davide Aliprandi, STMicrolectronics
+ * @author  Davide Aliprandi, STMicroelectronics
  * @version V1.0.0
  * @date    November 12th, 2015
  * @brief   This file contains the abstract class describing the interface of a
--- a/Components/l6474/l6474_class.h	Wed Jan 13 14:59:19 2016 +0000
+++ b/Components/l6474/l6474_class.h	Fri Jan 15 16:42:39 2016 +0000
@@ -1,7 +1,7 @@
 /**
  ******************************************************************************
  * @file    l6474_class.h
- * @author  Davide Aliprandi, STMicrolectronics
+ * @author  Davide Aliprandi, STMicroelectronics
  * @version V1.0.0
  * @date    October 14th, 2015
  * @brief   This file contains the class of an L6474 Motor Control component.
@@ -827,20 +827,6 @@
     }
 
     /**
-     * @brief  Setting the frequency of PWM.
-     *         The frequency controls directly the speed of the device.
-     * @param  newFreq the frequency of PWM.
-     * @retval None.
-     */
-    void L6474_PwmSetFreq(uint16_t newFreq)
-    {
-        double period = 1.0f / newFreq;
-        pwm.period(period);
-        pwm.write(0.5f);
-        ticker.attach(this, &L6474::L6474_StepClockHandler, period);
-    }
-
-    /**
      * @brief  Initialising the PWM.
      * @param  None.
      * @retval None.
@@ -848,6 +834,25 @@
     void L6474_PwmInit(void) {}
 
     /**
+     * @brief  Setting the frequency of PWM.
+     *         The frequency controls directly the speed of the device.
+     * @param  frequency the frequency of PWM.
+     * @retval None.
+     */
+    void L6474_PwmSetFreq(uint16_t frequency)
+    {
+        /* Computing the period of PWM. */
+        double period = 1.0f / frequency;
+        
+        /* Setting the period and the duty-cycle of PWM. */
+        pwm.period(period);
+        pwm.write(0.5f);
+
+        /* Setting a callback with the same period of PWM's, to update the state machine. */
+        ticker.attach(this, &L6474::L6474_StepClockHandler, period);
+    }
+
+    /**
      * @brief  Stopping the PWM.
      * @param  None.
      * @retval None.