truck-code
|
Go to the source code of this file.
Classes | |
union | frame |
struct | canregs |
struct | CanStatusPar |
struct | inode |
struct | _instance_data |
struct | file |
Macros | |
#define | INCLUDE_CAN_SJA1000_H_ |
#define | SJA1000_MAP_SIZE 128 |
#define | CAN_RANGE 0x20 /* default: 32 registers */ |
#define | CAN_SLEEP_MODE 0x10 |
#define | CAN_ACC_FILT_MASK 0x08 |
#define | CAN_SELF_TEST_MODE 0x04 |
#define | CAN_LISTEN_ONLY_MODE 0x02 |
#define | CAN_RESET_REQUEST 0x01 |
#define | CAN_MODE_DEF CAN_ACC_FILT_MASK |
#define | CAN_ERROR_BUSOFF_INT_ENABLE (1<<7) |
#define | CAN_ARBITR_LOST_INT_ENABLE (1<<6) |
#define | CAN_ERROR_PASSIVE_INT_ENABLE (1<<5) |
#define | CAN_WAKEUP_INT_ENABLE (1<<4) |
#define | CAN_OVERRUN_INT_ENABLE (1<<3) |
#define | CAN_ERROR_INT_ENABLE (1<<2) |
#define | CAN_TRANSMIT_INT_ENABLE (1<<1) |
#define | CAN_RECEIVE_INT_ENABLE (1<<0) |
#define | CAN_EFF 0x80 |
#define | CAN_SFF 0x00 |
#define | CAN_GOTO_SLEEP (1<<4) |
#define | CAN_CLEAR_OVERRUN_STATUS (1<<3) |
#define | CAN_RELEASE_RECEIVE_BUFFER (1<<2) |
#define | CAN_ABORT_TRANSMISSION (1<<1) |
#define | CAN_TRANSMISSION_REQUEST (1<<0) |
#define | CAN_BUS_STATUS (1<<7) |
#define | CAN_ERROR_STATUS (1<<6) |
#define | CAN_TRANSMIT_STATUS (1<<5) |
#define | CAN_RECEIVE_STATUS (1<<4) |
#define | CAN_TRANSMISSION_COMPLETE_STATUS (1<<3) |
#define | CAN_TRANSMIT_BUFFER_ACCESS (1<<2) |
#define | CAN_DATA_OVERRUN (1<<1) |
#define | CAN_RECEIVE_BUFFER_STATUS (1<<0) |
#define | CAN_WAKEUP_INT (1<<4) |
#define | CAN_OVERRUN_INT (1<<3) |
#define | CAN_ERROR_INT (1<<2) |
#define | CAN_TRANSMIT_INT (1<<1) |
#define | CAN_RECEIVE_INT (1<<0) |
#define | CAN_OCTP1 (1<<7) |
#define | CAN_OCTN1 (1<<6) |
#define | CAN_OCPOL1 (1<<5) |
#define | CAN_OCTP0 (1<<4) |
#define | CAN_OCTN0 (1<<3) |
#define | CAN_OCPOL0 (1<<2) |
#define | CAN_OCMODE1 (1<<1) |
#define | CAN_OCMODE0 (1<<0) |
#define | CAN_MODE_BASICCAN (0x00) |
#define | CAN_MODE_PELICAN (0xC0) |
#define | CAN_MODE_CLK1 (0x07) |
#define | CAN_MODE_CLK2 (0x00) |
#define | CAN_MODE_CLK CAN_MODE_CLK2 |
#define | CAN_RTR (1<<6) |
#define | CAN_TIM0_10K 49 |
#define | CAN_TIM1_10K 0x1c |
#define | CAN_TIM0_20K 24 |
#define | CAN_TIM1_20K 0x1c |
#define | CAN_TIM0_40K 0x89 |
#define | CAN_TIM1_40K 0xEB |
#define | CAN_TIM0_50K 9 |
#define | CAN_TIM1_50K 0x1c |
#define | CAN_TIM0_100K 4 |
#define | CAN_TIM1_100K 0x1c |
#define | CAN_TIM0_125K 3 |
#define | CAN_TIM1_125K 0x1c |
#define | CAN_TIM0_250K 1 |
#define | CAN_TIM1_250K 0x1c |
#define | CAN_TIM0_500K 0 |
#define | CAN_TIM1_500K 0x1c |
#define | CAN_TIM0_800K 0 |
#define | CAN_TIM1_800K 0x16 |
#define | CAN_TIM0_1000K 0 |
#define | CAN_TIM1_1000K 0x14 |
#define | MAX_CHANNELS 1 |
#define | MY_CHANNEL 0 |
#define | DBGprint(ms, ar) { } |
#define | DBGin() { } |
#define | DBGout() { } |
#define | DEBUG_TTY(n, args...) |
#define | MSG_ACTIVE (0) |
#define | MSG_BASE (0) |
#define | MSG_RTR (1<<0) |
#define | MSG_OVR (1<<1) |
#define | MSG_EXT (1<<2) |
#define | MSG_SELF (1<<3) |
#define | MSG_PASSIVE (1<<4) |
#define | MSG_BUSOFF (1<<5) |
#define | MSG_WARNING (1<<6) |
#define | MSG_BOVR (1<<7) |
#define | MSG_ERR_MASK (MSG_OVR+MSG_PASSIVE+MSG_BUSOFF+MSG_BOVR+MSG_WARNING) |
#define | CAN_SFF_MASK 0x000007FFU |
#define | CAN_EFF_MASK 0x1FFFFFFFU |
#define | CANDRIVERERROR 0xFFFFFFFFul |
#define | LINUX_VERSION_CODE 1 |
#define | KERNEL_VERSION(X, Y, Z) 0 |
#define | IRQ_NONE 0 |
#define | IRQ_HANDLED 1 |
#define | IRQ_RETVAL(x) (x) |
#define | CANin(bd, adr) can_read_reg(&can_base_addr->adr) |
#define | CANout(bd, adr, v) can_write_reg(&can_base_addr->adr, v) |
#define | CANset(bd, adr, m) can_set_reg(&can_base_addr->adr, m) |
#define | CANreset(bd, adr, m) can_reset_reg(&can_base_addr->adr, m) |
#define | R_OFF 1 |
Typedefs | |
typedef struct CanStatusPar | CanStatusPar_t |
typedef int | irqreturn_t |
Functions | |
struct canregs | __attribute__ ((packed)) canregs_t |
Variables | |
BYTE | canmode |
BYTE | cancmd |
BYTE | canstat |
BYTE | canirq |
BYTE | canirq_enable |
BYTE | reserved1 |
BYTE | cantim0 |
BYTE | cantim1 |
BYTE | canoutc |
BYTE | cantest |
BYTE | reserved2 |
BYTE | arbitrationlost |
BYTE | errorcode |
BYTE | errorwarninglimit |
BYTE | rxerror |
BYTE | txerror |
BYTE | frameinfo |
union frame | frame |
BYTE | reserved3 |
BYTE | canrxbufferadr |
BYTE | canclk |
unsigned int | dbgMask |
canregs_t * | can_base_addr |
This includes device-dependent CAN definitions for the Phillips SJA 1000 driver. Assumes board is memory mapped at address given during initialization.
#define CAN_ABORT_TRANSMISSION (1<<1) |
bit 1 in Command Register (see include/can/sja1000.h for details)
#define CAN_ACC_FILT_MASK 0x08 |
Acceptance Filter Mask
#define CAN_ARBITR_LOST_INT_ENABLE (1<<6) |
bit 6 in Interrupt Enable Register (see include/can/sja1000.h for details)
#define CAN_BUS_STATUS (1<<7) |
bit 7 in Status Register (see include/can/sja1000.h for details)
#define CAN_CLEAR_OVERRUN_STATUS (1<<3) |
bit 3 in Command Register (see include/can/sja1000.h for details)
#define CAN_DATA_OVERRUN (1<<1) |
bit 1 in Status Register (see include/can/sja1000.h for details)
#define CAN_EFF 0x80 |
extended frame
#define CAN_EFF_MASK 0x1FFFFFFFU |
Extended Frame Format (EFF)
#define CAN_ERROR_BUSOFF_INT_ENABLE (1<<7) |
bit 7 in Interrupt Enable Register (see include/can/sja1000.h for details)
#define CAN_ERROR_INT (1<<2) |
bit 2 in Interrupt Register (see include/can/sja1000.h for details)
#define CAN_ERROR_INT_ENABLE (1<<2) |
bit 2 in Interrupt Enable Register (see include/can/sja1000.h for details)
#define CAN_ERROR_PASSIVE_INT_ENABLE (1<<5) |
bit 5 in Interrupt Enable Register (see include/can/sja1000.h for details)
#define CAN_ERROR_STATUS (1<<6) |
bit 6 in Status Register (see include/can/sja1000.h for details)
#define CAN_GOTO_SLEEP (1<<4) |
bit 4 in Command Register (see include/can/sja1000.h for details)
#define CAN_LISTEN_ONLY_MODE 0x02 |
Listen only mode
#define CAN_MODE_BASICCAN (0x00) |
Specifies BasicCAN Mode
#define CAN_MODE_CLK CAN_MODE_CLK2 |
On the Janus-MM board the correct CLKout is Fclk/2
#define CAN_MODE_CLK1 (0x07) |
CLK-out = Fclk
#define CAN_MODE_CLK2 (0x00) |
CLK-out = Fclk/2
#define CAN_MODE_DEF CAN_ACC_FILT_MASK |
Default ModeRegister Value
#define CAN_MODE_PELICAN (0xC0) |
Specifies Pelican Mode
#define CAN_OCMODE0 (1<<0) |
bit 1 in Output Control Register (see include/can/sja1000.h for details)
#define CAN_OCMODE1 (1<<1) |
bit 2 in Output Control Register (see include/can/sja1000.h for details)
#define CAN_OCPOL0 (1<<2) |
bit 3 in Output Control Register (see include/can/sja1000.h for details)
#define CAN_OCPOL1 (1<<5) |
bit 6 in Output Control Register (see include/can/sja1000.h for details)
#define CAN_OCTN0 (1<<3) |
bit 4 in Output Control Register (see include/can/sja1000.h for details)
#define CAN_OCTN1 (1<<6) |
bit 7 in Output Control Register (see include/can/sja1000.h for details)
#define CAN_OCTP0 (1<<4) |
bit 5 in Output Control Register (see include/can/sja1000.h for details)
#define CAN_OCTP1 (1<<7) |
bit 8 in Output Control Register (see include/can/sja1000.h for details)
#define CAN_OVERRUN_INT (1<<3) |
bit 3 in Interrupt Register (see include/can/sja1000.h for details)
#define CAN_OVERRUN_INT_ENABLE (1<<3) |
bit 3 in Interrupt Enable Register (see include/can/sja1000.h for details)
#define CAN_RECEIVE_BUFFER_STATUS (1<<0) |
bit 0 in Status Register (see include/can/sja1000.h for details)
#define CAN_RECEIVE_INT (1<<0) |
bit 0 in Interrupt Register (see include/can/sja1000.h for details)
#define CAN_RECEIVE_INT_ENABLE (1<<0) |
bit 0 in Interrupt Enable Register (see include/can/sja1000.h for details)
#define CAN_RECEIVE_STATUS (1<<4) |
bit 4 in Status Register (see include/can/sja1000.h for details)
#define CAN_RELEASE_RECEIVE_BUFFER (1<<2) |
bit 2 in Command Register (see include/can/sja1000.h for details)
#define CAN_RESET_REQUEST 0x01 |
Reset mode
#define CAN_RTR (1<<6) |
— Remote Request ------------------------------------------------------—
Notes:
#define CAN_SELF_TEST_MODE 0x04 |
Self test mode
#define CAN_SFF 0x00 |
standard fame format
#define CAN_SFF_MASK 0x000007FFU |
Standard Frame Format (SFF)
#define CAN_SLEEP_MODE 0x10 |
Sleep Mode
#define CAN_TIM0_1000K 0 |
BTR0 value for timing of 1000 kHz
#define CAN_TIM0_100K 4 |
BTR0 value for timing of 100 kHz
#define CAN_TIM0_10K 49 |
BTR0 value for timing of 10 kHz
#define CAN_TIM0_125K 3 |
BTR0 value for timing of 125 kHz
#define CAN_TIM0_20K 24 |
BTR0 value for timing of 20 kHz
#define CAN_TIM0_250K 1 |
BTR0 value for timing of 250 kHz
#define CAN_TIM0_40K 0x89 |
BTR0 value for timing of 40 kHz
#define CAN_TIM0_500K 0 |
BTR0 value for timing of 500 kHz
#define CAN_TIM0_50K 9 |
BTR0 value for timing of 50 kHz
#define CAN_TIM0_800K 0 |
BTR0 value for timing of 800 kHz
#define CAN_TIM1_1000K 0x14 |
BTR1 value for timing of 1000 kHz
#define CAN_TIM1_100K 0x1c |
BTR1 value for timing of 100 kHz
#define CAN_TIM1_10K 0x1c |
BTR1 value for timing of 10 kHz
#define CAN_TIM1_125K 0x1c |
BTR1 value for timing of 125 kHz
#define CAN_TIM1_20K 0x1c |
BTR1 value for timing of 20 kHz
#define CAN_TIM1_250K 0x1c |
BTR1 value for timing of 250 kHz
#define CAN_TIM1_40K 0xEB |
BTR1 value for timing of 40 kHz
#define CAN_TIM1_500K 0x1c |
BTR1 value for timing of 500 kHz
#define CAN_TIM1_50K 0x1c |
BTR1 value for timing of 50 kHz
#define CAN_TIM1_800K 0x16 |
BTR1 value for timing of 800 kHz
#define CAN_TRANSMISSION_COMPLETE_STATUS (1<<3) |
bit 3 in Status Register (see include/can/sja1000.h for details)
#define CAN_TRANSMISSION_REQUEST (1<<0) |
bit 0 in Command Register (see include/can/sja1000.h for details)
#define CAN_TRANSMIT_BUFFER_ACCESS (1<<2) |
bit 2 in Status Register (see include/can/sja1000.h for details)
#define CAN_TRANSMIT_INT (1<<1) |
bit 1 in Interrupt Register (see include/can/sja1000.h for details)
#define CAN_TRANSMIT_INT_ENABLE (1<<1) |
bit 1 in Interrupt Enable Register (see include/can/sja1000.h for details)
#define CAN_TRANSMIT_STATUS (1<<5) |
bit 5 in Status Register (see include/can/sja1000.h for details)
#define CAN_WAKEUP_INT (1<<4) |
bit 4 in Interrupt Register (see include/can/sja1000.h for details)
#define CAN_WAKEUP_INT_ENABLE (1<<4) |
bit 4 in Interrupt Enable Register (see include/can/sja1000.h for details)
#define CANDRIVERERROR 0xFFFFFFFFul |
Invalid CAN ID == Error
#define DBGprint | ( | ms, | |
ar | |||
) | { } |
Fancy leveled debugging not really needed in simpler QNX driver environment.
#define MSG_ACTIVE (0) |
Controller Error Active
#define MSG_BASE (0) |
Base Frame Format
#define MSG_BOVR (1<<7) |
receive/transmit buffer overflow
#define MSG_BUSOFF (1<<5) |
controller Bus Off
#define MSG_ERR_MASK (MSG_OVR+MSG_PASSIVE+MSG_BUSOFF+MSG_BOVR+MSG_WARNING) |
mask used for detecting CAN errors in the canmsg_t flags field
#define MSG_EXT (1<<2) |
extended message format
#define MSG_OVR (1<<1) |
CAN controller Msg overflow error
#define MSG_PASSIVE (1<<4) |
controller in error passive
#define MSG_RTR (1<<0) |
RTR Message
#define MSG_SELF (1<<3) |
message received from own tx
#define MSG_WARNING (1<<6) |
CAN Warning Level reached
#define SJA1000_MAP_SIZE 128 |
TODO
typedef struct CanStatusPar CanStatusPar_t |
IOCTL generic CAN controller status request parameter structure
struct canregs __attribute__ | ( | (packed) | ) |
PeliCAN address allocation for the CAN controller.
Each address denotes the location of a byte, whose elements are later described throughout this file. The addresses are in incrementing order starting from canmode (address=0) to canclk (address=31).
BYTE arbitrationlost |
11: arbitration lost capture only
canregs_t* can_base_addr |
This must be initialized to the mapped address of the CAN channel.
BYTE canclk |
31: clock divider
BYTE cancmd |
1: command register
BYTE canirq |
3: interrupt register
BYTE canirq_enable |
4: interrupt enable register
BYTE canmode |
0: mode register
BYTE canoutc |
8: output control register
BYTE canrxbufferadr |
30: RX buffer start address (read only)
BYTE canstat |
2: status register
BYTE cantest |
9: command register
BYTE cantim0 |
6: bus timing 0 register
BYTE cantim1 |
7: bus timing 1 register
BYTE errorcode |
12: error code capture (read only)
BYTE errorwarninglimit |
13: error warning limit register
BYTE frameinfo |
TODO
BYTE reserved1 |
5: reserved register (read only)
BYTE reserved2 |
10: reserved register (read only)
BYTE reserved3 |
29: RX message counter (read only)
BYTE rxerror |
14: RX error counter
BYTE txerror |
15: RX error counter