/*******************************************************************************
 * 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 2021-2022 Renesas Electronics Corporation All rights reserved.
 *******************************************************************************/

/*******************************************************************************
 * DESCRIPTION   : RPC driver header
 ******************************************************************************/

#ifndef RPC_H__
#define RPC_H__

#include <stdint.h>
#include <rpc_register.h>

/* If user customizes for another vendor's QSPI Flash, set to 1. */
#define USER_ADDED_QSPI         (0U)    /* 0:Disable 1:Enable */

/* The number of Flash vendor */
#if USER_ADDED_QSPI == 0
#define VENDOR_NUM                  (1U)
#endif /* USER_ADDED_QSPI == 0 */
/* Command for S25FS512S */
#define S25FS512S_READ_32BIT_ADDR                   (0x13U) /* read 32bit address */
#define S25FS512S_DDR_QUAD_IO_READ_32BIT_ADDR       (0xEEU) /* DDR quad I/O read 32bit address */

#if USER_ADDED_QSPI == 1
/* User can customize for another vendor's QSPI Flash. */
#define VENDOR_NUM                  (2U)
/* Command for XXXXXXXXX */
#define XXXXXXXXX_READ_32BIT_ADDR                   (0x00U) /* read 32bit address */
#define XXXXXXXXX_DDR_QUAD_IO_READ_32BIT_ADDR       (0x00U) /* DDR quad I/O read 32bit address */
#endif /* USER_ADDED_QSPI == 1 */


typedef struct {
    uint32_t    read_32bit_addr;
    uint32_t    ddr_quad_io_read_32bit_addr;
} st_qspi_cmd_tbl_t;

static const st_qspi_cmd_tbl_t qspi_cmd_tbls[VENDOR_NUM] =
{
    /* Command table for S25FS512S */
    {
        S25FS512S_READ_32BIT_ADDR,                /* read 32bit address */
        S25FS512S_DDR_QUAD_IO_READ_32BIT_ADDR     /* DDR quad I/O read 32bit address */
    },
#if USER_ADDED_QSPI == 1
    /* Command table for XXXXXXXXX */
    /* User can customize for another vendor's QSPI Flash. */
    {
        XXXXXXXXX_READ_32BIT_ADDR,               /* read 32bit address */
        XXXXXXXXX_DDR_QUAD_IO_READ_32BIT_ADDR    /* DDR quad I/O read 32bit address */
    }
#endif /* USER_ADDED_QSPI == 1 */
};


void rpc_init(void);
void rpc_release(void);
void rpc_end_state_check(void);

#if (QSPI_DDR_MODE==1)
void qspi_ddr_transfer_mode(uint32_t command);
#else
void qspi_sdr_transfer_mode(uint32_t command);
#endif

#endif  /* RPC_H__ */
