/*!
* @file     Dio_Reg.h
*
* @version  1.0.0
*
* @brief    The header of the register definitions of the DIO module.
*
* @details  This header file includes the register definitions of the DIO module.
*
* @attention
*
* Project Name      : AUTOSAR MCAL
*
* Platform          : Arm
*
* Autosar Standard  : Classic Platform 4.4.0
*
* Compiled Version  : G32A10xx_MCAL_1_0_0_15-Nov-25
*
* Copyright (C) 2026 Geehy Semiconductor
*
* You may not use this file except in compliance with the
* GEEHY COPYRIGHT NOTICE (Geehy Semiconductor Software License Agreement).
*
* The program is only for reference, which is distributed in the hope
* that it will be usefull and instructional for customers to develop
* their software. Unless required by applicable law or agreed to in
* writing, the program is distributed on an "AS IS" BASIS, WITHOUT
* ANY WARRANTY OR CONDITIONS OF ANY KIND, either express or implied.
* See the Geehy Semiconductor Software License Agreement for the governing permissions
* and limitations under the License.
*/


#ifndef DIO_REG_H
#define DIO_REG_H

#ifdef __cplusplus
extern "C"{
#endif  /* ifdef __cplusplus */

#include "Reg_eSys.h"

/** @addtogroup G32A10xx_StdPeriphDriver
  @{
*/

/** @defgroup DIO_Driver
  @{
*/

/** @defgroup DIO_Macros
  @{
*/
/***********************************************************************************************************
                                    VENDOR ID & AUTOSAR VERSION INFO
***********************************************************************************************************/
/** Vendor ID (vendorId) of the dedicated implementation of this module according to the AUTOSAR vendor list. */
#define DIO_REG_H_VENDOR_ID                               0x00C1U
/** Major version number of AUTOSAR release on which the appropriate implementation is based on. */  
#define DIO_REG_H_AR_RELEASE_MAJOR_VERSION                0x04U
/** Minor version number of AUTOSAR release on which the appropriate implementation is based on. */
#define DIO_REG_H_AR_RELEASE_MINOR_VERSION                0x04U
/** Revision version number of AUTOSAR release on which the appropriate implementation is based on. */
#define DIO_REG_H_AR_RELEASE_REVISION_VERSION             0x00U
/** Major version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define DIO_REG_H_SW_MAJOR_VERSION                        0x01U
/** Minor version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define DIO_REG_H_SW_MINOR_VERSION                        0x00U
/** Patch level version number of the vendor specific implementation of the module. The numbering is vendor specific. */
#define DIO_REG_H_SW_PATCH_VERSION                        0x00U

/**@} end of group DIO_Macros */
/***********************************************************************************************************
                                      VERSION INFOMATION VERIFICATION
***********************************************************************************************************/
#ifdef ENABLE_INTERMODULE_MCAL_CHECK
    /* Make sure the AUTOSAR major version number is the same between Dio_Reg.h and Reg_eSys.h */
    #if (DIO_REG_H_AR_RELEASE_MAJOR_VERSION != REG_ESYS_H_AR_RELEASE_MAJOR_VERSION)
        #error "AUTOSAR Major Version Number mismatch between Dio_Reg.h and Reg_eSys.h"
    #endif
    /* Make sure the AUTOSAR minor version number is the same between Dio_Reg.h and Reg_eSys.h */
    #if (DIO_REG_H_AR_RELEASE_MINOR_VERSION != REG_ESYS_H_AR_RELEASE_MINOR_VERSION)
        #error "AUTOSAR Minor Version Number mismatch between Dio_Reg.h and Reg_eSys.h"
    #endif
#endif

/***********************************************************************************************************
                                             GLOBAL VARIABLE
***********************************************************************************************************/
/** @defgroup DIO_Variable
  @{
*/
#define DIO_START_SEC_CONST_UNSPECIFIED
#include "Dio_MemMap.h"
  
/** The declaration of the DIO base address array  */
extern CONST(uint32, DIO_CONST) DIO_BASEADDR_ARR[6];

#define DIO_STOP_SEC_CONST_UNSPECIFIED
#include "Dio_MemMap.h"

/**@} end of group DIO_Variable */

/** @defgroup DIO_Macros
  @{
*/

#define DIO_CHANNELID_MASKBIT           ((uint8)0x1FU)      
#define DIO_CHANNELID_SHIFTBIT          ((uint8)0x0U) 

#define DIO_PORTID_MASKBIT              ((uint8)0xE0U)      
#define DIO_PORTID_SHIFTBIT             ((uint8)0x05U)

#define GPIO_GET_PORT_ID(channel)       ((uint32)((uint32)(channel)>>DIO_PORTID_SHIFTBIT))

#define GPIO_GET_CHANNEL_ID(channel)    ((uint32)((uint32)(channel)&DIO_CHANNELID_MASKBIT))  

#define  GPIOX_BASE_ADDR(x)             ((uint32)(GPIOA_BASEADDR + ((uint32)(x) * (uint32)0x40U)))

#define PIN_MASK(channel)               ((uint32)((uint32)1<<GPIO_GET_CHANNEL_ID(channel)))
/***********************************************************************************************************
        BIT MASK AND OFFSET FOR REGISTER: GPIOx_IDATA
***********************************************************************************************************/
/** GPIOx_IDATA register address */
/** Note: The value of PORT can be 0, 1, 2, 3, 5. */
#define GPIO_IDATA_REG_ADDR(PORT)        ((uint32)(DIO_BASEADDR_ARR[PORT] + (uint32)0x10U))

#define GPIO_IDATA_MASK                  ((uint32)0x0000FFFFU)
#define GPIO_IDATA_SHIFT                 ((uint8)0U)

/** Note: The value of PIN can be 0 ~ 15. */
#define GPIO_IDATA_PIN_MASK(PIN)         ((uint32)(1U << PIN))

/***********************************************************************************************************
        BIT MASK AND OFFSET FOR REGISTER: GPIOx_ODATA
***********************************************************************************************************/
/** GPIOx_ODATA register address */
/** Note: The value of PORT can be 0, 1, 2, 3, 5. */
#define GPIO_ODATA_REG_ADDR(PORT)        ((uint32)(DIO_BASEADDR_ARR[PORT] + (uint32)0x14U))

#define GPIO_ODATA_MASK                  ((uint32)0x0000FFFFU)
#define GPIO_ODATA_SHIFT                 ((uint8)0U)

/** Note: The value of PIN can be 0 ~ 15. */
#define GPIO_ODATA_SET_PIN_LEVEL(PIN)    ((uint32)(1U << PIN))

/**@} end of group DIO_Macros */

#ifdef __cplusplus
}
#endif  /* __cplusplus */

#endif  /* DIO_REG_H */

/**@} end of group DIO_Driver */
/**@} end of group G32A10xx_StdPeriphDriver */
