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

void Dealay(uint32_t nCount)
{
    while(nCount--);
}

int main(void)
{
    uint32_t nValue;

    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, 19200);
    printf("|                       GPIO                          |\n\r");

    //----------------P0-----------------------
    printf("\n\r\n\r P0 = ");
    OB_GPIO0->MODE = 0x00; //IO mode = pull up
    nValue = 0x01;
    while(1)
    {
        printf(" ,0x%02x", nValue);
        OB_GPIO0->DATA = nValue;
        Dealay(50000);
        if (nValue == 0x8000)
            break;
        nValue = nValue << 0x01;
    }
       //----------------P1-----------------------
    printf("\n\r\n\r P1 = ");
    OB_GPIO1->MODE = 0x00; //IO mode = pull up
    nValue = 0x01;
    while(1)
    {
        printf(" ,0x%02x", nValue);
        OB_GPIO1->DATA = nValue;
        Dealay(50000);
        if (nValue == 0x8000)
            break;
        nValue = nValue << 0x01;
    }
    //----------------P2-----------------------
    printf("\n\r\n\r P2 = ");
    OB_GPIO2->MODE = 0x00; //IO mode = pull up
    nValue = 0x01;
    while(1)
    {
        printf(" ,0x%02x", nValue);
        OB_GPIO2->DATA = nValue;
        Dealay(50000);
        if (nValue == 0x8000)
            break;
        nValue = nValue << 0x01;
    }
    //----------------P3-----------------------
    printf("\n\r\n\r P3 = ");
    OB_GPIO0->MODE = 0x00; //IO mode = pull up
    nValue = 0x01;
    while(1)
    {
        printf(" ,0x%02x", nValue);
        OB_GPIO3->DATA = nValue;
        Dealay(50000);
        if (nValue == 0x8000)
            break;
        nValue = nValue << 0x01;
    }
    while(1);
}
