AutosarOS
App.c
Go to the documentation of this file.
1
14
#include "
assert.h
"
15
16
#include "
OS_API.h
"
17
18
#include <avr/io.h>
19
#include <util/delay.h>
20
21
#if defined (OS_CONFIG_SIM) && OS_CONFIG_SIM == true
22
#define DELAY_MS(ms)
23
#else
24
#define DELAY_MS(ms) _delay_ms(ms)
25
#endif
/* defined (OS_CONFIG_SIM) && OS_CONFIG_SIM == true */
26
27
TASK
(Idle)
28
{
29
while
(1);
30
}
31
32
TASK
(Task1)
33
{
34
AppModeType
mode =
GetActiveApplicationMode
();
35
assert
(mode ==
OSDEFAULTAPPMODE
);
36
37
ShutdownOS
(
E_OK
);
38
}
39
40
extern
void
StartupHook
(
void
)
41
{
42
DDRB = 0xFF;
// PB as output
43
PORTB = 0xFF;
// keep all LEDs off
44
45
DDRD = 0x00;
// PD as input
46
PORTD = 0xFF;
// enable PU on PD
47
48
#if defined (__AVR_ATmega32__)
49
50
#elif defined (__AVR_ATmega128__) || defined (__AVR_ATmega1284__)
51
/* Timer 2 */
52
#if defined (OS_CONFIG_SIM) && OS_CONFIG_SIM == true
53
#if defined (__AVR_ATmega128__)
54
TCCR2 = (1 << CS20);
// Enable Timer2 with Prescaler 1
55
TIMSK |= 1 << TOIE2;
// Enable Overflow Interrupt (Timer2)
56
#else
/* defined (__AVR_ATmega128__) */
57
TCCR2B = (1 << CS20);
// Enable Timer2 with Prescaler 1
58
TIMSK2 |= 1 << TOIE2;
// Enable Overflow Interrupt (Timer2)
59
#endif
/* defined (__AVR_ATmega128__) */
60
#endif
/* defined (OS_CONFIG_SIM) && OS_CONFIG_SIM == true */
61
#else
/* defined (__AVR_ATmega32__) */
62
#error Unknown CPU defined!
63
#endif
/* defined (__AVR_ATmega32__) */
64
65
uint8_t t = 0;
66
67
while
(t < 6) {
68
uint8_t r = PORTB;
69
r ^= (1 << 7);
70
PORTB = r;
71
DELAY_MS
(50);
72
t++;
73
}
74
}
75
76
extern
void
ShutdownHook
(
StatusType
error)
77
{
78
DDRB = 0xFF;
// PB as output
79
PORTB = 0xFF;
// keep all LEDs off
80
81
for
(uint8_t i = 0; i < 11; i++) {
82
PORTB ^= 0xFF;
83
DELAY_MS
(1000);
84
}
85
}
86
87
extern
void
PreTaskHook
(
void
)
88
{
89
90
}
91
92
extern
void
PostTaskHook
(
void
)
93
{
94
95
}
96
97
extern
void
ErrorHook
(
StatusType
error)
98
{
99
100
}
101
102
ISR
(TIMER2_OVF_vect)
103
{
104
105
}
StatusType
enum StatusType_e StatusType
Type for status.
ErrorHook
void ErrorHook(StatusType error)
PostTask hook function.
Definition:
App.c:784
StartupHook
void StartupHook(void)
Definition:
App.c:702
GetActiveApplicationMode
#define GetActiveApplicationMode
Definition:
OS_API.h:57
assert.h
Assert macros and functions.
TASK
TASK(Idle)
Definition:
App.c:33
E_OK
@ E_OK
Definition:
Types.h:40
ISR
ISR(INT0_vect)
Definition:
App.c:806
PreTaskHook
void PreTaskHook(void)
PreTask hook function.
Definition:
App.c:768
DELAY_MS
#define DELAY_MS(ms)
Definition:
App.c:24
assert
#define assert(expression)
Definition:
assert.h:37
ShutdownOS
#define ShutdownOS
Definition:
OS_API.h:56
OS_API.h
Operating System API.
OSDEFAULTAPPMODE
@ OSDEFAULTAPPMODE
Definition:
Types.h:69
PostTaskHook
void PostTaskHook(void)
PostTask hook function.
Definition:
App.c:776
ShutdownHook
void ShutdownHook(StatusType error)
Definition:
App.c:757
AppModeType
enum applicationMode_e AppModeType
Type for application mode.
test
Hooks
Hooks2
App.c
Generated by
1.8.20