/*
 * Copyright (c) 2022, Shenzhen CVA Innovation CO.,LTD
 * All rights reserved.
 *
 * Shenzhen CVA Innovation CO.,LTD (CVA chip) is supplying this file for use
 * exclusively with CVA's microcontroller products. This file can be freely
 * distributed within development tools that are supporting such microcontroller
 * products.
 *
 * THIS SOFTWARE IS PROVIDED "AS IS".  NO WARRANTIES, WHETHER EXPRESS, IMPLIED
 * OR STATUTORY, INCLUDING, BUT NOT LIMITED TO, IMPLIED WARRANTIES OF
 * MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE APPLY TO THIS SOFTWARE.
 * CVA SHALL NOT, IN ANY CIRCUMSTANCES, BE LIABLE FOR SPECIAL, INCIDENTAL,
 * OR CONSEQUENTIAL DAMAGES, FOR ANY REASON WHATSOEVER.
 */

#ifndef _PMC_REG_H_
#define _PMC_REG_H_

/*! \brief Contains public interface to various functions related
 *         to the PMC Registers
 */

/*******************************************************************************
 * the includes
 ******************************************************************************/

#include <stdint.h>

#ifdef __cplusplus
extern "C" {
#endif

/*******************************************************************************
 * the defines
 ******************************************************************************/

/* GLB_CTRL Bit Fields */
#define PMC_GLB_CTRL_CPU_RETION_EN_MASK          (0x20u)
#define PMC_GLB_CTRL_CPU_RETION_EN_SHIFT         (5u)
#define PMC_GLB_CTRL_CPU_RETION_EN_WIDTH         (1u)
#define PMC_GLB_CTRL_STOP_EN_MASK                (0x04u)
#define PMC_GLB_CTRL_STOP_EN_SHIFT               (2u)
#define PMC_GLB_CTRL_STOP_EN_WIDTH               (1u)
#define PMC_GLB_CTRL_STDBY_EN_MASK               (0x02u)
#define PMC_GLB_CTRL_STDBY_EN_SHIFT              (1u)
#define PMC_GLB_CTRL_STDBY_EN_WIDTH              (1u)

/* DAINTF_CTRL Bit Fields */
#define PMC_DAINTF_CTRL_EN_FLDO_VDET_MASK        (0x80000u)
#define PMC_DAINTF_CTRL_EN_FLDO_VDET_SHIFT       (19u)
#define PMC_DAINTF_CTRL_EN_FLDO_VDET_WIDTH       (1u)
#define PMC_DAINTF_CTRL_SEL_LVW_MASK             (0xC000u)
#define PMC_DAINTF_CTRL_SEL_LVW_SHIFT            (14u)
#define PMC_DAINTF_CTRL_SEL_LVW_WIDTH            (2u)
#define PMC_DAINTF_CTRL_EN_LVW_MASK              (0x2000u)
#define PMC_DAINTF_CTRL_EN_LVW_SHIFT             (13u)
#define PMC_DAINTF_CTRL_EN_LVW_WIDTH             (1u)
#define PMC_DAINTF_CTRL_EN_LVD_MASK              (0x1000u)
#define PMC_DAINTF_CTRL_EN_LVD_SHIFT             (12u)
#define PMC_DAINTF_CTRL_EN_LVD_WIDTH             (1u)
#define PMC_DAINTF_CTRL_OTP_EN_MASK              (0x80u)
#define PMC_DAINTF_CTRL_OTP_EN_SHIFT             (7u)
#define PMC_DAINTF_CTRL_OTP_EN_WIDTH             (1u)

/* WAKUP_FLG Bit Fields */
#define PMC_WAKUP_FLG_CMP_WAKUP_EVT_FLG_MASK     (0x400u)
#define PMC_WAKUP_FLG_CMP_WAKUP_EVT_FLG_SHIFT    (10u)
#define PMC_WAKUP_FLG_CMP_WAKUP_EVT_FLG_WIDTH    (1u)
#define PMC_WAKUP_FLG_LPTMR_WAKUP_EVT_FLG_MASK   (0x200u)
#define PMC_WAKUP_FLG_LPTMR_WAKUP_EVT_FLG_SHIFT  (9u)
#define PMC_WAKUP_FLG_LPTMR_WAKUP_EVT_FLG_WIDTH  (1u)
#define PMC_WAKUP_FLG_LPIT_WAKUP_EVT_FLG_MASK    (0x100u)
#define PMC_WAKUP_FLG_LPIT_WAKUP_EVT_FLG_SHIFT   (8u)
#define PMC_WAKUP_FLG_LPIT_WAKUP_EVT_FLG_WIDTH   (1u)
#define PMC_WAKUP_FLG_RTC_WAKUP_EVT_FLG_MASK     (0x40u)
#define PMC_WAKUP_FLG_RTC_WAKUP_EVT_FLG_SHIFT    (6u)
#define PMC_WAKUP_FLG_RTC_WAKUP_EVT_FLG_WIDTH    (1u)
#define PMC_WAKUP_FLG_EXTRST_WAKUP_EVT_FLG_MASK  (0x20u)
#define PMC_WAKUP_FLG_EXTRST_WAKUP_EVT_FLG_SHIFT (5u)
#define PMC_WAKUP_FLG_EXTRST_WAKUP_EVT_FLG_WIDTH (1u)
#define PMC_WAKUP_FLG_PORTE_WAKUP_EVT_FLG_MASK   (0x10u)
#define PMC_WAKUP_FLG_PORTE_WAKUP_EVT_FLG_SHIFT  (4u)
#define PMC_WAKUP_FLG_PORTE_WAKUP_EVT_FLG_WIDTH  (1u)
#define PMC_WAKUP_FLG_PORTD_WAKUP_EVT_FLG_MASK   (0x08u)
#define PMC_WAKUP_FLG_PORTD_WAKUP_EVT_FLG_SHIFT  (3u)
#define PMC_WAKUP_FLG_PORTD_WAKUP_EVT_FLG_WIDTH  (1u)
#define PMC_WAKUP_FLG_PORTC_WAKUP_EVT_FLG_MASK   (0x04u)
#define PMC_WAKUP_FLG_PORTC_WAKUP_EVT_FLG_SHIFT  (2u)
#define PMC_WAKUP_FLG_PORTC_WAKUP_EVT_FLG_WIDTH  (1u)
#define PMC_WAKUP_FLG_PORTB_WAKUP_EVT_FLG_MASK   (0x02u)
#define PMC_WAKUP_FLG_PORTB_WAKUP_EVT_FLG_SHIFT  (1u)
#define PMC_WAKUP_FLG_PORTB_WAKUP_EVT_FLG_WIDTH  (1u)
#define PMC_WAKUP_FLG_PORTA_WAKUP_EVT_FLG_MASK   (0x01u)
#define PMC_WAKUP_FLG_PORTA_WAKUP_EVT_FLG_SHIFT  (0u)
#define PMC_WAKUP_FLG_PORTA_WAKUP_EVT_FLG_WIDTH  (1u)

/* STATUS Bit Fields */
#define PMC_STATUS_RUN_MODE_MASK                 (0x20u)
#define PMC_STATUS_RUN_MODE_SHIFT                (5u)
#define PMC_STATUS_RUN_MODE_WIDTH                (1u)
#define PMC_STATUS_STDBY_ABORT_STS_MASK          (0x10u)
#define PMC_STATUS_STDBY_ABORT_STS_SHIFT         (4u)
#define PMC_STATUS_STDBY_ABORT_STS_WIDTH         (1u)
#define PMC_STATUS_PAD_KEEP_MASK                 (0x02u)
#define PMC_STATUS_PAD_KEEP_SHIFT                (1u)
#define PMC_STATUS_PAD_KEEP_WIDTH                (1u)
#define PMC_STATUS_LOCK_MASK                     (0x01u)
#define PMC_STATUS_LOCK_SHIFT                    (0u)
#define PMC_STATUS_LOCK_WIDTH                    (1u)

/*******************************************************************************
 * the typedefs
 ******************************************************************************/

/*! \brief The definition of PMC registers
 */
typedef struct _PmcRegType_
{
    volatile uint32_t GLB_CTRL;      /*!< wakeup source regsiter, offset: 0x0 */
    uint32_t          RESERVED0[2];  /*!< Reserverd block, offset: 0x04 */
    volatile uint32_t DAINTF_CTRL;   /*!< digital to analog interface control signal register, offset: 0xC */
    uint32_t          RESERVED1[1];  /*!< Reserverd block, offset: 0x10 */
    volatile uint32_t WAKUP_FLG;     /*!< wake up flag register, offset: 0x14 */
    volatile uint32_t STATUS;        /*!< status register register, offset: 0x18 */
    uint32_t          RESERVED2[13]; /*!< Reserverd block, offset: 0x1C */
    volatile uint32_t KEY;           /*!< key register, offset: 0x50 */
} PmcRegType;

/*******************************************************************************
 * the globals
 ******************************************************************************/

/*******************************************************************************
 * the function prototypes
 ******************************************************************************/

/*! \brief Gets the CPU retention enable
 *
 * This function gets the current CPU retention enable.
 * enable the PMC cpu retention function, when lock function disable this register can write access.
 * CPU after reset then start to excute instruction from the begining when exit standby mode
 * or CPU start to excute instruction from the states before enter standby mode when exit standby mode.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return CPU retention enable
 *         - 0 : excute instruction from the begining.
 *         - 1 : excute instruction from the states before enter standby mode.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetGlbCtrlCpuRetionEn(const PmcRegType *obj)
{
    return ((obj->GLB_CTRL & PMC_GLB_CTRL_CPU_RETION_EN_MASK) >> PMC_GLB_CTRL_CPU_RETION_EN_SHIFT);
}

/*! \brief Sets the CPU retention enable
 *
 * This function sets the CPU retention enable.
 * enable the PMC cpu retention function, when lock function disable this register can write access.
 * CPU after reset then start to excute instruction from the begining when exit standby mode
 * or CPU start to excute instruction from the states before enter standby mode when exit standby mode.
 *
 * \param[in] obj : pointer to PMC register instance
 * \param[in] value : the value of CPU retention enable
 *                    - 0 : excute instruction from the begining.
 *                    - 1 : excute instruction from the states before enter standby mode.
 */
__attribute__((always_inline)) static inline void PmcReg_SetGlbCtrlCpuRetionEn(PmcRegType *obj, uint8_t value)
{
    uint32_t tmp = obj->GLB_CTRL;

    tmp &= ~PMC_GLB_CTRL_CPU_RETION_EN_MASK;
    tmp |= (((uint32_t)(((uint32_t)(value)) << PMC_GLB_CTRL_CPU_RETION_EN_SHIFT)) & PMC_GLB_CTRL_CPU_RETION_EN_MASK);
    obj->GLB_CTRL = tmp;
}

/*! \brief Gets the Stop mode enable
 *
 * This function gets the current Stop mode enable.
 * PMC stop mode enable, when lock function disable this register can write access.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return Stop mode enable
 *         - 0 : stop mode disable.
 *         - 1 : stop mode enable.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetGlbCtrlStopEn(const PmcRegType *obj)
{
    return ((obj->GLB_CTRL & PMC_GLB_CTRL_STOP_EN_MASK) >> PMC_GLB_CTRL_STOP_EN_SHIFT);
}

/*! \brief Sets the Stop mode enable
 *
 * This function sets the Stop mode enable.
 * PMC stop mode enable, when lock function disable this register can write access.
 *
 * \param[in] obj : pointer to PMC register instance
 * \param[in] value : the value of Stop mode enable
 *                    - 0 : stop mode disable.
 *                    - 1 : stop mode enable.
 */
__attribute__((always_inline)) static inline void PmcReg_SetGlbCtrlStopEn(PmcRegType *obj, uint8_t value)
{
    uint32_t tmp = obj->GLB_CTRL;

    tmp &= ~PMC_GLB_CTRL_STOP_EN_MASK;
    tmp |= (((uint32_t)(((uint32_t)(value)) << PMC_GLB_CTRL_STOP_EN_SHIFT)) & PMC_GLB_CTRL_STOP_EN_MASK);
    obj->GLB_CTRL = tmp;
}

/*! \brief Gets the standby mode enable
 *
 * This function gets the current standby mode enable.
 * PMC standby mode enable, when lock function disable this register can write access.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return standby mode enable
 *         - 0 : standby mode disable.
 *         - 1 : standby mode enable.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetGlbCtrlStdbyEn(const PmcRegType *obj)
{
    return ((obj->GLB_CTRL & PMC_GLB_CTRL_STDBY_EN_MASK) >> PMC_GLB_CTRL_STDBY_EN_SHIFT);
}

/*! \brief Sets the standby mode enable
 *
 * This function sets the standby mode enable.
 * PMC standby mode enable, when lock function disable this register can write access.
 *
 * \param[in] obj : pointer to PMC register instance
 * \param[in] value : the value of standby mode enable
 *                    - 0 : standby mode disable.
 *                    - 1 : standby mode enable.
 */
__attribute__((always_inline)) static inline void PmcReg_SetGlbCtrlStdbyEn(PmcRegType *obj, uint8_t value)
{
    uint32_t tmp = obj->GLB_CTRL;

    tmp &= ~PMC_GLB_CTRL_STDBY_EN_MASK;
    tmp |= (((uint32_t)(((uint32_t)(value)) << PMC_GLB_CTRL_STDBY_EN_SHIFT)) & PMC_GLB_CTRL_STDBY_EN_MASK);
    obj->GLB_CTRL = tmp;
}

/*! \brief Gets the Flash LDO(FLDO) voltage detect control
 *
 * This function gets the current Flash LDO(FLDO) voltage detect control.
 * when write lock function disable this register can write access.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return Flash LDO(FLDO) voltage detect control
 *         - 1 : Enable voltage detect.
 *         - 0 : Disable voltage detect.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetDAIntfCtrlEnFldoVDet(const PmcRegType *obj)
{
    return ((obj->DAINTF_CTRL & PMC_DAINTF_CTRL_EN_FLDO_VDET_MASK) >> PMC_DAINTF_CTRL_EN_FLDO_VDET_SHIFT);
}

/*! \brief Sets the Flash LDO(FLDO) voltage detect control
 *
 * This function sets the Flash LDO(FLDO) voltage detect control.
 * when write lock function disable this register can write access.
 *
 * \param[in] obj : pointer to PMC register instance
 * \param[in] value : the value of Flash LDO(FLDO) voltage detect control
 *                    - 1 : Enable voltage detect.
 *                    - 0 : Disable voltage detect.
 */
__attribute__((always_inline)) static inline void PmcReg_SetDAIntfCtrlEnFldoVDet(PmcRegType *obj, uint8_t value)
{
    uint32_t tmp = obj->DAINTF_CTRL;

    tmp &= ~PMC_DAINTF_CTRL_EN_FLDO_VDET_MASK;
    tmp |= (((uint32_t)(((uint32_t)(value)) << PMC_DAINTF_CTRL_EN_FLDO_VDET_SHIFT)) & PMC_DAINTF_CTRL_EN_FLDO_VDET_MASK);
    obj->DAINTF_CTRL = tmp;
}

/*! \brief Gets the Low voltage warning(LVW) level select
 *
 * This function gets the current Low voltage warning(LVW) level select.
 * when write lock function disable this register can write access.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return Low voltage warning(LVW) level select
 *         - 00b : V_LVW1.
 *         - 01b : V_LVW2.
 *         - 01b : V_LVW3.
 *         - 11b : Not defined.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetDAIntfCtrlSelLvw(const PmcRegType *obj)
{
    return ((obj->DAINTF_CTRL & PMC_DAINTF_CTRL_SEL_LVW_MASK) >> PMC_DAINTF_CTRL_SEL_LVW_SHIFT);
}

/*! \brief Sets the Low voltage warning(LVW) level select
 *
 * This function sets the Low voltage warning(LVW) level select.
 * when write lock function disable this register can write access.
 *
 * \param[in] obj : pointer to PMC register instance
 * \param[in] value : the value of Low voltage warning(LVW) level select
 *                    - 00b : V_LVW1.
 *                    - 01b : V_LVW2.
 *                    - 01b : V_LVW3.
 *                    - 11b : Not defined.
 */
__attribute__((always_inline)) static inline void PmcReg_SetDAIntfCtrlSelLvw(PmcRegType *obj, uint8_t value)
{
    uint32_t tmp = obj->DAINTF_CTRL;

    tmp &= ~PMC_DAINTF_CTRL_SEL_LVW_MASK;
    tmp |= (((uint32_t)(((uint32_t)(value)) << PMC_DAINTF_CTRL_SEL_LVW_SHIFT)) & PMC_DAINTF_CTRL_SEL_LVW_MASK);
    obj->DAINTF_CTRL = tmp;
}

/*! \brief Gets the Low voltage detect warning(LVW) control
 *
 * This function gets the current Low voltage detect warning(LVW) control.
 * when write lock function disable this register can write access.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return Low voltage detect warning(LVW) control
 *         - 0b : Disable low voltage warning.
 *         - 1b : Enable low voltage warning.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetDAIntfCtrlEnLvw(const PmcRegType *obj)
{
    return ((obj->DAINTF_CTRL & PMC_DAINTF_CTRL_EN_LVW_MASK) >> PMC_DAINTF_CTRL_EN_LVW_SHIFT);
}

/*! \brief Sets the Low voltage detect warning(LVW) control
 *
 * This function sets the Low voltage detect warning(LVW) control.
 * when write lock function disable this register can write access.
 *
 * \param[in] obj : pointer to PMC register instance
 * \param[in] value : the value of Low voltage detect warning(LVW) control
 *                    - 0b : Disable low voltage warning.
 *                    - 1b : Enable low voltage warning.
 */
__attribute__((always_inline)) static inline void PmcReg_SetDAIntfCtrlEnLvw(PmcRegType *obj, uint8_t value)
{
    uint32_t tmp = obj->DAINTF_CTRL;

    tmp &= ~PMC_DAINTF_CTRL_EN_LVW_MASK;
    tmp |= (((uint32_t)(((uint32_t)(value)) << PMC_DAINTF_CTRL_EN_LVW_SHIFT)) & PMC_DAINTF_CTRL_EN_LVW_MASK);
    obj->DAINTF_CTRL = tmp;
}

/*! \brief Gets the Low voltage detect enable control
 *
 * This function gets the current Low voltage detect enable control.
 * when write lock function disable this register can write access.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return Low voltage detect enable control
 *         - 0b : Disable low voltage detect.
 *         - 1b : Enable low voltage detect.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetDAIntfCtrlEnLvd(const PmcRegType *obj)
{
    return ((obj->DAINTF_CTRL & PMC_DAINTF_CTRL_EN_LVD_MASK) >> PMC_DAINTF_CTRL_EN_LVD_SHIFT);
}

/*! \brief Sets the Low voltage detect enable control
 *
 * This function sets the Low voltage detect enable control.
 * when write lock function disable this register can write access.
 *
 * \param[in] obj : pointer to PMC register instance
 * \param[in] value : the value of Low voltage detect enable control
 *                    - 0b : Disable low voltage detect.
 *                    - 1b : Enable low voltage detect.
 */
__attribute__((always_inline)) static inline void PmcReg_SetDAIntfCtrlEnLvd(PmcRegType *obj, uint8_t value)
{
    uint32_t tmp = obj->DAINTF_CTRL;

    tmp &= ~PMC_DAINTF_CTRL_EN_LVD_MASK;
    tmp |= (((uint32_t)(((uint32_t)(value)) << PMC_DAINTF_CTRL_EN_LVD_SHIFT)) & PMC_DAINTF_CTRL_EN_LVD_MASK);
    obj->DAINTF_CTRL = tmp;
}

/*! \brief Gets the OTP function enable control
 *
 * This function gets the current OTP function enable control.
 * when write lock function disable this register can write access.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return OTP function enable control
 *         - 0 : Disable.
 *         - 1 : Enable.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetDAIntfCtrlOtpEn(const PmcRegType *obj)
{
    return ((obj->DAINTF_CTRL & PMC_DAINTF_CTRL_OTP_EN_MASK) >> PMC_DAINTF_CTRL_OTP_EN_SHIFT);
}

/*! \brief Sets the OTP function enable control
 *
 * This function sets the OTP function enable control.
 * when write lock function disable this register can write access.
 *
 * \param[in] obj : pointer to PMC register instance
 * \param[in] value : the value of OTP function enable control
 *                    - 0 : Disable.
 *                    - 1 : Enable.
 */
__attribute__((always_inline)) static inline void PmcReg_SetDAIntfCtrlOtpEn(PmcRegType *obj, uint8_t value)
{
    uint32_t tmp = obj->DAINTF_CTRL;

    tmp &= ~PMC_DAINTF_CTRL_OTP_EN_MASK;
    tmp |= (((uint32_t)(((uint32_t)(value)) << PMC_DAINTF_CTRL_OTP_EN_SHIFT)) & PMC_DAINTF_CTRL_OTP_EN_MASK);
    obj->DAINTF_CTRL = tmp;
}

/*! \brief Gets the cmp wake up event flag
 *
 * This function gets the current cmp wake up event flag.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return cmp wake up event flag
 *         - 0 : cmp wake up event flag not exist.
 *         - 1 : cmp wake up event flag exist.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetWakupFlgCmpWakupEvtFlag(const PmcRegType *obj)
{
    return ((obj->WAKUP_FLG & PMC_WAKUP_FLG_CMP_WAKUP_EVT_FLG_MASK) >> PMC_WAKUP_FLG_CMP_WAKUP_EVT_FLG_SHIFT);
}

/*! \brief Sets the cmp wake up event flag
 *
 * This function sets the cmp wake up event flag.
 *
 * \param[in] obj : pointer to PMC register instance
 */
__attribute__((always_inline)) static inline void PmcReg_ClearWakupFlgCmpWakupEvtFlag(PmcRegType *obj)
{
    /* Clear the affected bit-field and write '0' to the w1c bits to avoid side-effects */
    obj->WAKUP_FLG = (((uint32_t)(((uint32_t)(1)) << PMC_WAKUP_FLG_CMP_WAKUP_EVT_FLG_SHIFT)) & PMC_WAKUP_FLG_CMP_WAKUP_EVT_FLG_MASK);
}

/*! \brief Gets the lptmr wake up event flag
 *
 * This function gets the current lptmr wake up event flag.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return lptmr wake up event flag
 *         - 0 : lptmr wake up event flag not exist.
 *         - 1 : lptmr wake up event flag exist.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetWakupFlgLptmrWakupEvtFlg(const PmcRegType *obj)
{
    return ((obj->WAKUP_FLG & PMC_WAKUP_FLG_LPTMR_WAKUP_EVT_FLG_MASK) >> PMC_WAKUP_FLG_LPTMR_WAKUP_EVT_FLG_SHIFT);
}

/*! \brief Sets the lptmr wake up event flag
 *
 * This function sets the lptmr wake up event flag.
 *
 * \param[in] obj : pointer to PMC register instance
 */
__attribute__((always_inline)) static inline void PmcReg_ClearWakupFlgLptmrWakupEvtFlg(PmcRegType *obj)
{
    /* Clear the affected bit-field and write '0' to the w1c bits to avoid side-effects */
    obj->WAKUP_FLG = (((uint32_t)(((uint32_t)(1)) << PMC_WAKUP_FLG_LPTMR_WAKUP_EVT_FLG_SHIFT)) & PMC_WAKUP_FLG_LPTMR_WAKUP_EVT_FLG_MASK);
}

/*! \brief Gets the low power interrupt timer wake up event flag
 *
 * This function gets the current low power interrupt timer wake up event flag.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return low power interrupt timer wake up event flag
 *         - 0 : lpit wake up event flag not exist.
 *         - 1 : lpit wake up event flag exist.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetWakupFlgLpitWakupEvtFlg(const PmcRegType *obj)
{
    return ((obj->WAKUP_FLG & PMC_WAKUP_FLG_LPIT_WAKUP_EVT_FLG_MASK) >> PMC_WAKUP_FLG_LPIT_WAKUP_EVT_FLG_SHIFT);
}

/*! \brief Sets the low power interrupt timer wake up event flag
 *
 * This function sets the low power interrupt timer wake up event flag.
 *
 * \param[in] obj : pointer to PMC register instance
 */
__attribute__((always_inline)) static inline void PmcReg_ClearWakupFlgLpitWakupEvtFlg(PmcRegType *obj)
{
    /* Clear the affected bit-field and write '0' to the w1c bits to avoid side-effects */
    obj->WAKUP_FLG = (((uint32_t)(((uint32_t)(1)) << PMC_WAKUP_FLG_LPIT_WAKUP_EVT_FLG_SHIFT)) & PMC_WAKUP_FLG_LPIT_WAKUP_EVT_FLG_MASK);
}

/*! \brief Gets the real time clock wake up event flag
 *
 * This function gets the current real time clock wake up event flag.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return real time clock wake up event flag
 *         - 0 : rtc wake up event flag not exist.
 *         - 1 : rtc wake up event flag exist.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetWakupFlgRtcWakupEvtFlg(const PmcRegType *obj)
{
    return ((obj->WAKUP_FLG & PMC_WAKUP_FLG_RTC_WAKUP_EVT_FLG_MASK) >> PMC_WAKUP_FLG_RTC_WAKUP_EVT_FLG_SHIFT);
}

/*! \brief Sets the real time clock wake up event flag
 *
 * This function sets the real time clock wake up event flag.
 *
 * \param[in] obj : pointer to PMC register instance
 */
__attribute__((always_inline)) static inline void PmcReg_ClearWakupFlgRtcWakupEvtFlg(PmcRegType *obj)
{
    /* Clear the affected bit-field and write '0' to the w1c bits to avoid side-effects */
    obj->WAKUP_FLG = (((uint32_t)(((uint32_t)(1)) << PMC_WAKUP_FLG_RTC_WAKUP_EVT_FLG_SHIFT)) & PMC_WAKUP_FLG_RTC_WAKUP_EVT_FLG_MASK);
}

/*! \brief Gets the External reset wake up event flag
 *
 * This function gets the current External reset wake up event flag.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return External reset wake up event flag
 *         - 0 : extrst wake up event flag not exist.
 *         - 1 : extrst wake up event flag exist.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetWakupFlgExtrstWakupEvtFlg(const PmcRegType *obj)
{
    return ((obj->WAKUP_FLG & PMC_WAKUP_FLG_EXTRST_WAKUP_EVT_FLG_MASK) >> PMC_WAKUP_FLG_EXTRST_WAKUP_EVT_FLG_SHIFT);
}

/*! \brief Sets the External reset wake up event flag
 *
 * This function sets the External reset wake up event flag.
 *
 * \param[in] obj : pointer to PMC register instance
 */
__attribute__((always_inline)) static inline void PmcReg_ClearWakupFlgExtrstWakupEvtFlg(PmcRegType *obj)
{
    /* Clear the affected bit-field and write '0' to the w1c bits to avoid side-effects */
    obj->WAKUP_FLG = (((uint32_t)(((uint32_t)(1)) << PMC_WAKUP_FLG_EXTRST_WAKUP_EVT_FLG_SHIFT)) & PMC_WAKUP_FLG_EXTRST_WAKUP_EVT_FLG_MASK);
}

/*! \brief Gets the port E wake up event flag
 *
 * This function gets the current port E wake up event flag.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return port E wake up event flag
 *         - 0 : porte wake up event flag not exist.
 *         - 1 : porte wake up event flag exist.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetWakupFlgPortEWakupEvtFlg(const PmcRegType *obj)
{
    return ((obj->WAKUP_FLG & PMC_WAKUP_FLG_PORTE_WAKUP_EVT_FLG_MASK) >> PMC_WAKUP_FLG_PORTE_WAKUP_EVT_FLG_SHIFT);
}

/*! \brief Sets the port E wake up event flag
 *
 * This function sets the port E wake up event flag.
 *
 * \param[in] obj : pointer to PMC register instance
 */
__attribute__((always_inline)) static inline void PmcReg_ClearWakupFlgPortEWakupEvtFlg(PmcRegType *obj)
{
    /* Clear the affected bit-field and write '0' to the w1c bits to avoid side-effects */
    obj->WAKUP_FLG = (((uint32_t)(((uint32_t)(1)) << PMC_WAKUP_FLG_PORTE_WAKUP_EVT_FLG_SHIFT)) & PMC_WAKUP_FLG_PORTE_WAKUP_EVT_FLG_MASK);
}

/*! \brief Gets the port D wake up event flag
 *
 * This function gets the current port D wake up event flag.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return port D wake up event flag
 *         - 0 : portd wake up event flag not exist.
 *         - 1 : portd wake up event flag exist.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetWakupFlgPortDWakupEvtFlg(const PmcRegType *obj)
{
    return ((obj->WAKUP_FLG & PMC_WAKUP_FLG_PORTD_WAKUP_EVT_FLG_MASK) >> PMC_WAKUP_FLG_PORTD_WAKUP_EVT_FLG_SHIFT);
}

/*! \brief Sets the port D wake up event flag
 *
 * This function sets the port D wake up event flag.
 *
 * \param[in] obj : pointer to PMC register instance
 */
__attribute__((always_inline)) static inline void PmcReg_ClearWakupFlgPortDWakupEvtFlg(PmcRegType *obj)
{
    /* Clear the affected bit-field and write '0' to the w1c bits to avoid side-effects */
    obj->WAKUP_FLG = (((uint32_t)(((uint32_t)(1)) << PMC_WAKUP_FLG_PORTD_WAKUP_EVT_FLG_SHIFT)) & PMC_WAKUP_FLG_PORTD_WAKUP_EVT_FLG_MASK);
}

/*! \brief Gets the port C wake up event flag
 *
 * This function gets the current port C wake up event flag.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return port C wake up event flag
 *         - 0 : portc wake up event flag not exist.
 *         - 1 : portc wake up event flag exist.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetWakupFlgPortCWakupEvtFlg(const PmcRegType *obj)
{
    return ((obj->WAKUP_FLG & PMC_WAKUP_FLG_PORTC_WAKUP_EVT_FLG_MASK) >> PMC_WAKUP_FLG_PORTC_WAKUP_EVT_FLG_SHIFT);
}

/*! \brief Sets the port C wake up event flag
 *
 * This function sets the port C wake up event flag.
 *
 * \param[in] obj : pointer to PMC register instance
 */
__attribute__((always_inline)) static inline void PmcReg_ClearWakupFlgPortCWakupEvtFlg(PmcRegType *obj)
{
    /* Clear the affected bit-field and write '0' to the w1c bits to avoid side-effects */
    obj->WAKUP_FLG = (((uint32_t)(((uint32_t)(1)) << PMC_WAKUP_FLG_PORTC_WAKUP_EVT_FLG_SHIFT)) & PMC_WAKUP_FLG_PORTC_WAKUP_EVT_FLG_MASK);
}

/*! \brief Gets the port B wake up event flag
 *
 * This function gets the current port B wake up event flag.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return port B wake up event flag
 *         - 0 : portb wake up event flag not exist.
 *         - 1 : portb wake up event flag exist.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetWakupFlgPortBWakupEvtFlg(const PmcRegType *obj)
{
    return ((obj->WAKUP_FLG & PMC_WAKUP_FLG_PORTB_WAKUP_EVT_FLG_MASK) >> PMC_WAKUP_FLG_PORTB_WAKUP_EVT_FLG_SHIFT);
}

/*! \brief Sets the port B wake up event flag
 *
 * This function sets the port B wake up event flag.
 *
 * \param[in] obj : pointer to PMC register instance
 */
__attribute__((always_inline)) static inline void PmcReg_ClearWakupFlgPortBWakupEvtFlg(PmcRegType *obj)
{
    /* Clear the affected bit-field and write '0' to the w1c bits to avoid side-effects */
    obj->WAKUP_FLG = (((uint32_t)(((uint32_t)(1)) << PMC_WAKUP_FLG_PORTB_WAKUP_EVT_FLG_SHIFT)) & PMC_WAKUP_FLG_PORTB_WAKUP_EVT_FLG_MASK);
}

/*! \brief Gets the port A wake up event flag
 *
 * This function gets the current port A wake up event flag.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return port A wake up event flag
 *         - 0 : porta wake up event flag not exist.
 *         - 1 : porta wake up event flag exist.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetWakupFlgPortAWakupEvtFlg(const PmcRegType *obj)
{
    return ((obj->WAKUP_FLG & PMC_WAKUP_FLG_PORTA_WAKUP_EVT_FLG_MASK) >> PMC_WAKUP_FLG_PORTA_WAKUP_EVT_FLG_SHIFT);
}

/*! \brief Sets the port A wake up event flag
 *
 * This function sets the port A wake up event flag.
 *
 * \param[in] obj : pointer to PMC register instance
 */
__attribute__((always_inline)) static inline void PmcReg_ClearWakupFlgPortAWakupEvtFlg(PmcRegType *obj)
{
    /* Clear the affected bit-field and write '0' to the w1c bits to avoid side-effects */
    obj->WAKUP_FLG = (((uint32_t)(((uint32_t)(1)) << PMC_WAKUP_FLG_PORTA_WAKUP_EVT_FLG_SHIFT)) & PMC_WAKUP_FLG_PORTA_WAKUP_EVT_FLG_MASK);
}

/*! \brief Gets the normal run mode status
 *
 * This function gets the current normal run mode status.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return normal run mode status
 *         - 0 : normal run mode status not exist.
 *         - 1 : normal run mode status exist.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetStatusRunMode(const PmcRegType *obj)
{
    return ((obj->STATUS & PMC_STATUS_RUN_MODE_MASK) >> PMC_STATUS_RUN_MODE_SHIFT);
}

/*! \brief Gets the standby abort status
 *
 * This function gets the current standby abort status.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return standby abort status
 *         - 0 : standby abort status not exist.
 *         - 1 : standby abort status exist.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetStatusStdbyAbortSts(const PmcRegType *obj)
{
    return ((obj->STATUS & PMC_STATUS_STDBY_ABORT_STS_MASK) >> PMC_STATUS_STDBY_ABORT_STS_SHIFT);
}

/*! \brief Sets the standby abort status
 *
 * This function sets the standby abort status.
 *
 * \param[in] obj : pointer to PMC register instance
 */
__attribute__((always_inline)) static inline void PmcReg_ClearStatusStdbyAbortSts(PmcRegType *obj)
{
    /* Clear the affected bit-field and write '0' to the w1c bits to avoid side-effects */
    obj->STATUS = (((uint32_t)(((uint32_t)(1)) << PMC_STATUS_STDBY_ABORT_STS_SHIFT)) & PMC_STATUS_STDBY_ABORT_STS_MASK);
}

/*! \brief Gets the pad keep status
 *
 * This function gets the current pad keep status.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return pad keep status
 *         - 0 : pad keep disable.
 *         - 1 : pad keep enable.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetStatusPadKeep(const PmcRegType *obj)
{
    return ((obj->STATUS & PMC_STATUS_PAD_KEEP_MASK) >> PMC_STATUS_PAD_KEEP_SHIFT);
}

/*! \brief Sets the pad keep status
 *
 * This function sets the pad keep status.
 *
 * \param[in] obj : pointer to PMC register instance
 */
__attribute__((always_inline)) static inline void PmcReg_ClearStatusPadKeep(PmcRegType *obj)
{
    /* Clear the affected bit-field and write '0' to the w1c bits to avoid side-effects */
    obj->STATUS = (((uint32_t)(((uint32_t)(1)) << PMC_STATUS_PAD_KEEP_SHIFT)) & PMC_STATUS_PAD_KEEP_MASK);
}

/*! \brief Gets the key lock enable
 *
 * This function gets the current key lock enable.
 *
 * \param[in] obj : pointer to PMC register instance
 * \return key lock enable
 *         - 0 : disable.
 *         - 1 : enable.
 */
__attribute__((always_inline)) static inline uint8_t PmcReg_GetStatusKeyLock(const PmcRegType *obj)
{
    return ((obj->STATUS & PMC_STATUS_LOCK_MASK) >> PMC_STATUS_LOCK_SHIFT);
}

/*! \brief Sets the PMC key lock enable
 *
 * This function sets the PMC key lock enable.
 * pmc write public function register hit key, the initial confirm key is 0x20220509,
 * when cpu write data is 0x20220509, PMC public function register lock is invalid,
 * CPU can write the pmc public function register.
 * When cpu write data is not equal 0x20220509, PMC public register function lock is valid,
 * CPU can not write the pmc function register
 *
 * \param[in] obj : pointer to PMC register instance
 * \param[in] value : the value of PMC key lock enable
 *                    - 0x20220509 : unlock
 *                    - others : lock
 */
__attribute__((always_inline)) static inline void PmcReg_SetKey(PmcRegType *obj, uint32_t value)
{
    obj->KEY = value;
}

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

#endif /* _PMC_REG_H_ */