你的浏览器版本过低,可能导致网站不能正常访问!
为了你能正常使用网站功能,请使用这些浏览器。

STM32 操作L6480 级联问题

[复制链接]
lixmlxm 提问时间:2020-5-13 21:26 /
  利用STM32F103RCT6的SPI2  操作两个级联在一起的L6480,用硬件SPI没有反应。用IO模拟SPI操作,后面一个有反应。前面一个始终不行。有使用过的,麻烦帮忙一下。  
收藏 评论2 发布时间:2020-5-13 21:26

举报

2个回答
butterflyspring 回答时间:2020-5-19 12:18:23
建议简单调试一下,参照官方手册,先尽量低速通讯,看看是否正确。
坛子里的大神路过也请提供一些指导
Grant_jx-82444 回答时间:2020-5-21 11:07:04
不知道你的具体使用环境,我还是告诉你去哪里找参考吧。

ST有一个3D打印机的EVK,叫STEVAL-3DP001V1,里面用的是6个L6470H级联,L6470和L6480的通讯协议和控制部分基本相同,你可以参考这个开源的代码。

1.png

源代码地址在http://www.st.com/content/st_com/en/products/embedded-software/evaluation-tool-software/stsw-3dp001.html#get-software
怪事,原来是放在github上的,怎么现在要注册才能下载了。。。工程很大,你自己去下载吧。

在UM2076里面说了,stm32_cube\Drivers\BSP\STM32F4xx-3dPrinter\stm32f4xx_3dprinter_misc.c是步进驱动相关的代码
2.png

这个驱动的文件我拷贝在这给你悄悄,不够信息就要你自己去下载完整工程啦。

/**
  ******************************************************************************
  * @file    stm32f4xx_3dPrinter_motor.c
  * @author  IPC Rennes
  * @version V1.0.0
  * @date    January 29, 2015
  * @brief   motor functions of 3D Printer BSP driver
  *  (based on L6474)
  ******************************************************************************
* @attention
  *
  * <h2><center>&copy; COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
  *
  * Redistribution and use in source and binary forms, with or without modification,
  * are permitted provided that the following conditions are met:
  *   1. Redistributions of source code must retain the above copyright notice,
  *      this list of conditions and the following disclaimer.
  *   2. Redistributions in binary form must reproduce the above copyright notice,
  *      this list of conditions and the following disclaimer in the documentation
  *      and/or other materials provided with the distribution.
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
  *      may be used to endorse or promote products derived from this software
  *      without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  ******************************************************************************
  */
  
/* Includes ------------------------------------------------------------------*/
#include "l6474.h"
#include "stm32f4xx_3dprinter_motor.h"
#include "motorcontrol.h"
/** @addtogroup BSP
  * @{
  */
/** @defgroup STM32F4XX_3DPRINTER_MOTOR
  * @{
  */   
   
/* Private constants ---------------------------------------------------------*/   
/** @defgroup STM32F4XX_3DPRINTER_MOTOR_Private_Constants
  * @{
  */   
   
/// Timer Prescaler
#define TIMER_PRESCALER (1024)
/// SPI Maximum Timeout values for flags waiting loops
#define SPIx_TIMEOUT_MAX                      ((uint32_t)0x1000)
/**
  * @}
  */
/* Private variables ---------------------------------------------------------*/
/** @defgroup STM32F4XX_3DPRINTER_MOTOR_Board_Private_Variables
  * @{
  */      
/// SPI handler declaration
static SPI_HandleTypeDef SpiHandle;
/// Timer handler for PWMX
TIM_HandleTypeDef hTimPwmX;
/// Timer handler for PWMY
TIM_HandleTypeDef hTimPwmY;
/// Timer handler for PWMZ
TIM_HandleTypeDef hTimPwmZ;
/// Timer handler for PWME1
TIM_HandleTypeDef hTimPwmE1;
/// Timer handler for PWME2
TIM_HandleTypeDef hTimPwmE2;
/// Timer handler for PWME3
TIM_HandleTypeDef hTimPwmE3;
/**
  * @}
  */
/** @defgroup STM32F4XX_3DPRINTER_MOTOR_Board_Private_Function_Prototypes
  * @{
  */   
   
void BSP_MotorControlBoard_Delay(uint32_t delay);         //Delay of the requested number of milliseconds
void BSP_MotorControlBoard_DisableIrq(void);              //Disable Irq
void BSP_MotorControlBoard_EnableIrq(void);               //Enable Irq
void BSP_MotorControlBoard_GpioInit(uint8_t nbDevices);   //Initialise GPIOs used for L6474s
void BSP_MotorControlBoard_PwmXSetFreq(uint16_t newFreq); //Set PWM_X frequency and start it
void BSP_MotorControlBoard_PwmYSetFreq(uint16_t newFreq); //Set PWM_Y frequency and start it  
void BSP_MotorControlBoard_PwmZSetFreq(uint16_t newFreq); //Set PWM_Z frequency and start it
void BSP_MotorControlBoard_PwmE1SetFreq(uint16_t newFreq); //Set PWM_E1 frequency and start it
void BSP_MotorControlBoard_PwmE2SetFreq(uint16_t newFreq); //Set PWM_E2 frequency and start it
void BSP_MotorControlBoard_PwmE3SetFreq(uint16_t newFreq); //Set PWM_E3 frequency and start it
void BSP_MotorControlBoard_PwmE4SetFreq(uint16_t newFreq); //Set PWM_E4 frequency and start it
void BSP_MotorControlBoard_PwmInit(uint8_t deviceId);    //Init the PWM of the specified device
void BSP_MotorControlBoard_PwmStop(uint8_t deviceId);    //Stop the PWM of the specified device
void BSP_MotorControlBoard_ReleaseReset(void);           //Reset the L6474 reset pin
void BSP_MotorControlBoard_Reset(void);                  //Set the L6474 reset pin
void BSP_MotorControlBoard_SetDirectionGpio(uint8_t deviceId, uint8_t gpioState); //Set direction GPIO
uint8_t BSP_MotorControlBoard_SpiInit(void);   //Initialise the SPI used for L6474s
uint8_t BSP_MotorControlBoard_SpiWriteBytes(uint8_t *pByteToTransmit, uint8_t *pReceivedByte, uint8_t nbDevices); //Write bytes to the L6474s via SPI
/**
  * @}
  */

