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