-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathfunctions.c
66 lines (59 loc) · 1.19 KB
/
functions.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
56
57
58
59
60
61
62
63
64
65
66
#include <stddef.h>
#include "functions.h"
#include "shm.h"
static bool set_status(struct B *target, bool status, int t1, int t2)
{
target->status = status;
target->t1 = t1;
target->t2 = t2;
return true;
}
bool i_set_status(gpio g, bool status, int t1, int t2)
{
struct A *shm = (struct A *)shmget();
if (shm != NULL) {
struct B *target = &shm->gpio[g];
bool res = false;
if (target->active) {
res = set_status(target, status, t1, t2);
}
shmdt(shm);
return res;
}
return false;
}
static bool activate(struct B *target, bool active)
{
target->active = active;
return true;
}
bool i_activate(gpio g, bool active)
{
struct A *shm = (struct A *)shmget();
if (shm != NULL) {
struct B *target = &shm->gpio[g];
bool res = activate(target, active);
shmdt(shm);
return res;
}
return false;
}
static bool set_direction(struct B *target, bool direction)
{
target->direction = direction;
return true;
}
bool i_set_direction(gpio g, bool direction)
{
struct A *shm = (struct A *)shmget();
if (shm != NULL) {
struct B *target = &shm->gpio[g];
bool res = false;
if (target->active) {
res = set_direction(target, direction);
}
shmdt(shm);
return res;
}
return false;
}