/*==================================================================================================
*   Platform             : CORTEXM
*   Peripheral           :
*   Dependencies         : none
*
*   Autosar Version      : 4.4.0
*   Autosar Revision     : ASR_REL_4_4_REV_0000
*   Autosar Conf.Variant :
*   SW Version           : 0.8.0
*
*   (c) Copyright 2020-2026 Yuntu Microelectronics co.,ltd.
*   All Rights Reserved.
*
*   YUNTU Confidential. This software is owned or controlled by YUNTU and may only be
*   used strictly in accordance with the applicable license terms. By expressly
*   accepting such terms or by downloading, installing, activating and/or otherwise
*   using the software, you are agreeing that you have read, and that you agree to
*   comply with and are bound by, such license terms. If you do not agree to be
*   bound by the applicable license terms, then you may not retain, install,
*   activate or otherwise use the software.
==================================================================================================*/

#ifndef PLATFORM_H_
#define PLATFORM_H_

/**
 *   @file
 *
 *   @addtogroup Platform
 *   @{
 */

/*==================================================================================================
*                                        INCLUDE FILES
==================================================================================================*/

#include "Platform_Cfg.h"
#if defined (CPU_YTM32B1ME0) || defined (CPU_YTM32B1MD1) || defined (CPU_YTM32B1MD2) || defined (CPU_YTM32B1ME1)
#include "YTM32B1Mx_CM33_DSP_FP.h"
#elif defined (CPU_YTM32B1HA0)
#include "YTM32B1Hx_CM7_DSP_FP.h"
#elif defined (CPU_YTM32B1MC0)
#include "YTM32B1Mx_CM33.h"
#else
#error "No valid CPU defined!"
#endif

/*==================================================================================================
*                              SOURCE FILE VERSION INFORMATION
==================================================================================================*/
#define PLATFORM_MAIN_VENDOR_ID                     (180)
#define PLATFORM_MAIN_MODULE_ID                     (255)
#define PLATFORM_MAIN_AR_RELEASE_MAJOR_VERSION      (4)
#define PLATFORM_MAIN_AR_RELEASE_MINOR_VERSION      (4)
#define PLATFORM_MAIN_AR_RELEASE_REVISION_VERSION   (0)
#define PLATFORM_MAIN_SW_MAJOR_VERSION              (0)
#define PLATFORM_MAIN_SW_MINOR_VERSION              (8)
#define PLATFORM_MAIN_SW_PATCH_VERSION              (0)

/*==================================================================================================
*                                     FILE VERSION CHECKS
==================================================================================================*/
/* Check if current file and Platform_Cfg header file are of the same vendor */
#if (PLATFORM_MAIN_VENDOR_ID != PLATFORM_MAIN_CFG_VENDOR_ID)
#error "Platform.h and Platform_Cfg.h have different vendor ids"
#endif
/* Check if current file and Platform_Cfg header file are of the same Autosar version */
#if ((PLATFORM_MAIN_AR_RELEASE_MAJOR_VERSION    != PLATFORM_MAIN_CFG_AR_RELEASE_MAJOR_VERSION) || \
     (PLATFORM_MAIN_AR_RELEASE_MINOR_VERSION    != PLATFORM_MAIN_CFG_AR_RELEASE_MINOR_VERSION) || \
     (PLATFORM_MAIN_AR_RELEASE_REVISION_VERSION != PLATFORM_MAIN_CFG_AR_RELEASE_REVISION_VERSION) \
    )
#error "AutoSar Version Numbers of Platform.h and Platform_Cfg.h are different"
#endif
/* Check if current file and Platform_Cfg header file are of the same Software version */
#if ((PLATFORM_MAIN_SW_MAJOR_VERSION != PLATFORM_MAIN_CFG_SW_MAJOR_VERSION) || \
     (PLATFORM_MAIN_SW_MINOR_VERSION != PLATFORM_MAIN_CFG_SW_MINOR_VERSION) || \
     (PLATFORM_MAIN_SW_PATCH_VERSION != PLATFORM_MAIN_CFG_SW_PATCH_VERSION) \
    )
