File indexing completed on 2025-05-11 08:23:43
0001
0002
0003
0004
0005
0006
0007
0008
0009
0010
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030 #ifndef __GRADCDAC_H__
0031 #define __GRADCDAC_H__
0032
0033 #ifdef __cplusplus
0034 extern "C" {
0035 #endif
0036
0037 struct gradcdac_regs {
0038 volatile unsigned int config;
0039 volatile unsigned int status;
0040 int unused0[2];
0041 volatile unsigned int adc_din;
0042 volatile unsigned int dac_dout;
0043 int unused1[2];
0044 volatile unsigned int adrin;
0045 volatile unsigned int adrout;
0046 volatile unsigned int adrdir;
0047 int unused2[1];
0048 volatile unsigned int data_in;
0049 volatile unsigned int data_out;
0050 volatile unsigned int data_dir;
0051 };
0052
0053 #define GRADCDAC_CFG_DACWS 0x00f80000
0054 #define GRADCDAC_CFG_WRPOL 0x00040000
0055 #define GRADCDAC_CFG_DACDW 0x00030000
0056 #define GRADCDAC_CFG_ADCWS 0x0000f800
0057 #define GRADCDAC_CFG_RCPOL 0x00000400
0058 #define GRADCDAC_CFG_CSMODE 0x00000300
0059 #define GRADCDAC_CFG_CSPOL 0x00000080
0060 #define GRADCDAC_CFG_RDYMODE 0x00000040
0061 #define GRADCDAC_CFG_RDYPOL 0x00000020
0062 #define GRADCDAC_CFG_TRIGPOL 0x00000010
0063 #define GRADCDAC_CFG_TRIGMODE 0x0000000c
0064 #define GRADCDAC_CFG_ADCDW 0x00000003
0065
0066 #define GRADCDAC_CFG_DACWS_BIT 19
0067 #define GRADCDAC_CFG_WRPOL_BIT 18
0068 #define GRADCDAC_CFG_DACDW_BIT 16
0069 #define GRADCDAC_CFG_ADCWS_BIT 11
0070 #define GRADCDAC_CFG_RCPOL_BIT 10
0071 #define GRADCDAC_CFG_CSMODE_BIT 8
0072 #define GRADCDAC_CFG_CSPOL_BIT 7
0073 #define GRADCDAC_CFG_RDYMODE_BIT 6
0074 #define GRADCDAC_CFG_RDYPOL_BIT 5
0075 #define GRADCDAC_CFG_TRIGPOL_BIT 4
0076 #define GRADCDAC_CFG_TRIGMODE_BIT 2
0077 #define GRADCDAC_CFG_ADCDW_BIT 0
0078
0079 #define GRADCDAC_STATUS_DACNO 0x40
0080 #define GRADCDAC_STATUS_DACRDY 0x20
0081 #define GRADCDAC_STATUS_DACON 0x10
0082 #define GRADCDAC_STATUS_ADCTO 0x08
0083 #define GRADCDAC_STATUS_ADCNO 0x04
0084 #define GRADCDAC_STATUS_ADCRDY 0x02
0085 #define GRADCDAC_STATUS_ADCON 0x01
0086
0087 #define GRADCDAC_STATUS_DACNO_BIT 6
0088 #define GRADCDAC_STATUS_DACRDY_BIT 5
0089 #define GRADCDAC_STATUS_DACON_BIT 4
0090 #define GRADCDAC_STATUS_ADCTO_BIT 3
0091 #define GRADCDAC_STATUS_ADCNO_BIT 2
0092 #define GRADCDAC_STATUS_ADCRDY_BIT 1
0093 #define GRADCDAC_STATUS_ADCON_BIT 0
0094
0095 #define GRADCDAC_IRQ_DAC 1
0096 #define GRADCDAC_IRQ_ADC 0
0097
0098 struct gradcdac_config {
0099 unsigned char dac_ws;
0100 char wr_pol;
0101 unsigned char dac_dw;
0102 unsigned char adc_ws;
0103 char rc_pol;
0104 unsigned char cs_mode;
0105 char cs_pol;
0106 char ready_mode;
0107 char ready_pol;
0108 char trigg_pol;
0109 unsigned char trigg_mode;
0110 unsigned char adc_dw;
0111 };
0112
0113 extern void *gradcdac_open(char *devname);
0114
0115 extern void gradcdac_set_config(void *cookie, struct gradcdac_config *cfg);
0116
0117 extern void gradcdac_get_config(void *cookie, struct gradcdac_config *cfg);
0118
0119 extern void gradcdac_set_cfg(void *cookie, unsigned int config);
0120
0121 extern unsigned int gradcdac_get_cfg(void *cookie);
0122
0123 extern unsigned int gradcdac_get_status(void *cookie);
0124
0125 static int __inline__ gradcdac_DAC_ReqRej(unsigned int status)
0126 {
0127 return (status & GRADCDAC_STATUS_DACNO);
0128 }
0129
0130 static int __inline__ gradcdac_DAC_isCompleted(unsigned int status)
0131 {
0132 return (status & GRADCDAC_STATUS_DACRDY);
0133 }
0134
0135 static int __inline__ gradcdac_DAC_isOngoing(unsigned int status)
0136 {
0137 return (status & GRADCDAC_STATUS_DACON);
0138 }
0139
0140 static int __inline__ gradcdac_ADC_isTimeouted(unsigned int status)
0141 {
0142 return (status & GRADCDAC_STATUS_ADCTO);
0143 }
0144
0145 static int __inline__ gradcdac_ADC_ReqRej(unsigned int status)
0146 {
0147 return (status & GRADCDAC_STATUS_ADCNO);
0148 }
0149
0150 static int __inline__ gradcdac_ADC_isCompleted(unsigned int status)
0151 {
0152 return (status & GRADCDAC_STATUS_ADCRDY);
0153 }
0154
0155 static int __inline__ gradcdac_ADC_isOngoing(unsigned int status)
0156 {
0157 return (status & GRADCDAC_STATUS_ADCON);
0158 }
0159
0160 #define GRADCDAC_ISR_BOTH 3
0161 #define GRADCDAC_ISR_DAC 2
0162 #define GRADCDAC_ISR_ADC 1
0163
0164
0165
0166
0167
0168
0169
0170
0171
0172
0173 extern int gradcdac_install_irq_handler
0174 (void *cookie, int adc, void (*isr)(void *cookie, void *arg), void *arg);
0175
0176 extern void gradcdac_uninstall_irq_handler(void *cookie, int adc);
0177
0178
0179
0180
0181
0182 extern void gradcdac_adc_convert_start(void *cookie);
0183
0184
0185
0186
0187
0188
0189
0190
0191
0192
0193 extern int gradcdac_adc_convert_try(void *cookie, unsigned short *digital_value);
0194
0195
0196
0197
0198
0199
0200
0201
0202 extern int gradcdac_adc_convert(void *cookie, unsigned short *digital_value);
0203
0204
0205
0206
0207
0208
0209 extern int gradcdac_dac_convert_try(void *cookie, unsigned short digital_value);
0210
0211
0212
0213
0214
0215
0216 extern void gradcdac_dac_convert(void *cookie, unsigned short digital_value);
0217
0218 extern unsigned int gradcdac_get_adrinput(void *cookie);
0219 extern void gradcdac_set_adrinput(void *cookie, unsigned int input);
0220
0221 extern unsigned int gradcdac_get_adroutput(void *cookie);
0222 extern void gradcdac_set_adroutput(void *cookie, unsigned int output);
0223
0224 extern unsigned int gradcdac_get_adrdir(void *cookie);
0225 extern void gradcdac_set_adrdir(void *cookie, unsigned int dir);
0226
0227 extern unsigned int gradcdac_get_datainput(void *cookie);
0228 extern void gradcdac_set_datainput(void *cookie, unsigned int input);
0229
0230 extern unsigned int gradcdac_get_dataoutput(void *cookie);
0231 extern void gradcdac_set_dataoutput(void *cookie, unsigned int output);
0232
0233 extern unsigned int gradcdac_get_datadir(void *cookie);
0234 extern void gradcdac_set_datadir(void *cookie, unsigned int dir);
0235
0236
0237 extern void grAdcDacShow(void *cookie);
0238
0239
0240 extern void gradcdac_register_drv (void);
0241
0242 #ifdef __cplusplus
0243 }
0244 #endif
0245
0246 #endif