00001 /* ---------------------------------------------------------------------- 00002 * Copyright (C) 2011 ARM Limited. All rights reserved. 00003 * 00004 * $Date: 15. December 2011 00005 * $Revision: V2.0.0 00006 * 00007 * Project: Cortex-R DSP Library 00008 * Title: arm_pid_init_q15.c 00009 * 00010 * Description: Q15 PID Control initialization function 00011 * 00012 * Target Processor: Cortex-R4/R5 00013 * 00014 * Version 1.0.0 2011/03/08 00015 * Alpha release. 00016 * 00017 * Version 1.0.1 2011/09/30 00018 * Beta release. 00019 * 00020 * Version 2.0.0 2011/12/15 00021 * Final release. 00022 * 00023 * -------------------------------------------------------------------- */ 00024 #include "arm_math.h" 00025 00044 void arm_pid_init_q15( 00045 arm_pid_instance_q15 * S, 00046 int32_t resetStateFlag) 00047 { 00048 /* Derived coefficient A0 */ 00049 S->A0 = __QADD16(__QADD16(S->Kp, S->Ki), S->Kd); 00050 00051 /* Derived coefficients and pack into A1 */ 00052 #ifndef ARM_MATH_BIG_ENDIAN 00053 S->A1 = __PKHBT(-__QADD16(__QADD16(S->Kd, S->Kd), S->Kp), S->Kd, 16); 00054 00055 #else 00056 00057 S->A1 = __PKHBT(S->Kd, -__QADD16(__QADD16(S->Kd, S->Kd), S->Kp), 16); 00058 00059 #endif /* #ifndef ARM_MATH_BIG_ENDIAN */ 00060 /* Check whether state needs reset or not */ 00061 if(resetStateFlag) 00062 { 00063 /* Clear the state buffer. The size will be always 3 samples */ 00064 memset(S->state, 0, 3u * sizeof(q15_t)); 00065 } 00066 00067 } 00068
1.7.2