📄 main.c
字号:
/*****************************************************************************
** **
** Name: main.c **
** **
** Comments: This routine is the CAN Receiver sample code, intended to **
** be used for CAN hardware test purposes and to show how to **
** perform simple transmit/receive functionality over CAN. **
** RX board executes a scrolling right LED by default, but **
** will change the display based on commands coming over CAN, **
** causing software flags to be set and cleared. **
** **
*****************************************************************************/
#include "CAN_RX.h"
/* Global Data */
char blink = 0; /* Display Select (1=blink, 0=scroll) */
char scroll = 0; /* LED Scroll Direction (1=left, 0=right) */
char change = 0; /* Change Display Flag (1=Changed, 0=Same) */
char off = 0; /* Clear Display (1=Clear, 0=Not) */
short display; /* LED Display Value */
volatile unsigned int delay = 0x400000; /* Delay Value for Blink Rate */
main()
{
Init_PLL(); /* Set PLL */
Init_Port(); /* Initialize Ports */
Init_Interrupts(); /* Initialize Interrupts */
Init_CAN_Timing(); /* Setup CAN Timing */
Init_CAN_Mailboxes(); /* Initialize CAN Mailbox Area */
CAN_Setup_Interrupts(); /* Configure CAN Mailbox Interrupts */
CAN_Enable(); /* Enable CAN */
/* Initial Setting Is Scroll Right */
display = 0x0800; /* Light Only LED6 */
while(1) /* wait for IRQs */
{
*pPORTFIO = display; /* write display */
while(delay--); /* wait */
delay = 0x400000; /* reset delay */
if (off) /* if OFF flag is set */
display = 0x0000; /* turn LEDs Off */
else if (blink) /* else if blink flag is set */
display = ~display; /* toggle display */
else /* else it is scrolling */
{
if (change) /* if mode changed to scroll */
{ /* we must initialize LED position */
if (scroll) /* if scrolling left */
display = 0x0020; /* initialize position far right */
else /* otherwise scrolling right */
display = 0x1000; /* initialize position far left */
change=0; /* clear CHANGE flag */
}
if (scroll) /* if scrolling left */
{
if ((display <<= 1) == 0x1000) /* scroll/check overflow */
display = 0x0040; /* reset to rightmost LED */
}
else /* otherwise scrolling right */
{
if ((display >>= 1) == 0x0020) /* scroll/check overflow */
display = 0x0800; /* reset to leftmost LED */
}
}
} /* end while forever */
} /* end main */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -