Functions | |
| int | can_Command (struct inode *inode, struct file *file, Command_par_t *argp) |
| int | can_Send (struct inode *inode, canmsg_t *Tx) |
| int | can_GetStat (struct inode *inode, struct file *file, CanStatusPar_t *s) |
| int | can_Config (struct inode *inode, struct file *file, int target, unsigned long val1, unsigned long val2) |
| int | can_ioctl (__LDDK_IOCTL_PARAM) |
| int ioctl(int fd, int request, . | |
| int can_ioctl | ( | __LDDK_IOCTL_PARAM | ) |
int ioctl(int fd, int request, .
..); the CAN controllers io-control interface
| fd | The descriptor to change properties
|
CAN_IOCTL_COMMAND some commands for start, stop and reset the CAN controller chip CAN_IOCTL_CONFIG configure some of the device properties like acceptance filtering, bit timings, mode of the output control register or the optional software message filter configuration(not implemented yet). CAN_IOCTL_STATUS request the CAN controllers status CAN_IOCTL_SEND a single message over the ioctl interface CAN_IOCTL_RECEIVE poll a receive message CAN_IOCTL_CONFIGURERTR configure automatic rtr responses(not implemented)struct Command_par struct Config_par struct CanStatusPar struct ConfigureRTR_par struct Receive_par struct Send_par
The following commands are available
CMD_START calls the target specific CAN_StartChip function. This normally clears all pending interrupts, enables interrupts and starts the CAN controller by releasing the RESET bit. CMD_STOP calls the target specific CAN_StopChip function. This sets only the RESET bit of the CAN controller which will stop working. CMD_RESET calls the target specific CAN_ChipReset function. This command also sets the RESET bit of the CAN controller, but additionally initializes CAN bit timing the output control register and acceptance and mask registers. The CAN controller itself stays in the RESET mode until CMD_START is called. CMD_CLEARBUFFERS clears/empties both the RX fifo of the associated process and the one and only global TX fifo.CMD_STOP CMD_CLEARBUFFERS CMD_RESET CMD_START AccCode and AccMask are used like specified in the controllers manual for Single Filter Configuration . Both are 4 byte entries. In the case of using standard identifiers for receiving CAN messages also all 4 bytes can be used. In this case two bytes are used for acceptance code and mask for all 11 identifier bits plus additional the first two data bytes. The SJA1000 is working in the Single Filter \ Mode . Bits
mask 31 30 ..... 4 3 2 1 0
code
-------------------------------------------
ID 28 27 ..... 1 0 R +--+-> unused
T
R
acccode = (id << 3) + (rtr << 2)
Example for base message format
Bits
mask 31 30 ..... 23 22 21 20 ... 0
code
-------------------------------------------
ID 11 10 ..... 1 0 R +--+-> unused
T
R
You have to shift the CAN-ID by 5 bits and two bytes to shift them into ACR0 and ACR1 (acceptance code register)
acccode = (id << 21) + (rtr << 20)
Config_par_t cfg; volatile Command_par_t cmd; cmd.cmd = CMD_STOP; ioctl(can_fd, CAN_IOCTL_COMMAND, &cmd); cfg.target = CONF_ACCM; cfg.val = acc_mask; ioctl(can_fd, CAN_IOCTL_CONFIG, &cfg); cfg.target = CONF_ACCC; cfg.val = acc_code; ioctl(can_fd, CAN_IOCTL_CONFIG, &cfg); cmd.cmd = CMD_START; ioctl(can_fd, CAN_IOCTL_COMMAND, &cmd);
CONF_TIMING and fixed values in Kbit/s. In this case ioctl(can_fd, CAN_IOCTL_CONFIG, &cfg); is used with configuration target CONF_BTR The configuration structure contains two values, val1 and val2 . The following relation to the bit timing registers is used regarding the CAN controller:
CONF_LISTEN_ONLY_MODE if set switch to listen only mode (default false) CONF_SELF_RECEPTION if set place sent messages back in the rx queue (default false) CONF_BTR configure bit timing registers directly CONF_TIMESTAMP if set fill time stamp value in message structure (default true) CONF_WAKEUP if set wake up waiting processes (default true)
service@port.de ,
© 1997-2011