Added all the F4 libraries to the project
[fw/stlink] / exampleF4 / CMSIS / DSP_Lib / Source / SupportFunctions / arm_q7_to_float.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_q7_to_float.c   
9 *   
10 * Description:  Converts the elements of the Q7 vector to floating-point 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  * @defgroup q7_to_x  Convert 8-bit Integer value   
38  */
39
40 /**   
41  * @addtogroup q7_to_x   
42  * @{   
43  */
44
45 /**   
46  * @brief Converts the elements of the Q7 vector to floating-point vector.   
47  * @param[in]       *pSrc points to the Q7 input vector   
48  * @param[out]      *pDst points to the floating-point output vector  
49  * @param[in]       blockSize length of the input vector   
50  * @return none.   
51  *                  
52  * \par Description:   
53  *   
54  * The equation used for the conversion process is:   
55  *  
56  * <pre>   
57  *      pDst[n] = (float32_t) pSrc[n] / 128;   0 <= n < blockSize.   
58  * </pre>   
59  *  
60  */
61
62
63 void arm_q7_to_float(
64   q7_t * pSrc,
65   float32_t * pDst,
66   uint32_t blockSize)
67 {
68   q7_t *pIn = pSrc;                              /* Src pointer */
69   uint32_t blkCnt;                               /* loop counter */
70
71
72 #ifndef ARM_MATH_CM0
73
74   /* Run the below code for Cortex-M4 and Cortex-M3 */
75
76   /*loop Unrolling */
77   blkCnt = blockSize >> 2u;
78
79   /* First part of the processing with loop unrolling.  Compute 4 outputs at a time.   
80    ** a second loop below computes the remaining 1 to 3 samples. */
81   while(blkCnt > 0u)
82   {
83     /* C = (float32_t) A / 128 */
84     /* convert from q7 to float and then store the results in the destination buffer */
85     *pDst++ = ((float32_t) * pIn++ / 128.0f);
86     *pDst++ = ((float32_t) * pIn++ / 128.0f);
87     *pDst++ = ((float32_t) * pIn++ / 128.0f);
88     *pDst++ = ((float32_t) * pIn++ / 128.0f);
89
90     /* Decrement the loop counter */
91     blkCnt--;
92   }
93
94   /* If the blockSize is not a multiple of 4, compute any remaining output samples here.   
95    ** No loop unrolling is used. */
96   blkCnt = blockSize % 0x4u;
97
98 #else
99
100   /* Run the below code for Cortex-M0 */
101
102   /* Loop over blockSize number of values */
103   blkCnt = blockSize;
104
105 #endif /* #ifndef ARM_MATH_CM0 */
106
107   while(blkCnt > 0u)
108   {
109     /* C = (float32_t) A / 128 */
110     /* convert from q7 to float and then store the results in the destination buffer */
111     *pDst++ = ((float32_t) * pIn++ / 128.0f);
112
113     /* Decrement the loop counter */
114     blkCnt--;
115   }
116 }
117
118 /**   
119  * @} end of q7_to_x group   
120  */