]> rtime.felk.cvut.cz Git - pes-rpp/rpp-lib.git/blob - rpp/src/sys/notification.c
Uncommented OS and CMD dependencies now that library is in good shape.
[pes-rpp/rpp-lib.git] / rpp / src / sys / notification.c
1 /** @file notification.c
2 *   @brief User Notification Definition File
3 *   @date 15.Mar.2012
4 *   @version 03.01.00
5 *
6 *   This file  defines  empty  notification  routines.
7 *   The user needs to remove the while loop and define
8 *   the sequence.
9 *
10 */
11
12 /* Include Files */
13
14 //#include "ti_drv_esm.h"
15 //#include "sys_selftest.h"
16 //#include "ti_drv_adc.h"
17 //#include "ti_drv_can.h"
18 //#include "ti_drv_gio.h"
19 //#include "ti_drv_lin.h"
20 //#include "ti_drv_mibspi.h"
21 //#include "ti_drv_sci.h"
22 //#include "ti_drv_het.h"
23 //#include "ti_drv_i2c.h"
24 /* USER CODE BEGIN (0) */
25 //#include "FreeRTOS.h"
26 //#include "os_semphr.h"
27 //#include "os_task.h"
28
29 #include "sys/sys.h"
30
31 /* USER CODE END */
32
33 void esmGroup1Notification(uint32_t channel)
34 {
35 /*  enter user code and remove the while loop... */
36     while(1);
37 /* USER CODE BEGIN (1) */
38 /* USER CODE END */
39
40 }
41
42 /* USER CODE BEGIN (2) */
43 /* USER CODE END */
44
45 void esmGroup2Notification(uint32_t channel)
46 {
47 /*  enter user code and remove the while loop... */
48     while(1);
49 /* USER CODE BEGIN (3) */
50 /* USER CODE END */
51
52 }
53
54 /* USER CODE BEGIN (4) */
55 /* USER CODE END */
56
57 void memoryPort0TestFailNotification(uint32_t groupSelect, uint32_t dataSelect, uint32_t address, uint32_t data)
58 {
59 /*  enter user code and remove the while loop... */
60     while(1);
61 /* USER CODE BEGIN (5) */
62 /* USER CODE END */
63
64 }
65
66 /* USER CODE BEGIN (6) */
67 /* USER CODE END */
68
69 void memoryPort1TestFailNotification(uint32_t groupSelect, uint32_t dataSelect, uint32_t address, uint32_t data)
70 {
71 /*  enter user code and remove the while loop... */
72     while(1);
73 /* USER CODE BEGIN (7) */
74 /* USER CODE END */
75
76 }
77
78 /* USER CODE BEGIN (8) */
79 /* USER CODE END */
80
81 /* USER CODE BEGIN (12) */
82 /** @brief Semaphore blocking task when it waits for interrupt signaling message receive
83  *
84  */
85 // FIXME It seems that all this are test application specific, because no one
86 // else in the library uses this variables. The functionality the notification
87 // provides could be replaced with a proper interface between subsystems.
88 // This where called extern on the file, which is not a good approach to include
89 // application specific variables in lower layers, coupling bidireccionally both
90 // layers.
91 // This was moved from cmd_can.c
92 /** Semaphore used for blocking task until message is received */
93 xSemaphoreHandle canMsgReceived;
94 /** Semaphore used for blocking task until message is sent */
95 xSemaphoreHandle canMsgSent;
96 /** Pointer to Destination CAN registers */
97 canBASE_t* canDst;
98 /** Pointer to Source CAN registers */
99 canBASE_t* canSrc;
100 /** Can message box for received messages */
101 uint32_t canMsgBox;
102 /** Error counter for errors in sending */
103 uint32_t canSendError;
104 /** Error counter for errors in receiving */
105 uint32_t canRecError;
106
107 /* USER CODE END */
108 void canErrorNotification(canBASE_t *node, uint32_t notification)
109 {
110 /* USER CODE BEGIN (13) */
111
112     if (node == canSrc) {
113         canSendError = notification;
114         xSemaphoreGiveFromISR(canMsgSent, NULL);
115     }
116     if (node == canDst) {
117         canRecError = notification;
118         xSemaphoreGiveFromISR(canMsgReceived, NULL);
119     }
120
121 /* USER CODE END */
122
123 }
124
125 /* USER CODE BEGIN (14) */
126 /* USER CODE END */
127
128 void canMessageNotification(canBASE_t *node, uint32_t messageBox)
129 {
130 /* USER CODE BEGIN (15) */
131
132     if (messageBox == canMsgBox)
133     {
134         if (node == canDst) {
135             // node 2 - receive testloopback message complete
136             while(!canIsRxMessageArrived(node, canMsgBox))
137                 ;
138             xSemaphoreGiveFromISR(canMsgReceived, NULL);
139         }
140         if (node == canSrc) {
141             xSemaphoreGiveFromISR(canMsgSent, NULL);
142         }
143     }
144 /* USER CODE END */
145 }
146
147 /* USER CODE BEGIN (16) */
148 /* USER CODE END */
149 void gioNotification(int bit)
150 {
151 /*  enter user code and remove the while loop... */
152     while(1);
153 /* USER CODE BEGIN (19) */
154 /* USER CODE END */
155
156 }
157
158 /* USER CODE BEGIN (20) */
159 /* USER CODE END */
160 void i2cNotification(i2cBASE_t *i2c, uint32_t flags)
161 {
162 /*  enter user code and remove the while loop... */
163     while(1);
164 /* USER CODE BEGIN (21) */
165 /* USER CODE END */
166
167 }
168
169 /* USER CODE BEGIN (24) */
170 /* USER CODE END */
171 void mibspiNotification(mibspiBASE_t *mibspi, uint32_t flags)
172 {
173 /*  enter user code and remove the while loop... */
174     while(1);
175 /* USER CODE BEGIN (25) */
176 /* USER CODE END */
177
178 }
179
180 /* USER CODE BEGIN (26) */
181 /* USER CODE END */
182
183 void mibspiGroupNotification(mibspiBASE_t *mibspi, uint32_t group)
184 {
185 /*  enter user code and remove the while loop... */
186     while(1);
187 /* USER CODE BEGIN (27) */
188 /* USER CODE END */
189
190 }
191 /* USER CODE BEGIN (28) */
192 /* USER CODE END */
193
194 void sciNotification(sciBASE_t *sci, uint32_t flags)
195 {
196 /* USER CODE BEGIN (29) */
197     if (sci == sciREG) {
198         if (flags & SCI_RX_INT) {
199             sciReceive(sci, 1, NULL);   // Restart receiving
200         }
201     }
202 /* USER CODE END */
203
204 }
205
206 /* USER CODE BEGIN (30) */
207 /* USER CODE END */
208 void pwmNotification(hetBASE_t * hetREG,uint32_t pwm, uint32_t notification)
209 {
210 /*  enter user code and remove the while loop... */
211     while(1);
212 /* USER CODE BEGIN (33) */
213 /* USER CODE END */
214
215 }
216
217 /* USER CODE BEGIN (34) */
218 /* USER CODE END */
219
220 void edgeNotification(hetBASE_t * hetREG,uint32_t edge)
221 {
222 /*  enter user code and remove the while loop... */
223     while(1);
224 /* USER CODE BEGIN (35) */
225 /* USER CODE END */
226
227 }
228
229 /* USER CODE BEGIN (36) */
230 /* USER CODE END */
231
232 void hetNotification(hetBASE_t *het, uint32_t offset)
233 {
234 /*  enter user code and remove the while loop... */
235     while(1);
236 /* USER CODE BEGIN (37) */
237 /* USER CODE END */
238
239 }
240
241 /** Semaphore used to stop command, until message is received */
242 xSemaphoreHandle linMsgReceived;
243 /** Semaphore used to stop command, until ID is received */
244 xSemaphoreHandle linIDReceived;
245 void linNotification(linBASE_t *lin, uint32_t flags)
246 {
247     /* FIXME Moved code from somewhere else. It was in cmd_lin.c
248      * It seems that nobody in the library uses this.
249      * sys/ti_drv_lin.c calls this function from linLowLevelInterrupt()
250      * The function prototipe is in sys/ti_drv_lin.h, so maybe it should be
251      * better to move it there, but because it is a "high-level" notification
252      * it could be here.
253      */
254     if (flags & LIN_ID_INT) {
255         xSemaphoreGiveFromISR(linIDReceived, NULL);
256     }
257     if (flags & LIN_RX_INT) {
258         lin->FLR |= (1 << 9);
259         xSemaphoreGiveFromISR(linMsgReceived, NULL);
260     }
261 }
262
263
264 #pragma INTERRUPT(EMACCore0RxIsr, FIQ)
265 void EMACCore0RxIsr(void)
266 {
267     /* FIXME was in cmd_emac.c and should move somewhere else.
268     rx_irq_cnt++;
269
270     // We know we have only one RX Packet Buffer descriptor --
271     // so we write it in CP to disable interrupt
272     EMACRxCPWrite(emacBase, channel, (unsigned int)rx_desc);
273     EMACCoreIntAck(emacBase, EMAC_INT_CORE0_RX);
274     */
275 }
276
277 #pragma INTERRUPT(EMACCore0TxIsr, FIQ)
278 void EMACCore0TxIsr(void)
279 {
280     /* FIXME Was in cmd_emac.c and should move somewhere else
281     tx_irq_cnt++;
282     // If is not being processed by the EMAC anymore
283     if (!(fr1.PktFlgLen & EMAC_DSC_FLAG_OWNER)) {
284         EMACTxCPWrite(emacBase, channel, (unsigned int)&fr1);
285         EMACCoreIntAck(emacBase, EMAC_INT_CORE0_TX);
286     }
287     */
288 }
289
290
291 /* USER CODE BEGIN (38) */
292 /* USER CODE END */