changeset 3268:b06697684f0a

* src/can_accfilt_lpc2xxx.c, src/can_lpc2xxx.c: Fix a compile issue of the lpc2xxx driver that only occurs if support for extended 29-bit CAN identifiers is enabled and support for message filtering is disabled. [ Bugzilla 1001901 ] * includes/can_lpc2xxx_baudrates.h: Added baudrate table for CAN clock of 14.745600 MHz. [ Bugzilla 1001900 ]
author sergeig
date Wed, 11 Sep 2013 21:00:16 +0000
parents 1053b0d2490c
children 638187db5595
files packages/devs/can/arm/lpc2xxx/current/ChangeLog packages/devs/can/arm/lpc2xxx/current/include/can_lpc2xxx_baudrates.h packages/devs/can/arm/lpc2xxx/current/src/can_accfilt_lpc2xxx.c packages/devs/can/arm/lpc2xxx/current/src/can_lpc2xxx.c
diffstat 4 files changed, 41 insertions(+), 1 deletions(-) [+]
line wrap: on
line diff
--- a/packages/devs/can/arm/lpc2xxx/current/ChangeLog
+++ b/packages/devs/can/arm/lpc2xxx/current/ChangeLog
@@ -1,3 +1,15 @@
+2013-09-11  Uwe Kindler <uwe_kindler@web.de>
+
+	* src/can_accfilt_lpc2xxx.c, src/can_lpc2xxx.c: Fix a compile issue of
+	the lpc2xxx driver that only occurs if support for extended 29-bit CAN
+	identifiers is enabled and support for message filtering is disabled.
+	[ Bugzilla 1001901 ]
+
+2013-08-29  Uwe Kindler <uwe_kindler@web.de>
+
+	* includes/can_lpc2xxx_baudrates.h: Added baudrate table for CAN clock
+	of 14.745600 MHz. [ Bugzilla 1001900 ]
+
 2013-06-24  Uwe Kindler <uwe_kindler@web.de>
 
 	* src/can_lpc2xxx.c: Add support for new config key
--- a/packages/devs/can/arm/lpc2xxx/current/include/can_lpc2xxx_baudrates.h
+++ b/packages/devs/can/arm/lpc2xxx/current/include/can_lpc2xxx_baudrates.h
@@ -185,6 +185,32 @@ static const cyg_uint32 lpc2xxx_br_tbl[]
 #define HAL_LPC2XXX_BAUD_TBL_DEFINED 1
 #endif // CYGNUM_HAL_ARM_LPC2XXX_CAN_CLK == 12000000
 
+#if CYGNUM_HAL_ARM_LPC2XXX_CAN_CLK == 14745600
+#warning "You can't get exactly the desired CAN bus speeds with the specified CAN clock of 14.7456 MHz"
+//
+// Table with register values for baudrates at peripheral clock of 14.7456 MHz
+// The clock of 14.7456 MHz is not suited for a good CAN bitrate timing because
+// you can't get exactly the desired CAN bus speed with the specified CAN
+// clock frequency. Be sure to check the error values behind the table entries.
+// Settings leading to speed deviations of more than 1.5% should be discarded.
+//
+static const cyg_uint32 lpc2xxx_br_tbl[] =
+{
+    //----------brp  tseg1 tseg2 sjw sam ------------
+    CAN_BR_TBL_ENTRY(58, 20, 2, 0, 1), // 10  kbaud - Timing Error  0.030%
+    CAN_BR_TBL_ENTRY(66,  8, 0, 0, 1), // 20  kbaud - Timing Error -0.038%
+    CAN_BR_TBL_ENTRY(13, 17, 1, 0, 1), // 50  kbaud - Timing Error -0.310%
+    CAN_BR_TBL_ENTRY( 6, 17, 1, 0, 1), // 100 kbaud - Timing Error -0.310%
+    CAN_BR_TBL_ENTRY(12,  6, 0, 0, 1), // 125 kbaud - Timing Error -0.825%
+    CAN_BR_TBL_ENTRY( 5,  7, 0, 0, 1), // 250 kbaud - Timing Error 1.696%
+    CAN_BR_TBL_ENTRY( 2,  7, 0, 0, 0), // 500 kbaud - Timing Error 1.696%
+    CAN_BR_TBL_ENTRY( 1,  6, 0, 0, 0), // 800 kbaud  - Timing Error -2.4%
+    CAN_BR_TBL_ENTRY( 0, 11, 1, 0, 0), // 1000 kbaud - Timing Error 1.696%
+    CAN_BR_TBL_ENTRY( 0,  0, 0, 0, 0), // Autobaud  - not supported
+};
+#define HAL_LPC2XXX_BAUD_TBL_DEFINED 1
+#endif // CYGNUM_HAL_ARM_LPC2XXX_CAN_CLK == 14745600
+
 
 //==========================================================================
 //                          BIT TIMING MACRO
--- a/packages/devs/can/arm/lpc2xxx/current/src/can_accfilt_lpc2xxx.c
+++ b/packages/devs/can/arm/lpc2xxx/current/src/can_accfilt_lpc2xxx.c
@@ -771,7 +771,7 @@ static void lpc2xxx_can_accfilt_simple_r
 #ifdef CYGOPT_IO_CAN_STD_CAN_ID
     cyg_uint8                 std_address = 0;     // std group entry address
 #ifdef CYGOPT_IO_CAN_EXT_CAN_ID
-    cyg_uint8                 ext_address = lpc2xxx_global_can_info.init_cnt << 2;
+    cyg_uint8                 ext_address = LPC2XXX_INIT_CNT << 2;
 #endif
 #else
     cyg_uint8                 ext_address = 0;
--- a/packages/devs/can/arm/lpc2xxx/current/src/can_lpc2xxx.c
+++ b/packages/devs/can/arm/lpc2xxx/current/src/can_lpc2xxx.c
@@ -538,8 +538,10 @@ typedef struct lpc2xxx_global_can_info_s
 
 #if CYGINT_IO_CAN_CHANNELS > 1
 #define LPC2XXX_GET_CAN_CHANNEL(_can_info_, _chan_no_) ((can_channel*)(_can_info_).active_channels[_chan_no_])
+#define LPC2XXX_INIT_CNT lpc2xxx_global_can_info.init_cnt
 #else
 #define LPC2XXX_GET_CAN_CHANNEL(_can_info_, _chan_no_) ((can_channel*)(_can_info_).active_channels[0])
+#define LPC2XXX_INIT_CNT 1
 #endif
 
 //