From 96d6da4e252b06dcfdc041e7df23e86161c33007 Mon Sep 17 00:00:00 2001 From: rihab kouki Date: Tue, 28 Jul 2020 11:24:49 +0100 Subject: Official ARM version: v5.6.0 --- DSP/Source/ControllerFunctions/arm_pid_init_q15.c | 61 +++++++++-------------- 1 file changed, 23 insertions(+), 38 deletions(-) (limited to 'DSP/Source/ControllerFunctions/arm_pid_init_q15.c') diff --git a/DSP/Source/ControllerFunctions/arm_pid_init_q15.c b/DSP/Source/ControllerFunctions/arm_pid_init_q15.c index 61049cf..c88a3d9 100644 --- a/DSP/Source/ControllerFunctions/arm_pid_init_q15.c +++ b/DSP/Source/ControllerFunctions/arm_pid_init_q15.c @@ -3,13 +3,13 @@ * Title: arm_pid_init_q15.c * Description: Q15 PID Control initialization function * - * $Date: 27. January 2017 - * $Revision: V.1.5.1 + * $Date: 18. March 2019 + * $Revision: V1.6.0 * * Target Processor: Cortex-M cores * -------------------------------------------------------------------- */ /* - * Copyright (C) 2010-2017 ARM Limited or its affiliates. All rights reserved. + * Copyright (C) 2010-2019 ARM Limited or its affiliates. All rights reserved. * * SPDX-License-Identifier: Apache-2.0 * @@ -28,22 +28,24 @@ #include "arm_math.h" - /** - * @addtogroup PID - * @{ +/** + @addtogroup PID + @{ */ /** - * @details - * @param[in,out] *S points to an instance of the Q15 PID structure. - * @param[in] resetStateFlag flag to reset the state. 0 = no change in state 1 = reset the state. - * @return none. - * \par Description: - * \par - * The resetStateFlag specifies whether to set state to zero or not. \n - * The function computes the structure fields: A0, A1 A2 - * using the proportional gain( \c Kp), integral gain( \c Ki) and derivative gain( \c Kd) - * also sets the state variables to all zeros. + @brief Initialization function for the Q15 PID Control. + @param[in,out] S points to an instance of the Q15 PID structure + @param[in] resetStateFlag + - value = 0: no change in state + - value = 1: reset state + @return none + + @par Details + The resetStateFlag specifies whether to set state to zero or not. \n + The function computes the structure fields: A0, A1 A2 + using the proportional gain( \c Kp), integral gain( \c Ki) and derivative gain( \c Kd) + also sets the state variables to all zeros. */ void arm_pid_init_q15( @@ -53,35 +55,20 @@ void arm_pid_init_q15( #if defined (ARM_MATH_DSP) - /* Run the below code for Cortex-M4 and Cortex-M3 */ - /* Derived coefficient A0 */ S->A0 = __QADD16(__QADD16(S->Kp, S->Ki), S->Kd); /* Derived coefficients and pack into A1 */ #ifndef ARM_MATH_BIG_ENDIAN - S->A1 = __PKHBT(-__QADD16(__QADD16(S->Kd, S->Kd), S->Kp), S->Kd, 16); - #else - S->A1 = __PKHBT(S->Kd, -__QADD16(__QADD16(S->Kd, S->Kd), S->Kp), 16); - -#endif /* #ifndef ARM_MATH_BIG_ENDIAN */ - - /* Check whether state needs reset or not */ - if (resetStateFlag) - { - /* Clear the state buffer. The size will be always 3 samples */ - memset(S->state, 0, 3U * sizeof(q15_t)); - } +#endif #else - /* Run the below code for Cortex-M0 */ - - q31_t temp; /*to store the sum */ + q31_t temp; /* to store the sum */ /* Derived coefficient A0 */ temp = S->Kp + S->Ki + S->Kd; @@ -92,19 +79,17 @@ void arm_pid_init_q15( S->A1 = (q15_t) __SSAT(temp, 16); S->A2 = S->Kd; - +#endif /* #if defined (ARM_MATH_DSP) */ /* Check whether state needs reset or not */ if (resetStateFlag) { - /* Clear the state buffer. The size will be always 3 samples */ + /* Reset state to zero, The size will be always 3 samples */ memset(S->state, 0, 3U * sizeof(q15_t)); } -#endif /* #if defined (ARM_MATH_DSP) */ - } /** - * @} end of PID group + @} end of PID group */ -- cgit