arch/arm/samv7: add support of SocketLIN interface

Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
This commit is contained in:
Petro Karashchenko 2023-10-23 17:56:56 +03:00 committed by Xiang Xiao
parent 549ad08013
commit f0267bc507
6 changed files with 1658 additions and 6 deletions

View File

@ -368,6 +368,10 @@ config SAMV7_1WIREDRIVER
bool
default n
config SAMV7_LIN_SOCKET
bool
default n
config SAMV7_USART_IS_SPI_MASTER
bool
default n
@ -1445,6 +1449,11 @@ config SAMV7_USART0_1WIREDRIVER
bool "1-Wire driver"
select SAMV7_1WIREDRIVER
config SAMV7_USART0_LIN_SOCKET
bool "LIN driver over SocketCAN"
select SAMV7_LIN_SOCKET
depends on NET_CAN
config SAMV7_USART0_SPI_MASTER
bool "USART0 as SPI Master driver"
select SAMV7_USART_IS_SPI_MASTER
@ -1474,6 +1483,17 @@ config SAMV7_USART0_RS485MODE
opened for the first time.
endif # SAMV7_USART0_SERIALDRIVER
if SAMV7_USART0_LIN_SOCKET
config SAMV7_USART0_LIN_BAUD
int "BAUD rate"
default 19200
---help---
The configured BAUD of the LIN bus.
endif # SAMV7_USART0_LIN_SOCKET
endif # SAMV7_USART0
menuconfig SAMV7_USART1
@ -1497,6 +1517,11 @@ config SAMV7_USART1_1WIREDRIVER
bool "1-Wire driver"
select SAMV7_1WIREDRIVER
config SAMV7_USART1_LIN_SOCKET
bool "LIN driver over SocketCAN"
select SAMV7_LIN_SOCKET
depends on NET_CAN
config SAMV7_USART1_SPI_MASTER
bool "USART1 as SPI Master driver"
select SAMV7_USART_IS_SPI_MASTER
@ -1526,6 +1551,17 @@ config SAMV7_USART1_RS485MODE
opened for the first time.
endif # SAMV7_USART1_SERIALDRIVER
if SAMV7_USART1_LIN_SOCKET
config SAMV7_USART1_LIN_BAUD
int "BAUD rate"
default 19200
---help---
The configured BAUD of the LIN bus.
endif # SAMV7_USART1_LIN_SOCKET
endif # SAMV7_USART1
menuconfig SAMV7_USART2
@ -1549,6 +1585,11 @@ config SAMV7_USART2_1WIREDRIVER
bool "1-Wire driver"
select SAMV7_1WIREDRIVER
config SAMV7_USART2_LIN_SOCKET
bool "LIN driver over SocketCAN"
select SAMV7_LIN_SOCKET
depends on NET_CAN
config SAMV7_USART2_SPI_MASTER
bool "USART2 as SPI Master driver"
select SAMV7_USART_IS_SPI_MASTER
@ -1578,8 +1619,29 @@ config SAMV7_USART2_RS485MODE
opened for the first time.
endif # SAMV7_USART2_SERIALDRIVER
if SAMV7_USART2_LIN_SOCKET
config SAMV7_USART2_LIN_BAUD
int "BAUD rate"
default 19200
---help---
The configured BAUD of the LIN bus.
endif # SAMV7_USART2_LIN_SOCKET
endif # SAMV7_USART2
if SAMV7_LIN_SOCKET
config SAMV7_LIN_REGDEBUG
bool "Register level debug"
default n
depends on DEBUG_NET_INFO
---help---
Output detailed register-level LIN device debug information.
Requires also CONFIG_DEBUG_NET_INFO.
endif # SAMV7_LIN_SOCKET
config SAMV7_WDT
bool "Watchdog Timer (WDT)"
default n

View File

@ -64,6 +64,10 @@ ifeq ($(CONFIG_SAMV7_1WIREDRIVER),y)
CHIP_CSRCS += sam_1wire.c
endif
ifeq ($(CONFIG_SAMV7_LIN_SOCKET),y)
CHIP_CSRCS += sam_lin_sock.c
endif
ifeq ($(CONFIG_SAMV7_USART_IS_SPI_MASTER),y)
CHIP_CSRCS += sam_serial_spi.c
endif

View File

@ -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

View File

@ -0,0 +1,81 @@
/****************************************************************************
* arch/arm/src/samv7/sam_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 __ARCH_ARM_SRC_SAMV7_SAM_LIN_H
#define __ARCH_ARM_SRC_SAMV7_SAM_LIN_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Public Data
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#ifdef CONFIG_SAMV7_LIN_SOCKET
/****************************************************************************
* Name: sam_linsockinitialize
*
* Description:
* Initialize the selected LIN port as CAN socket interface
*
* Input Parameters:
* Port number (for hardware that has multiple LIN interfaces)
*
* Returned Value:
* OK on success; Negated errno on failure.
*
****************************************************************************/
int sam_linsockinitialize(int port);
#endif
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_SRC_SAMV7_SAM_LIN_H */

File diff suppressed because it is too large Load Diff

View File

@ -272,12 +272,12 @@ typedef uint32_t can_err_mask_t;
struct can_frame
{
canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */
uint8_t can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */
uint8_t __pad; /* padding */
uint8_t __res0; /* reserved / padding */
uint8_t __res1; /* reserved / padding */
uint8_t data[CAN_MAX_DLEN];
canid_t can_id; /* 32 bit CAN_ID + EFF/RTR/ERR flags */
uint8_t can_dlc; /* frame payload length in byte (0 .. CAN_MAX_DLEN) */
uint8_t __pad; /* padding */
uint8_t __res0; /* reserved / padding */
uint8_t __res1; /* reserved / padding */
uint8_t data[CAN_MAX_DLEN];
};
/* struct canfd_frame - CAN flexible data rate frame structure