Added SocketCAN driver implementation to the tiva chip, modified the EK-TC1294XL launchpad board to use the new SocketCAN API

This commit is contained in:
David Vosahlik 2023-01-25 15:38:02 +01:00 committed by Xiang Xiao
parent 3f97a87162
commit 372fee9412
5 changed files with 2473 additions and 26 deletions

View File

@ -436,7 +436,6 @@ config TIVA_CAN
bool
default n
select CAN
select ARCH_HAVE_CAN_ERRORS
select CAN_TXREADY
select CAN_USE_RTR
@ -612,33 +611,12 @@ config TIVA_CAN0
default n
depends on TIVA_HAVE_CAN0
select TIVA_CAN
config TIVA_CAN0_PRIO
int "CAN0 kthread priority"
default 300
depends on TIVA_CAN0
---help---
The Tiva CAN driver retrieves messages using a kthread rather
than in the ISR or using a work queue. The ISR signals the
kthread, but the kthread can be preempted if needed. This
option sets the thread priority for CAN module 0.
config TIVA_CAN1
bool "CAN1"
default n
depends on TIVA_HAVE_CAN1
select TIVA_CAN
config TIVA_CAN1_PRIO
int "CAN1 kthread priority"
default 300
depends on TIVA_CAN1
---help---
The Tiva CAN driver retrieves messages using a kthread rather
than in the ISR or using a work queue. The ISR signals the
kthread, but the kthread can be preempted if needed. This
option sets the thread priority for CAN module 1.
config TIVA_QEI0
bool "QEI0"
default n
@ -1520,10 +1498,55 @@ endif # TIVA_ADC
menu "CAN Driver Configuration"
depends on TIVA_CAN
choice
prompt "CAN bus driver selection"
default TIVA_SOCKET_CAN
config TIVA_SOCKET_CAN
bool "Use SocketCAN driver"
depends on (TIVA_CAN0 || TIVA_CAN1) && NET_CAN
select NET_CAN_HAVE_ERRORS
config TIVA_CHAR_DEV_CAN
bool "Character device driver"
depends on (TIVA_CAN0 || TIVA_CAN1) && !NET_CAN
select ARCH_HAVE_CAN_ERRORS
endchoice # CAN driver selection
config TIVA_CAN0_PRIO
int "CAN0 kthread priority"
default 300
depends on TIVA_CAN0 && TIVA_CHAR_DEV_CAN
---help---
The Tiva CAN driver retrieves messages using a kthread rather
than in the ISR or using a work queue. The ISR signals the
kthread, but the kthread can be preempted if needed. This
option sets the thread priority for CAN module 0.
config TIVA_CAN0_BAUD
int "CAN0 baud rate kb/s"
default 125
depends on TIVA_CAN0 && TIVA_SOCKET_CAN
config TIVA_CAN1_BAUD
int "CAN1 baud rate kb/s"
default 125
depends on TIVA_CAN1 && TIVA_SOCKET_CAN
config TIVA_CAN1_PRIO
int "CAN1 kthread priority"
default 300
depends on TIVA_CAN1 && TIVA_CHAR_DEV_CAN
---help---
The Tiva CAN driver retrieves messages using a kthread rather
than in the ISR or using a work queue. The ISR signals the
kthread, but the kthread can be preempted if needed. This
option sets the thread priority for CAN module 1.
config TIVA_CAN_REGDEBUG
bool "CAN register level debug"
depends on DEBUG_CAN_INFO
depends on DEBUG_CAN_INFO && TIVA_CHAR_DEV_CAN
default n
---help---
Output detailed register-level CAN device debug information.
@ -1589,7 +1612,7 @@ config TIVA_CAN_ERR_HANDLER_PER
int "Rate-limited error handling period (milliseconds)"
range 10 1000
default 100
depends on CAN_ERRORS
depends on CAN_ERRORS || NET_CAN_ERRORS
---help---
When error messages (CAN_ERRORS) are enabled, the Tiva
CAN driver will disable interrupts for individual errors

View File

@ -91,10 +91,14 @@ ifeq ($(CONFIG_TIVA_ADC),y)
CHIP_CSRCS += tiva_adclib.c
endif
ifeq ($(CONFIG_TIVA_CAN),y)
ifeq ($(CONFIG_TIVA_CHAR_DEV_CAN),y)
CHIP_CSRCS += tiva_can.c
endif
ifeq ($(CONFIG_TIVA_SOCKET_CAN),y)
CHIP_CSRCS += tiva_sock_can.c
endif
ifeq ($(CONFIG_TIVA_ETHERNET),y)
ifeq ($(CONFIG_ARCH_CHIP_LM3S),y)
CHIP_CSRCS += lm3s_ethernet.c

File diff suppressed because it is too large Load Diff

View File

@ -61,7 +61,7 @@ extern "C"
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef CONFIG_TIVA_CHAR_DEV_CAN
/****************************************************************************
* Name: tiva_can_initialize
*
@ -78,6 +78,23 @@ extern "C"
****************************************************************************/
int tiva_can_initialize(char *devpath, int modnum);
#elif CONFIG_TIVA_SOCKET_CAN
/****************************************************************************
* Name: tiva_cansockinitialize
*
* Description:
* Initialize the selected CAN module using socket net API
*
* Input Parameters:
* Module number, for chips with multiple modules (typically 0 or 1)
*
* Returned Value:
* OK on success; Negated errno on failure.
*
****************************************************************************/
int tiva_cansockinitialize(int modnum);
#endif
#undef EXTERN
#if defined(__cplusplus)

View File

@ -78,6 +78,7 @@ int tm4c_can_setup(void)
goto configgpio_error;
}
# ifdef CONFIG_TIVA_CHAR_DEV_CAN
/* Call tiva_can_initialize() to get an instance of CAN interface 0
* and register it.
*/
@ -88,6 +89,20 @@ int tm4c_can_setup(void)
canerr("ERROR: Failed to get/register CAN interface 0\n");
return ret;
}
# endif /* CONFIG_TIVA_CHAR_DEV_CAN */
# if defined(CONFIG_TIVA_SOCKET_CAN)
/* Call tiva_cansockinitialize() to get an instance of CAN interface 0
* and register it.
*/
ret = tiva_cansockinitialize(0);
if (ret < 0)
{
canerr("ERROR: Failed to get/register CAN interface 0\n");
return ret;
}
# endif /* CONFIG_TIVA_SOCKET_CAN */
# endif /* CONFIG_TIVA_CAN0 */
# ifdef CONFIG_TIVA_CAN1
@ -105,6 +120,7 @@ int tm4c_can_setup(void)
goto configgpio_error;
}
# ifdef CONFIG_TIVA_CHAR_DEV_CAN
/* Call tiva_can_initialize() to get an instance of CAN interface 1
* and register it.
*/
@ -115,6 +131,20 @@ int tm4c_can_setup(void)
canerr("ERROR: Failed to get/register CAN interface 1\n");
return ret;
}
# endif /* CONFIG_TIVA_CHAR_DEV_CAN */
# if defined(CONFIG_TIVA_SOCKET_CAN)
/* Call tiva_cansockinitialize() to get an instance of CAN interface 0
* and register it.
*/
ret = tiva_cansockinitialize(0);
if (ret < 0)
{
canerr("ERROR: Failed to get/register CAN interface 0\n");
return ret;
}
# endif /* CONFIG_TIVA_SOCKET_CAN */
# endif /* CONFIG_TIVA_CAN1 */
return OK;