3 Register descriptions for NI DAQ-STC chip
5 COMEDI - Linux Control and Measurement Device Interface
6 Copyright (C) 1998-9 David A. Schleef <ds@schleef.org>
8 This program is free software; you can redistribute it and/or modify
9 it under the terms of the GNU General Public License as published by
10 the Free Software Foundation; either version 2 of the License, or
11 (at your option) any later version.
13 This program is distributed in the hope that it will be useful,
14 but WITHOUT ANY WARRANTY; without even the implied warranty of
15 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
16 GNU General Public License for more details.
18 You should have received a copy of the GNU General Public License
19 along with this program; if not, write to the Free Software
20 Foundation, Inc., 675 Mass Ave, Cambridge, MA 02139, USA.
26 DAQ-STC Technical Reference Manual
29 #ifndef _COMEDI_NI_STC_H
30 #define _COMEDI_NI_STC_H
49 #define NUM_PFI_OUTPUT_SELECT_REGS 6
51 /* Registers in the National Instruments DAQ-STC chip */
53 #define Interrupt_A_Ack_Register 2
54 #define G0_Gate_Interrupt_Ack _bit15
55 #define G0_TC_Interrupt_Ack _bit14
56 #define AI_Error_Interrupt_Ack _bit13
57 #define AI_STOP_Interrupt_Ack _bit12
58 #define AI_START_Interrupt_Ack _bit11
59 #define AI_START2_Interrupt_Ack _bit10
60 #define AI_START1_Interrupt_Ack _bit9
61 #define AI_SC_TC_Interrupt_Ack _bit8
62 #define AI_SC_TC_Error_Confirm _bit7
63 #define G0_TC_Error_Confirm _bit6
64 #define G0_Gate_Error_Confirm _bit5
66 #define AI_Status_1_Register 2
67 #define Interrupt_A_St 0x8000
68 #define AI_FIFO_Full_St 0x4000
69 #define AI_FIFO_Half_Full_St 0x2000
70 #define AI_FIFO_Empty_St 0x1000
71 #define AI_Overrun_St 0x0800
72 #define AI_Overflow_St 0x0400
73 #define AI_SC_TC_Error_St 0x0200
74 #define AI_START2_St 0x0100
75 #define AI_START1_St 0x0080
76 #define AI_SC_TC_St 0x0040
77 #define AI_START_St 0x0020
78 #define AI_STOP_St 0x0010
79 #define G0_TC_St 0x0008
80 #define G0_Gate_Interrupt_St 0x0004
81 #define AI_FIFO_Request_St 0x0002
82 #define Pass_Thru_0_Interrupt_St 0x0001
84 #define AI_Status_2_Register 5
86 #define Interrupt_B_Ack_Register 3
87 enum Interrupt_B_Ack_Bits
89 AO_BC_TC_Interrupt_Ack = _bit8,
90 AO_Error_Interrupt_Ack = _bit13,
93 #define AO_Status_1_Register 3
94 #define Interrupt_B_St _bit15
95 #define AO_FIFO_Full_St _bit14
96 #define AO_FIFO_Half_Full_St _bit13
97 #define AO_FIFO_Empty_St _bit12
98 #define AO_BC_TC_Error_St _bit11
99 #define AO_START_St _bit10
100 #define AO_Overrun_St _bit9
101 #define AO_START1_St _bit8
102 #define AO_BC_TC_St _bit7
103 #define AO_UC_TC_St _bit6
104 #define AO_UPDATE_St _bit5
105 #define AO_UI2_TC_St _bit4
106 #define G1_TC_St _bit3
107 #define G1_Gate_Interrupt_St _bit2
108 #define AO_FIFO_Request_St _bit1
109 #define Pass_Thru_1_Interrupt_St _bit0
112 #define AI_Command_2_Register 4
113 #define AI_End_On_SC_TC _bit15
114 #define AI_End_On_End_Of_Scan _bit14
115 #define AI_START1_Disable _bit11
116 #define AI_SC_Save_Trace _bit10
117 #define AI_SI_Switch_Load_On_SC_TC _bit9
118 #define AI_SI_Switch_Load_On_STOP _bit8
119 #define AI_SI_Switch_Load_On_TC _bit7
120 #define AI_SC_Switch_Load_On_TC _bit4
121 #define AI_STOP_Pulse _bit3
122 #define AI_START_Pulse _bit2
123 #define AI_START2_Pulse _bit1
124 #define AI_START1_Pulse _bit0
126 #define AO_Command_2_Register 5
127 #define AO_End_On_BC_TC(x) (((x) & 0x3) << 14)
128 #define AO_Start_Stop_Gate_Enable _bit13
129 #define AO_UC_Save_Trace _bit12
130 #define AO_BC_Gate_Enable _bit11
131 #define AO_BC_Save_Trace _bit10
132 #define AO_UI_Switch_Load_On_BC_TC _bit9
133 #define AO_UI_Switch_Load_On_Stop _bit8
134 #define AO_UI_Switch_Load_On_TC _bit7
135 #define AO_UC_Switch_Load_On_BC_TC _bit6
136 #define AO_UC_Switch_Load_On_TC _bit5
137 #define AO_BC_Switch_Load_On_TC _bit4
138 #define AO_Mute_B _bit3
139 #define AO_Mute_A _bit2
140 #define AO_UPDATE2_Pulse _bit1
141 #define AO_START1_Pulse _bit0
143 #define AO_Status_2_Register 6
145 #define DIO_Parallel_Input_Register 7
147 #define AI_Command_1_Register 8
148 #define AI_Analog_Trigger_Reset _bit14
149 #define AI_Disarm _bit13
150 #define AI_SI2_Arm _bit12
151 #define AI_SI2_Load _bit11
152 #define AI_SI_Arm _bit10
153 #define AI_SI_Load _bit9
154 #define AI_DIV_Arm _bit8
155 #define AI_DIV_Load _bit7
156 #define AI_SC_Arm _bit6
157 #define AI_SC_Load _bit5
158 #define AI_SCAN_IN_PROG_Pulse _bit4
159 #define AI_EXTMUX_CLK_Pulse _bit3
160 #define AI_LOCALMUX_CLK_Pulse _bit2
161 #define AI_SC_TC_Pulse _bit1
162 #define AI_CONVERT_Pulse _bit0
164 #define AO_Command_1_Register 9
165 #define AO_Analog_Trigger_Reset _bit15
166 #define AO_START_Pulse _bit14
167 #define AO_Disarm _bit13
168 #define AO_UI2_Arm_Disarm _bit12
169 #define AO_UI2_Load _bit11
170 #define AO_UI_Arm _bit10
171 #define AO_UI_Load _bit9
172 #define AO_UC_Arm _bit8
173 #define AO_UC_Load _bit7
174 #define AO_BC_Arm _bit6
175 #define AO_BC_Load _bit5
176 #define AO_DAC1_Update_Mode _bit4
177 #define AO_LDAC1_Source_Select _bit3
178 #define AO_DAC0_Update_Mode _bit2
179 #define AO_LDAC0_Source_Select _bit1
180 #define AO_UPDATE_Pulse _bit0
183 #define DIO_Output_Register 10
184 #define DIO_Parallel_Data_Out(a) ((a)&0xff)
185 #define DIO_Parallel_Data_Mask 0xff
186 #define DIO_SDOUT _bit0
187 #define DIO_SDIN _bit4
188 #define DIO_Serial_Data_Out(a) (((a)&0xff)<<8)
189 #define DIO_Serial_Data_Mask 0xff00
191 #define DIO_Control_Register 11
192 #define DIO_Software_Serial_Control _bit11
193 #define DIO_HW_Serial_Timebase _bit10
194 #define DIO_HW_Serial_Enable _bit9
195 #define DIO_HW_Serial_Start _bit8
196 #define DIO_Pins_Dir(a) ((a)&0xff)
197 #define DIO_Pins_Dir_Mask 0xff
199 #define AI_Mode_1_Register 12
200 #define AI_CONVERT_Source_Select(a) (((a) & 0x1f) << 11)
201 #define AI_SI_Source_select(a) (((a) & 0x1f) << 6)
202 #define AI_CONVERT_Source_Polarity _bit5
203 #define AI_SI_Source_Polarity _bit4
204 #define AI_Start_Stop _bit3
205 #define AI_Mode_1_Reserved _bit2
206 #define AI_Continuous _bit1
207 #define AI_Trigger_Once _bit0
209 #define AI_Mode_2_Register 13
210 #define AI_SC_Gate_Enable _bit15
211 #define AI_Start_Stop_Gate_Enable _bit14
212 #define AI_Pre_Trigger _bit13
213 #define AI_External_MUX_Present _bit12
214 #define AI_SI2_Initial_Load_Source _bit9
215 #define AI_SI2_Reload_Mode _bit8
216 #define AI_SI_Initial_Load_Source _bit7
217 #define AI_SI_Reload_Mode(a) (((a) & 0x7)<<4)
218 #define AI_SI_Write_Switch _bit3
219 #define AI_SC_Initial_Load_Source _bit2
220 #define AI_SC_Reload_Mode _bit1
221 #define AI_SC_Write_Switch _bit0
223 #define AI_SI_Load_A_Registers 14
224 #define AI_SI_Load_B_Registers 16
225 #define AI_SC_Load_A_Registers 18
226 #define AI_SC_Load_B_Registers 20
227 #define AI_SI_Save_Registers 64
228 #define AI_SC_Save_Registers 66
230 #define AI_SI2_Load_A_Register 23
231 #define AI_SI2_Load_B_Register 25
233 #define Joint_Status_1_Register 27
234 #define DIO_Serial_IO_In_Progress_St _bit12
236 #define DIO_Serial_Input_Register 28
237 #define Joint_Status_2_Register 29
238 enum Joint_Status_2_Bits
240 AO_TMRDACWRs_In_Progress_St = 0x20,
243 #define AO_Mode_1_Register 38
244 #define AO_UPDATE_Source_Select(x) (((x)&0x1f)<<11)
245 #define AO_UI_Source_Select(x) (((x)&0x1f)<<6)
246 #define AO_Multiple_Channels _bit5
247 #define AO_UPDATE_Source_Polarity _bit4
248 #define AO_UI_Source_Polarity _bit3
249 #define AO_UC_Switch_Load_Every_TC _bit2
250 #define AO_Continuous _bit1
251 #define AO_Trigger_Once _bit0
253 #define AO_Mode_2_Register 39
254 #define AO_FIFO_Mode_Mask ( 0x3 << 14 )
255 enum AO_FIFO_Mode_Bits
257 AO_FIFO_Mode_HF_to_F = (3<<14),
258 AO_FIFO_Mode_F = (2<<14),
259 AO_FIFO_Mode_HF = (1<<14),
260 AO_FIFO_Mode_E = (0<<14),
262 #define AO_FIFO_Retransmit_Enable _bit13
263 #define AO_START1_Disable _bit12
264 #define AO_UC_Initial_Load_Source _bit11
265 #define AO_UC_Write_Switch _bit10
266 #define AO_UI2_Initial_Load_Source _bit9
267 #define AO_UI2_Reload_Mode _bit8
268 #define AO_UI_Initial_Load_Source _bit7
269 #define AO_UI_Reload_Mode(x) (((x) & 0x7) << 4)
270 #define AO_UI_Write_Switch _bit3
271 #define AO_BC_Initial_Load_Source _bit2
272 #define AO_BC_Reload_Mode _bit1
273 #define AO_BC_Write_Switch _bit0
275 #define AO_UI_Load_A_Register 40
276 #define AO_UI_Load_A_Register_High 40
277 #define AO_UI_Load_A_Register_Low 41
278 #define AO_UI_Load_B_Register 42
279 #define AO_UI_Save_Registers 16
280 #define AO_BC_Load_A_Register 44
281 #define AO_BC_Load_A_Register_High 44
282 #define AO_BC_Load_A_Register_Low 45
283 #define AO_BC_Load_B_Register 46
284 #define AO_BC_Load_B_Register_High 46
285 #define AO_BC_Load_B_Register_Low 47
286 #define AO_BC_Save_Registers 18
287 #define AO_UC_Load_A_Register 48
288 #define AO_UC_Load_A_Register_High 48
289 #define AO_UC_Load_A_Register_Low 49
290 #define AO_UC_Load_B_Register 50
291 #define AO_UC_Save_Registers 20
293 #define Clock_and_FOUT_Register 56
294 #define FOUT_Enable _bit15
295 #define FOUT_Timebase_Select _bit14
296 #define DIO_Serial_Out_Divide_By_2 _bit13
297 #define Slow_Internal_Time_Divide_By_2 _bit12
298 #define Slow_Internal_Timebase _bit11
299 #define G_Source_Divide_By_2 _bit10
300 #define Clock_To_Board_Divide_By_2 _bit9
301 #define Clock_To_Board _bit8
302 #define AI_Output_Divide_By_2 _bit7
303 #define AI_Source_Divide_By_2 _bit6
304 #define AO_Output_Divide_By_2 _bit5
305 #define AO_Source_Divide_By_2 _bit4
306 #define FOUT_Divider(x) (((x) & 0xf) << 0)
308 #define IO_Bidirection_Pin_Register 57
309 #define RTSI_Trig_Direction_Register 58
310 enum RTSI_Trig_Direction_Bits
312 Drive_RTSI_Clock_Bit = 0x1,
313 Use_RTSI_Clock_Bit = 0x2,
315 static inline unsigned RTSI_Output_Bit(unsigned channel, int is_mseries)
317 unsigned max_channel;
318 unsigned base_bit_shift;
328 if(channel > max_channel)
330 rt_printk("%s: bug, invalid RTSI_channel=%i\n", __FUNCTION__, channel);
333 return 1 << (base_bit_shift + channel);
336 #define Interrupt_Control_Register 59
337 #define Interrupt_B_Enable _bit15
338 #define Interrupt_B_Output_Select(x) ((x)<<12)
339 #define Interrupt_A_Enable _bit11
340 #define Interrupt_A_Output_Select(x) ((x)<<8)
341 #define Pass_Thru_0_Interrupt_Polarity _bit3
342 #define Pass_Thru_1_Interrupt_Polarity _bit2
343 #define Interrupt_Output_On_3_Pins _bit1
344 #define Interrupt_Output_Polarity _bit0
346 #define AI_Output_Control_Register 60
347 #define AI_START_Output_Select _bit10
348 #define AI_SCAN_IN_PROG_Output_Select(x) (((x) & 0x3) << 8)
349 #define AI_EXTMUX_CLK_Output_Select(x) (((x) & 0x3) << 6)
350 #define AI_LOCALMUX_CLK_Output_Select(x) ((x)<<4)
351 #define AI_SC_TC_Output_Select(x) ((x)<<2)
352 #define AI_CONVERT_Output_Select(x) (((x) & 0x3) << 0)
354 #define AI_START_STOP_Select_Register 62
355 #define AI_START_Polarity _bit15
356 #define AI_STOP_Polarity _bit14
357 #define AI_STOP_Sync _bit13
358 #define AI_STOP_Edge _bit12
359 #define AI_STOP_Select(a) (((a) & 0x1f)<<7)
360 #define AI_START_Sync _bit6
361 #define AI_START_Edge _bit5
362 #define AI_START_Select(a) ((a) & 0x1f)
364 #define AI_Trigger_Select_Register 63
365 #define AI_START1_Polarity _bit15
366 #define AI_START2_Polarity _bit14
367 #define AI_START2_Sync _bit13
368 #define AI_START2_Edge _bit12
369 #define AI_START2_Select(a) (((a) & 0x1f) << 7)
370 #define AI_START1_Sync _bit6
371 #define AI_START1_Edge _bit5
372 #define AI_START1_Select(a) ((a) & 0x1f)
374 #define AI_DIV_Load_A_Register 64
376 #define AO_Start_Select_Register 66
377 #define AO_UI2_Software_Gate _bit15
378 #define AO_UI2_External_Gate_Polarity _bit14
379 #define AO_START_Polarity _bit13
380 #define AO_AOFREQ_Enable _bit12
381 #define AO_UI2_External_Gate_Select(a) (((a) & 0x1f) << 7)
382 #define AO_START_Sync _bit6
383 #define AO_START_Edge _bit5
384 #define AO_START_Select(a) ((a) & 0x1f)
386 #define AO_Trigger_Select_Register 67
387 #define AO_UI2_External_Gate_Enable _bit15
388 #define AO_Delayed_START1 _bit14
389 #define AO_START1_Polarity _bit13
390 #define AO_UI2_Source_Polarity _bit12
391 #define AO_UI2_Source_Select(x) (((x)&0x1f)<<7)
392 #define AO_START1_Sync _bit6
393 #define AO_START1_Edge _bit5
394 #define AO_START1_Select(x) (((x)&0x1f)<<0)
396 #define AO_Mode_3_Register 70
397 #define AO_UI2_Switch_Load_Next_TC _bit13
398 #define AO_UC_Switch_Load_Every_BC_TC _bit12
399 #define AO_Trigger_Length _bit11
400 #define AO_Stop_On_Overrun_Error _bit5
401 #define AO_Stop_On_BC_TC_Trigger_Error _bit4
402 #define AO_Stop_On_BC_TC_Error _bit3
403 #define AO_Not_An_UPDATE _bit2
404 #define AO_Software_Gate _bit1
405 #define AO_Last_Gate_Disable _bit0 /* M Series only */
407 #define Joint_Reset_Register 72
408 #define Software_Reset _bit11
409 #define AO_Configuration_End _bit9
410 #define AI_Configuration_End _bit8
411 #define AO_Configuration_Start _bit5
412 #define AI_Configuration_Start _bit4
413 #define G1_Reset _bit3
414 #define G0_Reset _bit2
415 #define AO_Reset _bit1
416 #define AI_Reset _bit0
418 #define Interrupt_A_Enable_Register 73
419 #define Pass_Thru_0_Interrupt_Enable _bit9
420 #define G0_Gate_Interrupt_Enable _bit8
421 #define AI_FIFO_Interrupt_Enable _bit7
422 #define G0_TC_Interrupt_Enable _bit6
423 #define AI_Error_Interrupt_Enable _bit5
424 #define AI_STOP_Interrupt_Enable _bit4
425 #define AI_START_Interrupt_Enable _bit3
426 #define AI_START2_Interrupt_Enable _bit2
427 #define AI_START1_Interrupt_Enable _bit1
428 #define AI_SC_TC_Interrupt_Enable _bit0
430 #define Interrupt_B_Enable_Register 75
431 #define Pass_Thru_1_Interrupt_Enable _bit11
432 #define G1_Gate_Interrupt_Enable _bit10
433 #define G1_TC_Interrupt_Enable _bit9
434 #define AO_FIFO_Interrupt_Enable _bit8
435 #define AO_UI2_TC_Interrupt_Enable _bit7
436 #define AO_UC_TC_Interrupt_Enable _bit6
437 #define AO_Error_Interrupt_Enable _bit5
438 #define AO_STOP_Interrupt_Enable _bit4
439 #define AO_START_Interrupt_Enable _bit3
440 #define AO_UPDATE_Interrupt_Enable _bit2
441 #define AO_START1_Interrupt_Enable _bit1
442 #define AO_BC_TC_Interrupt_Enable _bit0
444 #define Second_IRQ_B_Enable_Register 76
445 #define AI_Personal_Register 77
446 #define AI_SHIFTIN_Pulse_Width _bit15
447 #define AI_EOC_Polarity _bit14
448 #define AI_SOC_Polarity _bit13
449 #define AI_SHIFTIN_Polarity _bit12
450 #define AI_CONVERT_Pulse_Timebase _bit11
451 #define AI_CONVERT_Pulse_Width _bit10
452 #define AI_CONVERT_Original_Pulse _bit9
453 #define AI_FIFO_Flags_Polarity _bit8
454 #define AI_Overrun_Mode _bit7
455 #define AI_EXTMUX_CLK_Pulse_Width _bit6
456 #define AI_LOCALMUX_CLK_Pulse_Width _bit5
457 #define AI_AIFREQ_Polarity _bit4
459 #define AO_Personal_Register 78
460 enum AO_Personal_Bits
462 AO_Interval_Buffer_Mode = 1 << 3,
463 AO_BC_Source_Select = 1 << 4,
464 AO_UPDATE_Pulse_Width = 1 << 5,
465 AO_DMA_PIO_Control = 1 << 8, /* M Series: reserved */
466 AO_AOFREQ_Polarity = 1 << 9, /* M Series: reserved */
467 AO_FIFO_Enable = 1 << 10,
468 AO_TMRDACWR_Pulse_Width = 1 << 12,
469 AO_Number_Of_DAC_Packages = 1 << 14, // 1 for "single" mode, 0 for "dual"
471 #define RTSI_Trig_A_Output_Register 79
472 #define RTSI_Trig_B_Output_Register 80
473 enum RTSI_Trig_B_Output_Bits
475 RTSI_Sub_Selection_1_Bit = 0x8000 // not for m-series
477 static inline unsigned RTSI_Trig_Output_Bits(unsigned rtsi_channel, unsigned source)
479 return (source & 0xf) << ((rtsi_channel % 4) * 4);
481 static inline unsigned RTSI_Trig_Output_Mask(unsigned rtsi_channel)
483 return 0xf << ((rtsi_channel % 4) * 4);
485 // inverse to RTSI_Trig_Output_Bits()
486 static inline unsigned RTSI_Trig_Output_Source(unsigned rtsi_channel, unsigned bits)
488 return (bits >> ((rtsi_channel % 4) * 4)) & 0xf;
491 #define RTSI_Board_Register 81
492 #define Write_Strobe_0_Register 82
493 #define Write_Strobe_1_Register 83
494 #define Write_Strobe_2_Register 84
495 #define Write_Strobe_3_Register 85
497 #define AO_Output_Control_Register 86
498 #define AO_External_Gate_Enable _bit15
499 #define AO_External_Gate_Select(x) (((x)&0x1f)<<10)
500 #define AO_Number_Of_Channels(x) (((x)&0xf)<<6)
501 #define AO_UPDATE2_Output_Select(x) (((x)&0x3)<<4)
502 #define AO_External_Gate_Polarity _bit3
503 #define AO_UPDATE2_Output_Toggle _bit2
504 #define AO_UPDATE_Output_Select(x) (((x)&0x3)<<0)
506 #define AI_Mode_3_Register 87
507 #define AI_Trigger_Length _bit15
508 #define AI_Delay_START _bit14
509 #define AI_Software_Gate _bit13
510 #define AI_SI_Special_Trigger_Delay _bit12
511 #define AI_SI2_Source_Select _bit11
512 #define AI_Delayed_START2 _bit10
513 #define AI_Delayed_START1 _bit9
514 #define AI_External_Gate_Mode _bit8
515 #define AI_FIFO_Mode_HF_to_E (3<<6)
516 #define AI_FIFO_Mode_F (2<<6)
517 #define AI_FIFO_Mode_HF (1<<6)
518 #define AI_FIFO_Mode_NE (0<<6)
519 #define AI_External_Gate_Polarity _bit5
520 #define AI_External_Gate_Select(a) ((a) & 0x1f)
522 #define G_Autoincrement_Register(a) (68+(a))
523 #define G_Command_Register(a) (6+(a))
524 #define G_HW_Save_Register(a) (8+(a)*2)
525 #define G_HW_Save_Register_High(a) (8+(a)*2)
526 #define G_HW_Save_Register_Low(a) (9+(a)*2)
527 #define G_Input_Select_Register(a) (36+(a))
528 #define G_Load_A_Register(a) (28+(a)*4)
529 #define G_Load_A_Register_High(a) (28+(a)*4)
530 #define G_Load_A_Register_Low(a) (29+(a)*4)
531 #define G_Load_B_Register(a) (30+(a)*4)
532 #define G_Load_B_Register_High(a) (30+(a)*4)
533 #define G_Load_B_Register_Low(a) (31+(a)*4)
534 #define G_Mode_Register(a) (26+(a))
535 #define G_Save_Register(a) (12+(a)*2)
536 #define G_Save_Register_High(a) (12+(a)*2)
537 #define G_Save_Register_Low(a) (13+(a)*2)
538 #define G_Status_Register 4
539 #define Analog_Trigger_Etc_Register 61
541 /* command register */
542 #define G_Disarm_Copy _bit15 /* strobe */
543 #define G_Save_Trace_Copy _bit14
544 #define G_Arm_Copy _bit13 /* strobe */
545 #define G_Bank_Switch_Start _bit10 /* strobe */
546 #define G_Little_Big_Endian _bit9
547 #define G_Synchronized_Gate _bit8
548 #define G_Write_Switch _bit7
549 #define G_Up_Down(a) (((a)&0x03)<<5)
550 #define G_Disarm _bit4 /* strobe */
551 #define G_Analog_Trigger_Reset _bit3 /* strobe */
552 #define G_Save_Trace _bit1
553 #define G_Arm _bit0 /* strobe */
555 /*channel agnostic names for the command register #defines */
556 #define G_Bank_Switch_Enable _bit12
557 #define G_Bank_Switch_Mode _bit11
558 #define G_Load _bit2 /* strobe */
561 /* input select register */
562 #define G_Gate_Select(a) (((a)&0x1f)<<7)
563 #define G_Source_Select(a) (((a)&0x1f)<<2)
564 #define G_Write_Acknowledges_Irq _bit1
565 #define G_Read_Acknowledges_Irq _bit0
567 /* same input select register, but with channel agnostic names */
568 #define G_Source_Polarity _bit15
569 #define G_Output_Polarity _bit14
570 #define G_OR_Gate _bit13
571 #define G_Gate_Select_Load_Source _bit12
575 #define G_Loading_On_TC _bit12
576 #define G_Output_Mode(a) (((a)&0x03)<<8)
577 #define G_Trigger_Mode_For_Edge_Gate(a) (((a)&0x03)<<3)
578 #define G_Gating_Mode(a) (((a)&0x03)<<0)
580 /* same input mode register, but with channel agnostic names */
581 #define G_Load_Source_Select _bit7
582 #define G_Reload_Source_Switching _bit15
583 #define G_Loading_On_Gate _bit14
584 #define G_Gate_Polarity _bit13
586 #define G_Counting_Once(a) (((a)&0x03)<<10)
587 #define G_Stop_Mode(a) (((a)&0x03)<<5)
588 #define G_Gate_On_Both_Edges _bit2
590 /* G_Status_Register */
591 #define G1_Gate_Error_St _bit15
592 #define G0_Gate_Error_St _bit14
593 #define G1_TC_Error_St _bit13
594 #define G0_TC_Error_St _bit12
595 #define G1_No_Load_Between_Gates_St _bit11
596 #define G0_No_Load_Between_Gates_St _bit10
597 #define G1_Armed_St _bit9
598 #define G0_Armed_St _bit8
599 #define G1_Stale_Data_St _bit7
600 #define G0_Stale_Data_St _bit6
601 #define G1_Next_Load_Source_St _bit5
602 #define G0_Next_Load_Source_St _bit4
603 #define G1_Counting_St _bit3
604 #define G0_Counting_St _bit2
605 #define G1_Save_St _bit1
606 #define G0_Save_St _bit0
608 /* general purpose counter timer */
609 #define G0_TC_Interrupt_Enable _bit6
610 #define G1_TC_Interrupt_Enable _bit9
611 #define G0_Gate_Interrupt_Enable _bit8
612 #define G1_Gate_Interrupt_Enable _bit10
613 #define G0_Synchronized_Gate _bit8
614 #define G1_Synchronized_Gate _bit8
615 #define G0_Gate_Error_Confirm _bit5
616 #define G1_Gate_Error_Confirm _bit1
617 #define G0_TC_Error_Confirm _bit6
618 #define G1_TC_Error_Confirm _bit2
619 #define G0_TC_Interrupt_Ack _bit14
620 #define G1_TC_Interrupt_Ack _bit14
621 #define G0_Gate_Interrupt_Ack _bit15
622 #define G1_Gate_Interrupt_Ack _bit15
623 #define G_Autoincrement(a) ((a)<<0)
624 #define G_Autoincrement(a) ((a)<<0)
628 /*Analog_Trigger_Etc_Register*/
629 #define Analog_Trigger_Mode(x) ((x) & 0x7)
630 #define Analog_Trigger_Enable _bit3
631 #define Analog_Trigger_Drive _bit4
632 #define GPFO_1_Output_Select _bit7
633 #define GPFO_0_Output_Select(a) ((a)<<11)
634 #define GPFO_0_Output_Enable _bit14
635 #define GPFO_1_Output_Enable _bit15
637 /* Additional windowed registers unique to E series */
639 /* 16 bit registers shadowed from DAQ-STC */
640 #define Window_Address 0x00
641 #define Window_Data 0x02
643 #define Configuration_Memory_Clear 82
644 #define ADC_FIFO_Clear 83
645 #define DAC_FIFO_Clear 84
647 /* i/o port offsets */
649 /* 8 bit registers */
650 #define XXX_Status 0x01
654 AI_FIFO_LOWER_NOT_EMPTY = 0x8,
656 #define Serial_Command 0x0d
657 #define Misc_Command 0x0f
661 #define Configuration 0x1f
663 #define Channel_A_Mode 0x03
664 #define Channel_B_Mode 0x05
665 #define Channel_C_Mode 0x07
666 #define AI_AO_Select 0x09
667 #define G0_G1_Select 0x0b
669 /* 16 bit registers */
671 #define Configuration_Memory_Low 0x10
672 enum Configuration_Memory_Low_Bits
675 AI_LAST_CHANNEL = 0x8000,
677 #define Configuration_Memory_High 0x12
678 enum Configuration_Memory_High_Bits
680 AI_AC_COUPLE = 0x800,
681 AI_DIFFERENTIAL = 0x1000,
685 static inline unsigned int AI_CONFIG_CHANNEL( unsigned int channel )
687 return ( channel & 0x3f );
690 #define ADC_FIFO_Data_Register 0x1c
692 #define AO_Configuration 0x16
693 #define AO_Bipolar _bit0
694 #define AO_Deglitch _bit1
695 #define AO_Ext_Ref _bit2
696 #define AO_Ground_Ref _bit3
697 #define AO_Channel(x) ((x) << 8)
699 #define DAC_FIFO_Data 0x1e
700 #define DAC0_Direct_Data 0x18
701 #define DAC1_Direct_Data 0x1a
704 /* 611x registers (these boards differ from the e-series) */
706 #define Magic_611x 0x19 /* w8 (new) */
707 #define Calibration_Channel_Select_611x 0x1a /* w16 (new) */
708 #define ADC_FIFO_Data_611x 0x1c /* r32 (incompatible) */
709 #define AI_FIFO_Offset_Load_611x 0x05 /* r8 (new) */
710 #define DAC_FIFO_Data_611x 0x14 /* w32 (incompatible) */
711 #define Cal_Gain_Select_611x 0x05 /* w8 (new) */
713 #define AO_Window_Address_611x 0x18
714 #define AO_Window_Data_611x 0x1e
717 #define Magic_6143 0x19 /* w8 */
718 #define G0G1_DMA_Select_6143 0x0B /* w8 */
719 #define PipelineDelay_6143 0x1f /* w8 */
720 #define EOC_Set_6143 0x1D /* w8 */
721 #define AIDMA_Select_6143 0x09 /* w8 */
722 #define AIFIFO_Data_6143 0x8C /* w32 */
723 #define AIFIFO_Flag_6143 0x84 /* w32 */
724 #define AIFIFO_Control_6143 0x88 /* w32 */
725 #define AIFIFO_Status_6143 0x88 /* w32 */
726 #define AIFIFO_DMAThreshold_6143 0x90 /* w32 */
727 #define AIFIFO_Words_Available_6143 0x94 /* w32 */
729 #define Calibration_Channel_6143 0x42 /* w16 */
730 #define Calibration_LowTime_6143 0x20 /* w16 */
731 #define Calibration_HighTime_6143 0x22 /* w16 */
732 #define Relay_Counter_Load_Val__6143 0x4C /* w32 */
733 #define Signature_6143 0x50 /* w32 */
734 #define Release_Date_6143 0x54 /* w32 */
735 #define Release_Oldest_Date_6143 0x58 /* w32 */
737 #define Calibration_Channel_6143_RelayOn 0x8000 /* Calibration relay switch On */
738 #define Calibration_Channel_6143_RelayOff 0x4000 /* Calibration relay switch Off */
739 #define Calibration_Channel_Gnd_Gnd 0x00 /* Offset Calibration */
740 #define Calibration_Channel_2v5_Gnd 0x02 /* 2.5V Reference */
741 #define Calibration_Channel_Pwm_Gnd 0x05 /* +/- 5V Self Cal */
742 #define Calibration_Channel_2v5_Pwm 0x0a /* PWM Calibration */
743 #define Calibration_Channel_Pwm_Pwm 0x0d /* CMRR */
744 #define Calibration_Channel_Gnd_Pwm 0x0e /* PWM Calibration */
746 /* 671x, 611x registers */
748 /* 671xi, 611x windowed ao registers */
749 enum windowed_regs_67xx_61xx
751 AO_Immediate_671x = 0x11, /* W 16 */
752 AO_Timed_611x = 0x10, /* W 16 */
753 AO_FIFO_Offset_Load_611x = 0x13, /* W32 */
754 AO_Later_Single_Point_Updates = 0x14, /* W 16 */
755 AO_Waveform_Generation_611x = 0x15, /* W 16 */
756 AO_Misc_611x = 0x16, /* W 16 */
757 AO_Calibration_Channel_Select_67xx = 0x17, /* W 16 */
758 AO_Configuration_2_67xx = 0x18, /* W 16 */
759 CAL_ADC_Command_67xx = 0x19, /* W 8 */
760 CAL_ADC_Status_67xx = 0x1a, /* R 8 */
761 CAL_ADC_Data_67xx = 0x1b, /* R 16 */
762 CAL_ADC_Config_Data_High_Word_67xx = 0x1c, /* RW 16 */
763 CAL_ADC_Config_Data_Low_Word_67xx = 0x1d, /* RW 16 */
765 static inline unsigned int DACx_Direct_Data_671x(int channel)
769 enum AO_Misc_611x_Bits
773 enum cs5529_configuration_bits
775 CSCFG_CAL_CONTROL_MASK = 0x7,
776 CSCFG_SELF_CAL_OFFSET = 0x1,
777 CSCFG_SELF_CAL_GAIN = 0x2,
778 CSCFG_SELF_CAL_OFFSET_GAIN = 0x3,
779 CSCFG_SYSTEM_CAL_OFFSET = 0x5,
780 CSCFG_SYSTEM_CAL_GAIN = 0x6,
782 CSCFG_POWER_SAVE_SELECT = 1 << 4,
783 CSCFG_PORT_MODE = 1 << 5,
784 CSCFG_RESET_VALID = 1 << 6,
785 CSCFG_RESET = 1 << 7,
786 CSCFG_UNIPOLAR = 1 << 12,
787 CSCFG_WORD_RATE_2180_CYCLES = 0x0 << 13,
788 CSCFG_WORD_RATE_1092_CYCLES = 0x1 << 13,
789 CSCFG_WORD_RATE_532_CYCLES = 0x2 << 13,
790 CSCFG_WORD_RATE_388_CYCLES = 0x3 << 13,
791 CSCFG_WORD_RATE_324_CYCLES = 0x4 << 13,
792 CSCFG_WORD_RATE_17444_CYCLES = 0x5 << 13,
793 CSCFG_WORD_RATE_8724_CYCLES = 0x6 << 13,
794 CSCFG_WORD_RATE_4364_CYCLES = 0x7 << 13,
795 CSCFG_WORD_RATE_MASK = 0x7 << 13,
796 CSCFG_LOW_POWER = 1 << 16,
798 static inline unsigned int CS5529_CONFIG_DOUT(int output)
800 return 1 << (18 + output);
802 static inline unsigned int CS5529_CONFIG_AOUT(int output)
804 return 1 << (22 + output);
806 enum cs5529_command_bits
808 CSCMD_POWER_SAVE = 0x1,
809 CSCMD_REGISTER_SELECT_MASK = 0xe,
810 CSCMD_OFFSET_REGISTER = 0x0,
811 CSCMD_GAIN_REGISTER = 0x2,
812 CSCMD_CONFIG_REGISTER = 0x4,
814 CSCMD_CONTINUOUS_CONVERSIONS = 0x20,
815 CSCMD_SINGLE_CONVERSION = 0x40,
816 CSCMD_COMMAND = 0x80,
818 enum cs5529_status_bits
821 CSS_OSC_DETECT = 0x2, /* indicates adc error */
824 #define SerDacLd(x) (0x08<<(x))
827 This is stuff unique to the NI E series drivers,
828 but I thought I'd put it here anyway.
831 /* our default usage of mite channels */
832 enum mite_dma_channel{
839 enum{ ai_gain_16=0, ai_gain_8, ai_gain_14, ai_gain_4, ai_gain_611x, ai_gain_622x, ai_gain_628x, ai_gain_6143};
840 enum caldac_enum { caldac_none=0, mb88341, dac8800, dac8043, ad8522,
841 ad8804, ad8842, ad8804_debug };
847 ni_reg_67xx_mask = 0x6,
848 ni_reg_6xxx_mask = 0x7,
849 ni_reg_m_series = 0x8,
853 static comedi_lrange range_ni_E_ao_ext;
855 enum m_series_register_offsets
857 M_Offset_CDIO_DMA_Select = 0x7, // write
858 M_Offset_SCXI_Status = 0x7, // read
859 M_Offset_AI_AO_Select = 0x9, // write
860 M_Offset_SCXI_Serial_Data_In = 0x9, // read
861 M_Offset_G0_G1_Select = 0xb,
862 M_Offset_Misc_Command = 0xf,
863 M_Offset_SCXI_Serial_Data_Out = 0x11,
864 M_Offset_SCXI_Control = 0x13,
865 M_Offset_SCXI_Output_Enable = 0x15,
866 M_Offset_AI_FIFO_Data = 0x1c,
867 M_Offset_Static_Digital_Output = 0x24, // write
868 M_Offset_Static_Digital_Input = 0x24, // read
869 M_Offset_DIO_Direction = 0x28,
870 M_Offset_Cal_PWM = 0x40,
871 M_Offset_AI_Config_FIFO_Data = 0x5e,
872 M_Offset_Interrupt_C_Enable = 0x88, // write
873 M_Offset_Interrupt_C_Status = 0x88, // read
874 M_Offset_Analog_Trigger_Control = 0x8c,
875 M_Offset_AO_Serial_Interrupt_Enable = 0xa0,
876 M_Offset_AO_Serial_Interrupt_Ack = 0xa1, // write
877 M_Offset_AO_Serial_Interrupt_Status = 0xa1, // read
878 M_Offset_AO_Calibration = 0xa3,
879 M_Offset_AO_FIFO_Data = 0xa4,
880 M_Offset_PFI_Filter = 0xb0,
881 M_Offset_RTSI_Filter = 0xb4,
882 M_Offset_SCXI_Legacy_Compatibility = 0xbc,
883 M_Offset_Interrupt_A_Ack = 0x104, // write
884 M_Offset_AI_Status_1 = 0x104, // read
885 M_Offset_Interrupt_B_Ack = 0x106, // write
886 M_Offset_AO_Status_1 = 0x106, // read
887 M_Offset_AI_Command_2 = 0x108, // write
888 M_Offset_G01_Status = 0x108, // read
889 M_Offset_AO_Command_2 = 0x10a,
890 M_Offset_AO_Status_2 = 0x10c, // read
891 M_Offset_G0_Command = 0x10c, // write
892 M_Offset_G1_Command = 0x10e, // write
893 M_Offset_G0_HW_Save = 0x110,
894 M_Offset_G0_HW_Save_High = 0x110,
895 M_Offset_AI_Command_1 = 0x110,
896 M_Offset_G0_HW_Save_Low = 0x112,
897 M_Offset_AO_Command_1 = 0x112,
898 M_Offset_G1_HW_Save = 0x114,
899 M_Offset_G1_HW_Save_High = 0x114,
900 M_Offset_G1_HW_Save_Low = 0x116,
901 M_Offset_AI_Mode_1 = 0x118,
902 M_Offset_G0_Save = 0x118,
903 M_Offset_G0_Save_High = 0x118,
904 M_Offset_AI_Mode_2 = 0x11a,
905 M_Offset_G0_Save_Low = 0x11a,
906 M_Offset_AI_SI_Load_A = 0x11c,
907 M_Offset_G1_Save = 0x11c,
908 M_Offset_G1_Save_High = 0x11c,
909 M_Offset_G1_Save_Low = 0x11e,
910 M_Offset_AI_SI_Load_B = 0x120, // write
911 M_Offset_AO_UI_Save = 0x120, // read
912 M_Offset_AI_SC_Load_A = 0x124, // write
913 M_Offset_AO_BC_Save = 0x124, // read
914 M_Offset_AI_SC_Load_B = 0x128, // write
915 M_Offset_AO_UC_Save = 0x128, //read
916 M_Offset_AI_SI2_Load_A = 0x12c,
917 M_Offset_AI_SI2_Load_B = 0x130,
918 M_Offset_G0_Mode = 0x134,
919 M_Offset_G1_Mode = 0x136, // write
920 M_Offset_Joint_Status_1 = 0x136, // read
921 M_Offset_G0_Load_A = 0x138,
922 M_Offset_Joint_Status_2 = 0x13a,
923 M_Offset_G0_Load_B = 0x13c,
924 M_Offset_G1_Load_A = 0x140,
925 M_Offset_G1_Load_B = 0x144,
926 M_Offset_G0_Input_Select = 0x148,
927 M_Offset_G1_Input_Select = 0x14a,
928 M_Offset_AO_Mode_1 = 0x14c,
929 M_Offset_AO_Mode_2 = 0x14e,
930 M_Offset_AO_UI_Load_A = 0x150,
931 M_Offset_AO_UI_Load_B = 0x154,
932 M_Offset_AO_BC_Load_A = 0x158,
933 M_Offset_AO_BC_Load_B = 0x15c,
934 M_Offset_AO_UC_Load_A = 0x160,
935 M_Offset_AO_UC_Load_B = 0x164,
936 M_Offset_Clock_and_FOUT = 0x170,
937 M_Offset_IO_Bidirection_Pin = 0x172,
938 M_Offset_RTSI_Trig_Direction = 0x174,
939 M_Offset_Interrupt_Control = 0x176,
940 M_Offset_AI_Output_Control = 0x178,
941 M_Offset_Analog_Trigger_Etc = 0x17a,
942 M_Offset_AI_START_STOP_Select = 0x17c,
943 M_Offset_AI_Trigger_Select = 0x17e,
944 M_Offset_AI_SI_Save = 0x180, // read
945 M_Offset_AI_DIV_Load_A = 0x180, // write
946 M_Offset_AI_SC_Save = 0x184, // read
947 M_Offset_AO_Start_Select = 0x184, // write
948 M_Offset_AO_Trigger_Select = 0x186,
949 M_Offset_AO_Mode_3 = 0x18c,
950 M_Offset_G0_Autoincrement = 0x188,
951 M_Offset_G1_Autoincrement = 0x18a,
952 M_Offset_Joint_Reset = 0x190,
953 M_Offset_Interrupt_A_Enable = 0x192,
954 M_Offset_Interrupt_B_Enable = 0x196,
955 M_Offset_AI_Personal = 0x19a,
956 M_Offset_AO_Personal = 0x19c,
957 M_Offset_RTSI_Trig_A_Output = 0x19e,
958 M_Offset_RTSI_Trig_B_Output = 0x1a0,
959 M_Offset_RTSI_Shared_MUX = 0x1a2,
960 M_Offset_AO_Output_Control = 0x1ac,
961 M_Offset_AI_Mode_3 = 0x1ae,
962 M_Offset_Configuration_Memory_Clear = 0x1a4,
963 M_Offset_AI_FIFO_Clear = 0x1a6,
964 M_Offset_AO_FIFO_Clear = 0x1a8,
965 M_Offset_G0_Counting_Mode = 0x1b0,
966 M_Offset_G1_Counting_Mode = 0x1b2,
967 M_Offset_G0_Second_Gate = 0x1b4,
968 M_Offset_G1_Second_Gate = 0x1b6,
969 M_Offset_G0_DMA_Config = 0x1b8, // write
970 M_Offset_G0_DMA_Status = 0x1b8, // read
971 M_Offset_G1_DMA_Config = 0x1ba, // write
972 M_Offset_G1_DMA_Status = 0x1ba, // read
973 M_Offset_G0_MSeries_ABZ = 0x1c0,
974 M_Offset_G1_MSeries_ABZ = 0x1c2,
975 M_Offset_Clock_and_Fout2 = 0x1c4,
976 M_Offset_PLL_Control = 0x1c6,
977 M_Offset_PLL_Status = 0x1c8,
978 M_Offset_PFI_Output_Select_1 = 0x1d0,
979 M_Offset_PFI_Output_Select_2 = 0x1d2,
980 M_Offset_PFI_Output_Select_3 = 0x1d4,
981 M_Offset_PFI_Output_Select_4 = 0x1d6,
982 M_Offset_PFI_Output_Select_5 = 0x1d8,
983 M_Offset_PFI_Output_Select_6 = 0x1da,
984 M_Offset_PFI_DI = 0x1dc,
985 M_Offset_PFI_DO = 0x1de,
986 M_Offset_AI_Config_FIFO_Bypass = 0x218,
987 M_Offset_SCXI_DIO_Enable = 0x21c,
988 M_Offset_CDI_FIFO_Data = 0x220, // read
989 M_Offset_CDO_FIFO_Data = 0x220, // write
990 M_Offset_CDIO_Status = 0x224, // read
991 M_Offset_CDIO_Command = 0x224, // write
992 M_Offset_CDI_Mode = 0x228,
993 M_Offset_CDO_Mode = 0x22c,
994 M_Offset_CDI_Mask_Enable = 0x230,
995 M_Offset_CDO_Mask_Enable = 0x234,
997 static inline int M_Offset_AO_Waveform_Order(int channel)
999 return 0xc2 + 0x4 * channel;
1001 static inline int M_Offset_AO_Config_Bank(int channel)
1003 return 0xc3 + 0x4 * channel;
1005 static inline int M_Offset_DAC_Direct_Data(int channel)
1007 return 0xc0 + 0x4 * channel;
1009 static inline int M_Offset_Gen_PWM(int channel)
1011 return 0x44 + 0x2 * channel;
1013 static inline int M_Offset_Static_AI_Control(int i)
1022 if(((unsigned)i) >= sizeof(offset) / sizeof(offset[0]))
1024 rt_printk("%s: invalid channel=%i\n", __FUNCTION__, i);
1029 static inline int M_Offset_AO_Reference_Attenuation(int channel)
1038 if(((unsigned)channel) >= sizeof(offset) / sizeof(offset[0]))
1040 rt_printk("%s: invalid channel=%i\n", __FUNCTION__, channel);
1043 return offset[channel];
1045 static inline unsigned M_Offset_PFI_Output_Select(unsigned n)
1047 if(n < 1 || n > NUM_PFI_OUTPUT_SELECT_REGS)
1049 rt_printk("%s: invalid pfi output select register=%i\n", __FUNCTION__, n);
1050 return M_Offset_PFI_Output_Select_1;
1052 return M_Offset_PFI_Output_Select_1 + (n - 1) * 2;
1055 enum MSeries_AI_Config_FIFO_Data_Bits
1057 MSeries_AI_Config_Channel_Type_Mask = 0x7 << 6,
1058 MSeries_AI_Config_Channel_Type_Calibration_Bits = 0x0,
1059 MSeries_AI_Config_Channel_Type_Differential_Bits = 0x1 << 6,
1060 MSeries_AI_Config_Channel_Type_Common_Ref_Bits = 0x2 << 6,
1061 MSeries_AI_Config_Channel_Type_Ground_Ref_Bits = 0x3 << 6,
1062 MSeries_AI_Config_Channel_Type_Aux_Bits = 0x5 << 6,
1063 MSeries_AI_Config_Channel_Type_Ghost_Bits = 0x7 << 6,
1064 MSeries_AI_Config_Polarity_Bit = 0x1000, // 0 for 2's complement encoding
1065 MSeries_AI_Config_Dither_Bit = 0x2000,
1066 MSeries_AI_Config_Last_Channel_Bit = 0x4000,
1068 static inline unsigned MSeries_AI_Config_Channel_Bits(unsigned channel)
1070 return channel & 0xf;
1072 static inline unsigned MSeries_AI_Config_Bank_Bits(unsigned channel)
1074 return channel & 0x30;
1076 static inline unsigned MSeries_AI_Config_Gain_Bits(unsigned range)
1078 return (range & 0x7) << 9;
1081 enum MSeries_Clock_and_Fout2_Bits
1083 MSeries_PLL_In_Source_Select_RTSI0_Bits = 0xb,
1084 MSeries_PLL_In_Source_Select_Star_Trigger_Bits = 0x14,
1085 MSeries_PLL_In_Source_Select_RTSI7_Bits = 0x1b,
1086 MSeries_PLL_In_Source_Select_PXI_Clock10 = 0x1d,
1087 MSeries_PLL_In_Source_Select_Mask = 0x1f,
1088 MSeries_Timebase1_Select_Bit = 0x20, // use PLL for timebase 1
1089 MSeries_Timebase3_Select_Bit = 0x40, // use PLL for timebase 3
1090 /* use 10MHz instead of 20MHz for RTSI clock frequency. Appears
1091 to have no effect, at least on pxi-6281, which always uses
1092 20MHz rtsi clock frequency */
1093 MSeries_RTSI_10MHz_Bit = 0x80
1095 static inline unsigned MSeries_PLL_In_Source_Select_RTSI_Bits(unsigned RTSI_channel)
1097 if(RTSI_channel > 7)
1099 rt_printk("%s: bug, invalid RTSI_channel=%i\n", __FUNCTION__, RTSI_channel);
1102 if(RTSI_channel == 7) return MSeries_PLL_In_Source_Select_RTSI7_Bits;
1103 else return MSeries_PLL_In_Source_Select_RTSI0_Bits + RTSI_channel;
1106 enum MSeries_PLL_Control_Bits
1108 MSeries_PLL_Enable_Bit = 0x1000,
1109 MSeries_PLL_VCO_Mode_200_325MHz_Bits = 0x0,
1110 MSeries_PLL_VCO_Mode_175_225MHz_Bits = 0x2000,
1111 MSeries_PLL_VCO_Mode_100_225MHz_Bits = 0x4000,
1112 MSeries_PLL_VCO_Mode_75_150MHz_Bits = 0x6000,
1114 static inline unsigned MSeries_PLL_Divisor_Bits(unsigned divisor)
1116 static const unsigned max_divisor = 0x10;
1117 if(divisor < 1 || divisor > max_divisor)
1119 rt_printk("%s: bug, invalid divisor=%i\n", __FUNCTION__, divisor);
1122 return (divisor & 0xf) << 8;
1124 static inline unsigned MSeries_PLL_Multiplier_Bits(unsigned multiplier)
1126 static const unsigned max_multiplier = 0x100;
1127 if(multiplier < 1 || multiplier > max_multiplier)
1129 rt_printk("%s: bug, invalid multiplier=%i\n", __FUNCTION__, multiplier);
1132 return multiplier & 0xff;
1135 enum MSeries_PLL_Status
1137 MSeries_PLL_Locked_Bit = 0x1
1140 enum MSeries_AI_Config_FIFO_Bypass_Bits
1142 MSeries_AI_Bypass_Channel_Mask = 0x7,
1143 MSeries_AI_Bypass_Bank_Mask = 0x78,
1144 MSeries_AI_Bypass_Cal_Sel_Pos_Mask = 0x380,
1145 MSeries_AI_Bypass_Cal_Sel_Neg_Mask = 0x1c00,
1146 MSeries_AI_Bypass_Mode_Mux_Mask = 0x6000,
1147 MSeries_AO_Bypass_AO_Cal_Sel_Mask = 0x38000,
1148 MSeries_AI_Bypass_Gain_Mask = 0x1c0000,
1149 MSeries_AI_Bypass_Dither_Bit = 0x200000,
1150 MSeries_AI_Bypass_Polarity_Bit = 0x400000, // 0 for 2's complement encoding
1151 MSeries_AI_Bypass_Config_FIFO_Bit = 0x80000000
1153 static inline unsigned MSeries_AI_Bypass_Cal_Sel_Pos_Bits(int calibration_source)
1155 return (calibration_source << 7) & MSeries_AI_Bypass_Cal_Sel_Pos_Mask;
1157 static inline unsigned MSeries_AI_Bypass_Cal_Sel_Neg_Bits(int calibration_source)
1159 return (calibration_source << 10) & MSeries_AI_Bypass_Cal_Sel_Pos_Mask;
1161 static inline unsigned MSeries_AI_Bypass_Gain_Bits(int gain)
1163 return (gain << 18) & MSeries_AI_Bypass_Gain_Mask;
1166 enum MSeries_AO_Config_Bank_Bits
1168 MSeries_AO_DAC_Offset_Select_Mask = 0x7,
1169 MSeries_AO_DAC_Offset_0V_Bits = 0x0,
1170 MSeries_AO_DAC_Offset_5V_Bits = 0x1,
1171 MSeries_AO_DAC_Reference_Mask = 0x38,
1172 MSeries_AO_DAC_Reference_10V_Internal_Bits = 0x0,
1173 MSeries_AO_DAC_Reference_5V_Internal_Bits = 0x8,
1174 MSeries_AO_Update_Timed_Bit = 0x40,
1175 MSeries_AO_Bipolar_Bit = 0x80 // turns on 2's complement encoding
1178 enum MSeries_AO_Reference_Attenuation_Bits
1180 MSeries_Attenuate_x5_Bit = 0x1
1183 static inline unsigned MSeries_Cal_PWM_High_Time_Bits(unsigned count)
1185 return (count << 16) & 0xffff0000;
1188 static inline unsigned MSeries_Cal_PWM_Low_Time_Bits(unsigned count)
1190 return count & 0xffff;
1193 static inline unsigned MSeries_PFI_Output_Select_Mask(unsigned channel)
1195 return 0x1f << (channel % 3) * 5;
1197 static inline unsigned MSeries_PFI_Output_Select_Bits(unsigned channel, unsigned source)
1199 return (source & 0x1f) << ((channel % 3) * 5);
1201 // inverse to MSeries_PFI_Output_Select_Bits
1202 static inline unsigned MSeries_PFI_Output_Select_Source(unsigned channel, unsigned bits)
1204 return (bits >> ((channel % 3) * 5)) & 0x1f;
1207 #define M_SERIES_EEPROM_SIZE 1024
1209 typedef struct ni_board_struct{
1218 unsigned int alwaysdither : 1;
1226 comedi_lrange *ao_range_table;
1230 unsigned int ao_unipolar : 1;
1231 unsigned int has_8255 : 1;
1232 unsigned int has_analog_trig : 1;
1234 enum caldac_enum caldac[3];
1237 static ni_board ni_boards[];
1238 #define n_ni_boards (sizeof(ni_boards)/sizeof(ni_board))
1240 #define boardtype (*(ni_board *)dev->board_ptr)
1242 #define MAX_N_AO_CHAN 8
1244 #define NI_PRIVATE_COMMON \
1245 uint16_t (*stc_readw)(comedi_device *dev, int register); \
1246 void (*stc_writew)(comedi_device *dev, uint16_t value, int register); \
1247 void (*stc_writel)(comedi_device *dev, uint32_t value, int register); \
1249 unsigned short dio_output; \
1250 unsigned short dio_control; \
1257 int ai_continuous; \
1260 unsigned int ai_calib_source; \
1261 unsigned int ai_calib_source_enabled; \
1262 spinlock_t window_lock; \
1264 int changain_state; \
1265 unsigned int changain_spec; \
1267 unsigned int caldac_maxdata_list[MAX_N_CALDACS]; \
1268 unsigned short ao[MAX_N_AO_CHAN]; \
1269 unsigned short caldacs[MAX_N_CALDACS]; \
1271 volatile unsigned short ai_cmd2; \
1273 unsigned short ao_conf[MAX_N_AO_CHAN]; \
1274 unsigned short ao_mode1; \
1275 unsigned short ao_mode2; \
1276 unsigned short ao_mode3; \
1277 unsigned short ao_cmd1; \
1278 unsigned short ao_cmd2; \
1279 unsigned short ao_cmd3; \
1280 unsigned short ao_trigger_select; \
1282 unsigned short gpct_mode[2]; \
1283 unsigned short gpct_command[2]; \
1284 unsigned short gpct_input_select[2]; \
1285 int gpct_cur_operation[2]; \
1286 unsigned short an_trig_etc_reg; \
1288 unsigned ai_offset[512]; \
1290 unsigned long serial_interval_ns; \
1291 unsigned char serial_hw_mode; \
1292 unsigned short clock_and_fout; \
1293 unsigned short clock_and_fout2; \
1295 volatile unsigned short int_a_enable_reg; \
1296 volatile unsigned short int_b_enable_reg; \
1297 unsigned short io_bidirection_pin_reg; \
1298 unsigned short rtsi_trig_direction_reg; \
1299 unsigned short rtsi_trig_a_output_reg; \
1300 unsigned short rtsi_trig_b_output_reg; \
1301 unsigned short pfi_output_select_reg[NUM_PFI_OUTPUT_SELECT_REGS]; \
1303 unsigned clock_ns; \
1304 unsigned clock_source; \
1306 unsigned short atrig_mode; \
1307 unsigned short atrig_high; \
1308 unsigned short atrig_low; \
1310 unsigned short pwm_up_count; \
1311 unsigned short pwm_down_count; \
1313 sampl_t ai_fifo_buffer[0x2000]; \
1314 uint8_t eeprom_buffer[M_SERIES_EEPROM_SIZE];
1316 #endif /* _COMEDI_NI_STC_H */