SAMV7 MCAN Driver. Initial commit is just the SAMA5 CAN driver with naming changes. It should not even compile yet
This commit is contained in:
parent
ee72304b25
commit
1638d61389
@ -65,7 +65,7 @@ config ARCH_CHIP_SAMV71Q
|
||||
bool
|
||||
default n
|
||||
select ARCH_CHIP_SAMV71
|
||||
select SAMV7_HAVE_CAN1
|
||||
select SAMV7_HAVE_MCAN1
|
||||
select SAMV7_HAVE_DAC1
|
||||
select SAMV7_HAVE_EBI
|
||||
select SAMV7_HAVE_HSMCI0
|
||||
@ -82,7 +82,7 @@ config ARCH_CHIP_SAMV71N
|
||||
bool
|
||||
default n
|
||||
select ARCH_CHIP_SAMV71
|
||||
select SAMV7_HAVE_CAN1
|
||||
select SAMV7_HAVE_MCAN1
|
||||
select SAMV7_HAVE_DAC1
|
||||
select SAMV7_HAVE_HSMCI0
|
||||
select SAMV7_HAVE_SPI0
|
||||
@ -102,7 +102,11 @@ config ARCH_CHIP_SAMV71J
|
||||
|
||||
# Chip Capabilities
|
||||
|
||||
config SAMV7_HAVE_CAN1
|
||||
config SAMV7_MCAN
|
||||
bool
|
||||
default n
|
||||
|
||||
config SAMV7_HAVE_MCAN1
|
||||
bool
|
||||
default n
|
||||
|
||||
@ -207,14 +211,18 @@ config SAMV7_AFEC1
|
||||
bool "Analog Front End 1 (AFEC1)"
|
||||
default n
|
||||
|
||||
config SAMV7_CAN0
|
||||
bool "CAN0"
|
||||
config SAMV7_MCAN0
|
||||
bool "CAN controller 0 (MCAN0)"
|
||||
default n
|
||||
select CAN
|
||||
select SAMV7_MCAN
|
||||
|
||||
config SAMV7_CAN1
|
||||
bool "CAN1"
|
||||
config SAMV7_MCAN1
|
||||
bool "CAN controller 1 (MCAN1)"
|
||||
default n
|
||||
depends on SAMV7_HAVE_CAN1
|
||||
depends on SAMV7_HAVE_MCAN1
|
||||
select CAN
|
||||
select SAMV7_MCAN
|
||||
|
||||
config SAMV7_DAC0
|
||||
bool "Digital To Analog Converter 0 (DAC0)"
|
||||
@ -1296,3 +1304,214 @@ config SAMV7_USBHS_REGDEBUG
|
||||
depends on DEBUG
|
||||
|
||||
endmenu # USB High Speed Device Controller driver (DCD) options
|
||||
|
||||
if SAMV7_MCAN
|
||||
|
||||
menu "MCAN device driver options"
|
||||
|
||||
if SAMV7_MCAN0
|
||||
|
||||
config SAMV7_MCAN0_BAUD
|
||||
int "CAN0 BAUD"
|
||||
default 250000
|
||||
depends on SAMV7_MCAN0
|
||||
---help---
|
||||
CAN0 BAUD rate. Required if SAMV7_MCAN0 is defined.
|
||||
|
||||
config SAMV7_MCAN0_NRECVMB
|
||||
int "Number of receive mailboxes"
|
||||
default 1
|
||||
range 1 3
|
||||
---help---
|
||||
The SAMV7 CAN0 peripheral supports 8 mailboxes that can be used for
|
||||
sending and receiving messages. Up the three of these can be set
|
||||
aside statically for message reception. The remainder can be
|
||||
configured dynamically to send CAN messages. Multiple receive
|
||||
mailboxes might needed to either (1) receive bursts of messages, or
|
||||
(2) to support multiple groups of messages filtered on message ID.
|
||||
|
||||
NOTE: The maximum of 3 is a completely arbitrary design decision
|
||||
and can certainly be changed if you need more.
|
||||
|
||||
config SAMV7_MCAN0_ADDR0
|
||||
hex "Mailbox 0 address"
|
||||
---help---
|
||||
This setting defines the address for receive mailbox 0. If CAN_EXTID
|
||||
is defined, this should be a 29-bit extended CAN address; otherwise
|
||||
it should be an 11-bit standard CAN address.
|
||||
|
||||
config SAMV7_MCAN0_MASK0
|
||||
hex "Mailbox 0 address mask"
|
||||
default 0x7fff if !CAN_EXTID
|
||||
default 0x1fffffff if CAN_EXTID
|
||||
---help---
|
||||
This setting defines the address mask for receive mailbox 0. And
|
||||
address matching SAMV7_MCAN0_ADDR0 under this mask are accepted. The
|
||||
default, all ones, forces an exact match. A value of zero will accept
|
||||
any address.
|
||||
|
||||
If CAN_EXTID is defined, this should be a 29-bit extended CAN address
|
||||
mask; otherwise it should be an 11-bit standard CAN address.
|
||||
|
||||
config SAMV7_MCAN0_ADDR1
|
||||
hex "Mailbox 1 address"
|
||||
---help---
|
||||
This setting defines the address for receive mailbox 1. If CAN_EXTID
|
||||
is defined, this should be a 29-bit extended CAN address; otherwise
|
||||
it should be an 11-bit standard CAN address.
|
||||
|
||||
This setting is ignored if SAMV7_MCAN0_NRECVMB is less than 2.
|
||||
|
||||
config SAMV7_MCAN0_MASK1
|
||||
hex "Mailbox 1 address mask"
|
||||
default 0x7fff if !CAN_EXTID
|
||||
default 0x1fffffff if CAN_EXTID
|
||||
---help---
|
||||
This setting defines the address mask for receive mailbox 1. And
|
||||
address matching SAMV7_MCAN0_ADDR1 under this mask are accepted. The
|
||||
default, all ones, forces an exact match. A value of zero will accept
|
||||
any address.
|
||||
|
||||
If CAN_EXTID is defined, this should be a 29-bit extended CAN address
|
||||
mask; otherwise it should be an 11-bit standard CAN address.
|
||||
|
||||
This setting is ignored if SAMV7_MCAN0_NRECVMB is less than 2.
|
||||
|
||||
config SAMV7_MCAN0_ADDR2
|
||||
hex "Mailbox 2 address"
|
||||
---help---
|
||||
This setting defines the address for receive mailbox 2. If CAN_EXTID
|
||||
is defined, this should be a 29-bit extended CAN address; otherwise
|
||||
it should be an 11-bit standard CAN address.
|
||||
|
||||
This setting is ignored if SAMV7_MCAN0_NRECVMB is less than 3.
|
||||
|
||||
config SAMV7_MCAN0_MASK2
|
||||
hex "Mailbox 1 address mask"
|
||||
default 0x7fff if !CAN_EXTID
|
||||
default 0x1fffffff if CAN_EXTID
|
||||
---help---
|
||||
This setting defines the address mask for receive mailbox 2. And
|
||||
address matching SAMV7_MCAN0_ADDR2 under this mask are accepted. The
|
||||
default, all ones, forces an exact match. A value of zero will accept
|
||||
any address.
|
||||
|
||||
If CAN_EXTID is defined, this should be a 29-bit extended CAN address
|
||||
mask; otherwise it should be an 11-bit standard CAN address.
|
||||
|
||||
This setting is ignored if SAMV7_MCAN0_NRECVMB is less than 2.
|
||||
|
||||
endif # SAMV7_MCAN0
|
||||
|
||||
if SAMV7_MCAN1
|
||||
|
||||
config SAMV7_MCAN1_BAUD
|
||||
int "CAN1 BAUD"
|
||||
default 250000
|
||||
depends on SAMV7_MCAN1
|
||||
---help---
|
||||
CAN1 BAUD rate. Required if SAMV7_MCAN1 is defined.
|
||||
|
||||
config SAMV7_MCAN1_NRECVMB
|
||||
int "Number of receive mailboxes"
|
||||
default 1
|
||||
range 1 3
|
||||
---help---
|
||||
The SAMV7 CAN1 peripheral supports 8 mailboxes that can be used for
|
||||
sending and receiving messages. Up the three of these can be set
|
||||
aside statically for message reception. The remainder can be
|
||||
configured dynamically to send CAN messages. Multiple receive
|
||||
mailboxes might needed to either (1) receive bursts of messages, or
|
||||
(2) to support multiple groups of messages filtered on message ID.
|
||||
|
||||
NOTE: The maximum of 3 is a completely arbitrary design decision
|
||||
and can certainly be changed if you need more.
|
||||
|
||||
config SAMV7_MCAN1_ADDR0
|
||||
hex "Mailbox 0 address"
|
||||
---help---
|
||||
This setting defines the address for receive mailbox 0. If CAN_EXTID
|
||||
is defined, this should be a 29-bit extended CAN address; otherwise
|
||||
it should be an 11-bit standard CAN address.
|
||||
|
||||
config SAMV7_MCAN1_MASK0
|
||||
hex "Mailbox 0 address mask"
|
||||
default 0x7fff if !CAN_EXTID
|
||||
default 0x1fffffff if CAN_EXTID
|
||||
---help---
|
||||
This setting defines the address mask for receive mailbox 0. And
|
||||
address matching SAMV7_MCAN1_ADDR0 under this mask are accepted. The
|
||||
default, all ones, forces an exact match. A value of zero will accept
|
||||
any address.
|
||||
|
||||
If CAN_EXTID is defined, this should be a 29-bit extended CAN address
|
||||
mask; otherwise it should be an 11-bit standard CAN address.
|
||||
|
||||
config SAMV7_MCAN1_ADDR1
|
||||
hex "Mailbox 1 address"
|
||||
---help---
|
||||
This setting defines the address for receive mailbox 1. If CAN_EXTID
|
||||
is defined, this should be a 29-bit extended CAN address; otherwise
|
||||
it should be an 11-bit standard CAN address.
|
||||
|
||||
This setting is ignored if SAMV7_MCAN0_NRECVMB is less than 2.
|
||||
|
||||
config SAMV7_MCAN1_MASK1
|
||||
hex "Mailbox 1 address mask"
|
||||
default 0x7fff if !CAN_EXTID
|
||||
default 0x1fffffff if CAN_EXTID
|
||||
---help---
|
||||
This setting defines the address mask for receive mailbox 1. And
|
||||
address matching SAMV7_MCAN1_ADDR1 under this mask are accepted. The
|
||||
default, all ones, forces an exact match. A value of zero will accept
|
||||
any address.
|
||||
|
||||
If CAN_EXTID is defined, this should be a 29-bit extended CAN address
|
||||
mask; otherwise it should be an 11-bit standard CAN address.
|
||||
|
||||
This setting is ignored if SAMV7_MCAN1_NRECVMB is less than 2.
|
||||
|
||||
config SAMV7_MCAN1_ADDR2
|
||||
hex "Mailbox 2 address"
|
||||
---help---
|
||||
This setting defines the address for receive mailbox 2. If CAN_EXTID
|
||||
is defined, this should be a 29-bit extended CAN address; otherwise
|
||||
it should be an 11-bit standard CAN address.
|
||||
|
||||
This setting is ignored if SAMV7_MCAN1_NRECVMB is less than 3.
|
||||
|
||||
config SAMV7_MCAN1_MASK2
|
||||
hex "Mailbox 2 address mask"
|
||||
default 0x7fff if !CAN_EXTID
|
||||
default 0x1fffffff if CAN_EXTID
|
||||
---help---
|
||||
This setting defines the address mask for receive mailbox 2. And
|
||||
address matching SAMV7_MCAN1_ADDR2 under this mask are accepted. The
|
||||
default, all ones, forces an exact match. A value of zero will accept
|
||||
any address.
|
||||
|
||||
If CAN_EXTID is defined, this should be a 29-bit extended CAN address
|
||||
mask; otherwise it should be an 11-bit standard CAN address.
|
||||
|
||||
This setting is ignored if SAMV7_MCAN1_NRECVMB is less than 3.
|
||||
|
||||
endif # SAMV7_MCAN1
|
||||
|
||||
config SAMV7_MCAN_AUTOBAUD
|
||||
bool "Enable auto-baud"
|
||||
default n
|
||||
depends on EXPERIMENTAL
|
||||
---help---
|
||||
Enable the SAMV7 auto-baud feature. NOTE: This feature is not yet
|
||||
fully implemented.
|
||||
|
||||
config SAMV7_MCAN_REGDEBUG
|
||||
bool "CAN Register level debug"
|
||||
depends on DEBUG
|
||||
default n
|
||||
---help---
|
||||
Output detailed register-level CAN device debug information.
|
||||
Requires also DEBUG.
|
||||
|
||||
endmenu # CAN device driver options
|
||||
endif # SAMV7_MCAN
|
||||
|
@ -150,6 +150,10 @@ ifeq ($(CONFIG_SAMV7_EMAC),y)
|
||||
CHIP_CSRCS += sam_emac.c sam_ethernet.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SAMV7_MCAN),y)
|
||||
CHIP_CSRCS += sam_mcan.c
|
||||
endif
|
||||
|
||||
ifeq ($(CONFIG_SAMV7_USBDEVHS),y)
|
||||
CHIP_CSRCS += sam_usbdevhs.c
|
||||
endif
|
||||
|
2011
arch/arm/src/samv7/sam_mcan.c
Normal file
2011
arch/arm/src/samv7/sam_mcan.c
Normal file
File diff suppressed because it is too large
Load Diff
153
arch/arm/src/samv7/sam_mcan.h
Normal file
153
arch/arm/src/samv7/sam_mcan.h
Normal file
@ -0,0 +1,153 @@
|
||||
/****************************************************************************
|
||||
* arch/arm/src/samv7/sam_mcan.h
|
||||
*
|
||||
* Copyright (C) 2015 Gregory Nutt. All rights reserved.
|
||||
* Author: Gregory Nutt <gnutt@nuttx.org>
|
||||
*
|
||||
* Redistribution and use in source and binary forms, with or without
|
||||
* modification, are permitted provided that the following conditions
|
||||
* are met:
|
||||
*
|
||||
* 1. Redistributions of source code must retain the above copyright
|
||||
* notice, this list of conditions and the following disclaimer.
|
||||
* 2. Redistributions in binary form must reproduce the above copyright
|
||||
* notice, this list of conditions and the following disclaimer in
|
||||
* the documentation and/or other materials provided with the
|
||||
* distribution.
|
||||
* 3. Neither the name NuttX nor the names of its contributors may be
|
||||
* used to endorse or promote products derived from this software
|
||||
* without specific prior written permission.
|
||||
*
|
||||
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS
|
||||
* "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT
|
||||
* LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS
|
||||
* FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE
|
||||
* COPYRIGHT OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT,
|
||||
* INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING,
|
||||
* BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS
|
||||
* OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED
|
||||
* AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
||||
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN
|
||||
* ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
|
||||
* POSSIBILITY OF SUCH DAMAGE.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef __ARCH_ARM_SRC_SAMV7_SAM_MCAN_H
|
||||
#define __ARCH_ARM_SRC_SAMV7_SAM_MCAN_H
|
||||
|
||||
/****************************************************************************
|
||||
* Included Files
|
||||
****************************************************************************/
|
||||
|
||||
#include <nuttx/config.h>
|
||||
|
||||
#include "chip.h"
|
||||
#include "chip/sam_mcan.h"
|
||||
|
||||
#include <nuttx/can.h>
|
||||
|
||||
#if defined(CONFIG_CAN) && (defined(CONFIG_SAMV7_CAN0) || \
|
||||
defined(CONFIG_SAMV7_CAN1))
|
||||
|
||||
/****************************************************************************
|
||||
* Pre-processor Definitions
|
||||
****************************************************************************/
|
||||
/* Configuration ************************************************************/
|
||||
|
||||
/* CAN BAUD */
|
||||
|
||||
#if defined(CONFIG_SAMV7_CAN0) && !defined(CONFIG_SAMV7_CAN0_BAUD)
|
||||
# error "CONFIG_SAMV7_CAN0_BAUD is not defined"
|
||||
#endif
|
||||
|
||||
#if defined(CONFIG_SAMV7_CAN1) && !defined(CONFIG_SAMV7_CAN1_BAUD)
|
||||
# error "CONFIG_SAMV7_CAN1_BAUD is not defined"
|
||||
#endif
|
||||
|
||||
/* There must be at least one but not more than three receive mailboxes */
|
||||
|
||||
#ifdef CONFIG_SAMV7_CAN0
|
||||
# if !defined(CONFIG_SAMV7_CAN0_NRECVMB) || CONFIG_SAMV7_CAN0_NRECVMB < 1
|
||||
# undef CONFIG_SAMV7_CAN0_NRECVMB
|
||||
# define CONFIG_SAMV7_CAN0_NRECVMB 1
|
||||
# endif
|
||||
# if CONFIG_SAMV7_CAN0_NRECVMB > 3
|
||||
# warning Current implementation only supports up to three receive mailboxes
|
||||
# undef CONFIG_SAMV7_CAN0_NRECVMB
|
||||
# define CONFIG_SAMV7_CAN0_NRECVMB 3
|
||||
# endif
|
||||
#else
|
||||
# undef CONFIG_SAMV7_CAN0_NRECVMB
|
||||
# define CONFIG_SAMV7_CAN0_NRECVMB 0
|
||||
#endif
|
||||
|
||||
#ifdef CONFIG_SAMV7_CAN1
|
||||
# if !defined(CONFIG_SAMV7_CAN1_NRECVMB) || CONFIG_SAMV7_CAN1_NRECVMB < 1
|
||||
# undef CONFIG_SAMV7_CAN1_NRECVMB
|
||||
# define CONFIG_SAMV7_CAN1_NRECVMB 1
|
||||
# endif
|
||||
# if CONFIG_SAMV7_CAN1_NRECVMB > 3
|
||||
# warning Current implementation only supports up to three receive mailboxes
|
||||
# undef CONFIG_SAMV7_CAN1_NRECVMB
|
||||
# define CONFIG_SAMV7_CAN1_NRECVMB 3
|
||||
# endif
|
||||
#else
|
||||
# undef CONFIG_SAMV7_CAN1_NRECVMB
|
||||
# define CONFIG_SAMV7_CAN1_NRECVMB 0
|
||||
#endif
|
||||
|
||||
/* Port numbers for use with sam_mcan_initialize() */
|
||||
|
||||
#define MCAN0 0
|
||||
#define MCAN1 1
|
||||
|
||||
/***************************************************************************
|
||||
* Public Types
|
||||
***************************************************************************/
|
||||
|
||||
#ifndef __ASSEMBLY__
|
||||
|
||||
/****************************************************************************
|
||||
* Public Data
|
||||
****************************************************************************/
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
#define EXTERN extern "C"
|
||||
extern "C"
|
||||
{
|
||||
#else
|
||||
#define EXTERN extern
|
||||
#endif
|
||||
|
||||
/***************************************************************************
|
||||
* Public Functions
|
||||
***************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_mcan_initialize
|
||||
*
|
||||
* Description:
|
||||
* Initialize the selected MCAN port
|
||||
*
|
||||
* Input Parameter:
|
||||
* port - Port number (for hardware that has multiple CAN interfaces),
|
||||
* 0=MCAN0, 1=NCAN1
|
||||
*
|
||||
* Returned Value:
|
||||
* Valid CAN device structure reference on success; a NULL on failure
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
struct can_dev_s;
|
||||
FAR struct can_dev_s *sam_mcan_initialize(int port);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
#endif
|
||||
|
||||
#endif /* __ASSEMBLY__ */
|
||||
#endif /* CONFIG_CAN && (CONFIG_SAMV7_CAN0 || CONFIG_SAMV7_CAN1) */
|
||||
#endif /* __ARCH_ARM_SRC_SAMV7_SAM_MCAN_H */
|
Loading…
Reference in New Issue
Block a user