/**************************************************************************************************
*
* Copyright 2021 NXP
*
**************************************************************************************************
*
* NXP Confidential Proprietary. This software is owned or controlled by NXP and may only be used
* strictly in accordance with the applicable 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.
*
* THIS SOFTWARE IS PROVIDED BY NXP "AS IS" AND ANY EXPRESSED OR
* IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
* OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
* IN NO EVENT SHALL NXP OR ITS CONTRIBUTORS BE LIABLE FOR ANY DIRECT,
* INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES
* (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT,
* STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING
* IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF
* THE POSSIBILITY OF SUCH DAMAGE.
*
**************************************************************************************************/

#ifndef DVFS_H_
#define DVFS_H_

#include "fsl_debug_console.h"
#include "fsl_tempsensor.h"
#include "fsl_dcdc.h"
#include "fsl_gpt.h"

#define GPT_IRQ_ID GPT2_IRQn
#define EXAMPLE_GPT GPT2
#define Monitor_Tempertature_GPT_IRQHandler GPT2_IRQHandler

/* Get source clock for GPT driver (GPT prescaler = 0) */
#define EXAMPLE_GPT_CLK_FREQ CLOCK_GetFreq(kCLOCK_OscRc48MDiv2)

typedef enum _power_mode{
    kPower_Mode_unknown = 0,
    kPower_Mode_600MHz = 1,
    kPower_Mode_800MHz = 2,
}_power_mode_t;

struct TMPSNS_STATUS0{
    uint8_t PANIC_TEMP;
    uint8_t HIGH_TEMP;
    uint8_t LOW_TEMP;
    uint8_t FINISH;
    uint16_t TEMP_VAL;
};

void dvfs_low_high_irq_handle(TMPSNS_Type *base);
void dump_voltage_and_frequency(void);

void GPT_Configure(void);
void Monitor_Tempertature_GPT_IRQHandler(void);

#endif /* DVFS_H_ */
