Code: Select all
#include <xs1.h>
#include <platform.h>
#include <gpio.h>
#include <timer.h>
#include <stdio.h>
out port d1 = XS1_PORT_1E; /* SIGNAL AT D12 */
out port d2 = XS1_PORT_1F; /*SIGNAL AT D13*/
clock clk = XS1_CLKBLK_1;
void dimm4(out port p)
{
timer tmr;
int port_count;
int dim_period = 250*60000;
int dim_value = dim_period*0.5;
int state = 0;
tmr :> port_count;
port_count += dim_period;
while (1) {
select {
case tmr when timerafter(port_count) :> void:
p @ port_count <: state;
state = !state;
if (state)
port_count += dim_period - dim_value;
else
port_count += dim_value;
break;
}
}
}
void dimm3(out port p)
{
int port_count;
int dim_value = 3000000;
int dim_period = 6000000;
configure_clock_rate(clk, 25, 1);
configure_out_port(p, clk, 0);
start_clock(clk);
p <: 0 @ port_count;
port_count += dim_period;
while (1)
{
p @ port_count <: 0;
p @ port_count + (dim_period-dim_value) <: 1;
port_count += dim_period;
}
}
int main ()
{
par
{
dimm4(d1);
dimm3(d2);
}
return 0;
}