X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/blobdiff_plain/45b3ad9101e4e75af54e2d3bc25be419d3df7224..7d282b5f3c17776f056dbe3f1530403c829de17b:/embedded/app/usbcan/can/lpc17xx_can.h diff --git a/embedded/app/usbcan/can/lpc17xx_can.h b/embedded/app/usbcan/can/lpc17xx_can.h index bd2d1e5..4e50be1 100644 --- a/embedded/app/usbcan/can/lpc17xx_can.h +++ b/embedded/app/usbcan/can/lpc17xx_can.h @@ -14,11 +14,12 @@ extern "C" { #endif - +// CAN1, CAN2 and CAN Acceptance filter base addresses #define CAN1_REGS_BASE 0x40044000UL #define CAN2_REGS_BASE 0x40048000UL #define CANAF_REGS_BASE 0x4003C000UL +// offset of CAN registers #define CAN_MOD_o 0x0000 #define CAN_CMR_o 0x0004 #define CAN_GSR_o 0x0008 @@ -44,7 +45,7 @@ extern "C" #define CAN_TDA3_o 0x0058 #define CAN_TDB3_o 0x005C - +// offset of CAN Acceptance filter registers #define CANAF_AFMR_o 0x0000 #define CANAF_SFF_sa_o 0x0004 #define CANAF_SFF_GRP_sa_o 0x0008 @@ -106,7 +107,8 @@ extern "C" //CAN Status Register bits #define CAN_SR_RBS (1<<0) #define CAN_SR_DOS (1<<1) -#define CAN_SR_TBS1 (1<<2) +#define CAN_SR_TBS1 (1<<2) +#define CAN_SR_TCS1 (1<<3) //CAN Command Register bits #define CAN_CMR_TR (1<<0) @@ -145,19 +147,40 @@ extern "C" // CAN1_RX_BIT a CAN1_TX_BIT jiz definovany v system_def.h +//---------------------------------- + +#define MAX_TRANSMIT_WAIT_LOOPS 20 void CAN_init(struct canchip_t *chip); void CAN_send(struct canchip_t *chip, canmsg_t* msg); void CAN_recv(struct canchip_t *chip, canmsg_t* msg); -void CAN_IRQHandler(void); -//---------------------------------- + +/* + * CAN harware-dependent bit-timing constant + * + * Used for calculating and checking bit-timing parameters + */ + +struct can_bittiming_const { + char name[16]; /* Name of the CAN controller hardware */ + uint32_t tseg1_min; /* Time segement 1 = prop_seg + phase_seg1 */ + uint32_t tseg1_max; + uint32_t tseg2_min; /* Time segement 2 = phase_seg2 */ + uint32_t tseg2_max; + uint32_t sjw_max; /* Synchronisation jump width */ + uint32_t brp_min; /* Bit-rate prescaler */ + uint32_t brp_max; + uint32_t brp_inc; +}; struct can_lmc1_chip_data { int flags; + struct can_bittiming_const btc; }; + // board can-lmc1 specific functions: int can_lmc1_register(struct hwspecops_t *hwspecops); int can_lmc1_init_hw_data(struct candevice_t *candev); @@ -167,6 +190,7 @@ void can_lmc1_write_register(unsigned data, unsigned long address); unsigned can_lmc1_read_register(unsigned long address); int can_lmc1_request_io(struct candevice_t *candev); int can_lmc1_reset(struct candevice_t *candev); +int can_lmc1_program_irq(struct candevice_t *candev); // lpc17xx can chip specific functions: int lpc17xx_chip_config(struct canchip_t *chip);