summaryrefslogtreecommitdiff
path: root/DSP/Source/ControllerFunctions/arm_pid_init_q31.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_q31.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_q31.c')
-rw-r--r--DSP/Source/ControllerFunctions/arm_pid_init_q31.c45
1 files changed, 21 insertions, 24 deletions
diff --git a/DSP/Source/ControllerFunctions/arm_pid_init_q31.c b/DSP/Source/ControllerFunctions/arm_pid_init_q31.c
index 17b3b09..1625a5f 100644
--- a/DSP/Source/ControllerFunctions/arm_pid_init_q31.c
+++ b/DSP/Source/ControllerFunctions/arm_pid_init_q31.c
@@ -3,13 +3,13 @@
* Title: arm_pid_init_q31.c
* Description: Q31 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
+ @{
*/
/**
- * @brief Initialization function for the Q31 PID Control.
- * @param[in,out] *S points to an instance of the Q31 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 Q31 PID Control.
+ @param[in,out] S points to an instance of the Q31 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_q31(
@@ -53,20 +55,15 @@ void arm_pid_init_q31(
#if defined (ARM_MATH_DSP)
- /* Run the below code for Cortex-M4 and Cortex-M3 */
-
/* Derived coefficient A0 */
S->A0 = __QADD(__QADD(S->Kp, S->Ki), S->Kd);
/* Derived coefficient A1 */
S->A1 = -__QADD(__QADD(S->Kd, S->Kd), S->Kp);
-
#else
- /* Run the below code for Cortex-M0 */
-
- q31_t temp;
+ q31_t temp; /* to store the sum */
/* Derived coefficient A0 */
temp = clip_q63_to_q31((q63_t) S->Kp + S->Ki);
@@ -84,12 +81,12 @@ void arm_pid_init_q31(
/* 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(q31_t));
}
}
/**
- * @} end of PID group
+ @} end of PID group
*/