-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathaccregs.c
57 lines (50 loc) · 1.35 KB
/
accregs.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
#include <stdio.h>
#include <stdlib.h>
#include <stdint.h>
#include <sleep.h>
#include <time.h>
#include "platform.h"
#include "xparameters.h"
#include "xuartps_hw.h"
#include "xtime_l.h"
#include "main.h"
#include "accregs.h"
volatile unsigned* accregs_ptr = (void*)0x43C00000;
/*
* DEBUG
* Utility function to print the state of relevant IP registers
*/
void accreg_print_regs()
{
unsigned i = 0;
for(i = 0; i < 16; i++) {
if(i > 0) printf(" ");
printf("%08x", (unsigned)accreg_rd(i));
}
printf("\n");
}
/*
* DEBUG
* Use the 14th register to print the count of different FIFOs according to
* given bit mapping.
*/
void accregs_print_fifo_counts()
{
unsigned register14 = (unsigned)accreg_rd(14);
unsigned register15 = (unsigned)accreg_rd(15);
printf("FIFO rd count : %u\n", (register14 & 0xFF000000) >> 24);
printf("FIFO 1r count : %u\n", (register14 & 0x000000FF) >> 0);
printf("FIFO r2 count : %u\n", (register14 & 0x0000FF00) >> 8);
printf("FIFO 2o count : %u\n", (register14 & 0x00FF0000) >> 16);
printf("FIFO wr count : %u\n", (register15 & 0x000000FF) >> 0);
}
/*
* DEBUG
* Pop the value from one of the FIFO. The according unused register, 8 here,
* has to be granted this functionality in the hardware for the corresponding
* FIFO to be poped after a read in this register.
*/
int32_t accregs_pop()
{
return (int32_t)accreg_rd(8);
}