/**
* @file    Port_Lld.h
*==================================================================================================
*   Project              : YTMicro AUTOSAR 4.4.0 MCAL
*   Platform             : ARM
*   Peripheral           : Port_Lld
*   Dependencies         : none
*
*   Autosar Version      : V4.4.0
*   Autosar Revision     : ASR_REL_4_4_REV_0000
*   SW Version           : V0.8.0
*
*   (c) Copyright 2020-2026 Yuntu Microelectronics co.,ltd.
*   All Rights Reserved.
==================================================================================================*/

#ifndef PORT_LLD_H
#define PORT_LLD_H

#ifdef __cplusplus
extern "C" {
#endif

/*==================================================================================================
 *                                          INCLUDE FILES
==================================================================================================*/
#include "Port_Types.h"
/*==================================================================================================
 *                                  HEADER FILE VERSION INFORMATION
==================================================================================================*/
#define PORT_LLD_VENDOR_ID                      (180)
#define PORT_LLD_AR_RELEASE_MAJOR_VERSION       (4)
#define PORT_LLD_AR_RELEASE_MINOR_VERSION       (4)
#define PORT_LLD_AR_RELEASE_REVISION_VERSION    (0)
#define PORT_LLD_SW_MAJOR_VERSION               (0)
#define PORT_LLD_SW_MINOR_VERSION               (8)
#define PORT_LLD_SW_PATCH_VERSION               (0)

/*==================================================================================================
                                        FILE VERSION CHECKS
==================================================================================================*/
/* Check if source file and PORT configuration header file are of the same vendor */
#if (PORT_LLD_VENDOR_ID != PORT_TYPES_VENDOR_ID)
#error "Port_Lld.h and Port_Types.h have different vendor ids"
#endif

/* Check if source file and PORT configuration header file are of the same Autosar version */
#if ((PORT_LLD_AR_RELEASE_MAJOR_VERSION != PORT_TYPES_AR_RELEASE_MAJOR_VERSION) || \
     (PORT_LLD_AR_RELEASE_MINOR_VERSION != PORT_TYPES_AR_RELEASE_MINOR_VERSION) || \
     (PORT_LLD_AR_RELEASE_REVISION_VERSION != PORT_TYPES_AR_RELEASE_REVISION_VERSION))
#error "AutoSar Version Numbers of Port_Lld.h and Port_Cfg.h are different"
#endif

/* Check if source file and PORT configuration header file are of the same software version */
#if ((PORT_LLD_SW_MAJOR_VERSION != PORT_TYPES_SW_MAJOR_VERSION) || \
     (PORT_LLD_SW_MINOR_VERSION != PORT_TYPES_SW_MINOR_VERSION) || \
     (PORT_LLD_SW_PATCH_VERSION != PORT_TYPES_SW_PATCH_VERSION))
#error "Software Version Numbers of Port_Lld.h and Port_Types.h are different"
#endif
/*==================================================================================================
 *                                        FUNCTION PROTOTYPES
==================================================================================================*/
/**
 * @brief         Low-level driver function to set pin mode configuration
 * @autosar       N/A
 *
 * @details       Service ID: N/A (Internal Function)
 *                Sync/Async: Synchronous
 *                Reentrancy: Reentrant
 *                Available via: Port_Lld.h
 *
 * @param[in] Port: Hardware port identifier
 * @param[in] Pin:  Hardware pin number
 * @param[in] Mode: Pin mode to be set (GPIO or alternate function)
 * @return void
*/
void Port_Lld_SetPinMode(Port_HwPortType Port, Port_HwPinType Pin, Port_PinModeType Mode);

/**
 * @brief         Low-level driver function to set pin direction (input/output)
 * @autosar       N/A
 *
 * @details       Service ID: N/A (Internal Function)
 *                Sync/Async: Synchronous
 *                Reentrancy: Reentrant
 *                Available via: Port_Lld.h
 *
 * @param[in] Port: Hardware port identifier
 * @param[in] Pin:  Hardware pin number
 * @param[in] Direction: Direction to set (PORT_PIN_IN or PORT_PIN_OUT)
 * @return void
*/
void Port_Lld_SetPinDirection(Port_HwPortType Port, Port_HwPinType Pin, Port_PinDirectionType Direction);

/**
 * @brief         Low-level driver function to check if a pin mode is changeable
 * @autosar       N/A
 *
 * @details       Service ID: N/A (Internal Function)
 *                Sync/Async: Synchronous
 *                Reentrancy: Reentrant
 *                Available via: Port_Lld.h
 *
 * @param[in] ConfigPtr: Pointer to port configuration structure
 * @param[in] Port: Hardware port identifier
 * @param[in] Pin:  Hardware pin number
 * @return boolean TRUE if mode is changeable, FALSE otherwise
*/
boolean Port_Lld_IsPinModeChangeable(const Port_ConfigType *ConfigPtr, Port_HwPortType Port, Port_HwPinType Pin);

/**
 * @brief         Low-level driver function to check if a pin direction is changeable
 * @autosar       N/A
 *
 * @details       Service ID: N/A (Internal Function)
 *                Sync/Async: Synchronous
 *                Reentrancy: Reentrant
 *                Available via: Port_Lld.h
 *
 * @param[in] ConfigPtr: Pointer to port configuration structure
 * @param[in] Port: Hardware port identifier
 * @param[in] Pin:  Hardware pin number
 * @return boolean TRUE if direction is changeable, FALSE otherwise
*/
boolean Port_Lld_IsPinDireChangeable(const Port_ConfigType *ConfigPtr, Port_HwPortType Port, Port_HwPinType Pin);

/**
 * @brief         Low-level driver function to refresh port pin directions according to configuration
 * @autosar       N/A
 *
 * @details       Service ID: N/A (Internal Function)
 *                Sync/Async: Synchronous
 *                Reentrancy: Reentrant
 *                Available via: Port_Lld.h
 *
 * @param[in] ConfigPtr: Pointer to port configuration structure
 * @return void
*/
void Port_Lld_RefreshPortDirection(const Port_ConfigType *ConfigPtr);

/**
 * @brief         Low-level driver function to initialize all port pins according to configuration
 * @autosar       N/A
 *
 * @details       Service ID: N/A (Internal Function)
 *                Sync/Async: Synchronous
 *                Reentrancy: Non Reentrant
 *                Available via: Port_Lld.h
 *
 * @param[in] ConfigPtr: Pointer to port configuration structure
 * @return void
*/
void Port_Lld_Init(const Port_ConfigType *ConfigPtr);



#ifdef __cplusplus
}
#endif

#endif /* End of file Port_Lld.h */

