📄 main.c
字号:
/*******************************************************************************/
/*
Copyright (c) 2008 Freescale Semiconductor
\file main.c
\brief DZ60 - CAN sample code
\author Freescale Semiconductor
\author B05114
\version 0.1
\date January/2008
*/
/*******************************************************************************/
/* Derivative peripheral declarations */
#include "derivative.h"
#include <hidef.h>
/* DZ60 initialization functions */
#include "DZ60_init.h"
/* MSCAN definitions */
#include "MSCAN.h"
/* Definitions and function prototypes for CAN messages handling */
#include "CAN_handler.h"
/* TPM1 overflow interrupt service routine */
interrupt void TPM1_ISR(void);
/* Global timebase, reported status selector */
unsigned char TPMFlag;
unsigned char timebaseFlag;
/* Scheduler periods */
#define PERIOD_1 1
#define PERIOD_2 3
#define PERIOD_3 5
/*****************************************************************************/
void main( void )
{
/* Generate 10ms delay to ensure, that board power supply is in limits */
MCG_Init(); /* Clock Generator initialization */
GPIO_Init(); /* GPIO configuration */
TPM1_Init(); /* Real time counter initialization */
MSCAN_Init(); /* MSCAN module initialization */
EnableInterrupts; /* Enable interrupts */
while(1)
{
if(TPMFlag == 1)
{
TPMFlag = 0;
// Update system timebase
timebaseFlag++;
if(timebaseFlag >= (PERIOD_3+1))
{
timebaseFlag = 1;
}
}
// Select currently processed tasks based on the time schedule
switch(timebaseFlag)
{
case PERIOD_1:
{
timebaseFlag++; /* Update system timebase */
Send_CAN_Msg();
break;
}
case PERIOD_2:
{
timebaseFlag++; /* Update system timebase */
break;
}
case PERIOD_3:
{
timebaseFlag++; /* Update system timebase */
Read_CAN_Buffer();
break;
}
}
}
}
/*****************************************************************************/
/*
* \brief TPM1 overflow interrupt service routine
* \author B05114
*/
interrupt void TPM1_ISR(void)
{
static char PB_status = 0;
(void)TPM1SC; /* Read TPM status register */
TPM1SC_TOF = 0; /* and clear interrupt flag */
TPMFlag = 1;
}
/*******************************************************************************/
/*******************************************************************************/
/* */
/* All software, source code, included documentation, and any implied know-how */
/* are property of Freescale Semiconductor and therefore considered */
/* CONFIDENTIAL INFORMATION. */
/* */
/* This confidential information is disclosed FOR DEMONSTRATION PURPOSES ONLY. */
/* */
/* All Confidential Information remains the property of Freescale Semiconductor*/
/* and will not be copied or reproduced without the express written permission */
/* of the Discloser, except for copies that are absolutely necessary in order */
/* to fulfill the Purpose. */
/* */
/* Services performed by FREESCALE in this matter are performed AS IS and */
/* without any warranty. CUSTOMER retains the final decision relative to the */
/* total design and functionality of the end product. */
/* */
/* FREESCALE neither guarantees nor will be held liable by CUSTOMER for the */
/* success of this project. */
/* */
/* FREESCALE disclaims all warranties, express, implied or statutory including,*/
/* but not limited to, implied warranty of merchantability or fitness for a */
/* particular purpose on any hardware, software ore advise supplied to the */
/* project by FREESCALE, and or any product resulting from FREESCALE services. */
/* */
/* In no event shall FREESCALE be liable for incidental or consequential */
/* damages arising out of this agreement. CUSTOMER agrees to hold FREESCALE */
/* harmless against any and all claims demands or actions by anyone on account */
/* of any damage,or injury, whether commercial, contractual, or tortuous, */
/* rising directly or indirectly as a result of the advise or assistance */
/* supplied CUSTOMER in connectionwith product, services or goods supplied */
/* under this Agreement. */
/* */
/*******************************************************************************/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -