#include <stdio.h>
#include "OB90R32A2.h"
#include "uart.h"
#include "gpio.h"

extern uint8_t  g_UartRxData[UART_RX_SIZE];
extern uint32_t g_UartRxCounter;
extern uint32_t g_UartInterrupt;

int main(void)
{
    SystemCoreClockUpdate();
    GPIO_SetPinMFType(OB_GPIO1, GPIO_PIN4, GPIO_MF_UART1_RX);   // P1.4
    GPIO_SetPinMFType(OB_GPIO2, GPIO_PIN5, GPIO_MF_UART1_TX);   // P2.5
    UART_Open(OB_UART1, 19200);
    printf(" UART function test\n\r");
    printf(" CPU Clock = %dHz\n\r", SystemCoreClock);
    //--------------- enable Interrupt------------------------------
    UART_EnableInt(OB_UART1, UART_INT_RBR);
    NVIC_EnableIRQ(UART1_IRQn);
    //--------------------------------------------------------------
    g_UartRxCounter = 0x00;
    while(1)
    {
        if(g_UartRxCounter >= 1)
        {
            UART_Write(OB_UART1, &g_UartRxData[0], 1);
            g_UartRxCounter = 0x00;
        }
    }
}
