2.3.1.2
Motor control BSP
,
, etc. This is done via a couple of c/h files: MotorControl/motorcontrol.c/h,
which defines all the functions to configure and control the motor driver. These functions are then mapped to
the functions of the motor driver component used on the given expansion board via the structure file: motorDrv_t
(defined in Components\Common\motor.h).
This structure defines a list of function pointers filled during its instantiation in the corresponding motor driver
component.
For
, the structure instance is called stspin240_250Drv (see file
BSP\Components\stspin240_250\stspin240_250.c)
As the motor control BSP is common for all motor driver expansion boards, some functions are not available for
all expansion boards. In this case, during the instantiation of the motorDrv_t structure in the driver component, the
unavailable functions are replaced by a null pointer.
2.3.1.3
Stspin240_250 BSP component
The stspin240_250 BSP component provides the driver functions of the
low voltage dual brush DC
motor driver in the folder stm32_cube\Drivers\BSP\Components\stspin240_250, which contains:
•
stspin240_250.c:
Stspin240_250 driver core functions
•
stspin240_250.h:
declaration of the Stspin240_250 driver functions and their associated definitions
•
stspin240_250_target_config.h:
of brush DC motors, bridge input PWMs frequency)
expansion board, this
component requires the compilation flag declaration: STSPIN_240.
2.3.2
Project folder
For each
development board, the example projects are in the folder
stm32_cube\Projects\Multi\Examples\MotionControl\: IHM12A1_ExampleFor2BiDirMotors (examples of control
functions for two bidirectional brush DC motor driving).
There is a dedicated folder for the target IDE:
•
EWARM
containing the project files for IAR
•
MDK-ARM
containing the project files for Keil
•
STM32CubeIDE
containing the project files for
Each example also has the following code files:
•
inc\main.h
: main header file
•
inc\ stm32xxxx_hal_conf.h
: HAL configuration file
•
inc\stm32xxxx_it.h
: header for the interrupt handler
•
src\main.c:
main program (code of the example which is based on the motor control library for
)
•
src\stm32xxxx_hal_msp.c
: HAL initialization routines
•
src\stm32xxxx_it.c
: interrupt handler
•
src\system_stm32xxxx.c
: system initialization
•
src\clock_xx.c
: clock initialization
2.4
Software required resources
and the MCU communicate through GPIOs:
•
1 common GPIO for the flag interrupt (overcurrent detection or overtemperature protection) and the enable
pin
•
2 GPIOs to generate a PWM for each bridge input (PWMA and PWMB)
•
2 GPIOs for the bridge input phase and to set the motor direction (PHA/DIR_A and PHB/DIR_B)
•
1 GPIO to generate a PWM for REF level setup
•
1 GPIO to set/reset the reset pin
UM2110
Software required resources
UM2110
-
Rev 2
page 5/14