1
0
mirror of https://github.com/bmartini/zynq-axis.git synced 2024-09-05 19:19:27 +08:00

Add some more configuration bus functions

Similar functions could be constructed using calls to the already existing
functions, however, it seems more efficient to add them to the library in case
the application cannot optimizes external library calls.
This commit is contained in:
Berin Martini 2015-01-09 17:17:34 -05:00
parent 76e102294b
commit 66f4315fdd
2 changed files with 35 additions and 0 deletions

View File

@ -88,6 +88,26 @@ void cfg_write(unsigned int addr, unsigned int data)
*reg = data;
}
void cfg_write_array(unsigned int addr, unsigned int *data, int length)
{
int xx;
volatile unsigned int *reg = ((volatile unsigned int *)cfg) + addr;
for (xx = 0; xx < length; xx++) {
*reg = data[xx];
}
}
void cfg_write_sequence(unsigned int *addr, unsigned int *data, int length)
{
int xx;
volatile unsigned int *reg = ((volatile unsigned int *)cfg);
for (xx = 0; xx < length; xx++) {
*(reg + addr[xx]) = data[xx];
}
}
int cfg_read(unsigned int addr)
{
volatile unsigned int *reg = ((volatile unsigned int *)cfg) + addr;
@ -95,6 +115,14 @@ int cfg_read(unsigned int addr)
return *reg;
}
void cfg_poll(unsigned int addr, unsigned int data)
{
int test = 0;
do {
test = cfg_read(addr);
} while (data > test) ;
}
void *mem_alloc(const int length, const int byte_nb)
{
assert(mem);

View File

@ -16,8 +16,15 @@ extern "C" {
// configuration bus
void cfg_write(unsigned int addr, unsigned int data);
void cfg_write_array(unsigned int addr, unsigned int *data, int length);
void cfg_write_sequence(unsigned int *addr,
unsigned int *data, int length);
int cfg_read(unsigned int addr);
void cfg_poll(unsigned int addr, unsigned int data);
// dma memory
void *mem_alloc(const int length, const int byte_nb);