hi
Dependencies: ST_INTERFACES X_NUCLEO_COMMON
Fork of X_NUCLEO_IHM02A1 by
Revision 21:1b7f3e002688, committed 2017-03-01
- Comitter:
- Davidroid
- Date:
- Wed Mar 01 17:52:33 2017 +0000
- Parent:
- 20:e6fa636dbdea
- Child:
- 22:ba7f4131a5e0
- Commit message:
- Fitting mbed coding style.
Changed in this revision
--- a/BSP/x_nucleo_ihm02a1_class.cpp Tue Sep 27 13:57:51 2016 +0000
+++ b/BSP/x_nucleo_ihm02a1_class.cpp Wed Mar 01 17:52:33 2017 +0000
@@ -73,13 +73,15 @@
X_NUCLEO_IHM02A1::X_NUCLEO_IHM02A1(L6470_Init_t *init_0, L6470_Init_t *init_1, PinName flag_irq, PinName busy_irq, PinName standby_reset, PinName ssel, DevSPI *spi) : dev_spi(spi)
{
/* Checking stackability. */
- if (!(number_of_boards < EXPBRD_MOUNTED_NR_MAX))
+ if (!(number_of_boards < EXPBRD_MOUNTED_NR_MAX)) {
error("Instantiation of the X_NUCLEO_IHM02A1 expansion board failed: it can be stacked up to %d times.\r\n", EXPBRD_MOUNTED_NR_MAX);
+ }
X_NUCLEO_IHM02A1_Id = number_of_boards++;
/* SPI communication. */
- if (dev_spi == NULL)
+ if (dev_spi == NULL) {
dev_spi = new DevSPI(X_NUCLEO_IHM02A1_PIN_SPI_MOSI, X_NUCLEO_IHM02A1_PIN_SPI_MISO, X_NUCLEO_IHM02A1_PIN_SPI_SCLK);
+ }
/* Instantiating the components. */
/* ACTION 3 --------------------------------------------------------------*
@@ -95,8 +97,9 @@
/* Initializing the components. */
init_components[0] = init_0;
init_components[1] = init_1;
- if (!Init())
+ if (!Init()) {
error("Initialization of the X_NUCLEO_IHM02A1 expansion board failed.\r\n");
+ }
}
/**
@@ -114,8 +117,9 @@
X_NUCLEO_IHM02A1::X_NUCLEO_IHM02A1(L6470_Init_t *init_0, L6470_Init_t *init_1, PinName flag_irq, PinName busy_irq, PinName standby_reset, PinName ssel, PinName mosi, PinName miso, PinName sclk)
{
/* Checking stackability. */
- if (!(number_of_boards < EXPBRD_MOUNTED_NR_MAX))
+ if (!(number_of_boards < EXPBRD_MOUNTED_NR_MAX)) {
error("Instantiation of the X_NUCLEO_IHM02A1 expansion board failed: it can be stacked up to %d times.\r\n", EXPBRD_MOUNTED_NR_MAX);
+ }
X_NUCLEO_IHM02A1_Id = number_of_boards++;
/* SPI communication. */
@@ -135,8 +139,9 @@
/* Initializing the components. */
init_components[0] = init_0;
init_components[1] = init_1;
- if (!Init())
+ if (!Init()) {
error("Initialization of the X_NUCLEO_IHM02A1 expansion board failed.\r\n");
+ }
}
/**
@@ -191,8 +196,9 @@
bool X_NUCLEO_IHM02A1::Init_L6470_0(void)
{
/* Initialization. */
- if (l6470_0->Init((void *) init_components[0]) != COMPONENT_OK)
+ if (l6470_0->Init((void *) init_components[0]) != COMPONENT_OK) {
return false;
+ }
return true;
}
@@ -204,8 +210,9 @@
bool X_NUCLEO_IHM02A1::Init_L6470_1(void)
{
/* Initialization. */
- if (l6470_1->Init((void *) init_components[1]) != COMPONENT_OK)
+ if (l6470_1->Init((void *) init_components[1]) != COMPONENT_OK) {
return false;
+ }
return true;
}
--- a/BSP/x_nucleo_ihm02a1_class.h Tue Sep 27 13:57:51 2016 +0000
+++ b/BSP/x_nucleo_ihm02a1_class.h Wed Mar 01 17:52:33 2017 +0000
@@ -136,22 +136,23 @@
virtual uint32_t* PerformPreparedActions(void)
{
/* Performing pre-actions, if needed. */
- for (int m = 0; m < L6470DAISYCHAINSIZE; m++)
- {
+ for (int m = 0; m < L6470DAISYCHAINSIZE; m++) {
/*
"GetPosition()" is needed by "PrepareSetMark()" at the time when the
prepared actions get performed.
*/
- if (components[m]->GetPreparedAction() == L6470::PREPARED_SET_MARK)
+ if (components[m]->GetPreparedAction() == L6470::PREPARED_SET_MARK) {
components[m]->PrepareSetMark((uint32_t) components[m]->GetPosition());
+ }
}
/* Performing the prepared actions and getting back raw data. */
uint8_t *raw_data = components[0]->PerformPreparedActions();
/* Processing raw data. */
- for (int m = 0; m < L6470DAISYCHAINSIZE; m++)
+ for (int m = 0; m < L6470DAISYCHAINSIZE; m++) {
results[m] = components[m]->GetResult(raw_data);
+ }
/* Returning results. */
return results;
--- a/Components/l6470/l6470_class.h Tue Sep 27 13:57:51 2016 +0000
+++ b/Components/l6470/l6470_class.h Wed Mar 01 17:52:33 2017 +0000
@@ -455,9 +455,9 @@
*/
virtual bool SetStepMode(step_mode_t step_mode)
{
- if ((eMotorStepMode_t) step_mode > MICROSTEP_1_128)
+ if ((eMotorStepMode_t) step_mode > MICROSTEP_1_128) {
return false;
-
+ }
SoftHiZ();
L6470_SetParam((eL6470_RegId_t) L6470_STEP_MODE_ID, (eMotorStepMode_t) step_mode);
return true;
@@ -785,8 +785,7 @@
*/
virtual void PrepareGetDirection(void)
{
- if (!L6470_DaisyChain_HalfPrepared)
- {
+ if (!L6470_DaisyChain_HalfPrepared) {
/* To avoid deleting the previous entered command. */
L6470_DaisyChain_HalfPrepared = ONE_F;
/* Resetting commands. */
@@ -1194,8 +1193,7 @@
*/
int32_t GetResult(uint8_t *raw_data)
{
- switch (prepared_action)
- {
+ switch (prepared_action) {
case PREPARED_GET_POSITION:
return L6470_AbsPos_2_Position(L6470_ExtractReturnedData(raw_data, L6470_Register[L6470_ABS_POS_ID].LengthByte));
@@ -1418,10 +1416,11 @@
*/
int round(float f)
{
- if (f >= 0)
+ if (f >= 0) {
return (int) f + (f - (int) f < 0.5f ? 0 : 1);
- else
+ } else {
return (int) f - (f - (int) f < -0.5f ? 1 : 0);
+ }
}
@@ -1435,8 +1434,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;
}
@@ -1448,8 +1448,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;
}
@@ -1462,8 +1463,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;
}
