#include <stdio.h>
#include "platform.h"
#include "xil_printf.h"
#include "xtmrctr.h"
#include "xparameters.h"

XTmrCtr tmr;

void tmr_init(){
	int status = XTmrCtr_Initialize(&tmr, XPAR_AXI_TIMER_0_DEVICE_ID);
	if(status == XST_SUCCESS)
		xil_printf("TMR INIT SUCCESSFUL\n");
	else
		xil_printf("TMR INIT FAILED\n");

}



int main()
{
    init_platform();
    tmr_init();

    u32 periodPWM = 1000000000;
    u32 highValue = 0;
    u8 duty = 0 ;

    while(1){


    XTmrCtr_PwmDisable(&tmr);

    if(highValue == 1000000000)
    	highValue = 0;
    else
    	highValue = highValue + 50000000;



    duty = XTmrCtr_PwmConfigure(&tmr,periodPWM,highValue);

    XTmrCtr_PwmEnable(&tmr);

    xil_printf("Duty Cycle : %0d\n", duty);

    while(!XTmrCtr_IsExpired(&tmr,0));

    }


    cleanup_platform();
    return 0;
}