Added all the F4 libraries to the project
[fw/stlink] / exampleF4 / CMSIS / DSP_Lib / Source / SupportFunctions / arm_fill_q15.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_fill_q15.c   
9 *   
10 * Description:  Fills a constant value into a Q15 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 * Version 0.0.7  2010/06/10    
30 *    Misra-C changes done   
31 * -------------------------------------------------------------------- */
32
33 #include "arm_math.h"
34
35 /**   
36  * @ingroup groupSupport   
37  */
38
39 /**   
40  * @addtogroup Fill   
41  * @{   
42  */
43
44 /**   
45  * @brief Fills a constant value into a Q15 vector.   
46  * @param[in]       value input value to be filled  
47  * @param[out]      *pDst points to output vector   
48  * @param[in]       blockSize length of the output vector  
49  * @return none.   
50  *   
51  */
52
53 void arm_fill_q15(
54   q15_t value,
55   q15_t * pDst,
56   uint32_t blockSize)
57 {
58   uint32_t blkCnt;                               /* loop counter */
59
60 #ifndef ARM_MATH_CM0
61
62   /* Run the below code for Cortex-M4 and Cortex-M3 */
63
64   q31_t packedValue;                             /* value packed to 32 bits */
65
66
67   /*loop Unrolling */
68   blkCnt = blockSize >> 2u;
69
70   /* Packing two 16 bit values to 32 bit value in order to use SIMD */
71   packedValue = __PKHBT(value, value, 16u);
72
73   /* First part of the processing with loop unrolling.  Compute 4 outputs at a time.   
74    ** a second loop below computes the remaining 1 to 3 samples. */
75   while(blkCnt > 0u)
76   {
77     /* C = value */
78     /* Fill the value in the destination buffer */
79     *__SIMD32(pDst)++ = packedValue;
80     *__SIMD32(pDst)++ = packedValue;
81
82     /* Decrement the loop counter */
83     blkCnt--;
84   }
85
86   /* If the blockSize is not a multiple of 4, compute any remaining output samples here.   
87    ** No loop unrolling is used. */
88   blkCnt = blockSize % 0x4u;
89
90 #else
91
92   /* Run the below code for Cortex-M0 */
93
94   /* Loop over blockSize number of values */
95   blkCnt = blockSize;
96
97 #endif /* #ifndef ARM_MATH_CM0 */
98
99   while(blkCnt > 0u)
100   {
101     /* C = value */
102     /* Fill the value in the destination buffer */
103     *pDst++ = value;
104
105     /* Decrement the loop counter */
106     blkCnt--;
107   }
108 }
109
110 /**   
111  * @} end of Fill group   
112  */