summaryrefslogtreecommitdiff
path: root/DSP/Source/ControllerFunctions/arm_pid_init_q15.c
diff options
context:
space:
mode:
authorrihab kouki <rihab.kouki@st.com>2020-07-28 11:24:49 +0100
committerrihab kouki <rihab.kouki@st.com>2020-07-28 11:24:49 +0100
commit96d6da4e252b06dcfdc041e7df23e86161c33007 (patch)
treea262f59bb1db7ec7819acae435f5049cbe5e2354 /DSP/Source/ControllerFunctions/arm_pid_init_q15.c
parent9f95ff5b6ba01db09552b84a0ab79607060a2666 (diff)
downloadst-cmsis-core-lowfat-master.tar.gz
st-cmsis-core-lowfat-master.tar.bz2
st-cmsis-core-lowfat-master.zip
Official ARM version: v5.6.0HEADmaster
Diffstat (limited to 'DSP/Source/ControllerFunctions/arm_pid_init_q15.c')
-rw-r--r--DSP/Source/ControllerFunctions/arm_pid_init_q15.c61
1 files changed, 23 insertions, 38 deletions
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 <code>resetStateFlag</code> specifies whether to set state to zero or not. \n
- * The function computes the structure fields: <code>A0</code>, <code>A1</code> <code>A2</code>
- * 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 <code>resetStateFlag</code> specifies whether to set state to zero or not. \n
+ The function computes the structure fields: <code>A0</code>, <code>A1</code> <code>A2</code>
+ 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
*/