/*==================================================================================================
*   Project              : RTD AUTOSAR 4.4
*   Platform             : CORTEXM
*   Peripheral           : DMA,CACHE,TRGMUX,LCU,EMIOS,FLEXIO
*   Dependencies         : none
*
*   Autosar Version      : 4.4.0
*   Autosar Revision     : ASR_REL_4_4_REV_0000
*   Autosar Conf.Variant :
*   SW Version           : 0.9.0
*   Build Version        : S32K3_RTD_0_9_0__ASR_REL_4_4_REV_0000_20210326
*
*   (c) Copyright 2020 - 2021 NXP Semiconductors
*   All Rights Reserved.
*
*   NXP Confidential. This software is owned or controlled by NXP 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.
==================================================================================================*/

/**
 *   @file       Emios_Mcl_Ip_Types.h
 *
 *   @version    0.9.0
 *
 *   @brief      AUTOSAR Mcl - Emios Common driver header file.
 *
 *   @addtogroup EMIOS_IP_DRIVER EMIOS IP Driver
 *   @{
 */

#ifndef EMIOS_MCL_IP_TYPES_H
#define EMIOS_MCL_IP_TYPES_H

#ifdef __cplusplus
extern "C"{
#endif

/*==================================================================================================
                                         INCLUDE FILES
 1) system and project includes
 2) needed interfaces from external units
 3) internal and external interfaces from this unit
==================================================================================================*/
#include "StandardTypes.h"
#include "Emios_Mcl_Ip_Cfg_Defines.h"

/*==================================================================================================
                               SOURCE FILE VERSION INFORMATION
==================================================================================================*/

/*==================================================================================================
                                      FILE VERSION CHECKS
==================================================================================================*/
/* TODO */

/*==================================================================================================
                                           CONSTANTS
==================================================================================================*/

/*==================================================================================================
                                 GLOBAL VARIABLE DECLARATIONS
==================================================================================================*/

/*==================================================================================================
                                       DEFINES AND MACROS
==================================================================================================*/
/** @brief Channel mask maxim value. */
#define EMIOS_CHANNELMASK_MAXVAL             0x00FFFFFFU

/*==================================================================================================
                                             ENUMS
==================================================================================================*/

/*==================================================================================================
                                 STRUCTURES AND OTHER TYPEDEFS
==================================================================================================*/
typedef enum
{
    EMIOS_IP_COMMON_STATUS_SUCCESS    = E_OK,
    EMIOS_IP_COMMON_STATUS_FAIL       = E_NOT_OK,
#if (EMIOS_IP_MULTICORE_IS_AVAILABLE == STD_ON)
    EMIOS_IP_COMMON_STATUS_WRONG_CORE = 2U
#endif
} Emios_Ip_CommonStatusType;

typedef enum
{
    EMIOS_IP_NO_MASTER_MODE      = 0U,
    EMIOS_IP_MC_UP_COUNTER_START = 16U,
    EMIOS_IP_MC_UP_COUNTER_END   = 18U,
    EMIOS_IP_MC_UP_DOWN_COUNTER  = 20U,
    EMIOS_IP_MCB_UP_COUNTER      = 80U,
    EMIOS_IP_MCB_UP_DOWN_COUNTER = 84U
} Emios_Ip_MasterBusModeType;

typedef struct
{
    const uint8                       hwChannel;
    const Emios_Ip_MasterBusModeType  masterMode;
    const uint32                      defaultPeriod;
    const uint32                      offsetStartValue;
    const uint8                       masterBusPrescaler;
    const uint8                       masterBusAltPrescaler;
    const boolean                     interruptEnable;
    const boolean                     allowDebugMode;
} Emios_Ip_MasterBusConfigType;

typedef struct
{
    const boolean   allowDebugMode;         /**< Allow all channel in EMIOS group can enter debug mode */
    const uint8     clkDivVal;              /**< Select the clock divider value for the global prescaler in range (1-256) */
    const boolean   enableGlobalTimeBase;   /**< Enable global timebase or disable   */
} Emios_Ip_GlobalConfigType;

/** @brief EMIOS IP configuration structure. */
typedef struct
{
    const uint8                         channelsNumber;       /**< @brief Number of master buses used. */
#if (STD_ON == EMIOS_IP_MULTICORE_IS_AVAILABLE)
    const uint8                         instanceCoreNumber;   /**< @brief Core number where EMIOS instance is used. */
#endif
    const Emios_Ip_GlobalConfigType     *emiosGlobalConfig;   /**< @brief Pointer to EMIOS configuration. */
    const Emios_Ip_MasterBusConfigType (*masterBusConfig)[];  /**< @brief Pointer to an array with all master buses used. */
} Emios_Mcl_Ip_ConfigType;

/** @brief Store EMIOS channel state. */
typedef struct 
{
    Emios_Ip_MasterBusModeType counterMode;      /* Current mode of the configured master bus. */
    boolean                    channelInitState; /* Store TRUE channel is initialized, FALSE otherwise. */
} Emios_Ip_ChStateType;


/** @brief Store EMIOS instance state. */
typedef struct 
{
    boolean instanceInitState; /* Store TRUE channel is initialized, FALSE otherwise. */
#if (EMIOS_IP_MULTICORE_IS_AVAILABLE == STD_ON)
    uint8   runCore;           /* Store the core on which current EMIOS instance is running. */
#endif
} Emios_Ip_InstStateType;

/*==================================================================================================
                                     FUNCTION PROTOTYPES
==================================================================================================*/

#ifdef __cplusplus
}
#endif

/** @} */

#endif /* EMIOS_MCL_IP_TYPES_H */
