Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: X_NUCLEO_COMMON ST_INTERFACES
Dependents: Stepper_Matlab_Control SunTracker_BLE Stepper_Matlab_Control MemsMotorControl ... more
Fork of X_NUCLEO_IHM01A1 by
Motor Control Library
Introduction
Library to handle the X-NUCLEO-IHM01A1 Motor Control Expansion Board based on the the L6474 component.
Daisy-Chain Configuration
This board can be stacked up to three times so that the L6474 components will be connected in daisy-chain configuration. For this purpose, some resistors must be correctly connected on the boards as depicted here below:
Platform compatibility
- NUCLEO boards have been tested with the default configuration provided by the HelloWorld_IHM01A1 example.
- LPCXpresso11U68 board has been tested with the following patch:
- to connect with a wire from the LPCX’s
D4pin to the IHM01A1’sD9pin; - to initialize the pwm PinName variable with
D4rather thanD9.
- to connect with a wire from the LPCX’s
- FRDM-K64F board has been tested with the following patch:
- to connect with a wire from the FRDM’s
D4pin to the IHM01A1’sD8pin; - to initialize the standby_reset PinName variable with
D4rather thanD8.
- to connect with a wire from the FRDM’s
Example Applications
- HelloWorld_IHM01A1
- HelloWorld_IHM01A1_2Motors
- MotorControl_IHM01A1
- MemsMotorControl
- MemsMotorControl_IHM01A1_IKS01A2
Diff: Components/l6474/l6474_class.h
- Revision:
- 32:6e5198e46287
- Parent:
- 30:a05820cfdba9
--- a/Components/l6474/l6474_class.h Fri Oct 28 13:31:51 2016 +0000
+++ b/Components/l6474/l6474_class.h Tue Feb 28 16:12:31 2017 +0000
@@ -98,8 +98,9 @@
L6474(PinName flag_irq, PinName standby_reset, PinName direction, PinName pwm, PinName ssel, DevSPI &spi) : StepperMotor(), flag_irq(flag_irq), standby_reset(standby_reset), direction(direction), pwm(pwm), ssel(ssel), dev_spi(spi)
{
/* Checking stackability. */
- if (!(number_of_devices < MAX_NUMBER_OF_DEVICES))
+ if (!(number_of_devices < MAX_NUMBER_OF_DEVICES)) {
error("Instantiation of the L6474 component failed: it can be stacked up to %d times.\r\n", MAX_NUMBER_OF_DEVICES);
+ }
/* ACTION 4 ----------------------------------------------------------*
* Initialize here the component's member variables, one variable per *
@@ -216,8 +217,7 @@
unsigned int register_value = (unsigned int) L6474_CmdGetParam((L6474_Registers_t) parameter);
float value;
- switch ((L6474_Registers_t) parameter)
- {
+ switch ((L6474_Registers_t) parameter) {
case L6474_TVAL:
value = L6474_Par_to_Tval_Current((float) register_value);
break;
@@ -368,8 +368,7 @@
{
float register_value;
- switch ((L6474_Registers_t) parameter)
- {
+ switch ((L6474_Registers_t) parameter) {
case L6474_TVAL:
register_value = L6474_Tval_Current_to_Par(value);
break;
@@ -590,8 +589,9 @@
*/
virtual bool SetStepMode(step_mode_t step_mode)
{
- if ((motorStepMode_t) step_mode > STEP_MODE_1_16)
+ if ((motorStepMode_t) step_mode > STEP_MODE_1_16) {
return false;
+ }
SoftHiZ();
L6474_SelectStepMode((motorStepMode_t) step_mode);
@@ -783,8 +783,9 @@
*/
Status_t Read(uint8_t* pBuffer, uint16_t NumBytesToRead)
{
- if (dev_spi.spi_read(pBuffer, ssel, NumBytesToRead) != 0)
+ if (dev_spi.spi_read(pBuffer, ssel, NumBytesToRead) != 0) {
return COMPONENT_ERROR;
+ }
return COMPONENT_OK;
}
@@ -796,8 +797,9 @@
*/
Status_t Write(uint8_t* pBuffer, uint16_t NumBytesToWrite)
{
- if (dev_spi.spi_write(pBuffer, ssel, NumBytesToWrite) != 0)
+ if (dev_spi.spi_write(pBuffer, ssel, NumBytesToWrite) != 0) {
return COMPONENT_ERROR;
+ }
return COMPONENT_OK;
}
@@ -810,8 +812,9 @@
*/
Status_t ReadWrite(uint8_t* pBufferToRead, uint8_t* pBufferToWrite, uint16_t NumBytes)
{
- if (dev_spi.spi_read_write(pBufferToRead, pBufferToWrite, ssel, NumBytes) != 0)
+ if (dev_spi.spi_read_write(pBufferToRead, pBufferToWrite, ssel, NumBytes) != 0) {
return COMPONENT_ERROR;
+ }
return COMPONENT_OK;
}

X-NUCLEO-IHM01A1 Stepper Motor Driver