* read/written directly in the I/O space of the board. The
* AT-MIO devices map the low 8 STC registers to iobase+addr*2. */
-#define win_out(data,addr) do{ \
- if((addr)<8){ \
- ni_writew((data),(addr)*2); \
- }else{ \
- ni_writew((addr),Window_Address); \
- ni_writew((data),Window_Data); \
- } \
-}while(0)
+#define win_out(data,addr) __win_out(dev,data,addr)
+static inline void __win_out(comedi_device *dev, unsigned short data, int addr)
+{
+ unsigned long flags;
+
+ comedi_spin_lock_irqsave(&dev->spinlock,flags);
+ if((addr)<8){
+ ni_writew(data,addr*2);
+ }else{
+ ni_writew(addr,Window_Address);
+ ni_writew(data,Window_Data);
+ }
+ comedi_spin_unlock_irqrestore(&dev->spinlock,flags);
+}
#define win_out2(data,addr) do{ \
win_out((data)>>16, (addr)); \
win_out((data)&0xffff, (addr)+1); \
}while(0)
-#define win_in(addr) ( \
- ((addr)<8) \
- ? (ni_readw(((addr))*2)) \
- : (ni_writew((addr),Window_Address),ni_readw(Window_Data)))
+#define win_in(addr) __win_in(dev,addr)
+static inline unsigned short __win_in(comedi_device *dev, int addr)
+{
+ unsigned long flags;
+ int ret;
-#define win_save() (ni_readw(Window_Address))
-#define win_restore(a) (ni_writew((a),Window_Address))
+ comedi_spin_lock_irqsave(&dev->spinlock,flags);
+ if(addr<8){
+ ret = ni_readw(addr*2);
+ }else{
+ ni_writew(addr,Window_Address);
+ ret = ni_readw(Window_Data);
+ }
+ comedi_spin_unlock_irqrestore(&dev->spinlock,flags);
+
+ return ret;
+}
#define ao_win_out(a,b) do{ \
ni_writew((b),AO_Window_Address_671x); \
comedi_device *dev=d;
unsigned short a_status;
unsigned short b_status;
- int wsave;
unsigned int m0_status;
unsigned int m1_status;
#ifdef PCIDMA
struct mite_struct *mite = devpriv->mite;
#endif
-/*
- If you want to use windowed registers in an interrupt, it is
- important that you restore the window address register. If
- you change certain modes, e.g., AI_Configuration_Start/End,
- you need to set up software flags for non-interrupt routines.
-*/
- wsave=win_save();
-
a_status=win_in(AI_Status_1_Register);
b_status=win_in(AO_Status_1_Register);
#ifdef PCIDMA
handle_a_interrupt(dev, a_status, m0_status);
if(b_status&Interrupt_B_St || m1_status & CHSR_INT )
handle_b_interrupt(dev, b_status, m1_status);
-
- win_restore(wsave);
}
#ifdef PCIDMA
static int ni_ai_insn_read(comedi_device *dev,comedi_subdevice *s,comedi_insn *insn,lsampl_t *data)
{
int i,n;
- int wsave;
unsigned int mask;
unsigned short signbits;
unsigned short d;
- wsave=win_save();
-
ni_load_channelgain_list(dev,1,&insn->chanspec);
win_out(1,ADC_FIFO_Clear);
}
if(i==NI_TIMEOUT){
rt_printk("ni_mio_common: timeout in 611x ni_ai_insn_read\n");
- win_restore(wsave);
return -ETIME;
}
d += signbits; /* subtle: needs to be short addition */
}
if(i==NI_TIMEOUT){
rt_printk("ni_mio_common: timeout in ni_ai_insn_read\n");
- win_restore(wsave);
return -ETIME;
}
d = ni_readw(ADC_FIFO_Data_Register);
data[n] = d;
}
}
- win_restore(wsave);
return insn->n;
}
static int ni_ai_cmd(comedi_device *dev,comedi_subdevice *s)
{
- int wsave;
comedi_cmd *cmd=&s->async->cmd;
int timer;
int mode1=0; /* mode1 is needed for both stop and convert */
unsigned int stop_count;
MDPRINTK("ni_ai_cmd\n");
- wsave = win_save();
win_out(1,ADC_FIFO_Clear);
break;
}
- win_restore(wsave);
-
MDPRINTK("exit ni_ai_cmd\n");
return 0;
static int ni_ai_inttrig(comedi_device *dev,comedi_subdevice *s,
unsigned int trignum)
{
- int wsave;
-
if(trignum!=0)return -EINVAL;
- wsave = win_save();
-
win_out(AI_START1_Pulse,AI_Command_2_Register);
s->async->inttrig=NULL;
- win_restore(wsave);
-
return 1;
}
bits |= 1 << chan;
ao_win_out( chan, AO_Waveform_Generation_611x);
}
- ao_win_out(~bits & 0x3, AO_Immediate_671x);
ao_win_out(bits, AO_Timed_611x);
}else{
for(i=0;i<n_chans;i++){
* read/written directly in the I/O space of the board. The
* DAQCard devices map the low 8 STC registers to iobase+addr*2. */
-#define win_out(data,addr) do{ \
- if((addr)<8){ \
- ni_writew((data),(addr)*2); \
- }else{ \
- ni_writew((addr),Window_Address); \
- ni_writew((data),Window_Data); \
- } \
-}while(0)
+#define win_out(data,addr) __win_out(dev,data,addr)
+static inline void __win_out(comedi_device *dev, unsigned short data, int addr)
+{
+ unsigned long flags;
+
+ comedi_spin_lock_irqsave(&dev->spinlock,flags);
+ if(addr<8){
+ ni_writew(data,addr*2);
+ }else{
+ ni_writew(addr,Window_Address);
+ ni_writew(data,Window_Data);
+ }
+ comedi_spin_unlock_irqrestore(&dev->spinlock,flags);
+}
#define win_out2(data,addr) do{ \
win_out((data)>>16, (addr)); \
win_out((data)&0xffff, (addr)+1); \
}while(0)
-#define win_in(addr) ( \
- ((addr)<8) \
- ? (ni_readw(((addr))*2)) \
- : (ni_writew((addr),Window_Address),ni_readw(Window_Data)))
+#define win_in(addr) __win_in(dev,addr)
+static inline unsigned short __win_in(comedi_device *dev, int addr)
+{
+ unsigned long flags;
+ int ret;
+
+ comedi_spin_lock_irqsave(&dev->spinlock,flags);
+ if(addr<8){
+ ret = ni_readw(addr*2);
+ }else{
+ ni_writew(addr,Window_Address);
+ ret = ni_readw(Window_Data);
+ }
+ comedi_spin_unlock_irqrestore(&dev->spinlock,flags);
-#define win_save() (ni_readw(Window_Address))
-#define win_restore(a) (ni_writew((a),Window_Address))
+ return ret;
+}
#define ao_win_out(a,b) do{ \
ni_writew((b),AO_Window_Address_671x); \