Personal fork of the library
Fork of X_NUCLEO_IHM01A1 by
Diff: Components/l6474/l6474_class.cpp
- Revision:
- 7:f7e0c3621f77
- Parent:
- 6:a47569fc7534
- Child:
- 13:ba2728afe4c2
--- a/Components/l6474/l6474_class.cpp Thu Nov 19 10:56:34 2015 +0000 +++ b/Components/l6474/l6474_class.cpp Fri Nov 20 18:00:03 2015 +0000 @@ -102,21 +102,6 @@ } /********************************************************** - * @brief Attaches a user callback to the flag Interrupt - * The call back will be then called each time the status - * flag pin will be pulled down due to the occurrence of - * a programmed alarms ( OCD, thermal pre-warning or - * shutdown, UVLO, wrong command, non-performable command) - * @param[in] callback Name of the callback to attach - * to the Flag Interrupt - * @retval None - **********************************************************/ -void L6474::L6474_AttachFlagInterrupt(void (*callback)(void)) -{ - flagInterruptCallback = (void (*)(void))callback; -} - -/********************************************************** * @brief Starts the L6474 library * @retval COMPONENT_OK in case of success **********************************************************/ @@ -357,28 +342,6 @@ } } -#if 0 -/********************************************************** - * @brief Resets all L6474 devices - * @param None - * @retval None - **********************************************************/ -void L6474::L6474_ResetAllDevices(void) -{ - uint8_t loop; - - for (loop = 0; loop < numberOfDevices; loop++) - { - /* Stop movement and disable power stage*/ - L6474_HardStop(loop); - } - L6474_Reset(); - L6474_Delay(1); // Reset pin must be forced low for at least 10us - L6474_ReleaseReset(); - L6474_Delay(1); -} -#endif - /********************************************************** * @brief Runs the motor. It will accelerate from the min * speed up to the max speed by using the device acceleration. @@ -551,10 +514,10 @@ /********************************************************** * @brief Issues the GetParam command to the L6474 of the specified device - * @param[in] param Register adress (L6474_ABS_POS, L6474_MARK,...) + * @param[in] parameter Register adress (L6474_ABS_POS, L6474_MARK,...) * @retval Register value **********************************************************/ -uint32_t L6474::L6474_CmdGetParam(uint32_t param) +uint32_t L6474::L6474_CmdGetParam(L6474_Registers_t parameter) { uint32_t i; uint32_t spiRxData; @@ -583,21 +546,21 @@ spiRxBursts[3][i] = 0; } - switch (param) + switch (parameter) { case L6474_ABS_POS: ; case L6474_MARK: - spiTxBursts[0][spiIndex] = ((uint8_t)L6474_GET_PARAM )| (param); + spiTxBursts[0][spiIndex] = ((uint8_t)L6474_GET_PARAM )| (parameter); maxArgumentNbBytes = 3; break; case L6474_EL_POS: ; case L6474_CONFIG: ; case L6474_STATUS: - spiTxBursts[1][spiIndex] = ((uint8_t)L6474_GET_PARAM )| (param); + spiTxBursts[1][spiIndex] = ((uint8_t)L6474_GET_PARAM )| (parameter); maxArgumentNbBytes = 2; break; default: - spiTxBursts[2][spiIndex] = ((uint8_t)L6474_GET_PARAM )| (param); + spiTxBursts[2][spiIndex] = ((uint8_t)L6474_GET_PARAM )| (parameter); maxArgumentNbBytes = 1; } @@ -629,7 +592,7 @@ * @retval Status Register value * @note Once the GetStatus command is performed, the flags of the status register * are reset. This is not the case when the status register is read with the - * GetParam command (via the functions L6474ReadStatusRegister or L6474CmdGetParam). + * GetParam command (via the functions L6474ReadStatusRegister or L6474_CmdGetParam). **********************************************************/ uint16_t L6474::L6474_CmdGetStatus(void) { @@ -687,11 +650,11 @@ /********************************************************** * @brief Issues the SetParam command to the L6474 of the specified device - * @param[in] param Register adress (L6474_ABS_POS, L6474_MARK,...) + * @param[in] parameter Register adress (L6474_ABS_POS, L6474_MARK,...) * @param[in] value Value to set in the register * @retval None **********************************************************/ -void L6474::L6474_CmdSetParam(uint32_t param, uint32_t value) +void L6474::L6474_CmdSetParam(L6474_Registers_t parameter, uint32_t value) { uint32_t i; uint8_t maxArgumentNbBytes = 0; @@ -715,23 +678,23 @@ spiTxBursts[3][i] = L6474_NOP; } - switch (param) + switch (parameter) { case L6474_ABS_POS: ; case L6474_MARK: - spiTxBursts[0][spiIndex] = param; + spiTxBursts[0][spiIndex] = parameter; spiTxBursts[1][spiIndex] = (uint8_t)(value >> 16); spiTxBursts[2][spiIndex] = (uint8_t)(value >> 8); maxArgumentNbBytes = 3; break; case L6474_EL_POS: ; case L6474_CONFIG: - spiTxBursts[1][spiIndex] = param; + spiTxBursts[1][spiIndex] = parameter; spiTxBursts[2][spiIndex] = (uint8_t)(value >> 8); maxArgumentNbBytes = 2; break; default: - spiTxBursts[2][spiIndex] = param; + spiTxBursts[2][spiIndex] = parameter; maxArgumentNbBytes = 1; break; } @@ -961,29 +924,8 @@ } else { - while(1) - { - /* Infinite loop */ - } - } -} - -/********************************************************** - * @brief Handlers of the flag interrupt which calls the user callback (if defined) - * @param None - * @retval None - **********************************************************/ -void L6474::L6474_FlagInterruptHandler(void) -{ - if (flagInterruptCallback != 0) - { - /* Set isr flag */ - isrFlag = TRUE; - - flagInterruptCallback(); - - /* Reset isr flag */ - isrFlag = FALSE; + /* Aborting the program. */ + exit(EXIT_FAILURE); } }