mirror of
https://github.com/apache/nuttx.git
synced 2026-06-05 07:12:54 +08:00
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:
committed by
Xiang Xiao
parent
3f97a87162
commit
372fee9412
+47
-24
@@ -436,7 +436,6 @@ config TIVA_CAN
|
|||||||
bool
|
bool
|
||||||
default n
|
default n
|
||||||
select CAN
|
select CAN
|
||||||
select ARCH_HAVE_CAN_ERRORS
|
|
||||||
select CAN_TXREADY
|
select CAN_TXREADY
|
||||||
select CAN_USE_RTR
|
select CAN_USE_RTR
|
||||||
|
|
||||||
@@ -612,33 +611,12 @@ config TIVA_CAN0
|
|||||||
default n
|
default n
|
||||||
depends on TIVA_HAVE_CAN0
|
depends on TIVA_HAVE_CAN0
|
||||||
select TIVA_CAN
|
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
|
config TIVA_CAN1
|
||||||
bool "CAN1"
|
bool "CAN1"
|
||||||
default n
|
default n
|
||||||
depends on TIVA_HAVE_CAN1
|
depends on TIVA_HAVE_CAN1
|
||||||
select TIVA_CAN
|
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
|
config TIVA_QEI0
|
||||||
bool "QEI0"
|
bool "QEI0"
|
||||||
default n
|
default n
|
||||||
@@ -1520,10 +1498,55 @@ endif # TIVA_ADC
|
|||||||
|
|
||||||
menu "CAN Driver Configuration"
|
menu "CAN Driver Configuration"
|
||||||
depends on TIVA_CAN
|
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
|
config TIVA_CAN_REGDEBUG
|
||||||
bool "CAN register level debug"
|
bool "CAN register level debug"
|
||||||
depends on DEBUG_CAN_INFO
|
depends on DEBUG_CAN_INFO && TIVA_CHAR_DEV_CAN
|
||||||
default n
|
default n
|
||||||
---help---
|
---help---
|
||||||
Output detailed register-level CAN device debug information.
|
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)"
|
int "Rate-limited error handling period (milliseconds)"
|
||||||
range 10 1000
|
range 10 1000
|
||||||
default 100
|
default 100
|
||||||
depends on CAN_ERRORS
|
depends on CAN_ERRORS || NET_CAN_ERRORS
|
||||||
---help---
|
---help---
|
||||||
When error messages (CAN_ERRORS) are enabled, the Tiva
|
When error messages (CAN_ERRORS) are enabled, the Tiva
|
||||||
CAN driver will disable interrupts for individual errors
|
CAN driver will disable interrupts for individual errors
|
||||||
|
|||||||
@@ -91,10 +91,14 @@ ifeq ($(CONFIG_TIVA_ADC),y)
|
|||||||
CHIP_CSRCS += tiva_adclib.c
|
CHIP_CSRCS += tiva_adclib.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_TIVA_CAN),y)
|
ifeq ($(CONFIG_TIVA_CHAR_DEV_CAN),y)
|
||||||
CHIP_CSRCS += tiva_can.c
|
CHIP_CSRCS += tiva_can.c
|
||||||
endif
|
endif
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_TIVA_SOCKET_CAN),y)
|
||||||
|
CHIP_CSRCS += tiva_sock_can.c
|
||||||
|
endif
|
||||||
|
|
||||||
ifeq ($(CONFIG_TIVA_ETHERNET),y)
|
ifeq ($(CONFIG_TIVA_ETHERNET),y)
|
||||||
ifeq ($(CONFIG_ARCH_CHIP_LM3S),y)
|
ifeq ($(CONFIG_ARCH_CHIP_LM3S),y)
|
||||||
CHIP_CSRCS += lm3s_ethernet.c
|
CHIP_CSRCS += lm3s_ethernet.c
|
||||||
|
|||||||
File diff suppressed because it is too large
Load Diff
@@ -61,7 +61,7 @@ extern "C"
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Public Function Prototypes
|
* Public Function Prototypes
|
||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
#ifdef CONFIG_TIVA_CHAR_DEV_CAN
|
||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* Name: tiva_can_initialize
|
* Name: tiva_can_initialize
|
||||||
*
|
*
|
||||||
@@ -78,6 +78,23 @@ extern "C"
|
|||||||
****************************************************************************/
|
****************************************************************************/
|
||||||
|
|
||||||
int tiva_can_initialize(char *devpath, int modnum);
|
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
|
#undef EXTERN
|
||||||
#if defined(__cplusplus)
|
#if defined(__cplusplus)
|
||||||
|
|||||||
@@ -78,6 +78,7 @@ int tm4c_can_setup(void)
|
|||||||
goto configgpio_error;
|
goto configgpio_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ifdef CONFIG_TIVA_CHAR_DEV_CAN
|
||||||
/* Call tiva_can_initialize() to get an instance of CAN interface 0
|
/* Call tiva_can_initialize() to get an instance of CAN interface 0
|
||||||
* and register it.
|
* and register it.
|
||||||
*/
|
*/
|
||||||
@@ -88,6 +89,20 @@ int tm4c_can_setup(void)
|
|||||||
canerr("ERROR: Failed to get/register CAN interface 0\n");
|
canerr("ERROR: Failed to get/register CAN interface 0\n");
|
||||||
return ret;
|
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 */
|
# endif /* CONFIG_TIVA_CAN0 */
|
||||||
|
|
||||||
# ifdef CONFIG_TIVA_CAN1
|
# ifdef CONFIG_TIVA_CAN1
|
||||||
@@ -105,6 +120,7 @@ int tm4c_can_setup(void)
|
|||||||
goto configgpio_error;
|
goto configgpio_error;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
# ifdef CONFIG_TIVA_CHAR_DEV_CAN
|
||||||
/* Call tiva_can_initialize() to get an instance of CAN interface 1
|
/* Call tiva_can_initialize() to get an instance of CAN interface 1
|
||||||
* and register it.
|
* and register it.
|
||||||
*/
|
*/
|
||||||
@@ -115,6 +131,20 @@ int tm4c_can_setup(void)
|
|||||||
canerr("ERROR: Failed to get/register CAN interface 1\n");
|
canerr("ERROR: Failed to get/register CAN interface 1\n");
|
||||||
return ret;
|
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 */
|
# endif /* CONFIG_TIVA_CAN1 */
|
||||||
|
|
||||||
return OK;
|
return OK;
|
||||||
|
|||||||
Reference in New Issue
Block a user