#include <stdio.h>
#include "OB90R64A2.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_GPIO0, GPIO_PIN1, GPIO_MF_UART0_RX);   // P0.1
    GPIO_SetPinMFType(OB_GPIO0, GPIO_PIN0, GPIO_MF_UART0_TX);   // P0.0
    
    UART_Open(OB_UART0, 9600);
    printf(" UART function test\n\r");
    printf(" CPU Clock = %dHz\n\r", SystemCoreClock);
    //--------------- enable Interrupt--------------------------------
    UART_EnableInt(OB_UART0, UART_INT_RBR);
    NVIC_EnableIRQ(UART0_IRQn);
    //--------------------------------------------------------------
    g_UartRxCounter = 0x00;
    while(1)
    {
        if(g_UartRxCounter >= 1)
        {
            UART_Write(OB_UART0, &g_UartRxData[0], 1);
            g_UartRxCounter = 0x00;
        }
    }
}
