-
Notifications
You must be signed in to change notification settings - Fork 0
/
timers.h
60 lines (47 loc) · 1.28 KB
/
timers.h
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
#pragma once
// Om den ovan inte funkar så använd (se öven #end if på slutet av filen):
#ifndef TIMERS_H
#define TIMERS_H
#include <stdint.h> /* Declarations of uint_32 and the like */
#include <pic32mx.h> /* Declarations of system-specific addresses etc */
#include "mipslab.h" /* Declatations for these labs */
#include <stdbool.h> // need this for bool
/**********************************************************************************************
Timer routines
**********************************************************************************************/
void startTimerOne(){
TMR1= 0x0;
T1CONSET = 0x8000;
}
void startTimerFour(){
TMR4 = 0x0;
T4CONSET = 0x8000;
}
void stopTimerOne(){
T1CONCLR = 0x8000;
}
void stopTimerFour(){
T4CONCLR = 0x8000;
}
/**********************************************************************************************
Flag routines
**********************************************************************************************/
bool flagTimerOneUp(){
return IFS(0) & 0x10;
}
void setFlagTimerOneDown(){
IFS(0) &= ~0x10;
}
bool flagTimerFourUp(){
return IFS(0) & 0x10000;
}
void setFlagTimerFourDown(){
IFS(0) &= ~0x10000;
}
bool flagTimerThreeUp(){
return IFS(0) & 0x1000;
}
void setFlagTimerThreeDown(){
IFS(0) &= ~0x1000;
}
#endif