-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathclock.c
64 lines (44 loc) · 1003 Bytes
/
clock.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
#define TRUE 1
#define FALSE 0
#include <stdio.h>
struct Clock
{
int Cycle ;
int Subcycle ; /* 0..4 */
} ;
struct Clock Quartz = {0, 0} ; /* Quartz is of TYPE clock */
FirstSubcycle ()
{
if (Quartz.Subcycle == 1)
return TRUE ;
else return FALSE ;
} /* END FirstSubcycle */
SecondSubcycle ()
{
if (Quartz.Subcycle == 2)
return TRUE ;
else return FALSE ;
} /* END SecondSubcycle */
ThirdSubcycle ()
{
if (Quartz.Subcycle == 3)
return TRUE ;
else return FALSE ;
} /* END ThirdSubcycle */
FourthSubcycle ()
{
if (Quartz.Subcycle == 4)
return TRUE ;
else return FALSE ;
} /* END FourthSubcycle */
int Cycle ()
{
return (Quartz.Cycle) ;
}
void GeneratePulse ()
{
//printf("\nIn GeneratePulse");
Quartz.Subcycle = (Quartz.Subcycle % 4) + 1 ;
if (Quartz.Subcycle == 1)
Quartz.Cycle = Quartz.Cycle + 1 ;
} /* END GeneratePulse */