From 007e258c2b4efd25f89fa00b617427be196384e6 Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Wed, 5 Aug 2015 16:22:40 -0600 Subject: [PATCH] Update some function headers --- ChangeLog | 5 +++++ arch | 2 +- drivers/can.c | 25 +++++++++++++++++++++---- include/nuttx/can.h | 10 ++++++++-- 4 files changed, 35 insertions(+), 7 deletions(-) diff --git a/ChangeLog b/ChangeLog index 08f1df472d..3dec204a8f 100755 --- a/ChangeLog +++ b/ChangeLog @@ -10780,3 +10780,8 @@ OS. It is a non-standard but more efficient version of sem_timedwait() for use in higher performance device drivers (2015-08-01). * drivers/net/slip.c: Fix another compilation error (2015-08-02). + * drivers/can.c include/nuttx/can.h, and fs/fs.h: Add CAN IOCTL command + definitions to manage CAN message filtering (2015-08-05) + * drivers/Kconfig and can.c: Add configuration to support DLC to byte + conversions needed for CAN FD mode (2015-08-05). + diff --git a/arch b/arch index b331b89caf..37ea27a989 160000 --- a/arch +++ b/arch @@ -1 +1 @@ -Subproject commit b331b89caf5aa68bc8b8e585b35e10777f469e1c +Subproject commit 37ea27a989e81fcbba814431b389ffe05286b0db diff --git a/drivers/can.c b/drivers/can.c index f11e7d66eb..f1eb4d195a 100644 --- a/drivers/can.c +++ b/drivers/can.c @@ -135,7 +135,7 @@ static const struct file_operations g_canops = ****************************************************************************/ /**************************************************************************** - * Name: can_dlc2bytes and can_bytes2dlc + * Name: can_dlc2bytes * * Description: * In the CAN FD format, the coding of the DLC differs from the standard @@ -145,11 +145,10 @@ static const struct file_operations g_canops = * in the range 12 to 64. * * Input Parameter: - * dlc - the DLC to convert to a byte count, OR - * nbytes - the byte count to convert to a DLC + * dlc - the DLC value to convert to a byte count * * Returned Value: - * The converted value + * The number of bytes corresponding to the DLC value. * ****************************************************************************/ @@ -184,6 +183,24 @@ static uint8_t can_dlc2bytes(uint8_t dlc) return dlc; } +/**************************************************************************** + * Name: can_bytes2dlc + * + * Description: + * In the CAN FD format, the coding of the DLC differs from the standard + * CAN format. The DLC codes 0 to 8 have the same coding as in standard + * CAN. But the codes 9 to 15 all imply a data field of 8 bytes with + * standard CAN. In CAN FD mode, the values 9 to 15 are encoded to values + * in the range 12 to 64. + * + * Input Parameter: + * nbytes - the byte count to convert to a DLC value + * + * Returned Value: + * The encoded DLC value corresponding to at least that number of bytes. + * + ****************************************************************************/ + #if 0 /* Not used */ static uint8_t can_bytes2dlc(FAR struct sam_can_s *priv, uint8_t nbytes) { diff --git a/include/nuttx/can.h b/include/nuttx/can.h index 25594814ef..69313024da 100644 --- a/include/nuttx/can.h +++ b/include/nuttx/can.h @@ -61,6 +61,8 @@ * CONFIG_STM32_CAN2 must also be defined) * CONFIG_CAN_EXTID - Enables support for the 29-bit extended ID. Default * Standard 11-bit IDs. + * CONFIG_CAN_FD - Enable support for CAN FD mode. For the upper half driver, this + * just means handling encoded DLC values (for values of DLC > 9). * CONFIG_CAN_FIFOSIZE - The size of the circular buffer of CAN messages. * Default: 8 * CONFIG_CAN_NPENDINGRTR - The size of the list of pending RTR requests. @@ -110,13 +112,13 @@ #define CAN_MSGLEN(nbytes) (sizeof(struct can_msg_s) - CAN_MAXDATALEN + (nbytes)) -/* Built-in ioctl commands support by the upper half driver. +/* Ioctl commands supported by the upper half CAN driver. * * CANIOC_RTR: * Description: Send the remote transmission request and wait for the response. * Argument: A reference to struct canioc_rtr_s * - * Ioctl commands that may or may not be supported by the lower half driver. + * Ioctl commands that may or may not be supported by the lower half CAN driver. * * CANIOC_ADD_STDFILTER: * Description: Add an address filter for a standard 11 bit address. @@ -124,6 +126,7 @@ * Returned Value: A non-negative filter ID is returned on success. * Otherwise -1 (ERROR) is returned with the errno * variable set to indicate the nature of the error. + * Dependencies: Requires CONFIG_CAN_EXID *not* defined * * CANIOC_ADD_EXTFILTER: * Description: Add an address filter for a extended 28 bit address. @@ -131,6 +134,7 @@ * Returned Value: A non-negative filter ID is returned on success. * Otherwise -1 (ERROR) is returned with the errno * variable set to indicate the nature of the error. + * Dependencies: Requires CONFIG_CAN_EXID=y * * CANIOC_DEL_STDFILTER: * Description: Remove an address filter for a standard 11 bit address. @@ -139,6 +143,7 @@ * Returned Value: Zero (OK) is returned on success. Otherwise -1 (ERROR) * is returned with the errno variable set to indicate the * nature of the error. + * Dependencies: Requires CONFIG_CAN_EXID *not* defined * * CANIOC_DEL_EXTFILTER: * Description: Remove an address filter for a standard 28 bit address. @@ -147,6 +152,7 @@ * Returned Value: Zero (OK) is returned on success. Otherwise -1 (ERROR) * is returned with the errno variable set to indicate the * nature of the error. + * Dependencies: Requires CONFIG_CAN_EXID=y */ #define CANIOC_RTR _CANIOC(1)