Skip to content

Commit

Permalink
arch/arm/samv7: Initial support of SocketLIN interface
Browse files Browse the repository at this point in the history
Signed-off-by: Petro Karashchenko <petro.karashchenko@gmail.com>
  • Loading branch information
pkarashchenko committed Oct 23, 2023
1 parent 6cad7e9 commit 691bb3a
Show file tree
Hide file tree
Showing 6 changed files with 1,449 additions and 7 deletions.
52 changes: 52 additions & 0 deletions arch/arm/src/samv7/Kconfig
Original file line number Diff line number Diff line change
Expand Up @@ -360,6 +360,10 @@ config SAMV7_1WIREDRIVER
bool
default n

config SAMV7_LIN_SOCKET
bool
default n

config SAMV7_HAVE_USART0
bool
default n
Expand Down Expand Up @@ -1339,6 +1343,11 @@ config SAMV7_USART0_1WIREDRIVER
bool "1-Wire driver"
select SAMV7_1WIREDRIVER

config SAMV7_USART0_LIN_SOCKET
bool "SocketLIN driver"
select SAMV7_LIN_SOCKET
depends on NET_CAN

endchoice # "USART0 Driver Configuration"

if SAMV7_USART0_SERIALDRIVER
Expand All @@ -1353,6 +1362,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 @@ -1376,6 +1396,11 @@ config SAMV7_USART1_1WIREDRIVER
bool "1-Wire driver"
select SAMV7_1WIREDRIVER

config SAMV7_USART1_LIN_SOCKET
bool "SocketLIN driver"
select SAMV7_LIN_SOCKET
depends on NET_CAN

endchoice # "USART1 Driver Configuration"

if SAMV7_USART1_SERIALDRIVER
Expand All @@ -1390,6 +1415,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 @@ -1413,6 +1449,11 @@ config SAMV7_USART2_1WIREDRIVER
bool "1-Wire driver"
select SAMV7_1WIREDRIVER

config SAMV7_USART2_LIN_SOCKET
bool "SocketLIN driver"
select SAMV7_LIN_SOCKET
depends on NET_CAN

endchoice # "USART2 Driver Configuration"

if SAMV7_USART2_SERIALDRIVER
Expand All @@ -1427,6 +1468,17 @@ 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

config SAMV7_WDT
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 @@ -67,6 +67,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_SPI_MASTER),y)
CHIP_CSRCS += sam_spi.c
endif
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 691bb3a

Please sign in to comment.