/
exti.c
79 lines (63 loc) · 1.79 KB
/
exti.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
67
68
69
70
71
72
73
74
75
76
77
78
79
/**
* @file exti.c
*
* @section License
* Copyright (C) 2014-2016, Erik Moqvist
*
* This library is free software; you can redistribute it and/or
* modify it under the terms of the GNU Lesser General Public
* License as published by the Free Software Foundation; either
* version 2.1 of the License, or (at your option) any later version.
*
* This library is distributed in the hope that it will be useful,
* but WITHOUT ANY WARRANTY; without even the implied warranty of
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
* Lesser General Public License for more details.
*
* This file is part of the Simba project.
*/
#include "simba.h"
struct module_t {
int initialized;
};
#include "exti_port.i"
static struct module_t module;
int exti_module_init()
{
/* Return immediately if the module is already initialized. */
if (module.initialized == 1) {
return (0);
}
module.initialized = 1;
return (exti_port_module_init());
}
int exti_init(struct exti_driver_t *self_p,
struct exti_device_t *dev_p,
int trigger,
void (*on_interrupt)(void *arg_p),
void *arg_p)
{
ASSERTN(self_p != NULL, EINVAL);
ASSERTN(dev_p != NULL, EINVAL);
ASSERTN(on_interrupt != NULL, EINVAL);
self_p->dev_p = dev_p;
self_p->trigger = trigger;
self_p->on_interrupt = on_interrupt;
self_p->arg_p = arg_p;
return (0);
}
int exti_start(struct exti_driver_t *self_p)
{
ASSERTN(self_p != NULL, EINVAL);
return (exti_port_start(self_p));
}
int exti_stop(struct exti_driver_t *self_p)
{
ASSERTN(self_p != NULL, EINVAL);
return (exti_port_stop(self_p));
}
int exti_clear(struct exti_driver_t *self_p)
{
ASSERTN(self_p != NULL, EINVAL);
return (exti_port_clear(self_p));
}