This commit is contained in:
2025-10-21 20:34:06 +08:00
commit c3f6375140
55 changed files with 34675 additions and 0 deletions

261
MAIN.C Normal file
View File

@@ -0,0 +1,261 @@
//****************************************************************************
// @Module Project Settings
// @Filename MAIN.C
// @Project CL2.0.dav
//----------------------------------------------------------------------------
// @Controller Infineon XC886CLM-8FF
//
// @Compiler Keil
//
// @Codegenerator 1.3
//
// @Description This file contains the Project initialization function.
//
//----------------------------------------------------------------------------
// @Date 2025/1/18 20:45:29
//
//****************************************************************************
// USER CODE BEGIN (MAIN_General,1)
// USER CODE END
//****************************************************************************
// @Project Includes
//****************************************************************************
#include "MAIN.H"
// USER CODE BEGIN (MAIN_General,2)
// USER CODE END
//****************************************************************************
// @Macros
//****************************************************************************
// USER CODE BEGIN (MAIN_General,3)
// USER CODE END
//****************************************************************************
// @Defines
//****************************************************************************
// USER CODE BEGIN (MAIN_General,4)
// USER CODE END
//****************************************************************************
// @Typedefs
//****************************************************************************
// USER CODE BEGIN (MAIN_General,5)
// USER CODE END
//****************************************************************************
// @Imported Global Variables
//****************************************************************************
// USER CODE BEGIN (MAIN_General,6)
// USER CODE END
//****************************************************************************
// @Global Variables
//****************************************************************************
// USER CODE BEGIN (MAIN_General,7)
// USER CODE END
//****************************************************************************
// @External Prototypes
//****************************************************************************
// USER CODE BEGIN (MAIN_General,8)
// USER CODE END
//****************************************************************************
// @Prototypes Of Local Functions
//****************************************************************************
// USER CODE BEGIN (MAIN_General,9)
// USER CODE END
//****************************************************************************
// @Function void MAIN_vInit(void)
//
//----------------------------------------------------------------------------
// @Description This function initializes the microcontroller. It is
// assumed that the SFRs are in their reset state.
//
//----------------------------------------------------------------------------
// @Returnvalue None
//
//----------------------------------------------------------------------------
// @Parameters None
//
//----------------------------------------------------------------------------
// @Date 2025/1/18
//
//****************************************************************************
// USER CODE BEGIN (MAIN_Init,1)
// USER CODE END
void MAIN_vInit(void)
{
// USER CODE BEGIN (MAIN_Init,2)
// USER CODE END
/// -----------------------------------------------------------------------
/// Configuration of the System Clock:
/// -----------------------------------------------------------------------
/// - External Osc is selected (configuration is done in the startup file
/// 'START_XC.A51')
/// - PLL Mode, NDIV = 24
/// - input frequency is 8 MHz
// FCLK runs at 2 times the frequency of PCLK.
SFR_PAGE(_su1, noSST); // switch to page1
CMCON = 0x10; // load Clock Control Register
SFR_PAGE(_su0, noSST); // switch to page0
/// *********************************************************************************
/// Note : All peripheral related IO configurations are done in the
/// respective peripheral modules (alternate functions selection)
/// *********************************************************************************
/// Initialization of module 'GPIO'
IO_vInit();
/// Initialization of module 'Timer 2'
T2_vInit();
/// Initialization of module 'Watch Dog Timer'
WDT_vInit();
/// Initialization of module 'MultiCAN Controller '
CAN_vInit();
/// Initialization of module 'UART (Serial Interface)'
UART_vInit();
/// Initialization of 'Shared interrupts'
SHINT_vInit();
// Interrupt Priority
IP = 0x00; // load Interrupt Priority Register
IPH = 0x00; // load Interrupt Priority High Register
IP1 = 0x00; // load Interrupt Priority 1 Register
IPH1 = 0x00; // load Interrupt Priority 1 High Register
// USER CODE BEGIN (MAIN_Init,3)
// USER CODE END
//// Interrupt structure 2 mode 0 is selected.
//// Interrupt service routine choice 2 is selected.
// globally enable interrupts
EA = 1;
} // End of function MAIN_vInit
//****************************************************************************
// @Function void main(void)
//
//----------------------------------------------------------------------------
// @Description This is the main function.
//
//----------------------------------------------------------------------------
// @Returnvalue None
//
//----------------------------------------------------------------------------
// @Parameters None
//
//----------------------------------------------------------------------------
// @Date 2025/1/18
//
//****************************************************************************
// USER CODE BEGIN (MAIN_Main,1)
ubyte rxbuf[25] = {0};
// USER CODE END
void main(void)
{
// USER CODE BEGIN (MAIN_Main,2)
// ulong i,j;
// static ubyte tmp[8] = {0};
// for(j=0;j<200;j++){for(i=0;i<133;i++);}
// USER CODE END
MAIN_vInit();
// USER CODE BEGIN (MAIN_Main,3)
SCU_PAGE = 0;
SP = 0xC0; // Initialize Stack Pointer to 0xC0;
// CanTransmit();
// FlgCan_1 = 1;//<2F><>λ<EFBFBD><CEBB><EFBFBD><EFBFBD>ʱһ<CAB1><D2BB>ʱ<EFBFBD><CAB1><EFBFBD>ٵ<EFBFBD><D9B5><EFBFBD>CAN<41><4E><EFBFBD><EFBFBD>
// USER CODE END
while(1)
{
// USER CODE BEGIN (MAIN_Main,4)
// for(j=0;j<200;j++){for(i=0;i<133;i++)WDT_vRefresh();}
// tmp[3] = (ubyte)CntCan_1;
// tmp[2] = (ubyte)(CntCan_1>>8);
// SwSample();
CanRXTX();
sbusCanDecode();
CanErrorProcess();
WDT_vRefresh();
// LedDr();
BootMain();
// tmp[1] = (ubyte)CntCan_1;
// tmp[0] = (ubyte)(CntCan_1>>8);
// CAN_vLoadData(0x2, (ulong *)(tmp)); // Add this Line
// CAN_vTransmit(2);
// for(j=0;j<200;j++){for(i=0;i<133;i++)WDT_vRefresh();}
// USER CODE END
}
} // End of function main
// USER CODE BEGIN (MAIN_General,10)
// USER CODE END