Skip to content

Commit

Permalink
arch/arm/samv7: add support of SocketLIN interface
Browse files Browse the repository at this point in the history
Signed-off-by: Petro Karashchenko <[email protected]>
  • Loading branch information
pkarashchenko authored and xiaoxiang781216 committed Sep 19, 2024
1 parent 549ad08 commit f0267bc
Show file tree
Hide file tree
Showing 6 changed files with 1,658 additions and 6 deletions.
62 changes: 62 additions & 0 deletions arch/arm/src/samv7/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand All @@ -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
Expand Down Expand Up @@ -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
Expand Down
4 changes: 4 additions & 0 deletions arch/arm/src/samv7/Make.defs
Original file line number Diff line number Diff line change
Expand Up @@ -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
Expand Down
2 changes: 2 additions & 0 deletions arch/arm/src/samv7/hardware/sam_uart.h
Original file line number Diff line number Diff line change
Expand Up @@ -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

Expand Down
81 changes: 81 additions & 0 deletions arch/arm/src/samv7/sam_lin.h
Original file line number Diff line number Diff line change
@@ -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 */
Loading

0 comments on commit f0267bc

Please sign in to comment.