-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathExternalInterrupt.cpp
More file actions
41 lines (34 loc) · 824 Bytes
/
Copy pathExternalInterrupt.cpp
File metadata and controls
41 lines (34 loc) · 824 Bytes
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
/*
* ExternalInterrupt.cpp
*
* Created: 5/8/2019 8:50:55 AM
* Author: Jordan
*/
#include "ExternalInterrupt.h"
void externalInterruptConfig(void){
static int m_isConfigured = 0;
//Only configure if not yet configured
if(1 == m_isConfigured) return;
//Enable EIC on bus
MCLK->APBAMASK.bit.EIC_ =
1;
//Give it a clock (GCLK 1)
GCLK->PCHCTRL[EIC_GCLK_ID].reg =
GCLK_PCHCTRL_CHEN |
GCLK_PCHCTRL_GEN_GCLK1;
//Software reset it really quick
EIC->CTRLA.bit.SWRST =
1;
//Wait for reset to end
while(EIC->CTRLA.reg & EIC_CTRLA_SWRST == 1);
}
void externalInterruptStart(void){
//Set configuration
EIC->CTRLA.reg =
EIC_CTRLA_ENABLE; //Just turn it on
}
void externalInterruptHalt(void){
//Set configuration
EIC->CTRLA.reg =
0; //Stop it
}