예제 #1
0
파일: spitest01.c 프로젝트: 0xc0170/cox
//*****************************************************************************
//
//! \brief xspi 004 test of SPI0 initialization.
//!
//! \return None.
//
//*****************************************************************************
static void SPI0MasterInit(void)
{
    //
    // Configure Some GPIO pins as SPI Mode
    //
    xSPinTypeSPI(SPI0CLK, PB13);
	xSPinTypeSPI(SPI0MOSI, PB15);
	xSPinTypeSPI(SPI0MISO, PB14);
	xSPinTypeSPI(SPI0CS, PA7);

    //
    // Master Mode polarity 0,Rx latched at rising edge Tx changed at rising edge
    // 200000Hz 8Bits Data windth  SPI MSB First
    //
    xSPIConfigSet(SPI0_BASE, 10000, SPI_FORMAT_MODE_5 | SPI_DATA_WIDTH16 | 
                                               SPI_MSB_FIRST | SPI_MODE_MASTER);
    //
    // Software Control Transfer Select SS0
    //
    xSPISSSet(SPI0_BASE, xSPI_SS_SOFTWARE, 0);

//	SPISSClear(SPI0_BASE);
    
//    xIntEnable(INT_SPI0);

	xSPIIntCallbackInit(SPI0_BASE, SPI0Callback);
    xSPIEnable(SPI0_BASE);
//    xIntPrioritySet(INT_SPI0, 1);
//	xSPIIntEnable(SPI0_BASE, xSPI_INT_EOT);
//	SPIFIFOLevelSet(SPI0_BASE, SPI_FSR_RX, 5);
	
}
예제 #2
0
파일: spi_drv.c 프로젝트: AlexGora/cox
//*****************************************************************************
//
//! \brief Init Spi communction port and wifi handshake pin.
//
//! WiFi shield IO refence volatge == 3.3V
//! Pin map is below:
//! HAND_PIN  --> PA3
//! SPI1_NSS  --> PA4
//! SPI1_SCK  --> PA5
//! SPI1_MISO --> PA6
//! SPI1_MOSI --> PA7
//!
//! \param none.
//!
//! \return None
//
//*****************************************************************************
void SpiDrv_Init(void)
{
    
    xSysCtlClockSet(72000000,  xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_8MHZ);

    xSysCtlPeripheralEnable(xSYSCTL_PERIPH_GPIOA);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_SPI1);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_AFIO);

    xGPIOSPinTypeGPIOInput(PA3);
    xGPIOSPinTypeGPIOOutput(PA4);

    xSPinTypeSPI(SPI1CLK(3),  PA5);
    xSPinTypeSPI(SPI1MOSI(3), PA7);
    xSPinTypeSPI(SPI1MISO(1), PA6);

    //
    // Configure MCU as a master device , 8 bits data width ,MSB first,Mode_0
    //
    xSPIConfigSet(xSPI1_BASE, 4000000, xSPI_MOTO_FORMAT_MODE_0 |
                                                xSPI_MODE_MASTER |
                                                xSPI_MSB_FIRST |
                                                xSPI_DATA_WIDTH8);
    xSPISSSet(xSPI1_BASE, xSPI_SS_SOFTWARE, xSPI_SS0);

    xSPIEnable(xSPI1_BASE);
}
예제 #3
0
파일: tc77.c 프로젝트: AlexGora/cox
//*****************************************************************************
//
//! \brief Initialize TC77 
//!
//! \param ulClock specifies the SPI Clock Rate
//!
//! This function is to initialize the MCU as master and specified SPI port.Set
//! TC77_PIN_SPI_CS as CS, TC77_PIN_SPI_CLK as CLK, TC77_PIN_SPI_MISO ->MISO and 
//! TC77_PIN_SPI_MOSI->MOSI,most of all it check the first conversion is finished 
//! or not in order to execute the following operation.
//! 
//! \return None.
//
//*****************************************************************************
void
TC77Init(unsigned long ulSpiClock)
{
    short sReadValue = 0;
    
    //
    // The max clock rate of TC77 is 7M Hz acoording to Datasheet, Otherwise
    // it will generate  bigger error
    //
    xASSERT((ulSpiClock > 0) && (ulSpiClock < 7000000));
    
    //
    // Enable the GPIOx port which is connected with tc77 
    //
    xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(TC77_PIN_SPI_MISO));
    xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(TC77_PIN_SPI_MOSI));
    xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(TC77_PIN_SPI_CLK));
    xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(TC77_PIN_SPI_CS));
    
    //
    // Enable the SPIx which is connected with tc77
    //
    xSysCtlPeripheralEnable2(TC77_PIN_SPI_PORT);
    
    //
    // Set TC77_PIN_SPI_CS as a chip select pin and set it as OUT_MODE
    //
    xGPIOSPinDirModeSet(TC77_PIN_SPI_CS, xGPIO_DIR_MODE_OUT);
    
    //
    // Set TC77_PIN_SPI_CLK as SPIx.CLK
    //
    xSPinTypeSPI(TC77_SPI_CLK, TC77_PIN_SPI_CLK);
    
    //
    // Set TC77_PIN_SPI_MISO as SPIx.MISO
    //
    xSPinTypeSPI(TC77_SPI_MISO, TC77_PIN_SPI_MISO);
    
    //
    // Configure MCU as a master device , 16 bits data width ,MSB first,Mode_0
    //
    xSPIConfigSet(TC77_PIN_SPI_PORT, ulSpiClock, xSPI_MOTO_FORMAT_MODE_0 |
                                                       xSPI_DATA_WIDTH16 |
                                                        xSPI_MODE_MASTER |
                                                           xSPI_MSB_FIRST);
    //
    // Disable TC77 when Power up
    //
    xGPIOSPinWrite(TC77_PIN_SPI_CS, 1);

    //
    // Wait for the first conversion completed
    //
    while(!(0x0004 & sReadValue))
    {
        sReadValue = TC77TemperRead();
    }
}
예제 #4
0
파일: AT45DB161.c 프로젝트: AlexGora/cox
//*****************************************************************************
//
//! \brief Initialize AT45DB161 and SPI
//!
//! \param ulSpiClock specifies the SPI Clock Rate
//!
//! This function initialize the mcu SPI as master and specified SPI port.
//! After SPI and port was configured, the mcu send a AT45DB161_CMD_SRRD command
//! to get the page size of AT45DB161 to get prepareed for the followed read and
//! write operations.
//!
//! \return None.
//
//*****************************************************************************
void AT45DB161_Init(unsigned long ulSpiClock)
{
    unsigned char tmp;
    xASSERT((ulSpiClock > 0) && (ulSpiClock < AT45DB161_MAX_CLK));
    xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(AT45DB161_SCK));
    xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(AT45DB161_CS_PIN));
    xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(AT45DB161_MISO));
    xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(AT45DB161_MOSI));
    xSysCtlPeripheralEnable2(AT45DB161_SPI_PORT);
    xSysCtlPeripheralEnable(SYSCTL_PERIPH_AFIO);
    xGPIOSPinDirModeSet(AT45DB161_CS_PIN, xGPIO_DIR_MODE_OUT);
#if (AT45DB161_WRITE_PROTECT < 1)
    xGPIOSPinDirModeSet(FLASH_PIN_WRITE_PROTECT, xGPIO_DIR_MODE_OUT);
    xGPIOSPinWrite(FLASH_PIN_WRITE_PROTECT, 0);
