-
Notifications
You must be signed in to change notification settings - Fork 3
Expand file tree
/
Copy pathutils_conf.c
More file actions
79 lines (67 loc) · 1.69 KB
/
utils_conf.c
File metadata and controls
79 lines (67 loc) · 1.69 KB
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
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
/*
* Copyright (c) 2019 OscillatorIMP Digital
* Gwenhael Goavec-Merou <gwenhael.goavec-merou@trabucayre.com>
*
* 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.
*
*/
#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>
#include <utils_conf.h>
#define SHIFT_VAL_REG (1 << 2)
int shifter_set(char *filename, int shift)
{
int fd_sw = open(filename, O_RDWR);
if (fd_sw < 0) {
printf("erreur d'ouverture de %s\n", filename);
return fd_sw;
}
ioctl(fd_sw, FPGAGEN_SET_REGISTER(SHIFT_VAL_REG), &shift);
close(fd_sw);
return 0;
}
int shifter_get(char *filename, int *shift)
{
int fd_sw = open(filename, O_RDWR);
if (fd_sw < 0) {
printf("erreur d'ouverture de %s\n", filename);
return fd_sw;
}
ioctl(fd_sw, FPGAGEN_GET_REGISTER(SHIFT_VAL_REG), &shift);
close(fd_sw);
return 0;
}
#define DELAYTEMPO_VAL_REG (1 << 0)
int delayTempo_set(char *filename, int delay)
{
int fd_sw = open(filename, O_RDWR);
if (fd_sw < 0) {
printf("erreur d'ouverture de %s\n", filename);
return fd_sw;
}
ioctl(fd_sw, FPGAGEN_SET_REGISTER(DELAYTEMPO_VAL_REG), &delay);
close(fd_sw);
return 0;
}
int delayTempo_get(char *filename, int *delay)
{
int fd_sw = open(filename, O_RDWR);
if (fd_sw < 0) {
printf("erreur d'ouverture de %s\n", filename);
return fd_sw;
}
ioctl(fd_sw, FPGAGEN_GET_REGISTER(DELAYTEMPO_VAL_REG), &delay);
close(fd_sw);
return 0;
}