/** @defgroup  STM32F4XX_3DPRINTER_MOTOR_Board_Private_Functions
  * @{
  */   
/******************************************************//**
* @brief This function provides an accurate delay in milliseconds
* @param[in] delay  time length in milliseconds
* @retval None
**********************************************************/
void BSP_MotorControlBoard_Delay(uint32_t delay)
{
  HAL_Delay(delay);
}
/******************************************************//**
* @brief This function disable the interruptions
* @param None
* @retval None
**********************************************************/
void BSP_MotorControlBoard_DisableIrq(void)
{
  __disable_irq();
}
/******************************************************//**
* @brief This function enable the interruptions
* @param None
* @retval None
**********************************************************/
void BSP_MotorControlBoard_EnableIrq(void)
{
  __enable_irq();
}
/******************************************************//**
* @brief  Initiliases the GPIOs used by the L6474s
* @param[in] nbDevices number of L6474 devices
* @retval None
  **********************************************************/
void BSP_MotorControlBoard_GpioInit(uint8_t nbDevices)
{
   GPIO_InitTypeDef GPIO_InitStruct;
  
  /* GPIO Ports Clock Enable */
  __GPIOA_CLK_ENABLE();
  __GPIOB_CLK_ENABLE();
  __GPIOC_CLK_ENABLE();
  __GPIOD_CLK_ENABLE();
  __GPIOE_CLK_ENABLE();
  /* Configure L6474 - DIR pin for device 0 -------------------------------*/
  GPIO_InitStruct.Pin = BSP_MOTOR_CONTROL_BOARD_DIR_X_PIN;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
  HAL_GPIO_Init(BSP_MOTOR_CONTROL_BOARD_DIR_X_PORT, &GPIO_InitStruct);
  
  /* Configure L6474 - Flag pin -------------------------------------------*/
  GPIO_InitStruct.Pin = BSP_MOTOR_CONTROL_BOARD_FLAG_PIN;
  GPIO_InitStruct.Mode = GPIO_MODE_IT_FALLING;
  GPIO_InitStruct.Pull = GPIO_PULLUP;
  GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
  HAL_GPIO_Init(BSP_MOTOR_CONTROL_BOARD_FLAG_PORT, &GPIO_InitStruct);
  
/* Set Priority of External Line Interrupt used for the Flag interrupt*/
  HAL_NVIC_SetPriority(BSP_MOTOR_CONTROL_BOARD_FLAG_IRQn, 7, 0);
   
  /* Enable the External Line Interrupt used for the Flag interrupt*/
  HAL_NVIC_EnableIRQ(BSP_MOTOR_CONTROL_BOARD_FLAG_IRQn);   
  /* Configure L6474 - CS pin ---------------------------------------------*/
  GPIO_InitStruct.Pin = BSP_MOTOR_CONTROL_BOARD_CS_PIN;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
  HAL_GPIO_Init(BSP_MOTOR_CONTROL_BOARD_CS_PORT, &GPIO_InitStruct);
  HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_CS_PORT, BSP_MOTOR_CONTROL_BOARD_CS_PIN, GPIO_PIN_SET);
  
  /* Configure L6474 - STBY/RESET pin -------------------------------------*/
  GPIO_InitStruct.Pin = BSP_MOTOR_CONTROL_BOARD_RESET_X_PIN;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
  HAL_GPIO_Init(BSP_MOTOR_CONTROL_BOARD_RESET_X_PORT, &GPIO_InitStruct);
  
  GPIO_InitStruct.Pin = BSP_MOTOR_CONTROL_BOARD_RESET_Y_PIN;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
  HAL_GPIO_Init(BSP_MOTOR_CONTROL_BOARD_RESET_Y_PORT, &GPIO_InitStruct);
  GPIO_InitStruct.Pin = BSP_MOTOR_CONTROL_BOARD_RESET_Z_PIN;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
  HAL_GPIO_Init(BSP_MOTOR_CONTROL_BOARD_RESET_Z_PORT, &GPIO_InitStruct);  
  GPIO_InitStruct.Pin = BSP_MOTOR_CONTROL_BOARD_RESET_E1_PIN;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
  HAL_GPIO_Init(BSP_MOTOR_CONTROL_BOARD_RESET_E1_PORT, &GPIO_InitStruct);   
  GPIO_InitStruct.Pin = BSP_MOTOR_CONTROL_BOARD_RESET_E2_PIN;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
  HAL_GPIO_Init(BSP_MOTOR_CONTROL_BOARD_RESET_E2_PORT, &GPIO_InitStruct);   
  
  GPIO_InitStruct.Pin = BSP_MOTOR_CONTROL_BOARD_RESET_E3_PIN;
  GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
  GPIO_InitStruct.Pull = GPIO_NOPULL;
  GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
  HAL_GPIO_Init(BSP_MOTOR_CONTROL_BOARD_RESET_E3_PORT, &GPIO_InitStruct);   
  BSP_MotorControlBoard_Reset();  
  if (nbDevices > 1)
  {
    /* Configure L6474 - DIR pin for device  1 ----------------------------*/
    GPIO_InitStruct.Pin = BSP_MOTOR_CONTROL_BOARD_DIR_Y_PIN;
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
    HAL_GPIO_Init(BSP_MOTOR_CONTROL_BOARD_DIR_Y_PORT, &GPIO_InitStruct);   
  }
  if (nbDevices > 2)
  {
    /* Configure L6474 - DIR pin for device  2 ----------------------------*/
    GPIO_InitStruct.Pin = BSP_MOTOR_CONTROL_BOARD_DIR_Z_PIN;
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
    HAL_GPIO_Init(BSP_MOTOR_CONTROL_BOARD_DIR_Z_PORT, &GPIO_InitStruct);   
  }  
  if (nbDevices > 3)
  {
    /* Configure L6474 - DIR pin for device  3 ----------------------------*/
    GPIO_InitStruct.Pin = BSP_MOTOR_CONTROL_BOARD_DIR_E1_PIN;
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
    HAL_GPIO_Init(BSP_MOTOR_CONTROL_BOARD_DIR_E1_PORT, &GPIO_InitStruct);   
  }  
    if (nbDevices > 4)
  {
    /* Configure L6474 - DIR pin for device  4 ----------------------------*/
    GPIO_InitStruct.Pin = BSP_MOTOR_CONTROL_BOARD_DIR_E2_PIN;
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
    HAL_GPIO_Init(BSP_MOTOR_CONTROL_BOARD_DIR_E2_PORT, &GPIO_InitStruct);   
  }  
  if (nbDevices > 5)
  {
    /* Configure L6474 - DIR pin for device  5 ----------------------------*/
    GPIO_InitStruct.Pin = BSP_MOTOR_CONTROL_BOARD_DIR_E3_PIN;
    GPIO_InitStruct.Mode = GPIO_MODE_OUTPUT_PP;
    GPIO_InitStruct.Pull = GPIO_NOPULL;
    GPIO_InitStruct.Speed = GPIO_SPEED_MEDIUM;
    HAL_GPIO_Init(BSP_MOTOR_CONTROL_BOARD_DIR_E3_PORT, &GPIO_InitStruct);   
  }  
}
/******************************************************//**
* @brief  Sets the frequency of PWM_X used by device 0
* @param[in] newFreq in Hz
* @retval None
* @note The frequency is directly the current speed of the device
**********************************************************/
void BSP_MotorControlBoard_PwmXSetFreq(uint16_t newFreq)
{
  uint32_t sysFreq = HAL_RCC_GetSysClockFreq();
  uint32_t period = (sysFreq/ (TIMER_PRESCALER * BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_X_FREQ_RESCALER * (uint32_t)newFreq)) - 1;
  
  __HAL_TIM_SetAutoreload(&hTimPwmX, period);
  __HAL_TIM_SetCompare(&hTimPwmX, BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_X, period >> 1);
  HAL_TIM_PWM_Start_IT(&hTimPwmX, BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_X);  
}
/******************************************************//**
* @brief  Sets the frequency of PWM_Y used by device 1
* @param[in] newFreq in Hz
* @retval None
* @note The frequency is directly the current speed of the device
**********************************************************/
void BSP_MotorControlBoard_PwmYSetFreq(uint16_t newFreq)
{
  uint32_t sysFreq = HAL_RCC_GetSysClockFreq();
  uint32_t period = (sysFreq/ (TIMER_PRESCALER * BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_Y_FREQ_RESCALER  * (uint32_t)newFreq)) - 1;
  
  __HAL_TIM_SetAutoreload(&hTimPwmY, period);
  __HAL_TIM_SetCompare(&hTimPwmY, BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_Y, period >> 1);
  HAL_TIM_PWM_Start_IT(&hTimPwmY, BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_Y);
}
/******************************************************//**
* @brief  Sets the frequency of PWM_Z used by device 2
* @param[in] newFreq in Hz
* @retval None
* @note The frequency is directly the current speed of the device
**********************************************************/
void BSP_MotorControlBoard_PwmZSetFreq(uint16_t newFreq)
{
  uint32_t sysFreq = HAL_RCC_GetSysClockFreq();
  uint32_t period = (sysFreq/ (TIMER_PRESCALER * BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_Z_FREQ_RESCALER * (uint32_t)newFreq)) - 1;
  
  __HAL_TIM_SetAutoreload(&hTimPwmZ, period);
  __HAL_TIM_SetCompare(&hTimPwmZ, BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_Z, period >> 1);
  HAL_TIM_PWM_Start_IT(&hTimPwmZ, BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_Z);  
}
/******************************************************//**
* @brief  Sets the frequency of PWM_E1 used by device 3
* @param[in] newFreq in Hz
* @retval None
* @note The frequency is directly the current speed of the device
**********************************************************/
void BSP_MotorControlBoard_PwmE1SetFreq(uint16_t newFreq)
{
  uint32_t sysFreq = HAL_RCC_GetSysClockFreq();
  uint32_t period = (sysFreq/ (TIMER_PRESCALER * BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_E1_FREQ_RESCALER * (uint32_t)newFreq)) - 1;
  
  __HAL_TIM_SetAutoreload(&hTimPwmE1, period);
  __HAL_TIM_SetCompare(&hTimPwmE1, BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_E1, period >> 1);
  HAL_TIM_PWM_Start_IT(&hTimPwmE1, BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_E1);  
}
/******************************************************//**
* @brief  Sets the frequency of PWM_E2 used by device 4
* @param[in] newFreq in Hz
* @retval None
* @note The frequency is directly the current speed of the device
**********************************************************/
void BSP_MotorControlBoard_PwmE2SetFreq(uint16_t newFreq)
{
  uint32_t sysFreq = HAL_RCC_GetSysClockFreq();
  uint32_t period = (sysFreq/ (TIMER_PRESCALER * BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_E2_FREQ_RESCALER * (uint32_t)newFreq)) - 1;
  
  __HAL_TIM_SetAutoreload(&hTimPwmE2, period);
  __HAL_TIM_SetCompare(&hTimPwmE2, BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_E2, period >> 1);
  HAL_TIM_PWM_Start_IT(&hTimPwmE2, BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_E2);  
}
/******************************************************//**
* @brief  Sets the frequency of PWM_E3 used by device 5
* @param[in] newFreq in Hz
* @retval None
* @note The frequency is directly the current speed of the device
**********************************************************/
void BSP_MotorControlBoard_PwmE3SetFreq(uint16_t newFreq)
{
  uint32_t sysFreq = HAL_RCC_GetSysClockFreq();
  uint32_t period = (sysFreq/ (TIMER_PRESCALER * BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_E3_FREQ_RESCALER * (uint32_t)newFreq)) - 1;
  
  __HAL_TIM_SetAutoreload(&hTimPwmE3, period);
  __HAL_TIM_SetCompare(&hTimPwmE3, BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_E3, period >> 1);
  HAL_TIM_PWM_Start_IT(&hTimPwmE3, BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_E3);  
}
/******************************************************//**
* @brief  Initialises the PWM uses by the specified device
* @param[in] deviceId (from 0 to 2)
* @retval None
* @note Device 0 uses PWM1 based on timer 1
* Device 1 uses PWM 2 based on timer 2
* Device 2 uses PWM3 based timer 0
**********************************************************/
void BSP_MotorControlBoard_PwmInit(uint8_t deviceId)
{
  TIM_OC_InitTypeDef sConfigOC;
  TIM_MasterConfigTypeDef sMasterConfig;
  TIM_HandleTypeDef *pHTim;
  uint32_t  channel;
  switch (deviceId)
  {
  case 0:
  default:
      pHTim = &hTimPwmX;
      pHTim->Instance = BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_X;
      channel = BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_X;
      break;
    case  1:
      pHTim = &hTimPwmY;
      pHTim->Instance = BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_Y;
      channel = BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_Y;
      break;
    case 2:
      pHTim = &hTimPwmZ;
      pHTim->Instance = BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_Z;
      channel = BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_Z;
      break;
    case 3:
      pHTim = &hTimPwmE1;
      pHTim->Instance = BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_E1;
      channel = BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_E1;
      break;
    case 4:
      pHTim = &hTimPwmE2;
      pHTim->Instance = BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_E2;
      channel = BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_E2;
      break;
    case 5:
      pHTim = &hTimPwmE3;
      pHTim->Instance = BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_E3;
      channel = BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_E3;
      break;
  }
  pHTim->Init.Prescaler = TIMER_PRESCALER -1;
  pHTim->Init.CounterMode = TIM_COUNTERMODE_UP;
  pHTim->Init.Period = 0;
  pHTim->Init.ClockDivision = TIM_CLOCKDIVISION_DIV1;
  HAL_TIM_PWM_Init(pHTim);
  
  sConfigOC.OCMode = TIM_OCMODE_PWM1;
  sConfigOC.Pulse = 0;
  sConfigOC.OCPolarity = TIM_OCPOLARITY_HIGH;
  sConfigOC.OCFastMode = TIM_OCFAST_DISABLE;
  HAL_TIM_PWM_ConfigChannel(pHTim, &sConfigOC, channel);
  
  sMasterConfig.MasterOutputTrigger = TIM_TRGO_RESET;
  sMasterConfig.MasterSlaveMode = TIM_MASTERSLAVEMODE_DISABLE;
  HAL_TIMEx_MasterConfigSynchronization(pHTim, &sMasterConfig);
}
/******************************************************//**
* @brief  Stops the PWM uses by the specified device
* @param[in] deviceId (from 0 to 2)
* @retval None
**********************************************************/
void BSP_MotorControlBoard_PwmStop(uint8_t deviceId)
{
  switch (deviceId)
  {
    case 0:
       HAL_TIM_PWM_Stop(&hTimPwmX,BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_X);
      break;
    case  1:
      HAL_TIM_PWM_Stop(&hTimPwmY,BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_Y);
      break;
    case 2:
       HAL_TIM_PWM_Stop(&hTimPwmZ,BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_Z);
      break;
    case 3:
       HAL_TIM_PWM_Stop(&hTimPwmE1,BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_E1);
      break;
    case 4:
       HAL_TIM_PWM_Stop(&hTimPwmE2,BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_E2);
      break;
    case 5:
       HAL_TIM_PWM_Stop(&hTimPwmE3,BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_E3);
      break;
  default:
      break;//ignore error
  }
}
/******************************************************//**
* @brief  Releases the L6474 reset (pin set to High) of all devices
* @param  None
* @retval None
**********************************************************/
void BSP_MotorControlBoard_ReleaseReset(void)
{
  HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_RESET_X_PORT, BSP_MOTOR_CONTROL_BOARD_RESET_X_PIN, GPIO_PIN_SET);
  HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_RESET_Y_PORT, BSP_MOTOR_CONTROL_BOARD_RESET_Y_PIN, GPIO_PIN_SET);
  HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_RESET_Z_PORT, BSP_MOTOR_CONTROL_BOARD_RESET_Z_PIN, GPIO_PIN_SET);
  HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_RESET_E1_PORT, BSP_MOTOR_CONTROL_BOARD_RESET_E1_PIN, GPIO_PIN_SET);
  HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_RESET_E2_PORT, BSP_MOTOR_CONTROL_BOARD_RESET_E2_PIN, GPIO_PIN_SET);
  HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_RESET_E3_PORT, BSP_MOTOR_CONTROL_BOARD_RESET_E3_PIN, GPIO_PIN_SET);
}
/******************************************************//**
* @brief  Resets the L6474 (reset pin set to low) of all devices
* @param  None
* @retval None
**********************************************************/
void BSP_MotorControlBoard_Reset(void)
{
  HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_RESET_X_PORT, BSP_MOTOR_CONTROL_BOARD_RESET_X_PIN, GPIO_PIN_RESET);
  HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_RESET_Y_PORT, BSP_MOTOR_CONTROL_BOARD_RESET_Y_PIN, GPIO_PIN_RESET);
  HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_RESET_Z_PORT, BSP_MOTOR_CONTROL_BOARD_RESET_Z_PIN, GPIO_PIN_RESET);
  HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_RESET_E1_PORT, BSP_MOTOR_CONTROL_BOARD_RESET_E1_PIN, GPIO_PIN_RESET);
  HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_RESET_E2_PORT, BSP_MOTOR_CONTROL_BOARD_RESET_E2_PIN, GPIO_PIN_RESET);
  HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_RESET_E3_PORT, BSP_MOTOR_CONTROL_BOARD_RESET_E3_PIN, GPIO_PIN_RESET);
}
/******************************************************//**
* @brief  Set the GPIO used for the direction
* @param[in] deviceId (from 0 to 6)
* @param[in] gpioState state of the direction gpio (0 to reset, 1 to set)
* @retval None
**********************************************************/
void BSP_MotorControlBoard_SetDirectionGpio(uint8_t deviceId, uint8_t gpioState)
{
  switch (deviceId)
  {
    case 5:
      HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_DIR_E3_PORT, BSP_MOTOR_CONTROL_BOARD_DIR_E3_PIN, (GPIO_PinState)gpioState);
      break;
    case 4:
      HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_DIR_E2_PORT, BSP_MOTOR_CONTROL_BOARD_DIR_E2_PIN, (GPIO_PinState)gpioState);
      break;
    case 3:
      HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_DIR_E1_PORT, BSP_MOTOR_CONTROL_BOARD_DIR_E1_PIN, (GPIO_PinState)gpioState);
      break;
    case 2:
      HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_DIR_Z_PORT, BSP_MOTOR_CONTROL_BOARD_DIR_Z_PIN, (GPIO_PinState)gpioState);
      break;
    case 1:
      HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_DIR_Y_PORT, BSP_MOTOR_CONTROL_BOARD_DIR_Y_PIN, (GPIO_PinState)gpioState);
      break;
    case 0:
      HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_DIR_X_PORT, BSP_MOTOR_CONTROL_BOARD_DIR_X_PIN, (GPIO_PinState)gpioState);
      break;
    default:
      ;
  }
}
/******************************************************//**
* @brief  Initialise the SPI used by L6474
* @param None
* @retval HAL_OK if SPI transaction is OK, HAL_KO else
**********************************************************/
uint8_t BSP_MotorControlBoard_SpiInit(void)
{
  HAL_StatusTypeDef status;
  
  /* Initialises the SPI  --------------------------------------------------*/
  SpiHandle.Instance               = SPIx;
  SpiHandle.Init.BaudRatePrescaler = SPI_BAUDRATEPRESCALER_32;
  SpiHandle.Init.Direction         = SPI_DIRECTION_2LINES;
  SpiHandle.Init.CLKPhase          = SPI_PHASE_2EDGE;   
  SpiHandle.Init.CLKPolarity       = SPI_POLARITY_HIGH;
  SpiHandle.Init.CRCCalculation    = SPI_CRCCALCULATION_DISABLED;
  SpiHandle.Init.CRCPolynomial     = 7;
  SpiHandle.Init.DataSize          = SPI_DATASIZE_8BIT;
  SpiHandle.Init.FirstBit          = SPI_FIRSTBIT_MSB;
  SpiHandle.Init.NSS               = SPI_NSS_SOFT;
  SpiHandle.Init.TIMode            = SPI_TIMODE_DISABLED;
  
  SpiHandle.Init.Mode = SPI_MODE_MASTER;
  
  status = HAL_SPI_Init(&SpiHandle);
  
  return (uint8_t) status;
}
/******************************************************//**
* @brief  Write and read SPI byte to the L6474
* @param[in] pByteToTransmit pointer to the byte to transmit
* @param[in] pReceivedByte pointer to the received byte
* @param[in] nbDevices Number of device in the SPI chain
* @retval HAL_OK if SPI transaction is OK, HAL_KO else
**********************************************************/
uint8_t BSP_MotorControlBoard_SpiWriteBytes(uint8_t *pByteToTransmit, uint8_t *pReceivedByte, uint8_t nbDevices)
{
  HAL_StatusTypeDef status = HAL_ERROR;
  uint32_t i;
  HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_CS_PORT, BSP_MOTOR_CONTROL_BOARD_CS_PIN, GPIO_PIN_RESET);
  for (i = 0; i < nbDevices; i++)
  {
    status = HAL_SPI_TransmitReceive(&SpiHandle, pByteToTransmit, pReceivedByte, 1, SPIx_TIMEOUT_MAX);
    if (status != HAL_OK)
    {
      break;
    }
    pByteToTransmit++;
    pReceivedByte++;
  }
  HAL_GPIO_WritePin(BSP_MOTOR_CONTROL_BOARD_CS_PORT, BSP_MOTOR_CONTROL_BOARD_CS_PIN, GPIO_PIN_SET);
  
  return (uint8_t) status;  
}