#endif
    //
    // PD1 as SPI2.CLK
    //
    xSPinTypeSPI(SPI_CLK, AT45DB161_SCK);
    //
    // PD2 as SPI2.MISO
    // MISO20 => SPI0MISO
    //
    xSPinTypeSPI(SPI_MISO, AT45DB161_MISO);
    //
    // PD3 as SPI2.MOSI
    // MOSI20 => SPI0MISO
    //
    xSPinTypeSPI(SPI_MOSI, AT45DB161_MOSI);

    //xSysCtlPeripheralEnable(SYSCTL_PERIPH_AFIO);
    //
    //! Set SPI mode.
    //
    xSPIConfigSet(AT45DB161_SPI_PORT, ulSpiClock, SPI_MODE_MASTER |
                  SPI_MSB_FIRST |
                  SPI_2LINE_FULL |
                  SPI_DATA_WIDTH8 |
                  SPI_FORMAT_MODE_4);
    SPISSModeConfig(AT45DB161_SPI_PORT, SPI_CR1_SSM);
    SPISSIConfig(AT45DB161_SPI_PORT, SPI_CR1_SSI);
    SPIEnble(AT45DB161_SPI_PORT);
    AT45DB161_CS = 1;
    xSPISingleDataReadWrite(AT45DB161_SPI_PORT, 0xFF);
    xSysCtlDelay(100000);
    AT45DB161_CS = 0;
    //
    //! Read AT45DB161 state register to get the page size.
    //
    xSPISingleDataReadWrite(AT45DB161_SPI_PORT, AT45DB161_CMD_SRRD);
    tmp = xSPISingleDataReadWrite(AT45DB161_SPI_PORT, 0xFF);
    if(tmp & AT45DB161_PGSZ) AT45DB161_PageSize = 512;
    AT45DB161_CS = 1;
}
예제 #5
0
파일: tc77.c 프로젝트: AlexGora/cox
//*****************************************************************************
//
//! \brief Read TC77 ID
//! 
//! \param None
//!
//! This function is to get ID
//! 
//! \return TC77 ID
//
//*****************************************************************************
unsigned short
TC77IDcodeGet(void)
{
    unsigned short usReadVal,usWriteVal,usIDcode;

    //
    //  Step 0, Set CS,Start communication
    //
    xGPIOSPinWrite(TC77_PIN_SPI_CS, 0);
    
    xGPIOSPinTypeGPIOInput(TC77_PIN_SPI_MOSI);
    
    //
    //  Step 1, Read 16
    //
    xSPIDataRead(TC77_PIN_SPI_PORT, &usReadVal, 1);
    
    //
    //  Step 2, Enter Shutdown mode : Write 0XFFFF
    //
    xSPinTypeSPI(TC77_SPI_MOSI, TC77_PIN_SPI_MOSI);
    
    usWriteVal = TC77_MODE_SHUTDOWN;
    
    xSPIDataWrite(TC77_PIN_SPI_PORT, &usWriteVal, 1);
    
    //
    // Step 3, Read IDcode
    //
    xGPIOSPinTypeGPIOInput(TC77_PIN_SPI_MOSI);
    
    usReadVal = 0;
    xSPIDataRead(TC77_PIN_SPI_PORT, &usReadVal, 1);
    
    //
    //  Step 4, Enter Continus Mode : Wirte 0x0000
    //
    xSPinTypeSPI(TC77_SPI_MOSI, TC77_PIN_SPI_MOSI);
    
    usWriteVal = TC77_MODE_CONTINUOUS;
    
    xSPIDataWrite(TC77_PIN_SPI_PORT, &usWriteVal, 1);
    
    //
    // Step 5, Set CS => 1 Stop Communication
    //
    xGPIOSPinWrite(TC77_PIN_SPI_CS, 1);
    
    usIDcode = usReadVal >> 8;
    
    return usIDcode;
}
예제 #6
0
//////////////////////////////////////////////////////////////////////////////
// Platform (STM32F103X) initialization for peripherals as GPIO, SPI, UARTs //
//////////////////////////////////////////////////////////////////////////////
void platform_init(void)
{
    xSysCtlClockSet(72000000,  xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_8MHZ);

    xSysCtlDelay((xSysCtlClockGet()/1000)*50); // wait 50ms


    /**************************/
    /* GPIO_A For SPI CS PIN  */// It must be first to enable GPIO peripheral than other peripheral. (Otherwise, UART do not run in STM32F103X)
    /**************************/
    xSysCtlPeripheralEnable( xSYSCTL_PERIPH_GPIOA );
    xGPIODirModeSet(xGPIO_PORTA_BASE, xGPIO_PIN_4, xGPIO_DIR_MODE_OUT);


    /************/
    /* For UART */
    /************/
    xSysCtlPeripheralReset(xSYSCTL_PERIPH_UART1);
    xSysCtlPeripheralEnable(xSYSCTL_PERIPH_UART1);
    xSPinTypeUART(UART1TX,PA9);
    xSPinTypeUART(UART1RX,PA10);
    xUARTConfigSet(xUART1_BASE, 115200, (UART_CONFIG_WLEN_8 | UART_CONFIG_STOP_ONE | UART_CONFIG_PAR_NONE));
    xUARTEnable(xUART1_BASE, (UART_BLOCK_UART | UART_BLOCK_TX | UART_BLOCK_RX));


    /***********/
    /* For SPI */
    /***********/
    xSysCtlPeripheralReset(WIZCHIP_SPI_PERIPH);
    xSysCtlPeripheralEnable(WIZCHIP_SPI_PERIPH);
    xSPinTypeSPI(WIZCHIP_SPI_CLK, WIZCHIP_SPI_CLK_PIN);  // xGPIODirModeSet(xGPIO_PORTA, xGPIO_PIN_5, GPIO_TYPE_AFOUT_STD, GPIO_OUT_SPEED_50M);
    xSPinTypeSPI(WIZCHIP_SPI_MOSI,WIZCHIP_SPI_MOSI_PIN);  // xGPIODirModeSet(xGPIO_PORTA, xGPIO_PIN_7, GPIO_TYPE_AFOUT_STD, GPIO_OUT_SPEED_50M);
    xSPinTypeSPI(WIZCHIP_SPI_MISO,WIZCHIP_SPI_MISO_PIN);  // xGPIODirModeSet(xGPIO_PORTA, xGPIO_PIN_6, GPIO_TYPE_IN_FLOATING, GPIO_IN_SPEED_FIXED);
    xSPIConfigSet(WIZCHIP_SPI_BASE, xSysCtlClockGet()/2, xSPI_MOTO_FORMAT_MODE_0 | xSPI_MODE_MASTER | xSPI_MSB_FIRST | xSPI_DATA_WIDTH8);

    xSPISSSet(WIZCHIP_SPI_BASE, SPI_SS_SOFTWARE, xSPI_SS_NONE);
    xSPIEnable(WIZCHIP_SPI_BASE);

    printf("HCLK = %dMHz\r\n", (unsigned int)(xSysCtlClockGet()/1000000));
}
예제 #7
0
파일: spitest03.c 프로젝트: 0xc0170/cox
static void xspi004_MasterIntFunction(void)
{
    unsigned long i, ulTemp=0;
    
    //
    // Configure Some GPIO pins as SPI Mode
    //    
    xSPinTypeSPI(SPI0CLK,  PC5);
    xSPinTypeSPI(SPI0CS,   PC4);
    xSPinTypeSPI(SPI0MISO, PC7);
    xSPinTypeSPI(SPI0MOSI, PC6);   
   
    //xHWREGB(xSPI0_BASE + SPI_C1) = 0x54; 
    //xHWREGB(xSPI0_BASE + SPI_C2) = 0x80; 
    //xHWREGB(xSPI0_BASE + SPI_BR) = 0x00; 
    //xHWREGB(xSPI0_BASE + SPI_M) = 0x04;

    //
    // Master Mode polarity 0,Rx latched at rising edge Tx changed at rising edge
    // 2000000Hz 8Bits Data windth SPI MSB First
    //
    ulTemp = xSPI_MOTO_FORMAT_MODE_0 | xSPI_MODE_MASTER | xSPI_MSB_FIRST;
    
    xSPIConfigSet(xSPI0_BASE, 20000, ulTemp);
    
    xSPIEnable(xSPI0_BASE);

    xIntEnable(INT_SPI0);   
    xIntPrioritySet(INT_SPI0, 1); 
    xSPIIntCallbackInit(xSPI0_BASE, SPI0Callback);
    xSPIIntEnable(xSPI0_BASE, SPI_SPTEF | SPI_SPRF);      
 
    while(!ulFlag);
        
    for(i = 0; i < 8; i++)
    {
        TestAssert((ulSourceData[i] == ulDestData[i]), "xspi API error!");
        ulSourceData[i] = 0;
    }
}
예제 #8
0
파일: SpiSlave.c 프로젝트: AlexGora/cox
//*****************************************************************************
//
//! Ininite the SPI case which is needed
//!
//! \param None
//!
//! This function ininite the SPI including clock source and enable spi 
//!
//! \return none
//
//*****************************************************************************
void SpiReceiveTransferInit(void)
{
    //
    // Set SysClk 36MHz using Extern 12M oscillator
    //
    xSysCtlClockSet(12000000, xSYSCTL_OSC_MAIN | xSYSCTL_XTAL_25MHZ);
    //
    // Enable Peripheral SPI0
    //
    SysCtlPeripheralEnable(SYSCTL_PERIPH_SPI1);
    
    //
    // Configure Some GPIO pins as SPI Mode
    //
    xSPinTypeSPI(SPI1CLK(1), PA5);
    xSPinTypeSPI(SPI1MOSI(1), PA7);
    xSPinTypeSPI(SPI1MISO(1), PA6);
    xSPinTypeSPI(SPI1CS(1), PA4);

    xSPIConfigSet(SPI1_BASE, 200000, xSPI_MOTO_FORMAT_MODE_0 | xSPI_DATA_WIDTH8 | 
                             xSPI_MSB_FIRST | xSPI_MODE_SLAVE);

}
예제 #9
0
파일: tc77.c 프로젝트: AlexGora/cox
//*****************************************************************************
//
//! \brief Configure TC77 temperature convertion mode 
//!
//! \param ulMode determines if TC77_CONTINUOUS_MODE or TC77_SHUTDOWN_MODE to select.
//!
//! The parameter of usMode can be:
//! - TC77_MODE_CONTINUOUS - enter Continuous Temperature Conversion Mode
//! - TC77_MODE_SHUTDOWN.  - enter ShutDown Mode
//!
//! This function is to set and change TC77 temperature convertion mode,you can 
//! use TC77_MODE_SHUTDOWN if you want to enter low power consumption condition.
//! And you can use TC77_MODE_CONTINUOUS to switch condition from shutdown mode.
//! 
//! \return None
//
//*****************************************************************************
void
TC77Configure(unsigned short usMode)
{
    unsigned short usRead,usWrite;
    
    //
    // Check the arguments.
    //
    xASSERT((usMode == TC77_MODE_CONTINUOUS) || (usMode == TC77_MODE_SHUTDOWN));
    
    //
    //  Step 0, Set CS,Start communication
    // 
    xGPIOSPinWrite(TC77_PIN_SPI_CS, 0);
    
    xGPIOSPinTypeGPIOInput(TC77_PIN_SPI_MOSI);
    
    //
    // Step 1, Read temperature
    //
    xSPIDataRead(TC77_PIN_SPI_PORT, &usRead, 1);  

    xSPinTypeSPI(TC77_SPI_MOSI, TC77_PIN_SPI_MOSI);
    
    //
    // Continous conversion mode 
    //
    if(usMode == TC77_MODE_CONTINUOUS)
    {
        usWrite = TC77_MODE_CONTINUOUS;
    }
    
    //
    // ShutDown conversion mode 
    //    
    else
    {
        usWrite = TC77_MODE_SHUTDOWN;
    }
    
    //
    // Step 2, Enter corresponding mode
    //
    xSPIDataWrite(TC77_PIN_SPI_PORT, &usWrite, 1);
    
    //
    // Step 3, Set CS => 1 Stop Communication
    //
    xGPIOSPinWrite(TC77_PIN_SPI_CS, 1);
}
예제 #10
0
파일: CH376.c 프로젝트: AlexGora/cox
//*****************************************************************************
//
//! \brief MCU communication port initialize
//!
//! \param None
//!
//! \return None.
//
//*****************************************************************************
void	CH376PortInit( void )
{
#ifdef CH376_INT_WIRE
    xSysCtlPeripheralEnable2(CH376_INT_PORT);
    xGPIOSPinDirModeSet(CH376_INT_PIN, xGPIO_DIR_MODE_IN); //pass
    xGPIOSPinWrite(CH376_INT_PIN, 1);
#endif
#ifdef CH376_USE_HARDWARE_SPI
    xSysCtlPeripheralEnable2(CH376_SPI_CS_PORT);
    xGPIOSPinDirModeSet(CH376_SPI_CS_PIN, xGPIO_DIR_MODE_OUT);
    xSysCtlPeripheralEnable(SYSCTL_PERIPH_AFIO);
    xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(CH376_SCK));
    xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(CH376_MOSI));
    xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(CH376_MISO));
    xSysCtlPeripheralEnable2(CH376_SPI_PORT);

    xSPinTypeSPI(CH376SPI_CLK, CH376_SCK);
    xSPinTypeSPI(CH376SPI_MISO, CH376_MISO);
    xSPinTypeSPI(CH376SPI_MOSI, CH376_MOSI);

    xSPIConfigSet(CH376_SPI_PORT, CH376_CLK_FREQ, SPI_MODE_MASTER |
    		            xSPI_MOTO_FORMAT_MODE_3 |
    		            xSPI_MODE_MASTER |
    		            xSPI_MSB_FIRST |
    		            xSPI_DATA_WIDTH8);
//    SPISSModeConfig(CH376_SPI_PORT, SPI_CR1_SSM);
//    SPISSIConfig(CH376_SPI_PORT, SPI_CR1_SSI);
    xSPISSSet( CH376_SPI_PORT, xSPI_SS_SOFTWARE, xSPI_SS0 );
    SPIEnble(CH376_SPI_PORT);
    CH376_SPI_CS_SET;
#endif  //End of CH376_USE_HARDWARE_SPI define

#ifdef CH376_USE_SOFTWARE_SPI
    xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(CH376_SCK_PIN));
    xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(CH376_MISO_PIN));
    xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(CH376_MOSI_PIN));
    xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(CH376_SPI_CS_PIN));

    xGPIOSPinDirModeSet(CH376_SPI_CS_PIN, xGPIO_DIR_MODE_OUT);
    xGPIOSPinDirModeSet(CH376_SCK_PIN, xGPIO_DIR_MODE_OUT);
    xGPIOSPinDirModeSet(CH376_MOSI_PIN, xGPIO_DIR_MODE_OUT);
    xGPIOSPinDirModeSet(CH376_MISO_PIN, xGPIO_DIR_MODE_IN);
    CH376_SPI_CS_SET;
#endif  //End of CH376_USE_SOFTWARE_SPI define

#ifdef CH376_USE_PARALLEL
    xSysCtlPeripheralEnable2(CH376_WR_PORT);
    xSysCtlPeripheralEnable2(CH376_RD_PORT);
    xSysCtlPeripheralEnable2(CH376_A0_PORT);
    xSysCtlPeripheralEnable2(CH376_PCS_PORT);
    xSysCtlPeripheralEnable2(CH376_DATA_PORT);
    xGPIOSPinDirModeSet(CH376_WR_PIN, xGPIO_DIR_MODE_OUT);
    xGPIOSPinDirModeSet(CH376_RD_PIN, xGPIO_DIR_MODE_OUT);
    xGPIOSPinDirModeSet(CH376_A0_PIN, xGPIO_DIR_MODE_OUT);
    xGPIOSPinDirModeSet(CH376_PCS_PIN, xGPIO_DIR_MODE_OUT);
    xGPIODirModeSet( CH376_DATA_PORT, 0xFF, xGPIO_DIR_MODE_IN );
    CH376_PCS_SET;
    CH376_WR_SET;
    CH376_RD_SET;
    CH376_A0_CLR;
#endif  //End of CH376_USE_PARALLEL define

}
예제 #11
0
파일: hd44780.c 프로젝트: AlexGora/cox
//*****************************************************************************
//
//! \brief Init the HD44780 LCD Device.
//!
//! \param None.
//!
//! This function is used to Init the HD44780 Device. It must be call before 
//! any other LCD function use.
//!
//! It Open the pins's GPIO peripheral port, and config the pins type to GPIO 
//! output. Then config the LCD into the default state, clear the LCD and 
//! Open the display. Default A Blink cursor is set on. The LCD cursor move 
//! direction is config as increment default.
//!
//! The HD44780 Initial state can be determined by the \ref HD44780_Config.
//! - Pins that used is determined by \ref HD44780_Config_Pins.
//! - The inteface data length is determined by \ref HD44780_INTERFACE_DATA_LEN.
//! - The LCD display line is determined by \ref HD44780_DISPLAY_LINE.
//! - The LCD character font is determined by \ref HD44780_CHARACTER_FONT.
//! .
//! 
//! \return None.
//
//*****************************************************************************
void 
HD44780Init(void)
{
	ucDisplayFunction = (HD44780_INTERFACE_DATA_LEN |
                         HD44780_FUNCTION_SET_N_2 |
                         HD44780_CHARACTER_FONT);
	ucRsPin = 1;
	ucRwPin = 255;
	ucEnablePin = 2;
	ucDataPin[0] = 6;
	ucDataPin[1] = 5;
	ucDataPin[2] = 4;
	ucDataPin[3] = 3;
	_SPIbuff = 0;

    xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(HD44780_PIN_CS));
    xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(HD44780_PIN_CLK));
    xSysCtlPeripheralEnable(xGPIOSPinToPeripheralId(HD44780_PIN_MOSI));
     

#if HD44780_SPI_MODE == SPIMODE_HARDWARE
    //
    // Enable Peripheral SPI1
    //
    xSysCtlPeripheralEnable2(HD44780_SPI);
    SysCtlPeripheralEnable(SYSCTL_PERIPH_AFIO);

    //
    // Configure Some GPIO pins as SPI Mode    SPI MISO is no use in LCD4884
    //
    xSPinTypeSPI(HD44780_CLK,HD44780_PIN_CLK);
    xSPinTypeSPI(HD44780_MOSI,HD44780_PIN_MOSI);
    xGPIOSPinTypeGPIOOutput(HD44780_PIN_CS);

    //
    // Configure SPI  SPI1,ulRate
    //
    xSPIConfigSet((HD44780_SPI), HD44780_SPI_BAUDRATE,
    	SPI_FORMAT_MODE_3 | SPI_DATA_WIDTH8 | SPI_MSB_FIRST | SPI_MODE_MASTER);

    //
    //! \note Enanble SPI SS,test on M0516LBN.other mcu there may need modify.
    //
    xSPISSSet((HD44780_SPI), xSPI_SS_SOFTWARE, xSPI_SS0);
    xSPIEnable(HD44780_SPI);
#else
    //
    // Set Pins Type to GPIO Output
    //

    xGPIOSPinTypeGPIOOutput(HD44780_PIN_CS);
    xGPIOSPinTypeGPIOOutput(HD44780_PIN_CLK);
    xGPIOSPinTypeGPIOOutput(HD44780_PIN_MOSI);
