コード例 #1
0
ファイル: xadc_core.c プロジェクト: 1nfused/RemoteAccess
static int get_iio_node(const char * deviceName)
{
	struct dirent **namelist;
	char file[MAX_PATH_SIZE];
	char name[MAX_NAME_SIZE];
	int i,n;
	int flag = 0;

	n = scandir(SYS_PATH_IIO, &namelist, 0, alphasort);
	if (n < 0)
		return RET_ERR_DEV_NOT_FOUND;

	for (i=0; i < n; i++)
	{
		sprintf(file, "%s/%s/name", SYS_PATH_IIO, namelist[i]->d_name);
		if ((line_from_file(file,name) == 0) && (strcmp(name,deviceName) ==  0))
		{
			flag =1;
			strcpy(gNodeName, namelist[i]->d_name);
			sprintf(gDevicePath, "%s/%s", SYS_PATH_IIO, gNodeName);
			break;
		}
	}

	if(flag == 0) return RET_ERR_DEV_NOT_FOUND;

	return RET_SUCCESS;
}
コード例 #2
0
int XImage_filter_Initialize(XImage_filter *InstancePtr, const char* InstanceName) {
	XImage_filter_uio_info *InfoPtr = &uio_info;
	struct dirent **namelist;
    int i, n;
    char* s;
    char file[ MAX_UIO_PATH_SIZE ];
    char name[ MAX_UIO_NAME_SIZE ];
    int flag = 0;

    assert(InstancePtr != NULL);

    n = scandir("/sys/class/uio", &namelist, 0, alphasort);
    if (n < 0)  return XST_DEVICE_NOT_FOUND;
    for (i = 0;  i < n; i++) {
    	strcpy(file, "/sys/class/uio/");
    	strcat(file, namelist[i]->d_name);
    	strcat(file, "/name");
        if ((line_from_file(file, name) == 0) && (strcmp(name, InstanceName) == 0)) {
            flag = 1;
            s = namelist[i]->d_name;
            s += 3; // "uio"
            InfoPtr->uio_num = atoi(s);
            break;
        }
    }
    if (flag == 0)  return XST_DEVICE_NOT_FOUND;

    uio_info_read_name(InfoPtr);
    uio_info_read_version(InfoPtr);
    for (n = 0; n < MAX_UIO_MAPS; ++n) {
        uio_info_read_map_addr(InfoPtr, n);
        uio_info_read_map_size(InfoPtr, n);
    }

    sprintf(file, "/dev/uio%d", InfoPtr->uio_num);
    if ((InfoPtr->uio_fd = open(file, O_RDWR)) < 0) {
        return XST_OPEN_DEVICE_FAILED;
    }

    // NOTE: slave interface 'Control_bus' should be mapped to uioX/map0
    InstancePtr->Control_bus_BaseAddress = (u32)mmap(NULL, InfoPtr->maps[0].size, PROT_READ|PROT_WRITE, MAP_SHARED, InfoPtr->uio_fd, 0 * getpagesize());
    assert(InstancePtr->Control_bus_BaseAddress);

    InstancePtr->IsReady = XIL_COMPONENT_IS_READY;

    return XST_SUCCESS;
}
コード例 #3
0
ファイル: xadc_core.c プロジェクト: 1nfused/RemoteAccess
static int read_xadc_param(struct XadcParameter *param)
{
	char filename[MAX_PATH_SIZE];
	char read_value[MAX_VALUE_SIZE];

	memset(filename, 0, sizeof(filename) );

	sprintf(filename, "%s/%s", gDevicePath, param->name );

	if (line_from_file(filename,read_value) == RET_SUCCESS)
	{
		param->value = param->conv_fn(atof(read_value), EConvType_Raw_to_Scale);
	}
	else
	{
		printf("\n***Error: reading file %s\n",filename);
		param->value = 0;
		return RET_FILE_READ_FAILED;
	}

	return RET_SUCCESS;
}
コード例 #4
0
static int uio_info_read_version(XImage_filter_uio_info* info) {
    char file[ MAX_UIO_PATH_SIZE ];
    sprintf(file, "/sys/class/uio/uio%d/version", info->uio_num);
    return line_from_file(file, info->version);
}
コード例 #5
0
ファイル: xeee_linux.c プロジェクト: munishjassi/vp_zebboard
static int uio_info_read_name(XEee_uio_info* info) {
    char file[ MAX_UIO_PATH_SIZE ];
    sprintf(file, "/sys/class/uio/uio%d/name", info->uio_num);
    return line_from_file(file, info->name);
}
static int uio_info_read_version(XGradientenverfahren_top_uio_info* info) {
    char file[ MAX_UIO_PATH_SIZE ];
    sprintf(file, "/sys/class/uio/uio%d/version", info->uio_num);
    return line_from_file(file, info->version);
}