/**
  * @}
  */
/**
  * @}
  */
   
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/





/**
  ******************************************************************************
  * @file    stm32f4xx_3dPrinter_motor.h
  * @author  IPC Rennes
  * @version V1.0.0
  * @date    January 29, 2015
  * @brief   Header for motor functions of 3D Printer BSP driver
  *  (based on L6474)
  ******************************************************************************
  * @attention
  *
  * <h2><center>&copy; COPYRIGHT(c) 2014 STMicroelectronics</center></h2>
  *
  * Redistribution and use in source and binary forms, with or without modification,
  * are permitted provided that the following conditions are met:
  *   1. Redistributions of source code must retain the above copyright notice,
  *      this list of conditions and the following disclaimer.
  *   2. Redistributions in binary form must reproduce the above copyright notice,
  *      this list of conditions and the following disclaimer in the documentation
  *      and/or other materials provided with the distribution.
  *   3. Neither the name of STMicroelectronics nor the names of its contributors
  *      may be used to endorse or promote products derived from this software
  *      without specific prior written permission.
  *
  * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
  * AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
  * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
  * DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
  * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
  * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
  * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
  * CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
  * OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
  * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
  *
  ******************************************************************************  
  */
  
/* Define to prevent recursive inclusion -------------------------------------*/
#ifndef __STM32F4XX_3DPRINTER_MOTOR_H
#define __STM32F4XX_3DPRINTER_MOTOR_H
#ifdef __cplusplus
extern "C" {
#endif
/* Includes ------------------------------------------------------------------*/
//#include "stm32f4xx_nucleo.h"
#include "stm32f4xx_hal.h"
   
/** @addtogroup BSP
  * @{
  */   
   
/** @addtogroup STM32F4XX_3DPRINTER_MOTOR
  * @{   
  */   
   
/* Exported Constants --------------------------------------------------------*/
   
/** @defgroup STM32F4XX_3DPRINTER_MOTOR_Exported_Constants
  * @{
  */   
   
/******************************************************************************/
/* USE_STM32F4XX_NUCLEO                                                       */
/******************************************************************************/
/** @defgroup Constants_For_STM32F4XX_3DPRINTER_MOTOR_MOTOR  
* @{
*/   
/// Interrupt line used for L6474 FLAG
#define BSP_MOTOR_CONTROL_BOARD_FLAG_IRQn           (EXTI15_10_IRQn)
   
/// Timer used for PWM_X
#define BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_X                   (TIM1)
/// Channel Timer used for PWM_X
#define BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_X              (TIM_CHANNEL_4)
/// HAL Active Channel Timer used for PWM_X
#define BSP_MOTOR_CONTROL_BOARD_HAL_ACT_CHAN_TIMER_PWM_X      (HAL_TIM_ACTIVE_CHANNEL_4)
/// Timer Clock Enable for PWM1
#define __BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_X_CLCK_ENABLE()   __TIM1_CLK_ENABLE()
/// Timer Clock Disable for PWM1
#define __BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_X_CLCK_DISABLE()  __TIM1_CLK_DISABLE()
/// PWM_X global interrupt
#define BSP_MOTOR_CONTROL_BOARD_PWM_X_IRQn                    (TIM1_CC_IRQn)      
/// PWM1 GPIO alternate function
#define BSP_MOTOR_CONTROL_BOARD_AFx_TIMx_PWM_X                (GPIO_AF1_TIM1)
/// PWM1 frequency rescaler (1 for HW PWM, 2 for SW PWM)
#define BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_X_FREQ_RESCALER            (1)  
   
/// Timer used for PWM_Y
#define BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_Y                   (TIM2)
/// Channel Timer used for PWM_Y
#define BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_Y              (TIM_CHANNEL_3)
/// HAL Active Channel Timer used for PWM_Y
#define BSP_MOTOR_CONTROL_BOARD_HAL_ACT_CHAN_TIMER_PWM_Y      (HAL_TIM_ACTIVE_CHANNEL_3)
/// Timer Clock Enable for PWM_Y
#define __BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_Y_CLCK_ENABLE()   __TIM2_CLK_ENABLE()
/// Timer Clock Disable for PWM_Y
#define __BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_Y_CLCK_DISABLE()  __TIM2_CLK_DISABLE()
/// PWM_Y global interrupt
#define BSP_MOTOR_CONTROL_BOARD_PWM_Y_IRQn                    (TIM2_IRQn)
/// PWM_Y GPIO alternate function
#define BSP_MOTOR_CONTROL_BOARD_AFx_TIMx_PWM_Y                 (GPIO_AF1_TIM2)
/// PWM_Y frequency rescaler (1 for HW PWM, 2 for SW PWM)
#define BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_Y_FREQ_RESCALER           (1)   
   
/// Timer used for PWM_Z
#define BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_Z                   (TIM3)
/// Channel Timer used for PWM_Z
#define BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_Z              (TIM_CHANNEL_1)
/// HAL Active Channel Timer used for PWM_Z
#define BSP_MOTOR_CONTROL_BOARD_HAL_ACT_CHAN_TIMER_PWM_Z      (HAL_TIM_ACTIVE_CHANNEL_1)
/// Timer Clock Enable for PWM_Z
#define __BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_Z_CLCK_ENABLE()    __TIM3_CLK_ENABLE()
/// Timer Clock Disable for PWM_Z
#define __BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_Z_CLCK_DISABLE()   __TIM3_CLK_DISABLE()
/// PWM_Z global interrupt
#define BSP_MOTOR_CONTROL_BOARD_PWM_Z_IRQn              (TIM3_IRQn)
/// PWM_Z GPIO alternate function
#define BSP_MOTOR_CONTROL_BOARD_AFx_TIMx_PWM_Z                (GPIO_AF2_TIM3)   
/// PWM_Z frequency rescaler (1 for HW PWM, 2 for SW PWM)   
#define BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_Z_FREQ_RESCALER     (1)   
/// Timer used for PWM_E1
#define BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_E1                  (TIM4)
/// Channel Timer used for PWM_E1
#define BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_E1             (TIM_CHANNEL_1)
/// HAL Active Channel Timer used for PWM_E1
#define BSP_MOTOR_CONTROL_BOARD_HAL_ACT_CHAN_TIMER_PWM_E1     (HAL_TIM_ACTIVE_CHANNEL_1)
/// Timer Clock Enable for PWM_E1
#define __BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_E1_CLCK_ENABLE()  __TIM4_CLK_ENABLE()
/// Timer Clock Disable for PWM_E1
#define __BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_E1_CLCK_DISABLE() __TIM4_CLK_DISABLE()
/// PWM_E1 global interrupt
#define BSP_MOTOR_CONTROL_BOARD_PWM_E1_IRQn             (TIM4_IRQn)
/// PWM_E1 GPIO alternate function
#define BSP_MOTOR_CONTROL_BOARD_AFx_TIMx_PWM_E1               (GPIO_AF2_TIM4)   
/// PWM_E1 frequency rescaler (1 for HW PWM, 2 for SW PWM)   
#define BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_E1_FREQ_RESCALER    (1)   
   
/// Timer used for PWM_E2
#define BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_E2                  (TIM9)
/// Channel Timer used for PWM_E2
#define BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_E2             (TIM_CHANNEL_1)
/// HAL Active Channel Timer used for PWM_E2
#define BSP_MOTOR_CONTROL_BOARD_HAL_ACT_CHAN_TIMER_PWM_E2     (HAL_TIM_ACTIVE_CHANNEL_1)
/// Timer Clock Enable for PWM_E2
#define __BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_E2_CLCK_ENABLE()  __TIM9_CLK_ENABLE()
/// Timer Clock Disable for PWM_E2
#define __BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_E2_CLCK_DISABLE() __TIM9_CLK_DISABLE()
/// PWM_E2 global interrupt
#define BSP_MOTOR_CONTROL_BOARD_PWM_E2_IRQn             (TIM1_BRK_TIM9_IRQn)
/// PWM_E2 GPIO alternate function
#define BSP_MOTOR_CONTROL_BOARD_AFx_TIMx_PWM_E2               (GPIO_AF3_TIM9)   
/// PWM_E2 frequency rescaler (1 for HW PWM, 2 for SW PWM)   
#define BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_E2_FREQ_RESCALER    (1)   
/// Timer used for PWM_E3
#define BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_E3                  (TIM10)
/// Channel Timer used for PWM_E3
#define BSP_MOTOR_CONTROL_BOARD_CHAN_TIMER_PWM_E3             (TIM_CHANNEL_1)
/// HAL Active Channel Timer used for PWM_E3
#define BSP_MOTOR_CONTROL_BOARD_HAL_ACT_CHAN_TIMER_PWM_E3     (HAL_TIM_ACTIVE_CHANNEL_1)
/// Timer Clock Enable for PWM_E3
#define __BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_E3_CLCK_ENABLE()  __TIM10_CLK_ENABLE()
/// Timer Clock Disable for PWM_E3
#define __BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_E3_CLCK_DISABLE() __TIM10_CLK_DISABLE()
/// PWM_E3 global interrupt
#define BSP_MOTOR_CONTROL_BOARD_PWM_E3_IRQn             (TIM1_UP_TIM10_IRQn)
/// PWM_E3 GPIO alternate function
#define BSP_MOTOR_CONTROL_BOARD_AFx_TIMx_PWM_E3               (GPIO_AF3_TIM10)   
/// PWM_E3 frequency rescaler (1 for HW PWM, 2 for SW PWM)   
#define BSP_MOTOR_CONTROL_BOARD_TIMER_PWM_E3_FREQ_RESCALER    (1)   
  
/**
* @}
*/
/******************************************************************************/
/* Independent plateform definitions                                          */
/******************************************************************************/
   /** @defgroup Constants_For_Motor_GPIO_Mapping
* @{
*/   
/// GPIO Pin used for the L6474 flag pin
#define BSP_MOTOR_CONTROL_BOARD_FLAG_PIN   (GPIO_PIN_1)
/// GPIO port used for the L6474 flag pin
#define BSP_MOTOR_CONTROL_BOARD_FLAG_PORT   (GPIOE)
/// GPIO Pin used for the L6474 step clock pin of device 0  
#define BSP_MOTOR_CONTROL_BOARD_PWM_X_PIN  (GPIO_PIN_14)
/// GPIO Port used for the L6474 step clock pin of device 0
#define BSP_MOTOR_CONTROL_BOARD_PWM_X_PORT  (GPIOE)
/// GPIO Pin used for the L6474 step clock pin of device 1
#define BSP_MOTOR_CONTROL_BOARD_PWM_Y_PIN  (GPIO_PIN_10)
/// GPIO port used for the L6474 step clock pin of device 1
#define BSP_MOTOR_CONTROL_BOARD_PWM_Y_PORT  (GPIOB)
  
/// GPIO Pin used for the L6474 step clock pin of device 2
#define BSP_MOTOR_CONTROL_BOARD_PWM_Z_PIN  (GPIO_PIN_6)
/// GPIO port used for the L6474 step clock pin of device 2
#define BSP_MOTOR_CONTROL_BOARD_PWM_Z_PORT  (GPIOC)
   
/// GPIO Pin used for the L6474 step clock pin of device 3
#define BSP_MOTOR_CONTROL_BOARD_PWM_E1_PIN   (GPIO_PIN_12)
/// GPIO port used for the L6474 step clock pin of device 3
#define BSP_MOTOR_CONTROL_BOARD_PWM_E1_PORT  (GPIOD)
/// GPIO Pin used for the L6474 step clock pin of device 4
#define BSP_MOTOR_CONTROL_BOARD_PWM_E2_PIN   (GPIO_PIN_5)
/// GPIO port used for the L6474 step clock pin of device 4
#define BSP_MOTOR_CONTROL_BOARD_PWM_E2_PORT  (GPIOE)
/// GPIO Pin used for the L6474 step clock pin of device 5
#define BSP_MOTOR_CONTROL_BOARD_PWM_E3_PIN   (GPIO_PIN_8)
/// GPIO port used for the L6474 step clock pin of device 5
#define BSP_MOTOR_CONTROL_BOARD_PWM_E3_PORT  (GPIOB)
   
/// GPIO Pin used for the L6474 direction pin of device 0                      *
#define BSP_MOTOR_CONTROL_BOARD_DIR_X_PIN  (GPIO_PIN_15)
/// GPIO port used for the L6474 direction pin of device 0                     *
#define BSP_MOTOR_CONTROL_BOARD_DIR_X_PORT  (GPIOE)
/// GPIO Pin used for the L6474 direction pin of device 1                      *
#define BSP_MOTOR_CONTROL_BOARD_DIR_Y_PIN   (GPIO_PIN_9)
/// GPIO port used for the L6474 direction pin of device 1                     *
#define BSP_MOTOR_CONTROL_BOARD_DIR_Y_PORT  (GPIOE)
/// GPIO Pin used for the L6474 direction pin of device 2                      *
#define BSP_MOTOR_CONTROL_BOARD_DIR_Z_PIN   (GPIO_PIN_0)
/// GPIO port used for the L6474 direction pin of device 2                     *
#define BSP_MOTOR_CONTROL_BOARD_DIR_Z_PORT  (GPIOC)
/// GPIO Pin used for the L6474 direction pin of device 3                      *
#define BSP_MOTOR_CONTROL_BOARD_DIR_E1_PIN   (GPIO_PIN_13)
/// GPIO port used for the L6474 direction pin of device 3                     *
#define BSP_MOTOR_CONTROL_BOARD_DIR_E1_PORT  (GPIOC)
   
/// GPIO Pin used for the L6474 direction pin of device 4
#define BSP_MOTOR_CONTROL_BOARD_DIR_E2_PIN   (GPIO_PIN_6)
/// GPIO port used for the L6474 direction pin of device 4
#define BSP_MOTOR_CONTROL_BOARD_DIR_E2_PORT  (GPIOE)      
/// GPIO Pin used for the L6474 direction pin of device 5
#define BSP_MOTOR_CONTROL_BOARD_DIR_E3_PIN   (GPIO_PIN_2)
/// GPIO port used for the L6474 direction pin of device 5
#define BSP_MOTOR_CONTROL_BOARD_DIR_E3_PORT  (GPIOE)   
   
/// GPIO Pin used for the L6474 reset pin (device 0)                           *
#define BSP_MOTOR_CONTROL_BOARD_RESET_X_PIN  (GPIO_PIN_13)
/// GPIO port used for the L6474 reset  (device 0)                             *
#define BSP_MOTOR_CONTROL_BOARD_RESET_X_PORT (GPIOE)
   
/// GPIO Pin used for the L6474 reset pin  (device 1)                          *
#define BSP_MOTOR_CONTROL_BOARD_RESET_Y_PIN  (GPIO_PIN_10)
/// GPIO port used for the L6474 reset pin (device 1)                          *
#define BSP_MOTOR_CONTROL_BOARD_RESET_Y_PORT (GPIOE)   
/// GPIO Pin used for the L6474 reset pin (device 2)                           *
#define BSP_MOTOR_CONTROL_BOARD_RESET_Z_PIN  (GPIO_PIN_15)
/// GPIO port used for the L6474 reset pin (device 2)                          *
#define BSP_MOTOR_CONTROL_BOARD_RESET_Z_PORT (GPIOC)
   
/// GPIO Pin used for the L6474 reset pin (device 3)                           *
#define BSP_MOTOR_CONTROL_BOARD_RESET_E1_PIN  (GPIO_PIN_14)
/// GPIO port used for the L6474 reset pin (device 3)                          *
#define BSP_MOTOR_CONTROL_BOARD_RESET_E1_PORT (GPIOC)  
   
/// GPIO Pin used for the L6474 reset pin (device 4)
#define BSP_MOTOR_CONTROL_BOARD_RESET_E2_PIN  (GPIO_PIN_4)
/// GPIO port used for the L6474 reset pin (device 4)
#define BSP_MOTOR_CONTROL_BOARD_RESET_E2_PORT (GPIOE)  
/// GPIO Pin used for the L6474 reset pin (device 5)
#define BSP_MOTOR_CONTROL_BOARD_RESET_E3_PIN  (GPIO_PIN_3)
/// GPIO port used for the L6474 reset pin (device 5)
#define BSP_MOTOR_CONTROL_BOARD_RESET_E3_PORT (GPIOE)  
   
/// GPIO Pin used for the L6474 SPI chip select pin
#define BSP_MOTOR_CONTROL_BOARD_CS_PIN  (GPIO_PIN_4)
/// GPIO port used for the L6474 SPI chip select  pin
#define BSP_MOTOR_CONTROL_BOARD_CS_PORT (GPIOA)
/* Definition for SPIx clock resources */
/// Used SPI
#define SPIx                             (SPI1)
/// SPI clock enable
#define SPIx_CLK_ENABLE()                __SPI1_CLK_ENABLE()
/// SPI SCK enable
#define SPIx_SCK_GPIO_CLK_ENABLE()       __GPIOA_CLK_ENABLE()
/// SPI MISO enable
#define SPIx_MISO_GPIO_CLK_ENABLE()      __GPIOA_CLK_ENABLE()
/// SPI MOSI enable
#define SPIx_MOSI_GPIO_CLK_ENABLE()      __GPIOA_CLK_ENABLE()
/// SPI Force reset
#define SPIx_FORCE_RESET()               __SPI1_FORCE_RESET()
/// SPI Release reset
#define SPIx_RELEASE_RESET()             __SPI1_RELEASE_RESET()
/// SPI SCK pin
#define SPIx_SCK_PIN                     (GPIO_PIN_5)
/// SPI SCK port
#define SPIx_SCK_GPIO_PORT               (GPIOA)
/// SPI MISO pin
#define SPIx_MISO_PIN                    (GPIO_PIN_6)
/// SPI MISO port
#define SPIx_MISO_GPIO_PORT              (GPIOA)
/// SPI MOSI pin
#define SPIx_MOSI_PIN                    (GPIO_PIN_7)
/// SPI MOSI port
#define SPIx_MOSI_GPIO_PORT              (GPIOA)
/// SPI_SCK alternate function   
#define SPIx_SCK_AF                      (GPIO_AF5_SPI1)
   
/// SPI MISO AF
#define SPIx_MISO_AF                     (SPIx_SCK_AF)
/// SPI MOSI AF
#define SPIx_MOSI_AF                     (SPIx_SCK_AF)
/**
  * @}
  */
/**
  * @}
  */

/**
  * @}
  */
#ifdef __cplusplus
}
#endif
#endif /* __STM32F4XX_3DPRINTER_MOTOR_H */
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/











关于意法半导体
我们是谁
投资者关系
意法半导体可持续发展举措
创新与技术
招聘信息
联系我们
联系ST分支机构
寻找销售人员和分销渠道
社区
媒体中心
活动与培训
隐私策略
隐私策略
Cookies管理
行使您的权利
关注我们
st-img 微信公众号
st-img 手机版