source: rtems/bsps/sparc/include/bsp/gradcdac.h @ 2afb22b

5
Last change on this file since 2afb22b was 2afb22b, checked in by Chris Johns <chrisj@…>, on 12/23/17 at 07:18:56

Remove make preinstall

A speciality of the RTEMS build system was the make preinstall step. It
copied header files from arbitrary locations into the build tree. The
header files were included via the -Bsome/build/tree/path GCC command
line option.

This has at least seven problems:

  • The make preinstall step itself needs time and disk space.
  • Errors in header files show up in the build tree copy. This makes it hard for editors to open the right file to fix the error.
  • There is no clear relationship between source and build tree header files. This makes an audit of the build process difficult.
  • The visibility of all header files in the build tree makes it difficult to enforce API barriers. For example it is discouraged to use BSP-specifics in the cpukit.
  • An introduction of a new build system is difficult.
  • Include paths specified by the -B option are system headers. This may suppress warnings.
  • The parallel build had sporadic failures on some hosts.

This patch removes the make preinstall step. All installed header
files are moved to dedicated include directories in the source tree.
Let @RTEMS_CPU@ be the target architecture, e.g. arm, powerpc, sparc,
etc. Let @RTEMS_BSP_FAMILIY@ be a BSP family base directory, e.g.
erc32, imx, qoriq, etc.

The new cpukit include directories are:

  • cpukit/include
  • cpukit/score/cpu/@RTEMS_CPU@/include
  • cpukit/libnetworking

The new BSP include directories are:

  • bsps/include
  • bsps/@RTEMS_CPU@/include
  • bsps/@RTEMS_CPU@/@RTEMS_BSP_FAMILIY@/include

There are build tree include directories for generated files.

The include directory order favours the most general header file, e.g.
it is not possible to override general header files via the include path
order.

The "bootstrap -p" option was removed. The new "bootstrap -H" option
should be used to regenerate the "headers.am" files.

Update #3254.

  • Property mode set to 100644
