1 /*
2
3 Generated with CMSIS-DSP SDF Scripts.
4 The generated code is not covered by CMSIS-DSP license.
5
6 The support classes and code is covered by CMSIS-DSP license.
7
8 */
9
10
11 #include "arm_math.h"
12 #include "custom.h"
13 #include "GenericNodes.h"
14 #include "AppNodes.h"
15 #include "scheduler.h"
16
17 /* List of nodes */
18 static NodeBase *nodeArray[7]={0};
19
20 /*
21
22 Description of the scheduling. It is a list of nodes to call.
23 The values are indexes in the previous array.
24
25 */
26 static unsigned int schedule[151]=
27 {
28 6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,
29 0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,
30 1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,
31 6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,6,0,1,2,3,4,5,
32 };
33
34 /***********
35
36 FIFO buffers
37
38 ************/
39 #define FIFOSIZE0 160
40 #define FIFOSIZE1 400
41 #define FIFOSIZE2 49
42 #define FIFOSIZE3 98
43 #define FIFOSIZE4 98
44 #define FIFOSIZE5 1
45
46 #define BUFFERSIZE0 160
47 q15_t buf0[BUFFERSIZE0]={0};
48
49 #define BUFFERSIZE1 400
50 q15_t buf1[BUFFERSIZE1]={0};
51
52 #define BUFFERSIZE2 49
53 q15_t buf2[BUFFERSIZE2]={0};
54
55 #define BUFFERSIZE3 98
56 q15_t buf3[BUFFERSIZE3]={0};
57
58 #define BUFFERSIZE4 98
59 q15_t buf4[BUFFERSIZE4]={0};
60
61 #define BUFFERSIZE5 1
62 q15_t buf5[BUFFERSIZE5]={0};
63
64
65 /**************
66
67 Classes created for pure function calls (like some CMSIS-DSP functions)
68
69 ***************/
70
71
scheduler(int * error,const q15_t * window,const q15_t * coef_q15,const int coef_shift,const q15_t intercept_q15,const int intercept_shift)72 uint32_t scheduler(int *error,const q15_t *window,
73 const q15_t *coef_q15,
74 const int coef_shift,
75 const q15_t intercept_q15,
76 const int intercept_shift)
77 {
78 int sdfError=0;
79 uint32_t nbSchedule=0;
80
81 /*
82 Create FIFOs objects
83 */
84 FIFO<q15_t,FIFOSIZE0,1> fifo0(buf0);
85 FIFO<q15_t,FIFOSIZE1,1> fifo1(buf1);
86 FIFO<q15_t,FIFOSIZE2,0> fifo2(buf2);
87 FIFO<q15_t,FIFOSIZE3,1> fifo3(buf3);
88 FIFO<q15_t,FIFOSIZE4,1> fifo4(buf4);
89 FIFO<q15_t,FIFOSIZE5,1> fifo5(buf5);
90
91 /*
92 Create node objects
93 */
94
95 SlidingBuffer<q15_t,400,240> audioWin(fifo0,fifo1);
96 nodeArray[0]=(NodeBase*)&audioWin;
97
98 Feature<q15_t,400,q15_t,1> feature(fifo1,fifo2,window);
99 nodeArray[1]=(NodeBase*)&feature;
100
101 SlidingBuffer<q15_t,98,49> featureWin(fifo2,fifo3);
102 nodeArray[2]=(NodeBase*)&featureWin;
103
104 FIR<q15_t,98,q15_t,98> fir(fifo3,fifo4);
105 nodeArray[3]=(NodeBase*)&fir;
106
107 KWS<q15_t,98,q15_t,1> kws(fifo4,fifo5,coef_q15,coef_shift,intercept_q15,intercept_shift);
108 nodeArray[4]=(NodeBase*)&kws;
109
110 Sink<q15_t,1> sink(fifo5);
111 nodeArray[5]=(NodeBase*)&sink;
112
113 Source<q15_t,160> src(fifo0);
114 nodeArray[6]=(NodeBase*)&src;
115
116 /* Run several schedule iterations */
117 while(sdfError==0)
118 {
119 /* Run a schedule iteration */
120 for(unsigned long id=0 ; id < 151; id++)
121 {
122 unsigned int nodeId = schedule[id];
123 sdfError = nodeArray[nodeId]->run();
124 CHECKERROR;
125 }
126 nbSchedule++;
127 }
128
129 *error=sdfError;
130 return(nbSchedule);
131 }
132