#endif

    //
    // Output default value : E disable
    //

    //
    // Set Entry Mode: Interface Data Length, Character Font, Display Line
    //
    while(HD44780Busy());
    HD44780WriteCmd(HD44780_CMD_FUNCTION_SET(HD44780_INTERFACE_DATA_LEN |
                                             HD44780_FUNCTION_SET_N_2 |
                                             HD44780_CHARACTER_FONT));

    //
    // Display on & Cursor Blink
    //
    while(HD44780Busy());
    HD44780WriteCmd(HD44780_CMD_DISPLAY_CTRL(HD44780_DISPLAY_CTRL_D |
                                             0 |
                                             HD44780_DISPLAY_CTRL_B));

    //
    // Clear LCD
    //
    while(HD44780Busy());
    HD44780WriteCmd(HD44780_CMD_CLS);

    //
    // Cursor Move Mode: Increment
    //
    while(HD44780Busy());
    HD44780WriteCmd(HD44780_CMD_ENTRY_MODE_SET(HD44780_ENTRY_MODE_SET_ID_INC |
                                               0));
    
}
예제 #12
0
파일: uc1701.c 프로젝트: AlexGora/cox
//*****************************************************************************
//
//! \brief Init the UC1701 LCD.
//!
//! \param ulSpiClock SPI clock to select.
//!
//! This function initialize the mcu SPI as master and specified SPI port.
//!
//! \return None.
//
//*****************************************************************************
void UC1701Init(unsigned long ulSpiClock)
{
    //
    // Enable the GPIOx port which is connected with UC1701
    //
    xSysCtlPeripheralEnable(xGPIOSPinToPort(LCD_PIN_SPI_CLK));
    xSysCtlPeripheralEnable(xGPIOSPinToPort(LCD_PIN_SPI_CS));
    xSysCtlPeripheralEnable(xGPIOSPinToPort(LCD_PIN_SPI_MOSI));
    xSysCtlPeripheralEnable(xGPIOSPinToPort(LCD_PIN_CD));
    xSysCtlPeripheralEnable(xGPIOSPinToPort(LCD_PIN_RESET));
    
    //
    // Enable the SPIx which is connected with UC1701
    //
    xSysCtlPeripheralEnable2(LCD_PIN_SPI_PORT);
    xSysCtlPeripheralReset2(LCD_PIN_SPI_PORT);
    //
    // Set the chip select pin as OUT_MODE
    //
    xGPIOSPinDirModeSet(LCD_PIN_SPI_CS, xGPIO_DIR_MODE_OUT);
    //
    // Set the chip reset pin as OUT_MODE
    //
    xGPIOSPinDirModeSet(LCD_PIN_CD, xGPIO_DIR_MODE_OUT);
    xGPIOSPinDirModeSet(LCD_PIN_RESET, xGPIO_DIR_MODE_OUT);
    
    xSPinTypeSPI(SPI_CLK, LCD_PIN_SPI_CLK);
    xSPinTypeSPI(SPI_MOSI, LCD_PIN_SPI_MOSI);
    
    //
    // Configure MCU as a master device , 8 bits data width ,MSB first,Mode_0
    //
    xSPIConfigSet(LCD_PIN_SPI_PORT, ulSpiClock, xSPI_MOTO_FORMAT_MODE_1 |
                                                xSPI_MODE_MASTER | 
                                                xSPI_MSB_FIRST |
                                                xSPI_DATA_WIDTH8);
    //
    // Disable UC1701 when Power up
    //
    xGPIOSPinWrite(LCD_PIN_SPI_CS, 1);

    //
    // Reset the chip
    //
    xGPIOSPinWrite(LCD_PIN_RESET, 0);
    delay_ms(2);
    xGPIOSPinWrite(LCD_PIN_RESET, 1);
    delay_ms(6);

    //
    // Initial Configuration
    //
    UC1701CmdWrite(0xe2);//System Reset
	UC1701CmdWrite(0x2c);//Power Rise Step1
	delay_ms(8);
	UC1701CmdWrite(0x2e);//Power Rise Step2
	delay_ms(8);
	UC1701CmdWrite(0x2f);//Power Rise Step3
	delay_ms(8);
	UC1701CmdWrite(0x23);
	UC1701DoubleCmdWrite(0x81, 0x1f);//Set LCD resistor ratio

	UC1701CmdWrite(0xa2);//Bias 1/9
	UC1701CmdWrite(0xc0);//Set COM Direction
	UC1701CmdWrite(0xa0);//Set SEG Direction
	UC1701CmdWrite(0x40);//Set Scroll Line: the first line
	UC1701CmdWrite(0xaf);//Display Enable

}
예제 #13
0
파일: xgpiotest1.c 프로젝트: 0xc0170/cox
//*****************************************************************************
//
//! \brief xgpio001 test execute main body.
//!
//! \return None.
//
//*****************************************************************************
static void xgpio001Execute(void)
{
   
    unsigned long ulPin, ulPort;
    unsigned long ulvalue, ulTemp;  
    int i, j;

    //
    // GPIOA PIN mode test
    //
    xGPIODirModeSet(xGPIO_PORTA_BASE, xGPIO_PIN_0, xGPIO_DIR_MODE_IN);
    ulvalue = xGPIODirModeGet(xGPIO_PORTA_BASE, xGPIO_PIN_0) ;  
    TestAssert((ulvalue == xGPIO_DIR_MODE_IN), 
                "xgpioA, \" GPIODirModeSet or GPIODirModeGet()\" error");      
    xGPIODirModeSet(xGPIO_PORTA_BASE, xGPIO_PIN_0, xGPIO_DIR_MODE_OUT);
    ulvalue = xGPIODirModeGet(xGPIO_PORTA_BASE, xGPIO_PIN_0) ;    
    TestAssert((ulvalue == xGPIO_DIR_MODE_OUT), 
               "xgpioA, \" GPIODirModeSet or GPIODirModeGet()\" error"); 
    
    xGPIODirModeSet(xGPIO_PORTA_BASE, xGPIO_PIN_4, xGPIO_DIR_MODE_IN);
    ulvalue = xGPIODirModeGet(xGPIO_PORTA_BASE, xGPIO_PIN_4) ;  
    TestAssert((ulvalue == xGPIO_DIR_MODE_IN), 
                "xgpioA, \" GPIODirModeSet or GPIODirModeGet()\" error");
    xGPIODirModeSet(xGPIO_PORTA_BASE, xGPIO_PIN_4, xGPIO_DIR_MODE_OUT);
    ulvalue = xGPIODirModeGet(xGPIO_PORTA_BASE, xGPIO_PIN_4) ;    
    TestAssert((ulvalue == xGPIO_DIR_MODE_OUT), 
               "xgpioA, \" GPIODirModeSet or GPIODirModeGet()\" error"); 
    
    //
    // GPIOB pin mode test
    //
    xGPIODirModeSet(xGPIO_PORTB_BASE, xGPIO_PIN_0, xGPIO_DIR_MODE_IN);
    ulvalue = xGPIODirModeGet(xGPIO_PORTB_BASE, xGPIO_PIN_0) ;  
    TestAssert((ulvalue == xGPIO_DIR_MODE_IN), 
                "xgpioB, \" GPIODirModeSet or GPIODirModeGet()\" error");      
    xGPIODirModeSet(xGPIO_PORTB_BASE, xGPIO_PIN_0, xGPIO_DIR_MODE_OUT);
    ulvalue = xGPIODirModeGet(xGPIO_PORTB_BASE, xGPIO_PIN_0) ;    
    TestAssert((ulvalue == xGPIO_DIR_MODE_OUT), 
               "xgpioB, \" GPIODirModeSet or GPIODirModeGet()\" error");     
    xGPIODirModeSet(xGPIO_PORTB_BASE, xGPIO_PIN_4, xGPIO_DIR_MODE_IN);
    ulvalue = xGPIODirModeGet(xGPIO_PORTB_BASE, xGPIO_PIN_4) ;  
    TestAssert((ulvalue == xGPIO_DIR_MODE_IN), 
                "xgpioB, \" GPIODirModeSet or GPIODirModeGet()\" error");
    xGPIODirModeSet(xGPIO_PORTB_BASE, xGPIO_PIN_4, xGPIO_DIR_MODE_OUT);
    ulvalue = xGPIODirModeGet(xGPIO_PORTB_BASE, xGPIO_PIN_4) ;    
    TestAssert((ulvalue == xGPIO_DIR_MODE_OUT), 
               "xgpioB, \" GPIODirModeSet or GPIODirModeGet()\" error");
	
    //
    // GPIOC pin mode test
    //			   
    xGPIODirModeSet(xGPIO_PORTC_BASE, xGPIO_PIN_0, xGPIO_DIR_MODE_IN);
    ulvalue = xGPIODirModeGet(xGPIO_PORTC_BASE, xGPIO_PIN_0) ;  
    TestAssert((ulvalue == xGPIO_DIR_MODE_IN), 
                "xgpioC, \" GPIODirModeSet or GPIODirModeGet()\" error");
    xGPIODirModeSet(xGPIO_PORTC_BASE, xGPIO_PIN_0, xGPIO_DIR_MODE_OUT);
    ulvalue = xGPIODirModeGet(xGPIO_PORTC_BASE, xGPIO_PIN_0) ;    
    TestAssert((ulvalue == xGPIO_DIR_MODE_OUT), 
               "xgpioC, \" GPIODirModeSet or GPIODirModeGet()\" error");
    xGPIODirModeSet(xGPIO_PORTC_BASE, xGPIO_PIN_4, xGPIO_DIR_MODE_IN);
    ulvalue = xGPIODirModeGet(xGPIO_PORTC_BASE, xGPIO_PIN_4) ;  
    TestAssert((ulvalue == xGPIO_DIR_MODE_IN), 
                "xgpioC, \" GPIODirModeSet or GPIODirModeGet()\" error");
    xGPIODirModeSet(xGPIO_PORTC_BASE, xGPIO_PIN_4, xGPIO_DIR_MODE_OUT);
    ulvalue = xGPIODirModeGet(xGPIO_PORTC_BASE, xGPIO_PIN_4) ;    
    TestAssert((ulvalue == xGPIO_DIR_MODE_OUT), 
               "xgpioC, \" GPIODirModeSet or GPIODirModeGet()\" error");
    //
    // GPIOD pin mode test
    //			   			      
    xGPIODirModeSet(xGPIO_PORTD_BASE, xGPIO_PIN_0, xGPIO_DIR_MODE_IN);
    ulvalue = xGPIODirModeGet(xGPIO_PORTD_BASE, xGPIO_PIN_0) ;  
    TestAssert((ulvalue == xGPIO_DIR_MODE_IN), 
                "xgpioC, \" GPIODirModeSet or GPIODirModeGet()\" error");
    xGPIODirModeSet(xGPIO_PORTD_BASE, xGPIO_PIN_0, xGPIO_DIR_MODE_OUT);
    ulvalue = xGPIODirModeGet(xGPIO_PORTD_BASE, xGPIO_PIN_0) ;    
    TestAssert((ulvalue == xGPIO_DIR_MODE_OUT), 
               "xgpioC, \" GPIODirModeSet or GPIODirModeGet()\" error");
    xGPIODirModeSet(xGPIO_PORTD_BASE, xGPIO_PIN_4, xGPIO_DIR_MODE_IN);
    ulvalue = xGPIODirModeGet(xGPIO_PORTD_BASE, xGPIO_PIN_4) ;  
    TestAssert((ulvalue == xGPIO_DIR_MODE_IN), 
                "xgpioC, \" GPIODirModeSet or GPIODirModeGet()\" error");
    xGPIODirModeSet(xGPIO_PORTD_BASE, xGPIO_PIN_4, xGPIO_DIR_MODE_OUT);
    ulvalue = xGPIODirModeGet(xGPIO_PORTD_BASE, xGPIO_PIN_4) ;    
    TestAssert((ulvalue == xGPIO_DIR_MODE_OUT), 
               "xgpioC, \" GPIODirModeSet or GPIODirModeGet()\" error");
	
    //
    // GPIOE pin mode test
    //			       
    xGPIODirModeSet(xGPIO_PORTE_BASE, xGPIO_PIN_0, xGPIO_DIR_MODE_IN);
    ulvalue = xGPIODirModeGet(xGPIO_PORTE_BASE, xGPIO_PIN_0) ;  
    TestAssert((ulvalue == xGPIO_DIR_MODE_IN), 
                "xgpioC, \" GPIODirModeSet or GPIODirModeGet()\" error");
    xGPIODirModeSet(xGPIO_PORTE_BASE, xGPIO_PIN_0, xGPIO_DIR_MODE_OUT);
    ulvalue = xGPIODirModeGet(xGPIO_PORTE_BASE, xGPIO_PIN_0) ;    
    TestAssert((ulvalue == xGPIO_DIR_MODE_OUT), 
               "xgpioC, \" GPIODirModeSet or GPIODirModeGet()\" error");
    xGPIODirModeSet(xGPIO_PORTE_BASE, xGPIO_PIN_4, xGPIO_DIR_MODE_IN);
    ulvalue = xGPIODirModeGet(xGPIO_PORTE_BASE, xGPIO_PIN_4) ;  
    TestAssert((ulvalue == xGPIO_DIR_MODE_IN), 
                "xgpioC, \" GPIODirModeSet or GPIODirModeGet()\" error");
    xGPIODirModeSet(xGPIO_PORTE_BASE, xGPIO_PIN_4, xGPIO_DIR_MODE_OUT);
    ulvalue = xGPIODirModeGet(xGPIO_PORTE_BASE, xGPIO_PIN_4) ;    
    TestAssert((ulvalue == xGPIO_DIR_MODE_OUT), 
               "xgpioC, \" GPIODirModeSet or GPIODirModeGet()\" error");
       
    xIntDisable(xINT_GPIOA);
    xIntDisable(xINT_GPIOB);
    xIntDisable(xINT_GPIOC);
    xIntDisable(xINT_GPIOD);
    xIntDisable(xINT_GPIOE);
 
/*    
    //
    // GPIOA int enable test
    //
    for(i = 0; i < 5; i++)
    {
        xGPIOPinIntEnable(xGPIO_PORTA_BASE, xGPIO_PIN_0, ulIntTypes[i]);
        ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_CFGR0) & EXTI_CFGR0_SRCTYPE_M;
        TestAssert(ulTemp == ulIntTypes[i],
                   "xgpio, \"xGPIOPinIntEnable \" error");
        ulTemp =  xHWREG(GPIO_AFIO_BASE + AFIO_ESSRO) & AFIO_ESSR0_EXTINPIN_M;
        TestAssert(ulTemp == 0,
                   "xgpio, \"xGPIOPinIntEnable \" error");
	    ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_ICR) & 0x00000001;
        TestAssert(ulTemp == 0x00000001,
                   "xgpio, \"xGPIOPinIntEnable \" error");
    }
    
    //
    // GPIOB int enable test
    //
    for(i = 0; i < 5; i++)
    {
        xGPIOPinIntEnable(xGPIO_PORTB_BASE, xGPIO_PIN_9, ulIntTypes[i]);
        ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_CFGR0 + 9*4) & EXTI_CFGR0_SRCTYPE_M;
        TestAssert(ulTemp == ulIntTypes[i],
                   "xgpio, \"xGPIOPinIntEnable \" error");  
        ulTemp =  xHWREG(GPIO_AFIO_BASE + AFIO_ESSR1) & (AFIO_ESSR0_EXTINPIN_M << 4);
        TestAssert(ulTemp == (1 << 4),
                   "xgpio, \"xGPIOPinIntEnable \" error");
	    ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_ICR) & (0x00000001 << 9);
        TestAssert(ulTemp == (0x00000001 << 9),
                   "xgpio, \"xGPIOPinIntEnable \" error");
    }    

    //
    // GPIOC int enable test
    //
    for(i = 0; i < 5; i++)
    {
        xGPIOPinIntEnable(xGPIO_PORTC_BASE, xGPIO_PIN_1, ulIntTypes[i]);
        ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_CFGR0 + 4) & EXTI_CFGR0_SRCTYPE_M;
        TestAssert(ulTemp == ulIntTypes[i],
                   "xgpio, \"xGPIOPinIntEnable \" error");
        ulTemp =  xHWREG(GPIO_AFIO_BASE + AFIO_ESSRO) & (AFIO_ESSR0_EXTINPIN_M << 4);
        TestAssert(ulTemp == 2 << 4,
                   "xgpio, \"xGPIOPinIntEnable \" error");
	    ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_ICR) & 0x00000002;
        TestAssert(ulTemp == 0x00000002,
                   "xgpio, \"xGPIOPinIntEnable \" error");
    }

    //
    // GPIOD int enable test
    //
    for(i = 0; i < 5; i++)
    {
        xGPIOPinIntEnable(xGPIO_PORTD_BASE, xGPIO_PIN_9, ulIntTypes[i]);
        ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_CFGR0 + 9*4) & EXTI_CFGR0_SRCTYPE_M;
        TestAssert(ulTemp == ulIntTypes[i],
                   "xgpio, \"xGPIOPinIntEnable \" error");  
        ulTemp =  xHWREG(GPIO_AFIO_BASE + AFIO_ESSR1) & (AFIO_ESSR0_EXTINPIN_M << 4);
        TestAssert(ulTemp == (3 << 4),
                   "xgpio, \"xGPIOPinIntEnable \" error");
	    ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_ICR) & (0x00000001 << 9);
        TestAssert(ulTemp == (0x00000001 << 9),
                   "xgpio, \"xGPIOPinIntEnable \" error");
    }

    //
    // GPIOE int enable test
    //
    for(i = 0; i < 5; i++)
    {
        xGPIOPinIntEnable(xGPIO_PORTE_BASE, xGPIO_PIN_10, ulIntTypes[i]);
        ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_CFGR0 + 10*4) & EXTI_CFGR0_SRCTYPE_M;
        TestAssert(ulTemp == ulIntTypes[i],
                   "xgpio, \"xGPIOPinIntEnable \" error");  
        ulTemp =  xHWREG(GPIO_AFIO_BASE + AFIO_ESSR1) & (AFIO_ESSR0_EXTINPIN_M << 8);
        TestAssert(ulTemp == (4 << 8),
                   "xgpio, \"xGPIOPinIntEnable \" error");
	    ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_ICR) & (0x00000001 << 10);
        TestAssert(ulTemp == (0x00000001 << 10),
                   "xgpio, \"xGPIOPinIntEnable \" error");
    } 	 
*/	 
    //
	// Int Disable test
	//
    for(ulPin = 0; ulPin < 16; ulPin++)
    {
        xGPIOPinIntDisable(GPIO_AFIO_BASE, ulPackedPin[ulPin]);
	    ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_ICR) & (0x00000001 << ulPin);
        TestAssert(ulTemp == 0,
                   "xgpio, \"Interrupt disable test \" error"); 
    }
 
    //
    // GPIOA out/in test
    //
    xGPIODirModeSet( xGPIO_PORTA_BASE, xGPIO_PIN_0, GPIO_DIR_MODE_OUT );
    xGPIOPinWrite(xGPIO_PORTA_BASE, xGPIO_PIN_0, 1);
    ulTemp = GPIOPinPortDoutGet(xGPIO_PORTA_BASE);
    TestAssert(ulTemp == xGPIO_PIN_0,
               "xgpio, \"Output pin value set \" error");   

    xGPIOPinWrite(xGPIO_PORTA_BASE, xGPIO_PIN_0, 0);
    ulTemp = GPIOPinPortDoutGet(xGPIO_PORTA_BASE);
    TestAssert(ulTemp == 0,
               "xgpio, \"Output pin value set \" error");  
    
    //
    // GPIOB out/in test
    //
    xGPIODirModeSet( xGPIO_PORTB_BASE, xGPIO_PIN_2, GPIO_DIR_MODE_OUT );
    xGPIOPinWrite(xGPIO_PORTB_BASE, xGPIO_PIN_2, 1);
    ulTemp = GPIOPinPortDoutGet(xGPIO_PORTB_BASE) & xGPIO_PIN_2;
    TestAssert(ulTemp == xGPIO_PIN_2,
               "xgpio, \"Output pin value set \" error");

    xGPIOPinWrite(xGPIO_PORTB_BASE, xGPIO_PIN_2, 0);
    ulTemp = GPIOPinPortDoutGet(xGPIO_PORTB_BASE) & xGPIO_PIN_2;
    TestAssert(ulTemp == 0,
               "xgpio, \"Output pin value set \" error");

    GPIOPortWrite(xGPIO_PORTB_BASE, 0x00000004);
	ulTemp = GPIOPinPortDoutGet(xGPIO_PORTB_BASE) & xGPIO_PIN_2;
    TestAssert(ulTemp == 0x00000004,
               "xgpio, \"Output port value set \" error");
	GPIOPinWrite(GPIO_PORTB_BASE, GPIO_PIN_2, 0);
	ulTemp = GPIOPinPortDoutGet(xGPIO_PORTB_BASE) & xGPIO_PIN_2;
    TestAssert(ulTemp == 0,
               "xgpio, \"Output port value set2 \" error");

    //
    // GPIOC out/in test
    //
    xGPIODirModeSet( xGPIO_PORTC_BASE, xGPIO_PIN_0, GPIO_DIR_MODE_OUT );
    xGPIOPinWrite(xGPIO_PORTC_BASE, xGPIO_PIN_0, 1);
    ulTemp = GPIOPinPortDoutGet(xGPIO_PORTC_BASE);
    TestAssert(ulTemp == xGPIO_PIN_0,
               "xgpio, \"Output pin value set \" error");   

    xGPIOPinWrite(xGPIO_PORTC_BASE, xGPIO_PIN_0, 0);
    ulTemp = GPIOPinPortDoutGet(xGPIO_PORTC_BASE);
    TestAssert(ulTemp == 0,
               "xgpio, \"Output pin value set \" error"); 

    //
    // GPIOD out/in test
    //
    xGPIODirModeSet( xGPIO_PORTD_BASE, xGPIO_PIN_0, GPIO_DIR_MODE_OUT );
    xGPIOPinWrite(xGPIO_PORTD_BASE, xGPIO_PIN_0, 1);
    ulTemp = GPIOPinPortDoutGet(xGPIO_PORTD_BASE);
    TestAssert(ulTemp == xGPIO_PIN_0,
               "xgpio, \"Output pin value set \" error");   

    xGPIOPinWrite(xGPIO_PORTD_BASE, xGPIO_PIN_0, 0);
    ulTemp = GPIOPinPortDoutGet(xGPIO_PORTD_BASE);
    TestAssert(ulTemp == 0,
               "xgpio, \"Output pin value set \" error"); 

    //
    // GPIOE out/in test
    //
    xGPIODirModeSet( xGPIO_PORTE_BASE, xGPIO_PIN_0, GPIO_DIR_MODE_OUT );
    xGPIOPinWrite(xGPIO_PORTE_BASE, xGPIO_PIN_0, 1);
    ulTemp = GPIOPinPortDoutGet(xGPIO_PORTE_BASE);
    TestAssert(ulTemp == xGPIO_PIN_0,
               "xgpio, \"Output pin value set \" error");   

    xGPIOPinWrite(xGPIO_PORTE_BASE, xGPIO_PIN_0, 0);
    ulTemp = GPIOPinPortDoutGet(xGPIO_PORTE_BASE);
    TestAssert(ulTemp == 0,
               "xgpio, \"Output pin value set \" error");
	    
    //
    // EXTI line De-bounce enable test
    //
    EXTILineDebounceEnable(xGPIO_PIN_0);
    ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_CFGR0) & EXTI_CFGR0_DBEN;
    TestAssert(ulTemp == EXTI_CFGR0_DBEN,
               "xgpio, \"De-bounce enable test \" error");  

	//
	// EXTI line De-bounce disable test
	//
    EXTILineDebounceDisable(xGPIO_PIN_0);
    ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_CFGR0) & EXTI_CFGR0_DBEN;
    TestAssert(ulTemp == 0,
               "xgpio, \"De-bounce disable test \" error"); 
	
	//
	// EXTI line De-bounce time set test
	//
	for(i = 0; i < 3; i++)
	{
	    for(j = 0; j < 3; j++)
		{
		    EXTIDebounceTimeSet(ulEXTILines[i], ulDeBounceTime[j]);
			ulTemp = EXTIDebounceTimeGet(ulEXTILines[i]);   
			TestAssert(ulTemp == ulDeBounceTime[j], 
			           "xgpio, \"De-bounce disable test \" error");  
		}  
	}	
	
	//
	// EXTI Wake Up Int configure test
	//
    EXTIWakeUpIntConfigure(ulEXTIWakeUpInt[0]);
	ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_WAKUPCR) & EXTI_WAKUPCR_EVWUPIEN;
    TestAssert(ulTemp == EXTI_WAKUPCR_EVWUPIEN,
               "xgpio, \"EXTI Wake Up Int Enable \" error");
	EXTIWakeUpIntConfigure(ulEXTIWakeUpInt[1]);
	ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_WAKUPCR) & EXTI_WAKUPCR_EVWUPIEN;
    TestAssert(ulTemp == 0,
               "xgpio, \"EXTI Wake Up Int Enable \" error");	   

	//
	// EXTI Wake up Configure test
	//
	for(i = 0; i < 3; i++)
	{	
		EXTILineWakeUpConfigure(ulEXTILines[i], ulEXTIWakeUpLevel[0],
			                    ulEXTIWakeUp[0]);
		ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_WAKUPPOLR) & 
		               (1 << ulEXTILineShift[i]);
		TestAssert(ulTemp == (1 << ulEXTILineShift[i]),
                   "xgpio, \"EXTI Wake Up Level \" error");

		EXTILineWakeUpConfigure(ulEXTILines[i], ulEXTIWakeUpLevel[1],
			                    ulEXTIWakeUp[0]);
		ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_WAKUPPOLR) & 
		               (1 << ulEXTILines[i]);
		TestAssert(ulTemp == 0,
                   "xgpio, \"EXTI Wake Up Level \" error");

		ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_WAKUPCR) & 
		               (1 << ulEXTILineShift[i]);
		TestAssert(ulTemp == (1 << ulEXTILineShift[i]),
                   "xgpio, \"EXTI Wake Up Enable \" error");

		EXTILineWakeUpConfigure(ulEXTILines[i], ulEXTIWakeUpLevel[0],
			                    ulEXTIWakeUp[1]);
		ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_WAKUPCR) & 
		               (1 << ulEXTILineShift[i]);
		TestAssert(ulTemp == 0,
                   "xgpio, \"EXTI Wake Up Disable \" error");
	}	  	   
	
	//
	// GPIO Pad configure
	//
    GPIOPadConfigSet(GPIO_PORTA_BASE, xGPIO_PIN_3, 
                     ulStrengthValue[0], ulOpenDrain[0] | ulPullResistor[0]);
    ulTemp =  xHWREG(GPIO_PORTA_BASE + GPIO_DRVR) & xGPIO_PIN_3;
    TestAssert(ulTemp ==0,
               "xgpio, \"Current drain Configure\" error");
    ulTemp = xHWREG(GPIO_PORTA_BASE + GPIO_PUR) & xGPIO_PIN_3;
    TestAssert(ulTemp == xGPIO_PIN_3,
               "xgpio, \"Pull up resistor Enable \" error");
    ulTemp = xHWREG(GPIO_PORTA_BASE + GPIO_PDR) & xGPIO_PIN_3;
    TestAssert(ulTemp == 0,
               "xgpio, \"Pull up resistor Enable \" error");
    ulTemp = xHWREG(ulPort + GPIO_ODR) & xGPIO_PIN_3;
    TestAssert(ulTemp == xGPIO_PIN_3,
               "xgpio, \"Open drain enable \" error");

    GPIOPadConfigSet(GPIO_PORTA_BASE, xGPIO_PIN_3, 
                     ulStrengthValue[1], ulOpenDrain[1] | ulPullResistor[1]);
    ulTemp =  xHWREG(GPIO_PORTA_BASE + GPIO_DRVR) & xGPIO_PIN_3;
    TestAssert(ulTemp == xGPIO_PIN_3,
               "xgpio, \"Current drain Configure\" error");
    ulTemp = xHWREG(GPIO_PORTA_BASE + GPIO_PUR) & xGPIO_PIN_3;
    TestAssert(ulTemp == 0,
               "xgpio, \"Pull up resistor Enable \" error");
    ulTemp = xHWREG(GPIO_PORTA_BASE + GPIO_PDR) & xGPIO_PIN_3;
    TestAssert(ulTemp == xGPIO_PIN_3,
               "xgpio, \"Pull up resistor Enable \" error");
    ulTemp = xHWREG(GPIO_PORTA_BASE + GPIO_ODR) & xGPIO_PIN_3;
    TestAssert(ulTemp == 0,
               "xgpio, \"Open drain disable \" error");	
			   
	//
	// Software Trigger test
	//
	for(i = 0; i < 3; i++)
	{		   		   			   	
	    EXTILineSoftwareTrigger(ulEXTILines[i]);
		ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_SSCR) &  ulEXTILines[i];
		TestAssert(ulTemp == ulEXTILines[i],
                   "xgpio, \"Software Trigger Set \" error");	
    }
	
	//
	// Software Trigger clear
	//	  
	for(i = 0; i < 3; i++)
	{
	    EXTILineSoftwareClear(ulEXTILines[i]);
		ulTemp = xHWREG(GPIO_EXTI_BASE + EXTI_SSCR) &  ulEXTILines[i];
		TestAssert(ulTemp == 0,
                   "xgpio, \"Software Trigger Clear \" error");
    }
    
    //
    // Short pin to pin test
    //
    ulTemp = xGPIOSPinToPin(PA0);
    TestAssert(ulTemp == ulPinValue[0],
               "xgpio, \" Short pin to pin test \" error");  
    ulTemp = xGPIOSPinToPin(PA1);
    TestAssert(ulTemp == ulPinValue[1],
               "xgpio, \" Short pin to pin test \" error");        
    ulTemp = xGPIOSPinToPin(PA2);
    TestAssert(ulTemp == ulPinValue[2],
               "xgpio, \" Short pin to pin test \" error");   
    
    
    //
    // Short pin write test
    //
    xGPIOSPinWrite(PA0, 1);
    ulTemp = GPIOSPinRead(PA0) & GPIO_PIN_0;
    TestAssert(ulTemp == GPIO_PIN_0,
               "xgpio, \"Short pin write test \" error"); 
 
   
    //
    // Ture pin to ADC function
    //    
    xSPinTypeADC(ADC0, PA0);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 0);
    TestAssert((ulTemp == (1 << 0 )),
               "xgpio, \"Turn pin to ADC AIN0 \" error");      
    
    xSPinTypeADC(ADC1, PA1);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 2);
    TestAssert((ulTemp == (1 << 2 )),
               "xgpio, \"Turn pin to ADC AIN1 \" error");  
    
    xSPinTypeADC(ADC2, PA2);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 4);
    TestAssert((ulTemp == (1 << 4 )),
               "xgpio, \"Turn pin to ADC AIN2 \" error");     

    xSPinTypeADC(ADC3, PA3);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 6);
    TestAssert((ulTemp == (1 << 6 )),
               "xgpio, \"Turn pin to ADC AIN3 \" error"); 
    
    xSPinTypeADC(ADC4, PA4);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 8);
    TestAssert((ulTemp == (1 << 8 )),
               "xgpio, \"Turn pin to ADC AIN4 \" error");  
    
    xSPinTypeADC(ADC5, PA5);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 10);
    TestAssert((ulTemp == (1 << 10 )),
               "xgpio, \"Turn pin to ADC AIN5 \" error"); 
    
    xSPinTypeADC(ADC6, PA6);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 12);
    TestAssert((ulTemp == (1 << 12 )),
               "xgpio, \"Turn pin to ADC AIN6 \" error");    
    
    xSPinTypeADC(ADC7, PA7);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 14);
    TestAssert((ulTemp == (1 << 14 )),
               "xgpio, \"Turn pin to ADC AIN7 \" error"); 

    
    //
    // Ture pin to I2C0 function
    //    
    xSPinTypeI2C(I2C0SDA, PC5);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 10);
    TestAssert((ulTemp == (2 << 10)),
               "xgpio, \"Turn pin to I2C SDA \" error");
    xSPinTypeI2C(I2C0SDA, PC12);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 24);
    TestAssert((ulTemp == (1 << 24)),
               "xgpio, \"Turn pin to I2C SDA \" error");
    xSPinTypeI2C(I2C0SDA, PD13);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 26);
    TestAssert((ulTemp == (2 << 26)),
               "xgpio, \"Turn pin to I2C SDA \" error");     			        			         
    
    xSPinTypeI2C(I2C0SCK, PC4);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 8);
    TestAssert((ulTemp == (2 << 8 )),
               "xgpio, \"Turn pin to I2C SCK \" error"); 
    xSPinTypeI2C(I2C0SCK, PC11);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 22);
    TestAssert((ulTemp == (1 << 22 )),
               "xgpio, \"Turn pin to I2C SCK \" error");
    xSPinTypeI2C(I2C0SCK, PD12);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 24);
    TestAssert((ulTemp == (2 << 24 )),
               "xgpio, \"Turn pin to I2C SCK \" error"); 

    //
    // Ture pin to I2C1 function
    //    
    xSPinTypeADC(I2C1SDA, PB7);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 14);
    TestAssert((ulTemp == (2 << 14 )),
               "xgpio, \"Turn pin to I2C1 SDA \" error");
    xSPinTypeADC(I2C1SDA, PC1);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 2);
    TestAssert((ulTemp == (3 << 2 )),
               "xgpio, \"Turn pin to I2C1 SDA \" error");
    xSPinTypeADC(I2C1SDA, PC7);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 14);
    TestAssert((ulTemp == (1 << 14 )),
               "xgpio, \"Turn pin to I2C1 SDA \" error"); 
    xSPinTypeADC(I2C1SDA, PE10);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPECFGR) & (3 << 20);
    TestAssert((ulTemp == (3 << 20 )),
               "xgpio, \"Turn pin to I2C1 SDA \" error"); 

    xSPinTypeI2C(I2C1SCK, PC0);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 0);
    TestAssert((ulTemp == (3 << 0 )),
               "xgpio, \"Turn pin to I2C1 SCK \" error");
    xSPinTypeI2C(I2C1SCK, PC6);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 12);
    TestAssert((ulTemp == (1 << 12 )),
               "xgpio, \"Turn pin to I2C1 SCK \" error"); 
    xSPinTypeI2C(I2C1SCK, PE9);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPECFGR) & (3 << 20);
    TestAssert((ulTemp == (3 << 20 )),
               "xgpio, \"Turn pin to I2C1 SCK \" error"); 			   			    			    
		      			     
/*			               
    //
    // Turn pin to pwm mode
    //
    xSPinTypePWM(PWM0, PC2);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP2;
    ulTemp1 = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_ALT2;
    TestAssert((ulTemp == 0) && (ulTemp1 == GCR_GPCMFP_ALT2),
               "xgpio, \"Turn pin to PWM function \" error");    
   
    xSPinTypePWM(PWM1, PC3);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP3;
    ulTemp1 = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_ALT3;
    TestAssert((ulTemp == 0) && (ulTemp1 == GCR_GPCMFP_ALT3),
               "xgpio, \"Turn pin to PWM function \" error");
    
    xSPinTypePWM(PWM2, PC4);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP4;
    ulTemp1 = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_ALT4;
    TestAssert((ulTemp == 0) && (ulTemp1 == GCR_GPCMFP_ALT4),
               "xgpio, \"Turn pin to PWM function \" error");    
    
    xSPinTypePWM(PWM3, PC5);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP5;
    ulTemp1 = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_ALT5;
    TestAssert((ulTemp == 0) && (ulTemp1 == GCR_GPCMFP_ALT5),
               "xgpio, \"Turn pin to PWM function \" error");       
    
    xSPinTypePWM(PWM4, PC6);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP6;
    ulTemp1 = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_ALT6;
    TestAssert((ulTemp == 0) && (ulTemp1 == GCR_GPCMFP_ALT6),
               "xgpio, \"Turn pin to PWM function \" error");   

    xSPinTypePWM(PWM5, PA4);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP5;
    ulTemp1 = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_ALT5;
    TestAssert((ulTemp == 0) && (ulTemp1 == GCR_GPCMFP_ALT5),
               "xgpio, \"Turn pin to PWM function \" error"); 
*/			         

 
    //
    // Turn pin to spi function test
    //
    xSPinTypeSPI(SPI0CLK, PB1);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 2);
    TestAssert((ulTemp == (3 << 2)),
               "xgpio, \"Turn pin to SPI function \" error");   
    xSPinTypeSPI(SPI0CLK, PD1);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 2);
    TestAssert((ulTemp == (2 << 2)),
               "xgpio, \"Turn pin to SPI function \" error");
    xSPinTypeSPI(SPI0CLK, PD9);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 18);
    TestAssert((ulTemp == (1 << 18)),
               "xgpio, \"Turn pin to SPI function \" error"); 			      

    xSPinTypeSPI(SPI0MOSI, PB2);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 4);
    TestAssert((ulTemp == (3 << 4 )),
               "xgpio, \"Turn pin to SPI function \" error");   
    xSPinTypeSPI(SPI0MOSI, PD2);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 4);
    TestAssert((ulTemp == (2 << 4 )),
               "xgpio, \"Turn pin to SPI function \" error");
    xSPinTypeSPI(SPI0MOSI, PD10);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 20);
    TestAssert((ulTemp == (1 << 20 )),
               "xgpio, \"Turn pin to SPI function \" error");
			    			    

    xSPinTypeSPI(SPI0MISO, PB3);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 6);
    TestAssert((ulTemp == (3 << 6 )),
               "xgpio, \"Turn pin to SPI function \" error"); 
    xSPinTypeSPI(SPI0MISO, PD3);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 6);
    TestAssert((ulTemp == (2 << 6 )),
               "xgpio, \"Turn pin to SPI function \" error");
    xSPinTypeSPI(SPI0MISO, PD11);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 22);
    TestAssert((ulTemp == (1 << 22 )),
               "xgpio, \"Turn pin to SPI function \" error");			    
    
    xSPinTypeSPI(SPI0CS, PB0);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 0);
    TestAssert((ulTemp == (3 << 0 )),
               "xgpio, \"Turn pin to SPI function \" error");        
    xSPinTypeSPI(SPI0CS, PD0);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 0);
    TestAssert((ulTemp == (2 << 0)),
               "xgpio, \"Turn pin to SPI function \" error"); 
    xSPinTypeSPI(SPI0CS, PD8);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 16);
    TestAssert((ulTemp == (1 << 16)),
               "xgpio, \"Turn pin to SPI function \" error");
    
    //
    // Turn pin to timer function test
    //
    xSPinTypeTimer(TIMCCP0, PA0);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 0);
    TestAssert((ulTemp == (3 << 0)),
               "xgpio, \"Turn pin to TIMER function \" error"); 
    xSPinTypeTimer(TIMCCP0, PB0);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 0);
    TestAssert((ulTemp == (1 << 0)),
               "xgpio, \"Turn pin to TIMER function \" error");
    xSPinTypeTimer(TIMCCP0, PD0);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 0);
    TestAssert((ulTemp == (1 << 0)),
               "xgpio, \"Turn pin to TIMER function \" error");
    xSPinTypeTimer(TIMCCP0, PE5);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPECFGR) & (3 << 10);
    TestAssert((ulTemp == (2 << 10)),
               "xgpio, \"Turn pin to TIMER function \" error"); 			    			    
			     
    xSPinTypeTimer(TIMCCP1, PA1);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 2);
    TestAssert((ulTemp == (3 << 2)),
               "xgpio, \"Turn pin to TIMER function \" error");		      
    xSPinTypeTimer(TIMCCP1, PB1);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 2);
    TestAssert((ulTemp == (1 << 2)),
               "xgpio, \"Turn pin to TIMER function \" error");
    xSPinTypeTimer(TIMCCP1, PD1);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 2);
    TestAssert((ulTemp == (1 << 2)),
               "xgpio, \"Turn pin to TIMER function \" error");
    xSPinTypeTimer(TIMCCP1, PE6);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPECFGR) & (3 << 12);
    TestAssert((ulTemp == (2 << 12)),
               "xgpio, \"Turn pin to TIMER function \" error");
			    	
			   
    xSPinTypeTimer(TIMCCP2, PA2);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 4);
    TestAssert((ulTemp == (3 << 4)),
               "xgpio, \"Turn pin to TIMER function \" error");		      
    xSPinTypeTimer(TIMCCP2, PB2);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 4);
    TestAssert((ulTemp == (1 << 4)),
               "xgpio, \"Turn pin to TIMER function \" error");
    xSPinTypeTimer(TIMCCP2, PD2);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 4);
    TestAssert((ulTemp == (1 << 4)),
               "xgpio, \"Turn pin to TIMER function \" error");
    xSPinTypeTimer(TIMCCP2, PE7);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPECFGR) & (3 << 14);
    TestAssert((ulTemp == (2 << 14)),
               "xgpio, \"Turn pin to TIMER function \" error"); 
			   
    xSPinTypeTimer(TIMCCP3, PA3);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 6);
    TestAssert((ulTemp == (3 << 6)),
               "xgpio, \"Turn pin to TIMER function \" error");		      
    xSPinTypeTimer(TIMCCP3, PB3);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 6);
    TestAssert((ulTemp == (1 << 6)),
               "xgpio, \"Turn pin to TIMER function \" error");
    xSPinTypeTimer(TIMCCP3, PD3);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 6);
    TestAssert((ulTemp == (1 << 6)),
               "xgpio, \"Turn pin to TIMER function \" error");
    xSPinTypeTimer(TIMCCP3, PE8);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPECFGR) & (3 << 16);
    TestAssert((ulTemp == (2 << 16)),
               "xgpio, \"Turn pin to TIMER function \" error"); 
			   
    xSPinTypeTimer(TIMCCP4, PA12);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 24);
    TestAssert((ulTemp == (1 << 24)),
               "xgpio, \"Turn pin to TIMER function \" error");   
    xSPinTypeTimer(TIMCCP4, PC0);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 0);
    TestAssert((ulTemp == (2 << 0)),
               "xgpio, \"Turn pin to TIMER function \" error"); 
    xSPinTypeTimer(TIMCCP4, PD8);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 16);
    TestAssert((ulTemp == (3 << 16)),
               "xgpio, \"Turn pin to TIMER function \" error"); 			   	
			 
    xSPinTypeTimer(TIMCCP5, PA13);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 26);
    TestAssert((ulTemp == (1 << 26)),
               "xgpio, \"Turn pin to TIMER function \" error");   
    xSPinTypeTimer(TIMCCP5, PC1);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 2);
    TestAssert((ulTemp == (2 << 2)),
               "xgpio, \"Turn pin to TIMER function \" error"); 
    xSPinTypeTimer(TIMCCP5, PD9);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 18);
    TestAssert((ulTemp == (3 << 18)),
               "xgpio, \"Turn pin to TIMER function \" error"); 	
			   
    xSPinTypeTimer(TIMCCP6, PA14);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 28);
    TestAssert((ulTemp == (1 << 28)),
               "xgpio, \"Turn pin to TIMER function \" error");   
    xSPinTypeTimer(TIMCCP6, PC2);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 4);
    TestAssert((ulTemp == (2 << 4)),
               "xgpio, \"Turn pin to TIMER function \" error"); 
    xSPinTypeTimer(TIMCCP6, PD10);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 20);
    TestAssert((ulTemp == (3 << 20)),
               "xgpio, \"Turn pin to TIMER function \" error");	
			   
    xSPinTypeTimer(TIMCCP7, PA15);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 30);
    TestAssert((ulTemp == (1 << 30)),
               "xgpio, \"Turn pin to TIMER function \" error");   
    xSPinTypeTimer(TIMCCP7, PC3);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 6);
    TestAssert((ulTemp == (2 << 6)),
               "xgpio, \"Turn pin to TIMER function \" error"); 
    xSPinTypeTimer(TIMCCP7, PD11);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 22);
    TestAssert((ulTemp == (3 << 22)),
               "xgpio, \"Turn pin to TIMER function \" error");		   		   		   		    			   			   		     
    
    xSPinTypeTimer(T0EX, PC15);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 30);
    TestAssert((ulTemp == (2 << 30)),
               "xgpio, \"Turn pin to TIMER function \" error");  
    xSPinTypeTimer(T0EX, PD13);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 26);
    TestAssert((ulTemp == (3 << 26)),
               "xgpio, \"Turn pin to TIMER function \" error");
    xSPinTypeTimer(T0EX, PE9);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPECFGR) & (3 << 18);
    TestAssert((ulTemp == (2 << 18)),
               "xgpio, \"Turn pin to TIMER function \" error");			     
    
    xSPinTypeTimer(T1EX, PD12);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 24);
    TestAssert((ulTemp == (3 << 24)),
               "xgpio, \"Turn pin to TIMER function \" error");
    xSPinTypeTimer(T1EX, PE10);   
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPECFGR) & (3 << 20);
    TestAssert((ulTemp == (2 << 20)),
               "xgpio, \"Turn pin to TIMER function \" error");
			   			    
    
    // 
    // Turn pin to uart function test
    //
    xSPinTypeUART(UART0RX, PA3);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 6);
    TestAssert((ulTemp == (2 << 6)),
               "xgpio, \"Turn pin to UART function \" error"); 
    xSPinTypeUART(UART0RX, PA11);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 22);
    TestAssert((ulTemp == (2 << 22)),
               "xgpio, \"Turn pin to UART function \" error");	
    xSPinTypeUART(UART0RX, PB13);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 26);
    TestAssert((ulTemp == (1 << 26)),
               "xgpio, \"Turn pin to UART function \" error");	
    xSPinTypeUART(UART0RX, PC10);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 20);
    TestAssert((ulTemp == (3 << 20)),
               "xgpio, \"Turn pin to UART function \" error");

    xSPinTypeUART(UART0TX, PA2);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 4);
    TestAssert((ulTemp == (2 << 4)),
               "xgpio, \"Turn pin to UART function \" error");
    xSPinTypeUART(UART0TX, PA10);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 20);
    TestAssert((ulTemp == (2 << 20)),
               "xgpio, \"Turn pin to UART function \" error");
    xSPinTypeUART(UART0TX, PB10);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 20);
    TestAssert((ulTemp == (1 << 20)),
               "xgpio, \"Turn pin to UART function \" error");
    xSPinTypeUART(UART0TX, PC8);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 16);
    TestAssert((ulTemp == (3 << 16)),
               "xgpio, \"Turn pin to UART function \" error");				             
    
    xSPinTypeUART(UART0RTS, PA8);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 16);
    TestAssert((ulTemp == (2 << 16)),
               "xgpio, \"Turn pin to UART function \" error");  
    xSPinTypeUART(UART0RTS, PB8);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 16);
    TestAssert((ulTemp == (1 << 16)),
               "xgpio, \"Turn pin to UART function \" error");
    xSPinTypeUART(UART0RTS, PC11);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 22);
    TestAssert((ulTemp == (3 << 22)),
               "xgpio, \"Turn pin to UART function \" error"); 
    
    xSPinTypeUART(UART0CTS, PA9);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 18);
    TestAssert((ulTemp == (2 << 18)),
               "xgpio, \"Turn pin to UART function \" error");  
    xSPinTypeUART(UART0CTS, PB9);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 18);
    TestAssert((ulTemp == (1 << 18)),
               "xgpio, \"Turn pin to UART function \" error");
    xSPinTypeUART(UART0CTS, PC12);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 24);
    TestAssert((ulTemp == (3 << 24)),
               "xgpio, \"Turn pin to UART function \" error"); 

    xSPinTypeUART(UART0DCD, PC3);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 6);
    TestAssert((ulTemp == (3 << 6)),
               "xgpio, \"Turn pin to UART function \" error");  
    xSPinTypeUART(UART0DCD, PD2);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 4);
    TestAssert((ulTemp == (3 << 4)),
               "xgpio, \"Turn pin to UART function \" error");
			   
    xSPinTypeUART(UART0DSR, PC15);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 30);
    TestAssert((ulTemp == (3 << 30)),
               "xgpio, \"Turn pin to UART function \" error");  			   
	
    xSPinTypeUART(UART0DTR, PB7);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 14);
    TestAssert((ulTemp == (3 << 14)),
               "xgpio, \"Turn pin to UART function \" error");  
    xSPinTypeUART(UART0DTR, PD0);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 0);
    TestAssert((ulTemp == (3 << 0)),
               "xgpio, \"Turn pin to UART function \" error"); 	
			   
    xSPinTypeUART(UART0RI, PC2);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 4);
    TestAssert((ulTemp == (3 << 4)),
               "xgpio, \"Turn pin to UART function \" error");  
    xSPinTypeUART(UART0RI, PD1);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPDCFGR) & (3 << 2);
    TestAssert((ulTemp == (3 << 2)),
               "xgpio, \"Turn pin to UART function \" error"); 
			   
    xSPinTypeUART(UART1RX, PA7);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 14);
    TestAssert((ulTemp == (2 << 14)),
               "xgpio, \"Turn pin to UART function \" error"); 
    xSPinTypeUART(UART1RX, PB3);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 6);
    TestAssert((ulTemp == (2 << 6)),
               "xgpio, \"Turn pin to UART function \" error");
    xSPinTypeUART(UART1RX, PC5);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 10);
    TestAssert((ulTemp == (1 << 10)),
               "xgpio, \"Turn pin to UART function \" error");	   			   		    

    xSPinTypeUART(UART1TX, PA6);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 12);
    TestAssert((ulTemp == (2 << 12)),
               "xgpio, \"Turn pin to UART function \" error"); 
    xSPinTypeUART(UART1TX, PB2);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 4);
    TestAssert((ulTemp == (2 << 4)),
               "xgpio, \"Turn pin to UART function \" error");
    xSPinTypeUART(UART1TX, PC4);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 8);
    TestAssert((ulTemp == (1 << 8)),
               "xgpio, \"Turn pin to UART function \" error");

    xSPinTypeUART(UART1RTS, PA4);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 8);
    TestAssert((ulTemp == (2 << 8)),
               "xgpio, \"Turn pin to UART function \" error"); 
    xSPinTypeUART(UART1RTS, PB0);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 0);
    TestAssert((ulTemp == (2 << 0)),
               "xgpio, \"Turn pin to UART function \" error");
    xSPinTypeUART(UART1RTS, PB15);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 30);
    TestAssert((ulTemp == (1 << 30)),
               "xgpio, \"Turn pin to UART function \" error");
    xSPinTypeUART(UART1RTS, PC13);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 26);
    TestAssert((ulTemp == (3 << 26)),
               "xgpio, \"Turn pin to UART function \" error");

    xSPinTypeUART(UART1CTS, PA5);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPACFGR) & (3 << 10);
    TestAssert((ulTemp == (2 << 10)),
               "xgpio, \"Turn pin to UART function \" error"); 
    xSPinTypeUART(UART1CTS, PB1);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 2);
    TestAssert((ulTemp == (2 << 2)),
               "xgpio, \"Turn pin to UART function \" error");
    xSPinTypeUART(UART1CTS, PB14);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPBCFGR) & (3 << 28);
    TestAssert((ulTemp == (1 << 28)),
               "xgpio, \"Turn pin to UART function \" error");
    xSPinTypeUART(UART1CTS, PC14);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPCCFGR) & (3 << 28);
    TestAssert((ulTemp == (3 << 28)),
               "xgpio, \"Turn pin to UART function \" error");

   
    //
    // Turn the pin to ACMP function
    //
    xSPinTypeACMP(CMP0P, PE6);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPECFGR) & (3 << 12);
    TestAssert((ulTemp == (1 << 12)),
               "xgpio, \"Turn pin to ACMP function \" error");  
    
    xSPinTypeACMP(CMP0N, PE5);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPECFGR) & (3 << 10);
    TestAssert((ulTemp == (1 << 10)),
               "xgpio, \"Turn pin to ACMP function \" error");       

    xSPinTypeACMP(CMP0O, PE7);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPECFGR) & (3 << 14);
    TestAssert((ulTemp == (1 << 14)),
               "xgpio, \"Turn pin to ACMP function \" error");     

    xSPinTypeACMP(CMP1P, PE9);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPECFGR) & (3 << 18);
    TestAssert((ulTemp == (1 << 18)),
               "xgpio, \"Turn pin to ACMP function \" error"); 

    xSPinTypeACMP(CMP1N, PE8);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPECFGR) & (3 << 16);
    TestAssert((ulTemp == (1 << 16)),
               "xgpio, \"Turn pin to ACMP function \" error"); 

    xSPinTypeACMP(CMP1O, PE10);
    ulTemp = xHWREG(GPIO_AFIO_BASE + AFIO_GPECFGR) & (3 << 20);
    TestAssert((ulTemp == (1 << 20)),
               "xgpio, \"Turn pin to ACMP function \" error");

}   
예제 #14
0
파일: xgpiotest1.c 프로젝트: 0xc0170/cox
//*****************************************************************************
//
//! \brief xgpio001 test execute main body.
//!
//! \return None.
//
//*****************************************************************************
static void xgpio001Execute(void)
{
   
    unsigned long ulPin, ulPort;
    unsigned long ulvalue, ulTemp, ulTemp1;  
    int i, j;
    
    //
    // GPIO mode set and get. 
    //
    for(ulPort = 0; ulPort < 5; ulPort++)
    {
        for(ulPin = 0; ulPin < 16; ulPin++)
        {        
            for(i = 0; i < 5; i++)
            {
                if(ulPort != 1 && ulPort != 3)
                {
                    xGPIODirModeSet(ulGPIO[ulPort], ulPackedPin[ulPin], ulPinMode[i]);        
                    ulvalue = xGPIODirModeGet(ulGPIO[ulPort], ulPackedPin[ulPin]);
                    TestAssert((ulvalue == ulPinMode[i]), 
                                "xgpio, \" GPIODirModeSet or GPIODirModeGet()\" error");
                }
            }
        }
    }
    
    xIntDisable(xINT_GPIOA);
    xIntDisable(xINT_GPIOB);
    xIntDisable(xINT_GPIOC);
    xIntDisable(xINT_GPIOD);
    xIntDisable(xINT_GPIOE);    
    
    
    //
    // Interrupt enable.
    //
    for(ulPort = 0; ulPort < 5; ulPort++)
    {
        for(ulPin = 0; ulPin < 16; ulPin++)
        { 
            for(i = 0; i < 6; i++)
            {
                xGPIOPinIntEnable(ulGPIO[ulPort], ulPackedPin[ulPin], ulIntType[i]);
                if(ulIntType[i] & 0x10)
                { 
                    ulTemp = xHWREG(ulGPIO[ulPort] + GPIO_IMD) & ulPackedPin[ulPin];
                    TestAssert(ulTemp == ulPackedPin[ulPin],
                               "xgpio, \"Level INT type enable \" error");
                }
                else
                {
                    ulTemp = xHWREG(ulGPIO[ulPort] + GPIO_IMD) & ulPackedPin[ulPin];
                    TestAssert(ulTemp == 0,
                               "xgpio, \"Edge INT type enable \" error");
                }
                if(ulIntType[i] & 2)
                {
                    ulTemp = xHWREG(ulGPIO[ulPort] + GPIO_IEN) & (ulPackedPin[ulPin] << 16);
                    TestAssert(ulTemp == (ulPackedPin[ulPin] << 16),
                               "xgpio, \"Rising or high level Int \" error");                    
                }
                if(ulIntType[i] & 1)
                {
                    ulTemp = xHWREG(ulGPIO[ulPort] + GPIO_IEN) & ulPackedPin[ulPin];
                    TestAssert(ulTemp == ulPackedPin[ulPin],
                               "xgpio, \"Falling or low level Int \" error");  
                }
            }
        }
    }

    
    //
    // Interrupt disable test
    //
    for(ulPort = 0; ulPort < 5; ulPort++)
    {
        for(ulPin = 0; ulPin < 16; ulPin++)
        {
            xGPIOPinIntDisable(ulGPIO[ulPort], ulPackedPin[ulPin]);
            ulTemp = xHWREG(ulGPIO[ulPort] + GPIO_IEN) & (ulPackedPin[ulPin] << 16);
            ulTemp1 = xHWREG(ulGPIO[ulPort] + GPIO_IEN) & ulPackedPin[ulPin];
            ulTemp |= ulTemp1;
            TestAssert(ulTemp == 0,
                       "xgpio, \"Interrupt disable test \" error"); 
        }
    }
    
    //
    // Pin Out/in value test
    //
    for(ulPort = 0; ulPort < 5; ulPort++)
    {
        //
        // Output pin value set
        //
        for(ulPin = 0; ulPin < 16; ulPin++)
        {
            xGPIODirModeSet( ulGPIO[ulPort], ulPackedPin[ulPin], GPIO_DIR_MODE_OUT );
            xGPIOPinWrite(ulGPIO[ulPort], ulPackedPin[ulPin], 1);
            ulTemp = xHWREG(ulGPIO[ulPort] + GPIO_DOUT) & ulPackedPin[ulPin];
            TestAssert(ulTemp == ulPackedPin[ulPin],
                       "xgpio, \"Output pin value set \" error"); 
        }   
      
    }
    
    //
    // De-bounce enable/disable test
    //
    for(ulPort = 0; ulPort < 5; ulPort++)
    {
        //
        // De-bounce enable test
        //
        for(ulPin = 0; ulPin < 16; ulPin++)
        {
            GPIOPinDebounceEnable(ulGPIO[ulPort], ulPackedPin[ulPin]);
            ulTemp = xHWREG(ulGPIO[ulPort] + GPIO_DBEN) & ulPackedPin[ulPin];
            TestAssert(ulTemp == ulPackedPin[ulPin],
                       "xgpio, \"De-bounce enable test \" error");  
        }   
        
        //
        // De-bounce disable test
        //
        for(ulPin = 0; ulPin < 16; ulPin++)
        {
            GPIOPinDebounceDisable(ulGPIO[ulPort], ulPackedPin[ulPin]);
            ulTemp = xHWREG(ulGPIO[ulPort] + GPIO_DBEN) & ulPackedPin[ulPin];
            TestAssert(ulTemp == 0,
                       "xgpio, \"De-bounce Disable test \" error");  
        }  
    }
    
    //
    // Mask set/get test
    // 
    for(ulPort = 0; ulPort < 5; ulPort++)
    {
        for(ulPin = 0; ulPin < 16; ulPin++)
        {
            GPIOPinMaskSet(ulGPIO[ulPort], ulPackedPin[ulPin]);
            ulTemp = GPIOPortMaskGet(ulGPIO[ulPort]) & ulPackedPin[ulPin];     
            TestAssert(ulTemp == ulPackedPin[ulPin],
                       "xgpio, \" Mask set/get test \" error");  
        }
    }
    
    //
    // De-bounce time set and get test
    //
    for(i = 0; i < 2; i++)
    {
        for(j = 0; j < 3; j++)
        {
            GPIODebounceTimeSet(ulDelay[i], ulDelayCycle[j]);
            ulTemp = xHWREG(GPIO_DBNCECON) & 0x10;
            if(i == 0)
            {
                TestAssert(ulTemp == 0,
                           "xgpio, \" De-bounce source set \" error");  
            }
            else
            {  
                TestAssert(ulTemp == 0x10,
                           "xgpio, \" De-bounce source set \" error");  
            }
            ulTemp1 = GPIODebounceTimeGet();
            TestAssert(ulTemp1 == ulDelayCycle[j],
                       "xgpio, \" De-bounce cycle test \" error");  
        }
    }
    
    //
    // Pin to peripheral ID test
    //
    ulTemp = xGPIOSPinToPeripheralId(PA0);
    TestAssert(ulTemp == ulPeripheralID[0],
               "xgpio, \" Pin to peripheral ID test \" error");  
    
    //
    // Short pin to pin test
    //
    ulTemp = xGPIOSPinToPin(PA0);
    TestAssert(ulTemp == ulPinValue[0],
               "xgpio, \" Short pin to pin test \" error");  
    ulTemp = xGPIOSPinToPin(PB8);
    TestAssert(ulTemp == ulPinValue[1],
               "xgpio, \" Short pin to pin test \" error");        
    ulTemp = xGPIOSPinToPin(PE15);
    TestAssert(ulTemp == ulPinValue[2],
               "xgpio, \" Short pin to pin test \" error");   
    
    //
    // Short pin dir mode set test
    //
    for(i = 0; i < 5; i++)
    {
        xGPIOSPinDirModeSet(PA0, ulPinMode[i]);
        ulTemp = xGPIODirModeGet(xGPIO_PORTA_BASE, GPIO_PIN_0);
        TestAssert(ulTemp == ulPinMode[i],
                   "xgpio, \" Short pin dir mode set test \" error");       
    }
    
    //
    // Short pin interrupt enable
    //
    for(i = 0; i < 6; i++)
    {
        xGPIOSPinIntEnable(PA0, ulIntType[i]);
        if(ulIntType[i] & 0x10)
        { 
            ulTemp = xHWREG(xGPIO_PORTA_BASE + GPIO_IMD) & GPIO_PIN_0;
            TestAssert(ulTemp == GPIO_PIN_0,
                       "xgpio, \"ShortPin INT type enable \" error");
        }
        else
        {
            ulTemp = xHWREG(xGPIO_PORTA_BASE + GPIO_IMD) & GPIO_PIN_0;
            TestAssert(ulTemp == 0,
                       "xgpio, \"ShortPin INT type enable \" error");
        }
        if(ulIntType[i] & 2)
        {
            ulTemp = xHWREG(xGPIO_PORTA_BASE + GPIO_IEN) & (GPIO_PIN_0 << 16);
            TestAssert(ulTemp == (GPIO_PIN_0 << 16),
                       "xgpio, \"ShortPin INT type enable \" error");                    
        }
        if(ulIntType[i] & 1)
        {
            ulTemp = xHWREG(xGPIO_PORTA_BASE + GPIO_IEN) & GPIO_PIN_0;
            TestAssert(ulTemp == GPIO_PIN_0,
                       "xgpio, \"ShortPin INT type enable \" error");  
        }
    }
    
    //
    // Short pin interrupt disable
    // 
    xGPIOSPinIntDisable(PA0);
    ulTemp = xHWREG(xGPIO_PORTA_BASE + GPIO_IEN) & (GPIO_PIN_0 << 16);
    ulTemp1 = xHWREG(xGPIO_PORTA_BASE + GPIO_IEN) & GPIO_PIN_0;
    ulTemp |= ulTemp1;
    TestAssert(ulTemp == 0,
               "xgpio, \"Short pin interrupt disable \" error"); 
    
    //
    // Short pin write test
    //
    xGPIOSPinWrite(PA0, 1);
    ulTemp = xHWREG(xGPIO_PORTA_BASE + GPIO_DOUT) & GPIO_PIN_0;
    TestAssert(ulTemp == GPIO_PIN_0,
               "xgpio, \"Short pin write test \" error"); 
        
    //
    // Turn pin to gpio mode test
    //  
    xGPIOSPinTypeGPIOInput(PA0);
    ulTemp = xHWREG(GCR_GPAMFP) & GPIO_PIN_0;
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to gpio mode test \" error"); 
    
    //
    // Turn pin to ADC input function
    //
    xSPinTypeADC(ADC0, PA0);
    ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP0;
    TestAssert(ulTemp == GCR_GPAMFP_MFP0,
               "xgpio, \"Turn pin to ADC0 input \" error");   
    
    xSPinTypeADC(ADC1, PA1);
    ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP1;
    TestAssert(ulTemp == GCR_GPAMFP_MFP1,
               "xgpio, \"Turn pin to ADC1 input \" error"); 
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN | GCR_ALTMFP_EBI_HB_EN_4);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to ADC1 input \" error"); 
    
    xSPinTypeADC(ADC2, PA2);  
    ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP2;
    TestAssert(ulTemp == GCR_GPAMFP_MFP2,
               "xgpio, \"Turn pin to ADC2 input \" error"); 
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN | GCR_ALTMFP_EBI_HB_EN_3);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to ADC2 input \" error");    
    
    xSPinTypeADC(ADC3, PA3);  
    ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP3;
    TestAssert(ulTemp == GCR_GPAMFP_MFP3,
               "xgpio, \"Turn pin to ADC3 input \" error"); 
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN | GCR_ALTMFP_EBI_HB_EN_2);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to ADC3 input \" error");   
    
    xSPinTypeADC(ADC4, PA4);  
    ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP4;
    TestAssert(ulTemp == GCR_GPAMFP_MFP4,
               "xgpio, \"Turn pin to ADC4 input \" error"); 
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN | GCR_ALTMFP_EBI_HB_EN_1);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to ADC4 input \" error");
    
    xSPinTypeADC(ADC5, PA5);  
    ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP5;
    TestAssert(ulTemp == GCR_GPAMFP_MFP5,
               "xgpio, \"Turn pin to ADC5 input \" error"); 
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN | GCR_ALTMFP_EBI_HB_EN_0);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to ADC5 input \" error");
    
    xSPinTypeADC(ADC6, PA6);  
    ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP6;
    TestAssert(ulTemp == GCR_GPAMFP_MFP6,
               "xgpio, \"Turn pin to ADC6 input \" error"); 
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to ADC6 input \" error");
    
    xSPinTypeADC(ADC7, PA7);  
    ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP7;
    TestAssert(ulTemp == GCR_GPAMFP_MFP7,
               "xgpio, \"Turn pin to ADC7 input \" error"); 
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to ADC7 input \" error");    
    ulTemp = xHWREG(GCR_ALTMFP) & GCR_ALTMFP_PA7_S21;
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to ADC7 input \" error");   
    
    //
    // Ture pin to I2C function
    //
    xSPinTypeI2C(I2C0SCK, PA9);
    ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP9;
    TestAssert(ulTemp == GCR_GPAMFP_MFP9,
               "xgpio, \"Turn pin to I2C input \" error");    
    
    xSPinTypeI2C(I2C0SDA, PA8);
    ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP8;
    TestAssert(ulTemp == GCR_GPAMFP_MFP8,
               "xgpio, \"Turn pin to I2C input \" error");  
    
    xSPinTypeI2C(I2C1SCK, PA11);
    ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP11;
    TestAssert(ulTemp == GCR_GPAMFP_MFP11,
               "xgpio, \"Turn pin to I2C input \" error");     
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to I2C input \" error");   
    
    xSPinTypeI2C(I2C1SDA, PA10);
    ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP10;
    TestAssert(ulTemp == GCR_GPAMFP_MFP10,
               "xgpio, \"Turn pin to I2C input \" error");     
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to I2C input \" error");    
    
    //
    // Turn pin to CAN function 
    //    
    xSPinTypeCAN(CAN0RX, PD6);
    ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP6;
    TestAssert(ulTemp == GCR_GPDMFP_MFP6,
               "xgpio, \"Turn pin to CAN function \" error"); 
    
    xSPinTypeCAN(CAN0TX, PD7);
    ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP7;
    TestAssert(ulTemp == GCR_GPDMFP_MFP7,
               "xgpio, \"Turn pin to CAN function \" error");   
    
    //
    // Turn pin to I2S function
    //
    xSPinTypeI2S(I2S0RXMCLK, PA15);
    ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP15;
    TestAssert(ulTemp == GCR_GPAMFP_MFP15,
               "xgpio, \"Turn pin to I2S function \" error");     
    ulTemp = xHWREG(GCR_ALTMFP) & GCR_ALTMFP_PA15_I2SMCLK;
    TestAssert(ulTemp == GCR_ALTMFP_PA15_I2SMCLK,
               "xgpio, \"Turn pin to I2S function \" error");   
    
    xSPinTypeI2S(I2S0RXSCK, PC1);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP1;
    TestAssert(ulTemp == GCR_GPCMFP_MFP1,
               "xgpio, \"Turn pin to I2S function \" error");        
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PC1_I2SBCLK);
    TestAssert(ulTemp == GCR_ALTMFP_PC1_I2SBCLK,
               "xgpio, \"Turn pin to I2S function \" error");  
    
    xSPinTypeI2S(I2S0RXSD, PC2);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP2;
    TestAssert(ulTemp == GCR_GPCMFP_MFP2,
               "xgpio, \"Turn pin to I2S function \" error");        
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PC2_I2SDI);
    TestAssert(ulTemp == GCR_ALTMFP_PC2_I2SDI,
               "xgpio, \"Turn pin to I2S function \" error");  
    
    xSPinTypeI2S(I2S0RXWS, PC0);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP0;
    TestAssert(ulTemp == GCR_GPCMFP_MFP0,
               "xgpio, \"Turn pin to I2S function \" error");        
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PC0_I2SLRCLK);
    TestAssert(ulTemp == GCR_ALTMFP_PC0_I2SLRCLK,
               "xgpio, \"Turn pin to I2S function \" error");      
    
    xSPinTypeI2S(I2S0TXMCLK, PA15);
    ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP15;
    TestAssert(ulTemp == GCR_GPAMFP_MFP15,
               "xgpio, \"Turn pin to I2S function \" error");         
    ulTemp = xHWREG(GCR_ALTMFP) & GCR_ALTMFP_PA15_I2SMCLK;
    TestAssert(ulTemp == GCR_ALTMFP_PA15_I2SMCLK,
               "xgpio, \"Turn pin to I2S function \" error");   
 
    xSPinTypeI2S(I2S0TXSCK, PC1);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP1;
    TestAssert(ulTemp == GCR_GPCMFP_MFP1,
               "xgpio, \"Turn pin to I2S function \" error");        
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PC1_I2SBCLK);
    TestAssert(ulTemp == GCR_ALTMFP_PC1_I2SBCLK,
               "xgpio, \"Turn pin to I2S function \" error");   
    
    xSPinTypeI2S(I2S0TXSD, PC3);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP3;
    TestAssert(ulTemp == GCR_GPCMFP_MFP3,
               "xgpio, \"Turn pin to I2S function \" error");        
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PC3_I2SDO);
    TestAssert(ulTemp == GCR_ALTMFP_PC3_I2SDO,
               "xgpio, \"Turn pin to I2S function \" error");  

    xSPinTypeI2S(I2S0TXWS, PC0);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP0;
    TestAssert(ulTemp == GCR_GPCMFP_MFP0,
               "xgpio, \"Turn pin to I2S function \" error");        
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PC0_I2SLRCLK);
    TestAssert(ulTemp == GCR_ALTMFP_PC0_I2SLRCLK,
               "xgpio, \"Turn pin to I2S function \" error");    
    
    //
    // Turn pin to pwm mode
    //
    xSPinTypePWM(PWM0, PA12);
    ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP12;
    TestAssert(ulTemp == GCR_GPAMFP_MFP12,
               "xgpio, \"Turn pin to I2S function \" error");  
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN | GCR_ALTMFP_EBI_HB_EN_5);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to PWM input \" error");   
   
    xSPinTypePWM(PWM1, PA13);
    ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP13;
    TestAssert(ulTemp == GCR_GPAMFP_MFP13,
               "xgpio, \"Turn pin to I2S function \" error");  
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN | GCR_ALTMFP_EBI_HB_EN_6);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to PWM input \" error");       
    
    xSPinTypePWM(PWM2, PA14);
    ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP14;
    TestAssert(ulTemp == GCR_GPAMFP_MFP14,
               "xgpio, \"Turn pin to I2S function \" error");  
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN | GCR_ALTMFP_EBI_HB_EN_7);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to PWM input \" error");     
    
    xSPinTypePWM(PWM3, PA15);
    ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP15;
    TestAssert(ulTemp == GCR_GPAMFP_MFP15,
               "xgpio, \"Turn pin to I2S function \" error");  
    ulTemp = xHWREG(GCR_ALTMFP) & GCR_ALTMFP_PA15_I2SMCLK;
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to PWM function \" error");    
    
    xSPinTypePWM(PWM4, PB11);
    ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP11;
    TestAssert(ulTemp == GCR_GPBMFP_MFP11,
               "xgpio, \"Turn pin to I2S function \" error");    
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PB11_PWM4);
    TestAssert(ulTemp == GCR_ALTMFP_PB11_PWM4,
               "xgpio, \"Turn pin to PWM input \" error");     
    
    xSPinTypePWM(PWM5, PE5);
    ulTemp = xHWREG(GCR_GPEMFP) & GCR_GPEMFP_MFP5;
    TestAssert(ulTemp == GCR_GPEMFP_MFP5,
               "xgpio, \"Turn pin to I2S function \" error");    
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PE5_T1EX);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to PWM input \" error"); 
    
    xSPinTypePWM(PWM6, PE0);
    ulTemp = xHWREG(GCR_GPEMFP) & GCR_GPEMFP_MFP0;
    TestAssert(ulTemp == GCR_GPEMFP_MFP0,
               "xgpio, \"Turn pin to PWM function \" error");    
    
    xSPinTypePWM(PWM7, PE1);
    ulTemp = xHWREG(GCR_GPEMFP) & GCR_GPEMFP_MFP1;
    TestAssert(ulTemp == GCR_GPEMFP_MFP1,
               "xgpio, \"Turn pin to PWM function \" error");  
    
    //
    // Turn pin to spi function test
    //
    xSPinTypeSPI(SPI0CLK, PC1);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP1;
    TestAssert(ulTemp == GCR_GPCMFP_MFP1,
               "xgpio, \"Turn pin to SPI function \" error");      
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PC1_I2SBCLK);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to SPI function \" error"); 

    xSPinTypeSPI(SPI0MOSI, PC5);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP5;
    TestAssert(ulTemp == GCR_GPCMFP_MFP5,
               "xgpio, \"Turn pin to SPI function \" error");  
    
    xSPinTypeSPI(SPI0MOSI, PC3);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP3;
    TestAssert(ulTemp == GCR_GPCMFP_MFP3,
               "xgpio, \"Turn pin to SPI function \" error"); 
    
    xSPinTypeSPI(SPI0MISO, PC2);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP2;
    TestAssert(ulTemp == GCR_GPCMFP_MFP2,
               "xgpio, \"Turn pin to SPI function \" error");  
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PC2_I2SDI);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to I2S function \" error"); 
    
    xSPinTypeSPI(SPI0MISO, PC4);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP4;
    TestAssert(ulTemp == GCR_GPCMFP_MFP4,
               "xgpio, \"Turn pin to SPI function \" error");     
    
    xSPinTypeSPI(SPI0CS, PC0);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP0;
    TestAssert(ulTemp == GCR_GPCMFP_MFP0,
               "xgpio, \"Turn pin to SPI function \" error");   
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PC0_I2SLRCLK);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to SPI function \" error");  

    xSPinTypeSPI(SPI0CS, PB10);
    ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP10;
    TestAssert(ulTemp == GCR_GPBMFP_MFP10,
               "xgpio, \"Turn pin to SPI function \" error");   
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PB10_S01);
    TestAssert(ulTemp == GCR_ALTMFP_PB10_S01,
               "xgpio, \"Turn pin to SPI function \" error");
    
    xSPinTypeSPI(SPI0CS, PC0);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP0;
    TestAssert(ulTemp == GCR_GPCMFP_MFP0,
               "xgpio, \"Turn pin to SPI function \" error");   
    
    xSPinTypeSPI(SPI1MOSI, PC13);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP13;
    TestAssert(ulTemp == GCR_GPCMFP_MFP13,
               "xgpio, \"Turn pin to SPI function \" error");   
    
    xSPinTypeSPI(SPI1MOSI, PC11);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP11;
    TestAssert(ulTemp == GCR_GPCMFP_MFP11,
               "xgpio, \"Turn pin to SPI function \" error");   
    
    xSPinTypeSPI(SPI1MISO, PC12);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP12;
    TestAssert(ulTemp == GCR_GPCMFP_MFP12,
               "xgpio, \"Turn pin to SPI function \" error");   
    
    xSPinTypeSPI(SPI1MISO, PC10);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP10;
    TestAssert(ulTemp == GCR_GPCMFP_MFP10,
               "xgpio, \"Turn pin to SPI function \" error");    
    
    xSPinTypeSPI(SPI1CS, PB9);
    ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP9;
    TestAssert(ulTemp == GCR_GPBMFP_MFP9,
               "xgpio, \"Turn pin to SPI function \" error");  
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PB9_S11);
    TestAssert(ulTemp == GCR_ALTMFP_PB9_S11,
               "xgpio, \"Turn pin to SPI function \" error");  
    
    xSPinTypeSPI(SPI1CS, PC8);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP8;
    TestAssert(ulTemp == GCR_GPCMFP_MFP8,
               "xgpio, \"Turn pin to SPI function \" error");   
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to SPI function \" error");    
    
    xSPinTypeSPI(SPI2CLK, PD1);
    ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP1;
    TestAssert(ulTemp == GCR_GPDMFP_MFP1,
               "xgpio, \"Turn pin to SPI function \" error");   
    
    xSPinTypeSPI(SPI2MOSI, PD3);
    ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP3;
    TestAssert(ulTemp == GCR_GPDMFP_MFP3,
               "xgpio, \"Turn pin to SPI function \" error");     
    
    xSPinTypeSPI(SPI2MOSI, PD5);
    ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP5;
    TestAssert(ulTemp == GCR_GPDMFP_MFP5,
               "xgpio, \"Turn pin to SPI function \" error");    
    
    xSPinTypeSPI(SPI2MISO, PD4);
    ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP4;
    TestAssert(ulTemp == GCR_GPDMFP_MFP4,
               "xgpio, \"Turn pin to SPI function \" error");    
    
    xSPinTypeSPI(SPI2MISO, PD2);
    ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP2;
    TestAssert(ulTemp == GCR_GPDMFP_MFP2,
               "xgpio, \"Turn pin to SPI function \" error"); 
    
    xSPinTypeSPI(SPI2CS, PA7);
    ulTemp = xHWREG(GCR_GPAMFP) & GCR_GPAMFP_MFP7;
    TestAssert(ulTemp == GCR_GPAMFP_MFP7,
               "xgpio, \"Turn pin to SPI function \" error");     
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PA7_S21);
    TestAssert(ulTemp == GCR_ALTMFP_PA7_S21,
               "xgpio, \"Turn pin to SPI function \" error");
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to SPI function \" error");   
    
    xSPinTypeSPI(SPI2CS, PD0);
    ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP0;
    TestAssert(ulTemp == GCR_GPDMFP_MFP0,
               "xgpio, \"Turn pin to SPI function \" error");  
    
    xSPinTypeSPI(SPI3CLK, PD9);
    ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP9;
    TestAssert(ulTemp == GCR_GPDMFP_MFP9,
               "xgpio, \"Turn pin to SPI function \" error");    
    
    xSPinTypeSPI(SPI3MOSI, PD11);
    ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP11;
    TestAssert(ulTemp == GCR_GPDMFP_MFP11,
               "xgpio, \"Turn pin to SPI function \" error");  
    
    xSPinTypeSPI(SPI3MOSI, PD13);
    ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP13;
    TestAssert(ulTemp == GCR_GPDMFP_MFP13,
               "xgpio, \"Turn pin to SPI function \" error");   
    
    xSPinTypeSPI(SPI3MISO, PD10);
    ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP10;
    TestAssert(ulTemp == GCR_GPDMFP_MFP10,
               "xgpio, \"Turn pin to SPI function \" error");     
    
    xSPinTypeSPI(SPI3MISO, PD12);
    ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP12;
    TestAssert(ulTemp == GCR_GPDMFP_MFP12,
               "xgpio, \"Turn pin to SPI function \" error"); 
    
    
    xSPinTypeSPI(SPI3CS, PB14);
    ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP14;
    TestAssert(ulTemp == GCR_GPBMFP_MFP14,
               "xgpio, \"Turn pin to SPI function \" error");     
    ulTemp =  xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PB14_S31);  
    TestAssert(ulTemp == GCR_ALTMFP_PB14_S31,
               "xgpio, \"Turn pin to SPI function \" error");  
    
    
    xSPinTypeSPI(SPI3CS, PD8);
    ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP8;
    TestAssert(ulTemp == GCR_GPDMFP_MFP8,
               "xgpio, \"Turn pin to SPI function \" error");   
    
    //
    // Turn pin to timer function test
    //
    xSPinTypeTimer(TIMCCP0, PB8);   
    ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP8;
    TestAssert(ulTemp == GCR_GPBMFP_MFP8,
               "xgpio, \"Turn pin to TIMER function \" error");      
    
    xSPinTypeTimer(TIMCCP1, PB9);   
    ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP9;
    TestAssert(ulTemp == GCR_GPBMFP_MFP9,
               "xgpio, \"Turn pin to TIMER function \" error");        
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PB9_S11);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to TIMER function \" error"); 
    
    xSPinTypeTimer(TIMCCP2, PB10);   
    ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP10;
    TestAssert(ulTemp == GCR_GPBMFP_MFP10,
               "xgpio, \"Turn pin to TIMER function \" error");        
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PB10_S01);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to TIMER function \" error");     
    
    xSPinTypeTimer(TIMCCP3, PB11);   
    ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP11;
    TestAssert(ulTemp == GCR_GPBMFP_MFP11,
               "xgpio, \"Turn pin to TIMER function \" error");        
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PB11_PWM4);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to TIMER function \" error");  
    
    // 
    // Turn pin to uart function test
    //
    xSPinTypeUART(UART0RX, PB0);
    ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP0;
    TestAssert(ulTemp == GCR_GPBMFP_MFP0,
               "xgpio, \"Turn pin to UART function \" error");  
    
    xSPinTypeUART(UART0TX, PB1);
    ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP1;
    TestAssert(ulTemp == GCR_GPBMFP_MFP1,
               "xgpio, \"Turn pin to UART function \" error");     
    
    xSPinTypeUART(UART0RTS, PB2);
    ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP2;
    TestAssert(ulTemp == GCR_GPBMFP_MFP2,
               "xgpio, \"Turn pin to UART function \" error");   
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN | GCR_ALTMFP_EBI_nWRL_EN);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to UART function \" error");      
    ulTemp =  xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PB2_T2EX);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to UART function \" error");    

    xSPinTypeUART(UART0CTS, PB3);
    ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP3;
    TestAssert(ulTemp == GCR_GPBMFP_MFP3,
               "xgpio, \"Turn pin to UART function \" error");   
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN | GCR_ALTMFP_EBI_nWRH_EN);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to UART function \" error");
    ulTemp =  xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_PB3_T3EX);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to UART function \" error");  
    
    xSPinTypeUART(UART1RTS, PB6);
    ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP6;
    TestAssert(ulTemp == GCR_GPBMFP_MFP6,
               "xgpio, \"Turn pin to UART function \" error");   
    ulTemp =  xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to UART function \" error");  
    
    xSPinTypeUART(UART1RX, PB4);
    ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP4;
    TestAssert(ulTemp == GCR_GPBMFP_MFP4,
               "xgpio, \"Turn pin to UART function \" error");   
    
    xSPinTypeUART(UART1TX, PB5);
    ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP5;
    TestAssert(ulTemp == GCR_GPBMFP_MFP5,
               "xgpio, \"Turn pin to UART function \" error");   
    
    xSPinTypeUART(UART2RX, PD14);
    ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP14;
    TestAssert(ulTemp == GCR_GPDMFP_MFP14,
               "xgpio, \"Turn pin to UART function \" error");       

    xSPinTypeUART(UART2TX, PD15);
    ulTemp = xHWREG(GCR_GPDMFP) & GCR_GPDMFP_MFP15;
    TestAssert(ulTemp == GCR_GPDMFP_MFP15,
               "xgpio, \"Turn pin to UART function \" error");      
    
    //
    // Turn pin to ACMP function test
    //
    xSPinTypeACMP(CMP0P, PC6);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP6;
    TestAssert(ulTemp == GCR_GPCMFP_MFP6,
               "xgpio, \"Turn pin to SPI function \" error");   
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to SPI function \" error"); 
    
    xSPinTypeACMP(CMP0N, PC7);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP7;
    TestAssert(ulTemp == GCR_GPCMFP_MFP7,
               "xgpio, \"Turn pin to SPI function \" error");   
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to SPI function \" error"); 

    xSPinTypeACMP(CMP0O, PB12);
    ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP12;
    TestAssert(ulTemp == GCR_GPBMFP_MFP12,
               "xgpio, \"Turn pin to SPI function \" error");   
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to SPI function \" error");  

    xSPinTypeACMP(CMP1P, PC14);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP14;
    TestAssert(ulTemp == GCR_GPCMFP_MFP14,
               "xgpio, \"Turn pin to SPI function \" error");   
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to SPI function \" error");      
    
    xSPinTypeACMP(CMP1N, PC15);
    ulTemp = xHWREG(GCR_GPCMFP) & GCR_GPCMFP_MFP15;
    TestAssert(ulTemp == GCR_GPCMFP_MFP15,
               "xgpio, \"Turn pin to SPI function \" error");   
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to SPI function \" error");   
    
    xSPinTypeACMP(CMP1O, PB13);
    ulTemp = xHWREG(GCR_GPBMFP) & GCR_GPBMFP_MFP13;
    TestAssert(ulTemp == GCR_GPBMFP_MFP13,
               "xgpio, \"Turn pin to SPI function \" error");   
    ulTemp = xHWREG(GCR_ALTMFP) & (GCR_ALTMFP_EBI_EN);
    TestAssert(ulTemp == 0,
               "xgpio, \"Turn pin to SPI function \" error");        
    
}