RTEMS  5.1
grctm.h
1 /* GRCTM - CCSDS Time Manager - register driver interface.
2  *
3  * COPYRIGHT (c) 2009.
4  * Cobham Gaisler AB
5  *
6  * The license and distribution terms for this file may be
7  * found in the file LICENSE in this distribution or at
8  * http://www.rtems.org/license/LICENSE.
9  */
10 
11 #ifndef __GRCTM_H__
12 #define __GRCTM_H__
13 
14 #define DAT0_IRQ 0x1
15 #define DAT1_IRQ 0x2
16 #define DAT2_IRQ 0x4
17 #define PULSE0_IRQ 0x10
18 #define PULSE1_IRQ 0x20
19 #define PULSE2_IRQ 0x40
20 #define PULSE3_IRQ 0x80
21 #define PULSE4_IRQ 0x100
22 #define PULSE5_IRQ 0x200
23 #define PULSE6_IRQ 0x400
24 #define PULSE7_IRQ 0x800
25 
26 struct grctm_regs {
27  volatile unsigned int grr;
28  volatile unsigned int gcr;
29  volatile unsigned int gsr;
30  volatile unsigned int unused[2];
31  volatile unsigned int pfr;
32  volatile unsigned int etcr;
33  volatile unsigned int etfr;
34  volatile unsigned int dcr0;
35  volatile unsigned int dfr0;
36  volatile unsigned int dcr1;
37  volatile unsigned int dfr1;
38  volatile unsigned int dcr2;
39  volatile unsigned int dfr2;
40  volatile unsigned int stcr;
41  volatile unsigned int stfr;
42  volatile unsigned int pdr[8];
43  volatile unsigned int pimsr;
44  volatile unsigned int pimr;
45  volatile unsigned int pisr;
46  volatile unsigned int pir;
47  volatile unsigned int imr;
48  volatile unsigned int picr;
49  volatile unsigned int unused1[2];
50  volatile unsigned int etir;
51  volatile unsigned int fsir;
52  volatile unsigned int serconf;
53  volatile unsigned int unused2;
54  volatile unsigned int twsc;
55  volatile unsigned int twadj;
56  volatile unsigned int twtx;
57  volatile unsigned int twrx;
58 };
59 
60 struct grctm_stats {
61 
62  /* IRQ Stats */
63  unsigned int nirqs;
64  unsigned int pulse;
65 };
66 
67 /* Function ISR callback prototype */
68 typedef void (*grctm_isr_t)(unsigned int pimr, void *data);
69 
70 /* Open a GRCTM device by minor number. */
71 extern void *grctm_open(int minor);
72 
73 /* Close a previously opened GRCTM device */
74 extern void grctm_close(void *spwcuc);
75 
76 /* Hardware Reset of GRCTM */
77 extern int grctm_reset(void *grctm);
78 
79 /* Enable Interrupts at Interrupt controller */
80 extern void grctm_int_enable(void *grctm);
81 
82 /* Disable Interrupts at Interrupt controller */
83 extern void grctm_int_disable(void *grctm);
84 
85 /* Clear Statistics gathered by the driver */
86 extern void grctm_clr_stats(void *grctm);
87 
88 /* Get Statistics gathered by the driver */
89 extern void grctm_get_stats(void *grctm, struct grctm_stats *stats);
90 
91 /* Register an Interrupt handler and custom data, the function call is
92  * removed by setting func to NULL.
93  */
94 extern void grctm_int_register(void *grctm, grctm_isr_t func, void *data);
95 
96 /* Enable external synchronisation (from spwcuc) */
97 extern void grctm_enable_ext_sync(void *grctm);
98 
99 /* Disable external synchronisation (from spwcuc) */
100 extern void grctm_disable_ext_sync(void *grctm);
101 
102 /* Enable TimeWire synchronisation */
103 extern void grctm_enable_tw_sync(void *grctm);
104 
105 /* Disable TimeWire synchronisation */
106 extern void grctm_disable_tw_sync(void *grctm);
107 
108 /* Disable frequency synthesizer from driving ET */
109 extern void grctm_disable_fs(void *grctm);
110 
111 /* Enable frequency synthesizer to drive ET */
112 extern void grctm_enable_fs(void *grctm);
113 
114 /* Return elapsed coarse time */
115 extern unsigned int grctm_get_et_coarse(void *grctm);
116 
117 /* Return elapsed fine time */
118 extern unsigned int grctm_get_et_fine(void *grctm);
119 
120 /* Return elapsed time (coarse and fine) */
121 extern unsigned long long grctm_get_et(void *grctm);
122 
123 /* Return 1 if specified datation has been latched */
124 extern int grctm_is_dat_latched(void *grctm, int dat);
125 
126 /* Set triggering edge of datation input */
127 extern void grctm_set_dat_edge(void *grctm, int dat, int edge);
128 
129 /* Return latched datation coarse time */
130 extern unsigned int grctm_get_dat_coarse(void *grctm, int dat);
131 
132 /* Return latched datation fine time */
133 extern unsigned int grctm_get_dat_fine(void *grctm, int dat);
134 
135 /* Return latched datation ET */
136 extern unsigned long long grctm_get_dat_et(void *grctm, int dat);
137 
138 /* Return current pulse configuration */
139 extern unsigned int grctm_get_pulse_reg(void *grctm, int pulse);
140 
141 /* Set pulse register */
142 extern void grctm_set_pulse_reg(void *grctm, int pulse, unsigned int val);
143 
144 /* Configure pulse: pp = period, pw = width, pl = level, en = enable */
145 extern void grctm_cfg_pulse(void *grctm, int pulse, int pp, int pw, int pl, int en);
146 
147 /* Enable pulse output */
148 extern void grctm_enable_pulse(void *grctm, int pulse);
149 
150 /* Disable pulse output */
151 extern void grctm_disable_pulse(void *grctm, int pulse);
152 
153 /* Clear interrupts */
154 extern void grctm_clear_irqs(void *grctm, int irqs);
155 
156 /* Enable interrupts */
157 extern void grctm_enable_irqs(void *grctm, int irqs);
158 
159 /* Set Frequency synthesizer increment */
160 void grctm_set_fs_incr(void *grctm, int incr);
161 
162 /* Set ET increment */
163 void grctm_set_et_incr(void *grctm, int incr);
164 
165 /* Get register base address */
166 struct grctm_regs *grctm_get_regs(void *grctm);
167 
168 /* Register the GRCTM driver to Driver Manager */
169 extern void grctm_register(void);
170 
171 #endif
Definition: grctm.h:26
Definition: grctm.h:60