📄 test.cpp
字号:
//------------------------------------------------------------------------------
//
// Copyright (c) Microsoft Corporation. All rights reserved.
//
//
// Use of this source code is subject to the terms of the Microsoft end-user
// license agreement (EULA) under which you licensed this SOFTWARE PRODUCT.
// If you did not accept the terms of the EULA, you are not authorized to use
// this source code. For a copy of the EULA, please see the LICENSE.RTF on your
// install media.
//
//------------------------------------------------------------------------------
//
// Copyright (C) 2004, 2006, 2007, Freescale Semiconductor, Inc. All Rights Reserved.
// THIS SOURCE CODE, AND ITS USE AND DISTRIBUTION, IS SUBJECT TO THE TERMS
// AND CONDITIONS OF THE APPLICABLE LICENSE AGREEMENT
//
//------------------------------------------------------------------------------
//-----------------------------------------------------------------------------
//
// File: test.cpp
//
// This file contains test code for the GPT driver
//
//------------------------------------------------------------------------------
#pragma warning(push)
#pragma warning(disable: 4115)
#pragma warning(disable: 4201)
#pragma warning(disable: 4204)
#pragma warning(disable: 4214)
#include <windows.h>
#pragma warning(pop)
#include <Devload.h>
#include<Winbase.h>
#include <ceddk.h>
#include "main.h"
#include "globals.h"
#include "pmic_lla.h"
#include "pmic_regulator.h"
#include "csp.h"
#include "pmic_adc.h"
#include "regs_adc.h"
#include "pmic_pwrctrl.h"
#include "pmic_battery.h"
#include "test.h"
//-----------------------------------------------------------------------------
// External Functions
//-----------------------------------------------------------------------------
// External Variables
//-----------------------------------------------------------------------------
// Defines
#define GPT_ZONE_INFO 0
#define GPT_ZONE_ERROR 0
#define GPT_ZONE_FUNCTION 0
#define GPT_TEST_FUNCTION_ENTRY() \
g_pKato->Log(GPT_ZONE_FUNCTION, (TEXT("++%s\r\n"), __WFUNCTION__))
#define GPT_TEST_FUNCTION_EXIT() \
g_pKato->Log(GPT_ZONE_FUNCTION, (TEXT("--%s\r\n"), __WFUNCTION__))
#define GPT_EVENT_NAME L"GptTest1"
#define THREAD_PRIORITY 250
void alarmCB (void);
int alarm=0;
void Print_VoltageregulatorValues(PMIC_REGULATOR_VREG i,PMIC_REGULATOR_VREG_VOLTAGE Reg_Voltage);
double VoltageBitsValue[64]={
0.900,
0.925,
0.950,
0.975,
1.000,
1.025,
1.050,
1.075,
1.100,
1.125,
1.150,
1.175,
1.200,
1.225,
1.250,
1.275,
1.300,
1.325,
1.350,
1.375,
1.400,
1.425,
1.450,
1.475,
1.500,
1.525,
1.550,
1.575,
1.600,
1.625,
1.650,
1.675,
1.700,
1.700,
1.700,
1.700,
1.800,
1.800,
1.800,
1.800,
1.900,
1.900,
1.900,
1.900,
2.000,
2.000,
2.000,
2.000,
2.100,
2.100,
2.100,
2.100,
2.200,
2.200,
2.200,
2.200,
2.200,
2.200,
2.200,
2.200,
2.200,
2.200,
2.200,
2.200
};
//-----------------------------------------------------------------------------
// Types
//-----------------------------------------------------------------------------
// Global Variables
//-----------------------------------------------------------------------------
// Local Variables
//-----------------------------------------------------------------------------
// Local Functions
int MC13783_power_get_power_mode_sense(struct t_p_up_sense* mod);
int MC13783_power_cut_conf(struct t_power_cut_conf *pc);
int MC13783_power_cut_get_conf(struct t_power_cut_conf *pc);
//------------------------------------------------------------------------------
//
// Function: PMICTestRegisterAccess
//
// This function attempts to test PMIC Low-level APIs for read/write registers
//
// Parameters:
// uiMsg
// [in] Ignored.
//
// tpParam
// [in] Ignored.
//
// lpFTE
// [in] Ignored.
//
// Returns:
// Specifies if the test passed (TPR_PASS), failed (TPR_FAIL), or was
// skipped (TPR_SKIP).
//
//------------------------------------------------------------------------------
TESTPROCAPI PMICTestRegisterAccess(UINT uMsg, TPPARAM tpParam, LPFUNCTION_TABLE_ENTRY lpFTE)
{
UINT32 reg;
UNREFERENCED_PARAMETER(tpParam);
UNREFERENCED_PARAMETER(lpFTE);
// Validate that the shell wants the test to run
if (uMsg != TPM_EXECUTE)
{
return TPR_NOT_HANDLED;
}
g_pKato->Log(LOG_COMMENT, TEXT("PMICTestRegisterAccess() +\r\n"));
// Read IMR
PmicRegisterRead(1, ®);
g_pKato->Log(LOG_COMMENT, TEXT("Register IMR is 0X%X\r\n"), (reg & 0xFFFFFF));
g_pKato->Log(LOG_COMMENT, TEXT("Now, try to change IMR to 0x0FF\r\n"));
PmicRegisterWrite(1, 0x0FF, 0xFFFFFF);
PmicRegisterRead(1, ®);
g_pKato->Log(LOG_COMMENT, TEXT("Register IMR is 0X%X\r\n"), (reg & 0xFFFFFF));
// Enter ISR loop
if ((reg&0xFFFFFF) == 0xFF)
{
GPT_TEST_FUNCTION_EXIT();
return TPR_PASS;
}
else
{
GPT_TEST_FUNCTION_EXIT();
return TPR_FAIL;
}
}
//------------------------------------------------------------------------------
//
// Function: PMICTestVoltageRegulator
//
// This function tests the Voltage Regulator.
//
// Parameters:
// uiMsg
// [in] Ignored.
//
// tpParam
// [in] Ignored.
//
// lpFTE
// [in] Ignored.
//
// Returns:
// Specifies if the test passed (TPR_PASS), failed (TPR_FAIL), or was
// skipped (TPR_SKIP).
//
//------------------------------------------------------------------------------
TESTPROCAPI PMICTestVoltageRegulator(UINT uMsg, TPPARAM tpParam, LPFUNCTION_TABLE_ENTRY lpFTE)
{
PMIC_REGULATOR_VREG_VOLTAGE Reg_Voltage;
UINT8 dvsspeed;
int i, j;
int count;
PMIC_REGULATOR_VREG_VOLTAGE lCount;
PMIC_REGULATOR_SREG_MODE mode;
PMIC_REGULATOR_SREG_MODE regulator_mode;
PMIC_REGULATOR_SREG sreg;
PMIC_REGULATOR_SREG sreg_tab[4] = {SW1A, SW1B, SW2A, SW2B};
WCHAR* sreg_name;
WCHAR* sreg_name_tab[4] = {TEXT("SW1A"), TEXT("SW1B"), TEXT("SW2A"), TEXT("SW2B")};
UNREFERENCED_PARAMETER(tpParam);
UNREFERENCED_PARAMETER(lpFTE);
// Validate that the shell wants the test to run
if (uMsg != TPM_EXECUTE)
{
return TPR_NOT_HANDLED;
}
g_pKato->Log(LOG_COMMENT, TEXT("Voltage Regulator -- PMICTestVoltageRegulator() +\r\n"));
// Read voltage levels and display.
for(i = 0; i < 15; i++)
{
PmicVoltageRegulatorGetVoltageLevel (( PMIC_REGULATOR_VREG) i,&Reg_Voltage);
g_pKato->Log(LOG_COMMENT, TEXT("%d Voltage Regulator set Voltage is :0x%x\r\n"),i,Reg_Voltage);
}
// Switch off the voltage regulators and verify LEDs
for(i = 0;i < 15; i++){
#ifdef PLAT_FALCON
if(!(i==1 || i==12 || i==3 || i == 4))
#else
if(!(i==1 || i==3 || i==4 || i==12 || i==13 || i==14))
#endif
{
g_pKato->Log(LOG_COMMENT, TEXT("Switching off and switch On Voltage Regulator %d\r\n"),i);
PmicVoltageRegulatorOff ((PMIC_REGULATOR_VREG)i);
}
PmicVoltageRegulatorOn ((PMIC_REGULATOR_VREG)i);
// PmicVoltageRegulatorGetVoltageLevel (( PMIC_REGULATOR_VREG) i,&Reg_Voltage);
// g_pKato->Log(LOG_COMMENT, TEXT("%d Voltage Regulator set Voltage is :0x%x\r\n"),i,Reg_Voltage);
}
g_pKato->Log(LOG_COMMENT, TEXT("Check LED's of repective Voltage regulators for off position\r\n"));
// Read voltage levels and display again.
for(i = 0; i < 15; i++)
{
PmicVoltageRegulatorGetVoltageLevel (( PMIC_REGULATOR_VREG) i,&Reg_Voltage);
Print_VoltageregulatorValues(( PMIC_REGULATOR_VREG) i,Reg_Voltage);
}
// for all regulators, set various possible voltage levels and verify through test pins.
for(i = 0; i < 15; i++)
{
switch(i)
{
case 0:
lCount.viohi =(MC13783_REGULATOR_VREG_VOLTAGE_VIOHI) i;
PmicVoltageRegulatorSetVoltageLevel (( PMIC_REGULATOR_VREG)i,lCount);
PmicVoltageRegulatorGetVoltageLevel (( PMIC_REGULATOR_VREG) i,&Reg_Voltage);
Print_VoltageregulatorValues(( PMIC_REGULATOR_VREG) i,Reg_Voltage);
Sleep(3000);
break;
case 1:
for(count = 0; count <= VIOLO_1_80V; count++)
{
lCount.violo =(MC13783_REGULATOR_VREG_VOLTAGE_VIOLO) count;
PmicVoltageRegulatorSetVoltageLevel (( PMIC_REGULATOR_VREG)i,lCount);
PmicVoltageRegulatorGetVoltageLevel (( PMIC_REGULATOR_VREG) i,&Reg_Voltage);
Print_VoltageregulatorValues(( PMIC_REGULATOR_VREG) i,Reg_Voltage);
Sleep(3000);
}
break;
case 2:
for(count = 0; count <= VDIG_1_80V; count++)
{
lCount.vdig =(MC13783_REGULATOR_VREG_VOLTAGE_VDIG) count;
PmicVoltageRegulatorSetVoltageLevel (( PMIC_REGULATOR_VREG)i,lCount);
PmicVoltageRegulatorGetVoltageLevel (( PMIC_REGULATOR_VREG) i,&Reg_Voltage);
Print_VoltageregulatorValues(( PMIC_REGULATOR_VREG) i,Reg_Voltage);
Sleep(3000);
}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -