ADM/GW/RTD/include/Clock_Ip.h
2024-08-08 10:00:15 +09:00

293 lines
10 KiB
C

/*==================================================================================================
* Project : RTD AUTOSAR 4.4
* Platform : CORTEXM
* Peripheral :
* 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 Clock_Ip.h
* @version 0.9.0
*
* @brief CLOCK IP driver header file.
* @details CLOCK IP driver header file.
*
* @addtogroup CLOCK_DRIVER Clock Ip Driver
* @{
*/
#ifndef CLOCK_IP_H
#define CLOCK_IP_H
#include "Clock_Ip_Types.h"
#include "Clock_Ip_Cfg.h"
#if defined(__cplusplus)
extern "C"{
#endif
/*==================================================================================================
SOURCE FILE VERSION INFORMATION
==================================================================================================*/
#define CLOCK_IP_VENDOR_ID 43
#define CLOCK_IP_AR_RELEASE_MAJOR_VERSION 4
#define CLOCK_IP_AR_RELEASE_MINOR_VERSION 4
#define CLOCK_IP_AR_RELEASE_REVISION_VERSION 0
#define CLOCK_IP_SW_MAJOR_VERSION 0
#define CLOCK_IP_SW_MINOR_VERSION 9
#define CLOCK_IP_SW_PATCH_VERSION 0
/*==================================================================================================
FILE VERSION CHECKS
==================================================================================================*/
/* Check if Clock_Ip.h file and Clock_Ip_Types.h file have same versions */
#if (CLOCK_IP_VENDOR_ID != CLOCK_IP_TYPES_VENDOR_ID)
#error "Clock_Ip.h and Clock_Ip_Types.h have different vendor IDs"
#endif
/* Check if Clock_Ip.h file and Clock_Ip_Types.h file are of the same Autosar version */
#if ((CLOCK_IP_AR_RELEASE_MAJOR_VERSION != CLOCK_IP_TYPES_AR_RELEASE_MAJOR_VERSION) || \
(CLOCK_IP_AR_RELEASE_MINOR_VERSION != CLOCK_IP_TYPES_AR_RELEASE_MINOR_VERSION) || \
(CLOCK_IP_AR_RELEASE_REVISION_VERSION != CLOCK_IP_TYPES_AR_RELEASE_REVISION_VERSION))
#error "AutoSar Version Numbers of Clock_Ip.h and Clock_Ip_Types.h are different"
#endif
/* Check if Clock_Ip.h file and Clock_Ip_Types.h file are of the same Software version */
#if ((CLOCK_IP_SW_MAJOR_VERSION != CLOCK_IP_TYPES_SW_MAJOR_VERSION) || \
(CLOCK_IP_SW_MINOR_VERSION != CLOCK_IP_TYPES_SW_MINOR_VERSION) || \
(CLOCK_IP_SW_PATCH_VERSION != CLOCK_IP_TYPES_SW_PATCH_VERSION))
#error "Software Version Numbers of Clock_Ip.h and Clock_Ip_Types.h are different"
#endif
/* Check if Clock_Ip.h file and Clock_Ip_Cfg.h file have same versions */
#if (CLOCK_IP_VENDOR_ID != CLOCK_IP_CFG_VENDOR_ID)
#error "Clock_Ip.h and Clock_Ip_Cfg.h have different vendor IDs"
#endif
/* Check if Clock_Ip.h file and Clock_Ip_Cfg.h file are of the same Autosar version */
#if ((CLOCK_IP_AR_RELEASE_MAJOR_VERSION != CLOCK_IP_CFG_AR_RELEASE_MAJOR_VERSION) || \
(CLOCK_IP_AR_RELEASE_MINOR_VERSION != CLOCK_IP_CFG_AR_RELEASE_MINOR_VERSION) || \
(CLOCK_IP_AR_RELEASE_REVISION_VERSION != CLOCK_IP_CFG_AR_RELEASE_REVISION_VERSION))
#error "AutoSar Version Numbers of Clock_Ip.h and Clock_Ip_Cfg.h are different"
#endif
/* Check if Clock_Ip.h file and Clock_Ip_Cfg.h file are of the same Software version */
#if ((CLOCK_IP_SW_MAJOR_VERSION != CLOCK_IP_CFG_SW_MAJOR_VERSION) || \
(CLOCK_IP_SW_MINOR_VERSION != CLOCK_IP_CFG_SW_MINOR_VERSION) || \
(CLOCK_IP_SW_PATCH_VERSION != CLOCK_IP_CFG_SW_PATCH_VERSION))
#error "Software Version Numbers of Clock_Ip.h and Clock_Ip_Cfg.h are different"
#endif
/*******************************************************************************
* GLOBAL FUNCTION PROTOTYPES
******************************************************************************/
/*******************************************************************************
* API
******************************************************************************/
/* Clock start section code */
#define MCU_START_SEC_CODE
#include "Mcu_MemMap.h"
/*!
* @brief Gets the clock frequency for a specific clock name.
*
* This function checks the current clock configurations and then calculates
* the clock frequency for a specific clock name defined in Clock_Ip_NameType.
* Clock modules must be properly configured before using this function.
* See features.h for supported clock names for different chip families.
* The returned value is in Hertz. If frequency is required for a peripheral and the
* module is not clocked, then 0 Hz frequency is returned.
*
* @param[in] clockName Clock names defined in Clock_Ip_NameType
* @return frequency Returned clock frequency value in Hertz
*/
uint32 Clock_Ip_GetClockFrequency(Clock_Ip_NameType clockName);
/*!
* @brief Set clock configuration according to pre-defined structure.
*
* This function sets system to target clock configuration; It sets the
* clock modules registers for clock mode change.
*
* @param[in] config Pointer to configuration structure.
*
* @return void
*
* @note If external clock is used in the target mode, please make sure it is
* enabled, for example, if the external oscillator is used, please setup correctly.
*/
Clock_Ip_StatusType Clock_Ip_Init(Clock_Ip_ClockConfigType const * config);
/*!
* @brief Set the PLL and other MCU specific clock options.
*
* This function initializes the PLL and other MCU specific clock options.
* The clock configuration parameters are provided via the configuration structure.
*
* This function shall start the PLL lock procedure (if PLL
* shall be initialized) and shall return without waiting until the PLL is locked.
*
* @param[in] config Pointer to configuration structure.
*
* @return void
*/
void Clock_Ip_InitClock(Clock_Ip_ClockConfigType const * config);
/*!
* @brief Returns the lock status of the PLL.
*
* This function returns status of the PLL: undefined, unlocked or locked.
* This function returns undefined status if this function is called prior
* to calling of the function Clock_Ip_InitClock
*
* @return Status. Pll lock status
*/
Clock_Ip_PllStatusType Clock_Ip_GetPllStatus(void);
/*!
* @brief Activates the PLL in MCU clock distribution.
*
* This function activates the PLL clock to
* the MCU clock distribution.
*
* This function removes the current clock source
* (for example internal oscillator clock) from MCU clock distribution.
*
* Application layer calls this function after the status of the PLL has been detected as
* locked by the function Clock_Ip_GetPllStatus.
*
* The function Clock_Ip_DistributePll shall return without affecting
* the MCU hardware if the PLL clock has been automatically activated by the MCU
* hardware.
*
* @return void
*/
void Clock_Ip_DistributePll(void);
/*!
* @brief Sends notifications regarding power mode transition
*
* This function sends notifications regarding power mode transition.
* It is called by power driver each time power mode is changed.
*
*
* @param[in] powerMode Power mode.
* @param[in] powerMode Power mode notification.
*
* @return void
*/
void Clock_Ip_PowerModeChangeNotification(power_modes_t powerMode,power_notification_t notification);
/*!
* @brief Install a clock notifications callback
*
* This function installs a callback for
* reporting notifications from clock driver
*
*
* @param[in] Clock_Ip_NotificationsCallbackType notifications callback
*
* @return void
*/
void Clock_Ip_InstallNotificationsCallback(Clock_Ip_NotificationsCallbackType callback);
/*!
* @brief Clears status flags for a monitor clock.
*
* This function clears status flags for a monitor clock.
*
* @param[in] clockName Clock Name.
*
* @return void
*/
void Clock_Ip_ClearClockMonitorStatus(Clock_Ip_NameType clockName);
/*!
* @brief Returns the clock monitor status.
*
* This function returns status of the clock monitor: undefined, lower, higher, in range.
* This function returns undefined status if this function is called when corresponding
* cmu is not enabled.
*
* @return Status. Cmu status
*/
Clock_Ip_CmuStatusType Clock_Ip_GetClockMonitorStatus(Clock_Ip_NameType clockName);
/*!
* @brief Disables a clock monitor.
*
* This function disables a clock monitor.
*
* @param[in] clockName Clock Name.
*
* @return void
*/
void Clock_Ip_DisableClockMonitor(Clock_Ip_NameType clockName);
/*!
* @brief Disables clock for a peripheral.
*
* This function disables clock for a peripheral.
*
* @param[in] clockName Clock Name.
*
* @return void
*/
void Clock_Ip_DisableModuleClock(Clock_Ip_NameType clockName);
/*!
* @brief Enables clock for a peripheral.
*
* This function enables clock for a peripheral.
*
* @param[in] clockName Clock Name.
*
* @return void
*/
void Clock_Ip_EnableModuleClock(Clock_Ip_NameType clockName);
#if (defined(CLOCK_IP_ENABLE_USER_MODE_SUPPORT))
#if (STD_ON == CLOCK_IP_ENABLE_USER_MODE_SUPPORT)
void Clock_Ip_SetUserAccessAllowed(void);
#endif
#endif
/* Clock stop section code */
#define MCU_STOP_SEC_CODE
#include "Mcu_MemMap.h"
#if defined(__cplusplus)
}
#endif /* __cplusplus*/
/*! @}*/
#endif /* CLOCK_IP_H */
/*******************************************************************************
* EOF
******************************************************************************/