1 // -*- C++ -*-
2 /** @file */
3 #pragma once
4 
5 #ifdef DOXYGEN
6 #define ARM_MATH_DSP
7 #undef ARM_MATH_MVEI
8 #undef ARM_MATH_MVEF
9 #undef ARM_MATH_NEON
10 #endif
11 
12 
13 namespace arm_cmsis_dsp {
14 
15 
16 /** \addtogroup DSPALG
17  *  @{
18  */
19 
20 #define __PACKq7(v0,v1,v2,v3) ( (((int32_t)(v0) <<  0) & (int32_t)0x000000FF) | \
21                                   (((int32_t)(v1) <<  8) & (int32_t)0x0000FF00) | \
22                                   (((int32_t)(v2) << 16) & (int32_t)0x00FF0000) | \
23                                   (((int32_t)(v3) << 24) & (int32_t)0xFF000000)  )
24 
25 
read_q15x2(Q15 const * pQ15)26 __STATIC_FORCEINLINE int32_t read_q15x2 (
27   Q15 const * pQ15)
28 {
29   int32_t val;
30   const int16_t *p=reinterpret_cast<const int16_t* >(pQ15);
31 
32 #ifdef __ARM_FEATURE_UNALIGNED
33   memcpy (&val, p, 4);
34 #else
35   val = (p[1] << 16) | (p[0] & 0x0FFFF) ;
36 #endif
37 
38   return (val);
39 };
40 
41 
42 
write_q15x2(Q15 * pQ15,int32_t value)43 __STATIC_FORCEINLINE void write_q15x2 (
44   Q15 * pQ15,
45   int32_t   value)
46 {
47   int32_t val = value;
48   int16_t *p=reinterpret_cast<int16_t* >(pQ15);
49 
50 #ifdef __ARM_FEATURE_UNALIGNED
51   memcpy (p, &val, 4);
52 #else
53   p[0] = (int16_t)(val & 0x0FFFF);
54   p[1] = (int16_t)(val >> 16);
55 #endif
56 };
57 
58 
read_q7x4(Q7 const * pQ7)59 __STATIC_FORCEINLINE int32_t read_q7x4 (
60   Q7 const * pQ7)
61 {
62   int32_t val;
63   const int8_t *p=reinterpret_cast<const int8_t*>(pQ7);
64 
65 #ifdef __ARM_FEATURE_UNALIGNED
66   memcpy (&val, p, 4);
67 #else
68   val =((p[3] & 0x0FF) << 24)  | ((p[2] & 0x0FF) << 16)  | ((p[1] & 0x0FF) << 8)  | (p[0] & 0x0FF);
69 #endif
70   return (val);
71 };
72 
73 
74 
75 
76 
77 
write_q7x4(Q7 * & pQ7,int32_t value)78 __STATIC_FORCEINLINE void write_q7x4 (
79   Q7 *& pQ7,
80   int32_t   value)
81 {
82   int8_t *p=reinterpret_cast<int8_t*>(pQ7);
83   int32_t val = value;
84 #ifdef __ARM_FEATURE_UNALIGNED
85   memcpy (p, &val, 4);
86 #else
87   p[0] = (q7_t)(val & 0x0FF);
88   p[1] = (q7_t)((val >> 8) & 0x0FF);
89   p[2] = (q7_t)((val >> 16) & 0x0FF);
90   p[3] = (q7_t)((val >> 24) & 0x0FF);
91 
92 #endif
93 };
94 
95 /*! @} */
96 
97 }
98 
99