-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathGPTM.h
107 lines (95 loc) · 2.55 KB
/
GPTM.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
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
#ifndef GPTM_h
#define GPTM_h
#include "JLib.h"
#include "NVIC.h"
#include "SystemClock.h"
#include <stdlib.h>
typedef enum {OST_type, PT_type, IEC_type, IET_type, PWM_type} TMTypes;
typedef enum {GPTM_a, GPTM_b, GPTM_both} TimerLetter;
typedef enum { _16Bit, _32Bit, _64Bit} TimerSize;
typedef enum {count_down, count_up} UpOrDown;
//struct Timer{
// GPTM_TimerMode mode;
// unsigned char timerNumber;
// TimerLetter letter;
//
// BYTE_ADDRESS timerAddress;
// bool cDir;
// BYTE modeCode;
// BYTE eventCode;
//};
struct _64BitValue{
int lowerHalf;
int upperHalf;
};
struct oneShotTimer{
//user readable values
BYTE timerMode;
UpOrDown countDirection;
bool startAtExternTrigger;
bool captureFreeRunningTimerAtTimeOut;
//configure additionalTrigger or interrupt
//appropriate interrupts? -> yes =(
};
struct periodicTimer{
int x;
};
struct realTimeClock{
int x;
};
struct inputEdgeCount{
int x;
};
struct inputEdgeTiming{
int x;
};
struct pulseWidthModulation{
int x;
};
union TimerType{
struct oneShotTimer OST;
struct periodicTimer PT;
struct realTimeClock RTC;
struct inputEdgeCount IEC;
struct inputEdgeTiming IET;
struct pulseWidthModulation PWM;
};
struct TimerTypeWithData{
union TimerType timer;
bool active;
TimerLetter letter;
TMTypes type;
//auto-generated values
struct _64BitValue countValue;
};
struct timerAB{
struct TimerTypeWithData* a;
struct TimerTypeWithData* b;
};
union SpecificTimerVariables{
struct timerAB ab;
struct TimerTypeWithData* both;
};
struct Timer{
BYTE timerNumber;
BYTE_ADDRESS timerAddress;
bool useBothTimers;
union SpecificTimerVariables STV;
};
struct TimerTypeWithData* new_oneShotTimer(long long countValue, UpOrDown countDir, bool startAtExternTrig, bool capFreeRunTmAtTimeOut);
struct periodicTimer* new_periodicTimer();
struct inputEdgeCount* new_inputEdgeCount();
struct inputEdgeTiming* new_inputEdgeTimingMode();
struct pulseWidthModulation* new_pulseWidthModulation();
struct Timer* new_Timer(struct TimerTypeWithData* tm, unsigned char timerNumber, TimerLetter abOrBoth);
void GPTM_initializeTimer(BYTE timerNumber, TimerLetter tmLetter);
void GPTM_initPT(BYTE_ADDRESS, struct TimerTypeWithData*);
void GPTM_disableTimer(BYTE_ADDRESS addr, struct TimerTypeWithData* tm);
void GPTM_setConfigRegister(struct Timer* tm, WORD regValue);
void GPTM_configureOneShotVsPeriodic(struct Timer* tm);
void GPTM_setStartValue(struct Timer* tm);
void GPTM_configureInterrupts(struct Timer* tm);
void GPTM_enableTimer(struct Timer* tm);
void GPTM_setTimerMode(struct Timer* tm);
BYTE_ADDRESS GPTM_getAddress(BYTE);
#endif