-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathHelloWorld.cpp
More file actions
executable file
·67 lines (54 loc) · 1.33 KB
/
HelloWorld.cpp
File metadata and controls
executable file
·67 lines (54 loc) · 1.33 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
/* sample.cpp for TOPPERS/ATK(OSEK) */
// ECRobot++ API
#include "LightSensor.h"
#include "SonarSensor.h"
#include "SoundSensor.h"
#include "TouchSensor.h"
#include "IrSeeker.h"
#include "Clock.h"
#include "Lcd.h"
#include "Motor.h"
using namespace ecrobot;
extern "C"
{
#include "kernel.h"
#include "kernel_id.h"
#include "ecrobot_interface.h"
//wichtig, damit Tasks gestartet werden können, da sie nicht automatisch gestartet werden
DeclareCounter(SysTimerCnt);
DeclareTask(TaskDisplay);
Clock clock;
Lcd lcd;
LightSensor light(PORT_3, true);
SonarSensor sonar(PORT_1);
/* nxtOSEK hook to be invoked from an ISR in category 2 */
void user_1ms_isr_type2(void)
{
StatusType ercd = SignalCounter(SysTimerCnt); /* Increment OSEK Alarm Counter */
if(ercd != E_OK)
{
lcd.clear();
lcd.putf("sn", "Shutdown OS!");
lcd.disp();
clock.wait(2000);
ShutdownOS(ercd);
}
SleeperMonitor(); // needed for I2C device and Clock classes
}
TASK(TaskDisplay)
{
S16 bright;
S16 dist;
while(1)
{
bright = light.getBrightness();
dist = sonar.getDistance();
lcd.clear();
lcd.putf("sdn", "Bright:", bright);
lcd.putf("sdn", "Dist:", dist);
lcd.disp();
clock.wait(100);
}
TerminateTask();
}
}