-
Notifications
You must be signed in to change notification settings - Fork 1
/
rxfifo_reset.c
90 lines (66 loc) · 1.52 KB
/
rxfifo_reset.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
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
80
81
82
83
84
85
86
87
88
89
90
#include "rxfifo_reset.h"
int uio_wr(const char *dev, unsigned int reg_addr, unsigned int reg_val)
{
int uio_fd;
void *uio_addr;
uio_fd = open(dev, O_RDWR);
if(uio_fd < 1)
{
printf("error: invalid uio_fd\n\r");
return -1;
}
uio_addr = mmap(NULL, 0x1000, PROT_READ|PROT_WRITE, MAP_SHARED, uio_fd, 0);
*((unsigned *) (uio_addr + reg_addr)) = reg_val;
munmap(uio_addr, 0x1000);
close(uio_fd);
return 0;
}
/*
int uio_rd(const char *dev, unsigned int reg_addr, unsigned int* reg_val)
{
int uio_fd;
void *uio_addr;
uio_fd = open(dev, O_RDWR);
if(uio_fd < 1)
{
printf("error: invalid uio_fd\n\r");
return -1;
}
uio_addr = mmap(NULL, 0x1000, PROT_READ|PROT_WRITE, MAP_SHARED, uio_fd, 0);
*reg_val = *((unsigned *) (uio_addr + reg_addr));
//printf("r: reg[0x%x] = 0x%x\n\r", reg_addr, *reg_val);
munmap(uio_addr, 0x1000);
close(uio_fd);
return 0;
}
*/
int gm_rd(const char *dev, unsigned int* reg_val)
{
//int uio_fd;
FILE* uio_fd;
//void *uio_addr;
// uio_fd = fopen(dev, O_RDWR);
uio_fd = fopen(dev, "rb");
fread(reg_val,1,1,uio_fd);
fclose(uio_fd);
//*reg_val=0;
return 0;
}
void reset_qpsk_rx(void)
{
uio_wr("/dev/mwipcore", 0x00, 0x01);
}
void unreset_qpsk_rx(void)
{
uio_wr("/dev/mwipcore", 0x00, 0x00);
}
/*
unsigned int rd_txfifo_hf_flag(void)
{
unsigned int hf_flag=0;
// uio_rd("/dev/mwipcore2", 0x00, &hf_flag);
//gm_rd("/dev/mwipcore2", &hf_flag);
hf_flag = hf_flag&0x00000001;
return hf_flag;
}
*/