用ARM對FPGA進(jìn)行配置的原理與方法
static AT91PS_PIO pioc;
inline void pioc_out_0 (int mask)
{
pioc->PIO_CODR = mask;
}
inline void pioc_out_1 (int mask)
{
pioc->PIO_SODR = mask;
}
inline int pioc_in (int mask)
{
return pioc->PIO_PDSR mask;
}
inline void xmit_byte (char c)
{
int i;
for (i = 0; i 8; i++)
{
if (c 1)
pioc_out_1 (DATA0);
else
pioc_out_0 (DATA0);
pioc_out_0 (DCLK);
pioc_out_1 (DCLK);
c >>= 1;
}
}
void pioc_setup ()
{
pioc->PIO_PER =DATA0 | nCONFIG | DCLK | nSTATUS | CONF_DONE;
pioc->PIO_OER =DATA0 | nCONFIG | DCLK;
pioc->PIO_ODR =nSTATUS | CONF_DONE;
pioc->PIO_IFER =nSTATUS | CONF_DONE;
pioc->PIO_CODR =DATA0 | nCONFIG | DCLK;
pioc->PIO_IDR =DATA0 | nCONFIG | DCLK | nSTATUS | CONF_DONE;
pioc->PIO_MDDR =DATA0 | nCONFIG | DCLK;
pioc->PIO_PPUDR =DATA0 | nCONFIG | DCLK | nSTATUS | CONF_DONE;
pioc->PIO_OWDR =DATA0 | nCONFIG | DCLK | nSTATUS | CONF_DONE;
}
int pioc_map ()
{
int fd;
off_t addr = 0xFFFFF800; // PIO controller C
static void *base;
if ((fd = open (/dev/mem, O_RDWR | O_SYNC)) == -1)
{
printf (Cannot open /dev/mem. );
return 0;
}
printf (/dev/mem opened. );
base = mmap (0, MAP_SIZE, PROT_READ|PROT_WRITE, MAP_SHARED, fd, addr ~MAP_MASK);
評論