Files
TempControl/IO.C
2025-10-21 21:25:35 +08:00

376 lines
12 KiB
C
Raw Permalink Blame History

This file contains ambiguous Unicode characters

This file contains Unicode characters that might be confused with other characters. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

//****************************************************************************
// @Module GPIO
// @Filename IO.C
// @Project CL2.0.dav
//----------------------------------------------------------------------------
// @Controller Infineon XC886CLM-8FF
//
// @Compiler Keil
//
// @Codegenerator 1.3
//
// @Description: This file contains functions that use the IO module.
//
//----------------------------------------------------------------------------
// @Date 2021/9/7 09:54:12
//
//****************************************************************************
// USER CODE BEGIN (IO_General,1)
// USER CODE END
//****************************************************************************
// @Project Includes
//****************************************************************************
#include "MAIN.H"
// USER CODE BEGIN (IO_General,2)
// USER CODE END
//****************************************************************************
// @Macros
//****************************************************************************
// USER CODE BEGIN (IO_General,3)
// USER CODE END
//****************************************************************************
// @Defines
//****************************************************************************
// USER CODE BEGIN (IO_General,4)
// USER CODE END
//****************************************************************************
// @Typedefs
//****************************************************************************
// USER CODE BEGIN (IO_General,5)
// USER CODE END
//****************************************************************************
// @Imported Global Variables
//****************************************************************************
// USER CODE BEGIN (IO_General,6)
// USER CODE END
//****************************************************************************
// @Global Variables
//****************************************************************************
// USER CODE BEGIN (IO_General,7)
// USER CODE END
//****************************************************************************
// @External Prototypes
//****************************************************************************
// USER CODE BEGIN (IO_General,8)
// USER CODE END
//****************************************************************************
// @Prototypes Of Local Functions
//****************************************************************************
// USER CODE BEGIN (IO_General,9)
// USER CODE END
//****************************************************************************
// @Function void IO_vInit(void)
//
//----------------------------------------------------------------------------
// @Description This is the initialization function of the IO function
// library. It is assumed that the SFRs used by this library
// are in their reset state.
//
//----------------------------------------------------------------------------
// @Returnvalue None
//
//----------------------------------------------------------------------------
// @Parameters None
//
//----------------------------------------------------------------------------
// @Date 2021/9/7
//
//****************************************************************************
// USER CODE BEGIN (IO_Init,1)
// USER CODE END
void IO_vInit(void)
{
// USER CODE BEGIN (IO_Init,2)
ubyte i = 0;
// ubyte j = 0;
// USER CODE END
/// ***********************************************************************
/// Note : All peripheral related IO configurations are done in the
/// respective peripheral modules (alternate functions selection)
///
/// If no pins are selected DAvE assumes that registers are in default
/// settings
/// ***********************************************************************
/// -----------------------------------------------------------------------
/// Configuration of Port P0:
/// -----------------------------------------------------------------------
/// P0.0:
/// - is used as general purpose output
/// - push/pull output is selected
/// - the pin status is low level
/// - pull-down device is assigned
/// P0.1:
/// - is used as general purpose output
/// - push/pull output is selected
/// - the pin status is low level
/// - pull-down device is assigned
/// P0.2:
/// - is used as general purpose output
/// - push/pull output is selected
/// - the pin status is low level
/// - pull-down device is assigned
/// P0.3:
/// - is used as general purpose output
/// - push/pull output is selected
/// - the pin status is low level
/// - pull-down device is assigned
/// P0.7:
/// - is used as general purpose output
/// - push/pull output is selected
/// - the pin status is low level
/// - pull-down device is assigned
SFR_PAGE(_pp1, noSST); // switch to page 1
P0_PUDSEL = 0x70; // load pullup/pulldown select register
P0_PUDEN = 0xCF; // load pullup/pulldown enable register
SFR_PAGE(_pp0, noSST); // switch to page 0
P0_DIR = 0x8F; // load direction register
/// -----------------------------------------------------------------------
/// Configuration of Port P1:
/// -----------------------------------------------------------------------
/// P1.0:
/// - is used as alternate input for the MCAN Node 0 Receiver Input
/// - pull-up device is assigned
/// P1.1:
/// - is used as alternate output for the MCAN Node 0 Transmitter Output
/// - push/pull output is selected
/// - pull-up device is assigned
/// P1.2:
/// - is used as general purpose output
/// - push/pull output is selected
/// - the pin status is low level
/// - pull-down device is assigned
/// P1.3:
/// - is used as general purpose output
/// - push/pull output is selected
/// - the pin status is low level
/// - pull-down device is assigned
/// P1.4:
/// - is used as general purpose output
/// - push/pull output is selected
/// - the pin status is low level
/// - pull-down device is assigned
/// P1.5:
/// - is used as general purpose output
/// - push/pull output is selected
/// - the pin status is low level
/// - pull-down device is assigned
/// P1.7:
/// - is used as general purpose output
/// - push/pull output is selected
/// - the pin status is low level
/// - pull-down device is assigned
SFR_PAGE(_pp1, noSST); // switch to page 1
P1_PUDSEL = 0x43; // load pullup/pulldown select register
SFR_PAGE(_pp0, noSST); // switch to page 0
P1_DIR = 0xBC; // load direction register
/// -----------------------------------------------------------------------
/// Configuration of Port P2:
/// -----------------------------------------------------------------------
/// P2.4:
/// - is used as general input
/// - input driver is enabled
/// - pull-up device is assigned
/// P2.5:
/// - is used as general input
/// - input driver is enabled
/// - pull-up device is assigned
/// P2.6:
/// - is used as general input
/// - input driver is enabled
/// - pull-up device is assigned
/// P2.7:
/// - is used as general input
/// - input driver is enabled
/// - pull-up device is assigned
SFR_PAGE(_pp1, noSST); // switch to page 1
P2_PUDEN = 0xF0; // load pullup/pulldown enable register
/// -----------------------------------------------------------------------
/// Configuration of Port P3:
/// -----------------------------------------------------------------------
/// P3.0:
/// - is used as general input
/// - pull-up device is assigned
/// P3.1:
/// - is used as general input
/// - pull-up device is assigned
/// P3.2:
/// - is used as general purpose output
/// - push/pull output is selected
/// - the pin status is low level
/// - pull-down device is assigned
/// P3.3:
/// - is used as general purpose output
/// - push/pull output is selected
/// - the pin status is low level
/// - pull-down device is assigned
/// P3.4:
/// - is used as general purpose output
/// - push/pull output is selected
/// - the pin status is low level
/// - pull-down device is assigned
/// P3.5:
/// - is used as general purpose output
/// - open drain output is selected
/// - the pin status is high level
/// - pull-up device is assigned
/// P3.6:
/// - is used as general input
/// - pull-up device is assigned
/// P3.7:
/// - is used as general input
/// - pull-up device is assigned
SFR_PAGE(_pp3, noSST); // switch to page 3
P3_OD = 0x20; // load open-drain register
SFR_PAGE(_pp1, noSST); // switch to page 1
P3_PUDSEL = 0xE3; // load pullup/pulldown select register
P3_PUDEN = 0xFF; // load pullup/pulldown enable register
SFR_PAGE(_pp0, noSST); // switch to page 0
P3_DIR = 0x3C; // load direction register
P3_DATA = 0x20; // load data output register
/// -----------------------------------------------------------------------
/// Configuration of Port P4:
/// -----------------------------------------------------------------------
/// P4.0:
/// - is used as general purpose output
/// - push/pull output is selected
/// - the pin status is low level
/// - pull-down device is assigned
/// P4.1:
/// - is used as general purpose output
/// - push/pull output is selected
/// - the pin status is low level
/// - pull-down device is assigned
/// P4.3:
/// - is used as general purpose output
/// - push/pull output is selected
/// - the pin status is low level
/// - pull-down device is assigned
SFR_PAGE(_pp1, noSST); // switch to page 1
P4_PUDSEL = 0x00; // load pullup/pulldown select register
P4_PUDEN = 0x0B; // load pullup/pulldown enable register
SFR_PAGE(_pp0, noSST); // switch to page 0
P4_DIR = 0x0B; // load direction register
// USER CODE BEGIN (IO_Init,3)
if((0x55 != RestartDataFlg1) || (0x55 != RestartDataFlg2))//ֻҪ<D6BB><D2AA>һ<EFBFBD><D2BB>ֵ<EFBFBD><D6B5><EFBFBD><EFBFBD>ͬ<EFBFBD><CDAC>˵<EFBFBD><CBB5>Ϊ<EFBFBD>ϵ<EFBFBD><CFB5><EFBFBD><EFBFBD><EFBFBD>
{
for(i=0;i<8;i++)//0xF5E8~0xF5FF
{
UnInfCan_1.ArrData.Arr[0][i] = 0;
UnInfCan_1.ArrData.ArrRX[0][i] = 0;
UnInfCan_1.ArrData.ArrRX[1][i] = 0;
}
RestartDataFlg1 = 0x55;//<2F><><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD><EFBFBD>״̬<D7B4><CCAC><EFBFBD><EFBFBD><EFBFBD><EFBFBD>Ҫ<EFBFBD><D2AA>ֵΪ0x55 0xF5E7
RestartDataFlg2 = 0x55;//<2F><>ַ0xF600
dfOut_01 = 0;//<2F><><EFBFBD><EFBFBD><EFBFBD>ϵ磬<CFB5><E7A3AC>ʼ<EFBFBD><CABC>
dfOut_02 = 0;
dfOut_03 = 0;
dfOut_04 = 0;
dfOut_05 = 0;
dfOut_06 = 0;
dfOut_07 = 0;
dfOut_08 = 0;
dfOut_09 = 0;
dfOut_10 = 0;
dfOut_11 = 0;
dfOut_12 = 0;
dfOut_13 = 0;
dfOut_14 = 0;
dfOut_15 = 0;
dfOut_16 = 0;
RestartDataKGF = 0;
}
else//<2F><><EFBFBD><EFBFBD>,IO<49>ھͻָ<CDBB>
{
dfOut_01 = (bit)(RestartDataKGF&0x0001); //20210906<30>ָ<EFBFBD>IO<49><4F>״̬ <20><><EFBFBD><EFBFBD>KGF<47><46><EFBFBD><EFBFBD>ָʾ<D6B8><CABE><EFBFBD><EFBFBD>˸<EFBFBD><CBB8><EFBFBD><EFBFBD> ע<><D7A2>ubyteתΪbit<69><74><EFBFBD>ͣ<EFBFBD><CDA3><EFBFBD><EFBFBD><EFBFBD>ֱ<EFBFBD><D6B1>ȡ<EFBFBD><C8A1><EFBFBD><EFBFBD>Ϊ<EFBFBD><CEAA><EFBFBD><EFBFBD><EFBFBD>Ǹ<EFBFBD><C7B8>ݸ<EFBFBD>ֵΪ0<CEAA><30>ȡ0<C8A1><30>Ϊ1<CEAA><31>ȡ1
dfOut_02 = (bit)((RestartDataKGF >> 1)&0x0001);
dfOut_03 = (bit)((RestartDataKGF >> 2)&0x0001);
dfOut_04 = (bit)((RestartDataKGF >> 3)&0x0001);
dfOut_05 = (bit)((RestartDataKGF >> 4)&0x0001);
dfOut_06 = (bit)((RestartDataKGF >> 5)&0x0001);
dfOut_07 = (bit)((RestartDataKGF >> 6)&0x0001);
dfOut_08 = (bit)((RestartDataKGF >> 7)&0x0001);
dfOut_09 = (bit)((RestartDataKGF >> 8)&0x0001);
dfOut_10 = (bit)((RestartDataKGF >> 9)&0x0001);
dfOut_11 = (bit)((RestartDataKGF >> 10)&0x0001);
dfOut_12 = (bit)((RestartDataKGF >> 11)&0x0001);
dfOut_13 = (bit)((RestartDataKGF >> 12)&0x0001);
dfOut_14 = (bit)((RestartDataKGF >> 13)&0x0001);
dfOut_15 = (bit)((RestartDataKGF >> 14)&0x0001);
dfOut_16 = (bit)((RestartDataKGF >> 15)&0x0001);
}
// USER CODE END
} // End of function IO_vInit
// USER CODE BEGIN (IO_General,10)
// USER CODE END