From 2552bfd2ef2c17e5ed8413b59588f9615f49d7c5 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Thu, 28 Jun 2018 15:11:23 -0600 Subject: [PATCH] arch/arm/src/lpc43: Fix lpc43 CAN configuration. Configuration settings were used and documented in README.txt files, but never in any Kconfig file. Also fix the scoping name of CAN variable naming. CONFIG_CANx_BAUD->CONFIG_LPC43_CANx_BAUD. --- arch/arm/src/lpc43xx/Kconfig | 55 ++++++++++++++++++++++++++++++ arch/arm/src/lpc43xx/lpc43_can.c | 36 +++++++++---------- configs/bambino-200e/README.txt | 8 +++-- configs/lpc4330-xplorer/README.txt | 8 +++-- configs/lpc4337-ws/README.txt | 8 +++-- configs/lpc4357-evb/README.txt | 8 +++-- configs/lpc4370-link2/README.txt | 8 +++-- 7 files changed, 98 insertions(+), 33 deletions(-) diff --git a/arch/arm/src/lpc43xx/Kconfig b/arch/arm/src/lpc43xx/Kconfig index 59c927604b4..38d15dbecce 100644 --- a/arch/arm/src/lpc43xx/Kconfig +++ b/arch/arm/src/lpc43xx/Kconfig @@ -790,6 +790,61 @@ config LPC43_I2C0_SUPERFAST endmenu # I2C Configution endif # LPC43_I2C0 +menu "CAN driver options" + depends on LPC43_CAN0 || LPC43_CAN1 + +config LPC43_CAN0_BAUD + int "CAN0 BAUD" + depends on LPC43_CAN0 + default 1000000 + ---help--- + CAN0 BAUD rate. + +config LPC43_CAN1_BAUD + int "CAN1 BAUD" + depends on LPC43_CAN1 + default 1000000 + ---help--- + CAN1 BAUD rate. + +config LPC43_CAN0_DIVISOR + int "CAN0 CCLK divisor" + depends on LPC43_CAN0 + default 4 + ---help--- + CAN0 is clocked at CCLK divided by this number. (the CCLK frequency is divided + by this number to get the CAN clock). Options = {1,2,4,6}. Default: 4. + +config LPC43_CAN1_DIVISOR + int "CAN2 CCLK divisor" + depends on LPC43_CAN1 + default 4 + ---help--- + CAN1 is clocked at CCLK divided by this number. (the CCLK frequency is divided + by this number to get the CAN clock). Options = {1,2,4,6}. Default: 4. + +config CAN_TSEG1 + int "TSEG1 quanta" + default 12 + ---help--- + The number of CAN time quanta in segment 1. Default: 6 + +config CAN_TSEG2 + int "TSEG2 quanta" + default 4 + ---help--- + The number of CAN time quanta in segment 2. Default: 7 + +config LPC43_CAN_REGDEBUG + bool "Register level debug" + depends on DEBUG_CAN_INFO + default n + ---help--- + Output detailed register-level CAN debug information. Requires also + CONFIG_DEBUG_CAN_INFO. + +endmenu # CAN driver options + if LPC43_USBOTG && USBHOST menu "USB host controller driver (HCD) options" diff --git a/arch/arm/src/lpc43xx/lpc43_can.c b/arch/arm/src/lpc43xx/lpc43_can.c index 19cc3164a5a..e982ea9185e 100644 --- a/arch/arm/src/lpc43xx/lpc43_can.c +++ b/arch/arm/src/lpc43xx/lpc43_can.c @@ -83,8 +83,8 @@ /* A CAN bit rate must be provided */ -# ifndef CONFIG_CAN0_BAUD -# define CONFIG_CAN0_BAUD 1000000 +# ifndef CONFIG_LPC43_CAN0_BAUD +# define CONFIG_LPC43_CAN0_BAUD 1000000 # endif #endif @@ -92,8 +92,8 @@ /* A CAN bit rate must be provided */ -# ifndef CONFIG_CAN1_BAUD -# define CONFIG_CAN1_BAUD 1000000 +# ifndef CONFIG_LPC43_CAN1_BAUD +# define CONFIG_LPC43_CAN1_BAUD 1000000 # endif #endif @@ -142,14 +142,14 @@ struct up_dev_s ****************************************************************************/ /* CAN Register access */ -#ifdef CONFIG_CAN_REGDEBUG +#ifdef CONFIG_LPC43_CAN_REGDEBUG static void can_printreg(uint32_t addr, uint32_t value); #endif static uint32_t can_getreg(struct up_dev_s *priv, int offset); static void can_putreg(struct up_dev_s *priv, int offset, uint32_t value); -#ifdef CONFIG_CAN_REGDEBUG +#ifdef CONFIG_LPC43_CAN_REGDEBUG static uint32_t can_getcommon(uint32_t addr); static void can_putcommon(uint32_t addr, uint32_t value); #else @@ -215,7 +215,7 @@ static struct up_dev_s g_can0priv = { .port = 0, .clkdiv = CAN_CLKDIVVAL + 1, - .baud = CONFIG_CAN0_BAUD, + .baud = CONFIG_LPC43_CAN0_BAUD, .base = LPC43_CAN0_BASE, .irq = LPC43M4_IRQ_CAN0, }; @@ -232,7 +232,7 @@ static struct up_dev_s g_can1priv = { .port = 1, .clkdiv = CAN_CLKDIVVAL + 1, - .baud = CONFIG_CAN1_BAUD, + .baud = CONFIG_LPC43_CAN1_BAUD, .base = LPC43_CAN1_BASE, .irq = LPC43M4_IRQ_CAN1, }; @@ -263,7 +263,7 @@ static struct can_dev_s g_can1dev = * ****************************************************************************/ -#ifdef CONFIG_CAN_REGDEBUG +#ifdef CONFIG_LPC43_CAN_REGDEBUG static void can_printreg(uint32_t addr, uint32_t value) { static uint32_t prevaddr = 0; @@ -311,7 +311,7 @@ static void can_printreg(uint32_t addr, uint32_t value) caninfo("%08x->%08x\n", addr, value); } -#endif /* CONFIG_CAN_REGDEBUG */ +#endif /* CONFIG_LPC43_CAN_REGDEBUG */ /**************************************************************************** * Name: can_getreg @@ -327,7 +327,7 @@ static void can_printreg(uint32_t addr, uint32_t value) * ****************************************************************************/ -#ifdef CONFIG_CAN_REGDEBUG +#ifdef CONFIG_LPC43_CAN_REGDEBUG static uint32_t can_getreg(struct up_dev_s *priv, int offset) { uint32_t addr; @@ -345,7 +345,7 @@ static uint32_t can_getreg(struct up_dev_s *priv, int offset) { return getreg32(priv->base + offset); } -#endif /* CONFIG_CAN_REGDEBUG */ +#endif /* CONFIG_LPC43_CAN_REGDEBUG */ /**************************************************************************** * Name: can_putreg @@ -363,7 +363,7 @@ static uint32_t can_getreg(struct up_dev_s *priv, int offset) * ****************************************************************************/ -#ifdef CONFIG_CAN_REGDEBUG +#ifdef CONFIG_LPC43_CAN_REGDEBUG static void can_putreg(struct up_dev_s *priv, int offset, uint32_t value) { uint32_t addr = priv->base + offset; @@ -381,7 +381,7 @@ static void can_putreg(struct up_dev_s *priv, int offset, uint32_t value) { putreg32(value, priv->base + offset); } -#endif /* CONFIG_CAN_REGDEBUG */ +#endif /* CONFIG_LPC43_CAN_REGDEBUG */ /**************************************************************************** * Name: can_getcommon @@ -397,7 +397,7 @@ static void can_putreg(struct up_dev_s *priv, int offset, uint32_t value) * ****************************************************************************/ -#ifdef CONFIG_CAN_REGDEBUG +#ifdef CONFIG_LPC43_CAN_REGDEBUG static uint32_t can_getcommon(uint32_t addr) { uint32_t value; @@ -408,7 +408,7 @@ static uint32_t can_getcommon(uint32_t addr) can_printreg(addr, value); return value; } -#endif /* CONFIG_CAN_REGDEBUG */ +#endif /* CONFIG_LPC43_CAN_REGDEBUG */ /**************************************************************************** * Name: can_putcommon @@ -425,7 +425,7 @@ static uint32_t can_getcommon(uint32_t addr) * ****************************************************************************/ -#ifdef CONFIG_CAN_REGDEBUG +#ifdef CONFIG_LPC43_CAN_REGDEBUG static void can_putcommon(uint32_t addr, uint32_t value) { /* Show the register value being written */ @@ -436,7 +436,7 @@ static void can_putcommon(uint32_t addr, uint32_t value) putreg32(value, addr); } -#endif /* CONFIG_CAN_REGDEBUG */ +#endif /* CONFIG_LPC43_CAN_REGDEBUG */ /**************************************************************************** * Name: can_reset diff --git a/configs/bambino-200e/README.txt b/configs/bambino-200e/README.txt index 6c61ef030e1..2bb01b21fbf 100644 --- a/configs/bambino-200e/README.txt +++ b/configs/bambino-200e/README.txt @@ -241,8 +241,8 @@ Bambino-200e Configuration Options CONFIG_LPC43_ADC0=y CONFIG_LPC43_ADC1=y CONFIG_LPC43_ATIMER=y + CONFIG_LPC43_CAN0=y CONFIG_LPC43_CAN1=y - CONFIG_LPC43_CAN2=y CONFIG_LPC43_DAC=y CONFIG_LPC43_EMC=y CONFIG_LPC43_ETHERNET=y @@ -298,8 +298,10 @@ Bambino-200e Configuration Options CONFIG_CAN_EXTID - Enables support for the 29-bit extended ID. Default Standard 11-bit IDs. - CONFIG_CAN1_BAUD - CAN1 BAUD rate. Required if CONFIG_LPC43_CAN1 is defined. - CONFIG_CAN2_BAUD - CAN1 BAUD rate. Required if CONFIG_LPC43_CAN2 is defined. + CONFIG_LPC43_CAN0_BAUD - CAN1 BAUD rate. Required if CONFIG_LPC43_CAN0 + is defined. + CONFIG_LPC43_CAN1_BAUD - CAN1 BAUD rate. Required if CONFIG_LPC43_CAN1 + is defined. CONFIG_CAN_TSEG1 - The number of CAN time quanta in segment 1. Default: 6 CONFIG_CAN_TSEG2 = the number of CAN time quanta in segment 2. Default: 7 diff --git a/configs/lpc4330-xplorer/README.txt b/configs/lpc4330-xplorer/README.txt index 489cf5dc2e0..4f60e1a2511 100644 --- a/configs/lpc4330-xplorer/README.txt +++ b/configs/lpc4330-xplorer/README.txt @@ -493,8 +493,8 @@ LPC4330-Xplorer Configuration Options CONFIG_LPC43_ADC0=y CONFIG_LPC43_ADC1=y CONFIG_LPC43_ATIMER=y + CONFIG_LPC43_CAN0=y CONFIG_LPC43_CAN1=y - CONFIG_LPC43_CAN2=y CONFIG_LPC43_DAC=y CONFIG_LPC43_EMC=y CONFIG_LPC43_ETHERNET=y @@ -550,8 +550,10 @@ LPC4330-Xplorer Configuration Options CONFIG_CAN_EXTID - Enables support for the 29-bit extended ID. Default Standard 11-bit IDs. - CONFIG_CAN1_BAUD - CAN1 BAUD rate. Required if CONFIG_LPC43_CAN1 is defined. - CONFIG_CAN2_BAUD - CAN1 BAUD rate. Required if CONFIG_LPC43_CAN2 is defined. + CONFIG_LPC43_CAN0_BAUD - CAN1 BAUD rate. Required if CONFIG_LPC43_CAN0 + is defined. + CONFIG_LPC43_CAN1_BAUD - CAN1 BAUD rate. Required if CONFIG_LPC43_CAN1 + is defined. CONFIG_CAN_TSEG1 - The number of CAN time quanta in segment 1. Default: 6 CONFIG_CAN_TSEG2 = the number of CAN time quanta in segment 2. Default: 7 diff --git a/configs/lpc4337-ws/README.txt b/configs/lpc4337-ws/README.txt index 5009d9f5d01..e7f36830da9 100644 --- a/configs/lpc4337-ws/README.txt +++ b/configs/lpc4337-ws/README.txt @@ -532,8 +532,8 @@ LPC4337-ws Configuration Options CONFIG_LPC43_ADC0=y CONFIG_LPC43_ADC1=y CONFIG_LPC43_ATIMER=y + CONFIG_LPC43_CAN0=y CONFIG_LPC43_CAN1=y - CONFIG_LPC43_CAN2=y CONFIG_LPC43_DAC=y CONFIG_LPC43_EMC=y CONFIG_LPC43_ETHERNET=y @@ -589,8 +589,10 @@ LPC4337-ws Configuration Options CONFIG_CAN_EXTID - Enables support for the 29-bit extended ID. Default Standard 11-bit IDs. - CONFIG_CAN1_BAUD - CAN1 BAUD rate. Required if CONFIG_LPC43_CAN1 is defined. - CONFIG_CAN2_BAUD - CAN1 BAUD rate. Required if CONFIG_LPC43_CAN2 is defined. + CONFIG_LPC43_CAN0_BAUD - CAN1 BAUD rate. Required if CONFIG_LPC43_CAN0 + is defined. + CONFIG_LPC43_CAN1_BAUD - CAN1 BAUD rate. Required if CONFIG_LPC43_CAN1 + is defined. CONFIG_CAN_TSEG1 - The number of CAN time quanta in segment 1. Default: 6 CONFIG_CAN_TSEG2 = the number of CAN time quanta in segment 2. Default: 7 diff --git a/configs/lpc4357-evb/README.txt b/configs/lpc4357-evb/README.txt index fe5814bfc29..32e44145a05 100644 --- a/configs/lpc4357-evb/README.txt +++ b/configs/lpc4357-evb/README.txt @@ -529,8 +529,8 @@ LPC4357-EVB Configuration Options CONFIG_LPC43_ADC0=y CONFIG_LPC43_ADC1=y CONFIG_LPC43_ATIMER=y + CONFIG_LPC43_CAN0=y CONFIG_LPC43_CAN1=y - CONFIG_LPC43_CAN2=y CONFIG_LPC43_DAC=y CONFIG_LPC43_EMC=y CONFIG_LPC43_ETHERNET=y @@ -586,8 +586,10 @@ LPC4357-EVB Configuration Options CONFIG_CAN_EXTID - Enables support for the 29-bit extended ID. Default Standard 11-bit IDs. - CONFIG_CAN1_BAUD - CAN1 BAUD rate. Required if CONFIG_LPC43_CAN1 is defined. - CONFIG_CAN2_BAUD - CAN1 BAUD rate. Required if CONFIG_LPC43_CAN2 is defined. + CONFIG_LPC43_CAN0_BAUD - CAN1 BAUD rate. Required if CONFIG_LPC43_CAN0 + is defined. + CONFIG_LPC43_CAN1_BAUD - CAN1 BAUD rate. Required if CONFIG_LPC43_CAN1 + is defined. CONFIG_CAN_TSEG1 - The number of CAN time quanta in segment 1. Default: 6 CONFIG_CAN_TSEG2 = the number of CAN time quanta in segment 2. Default: 7 diff --git a/configs/lpc4370-link2/README.txt b/configs/lpc4370-link2/README.txt index 6b3204126d3..67a1b8cf33b 100644 --- a/configs/lpc4370-link2/README.txt +++ b/configs/lpc4370-link2/README.txt @@ -532,8 +532,8 @@ LPC4370-Link2 Configuration Options CONFIG_LPC43_ADC0=y CONFIG_LPC43_ADC1=y CONFIG_LPC43_ATIMER=y + CONFIG_LPC43_CAN0=y CONFIG_LPC43_CAN1=y - CONFIG_LPC43_CAN2=y CONFIG_LPC43_DAC=y CONFIG_LPC43_EMC=y CONFIG_LPC43_ETHERNET=y @@ -589,8 +589,10 @@ LPC4370-Link2 Configuration Options CONFIG_CAN_EXTID - Enables support for the 29-bit extended ID. Default Standard 11-bit IDs. - CONFIG_CAN1_BAUD - CAN1 BAUD rate. Required if CONFIG_LPC43_CAN1 is defined. - CONFIG_CAN2_BAUD - CAN1 BAUD rate. Required if CONFIG_LPC43_CAN2 is defined. + CONFIG_LPC43_CAN0_BAUD - CAN1 BAUD rate. Required if CONFIG_LPC43_CAN0 + is defined. + CONFIG_LPC43_CAN1_BAUD - CAN1 BAUD rate. Required if CONFIG_LPC43_CAN1 + is defined. CONFIG_CAN_TSEG1 - The number of CAN time quanta in segment 1. Default: 6 CONFIG_CAN_TSEG2 = the number of CAN time quanta in segment 2. Default: 7