📄 remote_receive.c
字号:
/*""FILE COMMENT""***************************************************** * M32R C Programming Rev. 1.00 * < Sample Program for CAN remote_receive > * * Copyright (c) 2003 Renesas Technology Corporation * And Renesas Solutions Corporation * All Rights Reserved *********************************************************************//************************************************************************//* Include file *//************************************************************************/#include "..\inc\sfr32170_pragma.h"/************************************************************************//* Function prototype declaration *//************************************************************************/ void main(void); void remote_receive(void);extern void can_init(void);/*""FUNC COMMENT""******************************************************* * Function name: void main(void) *----------------------------------------------------------------------- * Description : Remote frame reception sample program *----------------------------------------------------------------------- * Argument : - *----------------------------------------------------------------------- * Returns : - *----------------------------------------------------------------------- * Notes : *""FUNC COMMENT END""***************************************************/void main(void){ /* Initialize CAN module */ can_init(); /* Set data to be automatically sent as answer for remote frame */ C0MSL0DT0 = 0x01; C0MSL0DT1 = 0x23; C0MSL0DT2 = 0x45; C0MSL0DT3 = 0x67; C0MSL0DT4 = 0x89; C0MSL0DT5 = 0xab; C0MSL0DT6 = 0xcd; C0MSL0DT7 = 0xef; /* CAN module operation */ remote_receive(); while( 1 ) ;}/*""FUNC COMMENT""******************************************************* * Function name: void remote_receive(void) *----------------------------------------------------------------------- * Description : Receive remote frame in slot 0 *----------------------------------------------------------------------- * Argument : - *----------------------------------------------------------------------- * Returns : - *----------------------------------------------------------------------- * Notes : *""FUNC COMMENT END""***************************************************/void remote_receive(void){ C0MSL0CNT = 0x00; /* Initialize CAN message slot control register */ while ( ( C0MSL0CNT & TRSTAT) != 0) /* Verify that transmit operation is idle */ ; /* Set ID and DLC in message slot 0 */ C0MSL0SID0 = 0x00; /* ID : 0 */ C0MSL0SID1 = 0x00; /* Set extended ID register */ CAN0EXTID = 0x0000; /* Select standard format */ /* Set CAN message slot control register */ C0MSL0CNT = 0x60; /* Request reception of remote frame (with automatic answer) */ /* * Because ID mask register is set within can_init() for "all bits to be checked, * " slot 0 receives only remote frames in standard format with ID:0. * As a result of remote frame reception, ID and DLC of slot 0 are overwritten with the content of the * received frame. */}
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -