c_candrv-1.2.0

所属分类:嵌入式Linux
开发工具:C/C++
文件大小:143KB
下载次数:19
上传日期:2008-05-31 21:07:55
上 传 者ASang
说明:   HMS30C7202下的CAN驱动,基于LINUX2.6内核。文件中包含驱动源码,以及CAN的测试程序,代码注释详细,对LINUX下的CAN开发可以提供有力的帮助。
(HMS30C7202 under the CAN-driven, based on core LINUX2.6. File contains driver source code, as well as the CAN test procedures, code comment in detail on the development of CAN under LINUX can provide powerful help.)

文件列表:
c_candrv-1.2.0\examples\cantest.c (762, 2003-11-04)
c_candrv-1.2.0\examples\c_can_readburst.c (3535, 2004-08-13)
c_candrv-1.2.0\examples\c_can_sendburst.c (2744, 2004-08-13)
c_candrv-1.2.0\examples\c_can_sendburst2.c (4290, 2004-08-13)
c_candrv-1.2.0\examples\c_can_test.c (4052, 2004-08-13)
c_candrv-1.2.0\examples\c_can_testtool.c (37083, 2004-09-03)
c_candrv-1.2.0\examples\Makefile (412, 2004-09-03)
c_candrv-1.2.0\examples\multi_rb.sh (1208, 2003-11-04)
c_candrv-1.2.0\examples\multi_sb.sh (1399, 2004-08-13)
c_candrv-1.2.0\examples\multi_sbrb.sh (2630, 2004-08-13)
c_candrv-1.2.0\include\can.h (3641, 2004-08-13)
c_candrv-1.2.0\include\candrv.h (11591, 2004-09-03)
c_candrv-1.2.0\include\c_can.h (8046, 2004-08-13)
c_candrv-1.2.0\include\hms30c7202_can.h (931, 2003-11-04)
c_candrv-1.2.0\include\irq.h (380, 2004-08-13)
c_candrv-1.2.0\include\proc.h (201, 2003-11-04)
c_candrv-1.2.0\include\sysdep.h (22472, 2003-11-04)
c_candrv-1.2.0\Makefile (1222, 2004-08-12)
c_candrv-1.2.0\paket\make_paket (412, 2004-09-03)
c_candrv-1.2.0\paket\paket.tgz (33775, 2004-09-03)
c_candrv-1.2.0\Rules.make (2598, 2003-11-04)
c_candrv-1.2.0\src\close.c (3940, 2004-09-03)
c_candrv-1.2.0\src\c_can.c (34300, 2004-09-03)
c_candrv-1.2.0\src\hms30c7202_can.c (10152, 2004-08-13)
c_candrv-1.2.0\src\ioctl.c (8762, 2004-09-03)
c_candrv-1.2.0\src\irq.c (30365, 2004-09-03)
c_candrv-1.2.0\src\main.c (12845, 2004-08-13)
c_candrv-1.2.0\src\open.c (9628, 2004-09-03)
c_candrv-1.2.0\src\proc.c (903, 2003-11-04)
c_candrv-1.2.0\src\read.c (10318, 2004-09-03)
c_candrv-1.2.0\src\write.c (6678, 2004-09-03)
c_candrv-1.2.0\start_can (1777, 2003-11-04)
c_candrv-1.2.0\start_can_timetrig (1801, 2004-08-13)
c_candrv-1.2.0\structures.gif (43224, 2003-11-04)
c_candrv-1.2.0\structures.png (10856, 2003-11-04)
c_candrv-1.2.0\examples (0, 2008-05-31)
c_candrv-1.2.0\include (0, 2008-05-31)
c_candrv-1.2.0\paket (0, 2008-05-31)
c_candrv-1.2.0\src (0, 2008-05-31)
... ...

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);

近期下载者

相关文件


收藏者