#include "stdio.h"
#include "OB90A64M1.h"
#include "gpio.h"
#include "uart.h"
#include "timer16.h"

int main(void)
{
    SystemCoreClockUpdate();
    GPIO_SetPinMFType(OB_GPIO2, GPIO_PIN0, GPIO_MF_UART1_RX);
    GPIO_SetPinMFType(OB_GPIO2, GPIO_PIN1, GPIO_MF_UART1_TX);
    UART_Open(OB_UART1, 19200);
    printf("\n  PWM Period 100us (P3.2) \n\r");

    GPIO_SetPinMFType(OB_GPIO3, GPIO_PIN2, GPIO_MF_TIMER16B0_MAT); //MAT0
	
	GPIO_SetPinMode(OB_GPIO3, GPIO_PIN2, GPIO_PINMODE_PULL_UP); 
    TIMER16_PWMSel(OB_CT16B0, TIMER16_EMATCH0, TIMER16_PWM_ENABLE);
	
	TIMER16_PWM_Length(OB_CT16B0, TIMER16_EMATCH3 ,100, TIMER16_PWM_LENGTH_HL); // PWM Length (Low + High) = 10ms,uint = us
    TIMER16_PWM_Length(OB_CT16B0, TIMER16_EMATCH0 ,60, TIMER16_PWM_LENGTH_L);  // Low Level = 60us, Higth Level = 40us
    TIMER16_Enable(OB_CT16B0);
	
    while(1);
}
