mirror of
https://github.com/apache/nuttx.git
synced 2026-05-30 13:27:01 +08:00
Merged can_bus into master
This commit is contained in:
@@ -4545,7 +4545,7 @@ void board_autoled_off(int led);
|
|||||||
</p>
|
</p>
|
||||||
<ul>
|
<ul>
|
||||||
<li><b>Interface Definition</b>.
|
<li><b>Interface Definition</b>.
|
||||||
The header file for the NuttX CAN driver resides at <code>include/nuttx/drivers/can.h</code>.
|
The header file for the NuttX CAN driver resides at <code>include/nuttx/can/can.h</code>.
|
||||||
This header file includes both the application level interface to the CAN driver as well as the interface between the "upper half" and "lower half" drivers.
|
This header file includes both the application level interface to the CAN driver as well as the interface between the "upper half" and "lower half" drivers.
|
||||||
The CAN module uses a standard character driver framework.
|
The CAN module uses a standard character driver framework.
|
||||||
</li>
|
</li>
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
|
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
#include "up_arch.h"
|
#include "up_arch.h"
|
||||||
|
|||||||
@@ -60,7 +60,7 @@
|
|||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
|
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
#include "up_arch.h"
|
#include "up_arch.h"
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
#include "chip/sam_can.h"
|
#include "chip/sam_can.h"
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
|
|
||||||
#if defined(CONFIG_CAN) && (defined(CONFIG_SAMA5_CAN0) || defined(CONFIG_SAMA5_CAN1))
|
#if defined(CONFIG_CAN) && (defined(CONFIG_SAMA5_CAN0) || defined(CONFIG_SAMA5_CAN1))
|
||||||
|
|
||||||
|
|||||||
@@ -56,7 +56,7 @@
|
|||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/semaphore.h>
|
#include <nuttx/semaphore.h>
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
|
|
||||||
#include "cache.h"
|
#include "cache.h"
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
#include "chip/sam_mcan.h"
|
#include "chip/sam_mcan.h"
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
|
|
||||||
#if defined(CONFIG_CAN) && (defined(CONFIG_SAMV7_MCAN0) || \
|
#if defined(CONFIG_CAN) && (defined(CONFIG_SAMV7_MCAN0) || \
|
||||||
defined(CONFIG_SAMV7_MCAN1))
|
defined(CONFIG_SAMV7_MCAN1))
|
||||||
|
|||||||
@@ -53,7 +53,7 @@
|
|||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
|
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
#include "up_arch.h"
|
#include "up_arch.h"
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
#include "chip/stm32_can.h"
|
#include "chip/stm32_can.h"
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
|
|||||||
@@ -57,7 +57,7 @@
|
|||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
#include <nuttx/irq.h>
|
#include <nuttx/irq.h>
|
||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
|
|
||||||
#include "up_internal.h"
|
#include "up_internal.h"
|
||||||
#include "up_arch.h"
|
#include "up_arch.h"
|
||||||
|
|||||||
@@ -49,7 +49,7 @@
|
|||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
#include "chip/stm32l4_can.h"
|
#include "chip/stm32l4_can.h"
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Pre-processor Definitions
|
* Pre-processor Definitions
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "stm32.h"
|
#include "stm32.h"
|
||||||
|
|||||||
@@ -45,7 +45,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
|
|
||||||
#include "stm32.h"
|
#include "stm32.h"
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "stm32.h"
|
#include "stm32.h"
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
|
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "stm32.h"
|
#include "stm32.h"
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "stm32.h"
|
#include "stm32.h"
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "stm32.h"
|
#include "stm32.h"
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "sam_mcan.h"
|
#include "sam_mcan.h"
|
||||||
|
|||||||
@@ -43,7 +43,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "sam_mcan.h"
|
#include "sam_mcan.h"
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
|
|||||||
@@ -42,7 +42,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
|
|||||||
@@ -47,7 +47,7 @@
|
|||||||
#include <errno.h>
|
#include <errno.h>
|
||||||
#include <debug.h>
|
#include <debug.h>
|
||||||
|
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
#include <arch/board/board.h>
|
#include <arch/board/board.h>
|
||||||
|
|
||||||
#include "chip.h"
|
#include "chip.h"
|
||||||
|
|||||||
+3
-122
@@ -157,130 +157,11 @@ menuconfig CAN
|
|||||||
default n
|
default n
|
||||||
---help---
|
---help---
|
||||||
This selection enables building of the "upper-half" CAN driver.
|
This selection enables building of the "upper-half" CAN driver.
|
||||||
See include/nuttx/drivers/can.h for further CAN driver information.
|
See include/nuttx/can/can.h for further CAN driver information.
|
||||||
|
|
||||||
if CAN
|
if CAN
|
||||||
|
source drivers/can/Kconfig
|
||||||
config CAN_EXTID
|
endif
|
||||||
bool "CAN extended IDs"
|
|
||||||
default n
|
|
||||||
---help---
|
|
||||||
Enables support for the 28-bit extended ID. Default Standard 11-bit
|
|
||||||
IDs.
|
|
||||||
|
|
||||||
config ARCH_HAVE_CAN_ERRORS
|
|
||||||
bool
|
|
||||||
default n
|
|
||||||
|
|
||||||
config CAN_ERRORS
|
|
||||||
bool "CAN error reporting"
|
|
||||||
default n
|
|
||||||
depends on ARCH_HAVE_CAN_ERRORS
|
|
||||||
---help---
|
|
||||||
Support CAN error reporting. If this option is selected then CAN
|
|
||||||
error reporting is enabled. In the event of an error, the ch_error
|
|
||||||
bit will be set in the CAN message and the following message payload
|
|
||||||
will include a more detailed description of certain errors.
|
|
||||||
|
|
||||||
config CAN_FD
|
|
||||||
bool "CAN FD"
|
|
||||||
default n
|
|
||||||
---help---
|
|
||||||
Enables support for the CAN_FD mode.
|
|
||||||
|
|
||||||
config CAN_FIFOSIZE
|
|
||||||
int "CAN driver I/O buffer size"
|
|
||||||
default 8
|
|
||||||
---help---
|
|
||||||
The size of the circular buffer of CAN messages. Default: 8
|
|
||||||
|
|
||||||
config CAN_NPENDINGRTR
|
|
||||||
int "Number of pending RTRs"
|
|
||||||
default 4
|
|
||||||
---help---
|
|
||||||
The size of the list of pending RTR requests. Default: 4
|
|
||||||
|
|
||||||
config CAN_TXREADY
|
|
||||||
bool "can_txready interface"
|
|
||||||
default n
|
|
||||||
select SCHED_WORKQUEUE
|
|
||||||
---help---
|
|
||||||
This selection enables the can_txready() interface. This interface
|
|
||||||
is needed only for CAN hardware that supports queing of outgoing
|
|
||||||
messages in a H/W FIFO.
|
|
||||||
|
|
||||||
The CAN upper half driver also supports a queue of output messages
|
|
||||||
in a S/W FIFO. Messages are added to that queue when when
|
|
||||||
can_write() is called and removed from the queue in can_txdone()
|
|
||||||
when each TX message is complete.
|
|
||||||
|
|
||||||
After each message is added to the S/W FIFO, the CAN upper half
|
|
||||||
driver will attempt to send the message by calling into the lower
|
|
||||||
half driver. That send will not be performed if the lower half
|
|
||||||
driver is busy, i.e., if dev_txready() returns false. In that
|
|
||||||
case, the number of messages in the S/W FIFO can grow. If the
|
|
||||||
S/W FIFO becomes full, then can_write() will wait for space in
|
|
||||||
the S/W FIFO.
|
|
||||||
|
|
||||||
If the CAN hardware does not support a H/W FIFO then busy means
|
|
||||||
that the hardware is actively sending the message and is
|
|
||||||
guaranteed to become non busy (i.e, dev_txready()) when the
|
|
||||||
send transfer completes and can_txdone() is called. So the call
|
|
||||||
to can_txdone() means that the transfer has completed and also
|
|
||||||
that the hardware is ready to accept another transfer.
|
|
||||||
|
|
||||||
If the CAN hardware supports a H/W FIFO, can_txdone() is not
|
|
||||||
called when the tranfer is complete, but rather when the
|
|
||||||
transfer is queued in the H/W FIFO. When the H/W FIFO becomes
|
|
||||||
full, then dev_txready() will report false and the number of
|
|
||||||
queued messages in the S/W FIFO will grow.
|
|
||||||
|
|
||||||
There is no mechanism in this case to inform the upper half
|
|
||||||
driver when the hardware is again available, when there is
|
|
||||||
again space in the H/W FIFO. can_txdone() will not be called
|
|
||||||
again. If the S/W FIFO becomes full, then the upper half
|
|
||||||
driver will wait for space to become available, but there is
|
|
||||||
no event to awaken it and the driver will hang.
|
|
||||||
|
|
||||||
Enabling this feature adds support for the can_txready()
|
|
||||||
interface. This function is called from the lower half
|
|
||||||
driver's CAN interrupt handler each time a TX transfer
|
|
||||||
completes. This is a sure indication that the H/W FIFO is
|
|
||||||
no longer full. can_txready() will then awaken the
|
|
||||||
can_write() logic and the hang condition is avoided.
|
|
||||||
|
|
||||||
choice
|
|
||||||
prompt "TX Ready Work Queue"
|
|
||||||
default CAN_TXREADY_HIPRI
|
|
||||||
depends on CAN_TXREADY
|
|
||||||
|
|
||||||
config CAN_TXREADY_LOPRI
|
|
||||||
bool "Low-priority work queue"
|
|
||||||
select SCHED_LPWORK
|
|
||||||
|
|
||||||
config CAN_TXREADY_HIPRI
|
|
||||||
bool "High-priority work queue"
|
|
||||||
select SCHED_HPWORK
|
|
||||||
|
|
||||||
endchoice # TX Ready Work Queue
|
|
||||||
|
|
||||||
config CAN_LOOPBACK
|
|
||||||
bool "CAN loopback mode"
|
|
||||||
default n
|
|
||||||
---help---
|
|
||||||
A CAN driver may or may not support a loopback mode for testing. If the
|
|
||||||
driver does support loopback mode, the setting will enable it. (If the
|
|
||||||
driver does not, this setting will have no effect).
|
|
||||||
|
|
||||||
config CAN_NPOLLWAITERS
|
|
||||||
int "Number of poll waiters"
|
|
||||||
default 2
|
|
||||||
depends on !DISABLE_POLL
|
|
||||||
---help---
|
|
||||||
The maximum number of threads that may be waiting on the
|
|
||||||
poll method.
|
|
||||||
|
|
||||||
endif # CAN
|
|
||||||
|
|
||||||
config ARCH_HAVE_PWM_PULSECOUNT
|
config ARCH_HAVE_PWM_PULSECOUNT
|
||||||
bool
|
bool
|
||||||
|
|||||||
@@ -52,6 +52,7 @@ VPATH = .
|
|||||||
include analog$(DELIM)Make.defs
|
include analog$(DELIM)Make.defs
|
||||||
include audio$(DELIM)Make.defs
|
include audio$(DELIM)Make.defs
|
||||||
include bch$(DELIM)Make.defs
|
include bch$(DELIM)Make.defs
|
||||||
|
include can$(DELIM)Make.defs
|
||||||
include i2c$(DELIM)Make.defs
|
include i2c$(DELIM)Make.defs
|
||||||
include input$(DELIM)Make.defs
|
include input$(DELIM)Make.defs
|
||||||
include ioexpander$(DELIM)Make.defs
|
include ioexpander$(DELIM)Make.defs
|
||||||
|
|||||||
+4
-4
@@ -12,10 +12,6 @@ Contents:
|
|||||||
Files in this directory
|
Files in this directory
|
||||||
^^^^^^^^^^^^^^^^^^^^^^^
|
^^^^^^^^^^^^^^^^^^^^^^^
|
||||||
|
|
||||||
can.c
|
|
||||||
This is a CAN driver. See include/nuttx/drivers/can.h for usage
|
|
||||||
information.
|
|
||||||
|
|
||||||
dev_null.c and dev_zero.c
|
dev_null.c and dev_zero.c
|
||||||
These files provide the standard /dev/null and /dev/zero devices.
|
These files provide the standard /dev/null and /dev/zero devices.
|
||||||
See include/nuttx/fs/fs.h for functions that should be called if you
|
See include/nuttx/fs/fs.h for functions that should be called if you
|
||||||
@@ -55,6 +51,10 @@ bch/
|
|||||||
performed by loop.c. See include/nuttx/fs/fs.h for registration
|
performed by loop.c. See include/nuttx/fs/fs.h for registration
|
||||||
information.
|
information.
|
||||||
|
|
||||||
|
can/
|
||||||
|
This is the CAN drivers and logic support. See include/nuttx/can/can.h
|
||||||
|
for usage information.
|
||||||
|
|
||||||
contactless/
|
contactless/
|
||||||
Contactless devices are related to wireless devices. They are not
|
Contactless devices are related to wireless devices. They are not
|
||||||
communication devices with other similar peers, but couplers/interfaces
|
communication devices with other similar peers, but couplers/interfaces
|
||||||
|
|||||||
@@ -0,0 +1,127 @@
|
|||||||
|
#
|
||||||
|
# For a description of the syntax of this configuration file,
|
||||||
|
# see the file kconfig-language.txt in the NuttX tools repository.
|
||||||
|
#
|
||||||
|
|
||||||
|
if CAN
|
||||||
|
|
||||||
|
config CAN_EXTID
|
||||||
|
bool "CAN extended IDs"
|
||||||
|
default n
|
||||||
|
---help---
|
||||||
|
Enables support for the 29-bit extended ID. Default Standard 11-bit
|
||||||
|
IDs.
|
||||||
|
|
||||||
|
config ARCH_HAVE_CAN_ERRORS
|
||||||
|
bool
|
||||||
|
default n
|
||||||
|
|
||||||
|
config CAN_ERRORS
|
||||||
|
bool "CAN error reporting"
|
||||||
|
default n
|
||||||
|
depends on ARCH_HAVE_CAN_ERRORS
|
||||||
|
---help---
|
||||||
|
Support CAN error reporting. If this option is selected then CAN
|
||||||
|
error reporting is enabled. In the event of an error, the ch_error
|
||||||
|
bit will be set in the CAN message and the following message payload
|
||||||
|
will include a more detailed description of certain errors.
|
||||||
|
|
||||||
|
config CAN_FD
|
||||||
|
bool "CAN FD"
|
||||||
|
default n
|
||||||
|
---help---
|
||||||
|
Enables support for the CAN_FD mode.
|
||||||
|
|
||||||
|
config CAN_FIFOSIZE
|
||||||
|
int "CAN driver I/O buffer size"
|
||||||
|
default 8
|
||||||
|
---help---
|
||||||
|
The size of the circular buffer of CAN messages. Default: 8
|
||||||
|
|
||||||
|
config CAN_NPENDINGRTR
|
||||||
|
int "Number of pending RTRs"
|
||||||
|
default 4
|
||||||
|
---help---
|
||||||
|
The size of the list of pending RTR requests. Default: 4
|
||||||
|
|
||||||
|
config CAN_TXREADY
|
||||||
|
bool "can_txready interface"
|
||||||
|
default n
|
||||||
|
select SCHED_WORKQUEUE
|
||||||
|
---help---
|
||||||
|
This selection enables the can_txready() interface. This interface
|
||||||
|
is needed only for CAN hardware that supports queing of outgoing
|
||||||
|
messages in a H/W FIFO.
|
||||||
|
|
||||||
|
The CAN upper half driver also supports a queue of output messages
|
||||||
|
in a S/W FIFO. Messages are added to that queue when when
|
||||||
|
can_write() is called and removed from the queue in can_txdone()
|
||||||
|
when each TX message is complete.
|
||||||
|
|
||||||
|
After each message is added to the S/W FIFO, the CAN upper half
|
||||||
|
driver will attempt to send the message by calling into the lower
|
||||||
|
half driver. That send will not be performed if the lower half
|
||||||
|
driver is busy, i.e., if dev_txready() returns false. In that
|
||||||
|
case, the number of messages in the S/W FIFO can grow. If the
|
||||||
|
S/W FIFO becomes full, then can_write() will wait for space in
|
||||||
|
the S/W FIFO.
|
||||||
|
|
||||||
|
If the CAN hardware does not support a H/W FIFO then busy means
|
||||||
|
that the hardware is actively sending the message and is
|
||||||
|
guaranteed to become non busy (i.e, dev_txready()) when the
|
||||||
|
send transfer completes and can_txdone() is called. So the call
|
||||||
|
to can_txdone() means that the transfer has completed and also
|
||||||
|
that the hardware is ready to accept another transfer.
|
||||||
|
|
||||||
|
If the CAN hardware supports a H/W FIFO, can_txdone() is not
|
||||||
|
called when the tranfer is complete, but rather when the
|
||||||
|
transfer is queued in the H/W FIFO. When the H/W FIFO becomes
|
||||||
|
full, then dev_txready() will report false and the number of
|
||||||
|
queued messages in the S/W FIFO will grow.
|
||||||
|
|
||||||
|
There is no mechanism in this case to inform the upper half
|
||||||
|
driver when the hardware is again available, when there is
|
||||||
|
again space in the H/W FIFO. can_txdone() will not be called
|
||||||
|
again. If the S/W FIFO becomes full, then the upper half
|
||||||
|
driver will wait for space to become available, but there is
|
||||||
|
no event to awaken it and the driver will hang.
|
||||||
|
|
||||||
|
Enabling this feature adds support for the can_txready()
|
||||||
|
interface. This function is called from the lower half
|
||||||
|
driver's CAN interrupt handler each time a TX transfer
|
||||||
|
completes. This is a sure indication that the H/W FIFO is
|
||||||
|
no longer full. can_txready() will then awaken the
|
||||||
|
can_write() logic and the hang condition is avoided.
|
||||||
|
|
||||||
|
choice
|
||||||
|
prompt "TX Ready Work Queue"
|
||||||
|
default CAN_TXREADY_HIPRI
|
||||||
|
depends on CAN_TXREADY
|
||||||
|
|
||||||
|
config CAN_TXREADY_LOPRI
|
||||||
|
bool "Low-priority work queue"
|
||||||
|
select SCHED_LPWORK
|
||||||
|
|
||||||
|
config CAN_TXREADY_HIPRI
|
||||||
|
bool "High-priority work queue"
|
||||||
|
select SCHED_HPWORK
|
||||||
|
|
||||||
|
endchoice # TX Ready Work Queue
|
||||||
|
|
||||||
|
config CAN_LOOPBACK
|
||||||
|
bool "CAN loopback mode"
|
||||||
|
default n
|
||||||
|
---help---
|
||||||
|
A CAN driver may or may not support a loopback mode for testing. If the
|
||||||
|
driver does support loopback mode, the setting will enable it. (If the
|
||||||
|
driver does not, this setting will have no effect).
|
||||||
|
|
||||||
|
config CAN_NPOLLWAITERS
|
||||||
|
int "Number of poll waiters"
|
||||||
|
default 2
|
||||||
|
depends on !DISABLE_POLL
|
||||||
|
---help---
|
||||||
|
The maximum number of threads that may be waiting on the
|
||||||
|
poll method.
|
||||||
|
|
||||||
|
endif # CAN
|
||||||
@@ -0,0 +1,52 @@
|
|||||||
|
############################################################################
|
||||||
|
# drivers/can/Make.defs
|
||||||
|
#
|
||||||
|
# Copyright (C) 2017 Gregory Nutt. All rights reserved.
|
||||||
|
# Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
#
|
||||||
|
# Redistribution and use in source and binary forms, with or without
|
||||||
|
# modification, are permitted provided that the following conditions
|
||||||
|
# are met:
|
||||||
|
#
|
||||||
|
# 1. Redistributions of source code must retain the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer.
|
||||||
|
# 2. Redistributions in binary form must reproduce the above copyright
|
||||||
|
# notice, this list of conditions and the following disclaimer in
|
||||||
|
# the documentation and/or other materials provided with the
|
||||||
|
# distribution.
|
||||||
|
# 3. Neither the name NuttX nor the names of its contributors may be
|
||||||
|
# used to endorse or promote products derived from this software
|
||||||
|
# without specific prior written permission.
|
||||||
|
#
|
||||||
|
# THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||||
|
# "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||||
|
# LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||||
|
# FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||||
|
# COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||||
|
# INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||||
|
# BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||||
|
# OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||||
|
# AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||||
|
# LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||||
|
# ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||||
|
# POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
#
|
||||||
|
############################################################################
|
||||||
|
|
||||||
|
# Don't build anything if there is no CAN support
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_CAN),y)
|
||||||
|
|
||||||
|
CSRCS += can.c
|
||||||
|
|
||||||
|
ifeq ($(CONFIG_CAN_MCP2515),y)
|
||||||
|
CSRCS += mcp2515.c
|
||||||
|
endif
|
||||||
|
|
||||||
|
# Include CAN device driver build support
|
||||||
|
|
||||||
|
DEPPATH += --dep-path can
|
||||||
|
VPATH += :can
|
||||||
|
CFLAGS += ${shell $(INCDIR) $(INCDIROPT) "$(CC)" $(TOPDIR)$(DELIM)drivers$(DELIM)can}
|
||||||
|
endif
|
||||||
|
|
||||||
@@ -1,5 +1,5 @@
|
|||||||
/****************************************************************************
|
/****************************************************************************
|
||||||
* drivers/can.c
|
* drivers/can/can.c
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008-2009, 2011-2012, 2014-2015 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2008-2009, 2011-2012, 2014-2015 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
@@ -57,7 +57,7 @@
|
|||||||
#include <nuttx/arch.h>
|
#include <nuttx/arch.h>
|
||||||
#include <nuttx/semaphore.h>
|
#include <nuttx/semaphore.h>
|
||||||
#include <nuttx/fs/fs.h>
|
#include <nuttx/fs/fs.h>
|
||||||
#include <nuttx/drivers/can.h>
|
#include <nuttx/can/can.h>
|
||||||
|
|
||||||
#ifdef CONFIG_CAN_TXREADY
|
#ifdef CONFIG_CAN_TXREADY
|
||||||
# include <nuttx/wqueue.h>
|
# include <nuttx/wqueue.h>
|
||||||
@@ -6,7 +6,7 @@
|
|||||||
* Author: Li Zhuoyi <lzyy.cn@gmail.com>
|
* Author: Li Zhuoyi <lzyy.cn@gmail.com>
|
||||||
* Gregory Nutt <gnutt@nuttx.org>
|
* Gregory Nutt <gnutt@nuttx.org>
|
||||||
*
|
*
|
||||||
* Derived from include/nuttx/drivers/can.h
|
* Derived from include/nuttx/can/can.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008, 2009 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2008, 2009 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
|||||||
@@ -6,7 +6,7 @@
|
|||||||
* Author: Li Zhuoyi <lzyy.cn@gmail.com>
|
* Author: Li Zhuoyi <lzyy.cn@gmail.com>
|
||||||
* History: 0.1 2011-08-04 initial version
|
* History: 0.1 2011-08-04 initial version
|
||||||
*
|
*
|
||||||
* Derived from include/nuttx/drivers/can.h
|
* Derived from include/nuttx/can/can.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008, 2009 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2008, 2009 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
|
|||||||
@@ -1,5 +1,5 @@
|
|||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* include/nuttx/drivers/can.h
|
* include/nuttx/can/can.h
|
||||||
*
|
*
|
||||||
* Copyright (C) 2008, 2009, 2011-2012, 2015-2017 Gregory Nutt. All rights reserved.
|
* Copyright (C) 2008, 2009, 2011-2012, 2015-2017 Gregory Nutt. All rights reserved.
|
||||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||||
@@ -33,8 +33,8 @@
|
|||||||
*
|
*
|
||||||
************************************************************************************/
|
************************************************************************************/
|
||||||
|
|
||||||
#ifndef __INCLUDE_NUTTX_DRVERS_CAN_H
|
#ifndef __INCLUDE_NUTTX_CAN_CAN_H
|
||||||
#define __INCLUDE_NUTTX_DRVERS_CAN_H
|
#define __INCLUDE_NUTTX_CAN_CAN_H
|
||||||
|
|
||||||
/************************************************************************************
|
/************************************************************************************
|
||||||
* Included Files
|
* Included Files
|
||||||
@@ -819,4 +819,4 @@ int can_txready(FAR struct can_dev_s *dev);
|
|||||||
#endif
|
#endif
|
||||||
|
|
||||||
#endif /* CONFIG_CAN */
|
#endif /* CONFIG_CAN */
|
||||||
#endif /* __INCLUDE_NUTTX_DRVERS_CAN_H */
|
#endif /* __INCLUDE_NUTTX_CAN_CAN_H */
|
||||||
@@ -357,7 +357,7 @@
|
|||||||
#define _RELAYIOC(nr) _IOC(_RELAYBASE,nr)
|
#define _RELAYIOC(nr) _IOC(_RELAYBASE,nr)
|
||||||
|
|
||||||
/* CAN driver ioctl definitions *********************************************/
|
/* CAN driver ioctl definitions *********************************************/
|
||||||
/* (see nuttx/drivers/can.h */
|
/* (see nuttx/can/can.h */
|
||||||
|
|
||||||
#define _CANIOCVALID(c) (_IOC_TYPE(c)==_CANBASE)
|
#define _CANIOCVALID(c) (_IOC_TYPE(c)==_CANBASE)
|
||||||
#define _CANIOC(nr) _IOC(_CANBASE,nr)
|
#define _CANIOC(nr) _IOC(_CANBASE,nr)
|
||||||
|
|||||||
Reference in New Issue
Block a user