#error "Software Version Numbers of Platform.h and Platform_Cfg.h are different"
#endif
/*==================================================================================================
*                                      FUNCTION PROTOTYPES
==================================================================================================*/

#if defined(__cplusplus)
extern "C" {
#endif /* __cplusplus*/


/**
 * @brief         Initializes the platform settings based on user configuration, including interrupts and platform-specific features.
 * @autosar       N/A
 *
 * @details       Service ID: 0x20
 *                Sync/Async: Synchronous
 *                Reentrancy: Non Reentrant
 *                Available via: Platform.h
 *
 * @param[in] Config: Pointer to platform configuration structure.
 * @return void
*/
void Platform_Init(const Platform_ConfigType *Config);

/**
 * @brief         Configures (enables/disables) an interrupt request.
 * @autosar       N/A
 *
 * @details       Service ID: 0x21
 *                Sync/Async: Synchronous
 *                Reentrancy: Non Reentrant
 *                Available via: Platform.h
 *
 * @param[in] IrqNumber: Interrupt to be configured.
 * @param[in] Enable: TRUE - enable interrupt, FALSE - disable interrupt.
 * @return Std_ReturnType E_OK/E_NOT_OK; specific errors are reported through DET.
*/
Std_ReturnType Platform_SetIrq(IRQn_Type IrqNumber, boolean Enable);

/**
 * @brief         Configures the priority of an interrupt request.
 * @autosar       N/A
 *
 * @details       Service ID: 0x22
 *                Sync/Async: Synchronous
 *                Reentrancy: Non Reentrant
 *                Available via: Platform.h
 *
 * @param[in] IrqNumber: Interrupt number for which priority is configured.
 * @param[in] Priority: Desired priority of the interrupt.
 * @return Std_ReturnType E_OK/E_NOT_OK; specific errors are reported through DET.
*/
Std_ReturnType Platform_SetIrqPriority(IRQn_Type IrqNumber, uint8 Priority);

/**
 * @brief         Returns the priority of an interrupt request. Retrieves the current priority of the selected interrupt.
 * @autosar       N/A
 *
 * @details       Service ID: 0x23
 *                Sync/Async: Synchronous
 *                Reentrancy: Non Reentrant
 *                Available via: Platform.h
 *
 * @param[in] IrqNumber: Interrupt number for which priority is returned.
 * @param[out] Priority: Output parameter storing the priority of the interrupt.
 * @return Std_ReturnType E_OK/E_NOT_OK; specific errors are reported through DET.
*/
Std_ReturnType Platform_GetIrqPriority(IRQn_Type IrqNumber, uint8 *Priority);

/**
 * @brief         Installs a new handler for an interrupt request. Replaces the current interrupt handler for the selected interrupt with the new function provided. The address of the old handler can be optionally stored.
 * @autosar       SWS_Platform_00026
 *
 * @details       Service ID: 0x24
 *                Sync/Async: Synchronous
 *                Reentrancy: Non Reentrant
 *                Available via: Platform.h
 *
 * @param[in] IrqNumber: Interrupt number for which handler is installed.
 * @param[in] NewHandler: Function pointer for the new handler.
 * @param[out] OldHandler: Function pointer that will store the address of the old handler. This parameter can be passed as NULL if not needed.
 * @return Std_ReturnType E_OK/E_NOT_OK; specific errors are reported through DET.
*/
Std_ReturnType Platform_InstallIrqHandler(IRQn_Type IrqNumber, const Platform_IrqHandlerType NewHandler, Platform_IrqHandlerType *const OldHandler);


#if (PLATFORM_INT_MONITOR == STD_ON)

/**
 * @brief         Configures (enables/disables) the interrupt monitor. Enables/disables the interrupt monitoring feature.
 * @autosar       N/A
 *
 * @details       Service ID: 0x25
 *                Sync/Async: Synchronous
 *                Reentrancy: Reentrant
 *                Available via: Platform.h
 *
 * @param[in] Enable: TRUE - enable interrupt monitoring, FALSE - disable interrupt monitoring.
 * @return void
*/
void Platform_SetIrqMonitor(boolean Enable);

/**
 * @brief         Acknowledges a monitored interrupt has been served. Confirms that a monitored interrupt has been served.
 * @autosar       N/A
 *
 * @details       Service ID: 0x26
 *                Sync/Async: Synchronous
 *                Reentrancy: Reentrant
 *                Available via: Platform.h
 *
 * @param[in] IrqNumber: Interrupt number to be acknowledged.
 * @return void
*/
void Platform_AckIrq(IRQn_Type IrqNumber);

/**
 * @brief         Selects an interrupt to monitor. Selects which interrupt is monitored on which interrupt monitor.
 * @autosar       N/A
 *
 * @details       Service ID: 0x27
 *                Sync/Async: Synchronous
 *                Reentrancy: Reentrant
 *                Available via: Platform.h
 *
 * @param[in] Channel: Logical channel of interrupt monitor used.
 * @param[in] IrqNumber: The interrupt vector to be monitored.
 * @return void
*/
void Platform_SelectMonitoredIrq(uint8 Channel, IRQn_Type IrqNumber);

/**
 * @brief         Sets the latency for a monitored interrupt. Sets the accepted latency for the monitored interrupt.
 * @autosar       N/A
 *
 * @details       Service ID: 0x28
 *                Sync/Async: Synchronous
 *                Reentrancy: Reentrant
 *                Available via: Platform.h
 *
 * @param[in] Channel: Logical channel of interrupt monitor used.
 * @param[in] Latency: The accepted latency for the monitored interrupt.
 * @return void
*/
void Platform_SetMonitoredIrqLatency(uint8 Channel, uint32 Latency);

/**
 * @brief         Resets the timer for an interrupt monitor. Resets the timer for the interrupt monitor.
 * @autosar       N/A
 *
 * @details       Service ID: 0x29
 *                Sync/Async: Synchronous
 *                Reentrancy: Reentrant
 *                Available via: Platform.h
 *
 * @param[in] Channel: Logical channel of interrupt monitor used.
 * @return void
*/
void Platform_ResetIrqMonitorTimer(uint8 Channel);

/**
 * @brief         Retrieves the status of an interrupt monitor. Returns whether the accepted latency for the monitored IRQs has been exceeded.
 * @autosar       N/A
 *
 * @details       Service ID: 0x2A
 *                Sync/Async: Synchronous
 *                Reentrancy: Reentrant
 *                Available via: Platform.h
 *
 * @param[in] Channel: Logical channel of interrupt monitor used.
 * @param[out] LatencyExceeded: Output status parameter: TRUE - latency exceeded, FALSE - latency not exceeded.
 * @return Std_ReturnType E_OK/E_NOT_OK; specific errors are reported through DET.
*/
Std_ReturnType Platform_GetIrqMonitorStatus(uint8 Channel, boolean *LatencyExceeded);
#endif


#if (PLATFORM_VERSION_INFO_API == STD_ON)
/**
 * @brief            Returns the version information of this module.
 * @details          Service ID: 0x2B
 *                   Sync/Async: Synchronous
 *                   Reentrancy: Reentrant
 *                   Available via: Platform.h
 *
 * @param[out]       versioninfo Pointer to where to store version information of this module
 * @return           void
 */
void Platform_GetVersionInfo(Std_VersionInfoType *versioninfo);
#endif /* PLATFORM_VERSION_INFO_API == STD_ON */



#if defined(__cplusplus)
}
#endif /* __cplusplus*/

#endif /* PLATFORM_H_ */

/** @} */

