-
Notifications
You must be signed in to change notification settings - Fork 2
/
Copy pathfpgagen_conf.c
50 lines (45 loc) · 1.22 KB
/
fpgagen_conf.c
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
/*
* SPI testing utility (using spidev driver)
*
* Copyright (c) 2007 MontaVista Software, Inc.
* Copyright (c) 2007 Anton Vorontsov <[email protected]>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation; either version 2 of the License.
*
* Cross-compile with cross-gcc -I/path/to/cross-kernel/include
*/
#include <stdint.h>
#include <unistd.h>
#include <stdio.h>
#include <stdlib.h>
#include <getopt.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <linux/types.h>
/* memory management */
#include <sys/mman.h>
#include <fpgagen_core/fpgagen_config.h>
int fpgagen_send_conf(char *filename, int reg, int value)
{
int fpgagen = open(filename, O_RDWR);
if (fpgagen < 0) {
printf("erreur d'ouverture de %s\n", filename);
return fpgagen;
}
ioctl(fpgagen, FPGAGEN_SET_REGISTER(reg), &value);
close(fpgagen);
return 0;
}
int fpgagen_recv_conf(char *filename, int reg, int *value)
{
int fpgagen = open(filename, O_RDWR);
if (fpgagen < 0) {
printf("erreur d'ouverture de %s\n", filename);
return fpgagen;
}
ioctl(fpgagen, FPGAGEN_GET_REGISTER(reg), value);
close(fpgagen);
return 0;
}