-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathexternal_int.cpp
More file actions
37 lines (34 loc) · 1.01 KB
/
external_int.cpp
File metadata and controls
37 lines (34 loc) · 1.01 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
#include "external_int.hpp"
#include <interrupt.hpp>
#include "IO.hpp"
namespace external_int{
External_int& External_int::event_on(int pin, int mode, handler_func callback){
switch(pin){
case _INT0_:
EICRA |= mode;
EIMSK |= 1<<0;
digitalIO::DigitalIO(2).input_pullup();
interrupt::handler.set_handle(INT0_vect_num, callback);
break;
case _INT1_:
EICRA |= (mode <<= 2);
EIMSK |= 1<<1;
digitalIO::DigitalIO(3).input_pullup();
interrupt::handler.set_handle(INT1_vect_num, callback);
break;
}
interrupt::handler.enable();
return *this;
}
External_int& External_int::disable(int pin){
switch(pin){
case _INT0_:
EIMSK |= 0<<0;
break;
case _INT1_:
EIMSK |= 0<<1;
break;
}
return *this;
}
}