vbenso commented on code in PR #5987:
URL: https://github.com/apache/incubator-nuttx/pull/5987#discussion_r962044521


##########
arch/xtensa/src/esp32/hardware/esp32_twai.h:
##########
@@ -0,0 +1,856 @@
+/****************************************************************************
+ * arch/xtensa/src/esp32/hardware/esp32_twai.h
+ *
+ * Licensed to the Apache Software Foundation (ASF) under one or more
+ * contributor license agreements.  See the NOTICE file distributed with
+ * this work for additional information regarding copyright ownership.  The
+ * ASF licenses this file to you under the Apache License, Version 2.0 (the
+ * "License"); you may not use this file except in compliance with the
+ * License.  You may obtain a copy of the License at
+ *
+ *   http://www.apache.org/licenses/LICENSE-2.0
+ *
+ * Unless required by applicable law or agreed to in writing, software
+ * distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
+ * WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.  See the
+ * License for the specific language governing permissions and limitations
+ * under the License.
+ *
+ ****************************************************************************/
+
+#ifndef __ARCH_XTENSA_SRC_ESP32_HARDWARE_ESP32_TWAI_H
+#define __ARCH_XTENSA_SRC_ESP32_HARDWARE_ESP32_TWAI_H
+
+/****************************************************************************
+ * Included Files
+ ****************************************************************************/
+
+#include "esp32_soc.h"
+
+/****************************************************************************
+ * Pre-processor Definitions
+ ****************************************************************************/
+
+/* TWAI_MODE_REG register
+ * Mode Register
+ */
+
+#define TWAI_MODE_REG (DR_REG_TWAI_BASE + 0x0)
+
+/* TWAI_RX_FILTER_MODE : R/W; bitpos: [3]; default: 0;
+ * This bit is used to configure the filter mode. 0: Dual filter mode; 1:
+ * Single filter mode.
+ */
+
+#define TWAI_RX_FILTER_MODE    (BIT(3))
+#define TWAI_RX_FILTER_MODE_M  (TWAI_RX_FILTER_MODE_V << TWAI_RX_FILTER_MODE_S)
+#define TWAI_RX_FILTER_MODE_V  0x00000001
+#define TWAI_RX_FILTER_MODE_S  3
+
+/* TWAI_SELF_TEST_MODE : R/W; bitpos: [2]; default: 0;
+ * 1: Self test mode. In this mode the TX nodes can perform a successful
+ * transmission without receiving the acknowledge signal. This mode is often
+ * used to test a single node with the self reception request command.
+ */
+
+#define TWAI_SELF_TEST_MODE    (BIT(2))
+#define TWAI_SELF_TEST_MODE_M  (TWAI_SELF_TEST_MODE_V << TWAI_SELF_TEST_MODE_S)
+#define TWAI_SELF_TEST_MODE_V  0x00000001
+#define TWAI_SELF_TEST_MODE_S  2
+
+/* TWAI_LISTEN_ONLY_MODE : R/W; bitpos: [1]; default: 0;
+ * 1: Listen only mode. In this mode the nodes will only receive messages
+ * from the bus, without generating the acknowledge signal nor updating the
+ * RX error counter.
+ */
+
+#define TWAI_LISTEN_ONLY_MODE    (BIT(1))
+#define TWAI_LISTEN_ONLY_MODE_M  (TWAI_LISTEN_ONLY_MODE_V << 
TWAI_LISTEN_ONLY_MODE_S)
+#define TWAI_LISTEN_ONLY_MODE_V  0x00000001
+#define TWAI_LISTEN_ONLY_MODE_S  1
+
+/* TWAI_RESET_MODE : R/W; bitpos: [0]; default: 1;
+ * This bit is used to configure the operating mode of the TWAI Controller.
+ * 1: Reset mode; 0: Operating mode.
+ */
+
+#define TWAI_RESET_MODE    (BIT(0))
+#define TWAI_RESET_MODE_M  (TWAI_RESET_MODE_V << TWAI_RESET_MODE_S)
+#define TWAI_RESET_MODE_V  0x00000001
+#define TWAI_RESET_MODE_S  0
+
+/* TWAI_CMD_REG register
+ * Command Register
+ */
+
+#define TWAI_CMD_REG (DR_REG_TWAI_BASE + 0x4)
+
+/* TWAI_SELF_RX_REQ : WO; bitpos: [4]; default: 0;
+ * Self reception request command. Set the bit to 1 to allow a message be
+ * transmitted and received simultaneously.
+ */
+
+#define TWAI_SELF_RX_REQ    (BIT(4))
+#define TWAI_SELF_RX_REQ_M  (TWAI_SELF_RX_REQ_V << TWAI_SELF_RX_REQ_S)
+#define TWAI_SELF_RX_REQ_V  0x00000001
+#define TWAI_SELF_RX_REQ_S  4
+
+/* TWAI_CLR_OVERRUN : WO; bitpos: [3]; default: 0;
+ * Set the bit to 1 to clear the data overrun status bit.
+ */
+
+#define TWAI_CLR_OVERRUN    (BIT(3))
+#define TWAI_CLR_OVERRUN_M  (TWAI_CLR_OVERRUN_V << TWAI_CLR_OVERRUN_S)
+#define TWAI_CLR_OVERRUN_V  0x00000001
+#define TWAI_CLR_OVERRUN_S  3
+
+/* TWAI_RELEASE_BUF : WO; bitpos: [2]; default: 0;
+ * Set the bit to 1 to release the RX buffer.
+ */
+
+#define TWAI_RELEASE_BUF    (BIT(2))
+#define TWAI_RELEASE_BUF_M  (TWAI_RELEASE_BUF_V << TWAI_RELEASE_BUF_S)
+#define TWAI_RELEASE_BUF_V  0x00000001
+#define TWAI_RELEASE_BUF_S  2
+
+/* TWAI_ABORT_TX : WO; bitpos: [1]; default: 0;
+ * Set the bit to 1 to cancel a pending transmission request.
+ */
+
+#define TWAI_ABORT_TX    (BIT(1))
+#define TWAI_ABORT_TX_M  (TWAI_ABORT_TX_V << TWAI_ABORT_TX_S)
+#define TWAI_ABORT_TX_V  0x00000001
+#define TWAI_ABORT_TX_S  1
+
+/* TWAI_TX_REQ : WO; bitpos: [0]; default: 0;
+ * Set the bit to 1 to allow the driving nodes start transmission.
+ */
+
+#define TWAI_TX_REQ    (BIT(0))
+#define TWAI_TX_REQ_M  (TWAI_TX_REQ_V << TWAI_TX_REQ_S)
+#define TWAI_TX_REQ_V  0x00000001
+#define TWAI_TX_REQ_S  0
+
+/* TWAI_STATUS_REG register
+ * Status register
+ */
+
+#define TWAI_STATUS_REG (DR_REG_TWAI_BASE + 0x8)
+
+/* TWAI_MISS_ST : RO; bitpos: [8]; default: 0;
+ * This bit reflects whether the data packet in the RX FIFO is complete. 1:
+ * The current packet is missing; 0: The current packet is complete
+ */
+
+#define TWAI_MISS_ST    (BIT(8))
+#define TWAI_MISS_ST_M  (TWAI_MISS_ST_V << TWAI_MISS_ST_S)
+#define TWAI_MISS_ST_V  0x00000001
+#define TWAI_MISS_ST_S  8
+
+/* TWAI_BUS_OFF_ST : RO; bitpos: [7]; default: 0;
+ * 1: In bus-off status, the TWAI Controller is no longer involved in bus
+ * activities.
+ */
+
+#define TWAI_BUS_OFF_ST    (BIT(7))
+#define TWAI_BUS_OFF_ST_M  (TWAI_BUS_OFF_ST_V << TWAI_BUS_OFF_ST_S)
+#define TWAI_BUS_OFF_ST_V  0x00000001
+#define TWAI_BUS_OFF_ST_S  7
+
+/* TWAI_ERR_ST : RO; bitpos: [6]; default: 0;
+ * 1: At least one of the RX/TX error counter has reached or exceeded the
+ * value set in register TWAI_ERR_WARNING_LIMIT_REG.
+ */
+
+#define TWAI_ERR_ST    (BIT(6))
+#define TWAI_ERR_ST_M  (TWAI_ERR_ST_V << TWAI_ERR_ST_S)
+#define TWAI_ERR_ST_V  0x00000001
+#define TWAI_ERR_ST_S  6
+
+/* TWAI_TX_ST : RO; bitpos: [5]; default: 0;
+ * 1: The TWAI Controller is transmitting a message to the bus.
+ */
+
+#define TWAI_TX_ST    (BIT(5))
+#define TWAI_TX_ST_M  (TWAI_TX_ST_V << TWAI_TX_ST_S)
+#define TWAI_TX_ST_V  0x00000001
+#define TWAI_TX_ST_S  5
+
+/* TWAI_RX_ST : RO; bitpos: [4]; default: 0;
+ * 1: The TWAI Controller is receiving a message from the bus.
+ */
+
+#define TWAI_RX_ST    (BIT(4))
+#define TWAI_RX_ST_M  (TWAI_RX_ST_V << TWAI_RX_ST_S)
+#define TWAI_RX_ST_V  0x00000001
+#define TWAI_RX_ST_S  4
+
+/* TWAI_TX_COMPLETE : RO; bitpos: [3]; default: 0;
+ * 1: The TWAI controller has successfully received a packet from the bus.
+ */
+
+#define TWAI_TX_COMPLETE    (BIT(3))
+#define TWAI_TX_COMPLETE_M  (TWAI_TX_COMPLETE_V << TWAI_TX_COMPLETE_S)
+#define TWAI_TX_COMPLETE_V  0x00000001
+#define TWAI_TX_COMPLETE_S  3
+
+/* TWAI_TX_BUF_ST : RO; bitpos: [2]; default: 0;
+ * 1: The TX buffer is empty, the CPU may write a message into it.
+ */
+
+#define TWAI_TX_BUF_ST    (BIT(2))
+#define TWAI_TX_BUF_ST_M  (TWAI_TX_BUF_ST_V << TWAI_TX_BUF_ST_S)
+#define TWAI_TX_BUF_ST_V  0x00000001
+#define TWAI_TX_BUF_ST_S  2
+
+/* TWAI_OVERRUN_ST : RO; bitpos: [1]; default: 0;
+ * 1: The RX FIFO is full and data overrun has occurred.
+ */
+
+#define TWAI_OVERRUN_ST    (BIT(1))
+#define TWAI_OVERRUN_ST_M  (TWAI_OVERRUN_ST_V << TWAI_OVERRUN_ST_S)
+#define TWAI_OVERRUN_ST_V  0x00000001
+#define TWAI_OVERRUN_ST_S  1
+
+/* TWAI_RX_BUF_ST : RO; bitpos: [0]; default: 0;
+ * 1: The data in the RX buffer is not empty, with at least one received
+ * data packet.
+ */
+
+#define TWAI_RX_BUF_ST    (BIT(0))
+#define TWAI_RX_BUF_ST_M  (TWAI_RX_BUF_ST_V << TWAI_RX_BUF_ST_S)
+#define TWAI_RX_BUF_ST_V  0x00000001
+#define TWAI_RX_BUF_ST_S  0
+
+/* TWAI_INT_RAW_REG register
+ * Interrupt Register
+ */
+
+#define TWAI_INT_RAW_REG (DR_REG_TWAI_BASE + 0xc)
+
+/* TWAI_BUS_ERR_INT_ST : RO; bitpos: [7]; default: 0;
+ * Error interrupt. If this bit is set to 1, it indicates an error is
+ * detected on the bus.
+ */
+
+#define TWAI_BUS_ERR_INT_ST    (BIT(7))
+#define TWAI_BUS_ERR_INT_ST_M  (TWAI_BUS_ERR_INT_ST_V << TWAI_BUS_ERR_INT_ST_S)
+#define TWAI_BUS_ERR_INT_ST_V  0x00000001
+#define TWAI_BUS_ERR_INT_ST_S  7
+
+/* TWAI_ARB_LOST_INT_ST : RO; bitpos: [6]; default: 0;
+ * Arbitration lost interrupt. If this bit is set to 1, it indicates an
+ * arbitration lost interrupt is generated.
+ */
+
+#define TWAI_ARB_LOST_INT_ST    (BIT(6))
+#define TWAI_ARB_LOST_INT_ST_M  (TWAI_ARB_LOST_INT_ST_V << 
TWAI_ARB_LOST_INT_ST_S)
+#define TWAI_ARB_LOST_INT_ST_V  0x00000001
+#define TWAI_ARB_LOST_INT_ST_S  6
+
+/* TWAI_ERR_PASSIVE_INT_ST : RO; bitpos: [5]; default: 0;
+ * Error passive interrupt. If this bit is set to 1, it indicates the TWAI
+ * Controller is switched between error active status and error passive
+ * status due to the change of error counters.
+ */
+
+#define TWAI_ERR_PASSIVE_INT_ST    (BIT(5))
+#define TWAI_ERR_PASSIVE_INT_ST_M  (TWAI_ERR_PASSIVE_INT_ST_V << 
TWAI_ERR_PASSIVE_INT_ST_S)
+#define TWAI_ERR_PASSIVE_INT_ST_V  0x00000001
+#define TWAI_ERR_PASSIVE_INT_ST_S  5
+
+/* TWAI_OVERRUN_INT_ST : RO; bitpos: [3]; default: 0;
+ * Data overrun interrupt. If this bit is set to 1, it indicates a data
+ * overrun interrupt is generated in the RX FIFO.
+ */
+
+#define TWAI_OVERRUN_INT_ST    (BIT(3))
+#define TWAI_OVERRUN_INT_ST_M  (TWAI_OVERRUN_INT_ST_V << TWAI_OVERRUN_INT_ST_S)
+#define TWAI_OVERRUN_INT_ST_V  0x00000001
+#define TWAI_OVERRUN_INT_ST_S  3
+
+/* TWAI_ERR_WARN_INT_ST : RO; bitpos: [2]; default: 0;
+ * Error warning interrupt. If this bit is set to 1, it indicates the error
+ * status signal and the bus-off status signal of Status register have
+ * changed (e.g., switched from 0 to 1 or from 1 to 0).
+ */
+
+#define TWAI_ERR_WARN_INT_ST    (BIT(2))
+#define TWAI_ERR_WARN_INT_ST_M  (TWAI_ERR_WARN_INT_ST_V << 
TWAI_ERR_WARN_INT_ST_S)
+#define TWAI_ERR_WARN_INT_ST_V  0x00000001
+#define TWAI_ERR_WARN_INT_ST_S  2
+
+/* TWAI_TX_INT_ST : RO; bitpos: [1]; default: 0;
+ * Transmit interrupt. If this bit is set to 1, it indicates the message
+ * transmitting mis- sion is finished and a new transmission is able to
+ * execute.
+ */
+
+#define TWAI_TX_INT_ST    (BIT(1))
+#define TWAI_TX_INT_ST_M  (TWAI_TX_INT_ST_V << TWAI_TX_INT_ST_S)
+#define TWAI_TX_INT_ST_V  0x00000001
+#define TWAI_TX_INT_ST_S  1
+
+/* TWAI_RX_INT_ST : RO; bitpos: [0]; default: 0;
+ * Receive interrupt. If this bit is set to 1, it indicates there are
+ * messages to be handled in the RX FIFO.
+ */
+
+#define TWAI_RX_INT_ST    (BIT(0))
+#define TWAI_RX_INT_ST_M  (TWAI_RX_INT_ST_V << TWAI_RX_INT_ST_S)
+#define TWAI_RX_INT_ST_V  0x00000001
+#define TWAI_RX_INT_ST_S  0
+
+/* TWAI_INT_ENA_REG register
+ * Interrupt Enable Register
+ */
+
+#define TWAI_INT_ENA_REG (DR_REG_TWAI_BASE + 0x10)
+
+/* TWAI_BUS_ERR_INT_ENA : R/W; bitpos: [7]; default: 0;
+ * Set this bit to 1 to enable error interrupt.
+ */
+
+#define TWAI_BUS_ERR_INT_ENA    (BIT(7))
+#define TWAI_BUS_ERR_INT_ENA_M  (TWAI_BUS_ERR_INT_ENA_V << 
TWAI_BUS_ERR_INT_ENA_S)
+#define TWAI_BUS_ERR_INT_ENA_V  0x00000001
+#define TWAI_BUS_ERR_INT_ENA_S  7
+
+/* TWAI_ARB_LOST_INT_ENA : R/W; bitpos: [6]; default: 0;
+ * Set this bit to 1 to enable arbitration lost interrupt.
+ */
+
+#define TWAI_ARB_LOST_INT_ENA    (BIT(6))
+#define TWAI_ARB_LOST_INT_ENA_M  (TWAI_ARB_LOST_INT_ENA_V << 
TWAI_ARB_LOST_INT_ENA_S)
+#define TWAI_ARB_LOST_INT_ENA_V  0x00000001
+#define TWAI_ARB_LOST_INT_ENA_S  6
+
+/* TWAI_ERR_PASSIVE_INT_ENA : R/W; bitpos: [5]; default: 0;
+ * Set this bit to 1 to enable error passive interrupt.
+ */
+
+#define TWAI_ERR_PASSIVE_INT_ENA    (BIT(5))
+#define TWAI_ERR_PASSIVE_INT_ENA_M  (TWAI_ERR_PASSIVE_INT_ENA_V << 
TWAI_ERR_PASSIVE_INT_ENA_S)
+#define TWAI_ERR_PASSIVE_INT_ENA_V  0x00000001
+#define TWAI_ERR_PASSIVE_INT_ENA_S  5
+
+/* TWAI_OVERRUN_INT_ENA : R/W; bitpos: [3]; default: 0;
+ * Set this bit to 1 to enable data overrun interrupt.
+ */
+
+#define TWAI_OVERRUN_INT_ENA    (BIT(3))
+#define TWAI_OVERRUN_INT_ENA_M  (TWAI_OVERRUN_INT_ENA_V << 
TWAI_OVERRUN_INT_ENA_S)
+#define TWAI_OVERRUN_INT_ENA_V  0x00000001
+#define TWAI_OVERRUN_INT_ENA_S  3
+
+/* TWAI_ERR_WARN_INT_ENA : R/W; bitpos: [2]; default: 0;
+ * Set this bit to 1 to enable error warning interrupt.
+ */
+
+#define TWAI_ERR_WARN_INT_ENA    (BIT(2))
+#define TWAI_ERR_WARN_INT_ENA_M  (TWAI_ERR_WARN_INT_ENA_V << 
TWAI_ERR_WARN_INT_ENA_S)
+#define TWAI_ERR_WARN_INT_ENA_V  0x00000001
+#define TWAI_ERR_WARN_INT_ENA_S  2
+
+/* TWAI_TX_INT_ENA : R/W; bitpos: [1]; default: 0;
+ * Set this bit to 1 to enable transmit interrupt.
+ */
+
+#define TWAI_TX_INT_ENA    (BIT(1))
+#define TWAI_TX_INT_ENA_M  (TWAI_TX_INT_ENA_V << TWAI_TX_INT_ENA_S)
+#define TWAI_TX_INT_ENA_V  0x00000001
+#define TWAI_TX_INT_ENA_S  1
+
+/* TWAI_RX_INT_ENA : R/W; bitpos: [0]; default: 0;
+ * Set this bit to 1 to enable receive interrupt.
+ */
+
+#define TWAI_RX_INT_ENA    (BIT(0))
+#define TWAI_RX_INT_ENA_M  (TWAI_RX_INT_ENA_V << TWAI_RX_INT_ENA_S)
+#define TWAI_RX_INT_ENA_V  0x00000001
+#define TWAI_RX_INT_ENA_S  0
+
+/* TWAI_BUS_TIMING_0_REG register
+ * Bus Timing Register 0
+ */
+
+#define TWAI_BUS_TIMING_0_REG (DR_REG_TWAI_BASE + 0x18)
+
+/* TWAI_SYNC_JUMP_WIDTH : RO | R/W; bitpos: [15:14]; default: 0;
+ * Synchronization Jump Width (SJW), 1 \verb+~+ 14 Tq wide.
+ */
+
+#define TWAI_SYNC_JUMP_WIDTH    0x00000003
+#define TWAI_SYNC_JUMP_WIDTH_M  (TWAI_SYNC_JUMP_WIDTH_V << 
TWAI_SYNC_JUMP_WIDTH_S)
+#define TWAI_SYNC_JUMP_WIDTH_V  0x00000003
+#define TWAI_SYNC_JUMP_WIDTH_S  14

Review Comment:
   The PR has been created https://github.com/apache/incubator-nuttx/pull/6993



-- 
This is an automated message from the Apache Git Service.
To respond to the message, please log on to GitHub and use the
URL above to go to the specific comment.

To unsubscribe, e-mail: commits-unsubscr...@nuttx.apache.org

For queries about this service, please contact Infrastructure at:
us...@infra.apache.org

Reply via email to