#include "stdio.h"
#include "OB90A64M1.h"
#include "timer32.h"
#include "gpio.h"
#include "uart.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  Output 100ms (P0.0) \n\r");

    GPIO_SetPinMFType(OB_GPIO0, GPIO_PIN0, GPIO_MF_TIMER32B0_MAT);
    GPIO_SetPinMFType(OB_GPIO1, GPIO_PIN0, GPIO_MF_TIMER32B0_MAT);
    TIMER32_PWMSel(OB_CT32B0, TIMER32_EMATCH1, TIMER32_PWM_ENABLE);
    TIMER32_PWMSel(OB_CT32B0, TIMER32_EMATCH2, TIMER32_PWM_ENABLE);

    TIMER32_PWM_Length(OB_CT32B0, TIMER32_EMATCH3 ,10000, TIMER32_PWM_LENGTH_HL); // PWM Length (Low + High) = 10ms,uint = us
    TIMER32_PWM_Length(OB_CT32B0, TIMER32_EMATCH1 ,6000, TIMER32_PWM_LENGTH_L);  // Low Level = 6ms, Higth Level = 4ms
    TIMER32_PWM_Length(OB_CT32B0, TIMER32_EMATCH2 ,3000, TIMER32_PWM_LENGTH_L) ; // Low Level = 3ms, Higth Level = 7ms
    TIMER32_Enable(OB_CT32B0);
    while(1);
}

