/* Some global definitions: the registers of the DNP ----------------------- */ /* */ /* For port A and B the mode register has bits corresponding to the output */ /* pins, where Bit-N = 0 -> input, Bit-N = 1 -> output. Note that bits */ /* 4 to 7 correspond to pin 0..3 for port C data register. Ensure that bits */ /* 0..3 remain unchanged! For details about Port C Mode Register see */ /* the remarks in dnp_insn_config() below. */
#define CSCIR 0x22 /* Chip Setup and Control Index Register */ #define CSCDR 0x23 /* Chip Setup and Control Data Register */ #define PAMR 0xa5 /* Port A Mode Register */ #define PADR 0xa9 /* Port A Data Register */ #define PBMR 0xa4 /* Port B Mode Register */ #define PBDR 0xa8 /* Port B Data Register */ #define PCMR 0xa3 /* Port C Mode Register */ #define PCDR 0xa7 /* Port C Data Register */
/* * Ports A and B are straight forward: each bit corresponds to an * output pin with the same order. Port C is different: bits 0...3 * correspond to bits 4...7 of the output register (PCDR).
*/
ret = comedi_dio_insn_config(dev, s, insn, data, 0); if (ret) return ret;
if (chan < 8) { /* Port A */
mask = 1 << chan;
outb(PAMR, CSCIR);
} elseif (chan < 16) { /* Port B */
mask = 1 << (chan - 8);
outb(PBMR, CSCIR);
} else { /* Port C */ /* * We have to pay attention with port C. * This is the meaning of PCMR: * Bit in PCMR: 7 6 5 4 3 2 1 0 * Corresponding port C pin: d 3 d 2 d 1 d 0 d= don't touch * * Multiplication by 2 brings bits into correct position * for PCMR!
*/
mask = 1 << ((chan - 16) * 2);
outb(PCMR, CSCIR);
}
val = inb(CSCDR); if (data[0] == COMEDI_OUTPUT)
val |= mask; else
val &= ~mask;
outb(val, CSCDR);
Die Informationen auf dieser Webseite wurden
nach bestem Wissen sorgfältig zusammengestellt. Es wird jedoch weder Vollständigkeit, noch Richtigkeit,
noch Qualität der bereit gestellten Informationen zugesichert.
Bemerkung:
Die farbliche Syntaxdarstellung und die Messung sind noch experimentell.