Updated VProc Python interface to include support for burst reads and writes. Updated demonstration test code to use these new functions

This commit is contained in:
Simon Southwell 2024-03-07 11:19:42 +00:00
commit c82d1dd27c
6 changed files with 84 additions and 12 deletions

View file

@ -26,12 +26,16 @@
// Pointer types for external API functions. Must match prototypes in VUser.h
typedef int (*wfunc_p) (const unsigned, const unsigned, const int, const unsigned);
typedef int (*rfunc_p) (const unsigned, unsigned *, const int, const unsigned);
typedef int (*wbfunc_p) (const unsigned, void *, const unsigned, const unsigned);
typedef int (*rbfunc_p) (const unsigned, void *, const unsigned, const unsigned);
typedef int (*tkfunc_p) (const unsigned, const unsigned );
typedef void (*regirqfunc_p) (const pVUserIrqCB_t, const unsigned);
// Define pointers to the external API functions
static wfunc_p Vwrite;
static rfunc_p Vread;
static wbfunc_p VburstWrite;
static rbfunc_p VburstRead;
static tkfunc_p Vtick;
static regirqfunc_p VregIrq;
@ -64,6 +68,18 @@ static int BindToApiFuncs(void)
fprintf(stderr, "***ERROR: failed to find symbol VRead\n");
return 1;
}
if ((VburstWrite = (wbfunc_p)dlsym(hdl, "VBurstWrite")) == NULL)
{
fprintf(stderr, "***ERROR: failed to find symbol VBurstWrite\n");
return 1;
}
if ((VburstRead = (rbfunc_p)dlsym(hdl, "VBurstRead")) == NULL)
{
fprintf(stderr, "***ERROR: failed to find symbol VBurstRead\n");
return 1;
}
if ((Vtick = (tkfunc_p)dlsym(hdl, "VTick")) == NULL)
{
@ -210,6 +226,26 @@ uint32_t PyTick (const uint32_t ticks, const uint32_t node)
return Vtick(ticks, node);
}
// ------------------------------------------------------------
// VBurstWrite wrapper function for Python
// ------------------------------------------------------------
uint32_t PyBurstWrite (const uint32_t addr, void *data, const uint32_t len, const uint32_t node)
{
//printf("addr=0x%08x data_p=0x%p data[1]=0x%08x len = %d node = %d", addr, data, ((uint32_t*)data)[1], len, node);
return VburstWrite(addr, data, len, node);
}
// ------------------------------------------------------------
// VBurstRead wrapper function for Python
// ------------------------------------------------------------
uint32_t PyBurstRead (const uint32_t addr, void *data, const uint32_t len, const uint32_t node)
{
return VburstRead(addr, data, len, node);
}
// ------------------------------------------------------------
// VRegIrq wrapper function for Python
// ------------------------------------------------------------