X-CUBE-SPN1-20150128 example source code for one motor compiled under mbed. Tested OK on Nucleo F401. l6474.cpp is modified from original with defines in l6474_target_config.h to select the original behaviour (motor de-energised when halted), or new mode to continue powering with a (reduced) current in the coils (braking/position hold capability). On F401 avoid using mbed's InterruptIn on pins 10-15 (any port). Beware of other conflicts! L0 & F0 are included but untested.
IHM01A1_Board_Private_Functions
[BSP, STM32F4XX_NUCLEO_IHM01A1]
Functions | |
void | BSP_MotorControlBoard_Delay (uint32_t delay) |
This function provides an accurate delay in milliseconds. | |
void | BSP_MotorControlBoard_DisableIrq (void) |
This function disable the interruptions. | |
void | BSP_MotorControlBoard_EnableIrq (void) |
This function enable the interruptions. | |
void | BSP_MotorControlBoard_GpioInit (uint8_t nbDevices) |
Initiliases the GPIOs used by the L6474s. | |
void | BSP_MotorControlBoard_Pwm1SetFreq (uint16_t newFreq) |
Sets the frequency of PWM1 used by device 0. | |
void | BSP_MotorControlBoard_Pwm2SetFreq (uint16_t newFreq) |
Sets the frequency of PWM2 used by device 1. | |
void | BSP_MotorControlBoard_Pwm3SetFreq (uint16_t newFreq) |
Sets the frequency of PWM3 used by device 2. | |
void | BSP_MotorControlBoard_PwmInit (uint8_t deviceId) |
Initialises the PWM uses by the specified device. | |
void | BSP_MotorControlBoard_PwmStop (uint8_t deviceId) |
Stops the PWM uses by the specified device. | |
void | BSP_MotorControlBoard_ReleaseReset (void) |
Releases the L6474 reset (pin set to High) of all devices. | |
void | BSP_MotorControlBoard_Reset (void) |
Resets the L6474 (reset pin set to low) of all devices. | |
void | BSP_MotorControlBoard_SetDirectionGpio (uint8_t deviceId, uint8_t gpioState) |
Set the GPIO used for the direction. | |
uint8_t | BSP_MotorControlBoard_SpiInit (void) |
Initialise the SPI used by L6474. | |
uint8_t | BSP_MotorControlBoard_SpiWriteBytes (uint8_t *pByteToTransmit, uint8_t *pReceivedByte, uint8_t nbDevices) |
Write and read SPI byte to the L6474. |
Function Documentation
void BSP_MotorControlBoard_Delay | ( | uint32_t | delay ) |
This function provides an accurate delay in milliseconds.
- Parameters:
-
[in] delay time length in milliseconds
- Return values:
-
None
Definition at line 99 of file stm32f0xx_nucleo_ihm01a1.cpp.
void BSP_MotorControlBoard_DisableIrq | ( | void | ) |
This function disable the interruptions.
- Parameters:
-
None
- Return values:
-
None
Definition at line 109 of file stm32f0xx_nucleo_ihm01a1.cpp.
void BSP_MotorControlBoard_EnableIrq | ( | void | ) |
This function enable the interruptions.
- Parameters:
-
None
- Return values:
-
None
Definition at line 119 of file stm32f0xx_nucleo_ihm01a1.cpp.
void BSP_MotorControlBoard_GpioInit | ( | uint8_t | nbDevices ) |
Initiliases the GPIOs used by the L6474s.
- Parameters:
-
[in] nbDevices number of L6474 devices
- Return values:
-
None
Definition at line 129 of file stm32f0xx_nucleo_ihm01a1.cpp.
void BSP_MotorControlBoard_Pwm1SetFreq | ( | uint16_t | newFreq ) |
Sets the frequency of PWM1 used by device 0.
- Parameters:
-
[in] newFreq in Hz
- Return values:
-
None
- Note:
- The frequency is directly the current speed of the device
Definition at line 200 of file stm32f0xx_nucleo_ihm01a1.cpp.
void BSP_MotorControlBoard_Pwm2SetFreq | ( | uint16_t | newFreq ) |
Sets the frequency of PWM2 used by device 1.
- Parameters:
-
[in] newFreq in Hz
- Return values:
-
None
- Note:
- The frequency is directly the current speed of the device
Definition at line 216 of file stm32f0xx_nucleo_ihm01a1.cpp.
void BSP_MotorControlBoard_Pwm3SetFreq | ( | uint16_t | newFreq ) |
Sets the frequency of PWM3 used by device 2.
- Parameters:
-
[in] newFreq in Hz
- Return values:
-
None
- Note:
- The frequency is directly the current speed of the device
Definition at line 231 of file stm32f0xx_nucleo_ihm01a1.cpp.
void BSP_MotorControlBoard_PwmInit | ( | uint8_t | deviceId ) |
Initialises the PWM uses by the specified device.
- Parameters:
-
[in] deviceId (from 0 to 2)
- Return values:
-
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
Definition at line 250 of file stm32f0xx_nucleo_ihm01a1.cpp.
void BSP_MotorControlBoard_PwmStop | ( | uint8_t | deviceId ) |
Stops the PWM uses by the specified device.
- Parameters:
-
[in] deviceId (from 0 to 2)
- Return values:
-
None
Definition at line 302 of file stm32f0xx_nucleo_ihm01a1.cpp.
void BSP_MotorControlBoard_ReleaseReset | ( | void | ) |
Releases the L6474 reset (pin set to High) of all devices.
- Parameters:
-
None
- Return values:
-
None
Definition at line 328 of file stm32f0xx_nucleo_ihm01a1.cpp.
void BSP_MotorControlBoard_Reset | ( | void | ) |
Resets the L6474 (reset pin set to low) of all devices.
- Parameters:
-
None
- Return values:
-
None
Definition at line 338 of file stm32f0xx_nucleo_ihm01a1.cpp.
void BSP_MotorControlBoard_SetDirectionGpio | ( | uint8_t | deviceId, |
uint8_t | gpioState | ||
) |
Set the GPIO used for the direction.
- Parameters:
-
[in] deviceId (from 0 to 2) [in] gpioState state of the direction gpio (0 to reset, 1 to set)
- Return values:
-
None
Definition at line 349 of file stm32f0xx_nucleo_ihm01a1.cpp.
uint8_t BSP_MotorControlBoard_SpiInit | ( | void | ) |
Initialise the SPI used by L6474.
- Parameters:
-
None
- Return values:
-
HAL_OK if SPI transaction is OK, HAL_KO else
Definition at line 372 of file stm32f0xx_nucleo_ihm01a1.cpp.
uint8_t BSP_MotorControlBoard_SpiWriteBytes | ( | uint8_t * | pByteToTransmit, |
uint8_t * | pReceivedByte, | ||
uint8_t | nbDevices | ||
) |
Write and read SPI byte to the L6474.
- Parameters:
-
[in] pByteToTransmit pointer to the byte to transmit [in] pReceivedByte pointer to the received byte [in] nbDevices Number of device in the SPI chain
- Return values:
-
HAL_OK if SPI transaction is OK, HAL_KO else
Definition at line 402 of file stm32f0xx_nucleo_ihm01a1.cpp.
Generated on Tue Jul 12 2022 22:53:31 by 1.7.2