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

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

int main(void)
{
    SystemCoreClockUpdate();
    GPIO_SetPinMFType(OB_GPIO3, GPIO_PIN0, GPIO_MF_UART0_RX);
    GPIO_SetPinMFType(OB_GPIO3, GPIO_PIN1, GPIO_MF_UART0_TX);
    UART_Open(OB_UART0, 19200);
    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, (uint8_t *)(&g_UartRxData[0]), 1);
            g_UartRxCounter = 0x00;
        }
    }
}
