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
Diff: Components/PowerStep01/PowerStep01.h
- Revision:
- 7:9d772e2a9dbe
- Parent:
- 6:7af3838de91a
--- a/Components/PowerStep01/PowerStep01.h Mon May 08 15:41:45 2017 +0000 +++ b/Components/PowerStep01/PowerStep01.h Fri Jul 14 12:51:38 2017 +0000 @@ -87,8 +87,9 @@ PowerStep01(PinName flag_irq, PinName busy_irq, PinName standby_reset, PinName pwm, PinName ssel, DevSPI &spi) : StepperMotor(), flag_irq(flag_irq), busy_irq(busy_irq), standby_reset(standby_reset), pwm(pwm), ssel(ssel), dev_spi(spi) { /* Checking stackability. */ - if (!(numberOfDevices < MAX_NUMBER_OF_DEVICES)) + if (!(numberOfDevices < MAX_NUMBER_OF_DEVICES)) { error("Instantiation of the PowerStep01 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 * @@ -466,8 +467,11 @@ */ virtual int check_busy_hw(void) { - if (busy_irq!=0) return 0x01; - else return 0x00; + if (busy_irq!=0) { + return 0x01; + } else { + return 0x00; + } } /** @@ -478,8 +482,11 @@ */ virtual unsigned int check_status_hw(void) { - if (flag_irq!=0) return 0x01; - else return 0x00; + if (flag_irq!=0) { + return 0x01; + } else { + return 0x00; + } } /** @@ -1290,10 +1297,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); + } } /*** Component's I/O Methods ***/ @@ -1306,8 +1314,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; } @@ -1319,8 +1328,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; } @@ -1333,8 +1343,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; }