summaryrefslogtreecommitdiff
path: root/nuttx/arch/arm/src/lpc17xx
diff options
context:
space:
mode:
authorpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-01-06 14:07:47 +0000
committerpatacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3>2012-01-06 14:07:47 +0000
commitb052b47c088d59520e9b8f8badf5a7354ac7242b (patch)
tree4c915d1497898702f0268aaeccc44eaa24734100 /nuttx/arch/arm/src/lpc17xx
parent970040cce478ac3596db46b696677f72d5fcacf3 (diff)
downloadpx4-nuttx-b052b47c088d59520e9b8f8badf5a7354ac7242b.tar.gz
px4-nuttx-b052b47c088d59520e9b8f8badf5a7354ac7242b.tar.bz2
px4-nuttx-b052b47c088d59520e9b8f8badf5a7354ac7242b.zip
LPC17xx CAN PCLK divisor is not a configuration parameter
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@4268 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/arm/src/lpc17xx')
-rwxr-xr-xnuttx/arch/arm/src/lpc17xx/lpc17_can.c64
1 files changed, 62 insertions, 2 deletions
diff --git a/nuttx/arch/arm/src/lpc17xx/lpc17_can.c b/nuttx/arch/arm/src/lpc17xx/lpc17_can.c
index fd04c8269..37d5a7c68 100755
--- a/nuttx/arch/arm/src/lpc17xx/lpc17_can.c
+++ b/nuttx/arch/arm/src/lpc17xx/lpc17_can.c
@@ -72,6 +72,66 @@
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
+/* Configuration ************************************************************/
+
+#ifdef CONFIG_LPC17_CAN1
+
+ /* A CAN bit rate must be provided */
+
+# ifndef CONFIG_CAN1_BAUD
+# error "CONFIG_CAN1_BAUD is not defined"
+# endif
+
+ /* If no divsor is provided, use a divisor of 4 */
+
+# ifndef CONFIG_CAN1_DIVISOR
+# define CONFIG_CAN1_DIVISOR 4
+# endif
+
+ /* Get the SYSCON_PCLKSEL value for CAN1 the implements this divisor */
+
+# if CONFIG_CAN1_DIVISOR == 1
+# define CAN1_CCLK_DIVISOR SYSCON_PCLKSEL_CCLK
+# elif CONFIG_CAN1_DIVISOR == 2
+# define CAN1_CCLK_DIVISOR SYSCON_PCLKSEL_CCLK2
+# elif CONFIG_CAN1_DIVISOR == 4
+# define CAN1_CCLK_DIVISOR SYSCON_PCLKSEL_CCLK4
+# elif CONFIG_CAN1_DIVISOR == 6
+# define CAN1_CCLK_DIVISOR SYSCON_PCLKSEL_CCLK6
+# else
+# error "Unsupported value of CONFIG_CAN1_DIVISOR"
+# endif
+#endif
+
+#ifdef CONFIG_LPC17_CAN2
+
+ /* A CAN bit rate must be provided */
+
+# ifndef CONFIG_CAN2_BAUD
+# error "CONFIG_CAN2_BAUD is not defined"
+# endif
+
+ /* If no divsor is provided, use a divisor of 4 */
+
+# ifndef CONFIG_CAN2_DIVISOR
+# define CONFIG_CAN2_DIVISOR 4
+# endif
+
+ /* Get the SYSCON_PCLKSEL value for CAN2 the implements this divisor */
+
+# if CONFIG_CAN2_DIVISOR == 1
+# define CAN2_CCLK_DIVISOR SYSCON_PCLKSEL_CCLK
+# elif CONFIG_CAN2_DIVISOR == 2
+# define CAN2_CCLK_DIVISOR SYSCON_PCLKSEL_CCLK2
+# elif CONFIG_CAN2_DIVISOR == 4
+# define CAN2_CCLK_DIVISOR SYSCON_PCLKSEL_CCLK4
+# elif CONFIG_CAN2_DIVISOR == 6
+# define CAN2_CCLK_DIVISOR SYSCON_PCLKSEL_CCLK6
+# else
+# error "Unsupported value of CONFIG_CAN2_DIVISOR"
+# endif
+#endif
+
/* Debug ********************************************************************/
/* Non-standard debug that may be enabled just for testing CAN */
@@ -1078,7 +1138,7 @@ FAR struct can_dev_s *lpc17_caninitialize(int port)
regval = can_getcommon(LPC17_SYSCON_PCLKSEL0);
regval &= ~SYSCON_PCLKSEL0_CAN1_MASK;
- regval |= (SYSCON_PCLKSEL_CCLK4 << SYSCON_PCLKSEL0_CAN1_SHIFT);
+ regval |= (CAN1_CCLK_DIVISOR << SYSCON_PCLKSEL0_CAN1_SHIFT);
can_putcommon(LPC17_SYSCON_PCLKSEL0, regval);
/* Configure CAN GPIO pins */
@@ -1105,7 +1165,7 @@ FAR struct can_dev_s *lpc17_caninitialize(int port)
regval = can_getcommon(LPC17_SYSCON_PCLKSEL0);
regval &= ~SYSCON_PCLKSEL0_CAN2_MASK;
- regval |= (SYSCON_PCLKSEL_CCLK4 << SYSCON_PCLKSEL0_CAN2_SHIFT);
+ regval |= (CAN2_CCLK_DIVISOR << SYSCON_PCLKSEL0_CAN2_SHIFT);
can_putcommon(LPC17_SYSCON_PCLKSEL0, regval);
/* Configure CAN GPIO pins */