]> rtime.felk.cvut.cz Git - arc.git/blob - examples/pwm_node/Hooks.c
Renamed USE_DEBUG to USE_DEBUG_PRINT, for now. Updates to kernel testsystem and kernel.
[arc.git] / examples / pwm_node / Hooks.c
1 /* -------------------------------- Arctic Core ------------------------------
2  * Arctic Core - the open source AUTOSAR platform http://arccore.com
3  *
4  * Copyright (C) 2009  ArcCore AB <contact@arccore.com>
5  *
6  * This source code is free software; you can redistribute it and/or modify it
7  * under the terms of the GNU General Public License version 2 as published by the
8  * Free Software Foundation; See <http://www.gnu.org/licenses/old-licenses/gpl-2.0.txt>.
9  *
10  * This program is distributed in the hope that it will be useful, but
11  * WITHOUT ANY WARRANTY; without even the implied warranty of MERCHANTABILITY
12  * or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License
13  * for more details.
14  * -------------------------------- Arctic Core ------------------------------*/
15
16
17
18
19
20
21
22
23 #include "Os.h"
24 #include "Pwm.h"
25 #include <stdio.h>
26 #include <assert.h>
27 #define USE_TRACE       1
28 #define USE_DEBUG_PRINT 1
29 #include "Trace.h"
30
31 /* Notification callback from channel 0 */
32 void MyPwmNotificationRoutine(void) {
33         static uint32 count = 0;
34         static uint32 highcount = 0;
35         static uint32 lowcount = 0;
36         Pwm_OutputStateType outputState = Pwm_GetOutputState(PWM_CHANNEL_1);
37
38         if (outputState == PWM_HIGH) {
39                 highcount++;
40         } else {
41                 lowcount++;
42         }
43
44         count++;
45 }
46
47
48 /* Global hooks */
49 ProtectionReturnType ProtectionHook( StatusType FatalError ) {
50         dbg_printf("## ProtectionHook\n");
51         return PRO_KILLAPPL;
52 }
53
54 void StartupHook( void ) {
55         dbg_printf("## StartupHook\n");
56
57         uint32_t sys_freq = McuE_GetSystemClock();
58
59         dbg_printf("Sys clock %d Hz\n",sys_freq);
60 }
61
62 void ShutdownHook( StatusType Error ) {
63         dbg_printf("## ShutdownHook\n");
64         while(1);
65 }
66
67 void ErrorHook( StatusType Error ) {
68         DisableAllInterrupts();
69
70         dbg_printf("## ErrorHook err=%d\n",Error);
71         while(1);
72 }
73
74 void PreTaskHook( void ) {
75         TaskType task;
76         GetTaskID(&task);
77         if( task > 10 ) {
78                 while(1);
79         }
80 //      dbg_printf("## PreTaskHook, taskid=%d\n",task);
81 }
82
83 void PostTaskHook( void ) {
84         TaskType task;
85         GetTaskID(&task);
86         if( task > 10 ) {
87                 while(1);
88         }
89 //      dbg_printf("## PostTaskHook, taskid=%d\n",task);
90 }
91
92 #if 0
93 struct OsHooks os_conf_global_hooks = {
94                 .StartupHook = StartupHook,
95                 .ProtectionHook = ProtectionHook,
96                 .ShutdownHook = ShutdownHook,
97                 .ErrorHook = ErrorHook,
98                 .PreTaskHook = PreTaskHook,
99                 .PostTaskHook = PostTaskHook
100                 };
101 #endif