it.board_name[COMEDI_NAMELEN-1]=0;
- if(it.options[COMEDI_DEVCONF_AUX_DATA] &&
- it.options[COMEDI_DEVCONF_AUX_DATA_LENGTH]){
+ if(comedi_aux_data(it.options, 0) &&
+ it.options[COMEDI_DEVCONF_AUX_DATA_LENGTH]){
+ int bit_shift;
aux_len = it.options[COMEDI_DEVCONF_AUX_DATA_LENGTH];
if(aux_len<0)return -EFAULT;
if(!aux_data)return -EFAULT;
if(copy_from_user(aux_data,
- (void *)it.options[COMEDI_DEVCONF_AUX_DATA], aux_len)){
+ comedi_aux_data(it.options, 0), aux_len)){
kfree(aux_data);
return -EFAULT;
}
-
- it.options[COMEDI_DEVCONF_AUX_DATA] = (unsigned long)aux_data;
+ it.options[COMEDI_DEVCONF_AUX_DATA_LO] = (unsigned long)aux_data;
+ if(sizeof(void*) > sizeof(int))
+ {
+ bit_shift = sizeof(int) * 8;
+ it.options[COMEDI_DEVCONF_AUX_DATA_HI] = ((unsigned long)aux_data) >> bit_shift;
+ }else
+ it.options[COMEDI_DEVCONF_AUX_DATA_HI] = 0;
}
ret = comedi_device_attach(dev,&it);
printk("Interrupt before is: %x\n", interrupt);
*/
- aux_data = (void *)it->options[COMEDI_DEVCONF_AUX_DATA];
+ aux_data = comedi_aux_data(it->options, 0);
aux_len = it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH];
if(aux_data && aux_len){
unsigned char *aux_data;
int aux_len;
- aux_data = (unsigned char *)it->options[COMEDI_DEVCONF_AUX_DATA];
+ aux_data = comedi_aux_data(it->options, 0);
aux_len = it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH];
if(!aux_data || aux_len)return -EINVAL;
#define FIRMWARE_MAX_LEN 0x2000
// taken from David Brownell's fxload and adjusted for this driver
-static int read_firmware(usbduxsub_t* usbduxsub,int firmwarePtr,long size) {
+static int read_firmware(usbduxsub_t* usbduxsub,void *firmwarePtr,long size) {
int i=0;
unsigned char* fp=(char*)firmwarePtr;
unsigned char* firmwareBinary=NULL;
usbduxsub[index].comedidev=dev;
// trying to upload the firmware into the chip
- if(it->options[COMEDI_DEVCONF_AUX_DATA] &&
+ if(comedi_aux_data(it->options, 0) &&
it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]){
read_firmware(usbduxsub,
- it->options[COMEDI_DEVCONF_AUX_DATA],
+ comedi_aux_data(it->options, 0),
it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]);
}
#define FIRMWARE_MAX_LEN 0x2000
// taken from David Brownell's fxload and adjusted for this driver
-static int read_firmware(usbduxfastsub_t* usbduxfastsub,int firmwarePtr,long size) {
+static int read_firmware(usbduxfastsub_t* usbduxfastsub, void *firmwarePtr,long size) {
int i=0;
unsigned char* fp=(char*)firmwarePtr;
unsigned char* firmwareBinary=NULL;
usbduxfastsub[index].comedidev=dev;
// trying to upload the firmware into the chip
- if(it->options[COMEDI_DEVCONF_AUX_DATA] &&
+ if(comedi_aux_data(it->options, 0) &&
it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]){
read_firmware(usbduxfastsub,
- it->options[COMEDI_DEVCONF_AUX_DATA],
+ comedi_aux_data(it->options, 0),
it->options[COMEDI_DEVCONF_AUX_DATA_LENGTH]);
}
/* number of config options in the config structure */
#define COMEDI_NDEVCONFOPTS 32
-#define COMEDI_DEVCONF_AUX_DATA 30
-#define COMEDI_DEVCONF_AUX_DATA_LENGTH 31
+/*length of nth chunk of firmware data*/
+#define COMEDI_DEVCONF_AUX_DATA3_LENGTH 25
+#define COMEDI_DEVCONF_AUX_DATA2_LENGTH 26
+#define COMEDI_DEVCONF_AUX_DATA1_LENGTH 27
+#define COMEDI_DEVCONF_AUX_DATA0_LENGTH 28
+#define COMEDI_DEVCONF_AUX_DATA_HI 29 /*most significant 32 bits of pointer address (if needed)*/
+#define COMEDI_DEVCONF_AUX_DATA_LO 30 /*least significant 32 bits of pointer address*/
+#define COMEDI_DEVCONF_AUX_DATA_LENGTH 31 /* total data length */
/* max length of device and driver names */
#define COMEDI_NAMELEN 20
information about their use
*/
-#define GPCT_X1 0x01 // X1 encoding
-#define GPCT_X2 0x02 // X2 encoding
-#define GPCT_X4 0x04 // X3 encoding
+// X1 encoding
+#define GPCT_X1 0x01
+// X2 encoding
+#define GPCT_X2 0x02
+// X3 encoding
+#define GPCT_X4 0x04
// When to take into account the indexpulse:
#define GPCT_IndexPhaseHighHigh 0
#define GPCT_IndexPhaseLowHigh 1
unsigned int comedi_buf_munge( comedi_device *dev, comedi_subdevice *s,
unsigned int num_bytes );
+static inline void* comedi_aux_data(int options[], int n)
+{
+ unsigned long address;
+ unsigned long addressLow;
+ int bit_shift;
+ if(sizeof(int) >= sizeof(void*))
+ address = options[COMEDI_DEVCONF_AUX_DATA_LO];
+ else
+ {
+ address = options[COMEDI_DEVCONF_AUX_DATA_HI];
+ bit_shift = sizeof(int) * 8;
+ address <<= bit_shift;
+ addressLow = options[COMEDI_DEVCONF_AUX_DATA_LO];
+ addressLow &= (1UL << bit_shift) - 1;
+ address |= addressLow;
+ }
+ if(n >= 1)
+ address += options[COMEDI_DEVCONF_AUX_DATA0_LENGTH];
+ if(n >= 2)
+ address += options[COMEDI_DEVCONF_AUX_DATA1_LENGTH];
+ if(n >= 3)
+ address += options[COMEDI_DEVCONF_AUX_DATA2_LENGTH];
+ return (void*) address;
+}
//#ifdef CONFIG_COMEDI_RT
#include <linux/comedi_rt.h>
//#endif