⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 readme

📁 HMS30C7202下的CAN驱动
💻
字号:


Each message object can be accessed through an own minor
number.
The script "start_can" creates the needed device-files
in the "/dev" path and loads the driver for both chips with
baudrate=1000baud.

>>>WRITE<<<
To write through an message object just open the according
device-file and save the returned filedescriptor:
   fd=open(can0file,O_RDWR)
Then call the write command:
   write(fd, &smessage, sizeof(struct canmsg_t))

&message is the address of the "canmsg_t" structure
(included from can.h) wich should be send.

>>>READ<<<
To read through a message object open it.
Then set it into reception mode. Therefore the Arbitrationmask
needs to set. After that all incoming messages with the same
mask will be received by this message object and stored in its
buffer.
   ioctl( fd, IOCTL_CAN_SET_READ_MODE, arbmask )

In addition to that it is possible set a filter mask.
	ioctl( fd, IOCTL_CAN_SET_FILTER, filter);
Then acceptance filtering works in another way.
A message is accepted when its arbitration bits are equal to the
arbitration bits of the message object at the positions specified
through the filter mask.
Example:
      msg. obj. arbitration : 01000111011
      msg. obj. filtermask  : 00001100000

      accepted messages     : ****01*****
Filtering is disabled through the call of
	ioctl( fd, IOCTL_CAN_DISABLE_FILTER )

To read from the buffer just call the read method.
   read(fd, &message, sizeof(struct canmsg_t))
Again &message is an address to a "canmsg_t" structure. But this
time the received message will be written to this structure.

>>>LOAD MODULE<<<
Following options are available to be used with the insmod command.

	hw  		- Tells the module which chip(s) it will work with. This
				  Version supports the C-CAN chip of the Hynix
				  HMS30C7202 processor only (hms30c7202_can).
		        example:
				   "hw=hms30c7202_can"
					for both chips
		   		"hw=hms30c7202_can,hms30c7202_can"

	io  		- Defines the first address of the IO-Memory-Area.
				  example:
				  	"io=0x8002f000"
		   		"io=0x8002f000,0x80030000"

	irq 		- Defines the interrupts.
				  example:
				   "irq=0x12"
					"irq=0x12,0x13"

	baudrate - The baudrate the chips will be initialized with.
				  It can be changed for every chip with the
				  "ioctl( fd, IOCTL_CAN_SET_BAUDRATE, baudrate)"
				  command of one of its message objects.
				  example:
				  	"baudrate=1000"
					"baudrate=1000,1000"

	extended - Flag which switches all Message Objects of the chip
				  to extended mode operation. In extended mode 29-bit
				  arbitration and filter are used (instead of 11-bit).
				  example:
				  	for standart mode
					"extended=0" or just write nothing (default)
					for extendet mode
					"extended=1"
					"extended=1,1"

	major		- Changes the Major number the module will work with.
				  It is set to 91 by default and should not be changed.
				  ([include]/linux/Documentation/devices.txt)
				  example:
				  	"major=91"

>>>IO-CONTROL<<<
A list of all available ioctl-calls can be found in "include/can.h".

With IOCTL_CAN_GET_STATISTICS each member of the "canstatistics_t"
structure can be requested individually. The argument of this function
is a pointer to a 32-bit value. This value indicates which member of
"canstatistics_t" should be returned. (0 for cntRxPkt, 1 for cntRxData,
etc.)
example:
	int busoffcount;
	int i = STAT_BUSOFF;  //to get "cntBusOff"
	busoffcount = ioctl( fd, IOCTL_CAN_GET_STATISTICS, &i);


⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -