/*******************************************************************************
* DISCLAIMER
* This software is supplied by Renesas Electronics Corporation and is only
* intended for use with Renesas products. No other uses are authorized. This
* software is owned by Renesas Electronics Corporation and is protected under
* all applicable laws, including copyright laws.
* THIS SOFTWARE IS PROVIDED "AS IS" AND RENESAS MAKES NO WARRANTIES REGARDING
* THIS SOFTWARE, WHETHER EXPRESS, IMPLIED OR STATUTORY, INCLUDING BUT NOT
* LIMITED TO WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE
* AND NON-INFRINGEMENT. ALL SUCH WARRANTIES ARE EXPRESSLY DISCLAIMED.
* TO THE MAXIMUM EXTENT PERMITTED NOT PROHIBITED BY LAW, NEITHER RENESAS
* ELECTRONICS CORPORATION NOR ANY OF ITS AFFILIATED COMPANIES SHALL BE LIABLE
* FOR ANY DIRECT, INDIRECT, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES FOR
* ANY REASON RELATED TO THIS SOFTWARE, EVEN IF RENESAS OR ITS AFFILIATES HAVE
* BEEN ADVISED OF THE POSSIBILITY OF SUCH DAMAGES.
* Renesas reserves the right, without notice, to make changes to this software
* and to discontinue the availability of this software. By using this software,
* you agree to the additional terms and conditions found by accessing the
* following link:
* http://www.renesas.com/disclaimer
* Copyright (C) 2012 - 2013 Renesas Electronics Corporation. All rights reserved.
*******************************************************************************/
/*******************************************************************************
* File Name   : port_init.c
* $Rev: 460 $
* $Date:: 2013-07-12 09:16:44 +0900#$
* Description : Initialize peripheral function sample - PORT initialize
*******************************************************************************/


/******************************************************************************
Includes   <System Includes> , "Project Includes"
******************************************************************************/
#include "r_typedefs.h"
#include "port_init.h"
#include "iodefine.h"
#include "rza_io_regrw.h"

#if 0
#pragma arm section code   = "CODE_RESET"
#pragma arm section rodata = "CONST_RESET"
#pragma arm section rwdata = "DATA_RESET"
#pragma arm section zidata = "BSS_RESET"
#endif

/******************************************************************************
Typedef definitions
******************************************************************************/


/******************************************************************************
Macro definitions
******************************************************************************/


/******************************************************************************
Imported global variables and functions (from other files)
******************************************************************************/


/******************************************************************************
Exported global variables and functions (to be accessed by other files)
******************************************************************************/


/******************************************************************************
Private global variables and functions
******************************************************************************/


/******************************************************************************
* Function Name: PORT_Init
* Description  : Executes initial setting for the PORT.
*              : In this sample code, the PORT initial setting is executed to 
*              : connect the SDRAM to the CS2 and the CS3 spaces.
* Arguments    : none
* Return Value : none
******************************************************************************/
void PORT_Init(void)
{
    /* ==== BSC settings ==== */

    /* ---- P2_1 : RAS# ---- */
    /* Port mode : Multiplex mode                     */
    /* Port function setting : 1st multiplex function */
    /* I/O control mode : Peripheral function         */
    RZA_IO_RegWrite_16(&GPIO.PFCAE2, 0, GPIO_PFCAE2_PFCAE21_SHIFT, GPIO_PFCAE2_PFCAE21);
    RZA_IO_RegWrite_16(&GPIO.PFCE2,  0, GPIO_PFCE2_PFCE21_SHIFT,   GPIO_PFCE2_PFCE21);
    RZA_IO_RegWrite_16(&GPIO.PFC2,   0, GPIO_PFC2_PFC21_SHIFT,     GPIO_PFC2_PFC21);
    RZA_IO_RegWrite_16(&GPIO.PMC2,   1, GPIO_PMC2_PMC21_SHIFT,     GPIO_PMC2_PMC21);
    RZA_IO_RegWrite_16(&GPIO.PIPC2,  1, GPIO_PIPC2_PIPC21_SHIFT,   GPIO_PIPC2_PIPC21);

    /* ---- P2_2 : CAS# ---- */
    /* Port mode : Multiplex mode                     */
    /* Port function setting : 1st multiplex function */
    /* I/O control mode : Peripheral function         */
    RZA_IO_RegWrite_16(&GPIO.PFCAE2, 0, GPIO_PFCAE2_PFCAE22_SHIFT, GPIO_PFCAE2_PFCAE22);
    RZA_IO_RegWrite_16(&GPIO.PFCE2,  0, GPIO_PFCE2_PFCE22_SHIFT,   GPIO_PFCE2_PFCE22);
    RZA_IO_RegWrite_16(&GPIO.PFC2,   0, GPIO_PFC2_PFC22_SHIFT,     GPIO_PFC2_PFC22);
    RZA_IO_RegWrite_16(&GPIO.PMC2,   1, GPIO_PMC2_PMC22_SHIFT,     GPIO_PMC2_PMC22);
    RZA_IO_RegWrite_16(&GPIO.PIPC2,  1, GPIO_PIPC2_PIPC22_SHIFT,   GPIO_PIPC2_PIPC22);

    /* ---- P2_3 : CKE ---- */
    /* Port mode : Multiplex mode                     */
    /* Port function setting : 1st multiplex function */
    /* I/O control mode : Peripheral function         */
    RZA_IO_RegWrite_16(&GPIO.PFCAE2, 0, GPIO_PFCAE2_PFCAE23_SHIFT, GPIO_PFCAE2_PFCAE23);
    RZA_IO_RegWrite_16(&GPIO.PFCE2,  0, GPIO_PFCE2_PFCE23_SHIFT,   GPIO_PFCE2_PFCE23);
    RZA_IO_RegWrite_16(&GPIO.PFC2,   0, GPIO_PFC2_PFC23_SHIFT,     GPIO_PFC2_PFC23);
    RZA_IO_RegWrite_16(&GPIO.PMC2,   1, GPIO_PMC2_PMC23_SHIFT,     GPIO_PMC2_PMC23);
    RZA_IO_RegWrite_16(&GPIO.PIPC2,  1, GPIO_PIPC2_PIPC23_SHIFT,   GPIO_PIPC2_PIPC23);

    /* ---- P2_6 : RD/WR# ---- */
    /* Port mode : Multiplex mode                     */
    /* Port function setting : 1st multiplex function */
    /* I/O control mode : Peripheral function         */
    RZA_IO_RegWrite_16(&GPIO.PFCAE2, 0, GPIO_PFCAE2_PFCAE26_SHIFT, GPIO_PFCAE2_PFCAE26);
    RZA_IO_RegWrite_16(&GPIO.PFCE2,  0, GPIO_PFCE2_PFCE26_SHIFT,   GPIO_PFCE2_PFCE26);
    RZA_IO_RegWrite_16(&GPIO.PFC2,   0, GPIO_PFC2_PFC26_SHIFT,     GPIO_PFC2_PFC26);
    RZA_IO_RegWrite_16(&GPIO.PMC2,   1, GPIO_PMC2_PMC26_SHIFT,     GPIO_PMC2_PMC26);
    RZA_IO_RegWrite_16(&GPIO.PIPC2,  1, GPIO_PIPC2_PIPC26_SHIFT,   GPIO_PIPC2_PIPC26);

    /* ---- P2_5 : DQMLU# ---- */
    /* Port mode : Multiplex mode                     */
    /* Port function setting : 1st multiplex function */
    /* I/O control mode : Peripheral function         */
    RZA_IO_RegWrite_16(&GPIO.PFCAE2, 0, GPIO_PFCAE2_PFCAE25_SHIFT, GPIO_PFCAE2_PFCAE25);
    RZA_IO_RegWrite_16(&GPIO.PFCE2,  0, GPIO_PFCE2_PFCE25_SHIFT,   GPIO_PFCE2_PFCE25);
    RZA_IO_RegWrite_16(&GPIO.PFC2,   0, GPIO_PFC2_PFC25_SHIFT,     GPIO_PFC2_PFC25);
    RZA_IO_RegWrite_16(&GPIO.PMC2,   1, GPIO_PMC2_PMC25_SHIFT,     GPIO_PMC2_PMC25);
    RZA_IO_RegWrite_16(&GPIO.PIPC2,  1, GPIO_PIPC2_PIPC25_SHIFT,   GPIO_PIPC2_PIPC25);

    /* ---- P2_4 : DQMLL# ---- */
    /* Port mode : Multiplex mode                     */
    /* Port function setting : 1st multiplex function */
    /* I/O control mode : Peripheral function         */
    RZA_IO_RegWrite_16(&GPIO.PFCAE2, 0, GPIO_PFCAE2_PFCAE24_SHIFT, GPIO_PFCAE2_PFCAE24);
    RZA_IO_RegWrite_16(&GPIO.PFCE2,  0, GPIO_PFCE2_PFCE24_SHIFT,   GPIO_PFCE2_PFCE24);
    RZA_IO_RegWrite_16(&GPIO.PFC2,   0, GPIO_PFC2_PFC24_SHIFT,     GPIO_PFC2_PFC24);
    RZA_IO_RegWrite_16(&GPIO.PMC2,   1, GPIO_PMC2_PMC24_SHIFT,     GPIO_PMC2_PMC24);
    RZA_IO_RegWrite_16(&GPIO.PIPC2,  1, GPIO_PIPC2_PIPC24_SHIFT,   GPIO_PIPC2_PIPC24);

    /* ---- P2_0 : CS3 ---- */
    /* Port mode : Multiplex mode                     */
    /* Port function setting : 1st multiplex function */
    /* I/O control mode : Peripheral function         */
    RZA_IO_RegWrite_16(&GPIO.PFCAE2, 0, GPIO_PFCAE2_PFCAE20_SHIFT, GPIO_PFCAE2_PFCAE20);
    RZA_IO_RegWrite_16(&GPIO.PFCE2,  0, GPIO_PFCE2_PFCE20_SHIFT,   GPIO_PFCE2_PFCE20);
    RZA_IO_RegWrite_16(&GPIO.PFC2,   0, GPIO_PFC2_PFC20_SHIFT,     GPIO_PFC2_PFC20);
    RZA_IO_RegWrite_16(&GPIO.PMC2,   1, GPIO_PMC2_PMC20_SHIFT,     GPIO_PMC2_PMC20);
    RZA_IO_RegWrite_16(&GPIO.PIPC2,  1, GPIO_PIPC2_PIPC20_SHIFT,   GPIO_PIPC2_PIPC20);
}

/* End of File */

