Davide Aliprandi / X_NUCLEO_IHM03A1

Dependencies:   ST_INTERFACES X_NUCLEO_COMMON

Fork of X_NUCLEO_IHM03A1 by ST

Revision:
1:8ce2a5d6fbf8
Parent:
0:00a3c3f5a8f0
Child:
2:06f3a5360a45
--- a/Components/powerstep01/powerstep01_class.cpp	Tue Apr 05 15:18:56 2016 +0000
+++ b/Components/powerstep01/powerstep01_class.cpp	Thu Apr 07 16:11:47 2016 +0000
@@ -41,11 +41,8 @@
 
 /* Definitions ---------------------------------------------------------------*/
 
-/* Error while initialising the SPI. */
-#define POWERSTEP01_ERROR_0        (0x8000)   
-
 /* Error of bad SPI transaction. */
-#define POWERSTEP01_ERROR_1        (0x8001)
+#define POWERSTEP01_ERROR_1        (POWERSTEP01_ERROR_BASE|0x0001)
 
 /* Variables  ----------------------------------------------------------------*/
 
@@ -453,7 +450,7 @@
  * @brief Returns the FW version of the library
  * @retval POWERSTEP01_FW_VERSION
  **********************************************************/
-uint8_t POWERSTEP01::Powerstep01_GetFwVersion(void)
+uint32_t POWERSTEP01::Powerstep01_GetFwVersion(void)
 {
   return (POWERSTEP01_FW_VERSION);
 }
@@ -512,7 +509,7 @@
  * as specified in enum motorStepMode_t
  * @retval None
  **********************************************************/
-void POWERSTEP01::Powerstep01_SelectStepMode(motorStepMode_t stepMode)
+bool POWERSTEP01::Powerstep01_SelectStepMode(motorStepMode_t stepMode)
 {
   uint8_t stepModeRegister;
   powerstep01_StepSel_t powerstep01StepMode;
@@ -541,9 +538,10 @@
       powerstep01StepMode = POWERSTEP01_STEP_SEL_1_64;
       break;
     case STEP_MODE_1_128:
+      powerstep01StepMode = POWERSTEP01_STEP_SEL_1_128;
+      break;
     default:
-      powerstep01StepMode = POWERSTEP01_STEP_SEL_1_128;
-      break;       
+      return false;
   }
   
   /* Set the powerstep01 in HiZ state */
@@ -558,6 +556,7 @@
   /* Reset abs pos register */
   Powerstep01_CmdResetPos();
 
+  return true;
 }
 
 /**********************************************************