X-Git-Url: http://rtime.felk.cvut.cz/gitweb/lincan.git/blobdiff_plain/a73d6ffea8948a9abc9bfb32728bb255cec18317..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 202ed2a..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 @@ -146,21 +147,39 @@ 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); -void CAN_set_bittiming(struct canchip_t *chip, uint32_t brp, uint32_t sjw, uint32_t tseg1, uint32_t tseg2); -//---------------------------------- + +/* + * 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; }; -#define CAN_LMC1_CHIP_CANBTR_SET (1<<1) // board can-lmc1 specific functions: int can_lmc1_register(struct hwspecops_t *hwspecops);