File size: 7.3 KB
Line 
1/*  ADC / DAC (GRADCDAC) 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 __GRADCDAC_H__
12#define __GRADCDAC_H__
13
14#ifdef __cplusplus
15extern "C" {
16#endif
17
18struct gradcdac_regs {
19        volatile unsigned int config;      /* 0x00 Configuration Register */
20        volatile unsigned int status;      /* 0x04 Status Register */
21        int unused0[2];
22        volatile unsigned int adc_din;     /* 0x10 ADC Data Input Register */
23        volatile unsigned int dac_dout;    /* 0x14 DAC Data Output Register */
24        int unused1[2];
25        volatile unsigned int adrin;       /* 0x20 Address Input Register */
26        volatile unsigned int adrout;      /* 0x24 Address Output Register */
27        volatile unsigned int adrdir;      /* 0x28 Address Direction Register */
28        int unused2[1];
29        volatile unsigned int data_in;     /* 0x30 Data Input Register  */
30        volatile unsigned int data_out;    /* 0x34 Data Output Register */
31        volatile unsigned int data_dir;    /* 0x38 Data Direction Register */
32};
33
34#define GRADCDAC_CFG_DACWS    0x00f80000
35#define GRADCDAC_CFG_WRPOL    0x00040000
36#define GRADCDAC_CFG_DACDW    0x00030000
37#define GRADCDAC_CFG_ADCWS    0x0000f800
38#define GRADCDAC_CFG_RCPOL    0x00000400
39#define GRADCDAC_CFG_CSMODE   0x00000300
40#define GRADCDAC_CFG_CSPOL    0x00000080
41#define GRADCDAC_CFG_RDYMODE  0x00000040
42#define GRADCDAC_CFG_RDYPOL   0x00000020
43#define GRADCDAC_CFG_TRIGPOL  0x00000010
44#define GRADCDAC_CFG_TRIGMODE 0x0000000c
45#define GRADCDAC_CFG_ADCDW    0x00000003
46
47#define GRADCDAC_CFG_DACWS_BIT    19
48#define GRADCDAC_CFG_WRPOL_BIT    18
49#define GRADCDAC_CFG_DACDW_BIT    16
50#define GRADCDAC_CFG_ADCWS_BIT    11
51#define GRADCDAC_CFG_RCPOL_BIT    10
52#define GRADCDAC_CFG_CSMODE_BIT    8
53#define GRADCDAC_CFG_CSPOL_BIT     7
54#define GRADCDAC_CFG_RDYMODE_BIT   6
55#define GRADCDAC_CFG_RDYPOL_BIT    5
56#define GRADCDAC_CFG_TRIGPOL_BIT   4
57#define GRADCDAC_CFG_TRIGMODE_BIT  2
58#define GRADCDAC_CFG_ADCDW_BIT     0
59
60#define GRADCDAC_STATUS_DACNO   0x40
61#define GRADCDAC_STATUS_DACRDY  0x20
62#define GRADCDAC_STATUS_DACON   0x10
63#define GRADCDAC_STATUS_ADCTO   0x08
64#define GRADCDAC_STATUS_ADCNO   0x04
65#define GRADCDAC_STATUS_ADCRDY  0x02
66#define GRADCDAC_STATUS_ADCON   0x01
67
68#define GRADCDAC_STATUS_DACNO_BIT  6
69#define GRADCDAC_STATUS_DACRDY_BIT 5
70#define GRADCDAC_STATUS_DACON_BIT  4
71#define GRADCDAC_STATUS_ADCTO_BIT  3
72#define GRADCDAC_STATUS_ADCNO_BIT  2
73#define GRADCDAC_STATUS_ADCRDY_BIT 1
74#define GRADCDAC_STATUS_ADCON_BIT  0
75
76#define GRADCDAC_IRQ_DAC 1
77#define GRADCDAC_IRQ_ADC 0
78
79struct gradcdac_config {
80        unsigned char dac_ws;
81        char wr_pol;
82        unsigned char dac_dw;
83        unsigned char adc_ws;
84        char rc_pol;
85        unsigned char cs_mode;
86        char cs_pol;
87        char ready_mode;
88        char ready_pol;
89        char trigg_pol;
90        unsigned char trigg_mode;
91        unsigned char adc_dw;
92};
93
94extern void *gradcdac_open(char *devname);
95
96extern void gradcdac_set_config(void *cookie, struct gradcdac_config *cfg);
97
98extern void gradcdac_get_config(void *cookie, struct gradcdac_config *cfg);
99
100extern void gradcdac_set_cfg(void *cookie, unsigned int config);
101
102extern unsigned int gradcdac_get_cfg(void *cookie);
103
104extern unsigned int gradcdac_get_status(void *cookie);
105
106static int __inline__ gradcdac_DAC_ReqRej(unsigned int status)
107{
108        return (status & GRADCDAC_STATUS_DACNO);
109}
110
111static int __inline__ gradcdac_DAC_isCompleted(unsigned int status)
112{
113        return (status & GRADCDAC_STATUS_DACRDY);
114}
115
116static int __inline__ gradcdac_DAC_isOngoing(unsigned int status)
117{
118        return (status & GRADCDAC_STATUS_DACON);
119}
120
121static int __inline__ gradcdac_ADC_isTimeouted(unsigned int status)
122{
123        return (status & GRADCDAC_STATUS_ADCTO);
124}
125
126static int __inline__ gradcdac_ADC_ReqRej(unsigned int status)
127{
128        return (status & GRADCDAC_STATUS_ADCNO);
129}
130
131static int __inline__ gradcdac_ADC_isCompleted(unsigned int status)
132{
133        return (status & GRADCDAC_STATUS_ADCRDY);
134}
135
136static int __inline__ gradcdac_ADC_isOngoing(unsigned int status)
137{
138        return (status & GRADCDAC_STATUS_ADCON);
139}
140
141#define GRADCDAC_ISR_BOTH 3
142#define GRADCDAC_ISR_DAC 2
143#define GRADCDAC_ISR_ADC 1
144
145/* Install IRQ handler for ADC and/or DAC interrupt.
146 * The installed IRQ handler(ISR) must read the status
147 * register to clear the pending interrupt avoiding multiple
148 * entries to the ISR caused by the same IRQ.
149 *
150 * \param adc  1=ADC interrupt, 2=ADC interrupt, 3=ADC and DAC interrupt
151 * \param isr  Interrupt service routine called when IRQ is fired
152 * \param arg  custom argument passed to ISR when called.
153 */
154extern int gradcdac_install_irq_handler
155        (void *cookie, int adc, void (*isr)(void *cookie, void *arg), void *arg);
156
157extern void gradcdac_uninstall_irq_handler(void *cookie, int adc);
158
159/* Make the ADC circuitry initialize a analogue to digital
160 * conversion. The result can be read out by gradcdac_adc_convert_try
161 * or gradcdac_adc_convert.
162 */
163extern void gradcdac_adc_convert_start(void *cookie);
164
165/* Tries to read the conversion result. If the circuitry is busy
166 * converting the function return a non-zero value, if the conversion
167 * has successfully finished the function return zero.
168 *
169 * \param digital_value the resulting converted value is placed here
170 * \return zero     = ADC conversion complete, digital_value contain current conversion result
171 *         positive = ADC busy, digital_value contain previous conversion result
172 *         negative = Conversion request failed.
173 */
174extern int gradcdac_adc_convert_try(void *cookie, unsigned short *digital_value);
175
176/* Waits until the ADC circuity has finished a digital to analogue
177 * conversion. The Waiting is implemented as a busy loop utilizing
178 * 100% CPU load.
179 *
180 * \return zero     = Conversion ok
181 *         negative = Conversion request failed.
182 */
183extern int gradcdac_adc_convert(void *cookie, unsigned short *digital_value);
184
185/* Try to make the DAC circuitry initialize a digital to analogue
186 * conversion. If the circuitry is busy by a previous conversion
187 * the function return a non-zero value, if the conversion is
188 * successfully initialized the function return zero.
189 */
190extern int gradcdac_dac_convert_try(void *cookie, unsigned short digital_value);
191
192/* Initializes a digital to analogue conversion by waiting until
193 * previous conversions is finished before procceding with the
194 * conversion. The Waiting is implemented as a busy loop utilizing
195 * 100% CPU load.
196 */
197extern void gradcdac_dac_convert(void *cookie, unsigned short digital_value);
198
199extern unsigned int gradcdac_get_adrinput(void *cookie);
200extern void gradcdac_set_adrinput(void *cookie, unsigned int input);
201
202extern unsigned int gradcdac_get_adroutput(void *cookie);
203extern void gradcdac_set_adroutput(void *cookie, unsigned int output);
204
205extern unsigned int gradcdac_get_adrdir(void *cookie);
206extern void gradcdac_set_adrdir(void *cookie, unsigned int dir);
207
208extern unsigned int gradcdac_get_datainput(void *cookie);
209extern void gradcdac_set_datainput(void *cookie, unsigned int input);
210
211extern unsigned int gradcdac_get_dataoutput(void *cookie);
212extern void gradcdac_set_dataoutput(void *cookie, unsigned int output);
213
214extern unsigned int gradcdac_get_datadir(void *cookie);
215extern void gradcdac_set_datadir(void *cookie, unsigned int dir);
216
217/* Show one or all GRADCDAC cores. If cookie is NULL all GRADCDAC's are shown */
218extern void grAdcDacShow(void *cookie);
219
220/* Register Driver routine */
221extern void gradcdac_register_drv (void);
222
223#ifdef __cplusplus
224}
225#endif
226
227#endif
Note: See TracBrowser for help on using the repository browser.