Skip to content

Commit

Permalink
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
arch/arm/samv7: add SocketLIN slave support
Browse files Browse the repository at this point in the history
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
pkarashchenko committed May 20, 2024
1 parent 6b28ae2 commit 2e78e68
Showing 5 changed files with 370 additions and 111 deletions.
2 changes: 2 additions & 0 deletions arch/arm/src/samv7/hardware/sam_uart.h
Original file line number Diff line number Diff line change
@@ -356,6 +356,8 @@
#define UART_INT_LINCE (1 << 28) /* Bit 28: LIN Checksum Error Interrupt (USART, LIN mode only) */
#define UART_INT_LBLOVFE (1 << 28) /* Bit 28: LON Backlog Overflow Error Interrupt Enable (USART, LON mode only) */
#define UART_INT_LINSNRE (1 << 29) /* Bit 29: LIN Slave Not Responding Error Interrupt (USART, LIN mode only) */
#define UART_INT_LINSTE (1 << 30) /* Bit 30: LIN Synch Tolerance Error Interrupt (USART, LIN mode only) */
#define UART_INT_LINHTE (1 << 31) /* Bit 31: LIN Header Timeout Error Interrupt (USART, LIN mode only) */

#define UART_INT_ALLINTS 0x3f08e7e7

392 changes: 303 additions & 89 deletions arch/arm/src/samv7/sam_lin_sock.c

Large diffs are not rendered by default.

24 changes: 2 additions & 22 deletions include/netpacket/can.h
Original file line number Diff line number Diff line change
@@ -31,22 +31,12 @@
#include <sys/types.h>
#include <stdint.h>

#include <nuttx/can.h>

/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

/* Special address description flags for the CAN_ID */

#define CAN_EFF_FLAG 0x80000000 /* EFF/SFF is set in the MSB */
#define CAN_RTR_FLAG 0x40000000 /* Remote transmission request */
#define CAN_ERR_FLAG 0x20000000 /* Error message frame */

/* Valid bits in CAN ID for frame formats */

#define CAN_SFF_MASK 0x000007ff /* Standard frame format (SFF) */
#define CAN_EFF_MASK 0x1fffffff /* Extended frame format (EFF) */
#define CAN_ERR_MASK 0x1fffffff /* Omit EFF, RTR, ERR flags */

#define CAN_MTU (sizeof(struct can_frame))
#define CANFD_MTU (sizeof(struct canfd_frame))

@@ -102,16 +92,6 @@
* Public Types
****************************************************************************/

/* Controller Area Network Identifier structure
*
* Bit 0-28: CAN identifier (11/29 bit)
* Bit 29: Error message frame flag (0 = data frame, 1 = error message)
* Bit 30: Remote transmission request flag (1 = rtr frame)
* Bit 31: Frame format flag (0 = standard 11 bit, 1 = extended 29 bit)
*/

typedef uint32_t canid_t;

/* The sockaddr structure for CAN sockets
*
* can_family: Address family number AF_CAN.
20 changes: 20 additions & 0 deletions include/nuttx/can.h
Original file line number Diff line number Diff line change
@@ -39,6 +39,18 @@
* Pre-processor Definitions
****************************************************************************/

/* Special address description flags for the CAN_ID */

#define CAN_EFF_FLAG 0x80000000 /* EFF/SFF is set in the MSB */
#define CAN_RTR_FLAG 0x40000000 /* Remote transmission request */
#define CAN_ERR_FLAG 0x20000000 /* Error message frame */

/* Valid bits in CAN ID for frame formats */

#define CAN_SFF_MASK 0x000007ff /* Standard frame format (SFF) */
#define CAN_EFF_MASK 0x1fffffff /* Extended frame format (EFF) */
#define CAN_ERR_MASK 0x1fffffff /* Omit EFF, RTR, ERR flags */

/* Ioctl Commands ***********************************************************/

/* Ioctl commands supported by the upper half CAN driver.
@@ -298,6 +310,14 @@ struct can_response_s
/* Message-specific data may follow */
}; /* FIXME remove */

/* Controller Area Network Identifier structure
*
* Bit 0-28: CAN identifier (11/29 bit)
* Bit 29: Error message frame flag (0 = data frame, 1 = error message)
* Bit 30: Remote transmission request flag (1 = rtr frame)
* Bit 31: Frame format flag (0 = standard 11 bit, 1 = extended 29 bit)
*/

typedef uint32_t canid_t;

/* Controller Area Network Error Message Frame Mask structure
43 changes: 43 additions & 0 deletions include/nuttx/lin.h
Original file line number Diff line number Diff line change
@@ -0,0 +1,43 @@
/****************************************************************************
* include/nuttx/lin.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 __INCLUDE_NUTTX_LIN_H
#define __INCLUDE_NUTTX_LIN_H

/****************************************************************************
* Included Files
****************************************************************************/

#include <nuttx/can.h>

/****************************************************************************
* Pre-processor Definitions
****************************************************************************/

#define LIN_ID_BITS 6

#define LIN_ID_MASK ((1 << LIN_ID_BITS) - 1)
#define LIN_ID_MAX LIN_ID_MASK

#define LIN_CACHE_RESPONSE (1 << (LIN_ID_BITS))
#define LIN_CHECKSUM_EXTENDED (1 << (LIN_ID_BITS + 1))
#define LIN_SINGLE_RESPONSE (1 << (LIN_ID_BITS + 2))

#endif /* __INCLUDE_NUTTX_LIN_H */

0 comments on commit 2e78e68

Please sign in to comment.