-
Notifications
You must be signed in to change notification settings - Fork 0
/
hook.c
55 lines (46 loc) · 1.28 KB
/
hook.c
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
#include "kernel.h"
#include "kernel_id.h"
#include "ecrobot_interface.h"
#include "balancer.h"
#include "port_IF.h"
#include "main_IF.h"
#include "lookup_IF.h"
#include "seesaw_IF.h"
#include "garage_IF.h"
DeclareCounter(SysTimerCnt);
/* nxtOSEK hooks */
void ecrobot_device_initialize(void)
{
nxt_motor_set_speed(PORT_MOTOR_L, 0, 1);
nxt_motor_set_speed(PORT_MOTOR_R, 0, 1);
balance_init();
nxt_motor_set_count(PORT_MOTOR_L, 0);
nxt_motor_set_count(PORT_MOTOR_R, 0);
ecrobot_init_sonar_sensor(PORT_SONAR);
ecrobot_set_light_sensor_active(PORT_LIGHT);
/* ƒƒO */
if (ecrobot_get_bt_status() == BT_NO_INIT) {
ecrobot_set_bt_device_name("ETROBOLT255");
} else { /* NOTHING */ }
ecrobot_init_bt_slave("LEJOS_OSEK");
lt_ini();
lookup_ini();
seesaw_ini();
garage_ini();
}
void ecrobot_device_terminate(void)
{
nxt_motor_set_speed(PORT_MOTOR_L, 0, 1);
nxt_motor_set_speed(PORT_MOTOR_R, 0, 1);
nxt_motor_set_speed(PORT_MOTOR_TAIL, 0, 1);
ecrobot_term_sonar_sensor(PORT_SONAR);
}
/* nxtOSEK hook to be invoked from an ISR in category 2 */
void user_1ms_isr_type2(void)
{
StatusType ercd;
ercd = SignalCounter(SysTimerCnt); /* Increment OSEK Alarm Counter */
if (ercd != E_OK) {
ShutdownOS(ercd);
}
}