This is an automated email from the ASF dual-hosted git repository.

ligd pushed a commit to branch master
in repository https://gitbox.apache.org/repos/asf/nuttx.git


The following commit(s) were added to refs/heads/master by this push:
     new 366ede9530 add  lin status changes the format of the reported frame 
and add the macros that lin needs
366ede9530 is described below

commit 366ede9530a637238c1069cd2aa67e76648e8c83
Author: wangxiaoxin <wangxiao...@xiaomi.com>
AuthorDate: Thu Jun 27 16:26:26 2024 +0800

    add  lin status changes the format of the reported frame and add the macros 
that lin needs
    
    Signed-off-by: wangxiaoxin <wangxiao...@xiaomi.com>
---
 include/nuttx/lin.h | 66 ++++++++++++++++++++++++++++++++++++-----------------
 1 file changed, 45 insertions(+), 21 deletions(-)

diff --git a/include/nuttx/lin.h b/include/nuttx/lin.h
index 77dd75a157..d9907e9c92 100644
--- a/include/nuttx/lin.h
+++ b/include/nuttx/lin.h
@@ -30,6 +30,8 @@
 #include <nuttx/config.h>
 #include <nuttx/can.h>
 
+#ifdef CONFIG_NET_CAN
+
 /****************************************************************************
  * Pre-processor Definitions
  ****************************************************************************/
@@ -38,37 +40,49 @@
 #define LIN_ID_MASK               ((1 << LIN_ID_BITS) - 1)
 #define LIN_ID_MAX                LIN_ID_MASK
 
-#define LIN_CTRL_FRAME            CAN_EFF_FLAG
+#define LIN_CTRL_FLAG             CAN_EFF_FLAG  /* Describe control 
information(such as wirte et.) */
+#define LIN_RTR_FLAG              CAN_RTR_FLAG  /* Describe the direction of 
sending and receiving */
+#define LIN_ERR_FLAG              CAN_ERR_FLAG  /* The flag indicate  this is 
LIN err_frame */
 
-/* When slave response to master, slave node should send  frame immediately
- * which already be cached in last transmission in case of response interval
- * over time;
+/* Bit flags on can_frame.types
+ *
+ * Use can_frame.types to identify other special frame.
+ *
+ * LIN_TCF_FLAG : TxConfirmation message frame. Lower_half use this flag to
+ *                confirm frame-transmit
+ *
+ * LIN_EVT_FLAG : Event message frame. Lower_half use this flag to report
+ *                state switch event
+ *
+ * LIN_CACHE_RESP_FLAG: When slave response to master, slave node should send
+ *                      frame immediately which already be cached in last
+ *                      transmission in case of response interval over time.
+ *
+ * LIN_CHKSUM_EXT_FLAG: LIN checksum have two types, default type will be
+ *                      classic checksum
+ *
+ * LIN_SINGLE_RESP_FLAG: Cache LIN frame only work once, then will be cleared
  */
 
-#define LIN_CACHE_RESPONSE        (1 << (LIN_ID_BITS))
-
-/* LIN checksum have two types, default type will be classic checksum */
-
-#define LIN_CHECKSUM_EXTENDED     (1 << (LIN_ID_BITS + 1))
-
-/* Cache LIN frame only work once. then will be clear */
-
-#define LIN_SINGLE_RESPONSE       (1 << (LIN_ID_BITS + 2))
+#define LIN_TCF_FLAG              CAN_TCF_FLAG
+#define LIN_EVT_FLAG              CAN_EVT_FLAG
+#define LIN_CACHE_RESP_FLAG       (1 << (CANFD_FLAGS_BITS + 2))
+#define LIN_CHKSUM_EXT_FLAG       (1 << (CANFD_FLAGS_BITS + 3))
+#define LIN_SINGLE_RESP_FLAG      (1 << (CANFD_FLAGS_BITS + 4))
 
 /* LIN Error Indications ****************************************************/
 
 /* LIN_ERR_FLAG: Used to distinguish it from ordinary frames.
- * The error frame consists of err_flag、err_class(defined in data[0])
- * and err_reason(defined in data[1] to data[4]).
+ * The error frame consists of err_flag(LIN_ERR_FLAG)、err_class
+ * (defined in data[0]) and err_reason(defined in data[1] to data[4]).
  * The error frame is described using the following structure:
  * struct can_frame {
  *    canid_t can_id;
  *    uint8_t can_dlc;
- *    uint8_t __pad;
- *    uint8_t __res0;
+ *    uint16_t flags;
  *    uint8_t __res1;
  *    uint8_t data[CAN_MAX_DLEN] __attribute__((aligned(8)));
- *  };
+ *  }__attribute__((packed));
  *
  * Error frame description format:
  *
@@ -85,8 +99,6 @@
  *              define in data[0] ~ data[4] in can_frame.
  */
 
-#define LIN_ERR_FLAG              CAN_ERR_FLAG  /* The flag indicate  this is 
LIN err_frame */
-
 /* ERR_CLASS in  data[0] */
 
 #define LIN_ERR_UNSPEC            0x00     /* Unspecified error */
@@ -124,7 +136,7 @@
 #define LIN_ERR_BUS_PID           (1 << 0) /* Bit 0: Pid received back is not 
equal to the pid sent */
 #define LIN_ERR_BUS_TXCKSUM       (1 << 1) /* Bit 1: Checksum received back is 
not equal to checksum sent */
 #define LIN_ERR_BUS_SYNC          (1 << 2) /* Bit 2: Master send sync, but 
receive back sync is not 0x55 */
-#define LIN_ERR_BUS_DATA          (1 << 3) /* Bit 3: Data received back is not 
equal to the data sent */ 
+#define LIN_ERR_BUS_DATA          (1 << 3) /* Bit 3: Data received back is not 
equal to the data sent */
 
 /* Data[4] error status of LIN-controller */
 
@@ -132,6 +144,17 @@
 #define LIN_ERR_CRTL_RXOVERFLOW   (1 << 0) /* Hardware controller receive 
overflow */
 #define LIN_ERR_CTRL_FRAMEERROR   (1 << 1) /* Hardware controller frame error 
*/
 
+/* LIN States Indications ***************************************************/
+
+/* lower_half State switch events are defined in  data[0] */
+
+#define LIN_EVT_UNSPEC           0x00     /* Unspecified state event */
+#define LIN_EVT_WAKEUP           (1 << 0) /* Already send a wake-up command to 
lin_bus */
+#define LIN_EVT_WAKEUP_PASSIVE   (1 << 1) /* Wake up when detecte low level 
signal of bus a for a period of time(such as 250us-5ms) */
+#define LIN_EVT_SLEEP            (1 << 2) /* Send a sleep command(0x3c) to the 
bus, only Master */
+#define LIN_EVT_SLEEP_PASSIVE    (1 << 3) /* Receive a sleep command from bus 
*/
+#define LIN_EVT_SLEEP_IDLE       (1 << 4) /* Go to sleep when bus keep in the 
inactive for a period of time(such as 4s) */
+
 /****************************************************************************
  * Public Function Prototypes
  ****************************************************************************/
@@ -150,4 +173,5 @@ extern "C"
 }
 #endif
 
+#endif /* CONFIG_CAN */
 #endif /* __INCLUDE_NUTTX_LIN_H */

Reply via email to