2022-10-19 15:03:52 +03:00
|
|
|
#include <stdio.h>
|
|
|
|
#include "altera_avalon_sem_regs.h"
|
|
|
|
#include "alt_types.h"
|
|
|
|
#include "system.h"
|
|
|
|
|
|
|
|
#define TIME_SETS 4
|
|
|
|
#define TIME_STATES 4
|
2022-12-19 22:48:11 +03:00
|
|
|
const alt_u32 divisors[TIME_SETS][TIME_STATES] = {
|
2022-12-22 22:27:05 +03:00
|
|
|
{0x00000010, 0x00000010, 0x00000005, 0x00000010},
|
|
|
|
{0x00000010, 0x00000020, 0x00000010, 0x00000010},
|
2022-12-24 02:08:20 +03:00
|
|
|
{0x000000f1, 0x000000f1, 0x000000f1, 0x00000011},
|
|
|
|
{0x000000d1, 0x000000f1, 0x000000f1, 0x00000011}
|
2022-10-19 15:03:52 +03:00
|
|
|
};
|
|
|
|
|
|
|
|
int main()
|
|
|
|
{
|
|
|
|
int i,j;
|
|
|
|
volatile alt_u32 *p;
|
|
|
|
alt_u32 tmp;
|
|
|
|
|
|
|
|
//program divisors
|
|
|
|
p = (alt_u32*) SEM_RAM_SLAVE_BASE;
|
2022-12-22 22:27:05 +03:00
|
|
|
for (i = 0; i < TIME_SETS; i++) {
|
|
|
|
for (j = TIME_STATES; j > 0; j--) {
|
2023-01-18 16:45:45 +03:00
|
|
|
*p = divisors[i][j - 1];
|
|
|
|
alt_dcache_flush();
|
|
|
|
++p;
|
2022-10-19 15:03:52 +03:00
|
|
|
}
|
|
|
|
}
|
|
|
|
//since we use pointers (cached data access) to write divisor RAM,
|
|
|
|
//and not direct i/o access with IOWR, we need to flush cache
|
2023-01-18 16:45:45 +03:00
|
|
|
// alt_dcache_flush();
|
2022-10-19 15:03:52 +03:00
|
|
|
|
|
|
|
//select timeset and run semafor
|
|
|
|
IOWR_ALTERA_AVALON_SEM_DIVSET(SEM_CTL_SLAVE_BASE,0x00);
|
|
|
|
IOWR_ALTERA_AVALON_SEM_CTL(SEM_CTL_SLAVE_BASE,0x01);
|
|
|
|
|
|
|
|
printf("Ready\n");
|
|
|
|
|
|
|
|
while (1)
|
|
|
|
{
|
|
|
|
;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|