Added all the F4 libraries to the project
[fw/stlink] / exampleF4 / CMSIS / DSP_Lib / Source / SupportFunctions / arm_q15_to_q7.c
1 /* ----------------------------------------------------------------------------   
2 * Copyright (C) 2010 ARM Limited. All rights reserved.   
3 *   
4 * $Date:        15. July 2011  
5 * $Revision:    V1.0.10  
6 *   
7 * Project:          CMSIS DSP Library   
8 * Title:                arm_q15_to_q7.c   
9 *   
10 * Description:  Converts the elements of the Q15 vector to Q7 vector. 
11 *   
12 * Target Processor: Cortex-M4/Cortex-M3/Cortex-M0
13 *  
14 * Version 1.0.10 2011/7/15 
15 *    Big Endian support added and Merged M0 and M3/M4 Source code.  
16 *   
17 * Version 1.0.3 2010/11/29  
18 *    Re-organized the CMSIS folders and updated documentation.   
19 *    
20 * Version 1.0.2 2010/11/11   
21 *    Documentation updated.    
22 *   
23 * Version 1.0.1 2010/10/05    
24 *    Production release and review comments incorporated.   
25 *   
26 * Version 1.0.0 2010/09/20    
27 *    Production release and review comments incorporated.   
28 * ---------------------------------------------------------------------------- */
29
30 #include "arm_math.h"
31
32 /**   
33  * @ingroup groupSupport   
34  */
35
36 /**   
37  * @addtogroup q15_to_x   
38  * @{   
39  */
40
41
42 /**   
43  * @brief Converts the elements of the Q15 vector to Q7 vector.    
44  * @param[in]       *pSrc points to the Q15 input vector   
45  * @param[out]      *pDst points to the Q7 output vector  
46  * @param[in]       blockSize length of the input vector   
47  * @return none.   
48  *   
49  * \par Description:   
50  *   
51  * The equation used for the conversion process is:   
52  *  
53  * <pre>   
54  *      pDst[n] = (q7_t) pSrc[n] >> 8;   0 <= n < blockSize.   
55  * </pre>  
56  *  
57  */
58
59
60 void arm_q15_to_q7(
61   q15_t * pSrc,
62   q7_t * pDst,
63   uint32_t blockSize)
64 {
65   q15_t *pIn = pSrc;                             /* Src pointer */
66   uint32_t blkCnt;                               /* loop counter */
67
68 #ifndef ARM_MATH_CM0
69
70   /* Run the below code for Cortex-M4 and Cortex-M3 */
71
72   /*loop Unrolling */
73   blkCnt = blockSize >> 2u;
74
75   /* First part of the processing with loop unrolling.  Compute 4 outputs at a time.   
76    ** a second loop below computes the remaining 1 to 3 samples. */
77   while(blkCnt > 0u)
78   {
79     /* C = (q7_t) A >> 8 */
80     /* convert from q15 to q7 and then store the results in the destination buffer */
81     *pDst++ = (q7_t) (*pIn++ >> 8);
82     *pDst++ = (q7_t) (*pIn++ >> 8);
83     *pDst++ = (q7_t) (*pIn++ >> 8);
84     *pDst++ = (q7_t) (*pIn++ >> 8);
85
86     /* Decrement the loop counter */
87     blkCnt--;
88   }
89
90   /* If the blockSize is not a multiple of 4, compute any remaining output samples here.   
91    ** No loop unrolling is used. */
92   blkCnt = blockSize % 0x4u;
93
94 #else
95
96   /* Run the below code for Cortex-M0 */
97
98   /* Loop over blockSize number of values */
99   blkCnt = blockSize;
100
101 #endif /* #ifndef ARM_MATH_CM0 */
102
103   while(blkCnt > 0u)
104   {
105     /* C = (q7_t) A >> 8 */
106     /* convert from q15 to q7 and then store the results in the destination buffer */
107     *pDst++ = (q7_t) (*pIn++ >> 8);
108
109     /* Decrement the loop counter */
110     blkCnt--;
111   }
112
113 }
114
115 /**   
116  * @} end of q15_to_x group   
117  */