You can not select more than 25 topics Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.

x_nucleo_ihmxx.h 10KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241
  1. /**
  2. ******************************************************************************
  3. * @file x_nucleo_ihmxx.h
  4. * @author IPC Rennes
  5. * @version V1.7.0
  6. * @date March 16th, 2018
  7. * @brief This file provides common definitions for motor control
  8. ******************************************************************************
  9. * @attention
  10. *
  11. * <h2><center>&copy; COPYRIGHT(c) 2018 STMicroelectronics</center></h2>
  12. *
  13. * Redistribution and use in source and binary forms, with or without modification,
  14. * are permitted provided that the following conditions are met:
  15. * 1. Redistributions of source code must retain the above copyright notice,
  16. * this list of conditions and the following disclaimer.
  17. * 2. Redistributions in binary form must reproduce the above copyright notice,
  18. * this list of conditions and the following disclaimer in the documentation
  19. * and/or other materials provided with the distribution.
  20. * 3. Neither the name of STMicroelectronics nor the names of its contributors
  21. * may be used to endorse or promote products derived from this software
  22. * without specific prior written permission.
  23. *
  24. * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  25. * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  26. * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  27. * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  28. * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  29. * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  30. * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  31. * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  32. * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  33. * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  34. *
  35. ******************************************************************************
  36. */
  37. /* Define to prevent recursive inclusion -------------------------------------*/
  38. #ifndef X_NUCLEO_IHMXX_H
  39. #define X_NUCLEO_IHMXX_H
  40. #ifdef __cplusplus
  41. extern "C" {
  42. #endif
  43. /* Includes ------------------------------------------------------------------*/
  44. #include "motor.h"
  45. /** @addtogroup BSP
  46. * @{
  47. */
  48. /** @addtogroup MOTOR_CONTROL
  49. * @{
  50. */
  51. /** @defgroup MOTOR_CONTROL_Exported_Types MOTOR CONTROL Exported Types
  52. * @{
  53. */
  54. /**
  55. * @}
  56. */
  57. /** @defgroup MOTOR_CONTROL_Exported_Constants MOTOR CONTROL Exported Constants
  58. * @{
  59. */
  60. /// Motor control error tag (used when trying to call undefined functions via motorDrvHandle)
  61. #define MOTOR_CONTROL_ERROR_TAG (0x0800)
  62. ///Motor control board id for L6474
  63. #define BSP_MOTOR_CONTROL_BOARD_ID_L6474 (6474)
  64. ///Motor control board id for L6470
  65. #define BSP_MOTOR_CONTROL_BOARD_ID_L6470 (6470)
  66. ///Motor control board id for L6472
  67. #define BSP_MOTOR_CONTROL_BOARD_ID_L6472 (6472)
  68. ///Motor control board id for L6480
  69. #define BSP_MOTOR_CONTROL_BOARD_ID_L6480 (6480)
  70. ///Motor control board id for L6482
  71. #define BSP_MOTOR_CONTROL_BOARD_ID_L6482 (6482)
  72. ///Motor control board id for L6474
  73. #define BSP_MOTOR_CONTROL_BOARD_ID_L6474 (6474)
  74. ///Motor control board id for Powerstep01
  75. #define BSP_MOTOR_CONTROL_BOARD_ID_POWERSTEP01 (0001)
  76. ///Motor control board id for L6206
  77. #define BSP_MOTOR_CONTROL_BOARD_ID_L6206 (6206)
  78. ///Motor control board id for L6208
  79. #define BSP_MOTOR_CONTROL_BOARD_ID_L6208 (6208)
  80. ///Motor control board id for STSPIN220
  81. #define BSP_MOTOR_CONTROL_BOARD_ID_STSPIN220 (220)
  82. ///Motor control board id for STSPIN240
  83. #define BSP_MOTOR_CONTROL_BOARD_ID_STSPIN240 (240)
  84. ///Motor control board id for STSPIN250
  85. #define BSP_MOTOR_CONTROL_BOARD_ID_STSPIN250 (250)
  86. /**
  87. * @}
  88. */
  89. /** @defgroup MOTOR_CONTROL_Exported_Macros MOTOR CONTROL Exported Macros
  90. * @{
  91. */
  92. #if defined ( __GNUC__ )
  93. #ifndef __weak
  94. #define __weak __attribute__((weak))
  95. #endif /* __weak */
  96. #endif /* __GNUC__ */
  97. /**
  98. * @}
  99. */
  100. /** @defgroup MOTOR_CONTROL_Weak_Function_Prototypes MOTOR CONTROL Weak Function Prototypes
  101. * @{
  102. */
  103. __weak motorDrv_t* L6474_GetMotorHandle(void);
  104. __weak motorDrv_t* l647x_GetMotorHandle(void);
  105. __weak motorDrv_t* l648x_GetMotorHandle(void);
  106. __weak motorDrv_t* Powerstep01_GetMotorHandle(void);
  107. __weak motorDrv_t* L6206_GetMotorHandle(void);
  108. __weak motorDrv_t* L6208_GetMotorHandle(void);
  109. __weak motorDrv_t* Stspin220_GetMotorHandle(void);
  110. __weak motorDrv_t* Stspin240_250_GetMotorHandle(void);
  111. /**
  112. * @}
  113. */
  114. /** @defgroup MOTOR_CONTROL_Exported_Functions MOTOR CONTROL Exported Functions
  115. * @{
  116. */
  117. void BSP_MotorControl_AttachErrorHandler(void (*callback)(uint16_t));
  118. void BSP_MotorControl_AttachFlagInterrupt(void (*callback)(void));
  119. void BSP_MotorControl_AttachBusyInterrupt(void (*callback)(void));
  120. void BSP_MotorControl_ErrorHandler(uint16_t error);
  121. void BSP_MotorControl_Init(uint16_t id, void* initDeviceParameters);
  122. void BSP_MotorControl_FlagInterruptHandler(void);
  123. uint16_t BSP_MotorControl_GetAcceleration(uint8_t deviceId);
  124. uint16_t BSP_MotorControl_GetBoardId(void);
  125. uint16_t BSP_MotorControl_GetCurrentSpeed(uint8_t deviceId);
  126. uint16_t BSP_MotorControl_GetDeceleration(uint8_t deviceId);
  127. motorState_t BSP_MotorControl_GetDeviceState(uint8_t deviceId);
  128. uint32_t BSP_MotorControl_GetFwVersion(void);
  129. int32_t BSP_MotorControl_GetMark(uint8_t deviceId);
  130. uint16_t BSP_MotorControl_GetMaxSpeed(uint8_t deviceId);
  131. uint16_t BSP_MotorControl_GetMinSpeed(uint8_t deviceId);
  132. int32_t BSP_MotorControl_GetPosition(uint8_t deviceId);
  133. void BSP_MotorControl_GoHome(uint8_t deviceId);
  134. void BSP_MotorControl_GoMark(uint8_t deviceId);
  135. void BSP_MotorControl_GoTo(uint8_t deviceId, int32_t targetPosition);
  136. void BSP_MotorControl_HardStop(uint8_t deviceId);
  137. void BSP_MotorControl_Move(uint8_t deviceId, motorDir_t direction, uint32_t stepCount);
  138. void BSP_MotorControl_ResetAllDevices(void);
  139. void BSP_MotorControl_Run(uint8_t deviceId, motorDir_t direction);
  140. bool BSP_MotorControl_SetAcceleration(uint8_t deviceId,uint16_t newAcc);
  141. bool BSP_MotorControl_SetDeceleration(uint8_t deviceId, uint16_t newDec);
  142. void BSP_MotorControl_SetHome(uint8_t deviceId, int32_t homePosition);
  143. void BSP_MotorControl_SetMark(uint8_t deviceId, int32_t markPosition);
  144. bool BSP_MotorControl_SetMaxSpeed(uint8_t deviceId, uint16_t newMaxSpeed);
  145. bool BSP_MotorControl_SetMinSpeed(uint8_t deviceId, uint16_t newMinSpeed);
  146. bool BSP_MotorControl_SoftStop(uint8_t deviceId);
  147. void BSP_MotorControl_StepClockHandler(uint8_t deviceId);
  148. void BSP_MotorControl_WaitWhileActive(uint8_t deviceId);
  149. void BSP_MotorControl_CmdDisable(uint8_t deviceId);
  150. void BSP_MotorControl_CmdEnable(uint8_t deviceId);
  151. uint32_t BSP_MotorControl_CmdGetParam(uint8_t deviceId, uint32_t param);
  152. uint16_t BSP_MotorControl_CmdGetStatus(uint8_t deviceId);
  153. void BSP_MotorControl_CmdNop(uint8_t deviceId);
  154. void BSP_MotorControl_CmdSetParam(uint8_t deviceId, uint32_t param, uint32_t value);
  155. uint16_t BSP_MotorControl_ReadStatusRegister(uint8_t deviceId);
  156. void BSP_MotorControl_ReleaseReset(uint8_t deviceId);
  157. void BSP_MotorControl_Reset(uint8_t deviceId);
  158. bool BSP_MotorControl_SelectStepMode(uint8_t deviceId, motorStepMode_t stepMode);
  159. void BSP_MotorControl_SetDirection(uint8_t deviceId, motorDir_t dir);
  160. void BSP_MotorControl_CmdGoToDir(uint8_t deviceId, motorDir_t dir, int32_t abs_pos);
  161. uint8_t BSP_MotorControl_CheckBusyHw(void);
  162. uint8_t BSP_MotorControl_CheckStatusHw(void);
  163. void BSP_MotorControl_CmdGoUntil(uint8_t deviceId, motorAction_t action, motorDir_t dir, uint32_t speed);
  164. void BSP_MotorControl_CmdHardHiZ(uint8_t deviceId);
  165. void BSP_MotorControl_CmdReleaseSw(uint8_t deviceId, motorAction_t action, motorDir_t dir);
  166. void BSP_MotorControl_CmdResetDevice(uint8_t deviceId);
  167. void BSP_MotorControl_CmdResetPos(uint8_t deviceId);
  168. void BSP_MotorControl_CmdRun(uint8_t deviceId, motorDir_t dir, uint32_t speed);
  169. void BSP_MotorControl_CmdSoftHiZ(uint8_t deviceId);
  170. void BSP_MotorControl_CmdStepClock(uint8_t deviceId, motorDir_t dir);
  171. void BSP_MotorControl_FetchAndClearAllStatus(void);
  172. uint16_t BSP_MotorControl_GetFetchedStatus(uint8_t deviceId);
  173. uint8_t BSP_MotorControl_GetNbDevices(void);
  174. bool BSP_MotorControl_IsDeviceBusy(uint8_t deviceId);
  175. void BSP_MotorControl_SendQueuedCommands(void);
  176. void BSP_MotorControl_QueueCommands(uint8_t deviceId, uint8_t command, int32_t value);
  177. void BSP_MotorControl_WaitForAllDevicesNotBusy(void);
  178. void BSP_MotorControl_BusyInterruptHandler(void);
  179. void BSP_MotorControl_CmdSoftStop(uint8_t deviceId);
  180. void BSP_MotorControl_StartStepClock(uint16_t newFreq);
  181. void BSP_MotorControl_StopStepClock(void);
  182. void BSP_MotorControl_SetDualFullBridgeConfig(uint8_t config);
  183. uint32_t BSP_MotorControl_GetBridgeInputPwmFreq(uint8_t bridgeId);
  184. void BSP_MotorControl_SetBridgeInputPwmFreq(uint8_t bridgeId, uint32_t newFreq);
  185. void BSP_MotorControl_SetStopMode(uint8_t deviceId, motorStopMode_t stopMode);
  186. motorStopMode_t BSP_MotorControl_GetStopMode(uint8_t deviceId);
  187. void BSP_MotorControl_SetDecayMode(uint8_t deviceId, motorDecayMode_t decayMode);
  188. motorDecayMode_t BSP_MotorControl_GetDecayMode(uint8_t deviceId);
  189. motorStepMode_t BSP_MotorControl_GetStepMode(uint8_t deviceId);
  190. motorDir_t BSP_MotorControl_GetDirection(uint8_t deviceId);
  191. void BSP_MotorControl_ExitDeviceFromReset(uint8_t deviceId);
  192. uint8_t BSP_MotorControl_GetTorque(uint8_t deviceId, motorTorqueMode_t torqueMode);
  193. void BSP_MotorControl_SetTorque(uint8_t deviceId, motorTorqueMode_t torqueMode, uint8_t torqueValue);
  194. void BSP_MotorControl_SetRefFreq(uint8_t refId, uint32_t newFreq);
  195. uint32_t BSP_MotorControl_GetRefFreq(uint8_t refId);
  196. void BSP_MotorControl_SetRefDc(uint8_t refId, uint8_t newDc);
  197. uint8_t BSP_MotorControl_GetRefDc(uint8_t refId);
  198. bool BSP_MotorControl_SetNbDevices(uint16_t id, uint8_t nbDevices);
  199. bool BSP_MotorControl_SetAnalogValue(uint8_t deviceId, uint32_t param, float value);
  200. float BSP_MotorControl_GetAnalogValue(uint8_t deviceId, uint32_t param);
  201. void BSP_MotorControl_SetTorqueBoostEnable(uint8_t deviceId, bool enable);
  202. bool BSP_MotorControl_GetTorqueBoostEnable(uint8_t deviceId);
  203. void BSP_MotorControl_SetTorqueBoostThreshold(uint8_t deviceId, uint16_t speedThreshold);
  204. uint16_t BSP_MotorControl_GetTorqueBoostThreshold(uint8_t deviceId);
  205. uint8_t BSP_MotorControl_GetDualFullBridgeConfig(void);
  206. /**
  207. * @}
  208. */
  209. /**
  210. * @}
  211. */
  212. /**
  213. * @}
  214. */
  215. #ifdef __cplusplus
  216. }
  217. #endif
  218. #endif /* X_NUCLEO_IHMXX_H */
  219. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/