This is the initial commit the port to the SAMD5x/E5x MCU family and also support for the Adafruit Metro M4 board. It port is untested and unfinished. It currently will not even link due to some missing clock related logic.

Squashed commit of the following:

    arch/arm/src/samd5e5: Clean-up EIC logic.
    arch/arm/src/samd5e5:  Fix some compilation issues; Still issues with the EIC logic from samd2x.
    arch/arm/src/samd5e5:  Fix some compilation issues; bring in some EIC logic from samd2x.
    arch/arm/src/samd5e5:  Add NVMCTRL header file, fix some compiler problems, misc. clean-up.
    configs/metro-m4:  Add LED support.
    arch/arm/src/samd5e5:  Bring in SAML21 clock configuration.  This is a WIP; it cannot possible even compile yet.
    arch/arm/src/samd5e5:  Leverage Cortex-M4 interrupt and SysTick logic from the SAM3/4.
    arch/arm/src/samd5e5: Add SERCOM utility function.
    arch/arm/src/samd5e5:  Bring all SERCOM USART logic from SAMD2L2 to SAMD5E5.  This is a brute coy with nothing more than more that name changes and extension from 5 to 7 SERCOMs.
    arch/arm/src/samd5e5: Add sam_config.h header file
    arch/arm/src/samd5e5/:  Add Generic Clock (GCLK) utility functions.
    arch/arm/src/samd5e5:  Add EVSYS register definition file
    arch/arm/src/samd5e5 and configs/metro-m4:  Use SERCOM3 for the Arduino serial shield as console.
    arch/arm/src/samd5e5/chip:  Add SERCOM USART, SPI, I2C master, and slave register defintions header files
    arch/arm/src/samd5e5/chip:  Add AES, PM, TRNG, and WDT header files.
    arch/arm/src/samd5e5/chip:  Add pin multiplexing header files.
    Various fixes to configuration system; fix metro-m4/nsh defconfig file.
    configs/metro-m4:  Add initial support for the Adafruit Metro M4 board.
    arch/arm/src/samd5e5:  Add peripheral clock helpers.
    arch/arm/src/samd5e5/chip:  Add PAC register definition header file.  Fix some errors in the memory map header file.
    arch/arm/src/samd5e5:  Add chip.h headerf file.
    arch/arm/src/samd5e5:  Add PORT register definitions and support from SAML21.
    arch/arm/include/samd5e5:  Add interrupt vector definitions.
    arch/arm/src/samd5e5:  Add some boilerplate files.  Correct some typos.
    arch/arm/src/samd5e5/chip/sam_eic.h:  Add EIC register definitions.
    arch/arm/src/samd5e5/chip:  Add OSC32KCTRL and OSCCTRL register definitions.
    arch/arm/src/samd5e5/chip:  Add GCLK, MCLK, and RSTC header files.
    arch/arm/src/samd5e5/chip/sam_cmcc.h:  Add CMCC register definitions
    arch/arm/src/samd5e5/chip/sam_supc.h:  Add SUPC header file.
    arch/arm/src/samd5e5:  Add start-up logic.
    arch/arm/src/samd5e5:  Add Make.defs file
    arch/arm/src/samd5e5/chip:  Add memory map header file.
    arch/arm/include/samd5e5:  Add chip.h header file.
    arch/arm/Kconfig and arch/arm/src/samd5e5/Kconfig:  Add configuration logic for the SAMD5x/Ex family.
This commit is contained in:
Gregory Nutt 2018-07-26 12:08:58 -06:00
parent bf2a61b8cf
commit a9d713bbcc
77 changed files with 18888 additions and 5 deletions

View File

@ -8,7 +8,7 @@
<tr align="center" bgcolor="#e4e4e4">
<td>
<h1><big><font color="#3c34ec"><i>NuttX README Files</i></font></big></h1>
<p>Last Updated: July 18, 2018</p>
<p>Last Updated: July 24, 2018</p>
</td>
</tr>
</table>
@ -154,6 +154,8 @@ nuttx/
| | `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/configs/mcb1700/README.txt" target="_blank"><b><i>README.txt</i></b></a>
| |- mcu123-lpc214x/
| | `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/configs/mcu123-lpc214x/README.txt" target="_blank"><b><i>README.txt</i></b></a>
| |- metro-m4/
| | `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/configs/metro-m4/README.txt" target="_blank"><b><i>README.txt</i></b></a>
| |- micropendous3/
| | `- <a href="https://bitbucket.org/nuttx/nuttx/src/master/configs/micropendous3/README.txt" target="_blank"><b><i>README.txt</i></b></a>
| |- mikroe-stm32f4/

View File

@ -1827,6 +1827,8 @@ nuttx/
| | `- README.txt
| |- mcu123-lpc214x/
| | `- README.txt
| |- metro-m4/
| | `- README.txt
| |- micropendous3/
| | `- README.txt
| |- mikroe-stm32f/

View File

@ -222,16 +222,28 @@ config ARCH_CHIP_SAMA5
Atmel SAMA5 (ARM Cortex-A5)
config ARCH_CHIP_SAMD2X
bool "Atmel SAMD2x"
bool "Microchip/Atmel SAMD2x"
select ARCH_CORTEXM0
---help---
Atmel SAMD (ARM Cortex-M0+)
Microchip (formerly Atmel) SAMD2X (ARM Cortex-M0+)
config ARCH_CHIP_SAML2X
bool "Atmel SAML2x"
bool "Microchip/Atmel SAML2x"
select ARCH_CORTEXM0
---help---
Atmel SAML (ARM Cortex-M0+)
Microchip (formerly Atmel) SAML2X (ARM Cortex-M0+)
config ARCH_CHIP_SAMD5X
bool "Microchip SAMD5x"
select ARCH_CORTEXM4
---help---
Microchip SAMD5X (ARM Cortex-M4)
config ARCH_CHIP_SAME5X
bool "Microchip SAME5x"
select ARCH_CORTEXM4
---help---
Microchip SAME5x (ARM Cortex-M4)
config ARCH_CHIP_SAM34
bool "Atmel SAM3/SAM4"
@ -580,6 +592,7 @@ config ARCH_CHIP
default "nuc1xx" if ARCH_CHIP_NUC1XX
default "sama5" if ARCH_CHIP_SAMA5
default "samd2l2" if ARCH_CHIP_SAMD2X || ARCH_CHIP_SAML2X
default "samd5e5" if ARCH_CHIP_SAMD5X || ARCH_CHIP_SAME5X
default "sam34" if ARCH_CHIP_SAM34
default "samv7" if ARCH_CHIP_SAMV7
default "stm32" if ARCH_CHIP_STM32
@ -846,6 +859,9 @@ endif
if ARCH_CHIP_SAMD2X || ARCH_CHIP_SAML2X
source arch/arm/src/samd2l2/Kconfig
endif
if ARCH_CHIP_SAMD5X || ARCH_CHIP_SAME5X
source arch/arm/src/samd5e5/Kconfig
endif
if ARCH_CHIP_SAM34
source arch/arm/src/sam34/Kconfig
endif

View File

@ -0,0 +1,632 @@
/************************************************************************************
* arch/arm/include/samd5e5/chip.h
*
* Copyright (C) 2018 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_INCLUDE_SAMD5E5_CHIP_H
#define __ARCH_ARM_INCLUDE_SAMD5E5_CHIP_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* Get customizations for each supported chip. Only sizes and numbers of things are
* provided here. See arch/arm/src/samd5e5/Kconfig for other, boolean configuration
* settings.
*/
#if defined(CONFIG_ARCH_CHIP_SAMD51P20)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (1024*1024) /* 1024KB */
# define SAMD5E5_SRAM_SIZE (256*1024) /* 256KB */
/* Peripherals */
# define SAMD5E5_NSERCOM 8 /* Sercomm0-7 */
# define SAMD5E5_NTC 8 /* TC0-TC7 */
# define SAMD5E5_NTCCOMP 2 /* TC compare */
# define SAMD5E5_NTCC24 2 /* TCC 24-bit */
# define SAMD5E5_NSDHC 2 /* SDHC0-1 */
# define SAMD5E5_PCCSIZE 14 /* PCC data size */
# define SAMD5E5_NCCL 4 /* CCL */
# define SAMD5E5_NEVTCHAN 32 /* Event system channels */
# define SAMD5E5_NADC0CHAN 16 /* ADC0 channels */
# define SAMD5E5_NADC1CHAN 16 /* ADC1 channels */
# define SAMD5E5_NACMP 4 /* Analog comparators */
# define SAMD5E5_NDACCHAN 2 /* DAC channels */
# define SAMD5E5_NPCTMANCHAN 256 /* PTC manual channels */
# define SAMD5E5_NPCTSELFCHAN 32 /* PTC self-capacitance channels */
# define SAMD5E5_NTAMPER 5 /* Tamper pins */
#elif defined(CONFIG_ARCH_CHIP_SAMD51P19)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (512*1024) /* 512KB */
# define SAMD5E5_SRAM_SIZE (192*1024) /* 192KB */
/* Peripherals */
# define SAMD5E5_NSERCOM 8 /* Sercomm0-7 */
# define SAMD5E5_NTC 8 /* TC0-TC7 */
# define SAMD5E5_NTCCOMP 2 /* TC compare */
# define SAMD5E5_NSDHC 2 /* SDHC0-1 */
# define SAMD5E5_PCCSIZE 14 /* PCC data size */
# define SAMD5E5_NCCL 4 /* CCL */
# define SAMD5E5_NEVTCHAN 32 /* Event system channels */
# define SAMD5E5_NADC0CHAN 16 /* ADC0 channels */
# define SAMD5E5_NADC1CHAN 6 /* ADC1 channels */
# define SAMD5E5_NACMP 4 /* Analog comparators */
# define SAMD5E5_NDACCHAN 2 /* DAC channels */
# define SAMD5E5_NPCTMANCHAN 256 /* PTC manual channels */
# define SAMD5E5_NPCTSELFCHAN 32 /* PTC self-capacitance channels */
# define SAMD5E5_NTAMPER 5 /* Tamper pins */
#elif defined(CONFIG_ARCH_CHIP_SAMD51N20)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (1024*1024) /* 1024KB */
# define SAMD5E5_SRAM_SIZE (256*1024) /* 256KB */
/* Peripherals */
# define SAMD5E5_NSERCOM 8 /* Sercomm0-7 */
# define SAMD5E5_NTC 8 /* TC0-TC7 */
# define SAMD5E5_NTCCOMP 2 /* TC compare */
# define SAMD5E5_NSDHC 2 /* SDHC0-1 */
# define SAMD5E5_PCCSIZE 14 /* PCC data size */
# define SAMD5E5_NCCL 4 /* CCL */
# define SAMD5E5_NEVTCHAN 32 /* Event system channels */
# define SAMD5E5_NADC0CHAN 16 /* ADC0 channels */
# define SAMD5E5_NADC1CHAN 12 /* ADC1 channels */
# define SAMD5E5_NACMP 4 /* Analog comparators */
# define SAMD5E5_NDACCHAN 2 /* DAC channels */
# define SAMD5E5_NPCTMANCHAN 256 /* PTC manual channels */
# define SAMD5E5_NPCTSELFCHAN 32 /* PTC self-capacitance channels */
# define SAMD5E5_NTAMPER 5 /* Tamper pins */
#elif defined(CONFIG_ARCH_CHIP_SAMD51N19)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (512*1024) /* 512KB */
# define SAMD5E5_SRAM_SIZE (192*1024) /* 192KB */
/* Peripherals */
# define SAMD5E5_NSERCOM 8 /* Sercomm0-7 */
# define SAMD5E5_NTC 8 /* TC0-TC7 */
# define SAMD5E5_NTCCOMP 2 /* TC compare */
# define SAMD5E5_NSDHC 2 /* SDHC0-1 */
# define SAMD5E5_PCCSIZE 14 /* PCC data size */
# define SAMD5E5_NCCL 4 /* CCL */
# define SAMD5E5_NEVTCHAN 32 /* Event system channels */
# define SAMD5E5_NADC0CHAN 16 /* ADC0 channels */
# define SAMD5E5_NADC1CHAN 12 /* ADC1 channels */
# define SAMD5E5_NACMP 4 /* Analog comparators */
# define SAMD5E5_NDACCHAN 2 /* DAC channels */
# define SAMD5E5_NPCTMANCHAN 256 /* PTC manual channels */
# define SAMD5E5_NPCTSELFCHAN 32 /* PTC self-capacitance channels */
# define SAMD5E5_NTAMPER 5 /* Tamper pins */
#elif defined(CONFIG_ARCH_CHIP_SAMD51J20)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (1024*1024) /* 1024KB */
# define SAMD5E5_SRAM_SIZE (256*1024) /* 256KB */
/* Peripherals */
# define SAMD5E5_NSERCOM 6 /* Sercomm0-5 */
# define SAMD5E5_NTC 6 /* TC0-TC5 */
# define SAMD5E5_NTCCOMP 2 /* TC compare */
# define SAMD5E5_NSDHC 1 /* SDHC0 */
# define SAMD5E5_PCCSIZE 10 /* PCC data size */
# define SAMD5E5_NCCL 4 /* CCL */
# define SAMD5E5_NEVTCHAN 32 /* Event system channels */
# define SAMD5E5_NADC0CHAN 16 /* ADC0 channels */
# define SAMD5E5_NADC1CHAN 8 /* ADC1 channels */
# define SAMD5E5_NACMP 4 /* Analog comparators */
# define SAMD5E5_NDACCHAN 2 /* DAC channels */
# define SAMD5E5_NPCTMANCHAN 256 /* PTC manual channels */
# define SAMD5E5_NPCTSELFCHAN 32 /* PTC self-capacitance channels */
# define SAMD5E5_NTAMPER 3 /* Tamper pins */
#elif defined(CONFIG_ARCH_CHIP_SAMD51J19)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (512*1024) /* 512KB */
# define SAMD5E5_SRAM_SIZE (192*1024) /* 192KB */
/* Peripherals */
# define SAMD5E5_NSERCOM 6 /* Sercomm0-5 */
# define SAMD5E5_NTC 6 /* TC0-TC5 */
# define SAMD5E5_NTCCOMP 2 /* TC compare */
# define SAMD5E5_NSDHC 1 /* SDHC0 */
# define SAMD5E5_PCCSIZE 10 /* PCC data size */
# define SAMD5E5_NCCL 4 /* CCL */
# define SAMD5E5_NEVTCHAN 32 /* Event system channels */
# define SAMD5E5_NADC0CHAN 16 /* ADC0 channels */
# define SAMD5E5_NADC1CHAN 8 /* ADC1 channels */
# define SAMD5E5_NACMP 4 /* Analog comparators */
# define SAMD5E5_NDACCHAN 2 /* DAC channels */
# define SAMD5E5_NPCTMANCHAN 256 /* PTC manual channels */
# define SAMD5E5_NPCTSELFCHAN 32 /* PTC self-capacitance channels */
# define SAMD5E5_NTAMPER 3 /* Tamper pins */
#elif defined(CONFIG_ARCH_CHIP_SAMD51J18)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (256*1024) /* 1256KB */
# define SAMD5E5_SRAM_SIZE (128*1024) /* 128KB */
/* Peripherals */
# define SAMD5E5_NSERCOM 6 /* Sercomm0-5 */
# define SAMD5E5_NTC 6 /* TC0-TC5 */
# define SAMD5E5_NTCCOMP 2 /* TC compare */
# define SAMD5E5_NSDHC 1 /* SDHC0 */
# define SAMD5E5_PCCSIZE 10 /* PCC data size */
# define SAMD5E5_NCCL 4 /* CCL */
# define SAMD5E5_NEVTCHAN 32 /* Event system channels */
# define SAMD5E5_NADC0CHAN 16 /* ADC0 channels */
# define SAMD5E5_NADC1CHAN 8 /* ADC1 channels */
# define SAMD5E5_NACMP 4 /* Analog comparators */
# define SAMD5E5_NDACCHAN 2 /* DAC channels */
# define SAMD5E5_NPCTMANCHAN 256 /* PTC manual channels */
# define SAMD5E5_NPCTSELFCHAN 32 /* PTC self-capacitance channels */
# define SAMD5E5_NTAMPER 3 /* Tamper pins */
#elif defined(CONFIG_ARCH_CHIP_SAMD51G19)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (512*1024) /* 512KB */
# define SAMD5E5_SRAM_SIZE (192*1024) /* 192KB */
/* Peripherals */
# define SAMD5E5_NSERCOM 6 /* Sercomm0-5 */
# define SAMD5E5_NTC 4 /* TC0-TC3 */
# define SAMD5E5_NTCCOMP 2 /* TC compare */
# define SAMD5E5_NTCC24 2 /* TCC 24-bit */
# define SAMD5E5_NTCC16 1 /* TCC 16-bit */
# define SAMD5E5_NSDHC 1 /* SDHC0 */
# define SAMD5E5_PCCSIZE 10 /* PCC data size */
# define SAMD5E5_NCCL 4 /* CCL */
# define SAMD5E5_NEVTCHAN 32 /* Event system channels */
# define SAMD5E5_NADC0CHAN 16 /* ADC0 channels */
# define SAMD5E5_NADC1CHAN 4 /* ADC1 channels */
# define SAMD5E5_NACMP 4 /* Analog comparators */
# define SAMD5E5_NDACCHAN 2 /* DAC channels */
# define SAMD5E5_NPCTMANCHAN 256 /* PTC manual channels */
# define SAMD5E5_NPCTSELFCHAN 32 /* PTC self-capacitance channels */
# define SAMD5E5_NTAMPER 2 /* Tamper pins */
#elif defined(CONFIG_ARCH_CHIP_SAMD51G18)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (256*1024) /* 1256KB */
# define SAMD5E5_SRAM_SIZE (128*1024) /* 128KB */
/* Peripherals */
# define SAMD5E5_NSERCOM 6 /* Sercomm0-5 */
# define SAMD5E5_NTC 4 /* TC0-TC3 */
# define SAMD5E5_NTCCOMP 2 /* TC compare */
# define SAMD5E5_NTCC24 2 /* TCC 24-bit */
# define SAMD5E5_NTCC16 1 /* TCC 16-bit */
# define SAMD5E5_NSDHC 1 /* SDHC0 */
# define SAMD5E5_PCCSIZE 10 /* PCC data size */
# define SAMD5E5_NCCL 4 /* CCL */
# define SAMD5E5_NEVTCHAN 32 /* Event system channels */
# define SAMD5E5_NADC0CHAN 16 /* ADC0 channels */
# define SAMD5E5_NADC1CHAN 4 /* ADC1 channels */
# define SAMD5E5_NACMP 4 /* Analog comparators */
# define SAMD5E5_NDACCHAN 2 /* DAC channels */
# define SAMD5E5_NPCTMANCHAN 256 /* PTC manual channels */
# define SAMD5E5_NPCTSELFCHAN 32 /* PTC self-capacitance channels */
# define SAMD5E5_NTAMPER 2 /* Tamper pins */
#elif defined(CONFIG_ARCH_CHIP_SAME51N20)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (1024*1024) /* 1024KB */
# define SAMD5E5_SRAM_SIZE (256*1024) /* 256KB */
/* Peripherals */
# define SAMD5E5_NSERCOM 8 /* Sercomm0-7 */
# define SAMD5E5_NTC 4 /* TC0-TC3 */
# define SAMD5E5_NTCCOMP 2 /* TC compare */
# define SAMD5E5_NTCC24 2 /* TCC 24-bit */
# define SAMD5E5_NTCC16 3 /* TCC 16-bit */
# define SAMD5E5_NSDHC 1 /* SDHC0 */
# define SAMD5E5_PCCSIZE 14 /* PCC data size */
# define SAMD5E5_NCCL 4 /* CCL */
# define SAMD5E5_NEVTCHAN 32 /* Event system channels */
# define SAMD5E5_NADC0CHAN 16 /* ADC0 channels */
# define SAMD5E5_NADC1CHAN 12 /* ADC1 channels */
# define SAMD5E5_NACMP 4 /* Analog comparators */
# define SAMD5E5_NDACCHAN 2 /* DAC channels */
# define SAMD5E5_NPCTMANCHAN 256 /* PTC manual channels */
# define SAMD5E5_NPCTSELFCHAN 32 /* PTC self-capacitance channels */
# define SAMD5E5_NTAMPER 5 /* Tamper pins */
#elif defined(CONFIG_ARCH_CHIP_SAME51N19)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (512*1024) /* 512KB */
# define SAMD5E5_SRAM_SIZE (192*1024) /* 192KB */
/* Peripherals */
# define SAMD5E5_NSERCOM 8 /* Sercomm0-7 */
# define SAMD5E5_NTC 4 /* TC0-TC3 */
# define SAMD5E5_NTCCOMP 2 /* TC compare */
# define SAMD5E5_NTCC24 2 /* TCC 24-bit */
# define SAMD5E5_NTCC16 3 /* TCC 16-bit */
# define SAMD5E5_NSDHC 1 /* SDHC0 */
# define SAMD5E5_PCCSIZE 14 /* PCC data size */
# define SAMD5E5_NCCL 4 /* CCL */
# define SAMD5E5_NEVTCHAN 32 /* Event system channels */
# define SAMD5E5_NADC0CHAN 16 /* ADC0 channels */
# define SAMD5E5_NADC1CHAN 12 /* ADC1 channels */
# define SAMD5E5_NACMP 4 /* Analog comparators */
# define SAMD5E5_NDACCHAN 2 /* DAC channels */
# define SAMD5E5_NPCTMANCHAN 256 /* PTC manual channels */
# define SAMD5E5_NPCTSELFCHAN 32 /* PTC self-capacitance channels */
# define SAMD5E5_NTAMPER 5 /* Tamper pins */
#elif defined(CONFIG_ARCH_CHIP_SAME51J20)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (1024*1024) /* 1024KB */
# define SAMD5E5_SRAM_SIZE (256*1024) /* 256KB */
/* Peripherals */
# define SAMD5E5_NSERCOM 6 /* Sercomm0-5 */
# define SAMD5E5_NTC 6 /* TC0-TC5 */
# define SAMD5E5_NTCCOMP 2 /* TC compare */
# define SAMD5E5_NTCC24 2 /* TCC 24-bit */
# define SAMD5E5_NTCC16 3 /* TCC 16-bit */
# define SAMD5E5_NSDHC 1 /* SDHC0 */
# define SAMD5E5_PCCSIZE 10 /* PCC data size */
# define SAMD5E5_NCCL 4 /* CCL */
# define SAMD5E5_NEVTCHAN 32 /* Event system channels */
# define SAMD5E5_NADC0CHAN 16 /* ADC0 channels */
# define SAMD5E5_NADC1CHAN 8 /* ADC1 channels */
# define SAMD5E5_NACMP 4 /* Analog comparators */
# define SAMD5E5_NDACCHAN 2 /* DAC channels */
# define SAMD5E5_NPCTMANCHAN 256 /* PTC manual channels */
# define SAMD5E5_NPCTSELFCHAN 32 /* PTC self-capacitance channels */
# define SAMD5E5_NTAMPER 3 /* Tamper pins */
#elif defined(CONFIG_ARCH_CHIP_SAME51J19)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (512*1024) /* 512KB */
# define SAMD5E5_SRAM_SIZE (192*1024) /* 192KB */
/* Peripherals -- to be provided */
#elif defined(CONFIG_ARCH_CHIP_SAME51J18)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (256*1024) /* 1256KB */
# define SAMD5E5_SRAM_SIZE (128*1024) /* 128KB */
/* Peripherals -- to be provided */
#elif defined(CONFIG_ARCH_CHIP_SAME53N20)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (1024*1024) /* 1024KB */
# define SAMD5E5_SRAM_SIZE (256*1024) /* 256KB */
/* Peripherals */
# define SAMD5E5_NSERCOM 8 /* Sercomm0-7 */
# define SAMD5E5_NTC 8 /* TC0-TC7 */
# define SAMD5E5_NTCCOMP 2 /* TC compare */
# define SAMD5E5_NTCC24 2 /* TCC 24-bit */
# define SAMD5E5_NTCC16 3 /* TCC 16-bit */
# define SAMD5E5_NSDHC 2 /* SDHC0-1 */
# define SAMD5E5_PCCSIZE 14 /* PCC data size */
# define SAMD5E5_NCCL 4 /* CCL */
# define SAMD5E5_NEVTCHAN 32 /* Event system channels */
# define SAMD5E5_NADC0CHAN 16 /* ADC0 channels */
# define SAMD5E5_NADC1CHAN 12 /* ADC1 channels */
# define SAMD5E5_NACMP 4 /* Analog comparators */
# define SAMD5E5_NDACCHAN 2 /* DAC channels */
# define SAMD5E5_NPCTMANCHAN 256 /* PTC manual channels */
# define SAMD5E5_NPCTSELFCHAN 32 /* PTC self-capacitance channels */
# define SAMD5E5_NTAMPER 5 /* Tamper pins */
#elif defined(CONFIG_ARCH_CHIP_SAME53N19)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (512*1024) /* 512KB */
# define SAMD5E5_SRAM_SIZE (192*1024) /* 192KB */
/* Peripherals */
# define SAMD5E5_NSERCOM 8 /* Sercomm0-7 */
# define SAMD5E5_NTC 8 /* TC0-TC7 */
# define SAMD5E5_NTCCOMP 2 /* TC compare */
# define SAMD5E5_NTCC24 2 /* TCC 24-bit */
# define SAMD5E5_NTCC16 3 /* TCC 16-bit */
# define SAMD5E5_NSDHC 2 /* SDHC0-1 */
# define SAMD5E5_PCCSIZE 14 /* PCC data size */
# define SAMD5E5_NCCL 4 /* CCL */
# define SAMD5E5_NEVTCHAN 32 /* Event system channels */
# define SAMD5E5_NADC0CHAN 16 /* ADC0 channels */
# define SAMD5E5_NADC1CHAN 12 /* ADC1 channels */
# define SAMD5E5_NACMP 4 /* Analog comparators */
# define SAMD5E5_NDACCHAN 2 /* DAC channels */
# define SAMD5E5_NPCTMANCHAN 256 /* PTC manual channels */
# define SAMD5E5_NPCTSELFCHAN 32 /* PTC self-capacitance channels */
# define SAMD5E5_NTAMPER 5 /* Tamper pins */
#elif defined(CONFIG_ARCH_CHIP_SAME53J20)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (1024*1024) /* 1024KB */
# define SAMD5E5_SRAM_SIZE (256*1024) /* 256KB */
/* Peripherals */
# define SAMD5E5_NSERCOM 6 /* Sercomm0-5 */
# define SAMD5E5_NTC 6 /* TC0-TC5 */
# define SAMD5E5_NTCCOMP 2 /* TC compare */
# define SAMD5E5_NTCC24 2 /* TCC 24-bit */
# define SAMD5E5_NTCC16 3 /* TCC 16-bit */
# define SAMD5E5_NSDHC 1 /* SDHC0 */
# define SAMD5E5_PCCSIZE 10 /* PCC data size */
# define SAMD5E5_NCCL 4 /* CCL */
# define SAMD5E5_NEVTCHAN 32 /* Event system channels */
# define SAMD5E5_NADC0CHAN 16 /* ADC0 channels */
# define SAMD5E5_NADC1CHAN 8 /* ADC1 channels */
# define SAMD5E5_NACMP 4 /* Analog comparators */
# define SAMD5E5_NDACCHAN 2 /* DAC channels */
# define SAMD5E5_NPCTMANCHAN 256 /* PTC manual channels */
# define SAMD5E5_NPCTSELFCHAN 32 /* PTC self-capacitance channels */
# define SAMD5E5_NTAMPER 3 /* Tamper pins */
#elif defined(CONFIG_ARCH_CHIP_SAME53J19)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (512*1024) /* 512KB */
# define SAMD5E5_SRAM_SIZE (192*1024) /* 192KB */
/* Peripherals */
# define SAMD5E5_NSERCOM 6 /* Sercomm0-5 */
# define SAMD5E5_NTC 6 /* TC0-TC5 */
# define SAMD5E5_NTCCOMP 2 /* TC compare */
# define SAMD5E5_NTCC24 2 /* TCC 24-bit */
# define SAMD5E5_NTCC16 3 /* TCC 16-bit */
# define SAMD5E5_NSDHC 1 /* SDHC0 */
# define SAMD5E5_PCCSIZE 10 /* PCC data size */
# define SAMD5E5_NCCL 4 /* CCL */
# define SAMD5E5_NEVTCHAN 32 /* Event system channels */
# define SAMD5E5_NADC0CHAN 16 /* ADC0 channels */
# define SAMD5E5_NADC1CHAN 8 /* ADC1 channels */
# define SAMD5E5_NACMP 4 /* Analog comparators */
# define SAMD5E5_NDACCHAN 2 /* DAC channels */
# define SAMD5E5_NPCTMANCHAN 256 /* PTC manual channels */
# define SAMD5E5_NPCTSELFCHAN 32 /* PTC self-capacitance channels */
# define SAMD5E5_NTAMPER 3 /* Tamper pins */
#elif defined(CONFIG_ARCH_CHIP_SAME53J18)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (256*1024) /* 1256KB */
# define SAMD5E5_SRAM_SIZE (128*1024) /* 128KB */
/* Peripherals */
# define SAMD5E5_NSERCOM 6 /* Sercomm0-5 */
# define SAMD5E5_NTC 6 /* TC0-TC5 */
# define SAMD5E5_NTCCOMP 2 /* TC compare */
# define SAMD5E5_NTCC24 2 /* TCC 24-bit */
# define SAMD5E5_NTCC16 3 /* TCC 16-bit */
# define SAMD5E5_NSDHC 1 /* SDHC0 */
# define SAMD5E5_PCCSIZE 10 /* PCC data size */
# define SAMD5E5_NCCL 4 /* CCL */
# define SAMD5E5_NEVTCHAN 32 /* Event system channels */
# define SAMD5E5_NADC0CHAN 16 /* ADC0 channels */
# define SAMD5E5_NADC1CHAN 8 /* ADC1 channels */
# define SAMD5E5_NACMP 4 /* Analog comparators */
# define SAMD5E5_NDACCHAN 2 /* DAC channels */
# define SAMD5E5_NPCTMANCHAN 256 /* PTC manual channels */
# define SAMD5E5_NPCTSELFCHAN 32 /* PTC self-capacitance channels */
# define SAMD5E5_NTAMPER 3 /* Tamper pins */
#elif defined(CONFIG_ARCH_CHIP_SAME54P20)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (1024*1024) /* 1024KB */
# define SAMD5E5_SRAM_SIZE (256*1024) /* 256KB */
/* Peripherals */
# define SAMD5E5_NSERCOM 8 /* Sercomm0-7 */
# define SAMD5E5_NTC 8 /* TC0-TC7 */
# define SAMD5E5_NTCCOMP 2 /* TC compare */
# define SAMD5E5_NTCC24 2 /* TCC 24-bit */
# define SAMD5E5_NTCC16 3 /* TCC 16-bit */
# define SAMD5E5_NSDHC 2 /* SDHC0-1 */
# define SAMD5E5_PCCSIZE 14 /* PCC data size */
# define SAMD5E5_NCCL 4 /* CCL */
# define SAMD5E5_NEVTCHAN 32 /* Event system channels */
# define SAMD5E5_NADC0CHAN 16 /* ADC0 channels */
# define SAMD5E5_NADC1CHAN 16 /* ADC1 channels */
# define SAMD5E5_NACMP 4 /* Analog comparators */
# define SAMD5E5_NDACCHAN 2 /* DAC channels */
# define SAMD5E5_NPCTMANCHAN 256 /* PTC manual channels */
# define SAMD5E5_NPCTSELFCHAN 32 /* PTC self-capacitance channels */
# define SAMD5E5_NTAMPER 5 /* Tamper pins */
#elif defined(CONFIG_ARCH_CHIP_SAME54P19)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (512*1024) /* 512KB */
# define SAMD5E5_SRAM_SIZE (192*1024) /* 192KB */
/* Peripherals */
# define SAMD5E5_NSERCOM 8 /* Sercomm0-7 */
# define SAMD5E5_NTC 8 /* TC0-TC7 */
# define SAMD5E5_NTCCOMP 2 /* TC compare */
# define SAMD5E5_NTCC24 2 /* TCC 24-bit */
# define SAMD5E5_NTCC16 3 /* TCC 16-bit */
# define SAMD5E5_NSDHC 2 /* SDHC0-1 */
# define SAMD5E5_PCCSIZE 14 /* PCC data size */
# define SAMD5E5_NCCL 4 /* CCL */
# define SAMD5E5_NEVTCHAN 32 /* Event system channels */
# define SAMD5E5_NADC0CHAN 16 /* ADC0 channels */
# define SAMD5E5_NADC1CHAN 16 /* ADC1 channels */
# define SAMD5E5_NACMP 4 /* Analog comparators */
# define SAMD5E5_NDACCHAN 2 /* DAC channels */
# define SAMD5E5_NPCTMANCHAN 256 /* PTC manual channels */
# define SAMD5E5_NPCTSELFCHAN 32 /* PTC self-capacitance channels */
# define SAMD5E5_NTAMPER 5 /* Tamper pins */
#elif defined(CONFIG_ARCH_CHIP_SAME54N20)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (1024*1024) /* 1024KB */
# define SAMD5E5_SRAM_SIZE (256*1024) /* 256KB */
/* Peripherals */
# define SAMD5E5_NSERCOM 8 /* Sercomm0-7 */
# define SAMD5E5_NTC 8 /* TC0-TC7 */
# define SAMD5E5_NTCCOMP 2 /* TC compare */
# define SAMD5E5_NTCC24 2 /* TCC 24-bit */
# define SAMD5E5_NTCC16 3 /* TCC 16-bit */
# define SAMD5E5_NSDHC 1 /* SDHC0 */
# define SAMD5E5_PCCSIZE 14 /* PCC data size */
# define SAMD5E5_NCCL 4 /* CCL */
# define SAMD5E5_NEVTCHAN 32 /* Event system channels */
# define SAMD5E5_NADC0CHAN 16 /* ADC0 channels */
# define SAMD5E5_NADC1CHAN 12 /* ADC1 channels */
# define SAMD5E5_NACMP 4 /* Analog comparators */
# define SAMD5E5_NDACCHAN 2 /* DAC channels */
# define SAMD5E5_NPCTMANCHAN 256 /* PTC manual channels */
# define SAMD5E5_NPCTSELFCHAN 32 /* PTC self-capacitance channels */
# define SAMD5E5_NTAMPER 5 /* Tamper pins */
#elif defined(CONFIG_ARCH_CHIP_SAME54N19)
/* Internal memory */
# define SAMD5E5_FLASH_SIZE (512*1024) /* 512KB */
# define SAMD5E5_SRAM_SIZE (192*1024) /* 192KB */
/* Peripherals */
# define SAMD5E5_NSERCOM 8 /* Sercomm0-7 */
# define SAMD5E5_NTC 8 /* TC0-TC7 */
# define SAMD5E5_NTCCOMP 2 /* TC compare */
# define SAMD5E5_NTCC24 2 /* TCC 24-bit */
# define SAMD5E5_NTCC16 3 /* TCC 16-bit */
# define SAMD5E5_NSDHC 1 /* SDHC0 */
# define SAMD5E5_PCCSIZE 14 /* PCC data size */
# define SAMD5E5_NCCL 4 /* CCL */
# define SAMD5E5_NEVTCHAN 32 /* Event system channels */
# define SAMD5E5_NADC0CHAN 16 /* ADC0 channels */
# define SAMD5E5_NADC1CHAN 12 /* ADC1 channels */
# define SAMD5E5_NACMP 4 /* Analog comparators */
# define SAMD5E5_NDACCHAN 2 /* DAC channels */
# define SAMD5E5_NPCTMANCHAN 256 /* PTC manual channels */
# define SAMD5E5_NPCTSELFCHAN 32 /* PTC self-capacitance channels */
# define SAMD5E5_NTAMPER 5 /* Tamper pins */
#else
# error Unrecognized SAMD5x/Ex chip
#endif
/* NVIC priority levels *************************************************************/
/* Each priority field holds a priority value, 0x00-0xe0. The lower the value, the
* greater the priority of the corresponding interrupt. The processor implements only
* bits[7:4] of each field, bits[6:0] read as zero and ignore writes.
*/
#define NVIC_SYSH_PRIORITY_MIN 0xe0 /* All bits[7:5] set is minimum priority */
#define NVIC_SYSH_PRIORITY_DEFAULT 0x80 /* Midpoint is the default */
#define NVIC_SYSH_PRIORITY_MAX 0x00 /* Zero is maximum priority */
#define NVIC_SYSH_PRIORITY_STEP 0x20 /* Eight priority levels in steps 0x20 */
/************************************************************************************
* Public Types
************************************************************************************/
/************************************************************************************
* Public Data
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
#endif /* __ARCH_ARM_INCLUDE_SAMD5E5_CHIP_H */

View File

@ -0,0 +1,113 @@
/****************************************************************************************
* arch/arm/include/samd5e5/irq.h
*
* Copyright (C) 2018 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.
*
****************************************************************************************/
/* This file should never be included directed but, rather, only indirectly through
* nuttx/irq.h
*/
#ifndef __ARCH_ARM_INCLUDE_SAMD5E5_IRQ_H
#define __ARCH_ARM_INCLUDE_SAMD5E5_IRQ_H
/****************************************************************************************
* Included Files
****************************************************************************************/
#include <nuttx/config.h>
#include <arch/samd5e5/chip.h>
/****************************************************************************************
* Pre-processor Definitions
****************************************************************************************/
/* IRQ numbers. The IRQ number corresponds vector number and hence map directly to
* bits in the NVIC. This does, however, waste several words of memory in the IRQ
* to handle mapping tables.
*/
/* Common Processor Exceptions (vectors 0-15) */
#define SAM_IRQ_RESERVED (0) /* Reserved vector (only used with CONFIG_DEBUG_FEATURES) */
/* Vector 0: Reset stack pointer value */
/* Vector 1: Reset (not handler as an IRQ) */
#define SAM_IRQ_NMI (2) /* Vector 2: Non-Maskable Interrupt (NMI) */
#define SAM_IRQ_HARDFAULT (3) /* Vector 3: Hard fault */
#define SAM_IRQ_MEMFAULT (4) /* Vector 4: Memory management (MPU) */
#define SAM_IRQ_BUSFAULT (5) /* Vector 5: Bus fault */
#define SAM_IRQ_USAGEFAULT (6) /* Vector 6: Usage fault */
#define SAM_IRQ_SVCALL (11) /* Vector 11: SVC call */
#define SAM_IRQ_DBGMONITOR (12) /* Vector 12: Debug Monitor */
/* Vector 13: Reserved */
#define SAM_IRQ_PENDSV (14) /* Vector 14: Pendable system service request */
#define SAM_IRQ_SYSTICK (15) /* Vector 15: System tick */
/* Chip-Specific External interrupts */
#define SAM_IRQ_EXTINT (16) /* Vector number of the first external interrupt */
#if defined(CONFIG_ARCH_CHIP_SAMD5X) || defined(ARCH_CHIP_SAME5X)
# include <arch/samd5e5/samd5e5_irq.h>
#else
# error "Unsupported SAMD5/E5 family"
#endif
/****************************************************************************************
* Public Types
****************************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************************
* Public Data
****************************************************************************************/
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************************
* Public Function Prototypes
****************************************************************************************/
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif
#endif /* __ARCH_ARM_INCLUDE_SAMD5E5_IRQ_H */

View File

@ -0,0 +1,246 @@
/************************************************************************************************
* arch/arm/include/samd5e5/sam4l_irq.h
*
* Copyright (C) 2018 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.
*
************************************************************************************************/
/* This file should never be included directed but, rather, only indirectly through
* nuttx/irq.h
*/
#ifndef __ARCH_ARM_INCLUDE_SAMD5E5_SAM4L_IRQ_H
#define __ARCH_ARM_INCLUDE_SAMD5E5_SAM4L_IRQ_H
/************************************************************************************************
* Included Files
************************************************************************************************/
/************************************************************************************************
* Pre-processor Definitions
************************************************************************************************/
/* External interrupts (vectors >= 16) */
#define SAM_IRQ_PM (SAM_IRQ_EXTINT+0) /* 0 Power Manager: SLEEPRDY */
#define SAM_IRQ_MCLK (SAM_IRQ_EXTINT+1) /* 1 Main clock: CKRDY */
#define SAM_IRQ_XOSC0 (SAM_IRQ_EXTINT+2) /* 2 XOSC0: Fail/Ready */
#define SAM_IRQ_XOSC1 (SAM_IRQ_EXTINT+3) /* 3 XOSC1: Fail/Ready */
#define SAM_IRQ_DFLL (SAM_IRQ_EXTINT+4) /* 4 OSCCTRLD: FLLLOCKC, DFLLLOCKF,
* DFLLOOB, DFLLRCS, DFLLRDY */
#define SAM_IRQ_DPLL0 (SAM_IRQ_EXTINT+5) /* 5 DPLL0: DPLLLCKF, DPLLLCKR,
* DPLLLDRTO, DPLLLTO */
#define SAM_IRQ_DPLL1 (SAM_IRQ_EXTINT+6) /* 6 DPLL1: DPLLLCKF, DPLLLCKR,
* DPLLLDRTO, DPLLLTO */
#define SAM_IRQ_OSC32K (SAM_IRQ_EXTINT+7) /* 7 OSC32KCTRL: OSC32KRDY,
* XOSC32KFAIL, XOSC32KRDY */
#define SAM_IRQ_SUPCRDY (SAM_IRQ_EXTINT+8) /* 8 Supply Controller: BOD12RDY,
* BOD33RDY, B12SRDY, B33SRDY,
* VCORERDY, VREGRDY */
#define SAM_IRQ_SUPCDET (SAM_IRQ_EXTINT+9) /* 9 Supply Controller: BOD12DET,
* BOD33DET */
#define SAM_IRQ_WDT (SAM_IRQ_EXTINT+10) /* 10 WDT: EW */
#define SAM_IRQ_RTC (SAM_IRQ_EXTINT+11) /* 11 RTC, CMPA0-3, PERA0-7, TAMPERA */
#define SAM_IRQ_EXTINT0 (SAM_IRQ_EXTINT+12) /* 12 EIC: EXTINT0 */
#define SAM_IRQ_EXTINT1 (SAM_IRQ_EXTINT+13) /* 13 EIC: EXTINT1 */
#define SAM_IRQ_EXTINT2 (SAM_IRQ_EXTINT+14) /* 14 EIC: EXTINT2 */
#define SAM_IRQ_EXTINT3 (SAM_IRQ_EXTINT+15) /* 15 EIC: EXTINT3 */
#define SAM_IRQ_EXTINT4 (SAM_IRQ_EXTINT+16) /* 16 EIC: EXTINT4 */
#define SAM_IRQ_EXTINT5 (SAM_IRQ_EXTINT+17) /* 17 EIC: EXTINT5 */
#define SAM_IRQ_EXTINT6 (SAM_IRQ_EXTINT+18) /* 18 EIC: EXTINT6 */
#define SAM_IRQ_EXTINT7 (SAM_IRQ_EXTINT+19) /* 19 EIC: EXTINT7 */
#define SAM_IRQ_EXTINT8 (SAM_IRQ_EXTINT+20) /* 20 EIC: EXTINT8 */
#define SAM_IRQ_EXTINT9 (SAM_IRQ_EXTINT+21) /* 21 EIC: EXTINT9 */
#define SAM_IRQ_EXTINT10 (SAM_IRQ_EXTINT+22) /* 22 EIC: EXTINT10 */
#define SAM_IRQ_EXTINT11 (SAM_IRQ_EXTINT+23) /* 23 EIC: EXTINT11 */
#define SAM_IRQ_EXTINT12 (SAM_IRQ_EXTINT+24) /* 24 EIC: EXTINT12 */
#define SAM_IRQ_EXTINT13 (SAM_IRQ_EXTINT+25) /* 25 EIC: EXTINT13 */
#define SAM_IRQ_EXTINT14 (SAM_IRQ_EXTINT+26) /* 26 EIC: EXTINT14 */
#define SAM_IRQ_EXTINT15 (SAM_IRQ_EXTINT+27) /* 27 EIC: EXTINT15 */
#define SAM_IRQ_FREQM (SAM_IRQ_EXTINT+28) /* 28 FREQM: Done */
#define SAM_IRQ_NVMCTRL0 (SAM_IRQ_EXTINT+29) /* 29 NVMCTRL: 0-7 */
#define SAM_IRQ_NVMCTRL1 (SAM_IRQ_EXTINT+30) /* 30 NVMCTRL: 8-10 */
#define SAM_IRQ_DMACH0 (SAM_IRQ_EXTINT+31) /* 31 DMA Channel 0: SUSP, TCMPL, TERR */
#define SAM_IRQ_DMACH1 (SAM_IRQ_EXTINT+32) /* 32 DMA Channel 1: SUSP, TCMPL, TERR */
#define SAM_IRQ_DMACH2 (SAM_IRQ_EXTINT+33) /* 33 DMA Channel 2: SUSP, TCMPL, TERR */
#define SAM_IRQ_DMACH3 (SAM_IRQ_EXTINT+34) /* 34 DMA Channel 3: SUSP, TCMPL, TERR */
#define SAM_IRQ_DMACH4_31 (SAM_IRQ_EXTINT+35) /* 35 DMA Channels 4-31: SUSP, TCMPL, TERR */
#define SAM_IRQ_EVSYS0 (SAM_IRQ_EXTINT+36) /* 36 EVSYS Channel 0: EVD, OVR */
#define SAM_IRQ_EVSYS1 (SAM_IRQ_EXTINT+37) /* 37 EVSYS Channel 1: EVD, OVR */
#define SAM_IRQ_EVSYS2 (SAM_IRQ_EXTINT+38) /* 38 EVSYS Channel 2: EVD, OVR */
#define SAM_IRQ_EVSYS3 (SAM_IRQ_EXTINT+39) /* 39 EVSYS Channel 3: EVD, OVR */
#define SAM_IRQ_EVSYS4_11 (SAM_IRQ_EXTINT+40) /* 40 EVSYS Channels 4-11: EVD, OVR */
#define SAM_IRQ_PAC (SAM_IRQ_EXTINT+41) /* 41 PAC: ERR */
#define SAM_IRQ_RAMECC (SAM_IRQ_EXTINT+45) /* 45 RAM ECC: 0-1 */
#define SAM_IRQ_SERCOM0_0 (SAM_IRQ_EXTINT+46) /* 46 SERCOM0: 0 */
#define SAM_IRQ_SERCOM0_1 (SAM_IRQ_EXTINT+47) /* 47 SERCOM0: 1 */
#define SAM_IRQ_SERCOM0_2 (SAM_IRQ_EXTINT+48) /* 48 SERCOM0: 2 */
#define SAM_IRQ_SERCOM0_46 (SAM_IRQ_EXTINT+49) /* 49 SERCOM0: 4-6 */
#define SAM_IRQ_SERCOM1_0 (SAM_IRQ_EXTINT+50) /* 50 SERCOM1: 0 */
#define SAM_IRQ_SERCOM1_1 (SAM_IRQ_EXTINT+51) /* 51 SERCOM1: 1 */
#define SAM_IRQ_SERCOM1_2 (SAM_IRQ_EXTINT+52) /* 52 SERCOM1: 2 */
#define SAM_IRQ_SERCOM1_46 (SAM_IRQ_EXTINT+53) /* 53 SERCOM1: 4-6 */
#define SAM_IRQ_SERCOM2_0 (SAM_IRQ_EXTINT+54) /* 54 SERCOM2: 0 */
#define SAM_IRQ_SERCOM2_1 (SAM_IRQ_EXTINT+55) /* 55 SERCOM2: 1 */
#define SAM_IRQ_SERCOM2_2 (SAM_IRQ_EXTINT+56) /* 56 SERCOM2: 2 */
#define SAM_IRQ_SERCOM2_46 (SAM_IRQ_EXTINT+57) /* 57 SERCOM2: 4-6 */
#define SAM_IRQ_SERCOM3_0 (SAM_IRQ_EXTINT+58) /* 58 SERCOM3: 0 */
#define SAM_IRQ_SERCOM3_1 (SAM_IRQ_EXTINT+59) /* 59 SERCOM3: 1 */
#define SAM_IRQ_SERCOM3_2 (SAM_IRQ_EXTINT+60) /* 60 SERCOM3: 2 */
#define SAM_IRQ_SERCOM3_46 (SAM_IRQ_EXTINT+61) /* 61 SERCOM3: 4-6 */
#define SAM_IRQ_SERCOM4_0 (SAM_IRQ_EXTINT+62) /* 62 SERCOM4: 0 */
#define SAM_IRQ_SERCOM4_1 (SAM_IRQ_EXTINT+63) /* 63 SERCOM4: 1 */
#define SAM_IRQ_SERCOM4_2 (SAM_IRQ_EXTINT+64) /* 64 SERCOM4: 2 */
#define SAM_IRQ_SERCOM4_46 (SAM_IRQ_EXTINT+65) /* 65 SERCOM4: 4-6 */
#define SAM_IRQ_SERCOM5_0 (SAM_IRQ_EXTINT+66) /* 66 SERCOM5: 0 */
#define SAM_IRQ_SERCOM5_1 (SAM_IRQ_EXTINT+67) /* 67 SERCOM5: 1 */
#define SAM_IRQ_SERCOM5_2 (SAM_IRQ_EXTINT+68) /* 68 SERCOM5: 2 */
#define SAM_IRQ_SERCOM5_46 (SAM_IRQ_EXTINT+69) /* 69 SERCOM5: 4-6 */
#define SAM_IRQ_SERCOM6_0 (SAM_IRQ_EXTINT+70) /* 70 SERCOM6: 0 */
#define SAM_IRQ_SERCOM6_1 (SAM_IRQ_EXTINT+71) /* 71 SERCOM6: 1 */
#define SAM_IRQ_SERCOM6_2 (SAM_IRQ_EXTINT+72) /* 72 SERCOM6: 2 */
#define SAM_IRQ_SERCOM6_46 (SAM_IRQ_EXTINT+73) /* 73 SERCOM6: 4-6 */
#define SAM_IRQ_SERCOM7_0 (SAM_IRQ_EXTINT+74) /* 74 SERCOM7: 0 */
#define SAM_IRQ_SERCOM7_1 (SAM_IRQ_EXTINT+75) /* 75 SERCOM7: 1 */
#define SAM_IRQ_SERCOM7_2 (SAM_IRQ_EXTINT+76) /* 76 SERCOM7: 2 */
#define SAM_IRQ_SERCOM7_46 (SAM_IRQ_EXTINT+77) /* 77 SERCOM7: 4-6 */
#define SAM_IRQ_CAN0 (SAM_IRQ_EXTINT+78) /* 78 CAN0: Line0, Line1 */
#define SAM_IRQ_CAN1 (SAM_IRQ_EXTINT+79) /* 79 CAN1: Line0, Line1 */
#define SAM_IRQ_USB (SAM_IRQ_EXTINT+80) /* 80 USB: EORSM, DNRSM, EORST RST,
* LPM DCONN, LPMSUSP DDISC, MSOF,
* RAMACER, RXSTP TXSTP 0-7, STALL0
* STALL 0-7, STALL1 0-7, SUSPEND,
* TRFAIL0 TRFAIL 097, TRFAIL1 PERR
* 0..7, UPRSM, WAKEUP */
#define SAM_IRQ_USBSOF (SAM_IRQ_EXTINT+81) /* 81 USB: SOF HSOF */
#define SAM_IRQ_USBTRCPT0 (SAM_IRQ_EXTINT+82) /* 82 USB: TRCPT0 0..7 */
#define SAM_IRQ_USBTRCPT1 (SAM_IRQ_EXTINT+83) /* 83 USB: TRCPT0 0..7 */
#define SAM_IRQ_GMAL (SAM_IRQ_EXTINT+84) /* 84 GMAC: GMAC, WOL */
#define SAM_IRQ_TCC0 (SAM_IRQ_EXTINT+85) /* 85 TCC0: CNT A, DFS A, ERR A, FAULTA
* A, FAULTB A, FAULT0 A, FAULT1 A,
* OVF, TRG, UFS A */
#define SAM_IRQ_TCC0MC0 (SAM_IRQ_EXTINT+86) /* 86 TCC0: MC 0 */
#define SAM_IRQ_TCC0MC1 (SAM_IRQ_EXTINT+87) /* 87 TCC0: MC 1 */
#define SAM_IRQ_TCC0MC2 (SAM_IRQ_EXTINT+88) /* 88 TCC0: MC 2 */
#define SAM_IRQ_TCC0MC3 (SAM_IRQ_EXTINT+89) /* 89 TCC0: MC 3 */
#define SAM_IRQ_TCC0MC4 (SAM_IRQ_EXTINT+90) /* 90 TCC0: MC 4 */
#define SAM_IRQ_TCC0MC5 (SAM_IRQ_EXTINT+91) /* 91 TCC0: MC 5 */
#define SAM_IRQ_TCC1 (SAM_IRQ_EXTINT+92) /* 92 TCC1: CNT A, DFS A, ERR A, FAULTA
* A, FAULTB A, FAULT0 A, FAULT1 A,
* OVF, TRG, UFS A */
#define SAM_IRQ_TCC1MC0 (SAM_IRQ_EXTINT+93) /* 93 TCC1: MC 0 */
#define SAM_IRQ_TCC1MC1 (SAM_IRQ_EXTINT+94) /* 94 TCC1: MC 1 */
#define SAM_IRQ_TCC1MC2 (SAM_IRQ_EXTINT+95) /* 95 TCC1: MC 2 */
#define SAM_IRQ_TCC1MC3 (SAM_IRQ_EXTINT+96) /* 96 TCC1: MC 3 */
#define SAM_IRQ_TCC2 (SAM_IRQ_EXTINT+97) /* 97 TCC2: CNT A, DFS A, ERR A, FAULTA
* A, FAULTB A, FAULT0 A, FAULT1 A,
* OVF, TRG, UFS A */
#define SAM_IRQ_TCC2MC0 (SAM_IRQ_EXTINT+98) /* 98 TCC2: MC 0 */
#define SAM_IRQ_TCC2MC1 (SAM_IRQ_EXTINT+99) /* 99 TCC2: MC 1 */
#define SAM_IRQ_TCC2MC2 (SAM_IRQ_EXTINT+100) /* 100 TCC2: MC 2 */
#define SAM_IRQ_TCC3 (SAM_IRQ_EXTINT+101) /* 101 TCC3: CNT A, DFS A, ERR A, FAULTA
* A, FAULTB A, FAULT0 A, FAULT1 A,
* OVF, TRG, UFS A */
#define SAM_IRQ_TCC3MC0 (SAM_IRQ_EXTINT+102) /* 102 TCC3: MC 0 */
#define SAM_IRQ_TCC3MC1 (SAM_IRQ_EXTINT+103) /* 103 TCC3: MC 1 */
#define SAM_IRQ_TCC4 (SAM_IRQ_EXTINT+104) /* 104 TCC4: CNT A, DFS A, ERR A, FAULTA
* A, FAULTB A, FAULT0 A, FAULT1 A,
* OVF, TRG, UFS A */
#define SAM_IRQ_TCC4MC0 (SAM_IRQ_EXTINT+105) /* 105 TCC4: MC 0 */
#define SAM_IRQ_TCC4MC1 (SAM_IRQ_EXTINT+106) /* 106 TCC4: MC 1 */
#define SAM_IRQ_TC0 (SAM_IRQ_EXTINT+107) /* 107 TC0: ERR A, MC 0, MC 1, OVF */
#define SAM_IRQ_TC1 (SAM_IRQ_EXTINT+108) /* 108 TC1: ERR A, MC 0, MC 1, OVF */
#define SAM_IRQ_TC2 (SAM_IRQ_EXTINT+109) /* 109 TC2: ERR A, MC 0, MC 1, OVF */
#define SAM_IRQ_TC3 (SAM_IRQ_EXTINT+110) /* 110 TC3: ERR A, MC 0, MC 1, OVF */
#define SAM_IRQ_TC4 (SAM_IRQ_EXTINT+111) /* 111 TC4: ERR A, MC 0, MC 1, OVF */
#define SAM_IRQ_TC5 (SAM_IRQ_EXTINT+112) /* 112 TC5: ERR A, MC 0, MC 1, OVF */
#define SAM_IRQ_TC6 (SAM_IRQ_EXTINT+113) /* 113 TC6: ERR A, MC 0, MC 1, OVF */
#define SAM_IRQ_TC7 (SAM_IRQ_EXTINT+114) /* 114 TC7: ERR A, MC 0, MC 1, OVF */
#define SAM_IRQ_PDEC (SAM_IRQ_EXTINT+115) /* 115 PDEC: DIR A, ERR A, OVF, VLC A */
#define SAM_IRQ_PDECMC0 (SAM_IRQ_EXTINT+116) /* 116 PDEC: MC 0 */
#define SAM_IRQ_PDECMC1 (SAM_IRQ_EXTINT+117) /* 117 PDEC: MC 1 */
#define SAM_IRQ_ADC0 (SAM_IRQ_EXTINT+118) /* 118 ADC0: OVERRUN, WINMON */
#define SAM_IRQ_ADC0RDY (SAM_IRQ_EXTINT+119) /* 119 ADC0: RESRDY */
#define SAM_IRQ_ADC1 (SAM_IRQ_EXTINT+120) /* 120 ADC0: OVERRUN, WINMON */
#define SAM_IRQ_ADC1RDY (SAM_IRQ_EXTINT+121) /* 121 ADC0: RESRDY */
#define SAM_IRQ_AC (SAM_IRQ_EXTINT+122) /* 122 AC: COMP 0, COMP 1, WIN 0 */
#define SAM_IRQ_DACERR (SAM_IRQ_EXTINT+123) /* 123 DAC: OVERRUN A 0, OVERRUN A 1,
* UNDERRUN A 0, UNDERRUN A 1 */
#define SAM_IRQ_DACEMPTY0 (SAM_IRQ_EXTINT+124) /* 124 DAC: EMPTY 0 */
#define SAM_IRQ_DACEMPTY1 (SAM_IRQ_EXTINT+125) /* 125 DAC: EMPTY 1 */
#define SAM_IRQ_DACRDY0 (SAM_IRQ_EXTINT+126) /* 126 DAC: RESRDY 0 */
#define SAM_IRQ_DACRDY1 (SAM_IRQ_EXTINT+127) /* 127 DAC: RESRDY 1 */
#define SAM_IRQ_I2S (SAM_IRQ_EXTINT+128) /* 128 I2S: RXOR 0, RXOR 1, RXRDY 0, RXRDY
* 1, TXRDY 0, TXRDY 1, TXUR 0, TXUR 1 */
#define SAM_IRQ_PCC (SAM_IRQ_EXTINT+129) /* 129 PCC: */
#define SAM_IRQ_AES (SAM_IRQ_EXTINT+130) /* 130 AES: ENCCMP, GFMCMP */
#define SAM_IRQ_TRNG (SAM_IRQ_EXTINT+131) /* 131 TRNG: IS0 */
#define SAM_IRQ_ICM (SAM_IRQ_EXTINT+132) /* 132 ICM: */
#define SAM_IRQ_PUKCC (SAM_IRQ_EXTINT+133) /* 133 PUKCC: */
#define SAM_IRQ_QSPI (SAM_IRQ_EXTINT+134) /* 134 QSPI: */
#define SAM_IRQ_SDHC0 (SAM_IRQ_EXTINT+135) /* 135 SDHC0: SDHC0, TIMER */
#define SAM_IRQ_SDHC1 (SAM_IRQ_EXTINT+136) /* 136 SDHC1: SDHC1, TIMER */
#define SAM_IRQ_NEXTINT 137 /* Total number of external interrupt numbers */
#define NR_IRQS (SAM_IRQ_EXTINT+SAM_IRQ_NEXTINT) /* The number of vectors */
/************************************************************************************************
* Public Types
************************************************************************************************/
/************************************************************************************************
* Inline functions
************************************************************************************************/
/************************************************************************************************
* Public Data
************************************************************************************************/
/************************************************************************************************
* Public Function Prototypes
************************************************************************************************/
#ifndef __ASSEMBLY__
#ifdef __cplusplus
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
#undef EXTERN
#ifdef __cplusplus
}
#endif
#endif
#endif /* __ARCH_ARM_INCLUDE_SAMD5E5_SAM4L_IRQ_H */

View File

@ -0,0 +1,711 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
comment "Microchip SAMD5x/E5x Configuration Options"
choice
prompt "Microchip SAMD5x/E5x Chip Selection"
default ARCH_CHIP_SAMD51P19 if ARCH_CHIP_SAMD5X
default ARCH_CHIP_ATSAME54P20A if ARCH_CHIP_SAME5X
depends on ARCH_CHIP_SAMD5X || ARCH_CHIP_SAME5X
config ARCH_CHIP_SAMD51P20
bool "SAMD51P20"
depends on ARCH_CHIP_SAMD5X
select ARCH_FAMILY_SAMD51
select SAMD5E5_HAVE_SDHC2
select SAMD5E5_HAVE_SERCOM6
select SAMD5E5_HAVE_SERCOM7
select SAMD5E5_HAVE_TC4
select SAMD5E5_HAVE_TC5
select SAMD5E5_HAVE_TC6
select SAMD5E5_HAVE_TC7
---help---
Flash 1024KB SRAM 256KB
config ARCH_CHIP_SAMD51P19
bool "SAMD51P19"
depends on ARCH_CHIP_SAMD5X
select ARCH_FAMILY_SAMD51
select SAMD5E5_HAVE_SDHC2
select SAMD5E5_HAVE_SERCOM6
select SAMD5E5_HAVE_SERCOM7
select SAMD5E5_HAVE_TC4
select SAMD5E5_HAVE_TC5
select SAMD5E5_HAVE_TC6
select SAMD5E5_HAVE_TC7
---help---
Flash 512KB SRAM 192KB
config ARCH_CHIP_SAMD51N20
bool "SAMD51N20"
depends on ARCH_CHIP_SAMD5X
select ARCH_FAMILY_SAMD51
select SAMD5E5_HAVE_SDHC2
select SAMD5E5_HAVE_SERCOM6
select SAMD5E5_HAVE_SERCOM7
select SAMD5E5_HAVE_TC4
select SAMD5E5_HAVE_TC5
select SAMD5E5_HAVE_TC6
select SAMD5E5_HAVE_TC7
---help---
Flash 1024KB SRAM 256KB
config ARCH_CHIP_SAMD51N19
bool "SAMD51N19"
depends on ARCH_CHIP_SAMD5X
select ARCH_FAMILY_SAMD51
select SAMD5E5_HAVE_SDHC2
select SAMD5E5_HAVE_SERCOM6
select SAMD5E5_HAVE_SERCOM7
select SAMD5E5_HAVE_TC4
select SAMD5E5_HAVE_TC5
select SAMD5E5_HAVE_TC6
select SAMD5E5_HAVE_TC7
---help---
Flash 512KB SRAM 192KB
config ARCH_CHIP_SAMD51J20
bool "SAMD51J20"
depends on ARCH_CHIP_SAMD5X
select ARCH_FAMILY_SAMD51
select SAMD5E5_HAVE_TC4
select SAMD5E5_HAVE_TC5
---help---
Flash 1024KB SRAM 256KB
config ARCH_CHIP_SAMD51J19
bool "SAMD51J19"
depends on ARCH_CHIP_SAMD5X
select ARCH_FAMILY_SAMD51
select SAMD5E5_HAVE_TC4
select SAMD5E5_HAVE_TC5
---help---
Flash 512KB SRAM 192KB
config ARCH_CHIP_SAMD51J18
bool "SAMD51J18"
depends on ARCH_CHIP_SAMD5X
select ARCH_FAMILY_SAMD51
select SAMD5E5_HAVE_TC4
select SAMD5E5_HAVE_TC5
---help---
Flash 256KB SRAM 128KB
config ARCH_CHIP_SAMD51G19
bool "SAMD51G19"
depends on ARCH_CHIP_SAMD5X
select ARCH_FAMILY_SAMD51
---help---
Flash 512KB SRAM 192KB
config ARCH_CHIP_SAMD51G18
bool "SAMD51G18"
depends on ARCH_CHIP_SAMD5X
select ARCH_FAMILY_SAMD51
---help---
Flash 256KB SRAM 128KB
config ARCH_CHIP_SAME51N20
bool "SAME51N20"
depends on ARCH_CHIP_SAME5X
select ARCH_FAMILY_SAME51
select SAMD5E5_HAVE_CANFD
select SAMD5E5_HAVE_SERCOM6
select SAMD5E5_HAVE_SERCOM7
select SAMD5E5_HAVE_TC4
select SAMD5E5_HAVE_TC5
select SAMD5E5_HAVE_TC6
select SAMD5E5_HAVE_TC7
---help---
Flash 1024KB SRAM 256KB
config ARCH_CHIP_SAME51N19
bool "SAME51N19"
depends on ARCH_CHIP_SAME5X
select ARCH_FAMILY_SAME51
select SAMD5E5_HAVE_CANFD
select SAMD5E5_HAVE_SERCOM6
select SAMD5E5_HAVE_SERCOM7
select SAMD5E5_HAVE_TC4
select SAMD5E5_HAVE_TC5
select SAMD5E5_HAVE_TC6
select SAMD5E5_HAVE_TC7
---help---
Flash 512KB SRAM 192KB
config ARCH_CHIP_SAME51J20
bool "SAME51J20"
depends on ARCH_CHIP_SAME5X
select ARCH_FAMILY_SAME51
select SAMD5E5_HAVE_CANFD
select SAMD5E5_HAVE_TC4
select SAMD5E5_HAVE_TC5
---help---
Flash 1024KB SRAM 256KB
config ARCH_CHIP_SAME51J19
bool "SAME51J19"
depends on ARCH_CHIP_SAME5X
select ARCH_FAMILY_SAME51
---help---
Flash 512KB SRAM 192KB
config ARCH_CHIP_SAME51J18
bool "SAME51J18"
depends on ARCH_CHIP_SAME5X
select ARCH_FAMILY_SAME51
---help---
Flash 256KB SRAM 128KB
config ARCH_CHIP_SAME53N20
bool "SAME53N20"
depends on ARCH_CHIP_SAME5X
select ARCH_FAMILY_SAME53
select SAMD5E5_HAVE_ETHERNET
select SAMD5E5_HAVE_SDHC2
select SAMD5E5_HAVE_SERCOM6
select SAMD5E5_HAVE_SERCOM7
select SAMD5E5_HAVE_TC4
select SAMD5E5_HAVE_TC5
select SAMD5E5_HAVE_TC6
select SAMD5E5_HAVE_TC7
---help---
Flash 1024KB SRAM 256KB
config ARCH_CHIP_SAME53N19
bool "SAME53N19"
depends on ARCH_CHIP_SAME5X
select ARCH_FAMILY_SAME53
select SAMD5E5_HAVE_ETHERNET
select SAMD5E5_HAVE_SDHC2
select SAMD5E5_HAVE_SERCOM6
select SAMD5E5_HAVE_SERCOM7
select SAMD5E5_HAVE_TC4
select SAMD5E5_HAVE_TC5
select SAMD5E5_HAVE_TC6
select SAMD5E5_HAVE_TC7
---help---
Flash 512KB SRAM 192KB
config ARCH_CHIP_SAME53J20
bool "SAME53J20"
depends on ARCH_CHIP_SAME5X
select ARCH_FAMILY_SAME53
select SAMD5E5_HAVE_ETHERNET
select SAMD5E5_HAVE_TC4
select SAMD5E5_HAVE_TC5
---help---
Flash 1024KB SRAM 256KB
config ARCH_CHIP_SAME53J19
bool "SAME53J19"
depends on ARCH_CHIP_SAME5X
select ARCH_FAMILY_SAME53
select SAMD5E5_HAVE_ETHERNET
select SAMD5E5_HAVE_TC4
select SAMD5E5_HAVE_TC5
---help---
Flash 512KB SRAM 192KB
config ARCH_CHIP_SAME53J18
bool "SAME53J18"
depends on ARCH_CHIP_SAME5X
select ARCH_FAMILY_SAME53
select SAMD5E5_HAVE_ETHERNET
select SAMD5E5_HAVE_TC4
select SAMD5E5_HAVE_TC5
---help---
Flash 256KB SRAM 128KB
config ARCH_CHIP_SAME54P20
bool "SAME54P20"
depends on ARCH_CHIP_SAME5X
select ARCH_FAMILY_SAME54
select SAMD5E5_HAVE_ETHERNET
select SAMD5E5_HAVE_CANFD
select SAMD5E5_HAVE_SDHC2
select SAMD5E5_HAVE_SERCOM6
select SAMD5E5_HAVE_SERCOM7
select SAMD5E5_HAVE_TC4
select SAMD5E5_HAVE_TC5
select SAMD5E5_HAVE_TC6
select SAMD5E5_HAVE_TC7
---help---
Flash 1024KB SRAM 256KB
config ARCH_CHIP_SAME54P19
bool "SAME54P19"
select ARCH_FAMILY_SAME54
select SAMD5E5_HAVE_ETHERNET
select SAMD5E5_HAVE_CANFD
select SAMD5E5_HAVE_SDHC2
select SAMD5E5_HAVE_SERCOM6
select SAMD5E5_HAVE_SERCOM7
select SAMD5E5_HAVE_TC4
select SAMD5E5_HAVE_TC5
select SAMD5E5_HAVE_TC6
select SAMD5E5_HAVE_TC7
---help---
Flash 512KB SRAM 192KB
config ARCH_CHIP_SAME54N20
bool "SAME54N20"
select ARCH_FAMILY_SAME54
select SAMD5E5_HAVE_ETHERNET
select SAMD5E5_HAVE_CANFD
select SAMD5E5_HAVE_SDHC2
select SAMD5E5_HAVE_SERCOM6
select SAMD5E5_HAVE_SERCOM7
select SAMD5E5_HAVE_TC4
select SAMD5E5_HAVE_TC5
select SAMD5E5_HAVE_TC6
select SAMD5E5_HAVE_TC7
---help---
Flash 1024KB SRAM 256KB
config ARCH_CHIP_SAME54N19
bool "SAME54N19"
select ARCH_FAMILY_SAME54
select SAMD5E5_HAVE_ETHERNET
select SAMD5E5_HAVE_CANFD
select SAMD5E5_HAVE_SDHC2
select SAMD5E5_HAVE_SERCOM6
select SAMD5E5_HAVE_SERCOM7
select SAMD5E5_HAVE_TC4
select SAMD5E5_HAVE_TC5
select SAMD5E5_HAVE_TC6
select SAMD5E5_HAVE_TC7
---help---
Flash 512KB SRAM 192KB
endchoice # Microchip SAMD5x/E5x Chip Selection
config ARCH_FAMILY_SAMD5X
bool
default n
config ARCH_FAMILY_SAMD51
bool
default n
config ARCH_FAMILY_SAME5X
bool
default n
config ARCH_FAMILY_SAME51
bool
default n
menu "SAMD5x/E5x Peripheral Support"
config SAMD5E5_HAVE_CANFD
bool
default n
config SAMD5E5_HAVE_ETHERNET
bool
default n
config SAMD5E5_HAVE_SDHC2
bool
default n
config SAMD5E5_HAVE_SERCOM6
bool
default n
config SAMD5E5_HAVE_SERCOM7
bool
default n
config SAMD5E5_HAVE_TC4
bool
default n
config SAMD5E5_HAVE_TC5
bool
default n
config SAMD5E5_HAVE_TC6
bool
default n
config SAMD5E5_HAVE_TC7
bool
default n
config SAMD5E5_AC
bool "Analog Comparator"
default n
config SAMD5E5_ADC
bool "Analog-to-Digital Converter"
default n
config SAMD5E5_CMCC
bool "Cortex M Cache Controller (CMCC)"
default n
depends on ARCH_CHIP_SAM4E
config SAMD5E5_DAC
bool "Digital-to-Analog Converter"
default n
config SAMD5E5_DMAC
bool "DMA Controller"
default n
select ARCH_DMA
depends on EXPERIMENTAL
config SAMD5E5_EVSYS
bool "Event System"
default n
config SAMD5E5_NVMCTRL
bool "Non-Volatile Memory Controller"
default n
config SAMD5E5_PTC
bool "Peripheral Touch Controller"
default n
config SAMD5E5_RTC
bool "Real Time Counter"
default n
config SAMD5E5_SERCOM0
bool "Serial Communication Interface 0"
default n
config SAMD5E5_SERCOM1
bool "Serial Communication Interface 1"
default n
config SAMD5E5_SERCOM2
bool "Serial Communication Interface 2"
default n
config SAMD5E5_SERCOM3
bool "Serial Communication Interface 3"
default n
config SAMD5E5_SERCOM4
bool "Serial Communication Interface 4"
default n
config SAMD5E5_SERCOM5
bool "Serial Communication Interface 5"
default n
config SAMD5E5_SERCOM6
bool "Serial Communication Interface 6"
default n
depends on SAMD5E5_HAVE_SERCOM6
config SAMD5E5_SERCOM7
bool "Serial Communication Interface 7"
default n
depends on SAMD5E5_HAVE_SERCOM7
config SAMD5E5_TC0
bool "Timer/Counter 0"
default n
config SAMD5E5_TC1
bool "Timer/Counter 1"
default n
config SAMD5E5_TC2
bool "Timer/Counter 2"
default n
config SAMD5E5_TC3
bool "Timer/Counter 3"
default n
config SAMD5E5_TC4
bool "Timer/Counter 4"
default n
depends on SAMD5E5_HAVE_TC4
config SAMD5E5_TC5
bool "Timer/Counter 5"
default n
depends on SAMD5E5_HAVE_TC5
config SAMD5E5_TC6
bool "Timer/Counter 6"
default n
depends on SAMD5E5_HAVE_TC6
config SAMD5E5_TC7
bool "Timer/Counter 7"
default n
depends on SAMD5E5_HAVE_TC7
config SAMD5E5_USB
bool "USB"
default n
config SAMD5E5_EIC
bool "External Interrupt Controller"
default n
config SAMD5E5_WDT
bool "Watchdog Timer"
default n
endmenu # SAMD5x/E5x Peripheral Support
config SAMD5E5_DMAC_NDESC
int "Number of additional DMA Descriptors"
default 0
depends on SAMD5E5_DMAC
---help---
This provides the number of additional DMA descriptors that can be
use to support multi-linked DMA transfers. A minimum of 16
descriptors will always be allocated (16 for the base descriptor which
overlap the writeback descriptors). If this value is set to zero,
then only single block DMA transfers can be supported.
Each additional DMA descriptor will require 16-bytes for LPRAM
memory.
config SAMD5E5_EIC_CLKGEN
int "EIC Clock Generator"
default 2
range 0 11
---help---
Some optional functions need a peripheral clock, which can either be
a generic clock (GCLK_EIC, for wider frequency selection) or a Ultra
Low Power 32KHz clock (CLK_ULP32K, for highest power efficiency). One
of the clock sources must be configured and enabled before using the
peripheral.
This option assumes that GCLK will be used and provides the GCL
number to be used
choice
prompt "SERCOM0 mode"
default SAMD5E5_SERCOM0_ISUSART
depends on SAMD5E5_SERCOM0
config SAMD5E5_SERCOM0_ISI2C
bool "I2C"
select I2C
select SAMD5E5_HAVE_I2C
config SAMD5E5_SERCOM0_ISSPI
bool "SPI"
select SAMD5E5_HAVE_SPI
config SAMD5E5_SERCOM0_ISUSART
bool "USART"
select USART0_SERIALDRIVER
endchoice
choice
prompt "SERCOM1 mode"
default SAMD5E5_SERCOM1_ISUSART
depends on SAMD5E5_SERCOM1
config SAMD5E5_SERCOM1_ISI2C
bool "I2C"
select I2C
select SAMD5E5_HAVE_I2C
config SAMD5E5_SERCOM1_ISSPI
bool "SPI"
select SAMD5E5_HAVE_SPI
config SAMD5E5_SERCOM1_ISUSART
bool "USART"
select USART1_SERIALDRIVER
endchoice
choice
prompt "SERCOM2 mode"
default SAMD5E5_SERCOM2_ISUSART
depends on SAMD5E5_SERCOM2
config SAMD5E5_SERCOM2_ISI2C
bool "I2C"
select I2C
select SAMD5E5_HAVE_I2C
config SAMD5E5_SERCOM2_ISSPI
bool "SPI"
select SAMD5E5_HAVE_SPI
config SAMD5E5_SERCOM2_ISUSART
bool "USART"
select USART2_SERIALDRIVER
endchoice
choice
prompt "SERCOM3 mode"
default SAMD5E5_SERCOM3_ISUSART
depends on SAMD5E5_SERCOM3
config SAMD5E5_SERCOM3_ISI2C
bool "I2C"
select I2C
select SAMD5E5_HAVE_I2C
config SAMD5E5_SERCOM3_ISSPI
bool "SPI"
select SAMD5E5_HAVE_SPI
config SAMD5E5_SERCOM3_ISUSART
bool "USART"
select USART3_SERIALDRIVER
endchoice
choice
prompt "SERCOM4 mode"
default SAMD5E5_SERCOM4_ISUSART
depends on SAMD5E5_SERCOM4
config SAMD5E5_SERCOM4_ISI2C
bool "I2C"
select I2C
select SAMD5E5_HAVE_I2C
config SAMD5E5_SERCOM4_ISSPI
bool "SPI"
select SAMD5E5_HAVE_SPI
config SAMD5E5_SERCOM4_ISUSART
bool "USART"
select USART4_SERIALDRIVER
endchoice
choice
prompt "SERCOM5 mode"
default SAMD5E5_SERCOM5_ISUSART
depends on SAMD5E5_SERCOM5
config SAMD5E5_SERCOM5_ISI2C
bool "I2C"
select I2C
select SAMD5E5_HAVE_I2C
config SAMD5E5_SERCOM5_ISSPI
bool "SPI"
select SAMD5E5_HAVE_SPI
config SAMD5E5_SERCOM5_ISUSART
bool "USART"
select USART5_SERIALDRIVER
endchoice
choice
prompt "SERCOM6 mode"
default SAMD5E5_SERCOM6_ISUSART
depends on SAMD5E5_SERCOM6
config SAMD5E5_SERCOM6_ISI2C
bool "I2C"
select I2C
select SAMD5E5_HAVE_I2C
config SAMD5E5_SERCOM6_ISSPI
bool "SPI"
select SAMD5E5_HAVE_SPI
config SAMD5E5_SERCOM6_ISUSART
bool "USART"
select USART6_SERIALDRIVER
endchoice
choice
prompt "SERCOM7 mode"
default SAMD5E5_SERCOM7_ISUSART
depends on SAMD5E5_SERCOM7
config SAMD5E5_SERCOM7_ISI2C
bool "I2C"
select I2C
select SAMD5E5_HAVE_I2C
config SAMD5E5_SERCOM7_ISSPI
bool "SPI"
select SAMD5E5_HAVE_SPI
config SAMD5E5_SERCOM7_ISUSART
bool "USART"
select USART7_SERIALDRIVER
endchoice
config SAMD5E5_HAVE_SPI
bool
select SPI
menu "SPI options"
depends on SAMD5E5_HAVE_SPI
config SAMD5E5_SPI_DMA
bool "SPI DMA"
default n
depends on SAMD5E5_DMAC && EXPERIMENTAL
---help---
Use DMA for SPI SERCOM peripherals.
config SAMD5E5_SPI_REGDEBUG
bool "SPI register-Level Debug"
default n
depends on DEBUG_SPI_INFO
---help---
Enable very low-level register access debug. Depends on DEBUG_SPI.
endmenu # SPI options
config SAMD5E5_HAVE_I2C
bool
select I2C
menu "I2C options"
depends on SAMD5E5_HAVE_I2C
config SAMD5E5_I2C_REGDEBUG
bool "I2C register-Level Debug"
default n
depends on DEBUG_I2C_INFO
---help---
Enable very low-level register access debug. Depends on DEBUG_I2C.
endmenu # I2C options
menu "USB options"
depends on SAMD5E5_USB
config SAMD5E5_USB_ENABLE_PPEP
bool "Enable Ping-Pong Endpoints"
default n
---help---
To maximize throughput, an endpoint can be configured for ping-pong
operation. When this is done the input and output endpoint with the same
address are used in the same direction. The CPU or DMA Controller can
then read/write one data buffer while the USB module writes/reads from
the other buffer. This gives double buffered communication.
config SAMD5E5_USB_REGDEBUG
bool "USB register-Level Debug"
default n
depends on DEBUG_USB_INFO
---help---
Enable very low-level register access debug. Depends on
CONFIG_DEBUG_USB_INFO.
endmenu # USB options

View File

@ -0,0 +1,158 @@
############################################################################
# arch/arm/src/samd5e5/Make.defs
#
# Copyright (C) 2018 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.
#
############################################################################
# The start-up, "head", file
HEAD_ASRC =
# Common ARM and Cortex-M4 files
CMN_UASRCS =
CMN_UCSRCS =
CMN_ASRCS = up_saveusercontext.S up_fullcontextrestore.S up_switchcontext.S
CMN_ASRCS += up_testset.S up_fetchadd.S vfork.S
CMN_CSRCS = up_allocateheap.c up_assert.c up_blocktask.c up_copyfullstate.c
CMN_CSRCS += up_createstack.c up_mdelay.c up_udelay.c up_exit.c
CMN_CSRCS += up_initialize.c up_initialstate.c up_interruptcontext.c
CMN_CSRCS += up_memfault.c up_modifyreg8.c up_modifyreg16.c up_modifyreg32.c
CMN_CSRCS += up_releasepending.c up_releasestack.c up_reprioritizertr.c
CMN_CSRCS += up_schedulesigaction.c up_sigdeliver.c up_stackframe.c
CMN_CSRCS += up_unblocktask.c up_usestack.c up_doirq.c up_hardfault.c
CMN_CSRCS += up_svcall.c up_vfork.c
# Configuration-dependent common files
ifeq ($(CONFIG_ARMV7M_LAZYFPU),y)
CMN_ASRCS += up_lazyexception.S
else
CMN_ASRCS += up_exception.S
endif
CMN_CSRCS += up_vectors.c
ifeq ($(CONFIG_ARCH_RAMVECTORS),y)
CMN_CSRCS += up_ramvec_initialize.c up_ramvec_attach.c
endif
ifeq ($(CONFIG_BUILD_PROTECTED),y)
CMN_CSRCS += up_mpu.c up_task_start.c up_pthread_start.c
ifneq ($(CONFIG_DISABLE_SIGNALS),y)
CMN_CSRCS += up_signal_dispatch.c
CMN_UASRCS += up_signal_handler.S
endif
endif
ifeq ($(CONFIG_ARCH_FPU),y)
CMN_ASRCS += up_fpu.S
CMN_CSRCS += up_copyarmstate.c
endif
ifeq ($(CONFIG_STACK_COLORATION),y)
CMN_CSRCS += up_checkstack.c
endif
# Required SAMD5x/E5x files
CHIP_ASRCS =
# REVISIT: sam_clockconfig.c and sam_eic.c
#CHIP_CSRCS = sam_clockconfig.c sam_cmcc.c sam_gclk.c sam_irq.c
CHIP_CSRCS = sam_cmcc.c sam_gclk.c sam_irq.c
CHIP_CSRCS += sam_lowputc.c sam_port.c sam_serial.c sam_start.c
CHIP_CSRCS += sam_supc.c sam_usart.c
# Configuration-dependent SAMD5x/E5x files
ifneq ($(CONFIG_SCHED_TICKLESS),y)
CHIP_CSRCS += sam_timerisr.c
endif
ifeq ($(CONFIG_SAMD5E5_TC),y)
CHIP_CSRCS += sam_tc.c
ifeq ($(CONFIG_SAMD5E5_ONESHOT),y)
CHIP_CSRCS += sam_oneshot.c sam_oneshot_lowerhalf.c
endif # CONFIG_SAMD5E5_ONESHOT
ifeq ($(CONFIG_SAMD5E5_FREERUN),y)
CHIP_CSRCS += sam_freerun.c
endif # CONFIG_SAMD5E5_FREERUN
ifeq ($(CONFIG_SCHED_TICKLESS),y)
CHIP_CSRCS += sam_tickless.c
endif # CONFIG_SCHED_TICKLESS
endif # CONFIG_SAMD5E5_TC
ifeq ($(CONFIG_BUILD_PROTECTED),y)
CHIP_CSRCS += sam_userspace.c sam_mpuinit.c
endif
ifeq ($(CONFIG_SAMD5E5_EIC),y)
CHIP_CSRCS += sam_eic.c
endif
ifeq ($(CONFIG_SAMD5E5_CMCC),y)
CHIP_CSRCS += sam_cmcc.c
endif
ifneq ($(CONFIG_ARCH_IDLE_CUSTOM),y)
CHIP_CSRCS += sam_idle.c
endif
ifeq ($(CONFIG_SAMD5E5_WDT),y)
CHIP_CSRCS += sam_wdt.c
endif
ifeq ($(CONFIG_SAMD5E5_GMAC),y)
CHIP_CSRCS += sam_gmac.c
endif
ifeq ($(CONFIG_SAMD5E5_USB),y)
CHIP_CSRCS += sam_usb.c
endif
ifeq ($(CONFIG_SAMD5E5_SDHC0),y)
CHIP_CSRCS += sam_sdhc.c
else ifeq ($(CONFIG_SAMD5E5_SDHC1),y)
CHIP_CSRCS += sam_sdhc.c
endif
ifeq ($(CONFIG_SAMD5E5_AES),y)
CHIP_CSRCS += sam_aes.c
endif
ifeq ($(CONFIG_SAMD5E5_RTC),y)
CHIP_CSRCS += sam_rtc.c
endif

View File

@ -0,0 +1,72 @@
/************************************************************************************
* arch/arm/src/samd5e5/chip.h
*
* Copyright (C) 2014 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_SAMD5E5_CHIP_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
/* Include the chip interrupt definitions file */
#include <arch/samd5e5/irq.h>
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* Provide the required number of peripheral interrupt vector definitions as well.
* The definition SAM_IRQ_NEXTINT simply comes from the chip-specific IRQ header
* file included by arch/sam34/irq.h.
*/
#define ARMV7M_PERIPHERAL_INTERRUPTS SAM_IRQ_NEXTINT
/************************************************************************************
* Public Types
************************************************************************************/
/************************************************************************************
* Public Data
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_H */

View File

@ -0,0 +1,211 @@
/********************************************************************************************
* arch/arm/src/samd5e5/chip/sam_aes.h
*
* Copyright (C) 2018 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_SAMD5E5_CHIP_SAM_AES_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_AES_H
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
#include "chip/sam_memorymap.h"
/********************************************************************************************
* Pre-processor Definitions
********************************************************************************************/
/* AES register offsets ********************************************************************/
#define SAM_AES_CTRLA_OFFSET 0x0000 /* Control A Register */
#define SAM_AES_CTRLB_OFFSET 0x0004 /* Control B Register */
#define SAM_AES_INTENCLR_OFFSET 0x0005 /* Interrupt Enable Clear Register */
#define SAM_AES_INTENSET_OFFSET 0x0006 /* Interrupt Enable Set Register */
#define SAM_AES_INTENFLAG_OFFSET 0x0007 /* Interrupt Flag Status and Clear Register */
#define SAM_AES_DATABUFPTR_OFFSET 0x0008 /* Data Buffer Pointer Register */
#define SAM_AES_DBGCTRL_OFFSET 0x0009 /* Debug Register */
#define SAM_AES_KEYWORD_OFFSET(n) (0x000c + ((n) << 2))
# define SAM_AES_KEYWORD0_OFFSET 0x000c /* Keyword 0 Register */
# define SAM_AES_KEYWORD1_OFFSET 0x0010 /* Keyword 1 Register */
# define SAM_AES_KEYWORD2_OFFSET 0x0014 /* Keyword 2 Register */
# define SAM_AES_KEYWORD3_OFFSET 0x0018 /* Keyword 3 Register */
# define SAM_AES_KEYWORD4_OFFSET 0x001c /* Keyword 4 Register */
# define SAM_AES_KEYWORD5_OFFSET 0x0020 /* Keyword 5 Register */
# define SAM_AES_KEYWORD6_OFFSET 0x0024 /* Keyword 6 Register */
# define SAM_AES_KEYWORD7_OFFSET 0x0028 /* Keyword 7 Register */
#define SAM_AES_DATA_OFFSET 0x0038 /* Data Register */
#define SAM_AES_INTVECT_OFFSET(n) (0x003c + ((n) << 2))
# define SAM_AES_INTVECT0_OFFSET 0x003c /* Initialization Vector 0 Register */
# define SAM_AES_INTVECT1_OFFSET 0x0040 /* Initialization Vector 1 Register */
# define SAM_AES_INTVECT2_OFFSET 0x0044 /* Initialization Vector 2 Register */
# define SAM_AES_INTVECT3_OFFSET 0x0048 /* Initialization Vector 3 Register */
#define SAM_AES_HASHKEY_OFFSET(n) (0x005c + ((n) << 2))
# define SAM_AES_HASHKEY0_OFFSET 0x005c /* Hash Key 0 Register */
# define SAM_AES_HASHKEY1_OFFSET 0x0060 /* Hash Key 1 Register */
# define SAM_AES_HASHKEY2_OFFSET 0x0064 /* Hash Key 2 Register */
# define SAM_AES_HASHKEY3_OFFSET 0x0068 /* Hash Key 3 Register */
#define SAM_AES_GHASH_OFFSET(n) (0x006c + ((n) << 2))
# define SAM_AES_GHASH0_OFFSET 0x006c /* Galois Hash 0 Register */
# define SAM_AES_GHASH1_OFFSET 0x0070 /* Galois Hash 1 Register */
# define SAM_AES_GHASH2_OFFSET 0x0074 /* Galois Hash 2 Register */
# define SAM_AES_GHASH3_OFFSET 0x0078 /* Galois Hash 3 Register */
#define SAM_AES_CIPLEN_OFFSET 0x0080 /* Cipher Length Register */
#define SAM_AES_RANDSEED_OFFSET 0x0084 /* Random Seed Register */
/* AES register addresses ******************************************************************/
#define SAM_AES_CTRLA (SAM_AES_BASE+SAM_AES_CTRLA_OFFSET)
#define SAM_AES_CTRLB (SAM_AES_BASE+SAM_AES_CTRLB_OFFSET)
#define SAM_AES_INTENCLR (SAM_AES_BASE+SAM_AES_INTENCLR_OFFSET)
#define SAM_AES_INTENSET (SAM_AES_BASE+SAM_AES_INTENSET_OFFSET)
#define SAM_AES_INTENFLAG (SAM_AES_BASE+SAM_AES_INTENFLAG_OFFSET)
#define SAM_AES_DATABUFPTR (SAM_AES_BASE+SAM_AES_DATABUFPTR_OFFSET)
#define SAM_AES_DBGCTRL (SAM_AES_BASE+SAM_AES_DBGCTRL_OFFSET)
#define SAM_AES_KEYWORD(n) (SAM_AES_BASE+SAM_AES_KEYWORD_OFFSET(n))
# define SAM_AES_KEYWORD0 (SAM_AES_BASE+SAM_AES_KEYWORD0_OFFSET)
# define SAM_AES_KEYWORD1 (SAM_AES_BASE+SAM_AES_KEYWORD1_OFFSET)
# define SAM_AES_KEYWORD2 (SAM_AES_BASE+SAM_AES_KEYWORD2_OFFSET)
# define SAM_AES_KEYWORD3 (SAM_AES_BASE+SAM_AES_KEYWORD3_OFFSET)
# define SAM_AES_KEYWORD4 (SAM_AES_BASE+SAM_AES_KEYWORD4_OFFSET)
# define SAM_AES_KEYWORD5 (SAM_AES_BASE+SAM_AES_KEYWORD5_OFFSET)
# define SAM_AES_KEYWORD6 (SAM_AES_BASE+SAM_AES_KEYWORD6_OFFSET)
# define SAM_AES_KEYWORD7 (SAM_AES_BASE+SAM_AES_KEYWORD7_OFFSET)
#define SAM_AES_DATA (SAM_AES_BASE+SAM_AES_DATA_OFFSET)
#define SAM_AES_INTVECT(n) (SAM_AES_BASE+SAM_AES_INTVECT_OFFSET(n))
# define SAM_AES_INTVECT0 (SAM_AES_BASE+SAM_AES_INTVECT0_OFFSET)
# define SAM_AES_INTVECT1 (SAM_AES_BASE+SAM_AES_INTVECT1_OFFSET)
# define SAM_AES_INTVECT2 (SAM_AES_BASE+SAM_AES_INTVECT2_OFFSET)
# define SAM_AES_INTVECT3 (SAM_AES_BASE+SAM_AES_INTVECT3_OFFSET)
#define SAM_AES_HASHKEY(n) (SAM_AES_BASE+SAM_AES_HASHKEY_OFFSET(n))
# define SAM_AES_HASHKEY0 (SAM_AES_BASE+SAM_AES_HASHKEY0_OFFSET)
# define SAM_AES_HASHKEY1 (SAM_AES_BASE+SAM_AES_HASHKEY1_OFFSET)
# define SAM_AES_HASHKEY2 (SAM_AES_BASE+SAM_AES_HASHKEY2_OFFSET)
# define SAM_AES_HASHKEY3 (SAM_AES_BASE+SAM_AES_HASHKEY3_OFFSET)
#define SAM_AES_GHASH(n) (SAM_AES_BASE+SAM_AES_GHASH_OFFSET(n))
# define SAM_AES_GHASH0 (SAM_AES_BASE+SAM_AES_GHASH0_OFFSET)
# define SAM_AES_GHASH1 (SAM_AES_BASE+SAM_AES_GHASH1_OFFSET)
# define SAM_AES_GHASH2 (SAM_AES_BASE+SAM_AES_GHASH2_OFFSET)
# define SAM_AES_GHASH3 (SAM_AES_BASE+SAM_AES_GHASH3_OFFSET)
#define SAM_AES_CIPLEN (SAM_AES_BASE+SAM_AES_CIPLEN_OFFSET)
#define SAM_AES_RANDSEED (SAM_AES_BASE+SAM_AES_RANDSEED_OFFSET)
/* AES register bit definitions ************************************************************/
/* Control A Register */
#define AES_CTRLA_SWRST (1 << 0) /* Bit 0: Software reset */
#define AES_CTRLA_ENABLE (1 << 1) /* Bit 1: Enable */
#define AES_CTRLA_AESMODE_SHIFT (2) /* Bits 2-4: AES mode of operation */
#define AES_CTRLA_AESMODE_MASK (7 << AES_CTRLA_AESMODE_SHIFT)
# define AES_CTRLA_AESMODE_ECB (0 << AES_CTRLA_AESMODE_SHIFT) /* Electronic code book mode */
# define AES_CTRLA_AESMODE_CBC (1 << AES_CTRLA_AESMODE_SHIFT) /* Cipher block chaining mode */
# define AES_CTRLA_AESMODE_OFB (2 << AES_CTRLA_AESMODE_SHIFT) /* Output feedback mode */
# define AES_CTRLA_AESMODE_CFB (3 << AES_CTRLA_AESMODE_SHIFT) /* Cipher feedback mode */
# define AES_CTRLA_AESMODE_CNTR (4 << AES_CTRLA_AESMODE_SHIFT) /* Counter mode */
# define AES_CTRLA_AESMODE_CCM (5 << AES_CTRLA_AESMODE_SHIFT) /* CCM mode */
# define AES_CTRLA_AESMODE_GCM (6 << AES_CTRLA_AESMODE_SHIFT) /* Galois counter mode */
#define AES_CTRLA_CFBS_SHIFT (5) /* Bits 5-7: Cipher feedback block size */
#define AES_CTRLA_CFBS_MASK (7 << AES_CTRLA_CFBS_SHIFT)
# define AES_CTRLA_CFBS_128 (0 << AES_CTRLA_CFBS_SHIFT) /* 128-bit data block */
# define AES_CTRLA_CFBS_64 (1 << AES_CTRLA_CFBS_SHIFT) /* 64-bit data block */
# define AES_CTRLA_CFBS_32 (2 << AES_CTRLA_CFBS_SHIFT) /* 32-bit data block */
# define AES_CTRLA_CFBS_16 (3 << AES_CTRLA_CFBS_SHIFT) /* 16-bit data block */
# define AES_CTRLA_CFBS_8 (4 << AES_CTRLA_CFBS_SHIFT) /* 8-bit data block */
#define AES_CTRLA_KEYSIZE_SHIFT (8) /* Bits 8-9: Encryption key size */
#define AES_CTRLA_KEYSIZE_MASK (3 << AES_CTRLA_KEYSIZE_SHIFT)
# define AES_CTRLA_KEYSIZE_128 (0 << AES_CTRLA_KEYSIZE_SHIFT) /* 128-bit key */
# define AES_CTRLA_KEYSIZE_192 (1 << AES_CTRLA_KEYSIZE_SHIFT) /* 192-bit key */
# define AES_CTRLA_KEYSIZE_256 (2 << AES_CTRLA_KEYSIZE_SHIFT) /* 256-bit key */
#define AES_CTRLA_CIPHER (1 << 10) /* Bit 10: Cipher */
#define AES_CTRLA_STARTMODE (1 << 11) /* Bit 11: Start mode select */
#define AES_CTRLA_LOD (1 << 12) /* Bit 12: Last output data mode */
#define AES_CTRLA_KEYGEN (1 << 13) /* Bit 13: Key generation */
#define AES_CTRLA_XORKEY (1 << 14) /* Bit 14: XOR key */
#define AES_CTRLA_CTYPE_SHIFT (16) /* Bits 16-19: Countermeasure type */
#define AES_CTRLA_CTYPE_MASK (15 << AES_CTRLA_CTYPE_SHIFT)
# define AES_CTRLA_CTYPE1_DISAB (0 << AES_CTRLA_CTYPE_SHIFT) /* Countermeasure 1 disabled */
# define AES_CTRLA_CTYPE1_ENAB (1 << AES_CTRLA_CTYPE_SHIFT) /* Countermeasure 1 enabled */
# define AES_CTRLA_CTYPE2_DISAB (0 << AES_CTRLA_CTYPE_SHIFT) /* Countermeasure 2 disabled */
# define AES_CTRLA_CTYPE2_ENAB (2 << AES_CTRLA_CTYPE_SHIFT) /* Countermeasure 2 enabled */
# define AES_CTRLA_CTYPE3_DISAB (0 << AES_CTRLA_CTYPE_SHIFT) /* Countermeasure 3 disabled */
# define AES_CTRLA_CTYPE3_ENAB (4 << AES_CTRLA_CTYPE_SHIFT) /* Countermeasure 3 enabled */
# define AES_CTRLA_CTYPE4_DISAB (0 << AES_CTRLA_CTYPE_SHIFT) /* Countermeasure 4 disabled */
# define AES_CTRLA_CTYPE4_ENAB (8 << AES_CTRLA_CTYPE_SHIFT) /* Countermeasure 4 enabled */
/* Control B Register */
#define AES_CTRLB_START (1 << 0) /* Bit 0: Start encryption/decryption */
#define AES_CTRLB_NEWMSG (1 << 1) /* Bit 1: New message */
#define AES_CTRLB_EOM (1 << 2) /* Bit 2: End of message */
#define AES_CTRLB_GFMUL (1 << 3) /* Bit 3: GF multiplication */
/* Common Bit Definitions for the Interrupt Enable Clear Register, Interrupt Enable Set
* Register, and Interrupt Flag Status and Clear Register
*/
#define AES_INT_ENCCMP (1 << 0) /* Bit 0: Encryption complete interrupt */
#define AES_INT_GFMCMP (1 << 1) /* Bit 1: GF multiplication complete interrupt */
#define AES_INT_ALL 0x03
/* Data Buffer Pointer Register */
#define AES_DATABUFPTR_MASK 0x03 /* Bits 0-1: Data pointer */
/* Debug Register */
#define AES_DBGCTRL_DBGRUN (1 << 0) /* Bit 0: Debug run */
/* Keyword n Register, n = 0-7 (32-value) */
/* Data Register (32-bit value) */
/* Initialization Vector n Register, n=0-3 (32-bit value) */
/* Hash Key n Register, n=0-3 (32-bit value) */
/* Galois Hash n Register, n=0-3 (32-bit value) */
/* Cipher Length Register (32-bit value) */
/* Random Seed Register (32-bit value) */
/********************************************************************************************
* Public Types
********************************************************************************************/
/********************************************************************************************
* Public Data
********************************************************************************************/
/********************************************************************************************
* Public Functions
********************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_AES_H */

View File

@ -0,0 +1,196 @@
/****************************************************************************************
* arch/arm/src/samd5e5/chip/sam_cmcc.h
* Cortex M Cache Controller (CMCC) for the SAMD5/E5
*
* Copyright (C) 2018 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_SAMD5E5_CHIP_SAM_CMCC_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_CMCC_H
/****************************************************************************************
* Included Files
****************************************************************************************/
#include <nuttx/config.h>
#include "chip/sam_memorymap.h"
/****************************************************************************************
* Pre-processor Definitions
****************************************************************************************/
/* This information is available in the Cache Type Register. How every, it is more
* efficient if we do not to do the decoding on each cache access.
*
* CacheSize = CacheLineSize * NCacheLines * NWays
* CacheAddressRange = CacheLineSize * NCacheLines = CacheSize / NWays
*/
#define CMCC_CACHE_SIZE 4096 /* 4Kb L1 data/instruction cache */
#define CMCC_CACHE_LINE_SIZE 16 /* 16 byte cache line size */
#define CMCC_NWAYS 4 /* 4 ways */
/* CMCC register offsets ****************************************************************/
#define SAM_CMCC_TYPE_OFFSET 0x0000 /* Cache Type Register */
#define SAM_CMCC_CFG_OFFSET 0x0004 /* Cache Configuration Register */
#define SAM_CMCC_CTRL_OFFSET 0x0008 /* Cache Control Register */
#define SAM_CMCC_SR_OFFSET 0x000c /* Cache Status Register */
#define SAM_CMCC_LCKWAY_OFFSET 0x0010 /* Cache Lock per Way */
/* 0x0014-0x001c Reserved */
#define SAM_CMCC_MAINT0_OFFSET 0x0020 /* Cache Maintenance Register 0 */
#define SAM_CMCC_MAINT1_OFFSET 0x0024 /* Cache Maintenance Register 1 */
#define SAM_CMCC_MCFG_OFFSET 0x0028 /* Cache Monitor Configuration Register */
#define SAM_CMCC_MEN_OFFSET 0x002c /* Cache Monitor Enable Register */
#define SAM_CMCC_MCTRL_OFFSET 0x0030 /* Cache Monitor Control Register */
#define SAM_CMCC_MSR_OFFSET 0x0034 /* Cache Monitor Status Register */
/* 0x0038-0x00fc Reserved */
/* CMCC register addresses **************************************************************/
#define SAM_CMCC_TYPE (SAM_CMCC_BASE + SAM_CMCC_TYPE_OFFSET)
#define SAM_CMCC_CFG (SAM_CMCC_BASE + SAM_CMCC_CFG_OFFSET)
#define SAM_CMCC_CTRL (SAM_CMCC_BASE + SAM_CMCC_CTRL_OFFSET)
#define SAM_CMCC_SR (SAM_CMCC_BASE + SAM_CMCC_SR_OFFSET)
#define SAM_CMCC_MAINT0 (SAM_CMCC_BASE + SAM_CMCC_MAINT0_OFFSET)
#define SAM_CMCC_MAINT1 (SAM_CMCC_BASE + SAM_CMCC_MAINT1_OFFSET)
#define SAM_CMCC_MCFG (SAM_CMCC_BASE + SAM_CMCC_MCFG_OFFSET)
#define SAM_CMCC_MEN (SAM_CMCC_BASE + SAM_CMCC_MEN_OFFSET)
#define SAM_CMCC_MCTRL (SAM_CMCC_BASE + SAM_CMCC_MCTRL_OFFSET)
#define SAM_CMCC_MSR (SAM_CMCC_BASE + SAM_CMCC_MSR_OFFSET)
/* CMCC register bit definitions ********************************************************/
/* Cache Type Register */
#define CMCC_TYPE_AP (1 << 0) /* Bit 0: Access Port Access Allowed */
#define CMCC_TYPE_GCLK (1 << 1) /* Bit 1: Dynamic Clock Gating Supported */
#define CMCC_TYPE_RANDP (1 << 2) /* Bit 2: Random Selection Policy Supported */
#define CMCC_TYPE_LRUP (1 << 3) /* Bit 3: Least Recently Used Policy Supported */
#define CMCC_TYPE_RRP (1 << 4) /* Bit 4: Random Selection Policy Supported */
#define CMCC_TYPE_WAYNUM_SHIFT (5) /* Bits 5-6: Number of Way */
#define CMCC_TYPE_WAYNUM_MASK (3 << CMCC_TYPE_WAYNUM_SHIFT)
# define CMCC_TYPE_WAYNUM_DMAPPED (0 << CMCC_TYPE_WAYNUM_SHIFT) /* Direct Mapped Cache */
# define CMCC_TYPE_WAYNUM_ARCH2WAY (1 << CMCC_TYPE_WAYNUM_SHIFT) /* 2-WAY set associative */
# define CMCC_TYPE_WAYNUM_ARCH4WAY (2 << CMCC_TYPE_WAYNUM_SHIFT) /* 4-WAY set associative */
# define CMCC_TYPE_WAYNUM_ARCH8WAY (3 << CMCC_TYPE_WAYNUM_SHIFT) /* 8-WAY set associative */
#define CMCC_TYPE_LCKDOWN (1 << 7) /* Bit 7: Lock Down Supported */
#define CMCC_TYPE_CSIZE_SHIFT (8) /* Bits 8-10: Cache Size */
#define CMCC_TYPE_CSIZE_MASK (7 << CMCC_TYPE_CSIZE_SHIFT)
# define CMCC_TYPE_CSIZE_1KB (0 << CMCC_TYPE_CSIZE_SHIFT) /* Cache Size 1 Kbytes */
# define CMCC_TYPE_CSIZE_2KB (1 << CMCC_TYPE_CSIZE_SHIFT) /* Cache Size 2 Kbytes */
# define CMCC_TYPE_CSIZE_4KB (2 << CMCC_TYPE_CSIZE_SHIFT) /* Cache Size 4 Kbytes */
# define CMCC_TYPE_CSIZE_8KB (3 << CMCC_TYPE_CSIZE_SHIFT) /* Cache Size 8 Kbytes */
#define CMCC_TYPE_CLSIZE_SHIFT (11) /* Bits 11-13: Cache Line Size */
#define CMCC_TYPE_CLSIZE_MASK (7 << CMCC_TYPE_CLSIZE_SHIFT)
# define CMCC_TYPE_CLSIZE_4B (0 << CMCC_TYPE_CLSIZE_SHIFT) /* 4 Bytes */
# define CMCC_TYPE_CLSIZE_8B (1 << CMCC_TYPE_CLSIZE_SHIFT) /* 8 Bytes */
# define CMCC_TYPE_CLSIZE_16B (2 << CMCC_TYPE_CLSIZE_SHIFT) /* 16 Bytes */
# define CMCC_TYPE_CLSIZE_32B (3 << CMCC_TYPE_CLSIZE_SHIFT) /* 32 Bytes */
/* Cache Configuration Register */
#define CMCC_CFG_GCLKDIS (1 << 0) /* Bit 0: Disable Clock Gating */
#define CMCC_CFG_ICDIS (1 << 1) /* Bit 1: Instruction Cache Disable */
#define CMCC_CFG_DCDIS (1 << 2) /* Bit 2: Data Cache Disable */
#define CMCC_CFG_CSIZEW_SHIFT (8) /* Bits 4-6: Cache Size Configured by Software */
#define CMCC_CFG_CSIZEW_MASK (7 << CMCC_CFG_CSIZEW_SHIFT)
# define CMCC_CFG_CSIZEW_1KB (0 << CMCC_CFG_CSIZEW_SHIFT) /* Cache Size configured to 1KB */
# define CMCC_CFG_CSIZEW_2KB (1 << CMCC_CFG_CSIZEW_SHIFT) /* Cache Size configured to 2KB */
# define CMCC_CFG_CSIZEW_4KB (2 << CMCC_CFG_CSIZEW_SHIFT) /* Cache Size configured to 4KB */
# define CMCC_CFG_CSIZEW_8KB (3 << CMCC_CFG_CSIZEW_SHIFT) /* Cache Size configured to 8KB */
# define CMCC_CFG_CSIZEW_16KB (4 << CMCC_CFG_CSIZEW_SHIFT) /* Cache Size configured to 16KB */
# define CMCC_CFG_CSIZEW_32KB (5 << CMCC_CFG_CSIZEW_SHIFT) /* Cache Size configured to 32KB */
# define CMCC_CFG_CSIZEW_64KB (6 << CMCC_CFG_CSIZEW_SHIFT) /* Cache Size configured to 64KB */
/* Cache Control Register */
#define CMCC_CTRL_CEN (1 << 0) /* Bit 0: Cache Controller Enable */
/* Cache Status Register */
#define CMCC_SR_CSTS (1 << 0) /* Bit 0: Cache Controller Status */
/* Cache Lock per Way */
#define CMCC_LCKWAY_SHIFT (0) /* Bits 0-3: Lockdown Way Register */
#define CMCC_LCKWAY_MASK (7 << CMCC_LCKWAY_SHIFT)
#define CMCC_LCKWAY(n) ((uint32_t)(n) << CMCC_LCKWAY_SHIFT)
/* Cache Maintenance Register 0 */
#define CMCC_MAINT0_INVALL (1 << 0) /* Bit 0: Cache Controller Invalidate All */
/* Cache Maintenance Register 1 */
#define CMCC_MAINT1_INDEX_SHIFT (4) /* Bits 4-11: Invalidate Index */
#define CMCC_MAINT1_INDEX_MASK (0xff << CMCC_MAINT1_INDEX_SHIFT)
# define CMCC_MAINT1_INDEX(n) ((uint32_t)(n) << CMCC_MAINT1_INDEX_SHIFT)
#define CMCC_MAINT1_WAY_SHIFT (28) /* Bits 28-31: Invalidate Way */
#define CMCC_MAINT1_WAY_MASK (15 << CMCC_MAINT1_WAY_SHIFT)
# define CMCC_MAINT1_WAY(n) ((uint32_t)(n) << CMCC_MAINT1_WAY_SHIFT)
# define CMCC_MAINT1_WAY0 (0 << CMCC_MAINT1_WAY_SHIFT) /* Way 0 selected */
# define CMCC_MAINT1_WAY1 (1 << CMCC_MAINT1_WAY_SHIFT) /* Way 1 selected */
# define CMCC_MAINT1_WAY2 (2 << CMCC_MAINT1_WAY_SHIFT) /* Way 2 selected */
# define CMCC_MAINT1_WAY3 (3 << CMCC_MAINT1_WAY_SHIFT) /* Way 3 selected */
/* Cache Monitor Configuration Register */
#define CMCC_MCFG_MODE_SHIFT (0) /* Bits 0-1: Cache Controller Monitor Counter Mode */
#define CMCC_MCFG_MODE_MASK (3 << CMCC_MCFG_MODE_SHIFT)
# define CMCC_MCFG_MODE_CYCLECOUNT (0 << CMCC_MCFG_MODE_SHIFT) /* Cycle counter */
# define CMCC_MCFG_MODE_IHITCOUNT (1 << CMCC_MCFG_MODE_SHIFT) /* Instruction hit counter */
# define CMCC_MCFG_MODE_DHITCOUNT (2 << CMCC_MCFG_MODE_SHIFT) /* Data hit counter */
/* Cache Monitor Enable Register */
#define CMCC_MEN_MENABLE (1 << 0) /* Bit 0: Cache Controller Monitor Enable */
/* Cache Monitor Control Register */
#define CMCC_MCTRL_SWRST (1 << 0) /* Bit 0: Monitor */
/* Cache Monitor Status Register -- 32-bit event count */
/****************************************************************************************
* Public Types
****************************************************************************************/
/****************************************************************************************
* Public Data
****************************************************************************************/
/****************************************************************************************
* Public Functions
****************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_CMCC_H */

View File

@ -0,0 +1,255 @@
/********************************************************************************************
* arch/arm/src/samd5e5/chip/sam_eic.h
*
* Copyright (C) 2018 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_SAMD5E5_CHIP_SAM_EIC_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_EIC_H
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
#include "chip/sam_memorymap.h"
/********************************************************************************************
* Pre-processor Definitions
********************************************************************************************/
/* EIC register offsets *********************************************************************/
#define SAM_EIC_CTRLA_OFFSET 0x0000 /* Control A register */
#define SAM_EIC_NMITRCL_OFFSET 0x0001 /* Non-maskable interrupt control register */
#define SAM_EIC_NMIFLAG_OFFSET 0x0002 /* Non-maskable interrupt flasg status and clear register */
#define SAM_EIC_SYNCBUSY_OFFSET 0x0004 /* Synchronization busy register */
#define SAM_EIC_EVCTRL_OFFSET 0x0008 /* Event control register */
#define SAM_EIC_INTENCLR_OFFSET 0x000c /* Interrupt enable clear register */
#define SAM_EIC_INTENSET_OFFSET 0x0010 /* Interrupt enable set register */
#define SAM_EIC_INTFLAG_OFFSET 0x0014 /* Interrupt flag and status clear register */
#define SAM_EIC_ASYNCH_OFFSET 0x0018 /* External interrupt asynchronous mode register */
#define SAM_EIC_CONFIG0_OFFSET 0x001c /* Configuration 0 register */
#define SAM_EIC_CONFIG1_OFFSET 0x0020 /* Configuration 1 register */
#define SAM_EIC_DEBOUNCEN_OFFSET 0x0030 /* Debouncer enable */
#define SAM_EIC_DPRESCALER_OFFSET 0x0034 /* Debouncer prescaler */
#define SAM_EIC_PINSTATE_OFFSET 0x0038 /* Pin state */
/* EIC register addresses *******************************************************************/
#define SAM_EIC_CTRLA (SAM_EIC_BASE + SAM_EIC_CTRLA_OFFSET)
#define SAM_EIC_NMITRCL (SAM_EIC_BASE + SAM_EIC_NMITRCL_OFFSET)
#define SAM_EIC_NMIFLAG (SAM_EIC_BASE + SAM_EIC_NMIFLAG_OFFSET)
#define SAM_EIC_SYNCBUSY (SAM_EIC_BASE + SAM_EIC_SYNCBUSY_OFFSET)
#define SAM_EIC_EVCTRL (SAM_EIC_BASE + SAM_EIC_EVCTRL_OFFSET)
#define SAM_EIC_INTENCLR (SAM_EIC_BASE + SAM_EIC_INTENCLR_OFFSET)
#define SAM_EIC_INTENSET (SAM_EIC_BASE + SAM_EIC_INTENSET_OFFSET)
#define SAM_EIC_INTFLAG (SAM_EIC_BASE + SAM_EIC_INTFLAG_OFFSET)
#define SAM_EIC_ASYNCH (SAM_EIC_BASE + SAM_EIC_ASYNCH_OFFSET)
#define SAM_EIC_CONFIG0 (SAM_EIC_BASE + SAM_EIC_CONFIG0_OFFSET)
#define SAM_EIC_CONFIG1 (SAM_EIC_BASE + SAM_EIC_CONFIG1_OFFSET)
#define SAM_EIC_DEBOUNCEN (SAM_EIC_BASE + SAM_EIC_DEBOUNCEN_OFFSET)
#define SAM_EIC_DPRESCALER (SAM_EIC_BASE + SAM_EIC_DPRESCALER_OFFSET)
#define SAM_EIC_PINSTATE (SAM_EIC_BASE + SAM_EIC_PINSTATE_OFFSET)
/* EIC register bit definitions *************************************************************/
/* Control A register */
#define EIC_CTRLA_SWRST (1 << 0) /* Bit 0: Software reset */
#define EIC_CTRLA_ENABLE (1 << 1) /* Bit 1: Enable */
#define EIC_CTRLA_CKSEL (1 << 4) /* Bit 4: Clock selection */
# define EIC_CTRLA_CKSEL_GCLK_EIC (0) /* 0=EIC clocked by GCLK_EIC */
# define EIC_CTRLA_CKSEL_CLK_ULP32K EIC_CTRLA_CKSEL /* 1=EIC clocked by CLK_ULP32K */
/* Non-maskable interrupt control register */
#define EIC_NMITRCL_NMISENSE_SHIFT (0) /* Bits 0-2: Non-maskable interrupt sense */
#define EIC_NMITRCL_NMISENSE_MASK (7 << EIC_NMITRCL_NMISENSE_SHIFT)
# define EIC_NMITRCL_NMISENSE_NONE (0 << EIC_NMITRCL_NMISENSE_SHIFT) /* No detection */
# define EIC_NMITRCL_NMISENSE_RISE (1 << EIC_NMITRCL_NMISENSE_SHIFT) /* Rising edge detection */
# define EIC_NMITRCL_NMISENSE_FALL (2 << EIC_NMITRCL_NMISENSE_SHIFT) /* Falling edge detection */
# define EIC_NMITRCL_NMISENSE_BOTH (3 << EIC_NMITRCL_NMISENSE_SHIFT) /* Both edge detection */
# define EIC_NMITRCL_NMISENSE_HIGH (4 << EIC_NMITRCL_NMISENSE_SHIFT) /* High level detection */
# define EIC_NMITRCL_NMISENSE_LOW (5 << EIC_NMITRCL_NMISENSE_SHIFT) /* Low level detection */
#define EIC_NMITRCL_NMIFLTEN (1 << 3) /* Bit 3: Non-maskable interrupt filter enable */
#define EIC_NMITRCL_ASYNC (1 << 4) /* Bit 4: Asynchronous edge detection mode */
/* Non-maskable interrupt flas status and clear register */
#define EIC_NMIFLAG_NMI (1 << 0) /* Non-maskable interrupt */
/* Synchronization busy register */
#define EIC_SYNCBUSY_SWRST (1 << 0) /* Bit 0: Software reset syncrhonization busy */
#define EIC_SYNCBUSY_ENABLE (1 << 1) /* Bit 1: Enable synchronization busy */
/* Event control, Interrupt enable clear, interrupt enable set register, interrupt flag
* status and clear, and External interrupt asynchronous mode registers.
*/
#define EIC_EXTINT_SHIFT (0) /* Bits 0-15: External interrupt n */
#define EIC_EXTINT_MASK (0xffff << EIC_EXTINT_SHIFT)
# define EIC_EXTINT(n) (1 << (n))
# define EIC_EXTINT_0 (1 << 0) /* Bit 0: External interrupt 0 */
# define EIC_EXTINT_1 (1 << 1) /* Bit 1: External interrupt 1 */
# define EIC_EXTINT_2 (1 << 2) /* Bit 2: External interrupt 2 */
# define EIC_EXTINT_3 (1 << 3) /* Bit 3: External interrupt 3 */
# define EIC_EXTINT_4 (1 << 4) /* Bit 4: External interrupt 4 */
# define EIC_EXTINT_5 (1 << 5) /* Bit 5: External interrupt 5 */
# define EIC_EXTINT_6 (1 << 6) /* Bit 6: External interrupt 6 */
# define EIC_EXTINT_7 (1 << 7) /* Bit 7: External interrupt 7 */
# define EIC_EXTINT_8 (1 << 8) /* Bit 8: External interrupt 8 */
# define EIC_EXTINT_9 (1 << 9) /* Bit 9: External interrupt 9 */
# define EIC_EXTINT_10 (1 << 10) /* Bit 10: External interrupt 10 */
# define EIC_EXTINT_11 (1 << 11) /* Bit 11: External interrupt 11 */
# define EIC_EXTINT_12 (1 << 12) /* Bit 12: External interrupt 12 */
# define EIC_EXTINT_13 (1 << 13) /* Bit 13: External interrupt 13 */
# define EIC_EXTINT_14 (1 << 14) /* Bit 14: External interrupt 14 */
# define EIC_EXTINT_15 (1 << 15) /* Bit 15: External interrupt 15 */
#define EIC_EXTINT_ALL EIC_EXTINT_MASK
/* Configuration 0 register */
#define EIC_CONFIG0_FILTEN(n) (3 + ((n) << 2)) /* Filter n enable, n=0-7 */
#define EIC_CONFIG0_SENSE_SHIFT(n) ((n) << 2) /* Filter n input sense, n=0-7 */
#define EIC_CONFIG0_SENSE_MASK(n) (7 << EIC_CONFIG0_SENSE_SHIFT(n))
# define EIC_CONFIG0_SENSE_NONE (0 << EIC_CONFIG0_SENSE_SHIFT(n)) /* No detection */
# define EIC_CONFIG0_SENSE_RISE (1 << EIC_CONFIG0_SENSE_SHIFT(n)) /* Rising edge detection */
# define EIC_CONFIG0_SENSE_FALL (2 << EIC_CONFIG0_SENSE_SHIFT(n)) /* Falling edge detection */
# define EIC_CONFIG0_SENSE_BOTH (3 << EIC_CONFIG0_SENSE_SHIFT(n)) /* Both edge detection */
# define EIC_CONFIG0_SENSE_HIGH (4 << EIC_CONFIG0_SENSE_SHIFT(n)) /* High level detection */
# define EIC_CONFIG0_SENSE_LOW (5 << EIC_CONFIG0_SENSE_SHIFT(n)) /* Low level detection */
/* Configuration 1 register */
#define EIC_CONFIG1_FILTEN(n) (3 + (((n) - 8) << 2)) /* Filter n enable, n=8-15 */
#define EIC_CONFIG1_SENSE_SHIFT(n) (((n) - 8) << 2) /* Filter n input sense, n=8-17 */
#define EIC_CONFIG1_SENSE_MASK(n) (7 << EIC_CONFIG1_SENSE_SHIFT(n))
# define EIC_CONFIG1_SENSE_NONE(n) (0 << EIC_CONFIG1_SENSE_SHIFT(n)) /* No detection */
# define EIC_CONFIG1_SENSE_RISE(n) (1 << EIC_CONFIG1_SENSE_SHIFT(n)) /* Rising edge detection */
# define EIC_CONFIG1_SENSE_FALL(n) (2 << EIC_CONFIG1_SENSE_SHIFT(n)) /* Falling edge detection */
# define EIC_CONFIG1_SENSE_BOTH(n) (3 << EIC_CONFIG1_SENSE_SHIFT(n)) /* Both edge detection */
# define EIC_CONFIG1_SENSE_HIGH(n) (4 << EIC_CONFIG1_SENSE_SHIFT(n)) /* High level detection */
# define EIC_CONFIG1_SENSE_LOW(n) (5 << EIC_CONFIG1_SENSE_SHIFT(n)) /* Low level detection */
/* Debouncer enable */
#define EIC_DEBOUNCEN_SHIFT (0) /* Bits 0-15: EXTINT n Debouncer enable */
#define EIC_DEBOUNCEN_MASK (0xffff << EIC_DEBOUNCEN_SHIFT)
# define EIC_DEBOUNCEN(n) (1 << (n))
# define EIC_DEBOUNCEN_0 (1 << 0) /* Bit 0: EXTINT 0 edge input is debounced */
# define EIC_DEBOUNCEN_1 (1 << 1) /* Bit 1: EXTINT 1 edge input is debounced */
# define EIC_DEBOUNCEN_2 (1 << 2) /* Bit 2: EXTINT 2 edge input is debounced */
# define EIC_DEBOUNCEN_3 (1 << 3) /* Bit 3: EXTINT 3 edge input is debounced */
# define EIC_DEBOUNCEN_4 (1 << 4) /* Bit 4: EXTINT 4 edge input is debounced */
# define EIC_DEBOUNCEN_5 (1 << 5) /* Bit 5: EXTINT 5 edge input is debounced */
# define EIC_DEBOUNCEN_6 (1 << 6) /* Bit 6: EXTINT 6 edge input is debounced */
# define EIC_DEBOUNCEN_7 (1 << 7) /* Bit 7: EXTINT 7 edge input is debounced */
# define EIC_DEBOUNCEN_8 (1 << 8) /* Bit 8: EXTINT 8 edge input is debounced */
# define EIC_DEBOUNCEN_9 (1 << 9) /* Bit 9: EXTINT 9 edge input is debounced */
# define EIC_DEBOUNCEN_10 (1 << 10) /* Bit 10: EXTINT 10 edge input is debounced */
# define EIC_DEBOUNCEN_11 (1 << 11) /* Bit 11: EXTINT 11 edge input is debounced */
# define EIC_DEBOUNCEN_12 (1 << 12) /* Bit 12: EXTINT 12 edge input is debounced */
# define EIC_DEBOUNCEN_13 (1 << 13) /* Bit 13: EXTINT 13 edge input is debounced */
# define EIC_DEBOUNCEN_14 (1 << 14) /* Bit 14: EXTINT 14 edge input is debounced */
# define EIC_DEBOUNCEN_15 (1 << 15) /* Bit 15: EXTINT 15 edge input is debounced */
/* Debouncer prescaler */
#define EIC_DPRESCALER_PRESCALER0_SHIFT (0) /* Bitx 0-2: Debouncer Prescaler. EXTINT 0-7 */
#define EIC_DPRESCALER_PRESCALER0_MASK (7 << EIC_DPRESCALER_PRESCALER0_SHIFT)
# define EIC_DPRESCALER_PRESCALER0_DIV2 (0 << EIC_DPRESCALER_PRESCALER0_SHIFT) /* EIC clock divided by 2 */
# define EIC_DPRESCALER_PRESCALER0_DIV4 (1 << EIC_DPRESCALER_PRESCALER0_SHIFT) /* EIC clock divided by 4 */
# define EIC_DPRESCALER_PRESCALER0_DIV8 (2 << EIC_DPRESCALER_PRESCALER0_SHIFT) /* EIC clock divided by 8 */
# define EIC_DPRESCALER_PRESCALER0_DIV16 (3 << EIC_DPRESCALER_PRESCALER0_SHIFT) /* EIC clock divided by 16 */
# define EIC_DPRESCALER_PRESCALER0_DIV32 (4 << EIC_DPRESCALER_PRESCALER0_SHIFT) /* EIC clock divided by 32 */
# define EIC_DPRESCALER_PRESCALER0_DIV64 (5 << EIC_DPRESCALER_PRESCALER0_SHIFT) /* EIC clock divided by 64 */
# define EIC_DPRESCALER_PRESCALER0_DIV128 (6 << EIC_DPRESCALER_PRESCALER0_SHIFT) /* EIC clock divided by 128 */
# define EIC_DPRESCALER_PRESCALER0_DIV256 (7 << EIC_DPRESCALER_PRESCALER0_SHIFT) /* EIC clock divided by 256 */
#define EIC_DPRESCALER_STATES0 (1 << 3) /* Bit 3: Debouncer number of states. EXTINT 0-7 */
# define EIC_DPRESCALER_STATES0_3 (0) /* 3 low frequency samples */
# define EIC_DPRESCALER_STATES0_7 EIC_DPRESCALER_STATES0 /* 7 low frequency samples */
#define EIC_DPRESCALER_PRESCALER1_SHIFT (4) /* Bitx 4-6: Debouncer Prescaler. EXTINT 8-15 */
#define EIC_DPRESCALER_PRESCALER1_MASK (7 << EIC_DPRESCALER_PRESCALER1_SHIFT)
# define EIC_DPRESCALER_PRESCALER1_DIV2 (0 << EIC_DPRESCALER_PRESCALER1_SHIFT) /* EIC clock divided by 2 */
# define EIC_DPRESCALER_PRESCALER1_DIV4 (1 << EIC_DPRESCALER_PRESCALER1_SHIFT) /* EIC clock divided by 4 */
# define EIC_DPRESCALER_PRESCALER1_DIV8 (2 << EIC_DPRESCALER_PRESCALER1_SHIFT) /* EIC clock divided by 8 */
# define EIC_DPRESCALER_PRESCALER1_DIV16 (3 << EIC_DPRESCALER_PRESCALER1_SHIFT) /* EIC clock divided by 16 */
# define EIC_DPRESCALER_PRESCALER1_DIV32 (4 << EIC_DPRESCALER_PRESCALER1_SHIFT) /* EIC clock divided by 32 */
# define EIC_DPRESCALER_PRESCALER1_DIV64 (5 << EIC_DPRESCALER_PRESCALER1_SHIFT) /* EIC clock divided by 64 */
# define EIC_DPRESCALER_PRESCALER1_DIV128 (6 << EIC_DPRESCALER_PRESCALER1_SHIFT) /* EIC clock divided by 128 */
# define EIC_DPRESCALER_PRESCALER1_DIV256 (7 << EIC_DPRESCALER_PRESCALER1_SHIFT) /* EIC clock divided by 256 */
#define EIC_DPRESCALER_STATES1 (1 << 7) /* Bit 7: Debouncer number of states. EXTINT 8-15 */
# define EIC_DPRESCALER_STATES1_3 (0) /* 3 low frequency samples */
# define EIC_DPRESCALER_STATES1_7 EIC_DPRESCALER_STATES1 /* 7 low frequency samples */
#define EIC_DPRESCALER_TICKON (1 << 16) /* Bit 16: Pin Sampler frequency selection */
# define EIC_DPRESCALER_TICKON_GCLKEIC (0) /* Bounce sampler uses GCLK_EIC */
# define EIC_DPRESCALER_TICKON_LFCLK EIC_DPRESCALER_TICKON /* Bounce sampler uses low frequency clock */
/* Pin state */
#define EIC_PINSTATE_SHIFT (0) /* Bits 0-15: EXTINT n Debouncer enable */
#define EIC_PINSTATE_MASK (0xffff << EIC_PINSTATE_SHIFT)
# define EIC_PINSTATE(n) (1 << (n))
# define EIC_PINSTATE_0 (1 << 0) /* Bit 0: EXTINT 0 pin state */
# define EIC_PINSTATE_1 (1 << 1) /* Bit 1: EXTINT 1 pin state */
# define EIC_PINSTATE_2 (1 << 2) /* Bit 2: EXTINT 2 pin state */
# define EIC_PINSTATE_3 (1 << 3) /* Bit 3: EXTINT 3 pin state */
# define EIC_PINSTATE_4 (1 << 4) /* Bit 4: EXTINT 4 pin state */
# define EIC_PINSTATE_5 (1 << 5) /* Bit 5: EXTINT 5 pin state */
# define EIC_PINSTATE_6 (1 << 6) /* Bit 6: EXTINT 6 pin state */
# define EIC_PINSTATE_7 (1 << 7) /* Bit 7: EXTINT 7 pin state */
# define EIC_PINSTATE_8 (1 << 8) /* Bit 8: EXTINT 8 pin state */
# define EIC_PINSTATE_9 (1 << 9) /* Bit 9: EXTINT 9 pin state */
# define EIC_PINSTATE_10 (1 << 10) /* Bit 10: EXTINT 10 pin state */
# define EIC_PINSTATE_11 (1 << 11) /* Bit 11: EXTINT 11 pin state */
# define EIC_PINSTATE_12 (1 << 12) /* Bit 12: EXTINT 12 pin state */
# define EIC_PINSTATE_13 (1 << 13) /* Bit 13: EXTINT 13 pin state */
# define EIC_PINSTATE_14 (1 << 14) /* Bit 14: EXTINT 14 pin state */
# define EIC_PINSTATE_15 (1 << 15) /* Bit 15: EXTINT 15 pin state */
/********************************************************************************************
* Public Types
********************************************************************************************/
/********************************************************************************************
* Public Data
********************************************************************************************/
/********************************************************************************************
* Public Functions
********************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_EIC_H */

View File

@ -0,0 +1,369 @@
/********************************************************************************************
* arch/arm/src/samd5e5/chip/sam_evsys.h
*
* Copyright (C) 2018 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_SAMD5E5_CHIP_SAM_EVSYS_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_EVSYS_H
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
#include "chip/sam_memorymap.h"
/********************************************************************************************
* Pre-processor Definitions
********************************************************************************************/
#define SAM_EVSYS_NCHANNELS 32 /* 0-31 */
#define SAM_EVSYS_NUSER 67 /* 0-66 */
/* EVSYS register offsets *******************************************************************/
#define SAM_EVSYS_CTRLA_OFFSET 0x0000 /* Control register */
#define SAM_EVSYS_SWEVT_OFFSET 0x0004 /* Software event register */
#define SAM_EVSYS_PRICTRL_OFFSET 0x0008 /* Software event register */
#define SAM_EVSYS_INTPEND_OFFSET 0x0010 /* Channel pending interrupt register */
#define SAM_EVSYS_INTSTATUS_OFFSET 0x0014 /* Channel pending interrupt register */
#define SAM_EVSYS_BUSYCH_OFFSET 0x0018 /* Busy channels register */
#define SAM_EVSYS_READYUSR_OFFSET 0x001c /* Busy channels register */
#define SAM_EVSYS_CHOFFSET(n) (0x0020 + ((n) << 3)) /* Channel registers */
# define SAM_EVSYS_CHANNEL_OFFSET 0x0000 /* Channel control register */
# define SAM_EVSYS_CHINTENCLR_OFFSET 0x0004 /* Channl interrupt clear register */
# define SAM_EVSYS_CHINTENSET_OFFSET 0x0005 /* Channel interrupt enable register */
# define SAM_EVSYS_CHINTFLAG_OFFSET 0x0006 /* Channel interrupt status register */
# define SAM_EVSYS_CHSTATUS_OFFSET 0x0007 /* Channel status register */
#define SAM_EVSYS_USER_OFFSET(n) (0x0120 + ((m)) /* User registers */
/* EVSYS register addresses *****************************************************************/
#define SAM_EVSYS_CTRLA (SAM_EVSYS_BASE + SAM_EVSYS_CTRLA_OFFSET)
#define SAM_EVSYS_SWEVT (SAM_EVSYS_BASE + SAM_EVSYS_SWEVT_OFFSET)
#define SAM_EVSYS_PRICTRL (SAM_EVSYS_BASE + SAM_EVSYS_PRICTRL_OFFSET)
#define SAM_EVSYS_INTPEND (SAM_EVSYS_BASE + SAM_EVSYS_INTPEND_OFFSET)
#define SAM_EVSYS_INTSTATUS (SAM_EVSYS_BASE + SAM_EVSYS_INTSTATUS_OFFSET)
#define SAM_EVSYS_BUSYCH (SAM_EVSYS_BASE + SAM_EVSYS_BUSYCH_OFFSET)
#define SAM_EVSYS_READYUSR (SAM_EVSYS_BASE + SAM_EVSYS_READYUSR_OFFSET)
#define SAM_EVSYS_CHBASEBASE(n) (SAM_EVSYS_BASE + SAM_EVSYS_CHOFFSET(n))
# define SAM_EVSYS_CHANNEL(n) (SAM_EVSYS_CHBASEBASE(n) + SAM_EVSYS_CHANNEL_OFFSET)
# define SAM_EVSYS_CHINTENCLR(n) (SAM_EVSYS_CHBASEBASE(n) + SAM_EVSYS_CHINTENCLR_OFFSET)
# define SAM_EVSYS_CHINTENSET(n) (SAM_EVSYS_CHBASEBASE(n) + SAM_EVSYS_CHINTENSET_OFFSET)
# define SAM_EVSYS_CHINTFLAG(n) (SAM_EVSYS_CHBASEBASE(n) + SAM_EVSYS_CHINTFLAG_OFFSET)
# define SAM_EVSYS_CHSTATUS(n) (SAM_EVSYS_CHBASEBASE(n) + SAM_EVSYS_CHSTATUS_OFFSET
#define SAM_EVSYS_USER(n) (SAM_EVSYS_BASE + SAM_EVSYS_USER_OFFSET(n))
/* EVSYS register bit definitions ***********************************************************/
/* Control register */
#define EVSYS_CTRLA_SWRST (1 << 0) /* Bit 0: Software reset */
/* Software event register */
#define EVSYS_SWEVT_CHAN(n) (1 << (n)) /* Bit n: Channel n software selection */
/* Software event register */
#define EVSYS_PRICTRL_PRI_SHIFT (0) /* Bist 0-4: Channel priority number */
#define EVSYS_PRICTRL_PRI_MASK (31 << EVSYS_PRICTRL_PRI_SHIFT)
# define EVSYS_PRICTRL_PRI(n) ((uint8_t)(n) << EVSYS_PRICTRL_PRI_SHIFT)
#define EVSYS_PRICTRL_RREN (1 << 7) /* Bit 7: Round-robin scheduling enable */
/* Channel pending interrupt register */
#define EVSYS_INTPEND_ID_SHIFT (0) /* Bits 0-4: Channel ID */
#define EVSYS_INTPEND_ID_MASK (31 << EVSYS_INTPEND_ID_SHIFT)
# define EVSYS_INTPEND_ID(n) ((uint16_t)(n) << EVSYS_INTPEND_ID_SHIFT)
#define EVSYS_INTPEND_OVR (1 << 8) /* Bit 8: Channel Overrun */
#define EVSYS_INTPEND_EVD (1 << 9) /* Bit 9: Channel Event Detected */
#define EVSYS_INTPEND_READY (1 << 14) /* Bit 14: Ready */
#define EVSYS_INTPEND_BUSY (1 << 15) /* Bit 15: Busy */
/* Channel pending interrupt register */
#define EVSYS_INTSTATUS_CHAN(n) (1 << (n)) /* Bit n: Channel n pending interrupt */
/* Busy channels register */
#define EVSYS_BUSYCH_CHAN(n) (1 << (n)) /* Bit n: Busy channel n */
/* Busy channels register */
#define EVSYS_READYUSR_CHAN(n) (1 << (n)) /* Bit n: Ready user for channel n */
/* Channel control register (see event generator selections below) */
#define EVSYS_CHANNEL_EVGEN_SHIFT (0) /* Bits 0-7: Event generator selection */
#define EVSYS_CHANNEL_EVGEN_MASK (0xff << EVSYS_CHANNEL_EVGEN_SHIFT)
# define EVSYS_CHANNEL_EVGEN(n) ((uint32_t)(n) << EVSYS_CHANNEL_EVGEN_SHIFT)
#define EVSYS_CHANNEL_PATH_SHIFT (8) /* Bits 8-9: Path Selection */
#define EVSYS_CHANNEL_PATH_MASK (3 << EVSYS_CHANNEL_PATH_SHIFT)
# define EVSYS_CHANNEL_PATH_SYNCH (0 << EVSYS_CHANNEL_PATH_SHIFT) /* Synchronous path */
# define EVSYS_CHANNEL_PATH_RESYNCH (1 << EVSYS_CHANNEL_PATH_SHIFT) /* Resynchronized path */
# define EVSYS_CHANNEL_PATH_ASYNCH (2 << EVSYS_CHANNEL_PATH_SHIFT) /* Asynchronous path */
#define EVSYS_CHANNEL_EDGSEL_SHIFT (10) /* Bits 10-11: Edge detection selection */
#define EVSYS_CHANNEL_EDGSEL_MASK (3 << EVSYS_CHANNEL_EDGSEL_SHIFT)
# define EVSYS_CHANNEL_EDGSEL_NONE (0 << EVSYS_CHANNEL_EDGSEL_SHIFT) /* No event output */
# define EVSYS_CHANNEL_EDGSEL_ RISING (1 << EVSYS_CHANNEL_EDGSEL_SHIFT) /* Event on rising edge */
# define EVSYS_CHANNEL_EDGSEL_FALLING (2 << EVSYS_CHANNEL_EDGSEL_SHIFT) /* Event on falling edge */
# define EVSYS_CHANNEL_EDGSEL_BOTH (3 << EVSYS_CHANNEL_EDGSEL_SHIFT) /* Event on both edges */
#define EVSYS_CHANNEL_RUNSTDBY (1 << 14) /* Bit 14: Run in standby */
#define EVSYS_CHANNEL_ONDEMAND (1 << 15) /* Bit 15: Generic clock on demand */
/* Channel interrupt clear register, Channel interrupt enable register, and Channel interrupt
* status register
*/
#define EVSYS_CHINT_OVR (1 << 0) /* Bit 0: Channel overrun */
#define EVSYS_CHINT_EVD (1 << 1) /* Bit 1: Channel event detected */
/* Channel status register */
#define EVSYS_CHSTATUS_RDYUSR (1 << 0) /* Bit 0: Ready user */
#define EVSYS_CHSTATUS_BUSYCH (1 << 1) /* Bit 1: Busy channel */
/* User registers (8-bit channel number. See user multiplexor numbers below */
/* Event generator channel event selection **************************************************/
#define EVSYS_EVENT_NONE 0x00 /* No event generator selected */
#define EVSYS_EVENT_OSCCTRL_XOSC_FAIL0 0x01 /* XOSC fail detection 0 */
#define EVSYS_EVENT_OSCCTRL_XOSC_FAIL1 0x02 /* XOSC fail detection 1 */
#define EVSYS_EVENT_OSC32KCTRL_XOSC32K_FAIL 0x03 /* XOSC32K fail detection */
#define EVSYS_EVENT_RTC_PER0 0x04 /* RTC period 0 */
#define EVSYS_EVENT_RTC_PER1 0x05 /* RTC period 1 */
#define EVSYS_EVENT_RTC_PER2 0x06 /* RTC period 2 */
#define EVSYS_EVENT_RTC_PER3 0x07 /* RTC period 3 */
#define EVSYS_EVENT_RTC_PER4 0x08 /* RTC period 4 */
#define EVSYS_EVENT_RTC_PER5 0x09 /* RTC period 5 */
#define EVSYS_EVENT_RTC_PER6 0x0a /* RTC period 6 */
#define EVSYS_EVENT_RTC_PER7 0x0b /* RTC period 7 */
#define EVSYS_EVENT_RTC_CMP0 0x0c /* RTC comparison 0 */
#define EVSYS_EVENT_RTC_CMP1 0x0d /* RTC comparison 0 */
#define EVSYS_EVENT_RTC_CMP2 0x0e /* RTC comparison 0 */
#define EVSYS_EVENT_RTC_CMP3 0x0f /* RTC comparison 0 */
#define EVSYS_EVENT_RTC_TAMPER 0x10 /* RTC tamper detection */
#define EVSYS_EVENT_RTC_OVF 0x11 /* RTC overflow */
#define EVSYS_EVENT_EIC_EXTINT0 0x12 /* EIC external interrupt 0 */
#define EVSYS_EVENT_EIC_EXTINT1 0x13 /* EIC external interrupt 1 */
#define EVSYS_EVENT_EIC_EXTINT2 0x14 /* EIC external interrupt 2 */
#define EVSYS_EVENT_EIC_EXTINT3 0x15 /* EIC external interrupt 3 */
#define EVSYS_EVENT_EIC_EXTINT4 0x16 /* EIC external interrupt 4 */
#define EVSYS_EVENT_EIC_EXTINT5 0x17 /* EIC external interrupt 5 */
#define EVSYS_EVENT_EIC_EXTINT6 0x18 /* EIC external interrupt 6 */
#define EVSYS_EVENT_EIC_EXTINT7 0x19 /* EIC external interrupt 7 */
#define EVSYS_EVENT_EIC_EXTINT8 0x1a /* EIC external interrupt 8 */
#define EVSYS_EVENT_EIC_EXTINT9 0x1b /* EIC external interrupt 9 */
#define EVSYS_EVENT_EIC_EXTINT10 0x1c /* EIC external interrupt 10 */
#define EVSYS_EVENT_EIC_EXTINT11 0x1d /* EIC external interrupt 11 */
#define EVSYS_EVENT_EIC_EXTINT12 0x1e /* EIC external interrupt 12 */
#define EVSYS_EVENT_EIC_EXTINT13 0x1f /* EIC external interrupt 13 */
#define EVSYS_EVENT_EIC_EXTINT14 0x20 /* EIC external interrupt 14 */
#define EVSYS_EVENT_EIC_EXTINT15 0x21 /* EIC external interrupt 15 */
#define EVSYS_EVENT_DMAC_CH0 0x22 /* DMA channel 0 */
#define EVSYS_EVENT_DMAC_CH1 0x23 /* DMA channel 0 */
#define EVSYS_EVENT_DMAC_CH2 0x24 /* DMA channel 0 */
#define EVSYS_EVENT_DMAC_CH3 0x25 /* DMA channel 0 */
#define EVSYS_EVENT_PAC_ACCERR 0x26 /* PAC Acc. error */
#define EVSYS_EVENT_TCC0_OVF 0x29 /* TCC0 Overflow */
#define EVSYS_EVENT_TCC0_TRG 0x2a /* TCC0 Trigger Event */
#define EVSYS_EVENT_TCC0_CNT 0x2b /* TCC0 Counter */
#define EVSYS_EVENT_TCC0_MC0 0x2c /* TCC0 Match/Compare 0 */
#define EVSYS_EVENT_TCC0_MC1 0x2d /* TCC0 Match/Compare 1 */
#define EVSYS_EVENT_TCC0_MC2 0x2e /* TCC0 Match/Compare 2 */
#define EVSYS_EVENT_TCC0_MC3 0x2f /* TCC0 Match/Compare 3 */
#define EVSYS_EVENT_TCC0_MC4 0x30 /* TCC0 Match/Compare 4 */
#define EVSYS_EVENT_TCC0_MC5 0x31 /* TCC0 Match/Compare 5 */
#define EVSYS_EVENT_TCC1_OVF 0x32 /* TCC1 Overflow */
#define EVSYS_EVENT_TCC1_TRG 0x33 /* TCC1 Trigger Event */
#define EVSYS_EVENT_TCC1_CNT 0x34 /* TCC1 Counter */
#define EVSYS_EVENT_TCC1_MC0 0x35 /* TCC1 Match/Compare 0 */
#define EVSYS_EVENT_TCC1_MC1 0x36 /* TCC1 Match/Compare 1 */
#define EVSYS_EVENT_TCC1_MC2 0x37 /* TCC1 Match/Compare 2 */
#define EVSYS_EVENT_TCC1_MC3 0x38 /* TCC1 Match/Compare 3 */
#define EVSYS_EVENT_TCC2_OVF 0x39 /* TCC2 Overflow */
#define EVSYS_EVENT_TCC2 0x3a /* TCC2_TRG Trigger Event */
#define EVSYS_EVENT_TCC2_CNT 0x3b /* TCC2 Counter */
#define EVSYS_EVENT_TCC2_MC0 0x3c /* TCC2 Match/Compare 0 */
#define EVSYS_EVENT_TCC2_MC1 0x3d /* TCC2 Match/Compare 1 */
#define EVSYS_EVENT_TCC2_MC2 0x3e /* TCC2 Match/Compare 2 */
#define EVSYS_EVENT_TCC3_OVF 0x3f /* TCC3 Overflow */
#define EVSYS_EVENT_TCC3_TRG 0x40 /* TCC3 Trigger Event */
#define EVSYS_EVENT_TCC3_CNT 0x41 /* TCC3 Counter */
#define EVSYS_EVENT_TCC3_MC0 0x42 /* TCC3 Match/Compare 0 */
#define EVSYS_EVENT_TCC3_MC1 0x43 /* TCC3 Match/Compare 1 */
#define EVSYS_EVENT_TCC4_OVF 0x44 /* TCC4 Overflow */
#define EVSYS_EVENT_TCC4_TRG 0x45 /* TCC4 Trigger Event */
#define EVSYS_EVENT_TCC4_CNT 0x46 /* TCC4 Counter */
#define EVSYS_EVENT_TCC4_MC0 0x47 /* TCC4 Match/Compare 0 */
#define EVSYS_EVENT_TCC4_MC1 0x48 /* TCC4 Match/Compare 1 */
#define EVSYS_EVENT_TC0_OVF 0x49 /* TC0 Overflow */
#define EVSYS_EVENT_TC0_MC0 0x4a /* TC0 Match/Compare 0 */
#define EVSYS_EVENT_TC0_MC1 0x4b /* TC0 Match/Compare 1 */
#define EVSYS_EVENT_TC1_OVF 0x4c /* TC1 Overflow */
#define EVSYS_EVENT_TC1_MC0 0x4d /* TC1 Match/Compare 0 */
#define EVSYS_EVENT_TC1_MC1 0x4e /* TC1 Match/Compare 1 */
#define EVSYS_EVENT_TC2_OVF 0x4f /* TC2 Overflow */
#define EVSYS_EVENT_TC2_MC0 0x50 /* TC2 Match/Compare 0 */
#define EVSYS_EVENT_TC2_MC1 0x51 /* TC2 Match/Compare 1 */
#define EVSYS_EVENT_TC3_OVF 0x52 /* TC3 Overflow */
#define EVSYS_EVENT_TC3_MC0 0x53 /* TC3 Match/Compare 0 */
#define EVSYS_EVENT_TC3_MC1 0x54 /* TC3 Match/Compare 1 */
#define EVSYS_EVENT_TC4_OVF 0x55 /* TC4 Overflow */
#define EVSYS_EVENT_TC4_MC0 0x56 /* TC4 Match/Compare 0 */
#define EVSYS_EVENT_TC4_MC1 0x57 /* TC4 Match/Compare 1 */
#define EVSYS_EVENT_TC5_OVF 0x58 /* TC5 Overflow */
#define EVSYS_EVENT_TC5_MC0 0x59 /* TC5 Match/Compare 0 */
#define EVSYS_EVENT_TC5_MC1 0x5a /* TC5 Match/Compare 1 */
#define EVSYS_EVENT_TC6_OVF 0x5b /* TC6 Overflow */
#define EVSYS_EVENT_TC6_MC0 0x5c /* TC6 Match/Compare 0 */
#define EVSYS_EVENT_TC6_MC1 0x5d /* TC6 Match/Compare 1 */
#define EVSYS_EVENT_TC7_OVF 0x5e /* TC7 Overflow */
#define EVSYS_EVENT_TC7_MC0 0x5f /* TC7 Match/Compare 0 */
#define EVSYS_EVENT_TC7_MC1 0x60 /* TC7 Match/Compare 1 */
#define EVSYS_EVENT_PDEC_OVF 0x61 /* PDEC Overflow */
#define EVSYS_EVENT_PDEC_ERR 0x62 /* PDEC Error */
#define EVSYS_EVENT_PDEC_DIR 0x63 /* PDEC Direction */
#define EVSYS_EVENT_PDEC_VLC 0x64 /* PDEC VLC */
#define EVSYS_EVENT_PDEC_MC0 0x65 /* PDEC MC0 */
#define EVSYS_EVENT_PDEC_MC1 0x66 /* PDEC MC1 */
#define EVSYS_EVENT_ADC0_RESRDY 0x67 /* ADC0 RESRDY */
#define EVSYS_EVENT_ADC0_WINMON 0x68 /* ADC0 Window Monitor */
#define EVSYS_EVENT_ADC1_RESRDY 0x69 /* ADC1 RESRDY */
#define EVSYS_EVENT_ADC1_WINMON 0x6a /* ADC1 Window Monitor */
#define EVSYS_EVENT_AC_COMP0 0x6b /* AC Comparator 0 */
#define EVSYS_EVENT_AC_COMP1 0x6c /* AC Comparator 1 */
#define EVSYS_EVENT_AC_WIN 0x6d /* AC0 Window */
#define EVSYS_EVENT_DAC_EMPTY0 0x6e /* DAC empty 0 */
#define EVSYS_EVENT_DAC_EMPTY1 0x6f /* DAC empty 1 */
#define EVSYS_EVENT_DAC_RESRDY0 0x70 /* DAC RSRDY 0 */
#define EVSYS_EVENT_DAC_RESRDY1 0x71 /* DAC RSRDY 1 */
#define EVSYS_EVENT_GMAC_TSU_CMP 0x72 /* GMAC Timestamp CMP */
#define EVSYS_EVENT_TRNG_READY 0x73 /* TRNG ready */
#define EVSYS_EVENT_CCL_LUTOUT0 0x74 /* CCL LUTOUT 0 */
#define EVSYS_EVENT_CCL_LUTOUT1 0x75 /* CCL LUTOUT 1 */
#define EVSYS_EVENT_CCL_LUTOUT2 0x76 /* CCL LUTOUT 2 */
#define EVSYS_EVENT_CCL_LUTOUT3 0x77 /* CCL LUTOUT 3 */
/* User multiplexer numbers ****************************************************************/
/* These are indices that may be used with the SAM_EVSYS_USER(n) macro to get the address of
* the correct user register.
*/
#define EVSYS_USER_RTC_TAMPER 0 /* RTC Tamper A */
#define EVSYS_USER_PORT_EV0 1 /* Port 0 event */
#define EVSYS_USER_PORT_EV1 2 /* Port 1 event */
#define EVSYS_USER_PORT_EV2 3 /* Port 2 event */
#define EVSYS_USER_PORT_EV3 4 /* Port 3 event */
#define EVSYS_USER_DMAC_CH0 5 /* DMA channel 0 event */
#define EVSYS_USER_DMAC_CH1 6 /* DMA channel 1 event */
#define EVSYS_USER_DMAC_CH2 7 /* DMA channel 2 event */
#define EVSYS_USER_DMAC_CH3 8 /* DMA channel 3 event */
#define EVSYS_USER_DMAC_CH4 9 /* DMA channel 4 event */
#define EVSYS_USER_DMAC_CH5 10 /* DMA channel 5 event */
#define EVSYS_USER_DMAC_CH6 11 /* DMA channel 6 event */
#define EVSYS_USER_DMAC_CH7 12 /* DMA channel 7 event */
#define EVSYS_USER_CM4_TRACE_START 14 /* CM4 trace start */
#define EVSYS_USER_CM4_TRACE_STOP 15 /* CM4 trace stop */
#define EVSYS_USER_CM4_TRACE_TRIG 16 /* CM4 trace trigger */
#define EVSYS_USER_TCC0_EV0 17 /* TCC0 EV0 */
#define EVSYS_USER_TCC0_EV1 18 /* TCC0 EV1 */
#define EVSYS_USER_TCC0_MC0 19 /* TCC0 MC0 */
#define EVSYS_USER_TCC0_MC1 20 /* TCC0 MC1 */
#define EVSYS_USER_TCC0_MC2 21 /* TCC0 MC2 */
#define EVSYS_USER_TCC0_MC3 22 /* TCC0 MC3 */
#define EVSYS_USER_TCC0_MC4 23 /* TCC0 MC4 */
#define EVSYS_USER_TCC0_MC5 24 /* TCC0 MC5 */
#define EVSYS_USER_TCC1_EV0 25 /* TCC1 EV0 */
#define EVSYS_USER_TCC1_EV1 26 /* TCC1 EV1 */
#define EVSYS_USER_TCC1_MC0 27 /* TCC1 MC0 */
#define EVSYS_USER_TCC1_MC1 28 /* TCC1 MC1 */
#define EVSYS_USER_TCC1_MC2 29 /* TCC1 MC2 */
#define EVSYS_USER_TCC1_MC3 30 /* TCC1 MC3 */
#define EVSYS_USER_TCC2_EV0 31 /* TCC2 EV0 */
#define EVSYS_USER_TCC2_EV1 32 /* TCC2 EV1 */
#define EVSYS_USER_TCC2_MC0 33 /* TCC2 MC0 */
#define EVSYS_USER_TCC2_MC1 34 /* TCC2 MC1 */
#define EVSYS_USER_TCC2_MC2 35 /* TCC2 MC2 */
#define EVSYS_USER_TCC3_EV0 36 /* TCC3 EV0 */
#define EVSYS_USER_TCC3_EV1 37 /* TCC3 EV1 */
#define EVSYS_USER_TCC3_MC0 38 /* TCC3 MC0 */
#define EVSYS_USER_TCC3_MC1 39 /* TCC3 MC1 */
#define EVSYS_USER_TCC4_EV0 40 /* TCC4 EV0 */
#define EVSYS_USER_TCC4_EV1 41 /* TCC4 EV1 */
#define EVSYS_USER_TCC4_MC0 42 /* TCC4 MC0 */
#define EVSYS_USER_TCC4_MC1 43 /* TCC4 MC1 */
#define EVSYS_USER_TC0_EVU 44 /* TC0 EVU */
#define EVSYS_USER_TC1_EVU 45 /* TC1 EVU */
#define EVSYS_USER_TC2_EVU 46 /* TC2 EVU */
#define EVSYS_USER_TC3_EVU 47 /* TC3 EVU */
#define EVSYS_USER_TC4_EVU 48 /* TC4 EVU */
#define EVSYS_USER_TC5_EVU 49 /* TC5 EVU */
#define EVSYS_USER_TC6_EVU 50 /* TC6 EVU */
#define EVSYS_USER_TC7_EVU 51 /* TC7 EVU */
#define EVSYS_USER_PDEC_EVU0 52 /* PDEC EVU 0 */
#define EVSYS_USER_PDEC_EVU1 53 /* PDEC EVU 1 */
#define EVSYS_USER_PDEC_EVU2 54 /* PDEC EVU 2 */
#define EVSYS_USER_ADC0_START 55 /* ADC0 start conversion */
#define EVSYS_USER_ADC0_SYNC 56 /* SYNC Flush ADC0 */
#define EVSYS_USER_ADC1_START 57 /* ADC1 start conversion */
#define EVSYS_USER_ADC1_SYNC 58 /* SYNC Flush ADC1 */
#define EVSYS_USER_AC_SOC0 59 /* AC SOC 0 */
#define EVSYS_USER_AC_SOC1 60 /* AC SOC 1 */
#define EVSYS_USER_DAC_START0 61 /* DAC0 start conversion */
#define EVSYS_USER_DAC_START1 62 /* DAC1 start conversion */
#define EVSYS_USER_CCL_LUTIN0 63 /* CCL input 0 */
#define EVSYS_USER_CCL_LUTIN1 64 /* CCL input 1 */
#define EVSYS_USER_CCL_LUTIN2 65 /* CCL input 2 */
#define EVSYS_USER_CCL_LUTIN3 66 /* CCL input 3 */
/********************************************************************************************
* Public Types
********************************************************************************************/
/********************************************************************************************
* Public Data
********************************************************************************************/
/********************************************************************************************
* Public Functions
********************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_EVSYS_H */

View File

@ -0,0 +1,217 @@
/********************************************************************************************
* arch/arm/src/samd5e5/chip/sam_gclk.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_SAMD5E5_CHIP_SAM_GCLK_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_GCLK_H
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
#include "chip/sam_memorymap.h"
/********************************************************************************************
* Pre-processor Definitions
********************************************************************************************/
/* GCLK register offsets ********************************************************************/
#define SAM_GCLK_CTRLA_OFFSET 0x0000 /* Control register */
#define SAM_GCLK_SYNCHBUSY_OFFSET 0x0004 /* Status register */
#define SAM_GCLK_GENCTRL_OFFSET(n) (0x0020 + ((n) << 2)) /* General clock generator n */
#define SAM_GCLK_PCHCTRL_OFFSET(m) (0x0080 + ((m) << 2)) /* Peripheral channel control m */
/* GCLK register addresses ******************************************************************/
#define SAM_GCLK_CTRLA (SAM_GCLK_BASE + SAM_GCLK_CTRLA_OFFSET)
#define SAM_GCLK_SYNCHBUSY (SAM_GCLK_BASE + SAM_GCLK_SYNCHBUSY_OFFSET)
#define SAM_GCLK_GENCTRL(n) (SAM_GCLK_BASE + SAM_GCLK_GENCTRL_OFFSET(n))
#define SAM_GCLK_PCHCTRL(m) (SAM_GCLK_BASE + SAM_GCLK_PCHCTRL_OFFSET(m))
/* GCLK register bit definitions ************************************************************/
/* Control register */
#define GCLK_CTRLA_SWRST (1 << 0) /* Bit 0: Software Reset */
/* Status register */
#define GCLK_SYNCHBUSY_SWRST (1 << 0) /* Bit 0: SWRST synchronization busy */
#define GCLK_SYNCHBUSY_GENCTRL(n) (1 << ((n) + 2)) /* Bit n+2: Generator control n busy */
# define GCLK_SYNCHBUSY_GENCTRL0 (1 << 2) /* Bit 2: Generator control 0 busy */
# define GCLK_SYNCHBUSY_GENCTRL1 (1 << 3) /* Bit 3: Generator control 1 busy */
# define GCLK_SYNCHBUSY_GENCTRL2 (1 << 4) /* Bit 4: Generator control 2 busy */
# define GCLK_SYNCHBUSY_GENCTRL3 (1 << 5) /* Bit 5: Generator control 3 busy */
# define GCLK_SYNCHBUSY_GENCTRL4 (1 << 6) /* Bit 6: Generator control 4 busy */
# define GCLK_SYNCHBUSY_GENCTRL5 (1 << 7) /* Bit 7: Generator control 5 busy */
# define GCLK_SYNCHBUSY_GENCTRL6 (1 << 8) /* Bit 8: Generator control 6 busy */
# define GCLK_SYNCHBUSY_GENCTRL7 (1 << 9) /* Bit 9: Generator control 7 busy */
# define GCLK_SYNCHBUSY_GENCTRL8 (1 << 10) /* Bit 10: Generator control 8 busy */
# define GCLK_SYNCHBUSY_GENCTRL9 (1 << 11) /* Bit 11: Generator control 9 busy */
# define GCLK_SYNCHBUSY_GENCTRL10 (1 << 12) /* Bit 12: Generator control 10 busy */
/* General clock generator n */
#define GCLK_GENCTRL_SRC_SHIFT (0) /* Bits 0-4: Generator source selection */
#define GCLK_GENCTRL_SRC_MASK (31 << GCLK_GENCTRL_SRC_SHIFT)
# define GCLK_GENCTRL_SRC_XOSC0 (0 << GCLK_GENCTRL_SRC_SHIFT) /* XOSC 0 oscillator input */
# define GCLK_GENCTRL_SRC_XOSC1 (1 << GCLK_GENCTRL_SRC_SHIFT) /* XOSC 1 oscillator input */
# define GCLK_GENCTRL_SRC_GCLK_IN (2 << GCLK_GENCTRL_SRC_SHIFT) /* Generator input pad */
# define GCLK_GENCTRL_SRC_GLCK_GEN1 (3 << GCLK_GENCTRL_SRC_SHIFT) /* Generic clock generater 1 output */
# define GCLK_GENCTRL_SRC_OSCULP32K (4 << GCLK_GENCTRL_SRC_SHIFT) /* OSCULP32K oscillator output */
# define GCLK_GENCTRL_SRC_XOSC32K (5 << GCLK_GENCTRL_SRC_SHIFT) /* XOSC32K oscillator output */
# define GCLK_GENCTRL_SRC_DFLL (6 << GCLK_GENCTRL_SRC_SHIFT) /* DFLL oscillator output */
# define GCLK_GENCTRL_SRC_DPLL0 (7 << GCLK_GENCTRL_SRC_SHIFT) /* DPLL0 output */
# define GCLK_GENCTRL_SRC_DPLL1 (8 << GCLK_GENCTRL_SRC_SHIFT) /* DPLL1 output */
#define GCLK_GENCTRL_GENEN (1 << 8) /* Bit 8: Generator enable */
#define GCLK_GENCTRL_IDC (1 << 9) /* Bit 9: Improve duty cycle */
#define GCLK_GENCTRL_OOV (1 << 10) /* Bit 10: Clock output selection */
#define GCLK_GENCTRL_OE (1 << 11) /* Bit 11: Clock output enable */
#define GCLK_GENCTRL_DIVSEL (1 << 12) /* Bit 12: Clock source divider */
#define GCLK_GENCTRL_RUNSTDBY (1 << 13) /* Bit 13: Run in standby */
#define GCLK_GENCTRL_DIV_SHIFT (16) /* Bits 16-31: Generator 0,2-11 Division factor */
#define GCLK_GENCTRL_DIV_MASK (0xff << GCLK_GENCTRL_DIV_SHIFT)
# define GCLK_GENCTRL_DIV(n) ((uint32_t)(n) << GCLK_GENCTRL_DIV_SHIFT)
#define GCLK_GENCTRL1_DIV_SHIFT (16) /* Bits 16-23: Generator 1 Division factor **/
#define GCLK_GENCTRL1_DIV_MASK (0xffff << GCLK_GENCTRL1_DIV_SHIFT)
# define GCLK_GENCTRL1_DIV(n) ((uint32_t)(n) << GCLK_GENCTRL1_DIV_SHIFT)
/* Peripheral channel control m */
#define GCLK_PCHCTRL_GEN_SHIFT (0) /* Bits 0-3: Generator selection */
#define GCLK_PCHCTRL_GEN_MASK (15 << GCLK_PCHCTRL_GEN_SHIFT)
# define GCLK_PCHCTRL_GEN(n) ((uint32_t)(n) << GCLK_PCHCTRL_GEN_SHIFT)
# define GCLK_PCHCTRL_GEN0 (0 << GCLK_PCHCTRL_GEN_SHIFT)
# define GCLK_PCHCTRL_GEN1 (1 << GCLK_PCHCTRL_GEN_SHIFT)
# define GCLK_PCHCTRL_GEN2 (2 << GCLK_PCHCTRL_GEN_SHIFT)
# define GCLK_PCHCTRL_GEN3 (3 << GCLK_PCHCTRL_GEN_SHIFT)
# define GCLK_PCHCTRL_GEN4 (4 << GCLK_PCHCTRL_GEN_SHIFT)
# define GCLK_PCHCTRL_GEN5 (5 << GCLK_PCHCTRL_GEN_SHIFT)
# define GCLK_PCHCTRL_GEN6 (6 << GCLK_PCHCTRL_GEN_SHIFT)
# define GCLK_PCHCTRL_GEN7 (7 << GCLK_PCHCTRL_GEN_SHIFT)
# define GCLK_PCHCTRL_GEN8 (8 << GCLK_PCHCTRL_GEN_SHIFT)
# define GCLK_PCHCTRL_GEN9 (9 << GCLK_PCHCTRL_GEN_SHIFT)
# define GCLK_PCHCTRL_GEN10 (10 << GCLK_PCHCTRL_GEN_SHIFT)
# define GCLK_PCHCTRL_GEN11 (11 << GCLK_PCHCTRL_GEN_SHIFT)
#define GCLK_PCHCTRL_CHEN (1 << 6) /* Bit 6: Channel enable */
#define GCLK_PCHCTRL_WRTLOCK (1 << 7) /* Bit 7: Write lock */
/* PCHCTRL channel mapping ******************************************************************/
#define GCLK_CHAN_OSCCTRL_DFLL48 0 /* DFLL48 input clock source */
#define GCLK_CHAN_OSCCTRL_FDPLL0 1 /* Reference clock for FDPLL0 */
#define GCLK_CHAN_OSCCTRL_FDPLL1 2 /* Reference clock for FDPLL1 */
#define GCLK_CHAN_OSCCTRL_FDPLL0_32K 3 /* FDPLL0 32KHz clock for internal lock timer */
#define GCLK_CHAN_OSCCTRL_FDPLL1_32K 3 /* FDPLL1 32KHz clock for internal lock timer */
#define GCLK_CHAN_SDHCn_SLOW 3 /* SDHC0-1 Slow */
#define GCLK_CHAN_SDHC0_SLOW 3 /* SDHC0 Slow */
#define GCLK_CHAN_SDHC1_SLOW 3 /* SDHC1 Slow */
#define GCLK_CHAN_SERCOMn_SLOW 3 /* SERCOM0=7 Slow */
#define GCLK_CHAN_SERCOM0_SLOW 3 /* SERCOM0 Slow */
#define GCLK_CHAN_SERCOM1_SLOW 3 /* SERCOM1 Slow */
#define GCLK_CHAN_SERCOM2_SLOW 3 /* SERCOM2 Slow */
#define GCLK_CHAN_SERCOM3_SLOW 3 /* SERCOM3 Slow */
#define GCLK_CHAN_SERCOM4_SLOW 3 /* SERCOM4 Slow */
#define GCLK_CHAN_SERCOM5_SLOW 3 /* SERCOM5 Slow */
#define GCLK_CHAN_SERCOM6_SLOW 3 /* SERCOM6 Slow */
#define GCLK_CHAN_SERCOM7_SLOW 3 /* SERCOM7 Slow */
#define GCLK_CHAN_EIC 4 /* EIC */
#define GCLK_CHAN_FREQM_MSR 5 /* FREQM Measure */
#define GCLK_CHAN_FREQM_REF 6 /* FREQM Reference */
#define GCLK_CHAN_SERCOM0_CORE 7 /* SERCOM0 Core */
#define GCLK_CHAN_SERCOM1_CORE 8 /* SERCOM1 Core */
#define GCLK_CHAN_TCn 9 /* TC0-1 */
#define GCLK_CHAN_TC0 9 /* TC0 */
#define GCLK_CHAN_TC1 9 /* TC1 */
#define GCLK_CHAN_USB 10 /* USB */
#define GCLK_CHAN_EVSYS0 11 /* EVSYS0 */
#define GCLK_CHAN_EVSYS1 12 /* EVSYS1 */
#define GCLK_CHAN_EVSYS2 13 /* EVSYS2 */
#define GCLK_CHAN_EVSYS3 14 /* EVSYS3 */
#define GCLK_CHAN_EVSYS4 15 /* EVSYS4 */
#define GCLK_CHAN_EVSYS5 16 /* EVSYS5 */
#define GCLK_CHAN_EVSYS6 17 /* EVSYS6 */
#define GCLK_CHAN_EVSYS7 18 /* EVSYS7 */
#define GCLK_CHAN_EVSYS8 19 /* EVSYS8 */
#define GCLK_CHAN_EVSYS9 20 /* EVSYS9 */
#define GCLK_CHAN_EVSYS10 21 /* EVSYS10 */
#define GCLK_CHAN_EVSYS11 22 /* EVSYS11 */
#define GCLK_CHAN_SERCOM2_CORE 23 /* SERCOM2 Core */
#define GCLK_CHAN_SERCOM3_CORE 24 /* SERCOM3 Core */
#define GCLK_CHAN_TCC0 25 /* TCC0 */
#define GCLK_CHAN_TCC1 25 /* TCC1 */
#define GCLK_CHAN_TC2 26 /* TC2 */
#define GCLK_CHAN_TC3 26 /* TC3 */
#define GCLK_CHAN_CAN0 27 /* CAN0 */
#define GCLK_CHAN_CAN1 28 /* CAN1 */
#define GCLK_CHAN_TCC2 29 /* TCC2 */
#define GCLK_CHAN_TCC3 29 /* TCC3 */
#define GCLK_CHAN_TC4 30 /* TC4 */
#define GCLK_CHAN_TC5 30 /* TC5 */
#define GCLK_CHAN_PDEC 31 /* PDEC */
#define GCLK_CHAN_AC 32 /* AC */
#define GCLK_CHAN_CCL 33 /* CCL */
#define GCLK_CHAN_SERCOM4_CORE 34 /* SERCOM4 Core */
#define GCLK_CHAN_SERCOM5_CORE 35 /* SERCOM5 Core */
#define GCLK_CHAN_SERCOM6_CORE 36 /* SERCOM6 Core */
#define GCLK_CHAN_SERCOM7_CORE 37 /* SERCOM7 Core */
#define GCLK_CHAN_TCC4 38 /* TCC4 */
#define GCLK_CHAN_TC6 39 /* TC6 */
#define GCLK_CHAN_TC7 39 /* TC7 */
#define GCLK_CHAN_ADC0 40 /* ADC0 */
#define GCLK_CHAN_ADC1 41 /* ADC1 */
#define GCLK_CHAN_DAC 42 /* DAC */
#define GCLK_CHAN_I2S_1 43 /* I2S */
#define GCLK_CHAN_I2S_2 44 /* I2S */
#define GCLK_CHAN_SDHC0 45 /* SDHC0 */
#define GCLK_CHAN_SDHC1 46 /* SDHC1 */
#define GCLK_CHAN_CM4_TRACE 47 /* CM4 Trace */
/********************************************************************************************
* Public Types
********************************************************************************************/
/********************************************************************************************
* Public Data
********************************************************************************************/
/********************************************************************************************
* Public Functions
********************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_GCLK_H */

View File

@ -0,0 +1,307 @@
/********************************************************************************************
* arch/arm/src/samd5e5/chip/sam_i2c_master.h
*
* Copyright (C) 2018 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_SAMD5E5_CHIP_SAM_I2C_MASTER_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_I2C_MASTER_H
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
#include "chip/sam_memorymap.h"
/********************************************************************************************
* Pre-processor Definitions
********************************************************************************************/
/* I2C register offsets *********************************************************************/
#define SAM_I2C_CTRLA_OFFSET 0x0000 /* Control A register */
#define SAM_I2C_CTRLB_OFFSET 0x0004 /* Control B register */
#define SAM_I2C_CTRLC_OFFSET 0x0004 /* Control C register */
#define SAM_I2C_BAUD_OFFSET 0x000c /* Baud register */
#define SAM_I2C_INTENCLR_OFFSET 0x0014 /* Interrupt enable clear register */
#define SAM_I2C_INTENSET_OFFSET 0x0016 /* Interrupt enable set register */
#define SAM_I2C_INTFLAG_OFFSET 0x0018 /* Interrupt flag and status clear register */
#define SAM_I2C_STATUS_OFFSET 0x001a /* Status register */
#define SAM_I2C_SYNCBUSY_OFFSET 0x001c /* Synchronization busy register */
#define SAM_I2C_ADDR_OFFSET 0x0024 /* Address register */
#define SAM_I2C_DATA_OFFSET 0x0028 /* Data register */
#define SAM_I2C_DBGCTRL_OFFSET 0x0030 /* Debug control register */
/* I2C register addresses *******************************************************************/
#define SAM_I2C0_CTRLA (SAM_SERCOM0_BASE + SAM_I2C_CTRLA_OFFSET)
#define SAM_I2C0_CTRLB (SAM_SERCOM0_BASE + SAM_I2C_CTRLB_OFFSET)
#define SAM_I20C_CTRLC (SAM_SERCOM0_BASE + SAM_I2C_CTRLC_OFFSET)
#define SAM_I2C0_BAUD (SAM_SERCOM0_BASE + SAM_I2C_BAUD_OFFSET)
#define SAM_I2C0_INTENCLR (SAM_SERCOM0_BASE + SAM_I2C_INTENCLR_OFFSET)
#define SAM_I2C0_INTENSET (SAM_SERCOM0_BASE + SAM_I2C_INTENSET_OFFSET)
#define SAM_I2C0_INTFLAG (SAM_SERCOM0_BASE + SAM_I2C_INTFLAG_OFFSET)
#define SAM_I2C0_STATUS (SAM_SERCOM0_BASE + SAM_I2C_STATUS_OFFSET)
#define SAM_I2C0_SYNCBUSY (SAM_SERCOM0_BASE + SAM_I2C_SYNCBUSY_OFFSET)
#define SAM_I2C0_ADDR (SAM_SERCOM0_BASE + SAM_I2C_ADDR_OFFSET)
#define SAM_I2C0_DATA (SAM_SERCOM0_BASE + SAM_I2C_DATA_OFFSET)
#define SAM_I2C0_DBGCTRL (SAM_SERCOM0_BASE + SAM_I2C_DBGCTRL_OFFSET)
#define SAM_I2C1_CTRLA (SAM_SERCOM1_BASE + SAM_I2C_CTRLA_OFFSET)
#define SAM_I2C1_CTRLB (SAM_SERCOM1_BASE + SAM_I2C_CTRLB_OFFSET)
#define SAM_I21C_CTRLC (SAM_SERCOM1_BASE + SAM_I2C_CTRLC_OFFSET)
#define SAM_I2C1_BAUD (SAM_SERCOM1_BASE + SAM_I2C_BAUD_OFFSET)
#define SAM_I2C1_INTENCLR (SAM_SERCOM1_BASE + SAM_I2C_INTENCLR_OFFSET)
#define SAM_I2C1_INTENSET (SAM_SERCOM1_BASE + SAM_I2C_INTENSET_OFFSET)
#define SAM_I2C1_INTFLAG (SAM_SERCOM1_BASE + SAM_I2C_INTFLAG_OFFSET)
#define SAM_I2C1_STATUS (SAM_SERCOM1_BASE + SAM_I2C_STATUS_OFFSET)
#define SAM_I2C1_SYNCBUSY (SAM_SERCOM1_BASE + SAM_I2C_SYNCBUSY_OFFSET)
#define SAM_I2C1_ADDR (SAM_SERCOM1_BASE + SAM_I2C_ADDR_OFFSET)
#define SAM_I2C1_DATA (SAM_SERCOM1_BASE + SAM_I2C_DATA_OFFSET)
#define SAM_I2C1_DBGCTRL (SAM_SERCOM1_BASE + SAM_I2C_DBGCTRL_OFFSET)
#define SAM_I2C2_CTRLA (SAM_SERCOM2_BASE + SAM_I2C_CTRLA_OFFSET)
#define SAM_I2C2_CTRLB (SAM_SERCOM2_BASE + SAM_I2C_CTRLB_OFFSET)
#define SAM_I22C_CTRLC (SAM_SERCOM2_BASE + SAM_I2C_CTRLC_OFFSET)
#define SAM_I2C2_BAUD (SAM_SERCOM2_BASE + SAM_I2C_BAUD_OFFSET)
#define SAM_I2C2_INTENCLR (SAM_SERCOM2_BASE + SAM_I2C_INTENCLR_OFFSET)
#define SAM_I2C2_INTENSET (SAM_SERCOM2_BASE + SAM_I2C_INTENSET_OFFSET)
#define SAM_I2C2_INTFLAG (SAM_SERCOM2_BASE + SAM_I2C_INTFLAG_OFFSET)
#define SAM_I2C2_STATUS (SAM_SERCOM2_BASE + SAM_I2C_STATUS_OFFSET)
#define SAM_I2C2_SYNCBUSY (SAM_SERCOM2_BASE + SAM_I2C_SYNCBUSY_OFFSET)
#define SAM_I2C2_ADDR (SAM_SERCOM2_BASE + SAM_I2C_ADDR_OFFSET)
#define SAM_I2C2_DATA (SAM_SERCOM2_BASE + SAM_I2C_DATA_OFFSET)
#define SAM_I2C2_DBGCTRL (SAM_SERCOM2_BASE + SAM_I2C_DBGCTRL_OFFSET)
#define SAM_I2C3_CTRLA (SAM_SERCOM3_BASE + SAM_I2C_CTRLA_OFFSET)
#define SAM_I2C3_CTRLB (SAM_SERCOM3_BASE + SAM_I2C_CTRLB_OFFSET)
#define SAM_I23C_CTRLC (SAM_SERCOM3_BASE + SAM_I2C_CTRLC_OFFSET)
#define SAM_I2C3_BAUD (SAM_SERCOM3_BASE + SAM_I2C_BAUD_OFFSET)
#define SAM_I2C3_INTENCLR (SAM_SERCOM3_BASE + SAM_I2C_INTENCLR_OFFSET)
#define SAM_I2C3_INTENSET (SAM_SERCOM3_BASE + SAM_I2C_INTENSET_OFFSET)
#define SAM_I2C3_INTFLAG (SAM_SERCOM3_BASE + SAM_I2C_INTFLAG_OFFSET)
#define SAM_I2C3_STATUS (SAM_SERCOM3_BASE + SAM_I2C_STATUS_OFFSET)
#define SAM_I2C3_SYNCBUSY (SAM_SERCOM3_BASE + SAM_I2C_SYNCBUSY_OFFSET)
#define SAM_I2C3_ADDR (SAM_SERCOM3_BASE + SAM_I2C_ADDR_OFFSET)
#define SAM_I2C3_DATA (SAM_SERCOM3_BASE + SAM_I2C_DATA_OFFSET)
#define SAM_I2C3_DBGCTRL (SAM_SERCOM3_BASE + SAM_I2C_DBGCTRL_OFFSET)
#define SAM_I2C4_CTRLA (SAM_SERCOM4_BASE + SAM_I2C_CTRLA_OFFSET)
#define SAM_I2C4_CTRLB (SAM_SERCOM4_BASE + SAM_I2C_CTRLB_OFFSET)
#define SAM_I24C_CTRLC (SAM_SERCOM4_BASE + SAM_I2C_CTRLC_OFFSET)
#define SAM_I2C4_BAUD (SAM_SERCOM4_BASE + SAM_I2C_BAUD_OFFSET)
#define SAM_I2C4_INTENCLR (SAM_SERCOM4_BASE + SAM_I2C_INTENCLR_OFFSET)
#define SAM_I2C4_INTENSET (SAM_SERCOM4_BASE + SAM_I2C_INTENSET_OFFSET)
#define SAM_I2C4_INTFLAG (SAM_SERCOM4_BASE + SAM_I2C_INTFLAG_OFFSET)
#define SAM_I2C4_STATUS (SAM_SERCOM4_BASE + SAM_I2C_STATUS_OFFSET)
#define SAM_I2C4_SYNCBUSY (SAM_SERCOM4_BASE + SAM_I2C_SYNCBUSY_OFFSET)
#define SAM_I2C4_ADDR (SAM_SERCOM4_BASE + SAM_I2C_ADDR_OFFSET)
#define SAM_I2C4_DATA (SAM_SERCOM4_BASE + SAM_I2C_DATA_OFFSET)
#define SAM_I2C4_DBGCTRL (SAM_SERCOM4_BASE + SAM_I2C_DBGCTRL_OFFSET)
#define SAM_I2C5_CTRLA (SAM_SERCOM5_BASE + SAM_I2C_CTRLA_OFFSET)
#define SAM_I2C5_CTRLB (SAM_SERCOM5_BASE + SAM_I2C_CTRLB_OFFSET)
#define SAM_I25C_CTRLC (SAM_SERCOM5_BASE + SAM_I2C_CTRLC_OFFSET)
#define SAM_I2C5_BAUD (SAM_SERCOM5_BASE + SAM_I2C_BAUD_OFFSET)
#define SAM_I2C5_INTENCLR (SAM_SERCOM5_BASE + SAM_I2C_INTENCLR_OFFSET)
#define SAM_I2C5_INTENSET (SAM_SERCOM5_BASE + SAM_I2C_INTENSET_OFFSET)
#define SAM_I2C5_INTFLAG (SAM_SERCOM5_BASE + SAM_I2C_INTFLAG_OFFSET)
#define SAM_I2C5_STATUS (SAM_SERCOM5_BASE + SAM_I2C_STATUS_OFFSET)
#define SAM_I2C5_SYNCBUSY (SAM_SERCOM5_BASE + SAM_I2C_SYNCBUSY_OFFSET)
#define SAM_I2C5_ADDR (SAM_SERCOM5_BASE + SAM_I2C_ADDR_OFFSET)
#define SAM_I2C5_DATA (SAM_SERCOM5_BASE + SAM_I2C_DATA_OFFSET)
#define SAM_I2C5_DBGCTRL (SAM_SERCOM5_BASE + SAM_I2C_DBGCTRL_OFFSET)
#define SAM_I2C6_CTRLA (SAM_SERCOM6_BASE + SAM_I2C_CTRLA_OFFSET)
#define SAM_I2C6_CTRLB (SAM_SERCOM6_BASE + SAM_I2C_CTRLB_OFFSET)
#define SAM_I26C_CTRLC (SAM_SERCOM6_BASE + SAM_I2C_CTRLC_OFFSET)
#define SAM_I2C6_BAUD (SAM_SERCOM6_BASE + SAM_I2C_BAUD_OFFSET)
#define SAM_I2C6_INTENCLR (SAM_SERCOM6_BASE + SAM_I2C_INTENCLR_OFFSET)
#define SAM_I2C6_INTENSET (SAM_SERCOM6_BASE + SAM_I2C_INTENSET_OFFSET)
#define SAM_I2C6_INTFLAG (SAM_SERCOM6_BASE + SAM_I2C_INTFLAG_OFFSET)
#define SAM_I2C6_STATUS (SAM_SERCOM6_BASE + SAM_I2C_STATUS_OFFSET)
#define SAM_I2C6_SYNCBUSY (SAM_SERCOM6_BASE + SAM_I2C_SYNCBUSY_OFFSET)
#define SAM_I2C6_ADDR (SAM_SERCOM6_BASE + SAM_I2C_ADDR_OFFSET)
#define SAM_I2C6_DATA (SAM_SERCOM6_BASE + SAM_I2C_DATA_OFFSET)
#define SAM_I2C6_DBGCTRL (SAM_SERCOM6_BASE + SAM_I2C_DBGCTRL_OFFSET)
#define SAM_I2C5_CTRLA (SAM_SERCOM7_BASE + SAM_I2C_CTRLA_OFFSET)
#define SAM_I2C7_CTRLB (SAM_SERCOM7_BASE + SAM_I2C_CTRLB_OFFSET)
#define SAM_I27C_CTRLC (SAM_SERCOM7_BASE + SAM_I2C_CTRLC_OFFSET)
#define SAM_I2C7_BAUD (SAM_SERCOM7_BASE + SAM_I2C_BAUD_OFFSET)
#define SAM_I2C7_INTENCLR (SAM_SERCOM7_BASE + SAM_I2C_INTENCLR_OFFSET)
#define SAM_I2C7_INTENSET (SAM_SERCOM7_BASE + SAM_I2C_INTENSET_OFFSET)
#define SAM_I2C7_INTFLAG (SAM_SERCOM7_BASE + SAM_I2C_INTFLAG_OFFSET)
#define SAM_I2C7_STATUS (SAM_SERCOM7_BASE + SAM_I2C_STATUS_OFFSET)
#define SAM_I2C7_SYNCBUSY (SAM_SERCOM7_BASE + SAM_I2C_SYNCBUSY_OFFSET)
#define SAM_I2C7_ADDR (SAM_SERCOM7_BASE + SAM_I2C_ADDR_OFFSET)
#define SAM_I2C7_DATA (SAM_SERCOM7_BASE + SAM_I2C_DATA_OFFSET)
#define SAM_I2C7_DBGCTRL (SAM_SERCOM7_BASE + SAM_I2C_DBGCTRL_OFFSET)
/* I2C register bit definitions *************************************************************/
/* Control A register */
#define I2C_CTRLA_SWRST (1 << 0) /* Bit 0: Software reset */
#define I2C_CTRLA_ENABLE (1 << 1) /* Bit 1: Enable */
#define I2C_CTRLA_MODE_SHIFT (2) /* Bits 2-4: Operating Mode */
#define I2C_CTRLA_MODE_MASK (7 << I2C_CTRLA_MODE_SHIFT)
# define I2C_CTRLA_MODE_MASTER (5 << I2C_CTRLA_MODE_SHIFT) /* I2C master mode */
#define I2C_CTRLA_RUNSTDBY (1 << 7) /* Bit 7: Run in standby */
#define I2C_CTRLA_PINOUT (1 << 16) /* Bit 16: Transmit data pinout */
# define I2C_CTRLA_1WIRE (0) /* 4-wire operation disable */
# define I2C_CTRLA_4WIRE I2C_CTRLA_PINOUT /* 4-wire operation enable */
#define I2C_CTRLA_SDAHOLD_SHIFT (20) /* Bits 20-21: SDA Hold Time */
#define I2C_CTRLA_SDAHOLD_MASK (3 << I2C_CTRLA_SDAHOLD_SHIFT)
# define I2C_CTRLA_SDAHOLD_DIS (0 << I2C_CTRLA_SDAHOLD_SHIFT) /* Disabled */
# define I2C_CTRLA_SDAHOLD_75NS (1 << I2C_CTRLA_SDAHOLD_SHIFT) /* 50-100ns hold time */
# define I2C_CTRLA_SDAHOLD_450NS (2 << I2C_CTRLA_SDAHOLD_SHIFT) /* 300-600ns hold time */
# define I2C_CTRLA_SDAHOLD_600NS (3 << I2C_CTRLA_SDAHOLD_SHIFT) /* 400-800ns hold time */
#define I2C_CTRLA_MEXTTOEN (1 << 22) /* Bit 22: Master SCL low extend time-out */
#define I2C_CTRLA_SEXTTOEN (1 << 23) /* Bit 23: Slave SCL low extend time-out */
#define I2C_CTRLA_SPEED_SHIFT (24) /* Bits 24-25: Transfer speed */
#define I2C_CTRLA_SPEED_MASK (3 << I2C_CTRLA_SPEED_SHIFT)
# define I2C_CTRLA_SPEED_STD (0 << I2C_CTRLA_SPEED_SHIFT) /* Standard (<=100KHz) and fast (<=400KHz) */
# define I2C_CTRLA_SPEED_FAST (1 << I2C_CTRLA_SPEED_SHIFT) /* Fast-mode plus (<=1MHz) */
# define I2C_CTRLA_SPEED_HIGH (2 << I2C_CTRLA_SPEED_SHIFT) /* High speed mode (<=3.4Mhz */
#define I2C_CTRLA_SCLAM (1 << 27) /* Bit 27: CSL clock stretch mode */
#define I2C_CTRLA_INACTOUT_SHIFT (28) /* Bits 28-29: Inactive Time-Out */
#define I2C_CTRLA_INACTOUT_MASK (7 << I2C_CTRLA_INACTOUT_SHIFT)
# define I2C_CTRLA_INACTOUT_DIS (0 << I2C_CTRLA_INACTOUT_SHIFT) /* Disabled */
# define I2C_CTRLA_INACTOUT_55US (1 << I2C_CTRLA_INACTOUT_SHIFT) /* 5-6 SCL cycle time-out (50-60µs) */
# define I2C_CTRLA_INACTOUT_105US (2 << I2C_CTRLA_INACTOUT_SHIFT) /* 10-11 SCL cycle time-out (100-110µs) */
# define I2C_CTRLA_INACTOUT_205US (3 << I2C_CTRLA_INACTOUT_SHIFT) /* 20-21 SCL cycle time-out (200-210µs) */
#define I2C_CTRLA_LOWTOUT (1 << 30) /* Bit 30: SCL Low Time-Out */
/* Control B register */
#define I2C_CTRLB_SMEN (1 << 8) /* Bit 8: Smart Mode Enable */
#define I2C_CTRLB_QCEN (1 << 9) /* Bit 9: Quick Command Enable */
#define I2C_CTRLB_CMD_SHIFT (16) /* Bits 16-17: Command */
#define I2C_CTRLB_CMD_MASK (3 << I2C_CTRLB_CMD_SHIFT)
# define I2C_CTRLB_CMD_NOACTION (0 << I2C_CTRLB_CMD_SHIFT) /* No action */
# define I2C_CTRLB_CMD_ACKREP (1 << I2C_CTRLB_CMD_SHIFT) /* ACK followed by repeated START */
# define I2C_CTRLB_CMD_ACKREAD (2 << I2C_CTRLB_CMD_SHIFT) /* ACK followed by read operation */
# define I2C_CTRLB_CMD_ACKSTOP (3 << I2C_CTRLB_CMD_SHIFT) /* ACK followed by STOP */
#define I2C_CTRLB_ACKACT (1 << 18) /* Bit 18: Acknowledge Action */
# define I2C_CTRLB_ACK (0) /* Send ACK */
# define I2C_CTRLB_NACK I2C_CTRLB_ACKACT /* Send NACK */
/* Control C register */
#define I2C_CTRLC_DATA32B (1 << 24) /* Bit 24: Data 32 Bit */
# define I2C_CTRLC_DATA32B_8BIT (0) /* DATA register is 8-bit */
# define I2C_CTRLC_DATA32B_32BIT I2C_CTRLC_DATA32B /* DATA register is 32-bit */
/* Baud register (16-bit baud value) */
#define I2C_BAUD_SHIFT (0) /* Bits 0-7: Master Baud Rate */
#define I2C_BAUD_MASK (0xff << I2C_BAUD_SHIFT)
# define I2C_BAUD(n) ((uint16)(n) << I2C_BAUD_SHIFT)
#define I2C_BAUDLOW_SHIFT (8) /* Bits 8-15: Master Baud Rate Low */
#define I2C_BAUDLOW_MASK (0xff << I2C_BAUDLOW_SHIFT)
# define I2C_BAUDLOW(n) (uint16)(n) << I2C_BAUDLOW_SHIFT)
#define I2C_HSBAUD_SHIFT (16) /* Bits 16-23: High speed master Baud Rate */
#define I2C_HSBAUD_MASK (0xff << I2C_HSBAUD_SHIFT)
# define I2C_HSBAUD(n) ((uint16)(n) << I2C_HSBAUD_SHIFT)
#define I2C_HSBAUDLOW_SHIFT (24) /* Bits 24-31: High speed master Baud Rate Low */
#define I2C_HSBAUDLOW_MASK (0xff << I2C_HSBAUDLOW_SHIFT)
# define I2C_HSBAUDLOW(n) (uint16)(n) << I2C_HSBAUDLOW_SHIFT)
/* Interrupt enable clear, interrupt enable set, interrupt enable set, interrupt flag and
* status clear registers.
*/
#define I2C_INT_MB (1 << 0) /* Bit 0: Master on bus interrupt */
#define I2C_INT_SB (1 << 1) /* Bit 1: Slave on bus interrupt */
#define I2C_INT_ERR (1 << 7) /* Bit 7: Bus Error */
#define I2C_INT_ALL (0x03)
/* Status register */
#define I2C_STATUS_BUSERR (1 << 0) /* Bit 0: Bus Error */
#define I2C_STATUS_ARBLOST (1 << 1) /* Bit 1: Arbitration Lost */
#define I2C_STATUS_RXNACK (1 << 2) /* Bit 2: Received Not Acknowledge */
#define I2C_STATUS_BUSSTATE_SHIFT (4) /* Bits 4-5: Bus State */
#define I2C_STATUS_BUSSTATE_MASK (3 << I2C_STATUS_BUSSTATE_SHIFT)
# define I2C_STATUS_BUSSTATE_UNKNOWN (0 << I2C_STATUS_BUSSTATE_SHIFT) /* Unknown to master */
# define I2C_STATUS_BUSSTATE_IDLE (1 << I2C_STATUS_BUSSTATE_SHIFT) /* Waiting for transaction */
# define I2C_STATUS_BUSSTATE_OWNER (2 << I2C_STATUS_BUSSTATE_SHIFT) /* Master of bus owner */
# define I2C_STATUS_BUSSTATE_BUSY (3 << I2C_STATUS_BUSSTATE_SHIFT) /* Other master owns */
#define I2C_STATUS_LOWTOUT (1 << 6) /* Bit 6: SCL Low Time-Out */
#define I2C_STATUS_CLKHOLD (1 << 7) /* Bit 7: Clock Hold */
#define I2C_STATUS_MEXTTOUT (1 << 8) /* Bit 8: Master SCL low extend time-out */
#define I2C_STATUS_SEXTTOUT (1 << 9) /* Bit 9: Slave SCL low extend time-out */
#define I2C_STATUS_LENERR (1 << 10) /* Bit 10: Transaction length error */
/* Synchronization busy register */
#define I2C_SYNCBUSY_SWRST (1 << 0) /* Bit 0: Software reset synchronization busy */
#define I2C_SYNCBUSY_ENABLE (1 << 1) /* Bit 1: SERCOM enable synchronization busy */
#define I2C_SYNCBUSY_SYSOP (1 << 2) /* Bit 2: System operation synchronization busy */
/* Address register */
#define I2C_ADDR_SHIFT (0) /* Bits 0-10: Address */
#define I2C_ADDR_MASK (0x7ff << I2C_ADDR_SHIFT)
# define I2C_ADDR(n) ((uint32-_t(n) << I2C_ADDR_SHIFT)
#define I2C_ADDR_LENEN (1 << 13) /* Bit 13: Transfer length enable */
#define I2C_ADDR_HS (1 << 14) /* Bit 14: High speed */
#define I2C_ADDR_TENBITEN (1 << 15) /* Bit 15: Ten bit addressing enable */
#define I2C_ADDR_LEN_SHIFT (16) /* Bits 16-23: Transaction length */
#define I2C_ADDR_LEN_MASK (0xff << I2C_ADDR_LEN_SHIFT)
# define I2C_ADDR_LEN(n) ((uint32_t)(n) << I2C_ADDR_LEN_SHIFT)
/* Data register (8- or 32-bit data) */
#define I2C_DATA_MASK (0xff) /* Bits 0-7: Data */
/* Debug control register */
#define I2C_DBGCTRL_DBGSTOP (1 << 0) /* Bit 0: Debug stop mode */
/********************************************************************************************
* Public Types
********************************************************************************************/
/********************************************************************************************
* Public Data
********************************************************************************************/
/********************************************************************************************
* Public Functions
********************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_I2C_MASTER_H */

View File

@ -0,0 +1,283 @@
/********************************************************************************************
* arch/arm/src/samd5e5/chip/sam_i2c_slave.h
*
* Copyright (C) 2018 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_SAMD5E5_CHIP_SAM_I2C_SLAVE_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_I2C_SLAVE_H
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
#include "chip/sam_memorymap.h"
/********************************************************************************************
* Pre-processor Definitions
********************************************************************************************/
/* I2C register offsets *********************************************************************/
#define SAM_I2C_CTRLA_OFFSET 0x0000 /* Control A register */
#define SAM_I2C_CTRLB_OFFSET 0x0004 /* Control B register */
#define SAM_I2C_CTRLC_OFFSET 0x0008 /* Control C register */
#define SAM_I2C_INTENCLR_OFFSET 0x0014 /* Interrupt enable clear register */
#define SAM_I2C_INTENSET_OFFSET 0x0016 /* Interrupt enable set register */
#define SAM_I2C_INTFLAG_OFFSET 0x0018 /* Interrupt flag and status clear register */
#define SAM_I2C_STATUS_OFFSET 0x001a /* Status register */
#define SAM_I2C_SYNCBUSY_OFFSET 0x001c /* Synchronization busy register */
#define SAM_I2C_LENGTH_OFFSET 0x0022 /* Length register */
#define SAM_I2C_ADDR_OFFSET 0x0024 /* Address register */
#define SAM_I2C_DATA_OFFSET 0x0028 /* Data register */
/* I2C register addresses *******************************************************************/
#define SAM_I2C0_CTRLA (SAM_SERCOM0_BASE + SAM_I2C_CTRLA_OFFSET)
#define SAM_I2C0_CTRLB (SAM_SERCOM0_BASE + SAM_I2C_CTRLB_OFFSET)
#define SAM_I2C0_CTRLC (SAM_SERCOM0_BASE + SAM_I2C_CTRLC_OFFSET)
#define SAM_I2C0_INTENCLR (SAM_SERCOM0_BASE + SAM_I2C_INTENCLR_OFFSET)
#define SAM_I2C0_INTENSET (SAM_SERCOM0_BASE + SAM_I2C_INTENSET_OFFSET)
#define SAM_I2C0_INTFLAG (SAM_SERCOM0_BASE + SAM_I2C_INTFLAG_OFFSET)
#define SAM_I2C0_STATUS (SAM_SERCOM0_BASE + SAM_I2C_STATUS_OFFSET)
#define SAM_I2C0_SYNCBUSY (SAM_SERCOM0_BASE + SAM_I2C_SYNCBUSY_OFFSET)
#define SAM_I2C0_LENGTH (SAM_SERCOM0_BASE + SAM_I2C_LENGTH_OFFSET)
#define SAM_I2C0_ADDR (SAM_SERCOM0_BASE + SAM_I2C_ADDR_OFFSET)
#define SAM_I2C0_DATA (SAM_SERCOM0_BASE + SAM_I2C_DATA_OFFSET)
#define SAM_I2C1_CTRLA (SAM_SERCOM1_BASE + SAM_I2C_CTRLA_OFFSET)
#define SAM_I2C1_CTRLB (SAM_SERCOM1_BASE + SAM_I2C_CTRLB_OFFSET)
#define SAM_I2C1_CTRLC (SAM_SERCOM1_BASE + SAM_I2C_CTRLC_OFFSET)
#define SAM_I2C1_INTENCLR (SAM_SERCOM1_BASE + SAM_I2C_INTENCLR_OFFSET)
#define SAM_I2C1_INTENSET (SAM_SERCOM1_BASE + SAM_I2C_INTENSET_OFFSET)
#define SAM_I2C1_INTFLAG (SAM_SERCOM1_BASE + SAM_I2C_INTFLAG_OFFSET)
#define SAM_I2C1_STATUS (SAM_SERCOM1_BASE + SAM_I2C_STATUS_OFFSET)
#define SAM_I2C1_SYNCBUSY (SAM_SERCOM1_BASE + SAM_I2C_SYNCBUSY_OFFSET)
#define SAM_I2C1_LENGTH (SAM_SERCOM1_BASE + SAM_I2C_LENGTH_OFFSET)
#define SAM_I2C1_ADDR (SAM_SERCOM1_BASE + SAM_I2C_ADDR_OFFSET)
#define SAM_I2C1_DATA (SAM_SERCOM1_BASE + SAM_I2C_DATA_OFFSET)
#define SAM_I2C2_CTRLA (SAM_SERCOM2_BASE + SAM_I2C_CTRLA_OFFSET)
#define SAM_I2C2_CTRLB (SAM_SERCOM2_BASE + SAM_I2C_CTRLB_OFFSET)
#define SAM_I2C2_CTRLC (SAM_SERCOM2_BASE + SAM_I2C_CTRLC_OFFSET)
#define SAM_I2C2_INTENCLR (SAM_SERCOM2_BASE + SAM_I2C_INTENCLR_OFFSET)
#define SAM_I2C2_INTENSET (SAM_SERCOM2_BASE + SAM_I2C_INTENSET_OFFSET)
#define SAM_I2C2_INTFLAG (SAM_SERCOM2_BASE + SAM_I2C_INTFLAG_OFFSET)
#define SAM_I2C2_STATUS (SAM_SERCOM2_BASE + SAM_I2C_STATUS_OFFSET)
#define SAM_I2C2_SYNCBUSY (SAM_SERCOM2_BASE + SAM_I2C_SYNCBUSY_OFFSET)
#define SAM_I2C2_LENGTH (SAM_SERCOM2_BASE + SAM_I2C_LENGTH_OFFSET)
#define SAM_I2C2_ADDR (SAM_SERCOM2_BASE + SAM_I2C_ADDR_OFFSET)
#define SAM_I2C2_DATA (SAM_SERCOM2_BASE + SAM_I2C_DATA_OFFSET)
#define SAM_I2C3_CTRLA (SAM_SERCOM3_BASE + SAM_I2C_CTRLA_OFFSET)
#define SAM_I2C3_CTRLB (SAM_SERCOM3_BASE + SAM_I2C_CTRLB_OFFSET)
#define SAM_I2C3_CTRLC (SAM_SERCOM3_BASE + SAM_I2C_CTRLC_OFFSET)
#define SAM_I2C3_INTENCLR (SAM_SERCOM3_BASE + SAM_I2C_INTENCLR_OFFSET)
#define SAM_I2C3_INTENSET (SAM_SERCOM3_BASE + SAM_I2C_INTENSET_OFFSET)
#define SAM_I2C3_INTFLAG (SAM_SERCOM3_BASE + SAM_I2C_INTFLAG_OFFSET)
#define SAM_I2C3_STATUS (SAM_SERCOM3_BASE + SAM_I2C_STATUS_OFFSET)
#define SAM_I2C3_SYNCBUSY (SAM_SERCOM3_BASE + SAM_I2C_SYNCBUSY_OFFSET)
#define SAM_I2C3_LENGTH (SAM_SERCOM3_BASE + SAM_I2C_LENGTH_OFFSET)
#define SAM_I2C3_ADDR (SAM_SERCOM3_BASE + SAM_I2C_ADDR_OFFSET)
#define SAM_I2C3_DATA (SAM_SERCOM3_BASE + SAM_I2C_DATA_OFFSET)
#define SAM_I2C4_CTRLA (SAM_SERCOM4_BASE + SAM_I2C_CTRLA_OFFSET)
#define SAM_I2C4_CTRLB (SAM_SERCOM4_BASE + SAM_I2C_CTRLB_OFFSET)
#define SAM_I2C4_CTRLC (SAM_SERCOM4_BASE + SAM_I2C_CTRLC_OFFSET)
#define SAM_I2C4_INTENCLR (SAM_SERCOM4_BASE + SAM_I2C_INTENCLR_OFFSET)
#define SAM_I2C4_INTENSET (SAM_SERCOM4_BASE + SAM_I2C_INTENSET_OFFSET)
#define SAM_I2C4_INTFLAG (SAM_SERCOM4_BASE + SAM_I2C_INTFLAG_OFFSET)
#define SAM_I2C4_STATUS (SAM_SERCOM4_BASE + SAM_I2C_STATUS_OFFSET)
#define SAM_I2C4_SYNCBUSY (SAM_SERCOM4_BASE + SAM_I2C_SYNCBUSY_OFFSET)
#define SAM_I2C4_LENGTH (SAM_SERCOM4_BASE + SAM_I2C_LENGTH_OFFSET)
#define SAM_I2C4_ADDR (SAM_SERCOM4_BASE + SAM_I2C_ADDR_OFFSET)
#define SAM_I2C4_DATA (SAM_SERCOM4_BASE + SAM_I2C_DATA_OFFSET)
#define SAM_I2C5_CTRLA (SAM_SERCOM5_BASE + SAM_I2C_CTRLA_OFFSET)
#define SAM_I2C5_CTRLB (SAM_SERCOM5_BASE + SAM_I2C_CTRLB_OFFSET)
#define SAM_I2C5_CTRLC (SAM_SERCOM5_BASE + SAM_I2C_CTRLC_OFFSET)
#define SAM_I2C5_INTENCLR (SAM_SERCOM5_BASE + SAM_I2C_INTENCLR_OFFSET)
#define SAM_I2C5_INTENSET (SAM_SERCOM5_BASE + SAM_I2C_INTENSET_OFFSET)
#define SAM_I2C5_INTFLAG (SAM_SERCOM5_BASE + SAM_I2C_INTFLAG_OFFSET)
#define SAM_I2C5_STATUS (SAM_SERCOM5_BASE + SAM_I2C_STATUS_OFFSET)
#define SAM_I2C5_SYNCBUSY (SAM_SERCOM5_BASE + SAM_I2C_SYNCBUSY_OFFSET)
#define SAM_I2C5_LENGTH (SAM_SERCOM5_BASE + SAM_I2C_LENGTH_OFFSET)
#define SAM_I2C5_ADDR (SAM_SERCOM5_BASE + SAM_I2C_ADDR_OFFSET)
#define SAM_I2C5_DATA (SAM_SERCOM5_BASE + SAM_I2C_DATA_OFFSET)
#define SAM_I2C6_CTRLA (SAM_SERCOM6_BASE + SAM_I2C_CTRLA_OFFSET)
#define SAM_I2C6_CTRLB (SAM_SERCOM6_BASE + SAM_I2C_CTRLB_OFFSET)
#define SAM_I2C6_CTRLC (SAM_SERCOM6_BASE + SAM_I2C_CTRLC_OFFSET)
#define SAM_I2C6_INTENCLR (SAM_SERCOM6_BASE + SAM_I2C_INTENCLR_OFFSET)
#define SAM_I2C6_INTENSET (SAM_SERCOM6_BASE + SAM_I2C_INTENSET_OFFSET)
#define SAM_I2C6_INTFLAG (SAM_SERCOM6_BASE + SAM_I2C_INTFLAG_OFFSET)
#define SAM_I2C6_STATUS (SAM_SERCOM6_BASE + SAM_I2C_STATUS_OFFSET)
#define SAM_I2C6_SYNCBUSY (SAM_SERCOM6_BASE + SAM_I2C_SYNCBUSY_OFFSET)
#define SAM_I2C6_LENGTH (SAM_SERCOM6_BASE + SAM_I2C_LENGTH_OFFSET)
#define SAM_I2C6_ADDR (SAM_SERCOM6_BASE + SAM_I2C_ADDR_OFFSET)
#define SAM_I2C6_DATA (SAM_SERCOM6_BASE + SAM_I2C_DATA_OFFSET)
#define SAM_I2C7_CTRLA (SAM_SERCOM7_BASE + SAM_I2C_CTRLA_OFFSET)
#define SAM_I2C7_CTRLB (SAM_SERCOM7_BASE + SAM_I2C_CTRLB_OFFSET)
#define SAM_I2C7_CTRLC (SAM_SERCOM7_BASE + SAM_I2C_CTRLC_OFFSET)
#define SAM_I2C7_INTENCLR (SAM_SERCOM7_BASE + SAM_I2C_INTENCLR_OFFSET)
#define SAM_I2C7_INTENSET (SAM_SERCOM7_BASE + SAM_I2C_INTENSET_OFFSET)
#define SAM_I2C7_INTFLAG (SAM_SERCOM7_BASE + SAM_I2C_INTFLAG_OFFSET)
#define SAM_I2C7_STATUS (SAM_SERCOM7_BASE + SAM_I2C_STATUS_OFFSET)
#define SAM_I2C7_SYNCBUSY (SAM_SERCOM7_BASE + SAM_I2C_SYNCBUSY_OFFSET)
#define SAM_I2C7_LENGTH (SAM_SERCOM7_BASE + SAM_I2C_LENGTH_OFFSET)
#define SAM_I2C7_ADDR (SAM_SERCOM7_BASE + SAM_I2C_ADDR_OFFSET)
#define SAM_I2C7_DATA (SAM_SERCOM7_BASE + SAM_I2C_DATA_OFFSET)
/* I2C register bit definitions *************************************************************/
/* Control A register */
#define I2C_CTRLA_SWRST (1 << 0) /* Bit 0: Software reset */
#define I2C_CTRLA_ENABLE (1 << 1) /* Bit 1: Enable */
#define I2C_CTRLA_MODE_SHIFT (2) /* Bits 2-4: Operating Mode */
#define I2C_CTRLA_MODE_MASK (7 << I2C_CTRLA_MODE_SHIFT)
# define I2C_CTRLA_MODE_SLAVE (4 << I2C_CTRLA_MODE_SHIFT) /* I2C slave mode */
#define I2C_CTRLA_RUNSTDBY (1 << 7) /* Bit 7: Run in standby */
#define I2C_CTRLA_PINOUT (1 << 16) /* Bit 16: Pin usage */
# define I2C_CTRLA_1WIRE (0) /* 4-wire operation disabled */
# define I2C_CTRLA_4WIRE I2C_CTRLA_PINOUT /* 4-wire operation enabled */
#define I2C_CTRLA_SDAHOLD_SHIFT (20) /* Bits 20-21: SDA Hold Time */
#define I2C_CTRLA_SDAHOLD_MASK (3 << I2C_CTRLA_SDAHOLD_SHIFT)
# define I2C_CTRLA_SDAHOLD_DIS (0 << I2C_CTRLA_SDAHOLD_SHIFT) /* Disabled */
# define I2C_CTRLA_SDAHOLD_75NS (1 << I2C_CTRLA_SDAHOLD_SHIFT) /* 50-100ns hold time */
# define I2C_CTRLA_SDAHOLD_450NS (2 << I2C_CTRLA_SDAHOLD_SHIFT) /* 300-600ns hold time */
# define I2C_CTRLA_SDAHOLD_600NS (3 << I2C_CTRLA_SDAHOLD_SHIFT) /* 400-800ns hold time */
#define I2C_CTRLA_SEXTTOEN (1 << 23) /* Bit 23: Slave SCL low extend time-out */
#define I2C_CTRLA_SPEED_SHIFT (24) /* Bits 24-25: Trnasfer speed */
#define I2C_CTRLA_SPEED_MASK (3 << I2C_CTRLA_SPEED_SHIFT)
# define I2C_CTRLA_SPEED_STD (0 << I2C_CTRLA_SPEED_SHIFT) /* Standard (<=100KHz) fast <=400KHz */
# define I2C_CTRLA_SPEED_FAST (1 << I2C_CTRLA_SPEED_SHIFT) /* Fast-mode plase (<=1MHz) */
# define I2C_CTRLA_SPEED_HIGH (2 << I2C_CTRLA_SPEED_SHIFT) /* High-speed mode (<=3.4Mhz */
#define I2C_CTRLA_SCLSM (1 << 27) /* Bit 27: SCL clock stretch mode */
#define I2C_CTRLA_LOWTOUT (1 << 30) /* Bit 30: SCL Low Time-Out */
/* Control B register */
#define I2C_CTRLB_SMEN (1 << 8) /* Bit 8: Smart Mode Enable */
#define I2C_CTRLB_GCMD (1 << 9) /* Bit 9: PMBus group commend */
#define I2C_CTRLB_AACKEN (1 << 10) /* Bit 10: Automatic acknowledge enable */
#define I2C_CRLB_AMODE_SHIFT (14) /* Bits 14-15: Address Mode */
#define I2C_CRLB_AMODE_MASK (3 << I2C_CRLB_AMODE_SHIFT)
# define I2C_CRLB_AMODE_MASK (0 << I2C_CRLB_AMODE_SHIFT) /* ADDRMASK used to mask ADDR */
# define I2C_CRLB_AMODE_2ADDRS (1 << I2C_CRLB_AMODE_SHIFT) /* Slave 2 addresses: ADDR & ADDRMASK */
# define I2C_CRLB_AMODE_RANGE (2 << I2C_CRLB_AMODE_SHIFT) /* Slave range of addresses: ADDRMASK-ADDR */
#define I2C_CTRLB_CMD_SHIFT (16) /* Bits 16-17: Command */
#define I2C_CTRLB_CMD_MASK (3 << I2C_CTRLB_CMD_SHIFT)
# define I2C_CTRLB_CMD_NOACTION (0 << I2C_CTRLB_CMD_SHIFT) /* No action */
# define I2C_CTRLB_CMD_WAITSTART (2 << I2C_CTRLB_CMD_SHIFT) /* ACK (write) wait for START */
# define I2C_CTRLB_CMD_ACKREAD (3 << I2C_CTRLB_CMD_SHIFT) /* ACK with read (context dependent) */
#define I2C_CTRLB_ACKACT (1 << 18) /* Bit 18: Acknowledge Action */
# define I2C_CTRLB_ACK (0) /* Send ACK */
# define I2C_CTRLB_NCK I2C_CTRLB_ACKACT /* Send NACK */
/* Control C register */
#define I2C_CTRLC_SDASETUP_SHIFT (0) /* Bits 0-3: Inter-Character Spacing */
#define I2C_CTRLC_SDASETUP_MASK (15 << I2C_CTRLC_SDASETUP_SHIFT)
# define I2C_CTRLC_SDASETUP(n) ((uint32_t)(n) << I2C_CTRLC_SDASETUP_SHIFT)
#define I2C_CTRLC_DATA32B (1 << 24) /* Bit 24: Data 32 Bit */
# define I2C_CTRLC_DATA32B_8BIT (0) /* DATA register is 8-bit */
# define I2C_CTRLC_DATA32B_32BIT I2C_CTRLC_DATA32B /* DATA register is 32-bit */
/* Interrupt enable clear, interrupt enable set, interrupt enable set, interrupt flag and
* status clear registers.
*/
#define I2C_INT_PREC (1 << 0) /* Bit 0: Stop received interrupt */
#define I2C_INT_AMATCH (1 << 1) /* Bit 1: Address match interrupt */
#define I2C_INT_DRDY (1 << 2) /* Bit 2: Data ready interrupt */
#define I2C_INT_ERROR (1 << 7) /* Bit 7: Error interrupt */
#define I2C_INT_ALL (0x87)
/* Status register */
#define I2C_STATUS_BUSERR (1 << 0) /* Bit 0: Bus Error */
#define I2C_STATUS_COLL (1 << 1) /* Bit 1: Transmit Collision */
#define I2C_STATUS_RXNACK (1 << 2) /* Bit 2: Received Not Acknowledge */
#define I2C_STATUS_DIR (1 << 3) /* Bit 3: Read / Write Direction */
#define I2C_STATUS_SR (1 << 4) /* Bit 4: Repeated Start */
#define I2C_STATUS_LOWTOUT (1 << 6) /* Bit 6: SCL Low Time-out */
#define I2C_STATUS_CLKHOLD (1 << 7) /* Bit 7: Clock Hold */
#define I2C_STATUS_SEXTTOUT (1 << 9) /* Bit 9: Slave SCL Low Extend Time-Out */
#define I2C_STATUS_HS (1 << 10) /* Bit 10: High-speed */
#define I2C_STATUS_LENERR (1 << 11) /* Bit 11: Transaction Length Error */
/* Synchronization busy register */
#define I2C_SYNCBUSY_SWRST (1 << 0) /* Bit 0: Software reset synchronization busy */
#define I2C_SYNCBUSY_ENABLE (1 << 1) /* Bit 1: SERCOM enable synchronization busy */
#define I2C_SYNCBUSY_LENGTH (1 << 4) /* Bit 3: LENGTH synchronization busy */
/* Length register */
#define I2C_LENGTH_LEN_SHIFT (0) /* Bit 0-7: Data length enable */
#define I2C_LENGTH_LEN_MASK (0xff << I2C_LENGTH_LEN_SHIFT)
# define I2C_LENGTHLEN(n) ((uint32_t)(n) << I2C_LENGTH_LEN_SHIFT)
#define I2C_LENGTH_LENEN (1 << 8) /* Bit 8: Data Length Enable */
/* Address register */
#define I2C_ADDR_GENCEN (1 << 0) /* Bit 0: General Call Address Enable */
#define I2C_ADDR_SHIFT (1) /* Bits 1-10: Address */
#define I2C_ADDR_MASK (0x3ff << I2C_ADDR_SHIFT)
# define I2C_ADDR(n) ((uint32_t)(n) << I2C_ADDR_SHIFT)
#define I2C_ADDR_TENBITEN (1 << 15) /* Bit 15: */
#define I2C_ADDRMASK_SHIFT (17) /* Bits 17-26: Address Mask */
#define I2C_ADDRMASK_MASK (0x3ff << I2C_ADDRMASK_SHIFT)
# define I2C_ADDRMASK(n) ((uint32_t)(n) << I2C_ADDRMASK_SHIFT)
/* Data register (8- or 32-bit data) */
#define I2C_DATA_MASK (0xff) /* Bits 0-7: Data */
/********************************************************************************************
* Public Types
********************************************************************************************/
/********************************************************************************************
* Public Data
********************************************************************************************/
/********************************************************************************************
* Public Functions
********************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_I2C_SLAVE_H */

View File

@ -0,0 +1,205 @@
/************************************************************************************
* arch/arm/src/samd5e5/chip/sam_mclk.h
*
* Copyright (C) 2018 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_SAMD5E5_CHIP_SAM_MCLK_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_MCLK_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include "chip/sam_memorymap.h"
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* MCLK register offsets ************************************************************/
#define SAM_MCLK_CTRLA_OFFSET 0x0000 /* CTRLA register */
#define SAM_MCLK_INTENCLR_OFFSET 0x0001 /* Interrupt enable clear */
#define SAM_MCLK_INTENSET_OFFSET 0x0002 /* Interrupt enable set */
#define SAM_MCLK_INTFLAG_OFFSET 0x0003 /* Interrupt flag status and clear */
#define SAM_MCLK_HSDIV_OFFSET 0x0004 /* High-Speed Clock Division */
#define SAM_MCLK_CPUDIV_OFFSET 0x0005 /* CPU clock division */
/* 0x0006-0x000f: Reserved */
#define SAM_MCLK_AHBMASK_OFFSET 0x0010 /* AHB mask */
#define SAM_MCLK_APBAMASK_OFFSET 0x0014 /* APBA mask */
#define SAM_MCLK_APBBMASK_OFFSET 0x0018 /* APBB mask */
#define SAM_MCLK_APBCMASK_OFFSET 0x001c /* APBC mask */
#define SAM_MCLK_APBDMASK_OFFSET 0x0020 /* APBD mask */
/* MCLK register addresses **********************************************************/
#define SAM_MCLK_CTRLA (SAM_MCLK_BASE + SAM_MCLK_CTRLA_OFFSET)
#define SAM_MCLK_INTENCLR (SAM_MCLK_BASE + SAM_MCLK_INTENCLR_OFFSET)
#define SAM_MCLK_INTENSET (SAM_MCLK_BASE + SAM_MCLK_INTENSET_OFFSET)
#define SAM_MCLK_INTFLAG (SAM_MCLK_BASE + SAM_MCLK_INTFLAG_OFFSET)
#define SAM_MCLK_HSDIV (SAM_MCLK_BASE + SAM_MCLK_HSDIV_OFFSET)
#define SAM_MCLK_CPUDIV (SAM_MCLK_BASE + SAM_MCLK_CPUDIV_OFFSET)
#define SAM_MCLK_AHBMASK (SAM_MCLK_BASE + SAM_MCLK_AHBMASK_OFFSET)
#define SAM_MCLK_APBAMASK (SAM_MCLK_BASE + SAM_MCLK_APBAMASK_OFFSET)
#define SAM_MCLK_APBBMASK (SAM_MCLK_BASE + SAM_MCLK_APBBMASK_OFFSET)
#define SAM_MCLK_APBCMASK (SAM_MCLK_BASE + SAM_MCLK_APBCMASK_OFFSET)
#define SAM_MCLK_APBDMASK (SAM_MCLK_BASE + SAM_MCLK_APBDMASK_OFFSET)
/* MCLK register bit definitions ****************************************************/
/* CTRLA register -- All bits are reserved (?) */
/* Interrupt enable clear, Interrupt enable set, and Interrupt flag status and
* clear.
*/
#define MCLK_INT_CKRDY (1 << 0) /* Bit 0: Clock ready */
/* High-Speed Clock Division (8-bit value) */
/* CPU clock division (8-bit divider) */
#define MCLK_CPUDIV_DIV1 0x01
#define MCLK_CPUDIV_DIV2 0x02
#define MCLK_CPUDIV_DIV4 0x04
#define MCLK_CPUDIV_DIV8 0x08
#define MCLK_CPUDIV_DIV16 0x10
#define MCLK_CPUDIV_DIV32 0x20
#define MCLK_CPUDIV_DIV64 0x40
#define MCLK_CPUDIV_DIV128 0x80
/* AHB mask */
#define MCLK_AHBMASK_HPB0 (1 << 0) /* Bit 0: AHB HPB0 clock for enable */
#define MCLK_AHBMASK_HPB1 (1 << 1) /* Bit 1: AHB HPB1 clock enable */
#define MCLK_AHBMASK_HPB2 (1 << 2) /* Bit 2: AHB HPB2 clock enable */
#define MCLK_AHBMASK_HPB3 (1 << 3) /* Bit 3: AHB HPB3 clock enable */
#define MCLK_AHBMASK_DSU (1 << 4) /* Bit 4: DSU AHB clock enable */
/* Bit 5: Reserved */
#define MCLK_AHBMASK_NVMCTRL (1 << 6) /* Bit 6: NVMCTRL AHB clock enable */
/* Bit 7: Reserved */
#define MCLK_AHBMASK_CMCC (1 << 8) /* Bit 8: CMCC AHB Clock Enable */
#define MCLK_AHBMASK_DMAC (1 << 9) /* Bit 9: DMAC AHB clock enable */
#define MCLK_AHBMASK_USB (1 << 10) /* Bit 10: USB AHB clock enable */
/* Bit 11: Reserved */
#define MCLK_AHBMASK_PAC (1 << 12) /* Bit 12: PAC AHB clock enable */
#define MCLK_AHBMASK_QSPI (1 << 13) /* Bit 13: QSPI AHB Clock Enable */
#define MCLK_AHBMASK_GMAC (1 << 14) /* Bit 14: GMAC AHB Clock Enable */
#define MCLK_AHBMASK_SDHC0 (1 << 15) /* Bit 15: SDHC0 HB Clock Enable */
#define MCLK_AHBMASK_SDHC1 (1 << 16) /* Bit 16: SDHC1 HB Clock Enable */
#define MCLK_AHBMASK_CAN0 (1 << 17) /* Bit 17: CAN0 AHB Clock Enable */
#define MCLK_AHBMASK_CAN1 (1 << 18) /* Bit 18: CAN1 AHB Clock Enable */
#define MCLK_AHBMASK_ICM (1 << 19) /* Bit 19: ICM AHB Clock Enable */
#define MCLK_AHBMASK_PUKCC (1 << 20) /* Bit 20: PUKCC AHB Clock Enable */
#define MCLK_AHBMASK_QSPI2X (1 << 21) /* Bit 21: QSPI_2X AHB Clock Enable */
#define MCLK_AHBMASK_NVMCTRL_SMEEPROM (1 << 22) /* Bit 22: NVMCTRL_SMEEPROM AHB Clock Enable */
#define MCLK_AHBMASK_NVMCTRL_CACHE (1 << 23) /* Bit 23: NVMCTRL_CACHE AHB Clock Enable */
/* APBA mask */
#define MCLK_APBAMASK_PAC (1 << 1) /* Bit 0: PAC APBA Clock Enable */
#define MCLK_APBAMASK_PM (1 << 1) /* Bit 1: PM APBA clock enable */
#define MCLK_APBAMASK_MCLK (1 << 2) /* Bit 2: MCLK APBA clock enable */
#define MCLK_APBAMASK_RSTC (1 << 3) /* Bit 3: RSTC APBA clock enable */
#define MCLK_APBAMASK_OSCCTRL (1 << 4) /* Bit 4: OSCCTRL APBA clock enable */
#define MCLK_APBAMASK_OSC32KCTRL (1 << 5) /* Bit 5: OSC32KCTRL APBA clock enable */
#define MCLK_APBAMASK_SUPC (1 << 6) /* Bit 6: SUPC APBA clock enable */
#define MCLK_APBAMASK_GCLK (1 << 7) /* Bit 7: GCLK APBA clock enable */
#define MCLK_APBAMASK_WDT (1 << 8) /* Bit 8: WDT APBA clock enable */
#define MCLK_APBAMASK_RTC (1 << 9) /* Bit 9: RTC APBA clock enable */
#define MCLK_APBAMASK_EIC (1 << 10) /* Bit 10: EIC APBA clock enable */
#define MCLK_APBAMASK_FREQM (1 << 11) /* Bit 11: FREQM APBA clock enable */
#define MCLK_APBAMASK_SERCOM0 (1 << 12) /* Bit 12: SERCOM0 APBA Clock Enable */
#define MCLK_APBAMASK_SERCOM1 (1 << 13) /* Bit 13: SERCOM1 APBA Clock Enable */
#define MCLK_APBAMASK_TC0 (1 << 14) /* Bit 14: TC0 APBA clock enable */
#define MCLK_APBAMASK_TC1 (1 << 15) /* Bit 15: TC1 APBA clock enable */
/* APBB mask */
#define MCLK_APBBMASK_USB (1 << 0) /* Bit 0: USB APBB clock enable */
#define MCLK_APBBMASK_DSU (1 << 1) /* Bit 1: DSU APBB clock enable */
#define MCLK_APBBMASK_NVMCTRL (1 << 2) /* Bit 2: NVMCTRL APBB clock enable */
#define MCLK_APBBMASK_PORT (1 << 4) /* Bit 4: PORT APBB Clock Enable */
#define MCLK_APBBMASK_EVSYS (1 << 7) /* Bit 7: EVSYS APBB Clock Enable */
#define MCLK_APBBMASK_SERCOM2 (1 << 9) /* Bit 9: SERCOM2 APBB Clock Enable */
#define MCLK_APBBMASK_SERCOM3 (1 << 10) /* Bit 10: SERCOM3 APBB Clock Enable */
#define MCLK_APBBMASK_TCC0 (1 << 11) /* Bit 11: TCC2 APBB Clock Enable */
#define MCLK_APBBMASK_TCC1 (1 << 12) /* Bit 12: TCC3 APBB Clock Enable */
#define MCLK_APBBMASK_TC2 (1 << 13) /* Bit 13: TC2 APBB Clock Enable */
#define MCLK_APBBMASK_TC3 (1 << 14) /* Bit 14: TC3 APBB Clock Enable */
#define MCLK_APBBMASK_RAMECC (1 << 16) /* Bit 16: RAMECC APBB Clock Enable */
/* APBC mask */
#define MCLK_APBCMASK_GMAC (1 << 2) /* Bit 2: GMAC APBC Mask Clock Enable */
#define MCLK_APBCMASK_TCC2 (1 << 3) /* Bit 3: TCC2 APBC Clock Enable */
#define MCLK_APBCMASK_TCC3 (1 << 4) /* Bit 4: TCC3 APBC Clock Enable */
#define MCLK_APBCMASK_TC4 (1 << 5) /* Bit 5: TC4 APBC Clock Enable */
#define MCLK_APBCMASK_TC5 (1 << 6) /* Bit 6: TC5 APBC Clock Enable */
#define MCLK_APBCMASK_PDEC (1 << 7) /* Bit 7: PDEC APBC Mask Clock Enable */
#define MCLK_APBCMASK_AC (1 << 8) /* Bit 8: AC APBC Mask Clock Enable */
#define MCLK_APBCMASK_AES (1 << 9) /* Bit 9: AES APBC Mask Clock Enable */
#define MCLK_APBCMASK_TRNG (1 << 10) /* Bit 10: TRNG APBC Mask Clock Enable */
#define MCLK_APBCMASK_ICM (1 << 11) /* Bit 11: ICM APBC Mask Clock Enable */
#define MCLK_APBCMASK_QSPI (1 << 13) /* Bit 13: QSPI APBC Mask Clock Enable */
#define MCLK_APBCMASK_CCL (1 << 14) /* Bit 14: CCL APBC Mask Clock Enable */
/* APBD mask */
#define MCLK_APBDMASK_SERCOM4 (1 << 0) /* Bit 0: SERCOM4 APBD clock enable */
#define MCLK_APBDMASK_SERCOM5 (1 << 1) /* Bit 1: SERCOM5 APBD clock enable */
#define MCLK_APBDMASK_SERCOM6 (1 << 2) /* Bit 2: SERCOM6 APBD clock enable */
#define MCLK_APBDMASK_SERCOM7 (1 << 3) /* Bit 3: SERCOM7 APBD clock enable */
#define MCLK_APBDMASK_TCC4 (1 << 4) /* Bit 4: TCC5 APBD Clock Enable */
#define MCLK_APBDMASK_TC6 (1 << 5) /* Bit 5: TC6 APBD Clock Enable */
#define MCLK_APBDMASK_TC7 (1 << 6) /* Bit 6: TC7 APBD Clock Enable */
#define MCLK_APBDMASK_ADC0 (1 << 7) /* Bit 7: ADC0 APBD clock enable */
#define MCLK_APBDMASK_ADC1 (1 << 8) /* Bit 8: ADC1 APBD clock enable */
#define MCLK_APBDMASK_DAC (1 << 9) /* Bit 9: DAC APBD clock enable */
#define MCLK_APBDMASK_I2C (1 << 10) /* Bit 10: I2S APBD clock enable */
#define MCLK_APBDMASK_PCC (1 << 11) /* Bit 11: PCC APBD clock enable */
/************************************************************************************
* Public Types
************************************************************************************/
/************************************************************************************
* Public Data
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_MCLK_H */

View File

@ -0,0 +1,52 @@
/************************************************************************************
* arch/arm/src/samd5e5/chip/sam_memorymap.h
*
* Copyright (C) 2018 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_SAMD5E5_CHIP_SAM_MEMORYMAP_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_MEMORYMAP_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#if defined(CONFIG_ARCH_CHIP_SAMD5X) || defined(ARCH_CHIP_SAME5X)
# include "chip/samd5e5_memorymap.h"
#else
# error "Unsupported SAMD5/E5 family"
#endif
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_MEMORYMAP_H */

View File

@ -0,0 +1,253 @@
/********************************************************************************************
* arch/arm/src/samd5e5/chip/sam_nvmctrl.h
*
* Copyright (C) 2018 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_SAMD5E5_CHIP_SAM_NVMCTRL_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_NVMCTRL_H
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
#include "chip/sam_memorymap.h"
/********************************************************************************************
* Pre-processor Definitions
********************************************************************************************/
/* NVMCTRL register offsets *****************************************************************/
#define SAM_NVMCTRL_CTRLA_OFFSET 0x0000 /* Control A register */
#define SAM_NVMCTRL_CTRLB_OFFSET 0x0004 /* Control B register */
#define SAM_NVMCTRL_PARAM_OFFSET 0x0008 /* NVM parameter register */
#define SAM_NVMCTRL_INTENCLR_OFFSET 0x000c /* Interrupt clear register */
#define SAM_NVMCTRL_INTENSET_OFFSET 0x000e /* Interrupt set register */
#define SAM_NVMCTRL_INTFLAG_OFFSET 0x0010 /* Interface flags status and clear register */
#define SAM_NVMCTRL_STATUS_OFFSET 0x0012 /* Status register */
#define SAM_NVMCTRL_ADDR_OFFSET 0x0014 /* Address register */
#define SAM_NVMCTRL_RUNLOCK_OFFSET 0x0018 /* Lock section register */
#define SAM_NVMCTRL_PBLDATAn0_OFFSET 0x001c /* Page buffer load data n 0 */
#define SAM_NVMCTRL_PBLDATAn1_OFFSET 0x0020 /* Page buffer load data n 1 */
#define SAM_NVMCTRL_ECCERR_OFFSET 0x0024 /* ECC error status register */
#define SAM_NVMCTRL_DBGCTRL_OFFSET 0x0028 /* Debug control register */
#define SAM_NVMCTRL_SEECFG_OFFSET 0x002a /* SmartEEPROM configuration register */
#define SAM_NVMCTRL_SEESTAT_OFFSET 0x002c /* SmartEEPROM status register */
/* NVMCTRL register addresses ***************************************************************/
#define SAM_NVMCTRL_CTRLA (SAM_NVMCTRL_BASE + SAM_NVMCTRL_CTRLA_OFFSET)
#define SAM_NVMCTRL_CTRLB (SAM_NVMCTRL_BASE + SAM_NVMCTRL_CTRLB_OFFSET)
#define SAM_NVMCTRL_INTENCLR (SAM_NVMCTRL_BASE + SAM_NVMCTRL_INTENCLR_OFFSET)
#define SAM_NVMCTRL_INTENSET (SAM_NVMCTRL_BASE + SAM_NVMCTRL_INTENSET_OFFSET)
#define SAM_NVMCTRL_INTFLAG (SAM_NVMCTRL_BASE + SAM_NVMCTRL_INTFLAG_OFFSET)
#define SAM_NVMCTRL_STATUS (SAM_NVMCTRL_BASE + SAM_NVMCTRL_STATUS_OFFSET)
#define SAM_NVMCTRL_ADDR (SAM_NVMCTRL_BASE + SAM_NVMCTRL_ADDR_OFFSET)
#define SAM_NVMCTRL_RUNLOCK (SAM_NVMCTRL_BASE + SAM_NVMCTRL_RUNLOCK_OFFSET)
#define SAM_NVMCTRL_PBLDATAn0 (SAM_NVMCTRL_BASE + SAM_NVMCTRL_PBLDATAn0_OFFSET)
#define SAM_NVMCTRL_PBLDATAn1 (SAM_NVMCTRL_BASE + SAM_NVMCTRL_PBLDATAn1_OFFSET)
#define SAM_NVMCTRL_ECCERR (SAM_NVMCTRL_BASE + SAM_NVMCTRL_ECCERR_OFFSET)
#define SAM_NVMCTRL_DBGCTRL (SAM_NVMCTRL_BASE + SAM_NVMCTRL_DBGCTRL_OFFSET)
#define SAM_NVMCTRL_SEECFG (SAM_NVMCTRL_BASE + SAM_NVMCTRL_SEECFG_OFFSET)
#define SAM_NVMCTRL_SEESTAT (SAM_NVMCTRL_BASE + SAM_NVMCTRL_SEESTAT_OFFSET)
/* NVMCTRL register bit definitions *********************************************************/
/* Control A register */
#define NVMCTRL_CTRLA_AUTOWS (1 << 2) /* Bit 2: Auto Wait State Enable */
#define NVMCTRL_CTRLA_SUSPEN (1 << 3) /* Bit 3: Suspend Enable */
#define NVMCTRL_CTRLA_WMODE_SHIFT (4) /* Bits 4-5: NVMCTRL Write Mode */
#define NVMCTRL_CTRLA_WMODE_MASK (3 << NVMCTRL_CTRLA_WMODE_SHIFT)
# define NVMCTRL_CTRLA_WMODE_MAN (0 << NVMCTRL_CTRLA_WMODE_SHIFT) /* Manual Write */
# define NVMCTRL_CTRLA_WMODE_ADW (1 << NVMCTRL_CTRLA_WMODE_SHIFT) /* Automatic Double Word Write */
# define NVMCTRL_CTRLA_WMODE_AQW (2 << NVMCTRL_CTRLA_WMODE_SHIFT) /* Automatic Quad Word */
# define NVMCTRL_CTRLA_WMODE_AP (2 << NVMCTRL_CTRLA_WMODE_SHIFT) /* Automatic Page Write */
#define NVMCTRL_CTRLA_PRM_SHIFT (8) /* Bits 8-9: Power Reduction Mode during Sleep */
#define NVMCTRL_CTRLA_PRM_MASK (3 << NVMCTRL_CTRLA_PRM_SHIFT)
# define NVMCTRL_CTRLA_PRM_SEMIAUTO (0 << NVMCTRL_CTRLA_PRM_SHIFT) /* Enter low power on STANDBY/SPRM cmd;
* Exit on first access */
# define NVMCTRL_CTRLA_PRM_FULLAUTO (1 << NVMCTRL_CTRLA_PRM_SHIFT) /* Enter/Exit low power on STANDBY */
# define NVMCTRL_CTRLA_PRM_MANUAL (3 << NVMCTRL_CTRLA_PRM_SHIFT) /* Enter low power only on SPRM cmd;
* Exit on first access */
#define NVMCTRL_CTRLA_RWS_SHIFT (8) /* Bits 8-11: NVM Read Wait States */
#define NVMCTRL_CTRLA_RWS_MASK (15 << NVMCTRL_CTRLA_RWS_SHIFT)
# define NVMCTRL_CTRLA_RWS(n) ((uint32_t)(n) << NVMCTRL_CTRLA_RWS_SHIFT)
#define NVMCTRL_CTRLA_AHBNS0 (1 << 12) /* Bit 12: Force AHB0 access to Non-Sequential */
#define NVMCTRL_CTRLA_AHBNS1 (1 << 13) /* Bit 13: Force AHB1 access to Non-Sequential */
#define NVMCTRL_CTRLA_CACHEDIS0 (1 << 14) /* Bit 14: AHB0 Cache Disable */
#define NVMCTRL_CTRLA_CACHEDIS1 (1 << 15) /* Bit 15: AHB1 Cache Disable */
/* Control B register */
#define NVMCTRL_CTRLB_CMD_SHIFT (0) /* Bits 0-6: Command */
#define NVMCTRL_CTRLB_CMD_MASK (0x7f << NVMCTRL_CTRLB_CMD_SHIFT)
# define NVMCTRL_CTRLB_CMD_EP (0x00 << NVMCTRL_CTRLB_CMD_SHIFT) /* Erase Page */
# define NVMCTRL_CTRLB_CMD_EB (0x01 << NVMCTRL_CTRLB_CMD_SHIFT) /* Erase Block */
# define NVMCTRL_CTRLB_CMD_WP (0x03 << NVMCTRL_CTRLB_CMD_SHIFT) /* Write Page */
# define NVMCTRL_CTRLB_CMD_WQW (0x04 << NVMCTRL_CTRLB_CMD_SHIFT) /* Write Quad Word */
# define NVMCTRL_CTRLB_CMD_SRST (0x10 << NVMCTRL_CTRLB_CMD_SHIFT) /* Software reset */
# define NVMCTRL_CTRLB_CMD_LR (0x11 << NVMCTRL_CTRLB_CMD_SHIFT) /* Lock Region */
# define NVMCTRL_CTRLB_CMD_UR (0x12 << NVMCTRL_CTRLB_CMD_SHIFT) /* Unlock Region */
# define NVMCTRL_CTRLB_CMD_SPRM (0x13 << NVMCTRL_CTRLB_CMD_SHIFT) /* Set power reduction mode */
# define NVMCTRL_CTRLB_CMD_CPRM (0x14 << NVMCTRL_CTRLB_CMD_SHIFT) /* Clear power reduction mode */
# define NVMCTRL_CTRLB_CMD_PBC (0x15 << NVMCTRL_CTRLB_CMD_SHIFT) /* Page Buffer Clear */
# define NVMCTRL_CTRLB_CMD_SSB (0x16 << NVMCTRL_CTRLB_CMD_SHIFT) /* Set Security Bit */
# define NVMCTRL_CTRLB_CMD_BKSWRST (0x17 << NVMCTRL_CTRLB_CMD_SHIFT) /* Bank swap and system reset */
# define NVMCTRL_CTRLB_CMD_CELCK (0x18 << NVMCTRL_CTRLB_CMD_SHIFT) /* Chip Erase Lock */
# define NVMCTRL_CTRLB_CMD_CEULCK (0x19 << NVMCTRL_CTRLB_CMD_SHIFT) /* Chip Erase Lock */
# define NVMCTRL_CTRLB_CMD_SBPDIS (0x1a << NVMCTRL_CTRLB_CMD_SHIFT) /* Sets STATUS */
# define NVMCTRL_CTRLB_CMD_CBPDIS (0x1b << NVMCTRL_CTRLB_CMD_SHIFT) /* Clears STATUS */
# define NVMCTRL_CTRLB_CMD_ASEES0 (0x30 << NVMCTRL_CTRLB_CMD_SHIFT) /* Configure SmartEEPROM Sector 0 */
# define NVMCTRL_CTRLB_CMD_ASEES1 (0x31 << NVMCTRL_CTRLB_CMD_SHIFT) /* Configure SmartEEPROM Sector 1 */
# define NVMCTRL_CTRLB_CMD_SEERALOC (0x32 << NVMCTRL_CTRLB_CMD_SHIFT) /* SmartEEPROM sector reallocation */
# define NVMCTRL_CTRLB_CMD_SEEFLSUH (0x33 << NVMCTRL_CTRLB_CMD_SHIFT) /* Flush SmartEEPROM data1 */
# define NVMCTRL_CTRLB_CMD_LSEE (0x34 << NVMCTRL_CTRLB_CMD_SHIFT) /* Lock SmartEEPROM data */
# define NVMCTRL_CTRLB_CMD_USEE (0x35 << NVMCTRL_CTRLB_CMD_SHIFT) /* Unlock SmartEEPROM data*/
# define NVMCTRL_CTRLB_CMD_LSEER (0x36 << NVMCTRL_CTRLB_CMD_SHIFT) /* Lock SmartEEPROM registers */
# define NVMCTRL_CTRLB_CMD_USEER (0x37 << NVMCTRL_CTRLB_CMD_SHIFT) /* Unlock SmartEEPROM registers */
#define NVMCTRL_CTRLB_CMDEX_SHIFT (8) /* Bits 8-15: Command Execution */
#define NVMCTRL_CTRLB_CMDEX_MASK (0xff << NVMCTRL_CTRLB_CMDEX_SHIFT)
# define NVMCTRL_CTRLB_CMDEX_KEY (0xa5 << NVMCTRL_CTRLB_CMDEX_SHIFT)
/* NVM parameter register */
#define NVMCTRL_PARAM_NVMP_SHIFT (0) /* Bits 0-15: NVM Pages */
#define NVMCTRL_PARAM_NVMP_MASK (0xffff << NVMCTRL_PARAM_NVMP_SHIFT)
# define NVMCTRL_PARAM_NVMP(n) ((uint32_t)(n) << NVMCTRL_PARAM_NVMP_SHIFT)
#define NVMCTRL_PARAM_PSZ_SHIFT (16) /* Bits 16-18: Page Size */
#define NVMCTRL_PARAM_PSZ_MASK (7 << NVMCTRL_PARAM_PSZ_SHIFT)
# define NVMCTRL_PARAM_PSZ_8B (0 << NVMCTRL_PARAM_PSZ_SHIFT) /* 8 bytes */
# define NVMCTRL_PARAM_PSZ_16B (1 << NVMCTRL_PARAM_PSZ_SHIFT) /* 16 bytes */
# define NVMCTRL_PARAM_PSZ_32B (2 << NVMCTRL_PARAM_PSZ_SHIFT) /* 32 bytes */
# define NVMCTRL_PARAM_PSZ_64B (3 << NVMCTRL_PARAM_PSZ_SHIFT) /* 64 bytes */
# define NVMCTRL_PARAM_PSZ_128B (4 << NVMCTRL_PARAM_PSZ_SHIFT) /* 128 bytes */
# define NVMCTRL_PARAM_PSZ_256B (5 << NVMCTRL_PARAM_PSZ_SHIFT) /* 256 bytes */
# define NVMCTRL_PARAM_PSZ_512B (6 << NVMCTRL_PARAM_PSZ_SHIFT) /* 512 bytes */
# define NVMCTRL_PARAM_PSZ_1KB (7 << NVMCTRL_PARAM_PSZ_SHIFT) /* 1024 bytes */
#define NVMCTRL_PARAM_SEE_ (1 << 31) /* Bit 31: SmartEEPROM Supported */
/* Interrupt clear register */
/* Interrupt set register */
/* Interface flags status and clear register */
#define NVMCTRL_INT_DONE (1 << 0) /* Bit 0: Command done interrupt */
#define NVMCTRL_INT_ADDRE (1 << 1) /* Bit 1: Address error interrupt */
#define NVMCTRL_INT_PROGE (1 << 2) /* Bit 2: Programming Error Status */
#define NVMCTRL_INT_LOCKE (1 << 3) /* Bit 3: Lock Error Status */
#define NVMCTRL_INT_ECCSE (1 << 4) /* Bit 4: ECC single error interrupt */
#define NVMCTRL_INT_ECCDE (1 << 5) /* Bit 5: ECC dual error interrupt */
#define NVMCTRL_INT_NVME (1 << 6) /* Bit 6: NVM error interrupt */
#define NVMCTRL_INT_SUSP (1 << 7) /* Bit 7: Suspended write or erase interrupt */
#define NVMCTRL_INT_SEESFULL (1 << 8) /* Bit 8: Active SEES full interrupt */
#define NVMCTRL_INT_SEESOVF (1 << 9) /* Bit 9: Active SEES overflow interrupt */
#define NVMCTRL_INT_SEEWRC (1 << 10) /* Bit 10: SEE Write completed interrupt */
/* Status register */
#define NVMCTRL_STATUS_READY (1 << 0) /* Bit 0: Ready to accept a command */
#define NVMCTRL_STATUS_PRM (1 << 1) /* Bit 1: Power reduction mode */
#define NVMCTRL_STATUS_LOAD (1 << 2) /* Bit 2: NVM Page Buffer active loading */
#define NVMCTRL_STATUS_SUSP (1 << 3) /* Bit 3: NVM Write or erase operation suspended */
#define NVMCTRL_STATUS_AFIRST (1 << 4) /* Bit 2: BANKA first */
#define NVMCTRL_STATUS_BPDIS (1 << 5) /* Bit 5: Boot loader protection disable */
#define NVMCTRL_STATUS_BOOTPROT_SHIFT (8) /* Bits 8-11: Boot loader protection size */
#define NVMCTRL_STATUS_BOOTPROT_MASK (15 << NVMCTRL_STATUS_BOOTPROT_SHIFT)
# define NVMCTRL_STATUS_BOOTPROT(n) ((uint16_t)(n) << NVMCTRL_STATUS_BOOTPROT_SHIFT)
/* Address register */
#define NVMCTRL_ADDR_MASK (0x00ffffff) /* Bits 0-23: NVM Address */
/* Lock section register */
#define NVMCTRL_RUNLOCK_REGION(n) (1 << (n)) /* Region n is locked */
/* Page buffer load data n 0/1 (32-bit data) */
/* ECC error status register */
#define NVMCTRL_ECCERR_ADDR_SHIFT (0) /* Bits 0-23: Error address */
#define NVMCTRL_ECCERR_ADDR_MASK (0xffffff << NVMCTRL_ECCERR_ADDR_SHIFT)
# define NVMCTRL_ECCERR_ADDR(n) ((uint32_t)(n) << NVMCTRL_ECCERR_ADDR_SHIFT)
#define NVMCTRL_ECCERR_TYPEL_SHIFT (28) /* Bits 28-29: Low double-word error type */
#define NVMCTRL_ECCERR_TYPEL_MASK (3 << NVMCTRL_ECCERR_TYPEL_SHIFT)
# define NVMCTRL_ECCERR_TYPEL_NONE (0 << NVMCTRL_ECCERR_TYPEL_SHIFT) /* No error detected */
# define NVMCTRL_ECCERR_TYPEL_SINGLE (1 << NVMCTRL_ECCERR_TYPEL_SHIFT) /* Single error(s) detected */
# define NVMCTRL_ECCERR_TYPEL_DUAL (2 << NVMCTRL_ECCERR_TYPEL_SHIFT) /* Dual error(s) detected */
#define NVMCTRL_ECCERR_TYPEH_SHIFT (30) /* Bits 30-31: High double-word error type */
#define NVMCTRL_ECCERR_TYPEH_MASK (3 << NVMCTRL_ECCERR_TYPEH_SHIFT)
# define NVMCTRL_ECCERR_TYPEH_NONE (0 << NVMCTRL_ECCERR_TYPEH_SHIFT) /* No error detected */
# define NVMCTRL_ECCERR_TYPEH_SINGLE (1 << NVMCTRL_ECCERR_TYPEH_SHIFT) /* Single error(s) detected */
# define NVMCTRL_ECCERR_TYPEH_DUAL (2 << NVMCTRL_ECCERR_TYPEH_SHIFT) /* Dual error(s) detected */
/* Debug control register */
#define NVMCTRL_DBGCTRL_ECCDIS (1 << 0) /* Bit 0: Debugger ECC read disable */
#define NVMCTRL_DBGCTRL_ECCELOG (1 << 1) /* Bit 1: Debugger ECC error tracking mode */
/* SmartEEPROM configuration register */
#define NVMCTRL_SEECFG_WMODE (1 << 0) /* Bit 0: Write mode */
#define NVMCTRL_SEECFG_APRDIS (1 << 1) /* Bit 1: Automatic page reallocation disable */
/* SmartEEPROM status register */
#define NVMCTRL_SEESTAT_ASEES (1 << 0) /* Bit 0: Active SmartEEPROM Sector */
#define NVMCTRL_SEESTAT_LOAD (1 << 1) /* Bit 1: Page buffer loaded */
#define NVMCTRL_SEESTAT_BUSY (1 << 2) /* Bit 2: Busy */
#define NVMCTRL_SEESTAT_LOCK (1 << 3) /* Bit 3: SmartEEPROM section locked */
#define NVMCTRL_SEESTAT_RLOCK (1 << 4) /* Bit 4: RLOCK */
#define NVMCTRL_SEESTAT_SBLK_SHIFT (8) /* Bits 8-11: Blocks number in a sector */
#define NVMCTRL_SEESTAT_SBLK_MASK (15 << NVMCTRL_SEESTAT_SBLK_SHIFT)
# define NVMCTRL_SEESTAT_SBLK(n) ((uint32_t)(n) << NVMCTRL_SEESTAT_SBLK_SHIFT)
#define NVMCTRL_SEESTAT_PSZ_SHIFT (16) /* Bits 16-18: SmartEEPROM page size */
#define NVMCTRL_SEESTAT_PSZ_MASK (7 << NVMCTRL_SEESTAT_PSZ_SHIFT)
# define NVMCTRL_SEESTAT_PSZ(n) ((uint32_t)(n) << NVMCTRL_SEESTAT_PSZ_SHIFT)
/********************************************************************************************
* Public Types
********************************************************************************************/
/********************************************************************************************
* Public Data
********************************************************************************************/
/********************************************************************************************
* Public Functions
********************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_NVMCTRL_H */

View File

@ -0,0 +1,151 @@
/********************************************************************************************
* arch/arm/src/samd5e5/chip/sam_osc32kctrl.h
*
* Copyright (C) 2018 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_SAMD5E5_CHIP_SAM_OSC32KCTRL_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_OSC32KCTRL_H
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
#include "chip/sam_memorymap.h"
/********************************************************************************************
* Pre-processor Definitions
********************************************************************************************/
/* OSC32KCTRL register offsets **************************************************************/
#define SAM_OSC32KCTRL_INTENCLR_OFFSET 0x0000 /* Interrupt enable clear */
#define SAM_OSC32KCTRL_INTENSET_OFFSET 0x0004 /* Interrupt enable set */
#define SAM_OSC32KCTRL_INTFLAG_OFFSET 0x0008 /* Interrupt flag status and clear */
#define SAM_OSC32KCTRL_STATUS_OFFSET 0x000c /* Status */
#define SAM_OSC32KCTRL_RTCCTRL_OFFSET 0x0010 /* RTC clock selection */
#define SAM_OSC32KCTRL_XOSC32K_OFFSET 0x0014 /* 32kHz external crystal oscillator control */
#define SAM_OSC32KCTRL_CFDCTRL_OFFSET 0x0016 /* Clock Failure Detector Control */
#define SAM_OSC32KCTRL_EVCTRL_OFFSET 0x0017 /* Event Control */
#define SAM_OSC32KCTRL_OSCULP32K_OFFSET 0x001c /* 32kHz ultra low power internal oscillator control */
/* OSC32KCTRL register addresses ************************************************************/
#define SAM_OSC32KCTRL_INTENCLR (SAM_OSC32KCTRL_BASE + SAM_OSC32KCTRL_INTENCLR_OFFSET)
#define SAM_OSC32KCTRL_INTENSET (SAM_OSC32KCTRL_BASE + SAM_OSC32KCTRL_INTENSET_OFFSET)
#define SAM_OSC32KCTRL_INTFLAG (SAM_OSC32KCTRL_BASE + SAM_OSC32KCTRL_INTFLAG_OFFSET)
#define SAM_OSC32KCTRL_STATUS (SAM_OSC32KCTRL_BASE + SAM_OSC32KCTRL_STATUS_OFFSET)
#define SAM_OSC32KCTRL_RTCCTRL (SAM_OSC32KCTRL_BASE + SAM_OSC32KCTRL_RTCCTRL_OFFSET)
#define SAM_OSC32KCTRL_XOSC32K (SAM_OSC32KCTRL_BASE + SAM_OSC32KCTRL_XOSC32K_OFFSET)
#define SAM_OSC32KCTRL_CFDCTRL (SAM_OSC32KCTRL_BASE + SAM_OSC32KCTRL_CFDCTRL_OFFSET )
#define SAM_OSC32KCTRL_EVCTRL (SAM_OSC32KCTRL_BASE + SAM_OSC32KCTRL_EVCTRL_OFFSET )
#define SAM_OSC32KCTRL_OSCULP32K (SAM_OSC32KCTRL_BASE + SAM_OSC32KCTRL_OSCULP32K_OFFSET)
/* OSC32KCTRL register bit definitions ******************************************************/
/* Interrupt enable clear, Interrupt enable set, Interrupt flag status and clear, and
* status registers.
*/
#define OSC32KCTRL_INT_XOSC32KRDY (1 << 0) /* Bit 0: XOSC32K ready interrupt */
#define OSC32KCTRL_INT_XOSC32KFAIL (1 << 2) /* Bit 2: Clock failure detector interrupt */
#define OSC32KCTRL_STATUS_XOSC32KSW (1 << 3) /* Bit 3: XOSC32K Clock Switch */
#define OSC32KCTRL_INT_ALL (0x00000005)
/* RTC clock selection */
#define OSC32KCTRL_RTCCTRL_RTCSEL_SHIFT (0) /* Bits 0-2: RTC clock source selection */
#define OSC32KCTRL_RTCCTRL_RTCSEL_MASK (7 << OSC32KCTRL_RTCCTRL_RTCSEL_SHIFT)
# define OSC32KCTRL_RTCCTRL_RTCSEL_ULP1K (0 << OSC32KCTRL_RTCCTRL_RTCSEL_SHIFT) /* 1.024KHz from 32HKz internal ULP oscillator */
# define OSC32KCTRL_RTCCTRL_RTCSEL_ULP32K (1 << OSC32KCTRL_RTCCTRL_RTCSEL_SHIFT) /* 32.768KHz from 32KHz internal ULP oscillator */
# define OSC32KCTRL_RTCCTRL_RTCSEL_XOSC1K (4 << OSC32KCTRL_RTCCTRL_RTCSEL_SHIFT) /* 1.024kHz from 32KHz external oscillator */
# define OSC32KCTRL_RTCCTRL_RTCSEL_XOSC312K (5 << OSC32KCTRL_RTCCTRL_RTCSEL_SHIFT) /* 32.768KHz from 32KHz external crystal oscillator */
/* 32kHz external crystal oscillator control register */
#define OSC32KCTRL_XOSC32K_ENABLE (1 << 1) /* Bit 1: Oscillator enable */
#define OSC32KCTRL_XOSC32K_XTALEN (1 << 2) /* Bit 2: Crystal oscillator enable */
#define OSC32KCTRL_XOSC32K_EN32K (1 << 3) /* Bit 3: 32kHz Output enable */
#define OSC32KCTRL_XOSC32K_EN1K (1 << 4) /* Bit 4: 1kHz Output enable */
#define OSC32KCTRL_XOSC32K_RUNSTDBY (1 << 6) /* Bit 6: Run in standby */
#define OSC32KCTRL_XOSC32K_ONDEMAND (1 << 7) /* Bit 7: On demand control */
#define OSC32KCTRL_XOSC32K_STARTUP_SHIFT (8) /* Bits 8-10: Oscillator start-up time */
#define OSC32KCTRL_XOSC32K_STARTUP_MASK (7 << OSC32KCTRL_XOSC32K_STARTUP_SHIFT)
# define OSC32KCTRL_XOSC32K_STARTUP(n) ((n) << OSC32KCTRL_XOSC32K_STARTUP_SHIFT)
# define OSC32KCTRL_XOSC32K_STARTUP_63MS (0 << OSC32KCTRL_XOSC32K_STARTUP_SHIFT) /* 62.592 msec */
# define OSC32KCTRL_XOSC32K_STARTUP_125MS (1 << OSC32KCTRL_XOSC32K_STARTUP_SHIFT) /* 125.092 msec */
# define OSC32KCTRL_XOSC32K_STARTUP_500MS (2 << OSC32KCTRL_XOSC32K_STARTUP_SHIFT) /* 500.092 msec */
# define OSC32KCTRL_XOSC32K_STARTUP_1S (3 << OSC32KCTRL_XOSC32K_STARTUP_SHIFT) /* 1000.0092 msec */
# define OSC32KCTRL_XOSC32K_STARTUP_2S (4 << OSC32KCTRL_XOSC32K_STARTUP_SHIFT) /* 2000.0092 msec */
# define OSC32KCTRL_XOSC32K_STARTUP_4S (5 << OSC32KCTRL_XOSC32K_STARTUP_SHIFT) /* 4000.092 msec */
# define OSC32KCTRL_XOSC32K_STARTUP_8S (6 << OSC32KCTRL_XOSC32K_STARTUP_SHIFT) /* 8000.0092 msec */
#define OSC32KCTRL_XOSC32K_WRTLOCK (1 << 12) /* Bit 12: Write lock */
#define OSC32KCTRL_XOSC32K_GCM_SHIFT (13) /* Bits 13-14: Control Gain Mode */
#define OSC32KCTRL_XOSC32K_GCM_MASK (3 << OSC32KCTRL_XOSC32K_GCM_SHIFT)
# define OSC32KCTRL_XOSC32K_GCM_XT (1 << OSC32KCTRL_XOSC32K_GCM_SHIFT) /* Standard mode */
# define OSC32KCTRL_XOSC32K_GCM_HS (2 << OSC32KCTRL_XOSC32K_GCM_SHIFT) /* High Speed mode */
/* Clock Failure Detector Control */
#define OSC32KCTRL_CFDCTRL_CFDEN (1 << 0) /* Bit 0: Clock Failure Detector Enable */
#define OSC32KCTRL_CFDCTRL_SWBACK (1 << 1) /* Bit 1: Clock Switch Back */
#define OSC32KCTRL_CFDCTRL_CFDPRESC (1 << 2) /* Bit 2: Clock Failure Detector Prescaler */
/* Event Control */
#define OSC32KCTRL_EVCTRL_CFDEO (1 << 0) /* Bit 0: Clock Failure Detector Event Out Enable */
/* 32kHz ultra low power internal oscillator control register */
#define OSC32KCTRL_OSCULP32K_EN32K (1 << 0) /* Bit 0: 32kHz Output Enable */
#define OSC32KCTRL_OSCULP32K_EN1K (1 << 1) /* Bit 1: 1kHz Output Enable */
#define OSC32KCTRL_OSCULP32K_CALIB_SHIFT (8) /* Bits 8-13: Oscillator Calibration */
#define OSC32KCTRL_OSCULP32K_CALIB_MASK (0x3f << OSC32KCTRL_OSCULP32K_CALIB_SHIFT)
# define OSC32KCTRL_OSCULP32K_CALIB(n) ((uint16_t)(n) << OSC32KCTRL_OSCULP32K_CALIB_SHIFT)
#define OSC32KCTRL_OSCULP32K_WRTLOCK (1 << 15) /* Bit 15: Write Lock */
/********************************************************************************************
* Public Types
********************************************************************************************/
/********************************************************************************************
* Public Data
********************************************************************************************/
/********************************************************************************************
* Public Functions
********************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_OSC32KCTRL_H */

View File

@ -0,0 +1,311 @@
/********************************************************************************************
* arch/arm/src/samd5e5/chip/sam_oscctrl.h
*
* Copyright (C) 2018 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_SAMD5E5_CHIP_SAM_OSCCTRL_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_OSCCTRL_H
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
#include "chip/sam_memorymap.h"
/********************************************************************************************
* Pre-processor Definitions
********************************************************************************************/
/* OSCCTRL register offsets *****************************************************************/
#define SAM_OSCCTRL_EVCTRL_OFFSET 0x0000 /* Event Control */
#define SAM_OSCCTRL_INTENCLR_OFFSET 0x0004 /* Interrupt enable clear */
#define SAM_OSCCTRL_INTENSET_OFFSET 0x0008 /* Interrupt enable set */
#define SAM_OSCCTRL_INTFLAG_OFFSET 0x000c /* Interrupt flag status and clear */
#define SAM_OSCCTRL_STATUS_OFFSET 0x0010 /* Status */
#define SAM_OSCCTRL_XOSCCTRL0_OFFSET 0x0014 /* External multi-purpose crystal oscillator control 0 */
#define SAM_OSCCTRL_XOSCCTRL1_OFFSET 0x0018 /* External multi-purpose crystal oscillator control 1 */
#define SAM_OSCCTRL_DFLLCTRLA_OFFSET 0x001c /* DFLL48M Control A */
#define SAM_OSCCTRL_DFLLCTRLB_OFFSET 0x0020 /* DFLL48M Control B */
#define SAM_OSCCTRL_DFLLVAL_OFFSET 0x0024 /* DFLL48M value */
#define SAM_OSCCTRL_DFLLMUL_OFFSET 0x0028 /* DFLL48M multiplier */
#define SAM_OSCCTRL_DFLLSYNC_OFFSET 0x002c /* DFLL48M synchronization */
#define SAM_OSCCTRL_DPLL0CTRLA_OFFSET 0x0030 /* DPLL0 control A */
#define SAM_OSCCTRL_DPLL0RATIO_OFFSET 0x0034 /* DPLL0 ratio control */
#define SAM_OSCCTRL_DPLL0CTRLB_OFFSET 0x0038 /* DPLL0 control B */
#define SAM_OSCCTRL_DPLL0SYNCBUSY_OFFSET 0x003c /* DPLL0 synchronization busy */
#define SAM_OSCCTRL_DPLL0STATUS_OFFSET 0x0040 /* DPLL0 status */
#define SAM_OSCCTRL_DPLL1CTRLA_OFFSET 0x0044 /* DPLL1 control A */
#define SAM_OSCCTRL_DPLL1RATIO_OFFSET 0x0048 /* DPLL1 ratio control */
#define SAM_OSCCTRL_DPLL1CTRLB_OFFSET 0x004c /* DPLL1 control B */
#define SAM_OSCCTRL_DPLL1SYNCBUSY_OFFSET 0x0050 /* DPLL1 synchronization busy */
#define SAM_OSCCTRL_DPLL1STATUS_OFFSET 0x0054 /* DPLL1 status */
/* OSCCTRL register addresses ***************************************************************/
#define SAM_OSCCTRL_EVCTRL (SAM_OSCCTRL_BASE + SAM_OSCCTRL_EVCTRL_OFFSET)
#define SAM_OSCCTRL_INTENCLR (SAM_OSCCTRL_BASE + SAM_OSCCTRL_INTENCLR_OFFSET)
#define SAM_OSCCTRL_INTENSET (SAM_OSCCTRL_BASE + SAM_OSCCTRL_INTENSET_OFFSET)
#define SAM_OSCCTRL_INTFLAG (SAM_OSCCTRL_BASE + SAM_OSCCTRL_INTFLAG_OFFSET)
#define SAM_OSCCTRL_STATUS (SAM_OSCCTRL_BASE + SAM_OSCCTRL_STATUS_OFFSET)
#define SAM_OSCCTRL_XOSCCTRL0 (SAM_OSCCTRL_BASE + SAM_OSCCTRL_XOSCCTRL0_OFFSET)
#define SAM_OSCCTRL_XOSCCTRL1 (SAM_OSCCTRL_BASE + SAM_OSCCTRL_XOSCCTRL1_OFFSET)
#define SAM_OSCCTRL_DFLLCTRLA (SAM_OSCCTRL_BASE + SAM_OSCCTRL_DFLLCTRLA_OFFSET)
#define SAM_OSCCTRL_DFLLCTRLB (SAM_OSCCTRL_BASE + SAM_OSCCTRL_DFLLCTRLB_OFFSET)
#define SAM_OSCCTRL_DFLLVAL (SAM_OSCCTRL_BASE + SAM_OSCCTRL_DFLLVAL_OFFSET)
#define SAM_OSCCTRL_DFLLMUL (SAM_OSCCTRL_BASE + SAM_OSCCTRL_DFLLMUL_OFFSET)
#define SAM_OSCCTRL_DFLLSYNC (SAM_OSCCTRL_BASE + SAM_OSCCTRL_DFLLSYNC_OFFSET)
#define SAM_OSCCTRL_DPLL0CTRLA (SAM_OSCCTRL_BASE + SAM_OSCCTRL_DPLL0CTRLA_OFFSET)
#define SAM_OSCCTRL_DPLL0RATIO (SAM_OSCCTRL_BASE + SAM_OSCCTRL_DPLL0RATIO_OFFSET)
#define SAM_OSCCTRL_DPLL0CTRLB (SAM_OSCCTRL_BASE + SAM_OSCCTRL_DPLL0CTRLB_OFFSET)
#define SAM_OSCCTRL_DPLLPRESC (SAM_OSCCTRL_BASE + SAM_OSCCTRL_DPLLPRESC_OFFSET)
#define SAM_OSCCTRL_DPLL0SYNCBUSY (SAM_OSCCTRL_BASE + SAM_OSCCTRL_DPLL0SYNCBUSY_OFFSET)
#define SAM_OSCCTRL_DPLL0STATUS (SAM_OSCCTRL_BASE + SAM_OSCCTRL_DPLL0STATUS_OFFSET)
#define SAM_OSCCTRL_DPLL1CTRLA (SAM_OSCCTRL_BASE + SAM_OSCCTRL_DPLL1CTRLA_OFFSET)
#define SAM_OSCCTRL_DPLL1RATIO (SAM_OSCCTRL_BASE + SAM_OSCCTRL_DPLL1RATIO_OFFSET)
#define SAM_OSCCTRL_DPLL1CTRLB (SAM_OSCCTRL_BASE + SAM_OSCCTRL_DPLL1CTRLB_OFFSET)
#define SAM_OSCCTRL_DPLLPRESC (SAM_OSCCTRL_BASE + SAM_OSCCTRL_DPLLPRESC_OFFSET)
#define SAM_OSCCTRL_DPLL1SYNCBUSY (SAM_OSCCTRL_BASE + SAM_OSCCTRL_DPLL1SYNCBUSY_OFFSET)
#define SAM_OSCCTRL_DPLL1STATUS (SAM_OSCCTRL_BASE + SAM_OSCCTRL_DPLL1STATUS_OFFSET)
/* OSCCTRL register bit definitions *********************************************************/
/* Event Control */
#define OSCCTRL_EVCTRL_CFDEO0 (1 << 0) /* Bit 0: Clock 0 failure detector event output enable */
#define OSCCTRL_EVCTRL_CFDEO1 (1 << 1) /* Bit 1: Clock 1 failure detector event output enable */
/* Interrupt enable clear, Interrupt enable set, Interrupt flag status and clear, and
* Status registers.
*/
#define OSCCTRL_INT_XOSCRDY0 (1 << 0) /* Bit 0: XOSC 0 ready interrupt */
#define OSCCTRL_INT_XOSCRDY1 (1 << 1) /* Bit 1: XOSC 1 ready interrupt */
#define OSCCTRL_INT_XOSCFAIL0 (1 << 2) /* Bit 2: XOSC 0 clock failure interrupt */
#define OSCCTRL_INT_XOSCFAIL1 (1 << 3) /* Bit 3: XOSC 1 clock failure interrupt */
#define OSCCTRL_STATUS_XOSCCKSW0 (1 << 4) /* Bit 4: XOSC 1 clock failure interrupt (status) */
#define OSCCTRL_STATUS_XOSCCKSW1 (1 << 5) /* Bit 5: XOSC 1 clock failure interrupt (status) */
#define OSCCTRL_INT_DFLLRDY (1 << 8) /* Bit 8: DFLL ready interrupt */
#define OSCCTRL_INT_DFLLOOB (1 << 9) /* Bit 9: DFLL out of bounds interrupt */
#define OSCCTRL_INT_DFLLLCKF (1 << 10) /* Bit 10: DFLL lock fine interrupt */
#define OSCCTRL_INT_DFLLLCKC (1 << 11) /* Bit 11: DFLL lock coarse interrupt */
#define OSCCTRL_INT_DFLLRCS (1 << 12) /* Bit 12: DFLL reference clock stopped interrupt */
#define OSCCTRL_INT_DPLL0LCKR (1 << 16) /* Bit 16: DPLL0 lock rise interrupt */
#define OSCCTRL_INT_DPLL0LCKF (1 << 17) /* Bit 17: DPLL0 lock fall interrupt */
#define OSCCTRL_INT_DPLL0LTO (1 << 18) /* Bit 18: DPLL0 lock timeout */
#define OSCCTRL_INT_DPLL0DRTO (1 << 19) /* Bit 19: DPLL0 loop divider ratio update complete */
#define OSCCTRL_INT_DPLL1LCKR (1 << 24) /* Bit 24: DPLL1 lock rise interrupt */
#define OSCCTRL_INT_DPLL1LCKF (1 << 25) /* Bit 25: DPLL1 lock fall interrupt */
#define OSCCTRL_INT_DPLL1LTO (1 << 26) /* Bit 26: DPLL1 lock timeout */
#define OSCCTRL_INT_DPLL1DRTO (1 << 27) /* Bit 27: DPLL1 loop divider ratio update complete */
#define OSCCTRL_INT_ALL (0x0f0f1f0f)
/* External multi-purpose crystal oscillator control register 0/1 */
#define OSCCTRL_XOSCCTRL_ENABLE (1 << 1) /* Bit 1: Oscillator enable */
#define OSCCTRL_XOSCCTRL_XTALEN (1 << 2) /* Bit 2: Crystal oscillator enable */
#define OSCCTRL_XOSCCTRL_RUNSTDBY (1 << 6) /* Bit 6: Run in standby */
#define OSCCTRL_XOSCCTRL_ONDEMAND (1 << 7) /* Bit 7: On demand control */
#define OSCCTRL_XOSCCTRL_LOWBUFGAIN (1 << 8) /* Bit 8: Low buffer gain enable */
#define OSCCTRL_XOSCCTRL_IPTAT_SHIFT (9) /* Bits 9-10: Oscillator current reference */
#define OSCCTRL_XOSCCTRL_IPTAT_MASK (3 << OSCCTRL_XOSCCTRL_IPTAT_SHIFT)
# define OSCCTRL_XOSCCTRL_IPTAT(n) ((uint32_t)(n) << OSCCTRL_XOSCCTRL_IPTAT_SHIFT)
#define OSCCTRL_XOSCCTRL_IMULT_SHIFT (11) /* Bits 11-14: Oscillator current reference */
#define OSCCTRL_XOSCCTRL_IMULT_MASK (15 << OSCCTRL_XOSCCTRL_IMULT_SHIFT)
# define OSCCTRL_XOSCCTRL_IMULT(n) ((uint32_t)(n) << OSCCTRL_XOSCCTRL_IMULT_SHIFT)
#define OSCCTRL_XOSCCTRL_ENALC (1 << 15) /* Bit 15: Automatic loop control enable */
#define OSCCTRL_XOSCCTRL_CFDEN (1 << 16) /* Bit 16: Clock failure detector enable */
#define OSCCTRL_XOSCCTRL_SWBEN (1 << 17) /* Bit 17: XOSC clock switch enable */
#define OSCCTRL_XOSCCTRL_STARTUP_SHIFT (20) /* Bits 20-23: Start-up time */
#define OSCCTRL_XOSCCTRL_STARTUP_MASK (15 << OSCCTRL_XOSCCTRL_STARTUP_SHIFT)
# define OSCCTRL_XOSCCTRL_STARTUP(n) ((n) << OSCCTRL_XOSCCTRL_STARTUP_SHIFT)
# define OSCCTRL_XOSCCTRL_STARTUP_31US (0 << OSCCTRL_XOSCCTRL_STARTUP_SHIFT) /* 31µs */
# define OSCCTRL_XOSCCTRL_STARTUP_61US (1 << OSCCTRL_XOSCCTRL_STARTUP_SHIFT) /* 61µs */
# define OSCCTRL_XOSCCTRL_STARTUP_122US (2 << OSCCTRL_XOSCCTRL_STARTUP_SHIFT) /* 122µs */
# define OSCCTRL_XOSCCTRL_STARTUP_244US (3 << OSCCTRL_XOSCCTRL_STARTUP_SHIFT) /* 244µs */
# define OSCCTRL_XOSCCTRL_STARTUP_488US (4 << OSCCTRL_XOSCCTRL_STARTUP_SHIFT) /* 488µs */
# define OSCCTRL_XOSCCTRL_STARTUP_977US (5 << OSCCTRL_XOSCCTRL_STARTUP_SHIFT) /* 977µs */
# define OSCCTRL_XOSCCTRL_STARTUP_2MS (6 << OSCCTRL_XOSCCTRL_STARTUP_SHIFT) /* 1953µs */
# define OSCCTRL_XOSCCTRL_STARTUP_4MS (7 << OSCCTRL_XOSCCTRL_STARTUP_SHIFT) /* 3906µs */
# define OSCCTRL_XOSCCTRL_STARTUP_8MS (8 << OSCCTRL_XOSCCTRL_STARTUP_SHIFT) /* 7813µs */
# define OSCCTRL_XOSCCTRL_STARTUP_16MS (9 << OSCCTRL_XOSCCTRL_STARTUP_SHIFT) /* 15625µs */
# define OSCCTRL_XOSCCTRL_STARTUP_31MS (10 << OSCCTRL_XOSCCTRL_STARTUP_SHIFT) /* 31250µs */
# define OSCCTRL_XOSCCTRL_STARTUP_63MS (11 << OSCCTRL_XOSCCTRL_STARTUP_SHIFT) /* 62500µs */
# define OSCCTRL_XOSCCTRL_STARTUP_125MS (12 << OSCCTRL_XOSCCTRL_STARTUP_SHIFT) /* 125000µs */
# define OSCCTRL_XOSCCTRL_STARTUP_250MS (13 << OSCCTRL_XOSCCTRL_STARTUP_SHIFT) /* 250000µs */
# define OSCCTRL_XOSCCTRL_STARTUP_500MS (14 << OSCCTRL_XOSCCTRL_STARTUP_SHIFT) /* 500000µs */
# define OSCCTRL_XOSCCTRL_STARTUP_1S (15 << OSCCTRL_XOSCCTRL_STARTUP_SHIFT) /* 1000000µs */
/* DFLL48M control register A */
#define OSCCTRL_DFLLCTRLA_ENABLE (1 << 1) /* Bit 1: DFLL enable */
#define OSCCTRL_DFLLCTRLA_RUNSTDBY (1 << 6) /* Bit 6: Run in standby */
#define OSCCTRL_DFLLCTRLA_ONDEMAND (1 << 7) /* Bit 7: On demand control */
/* DFLL48M control register B */
#define OSCCTRL_DFLLCTRLB_MODE (1 << 0) /* Bit 0: Operating mode selection */
#define OSCCTRL_DFLLCTRLB_STABLE (1 << 1) /* Bit 1: Stable DFLL frequency */
#define OSCCTRL_DFLLCTRLB_LLAW (1 << 2) /* Bit 2: Lose lock after wake */
#define OSCCTRL_DFLLCTRLB_USBCRM (1 << 3) /* Bit 3: USB clock recovery mode */
#define OSCCTRL_DFLLCTRLB_CCDIS (1 << 4) /* Bit 4: Chill cycle disable */
#define OSCCTRL_DFLLCTRLB_QLDIS (1 << 5) /* Bit 5: Quick Lock Disable */
#define OSCCTRL_DFLLCTRLB_BPLCKC (1 << 6) /* Bit 6: Bypass coarse clock */
#define OSCCTRL_DFLLCTRLB_WAITLOCK (1 << 7) /* Bit 7: Wait lock */
/* DFLL48M value register */
#define OSCCTRL_DFLLVAL_FINE_SHIFT (0) /* Bits 0-7: Fine value */
#define OSCCTRL_DFLLVAL_FINE_MASK (0xff << OSCCTRL_DFLLVAL_FINE_SHIFT)
# define OSCCTRL_DFLLVAL_FINE(n) ((uint32_t)(n) << OSCCTRL_DFLLVAL_FINE_SHIFT)
#define OSCCTRL_DFLLVAL_COARSE_SHIFT (10) /* Bits 10-15: Coarse value */
#define OSCCTRL_DFLLVAL_COARSE_MASK (0x3f << OSCCTRL_DFLLVAL_COARSE_SHIFT)
# define OSCCTRL_DFLLVAL_COARSE(n) ((uint32_t)(n) << OSCCTRL_DFLLVAL_COARSE_SHIFT)
#define OSCCTRL_DFLLVAL_DIFF_SHIFT (16) /* Bits 16-31: Multiplication ratio difference */
#define OSCCTRL_DFLLVAL_DIFF_MASK (0xffff << OSCCTRL_DFLLVAL_DIFF_SHIFT)
# define OSCCTRL_DFLLVAL_DIFF(n) ((n) << OSCCTRL_DFLLVAL_DIFF_SHIFT)
/* DFLL48M multiplier register */
#define OSCCTRL_DFLLMUL_MUL_SHIFT (0) /* Bits 0-15: DFLL multiply factor */
#define OSCCTRL_DFLLMUL_MUL_MASK (0xffff << OSCCTRL_DFLLMUL_MUL_SHIFT)
# define OSCCTRL_DFLLMUL_MUL(n) ((uint32_t)(n) << OSCCTRL_DFLLMUL_MUL_SHIFT)
#define OSCCTRL_DFLLMUL_FSTEP_SHIFT (16) /* Bits 16-23: Fine maximum step */
#define OSCCTRL_DFLLMUL_FSTEP_MASK (0xff << OSCCTRL_DFLLMUL_FSTEP_SHIFT)
# define OSCCTRL_DFLLMUL_FSTEP(n) ((uint32_t)(n) << OSCCTRL_DFLLMUL_FSTEP_SHIFT)
#define OSCCTRL_DFLLMUL_CSTEP_SHIFT (26) /* Bits 26-31: Coarse maximum step */
#define OSCCTRL_DFLLMUL_CSTEP_MASK (0x3f << OSCCTRL_DFLLMUL_CSTEP_SHIFT)
# define OSCCTRL_DFLLMUL_CSTEP(n) ((uint32_t)(n) << OSCCTRL_DFLLMUL_CSTEP_SHIFT)
/* DFLL48M synchronization register */
#define OSCCTRL_DFLLSYNC_ENABLE (1 << 1) /* Bit 1: ENABLE Synchronization Busy */
#define OSCCTRL_DFLLSYNC_DFLLCTRLB (1 << 2) /* Bit 2: DFLLCTRLB Synchronization Busy */
#define OSCCTRL_DFLLSYNC_DFLLVAL (1 << 3) /* Bit 3: DFLLVAL Synchronization Busy */
#define OSCCTRL_DFLLSYNC_REDFLLMULADREQ (1 << 4) /* Bit 4: DFLLMUL Synchronization Busy */
/* DPLL0/1 control A */
#define OSCCTRL_DPLLCTRLA_ENABLE (1 << 1) /* Bit 1: DPLL enable */
#define OSCCTRL_DPLLCTRLA_RUNSTDBY (1 << 6) /* Bit 6: Run in standby */
#define OSCCTRL_DPLLCTRLA_ONDEMAND (1 << 7) /* Bit 7: On demand clock activation */
/* DPLL0/1 ratio control */
#define OSCCTRL_DPLLRATIO_LDR_SHIFT (0) /* Bits 0-11: Loop divider ratio */
#define OSCCTRL_DPLLRATIO_LDR_MASK (0x1fff << OSCCTRL_DPLLRATIO_LDR_SHIFT)
# define OSCCTRL_DPLLRATIO_LDR(n) ((uint32_t)(n) << OSCCTRL_DPLLRATIO_LDR_SHIFT)
#define OSCCTRL_DPLLRATIO_LDRFRAC_SHIFT (16) /* Bits 16-20: Loop divider fractional part */
#define OSCCTRL_DPLLRATIO_LDRFRAC_MASK (31 << OSCCTRL_DPLLRATIO_LDRFRAC_SHIFT)
# define OSCCTRL_DPLLRATIO_LDRFRAC(n) ((uint32_t)(n) << OSCCTRL_DPLLRATIO_LDRFRAC_SHIFT)
/* DPLL0/1 control B */
#define OSCCTRL_DPLLCTRLB_FILTER_SHIFT (0) /* Bits 0-3: Proportional integer filter selection */
#define OSCCTRL_DPLLCTRLB_FILTER_MASK (15 << OSCCTRL_DPLLCTRLB_FILTER_SHIFT)
# define OSCCTRL_DPLLCTRLB_FILTER(n) ((uint32_t)(n) << OSCCTRL_DPLLCTRLB_FILTER_SHIFT)
/* PLL BW Damping */
# define OSCCTRL_DPLLCTRLB_FILTER0 (0 << OSCCTRL_DPLLCTRLB_FILTER_SHIFT) /* 92.7 kHz 0.76 */
# define OSCCTRL_DPLLCTRLB_FILTER1 (1 << OSCCTRL_DPLLCTRLB_FILTER_SHIFT) /* 131 kHz 1.08 */
# define OSCCTRL_DPLLCTRLB_FILTER2 (2 << OSCCTRL_DPLLCTRLB_FILTER_SHIFT) /* 46.4 kHz 0.38 */
# define OSCCTRL_DPLLCTRLB_FILTER3 (3 << OSCCTRL_DPLLCTRLB_FILTER_SHIFT) /* 65.6 kHz 0.54 */
# define OSCCTRL_DPLLCTRLB_FILTER4 (4 << OSCCTRL_DPLLCTRLB_FILTER_SHIFT) /* 131 kHz 0.56 */
# define OSCCTRL_DPLLCTRLB_FILTER5 (5 << OSCCTRL_DPLLCTRLB_FILTER_SHIFT) /* 185 kHz 0.79 */
# define OSCCTRL_DPLLCTRLB_FILTER6 (6 << OSCCTRL_DPLLCTRLB_FILTER_SHIFT) /* 65.6 kHz 0.28 */
# define OSCCTRL_DPLLCTRLB_FILTER7 (7 << OSCCTRL_DPLLCTRLB_FILTER_SHIFT) /* 92.7 kHz 0.39 */
# define OSCCTRL_DPLLCTRLB_FILTER8 (8 << OSCCTRL_DPLLCTRLB_FILTER_SHIFT) /* 46.4 kHz 1.49 */
# define OSCCTRL_DPLLCTRLB_FILTER9 (9 << OSCCTRL_DPLLCTRLB_FILTER_SHIFT) /* 65.6 kHz 2.11 */
# define OSCCTRL_DPLLCTRLB_FILTER10 (10 << OSCCTRL_DPLLCTRLB_FILTER_SHIFT) /* 23.2 kHz 0.75 */
# define OSCCTRL_DPLLCTRLB_FILTER11 (11 << OSCCTRL_DPLLCTRLB_FILTER_SHIFT) /* 32.8 kHz 1.06 */
# define OSCCTRL_DPLLCTRLB_FILTER12 (12 << OSCCTRL_DPLLCTRLB_FILTER_SHIFT) /* 65.6 kHz 1.07 */
# define OSCCTRL_DPLLCTRLB_FILTER13 (13 << OSCCTRL_DPLLCTRLB_FILTER_SHIFT) /* 92.7 kHz 1.51 */
# define OSCCTRL_DPLLCTRLB_FILTER14 (14 << OSCCTRL_DPLLCTRLB_FILTER_SHIFT) /* 32.8 kHz 0.53 */
# define OSCCTRL_DPLLCTRLB_FILTER15 (15 << OSCCTRL_DPLLCTRLB_FILTER_SHIFT) /* 46.4 kHz 0.75 */
#define OSCCTRL_DPLLCTRLB_WUF (1 << 4) /* Bit 4: Wake up fast */
#define OSCCTRL_DPLLCTRLB_REFLCK_SHIFT (5) /* Bits 5-7: Reference clock selection */
#define OSCCTRL_DPLLCTRLB_REFLCK_MASK (3 << OSCCTRL_DPLLCTRLB_REFLCK_SHIFT)
# define OSCCTRL_DPLLCTRLB_REFLCK_GLCK (0 << OSCCTRL_DPLLCTRLB_REFLCK_SHIFT) /* Dedicated GCLK clock reference */
# define OSCCTRL_DPLLCTRLB_REFLCK_XOSC32 (1 << OSCCTRL_DPLLCTRLB_REFLCK_SHIFT) /* XOSC32K clock reference (default) */
# define OSCCTRL_DPLLCTRLB_REFLCK_XOSC0 (2 << OSCCTRL_DPLLCTRLB_REFLCK_SHIFT) /* XOSC0 clock reference */
# define OSCCTRL_DPLLCTRLB_REFLCK_XOSC1 (3 << OSCCTRL_DPLLCTRLB_REFLCK_SHIFT) /* XOSC2 clock reference */
#define OSCCTRL_DPLLCTRLB_LTIME_SHIFT (8) /* Bits 8-10: Lock time */
#define OSCCTRL_DPLLCTRLB_LTIME_MASK (7 << OSCCTRL_DPLLCTRLB_LTIME_SHIFT)
# define OSCCTRL_DPLLCTRLB_LTIME_NONE (0 << OSCCTRL_DPLLCTRLB_LTIME_SHIFT) /* No time-out. Automatic lock */
# define OSCCTRL_DPLLCTRLB_LTIME_800US (4 << OSCCTRL_DPLLCTRLB_LTIME_SHIFT) /* Time-out if no locka within 800 us */
# define OSCCTRL_DPLLCTRLB_LTIME_900US (5 << OSCCTRL_DPLLCTRLB_LTIME_SHIFT) /* Time-out if no locka within 900 us */
# define OSCCTRL_DPLLCTRLB_LTIME_1MS (6 << OSCCTRL_DPLLCTRLB_LTIME_SHIFT) /* Time-out if no locka within 1MS */
# define OSCCTRL_DPLLCTRLB_LTIME_1p1MS (7 << OSCCTRL_DPLLCTRLB_LTIME_SHIFT) /* Time-out if no locka within 1.1MS */
#define OSCCTRL_DPLLCTRLB_LBYPASS (1 << 11) /* Bit 11: Lock bypass */
#define OSCCTRL_DPLLCTRLB_DCOFILTER_SHIFT (12) /* Bits 12-14: Sigma-Delta DCO Filter Selection */
#define OSCCTRL_DPLLCTRLB_DCOFILTER_MASK (7 << OSCCTRL_DPLLCTRLB_DCOFILTER_SHIFT)
# define OSCCTRL_DPLLCTRLB_DCOFILTER(n) ((uint32_t)(n) << OSCCTRL_DPLLCTRLB_DCOFILTER_SHIFT)
/* Capa pF BW MHz */
# define OSCCTRL_DPLLCTRLB_DCOFILTER0 (0 << OSCCTRL_DPLLCTRLB_DCOFILTER_SHIFT) /* 0.5 3.21 */
# define OSCCTRL_DPLLCTRLB_DCOFILTER1 (1 << OSCCTRL_DPLLCTRLB_DCOFILTER_SHIFT) /* 1 1.6 */
# define OSCCTRL_DPLLCTRLB_DCOFILTER2 (2 << OSCCTRL_DPLLCTRLB_DCOFILTER_SHIFT) /* 1.5 1.1 */
# define OSCCTRL_DPLLCTRLB_DCOFILTER3 (3 << OSCCTRL_DPLLCTRLB_DCOFILTER_SHIFT) /* 2 0.8 */
# define OSCCTRL_DPLLCTRLB_DCOFILTER4 (4 << OSCCTRL_DPLLCTRLB_DCOFILTER_SHIFT) /* 2.5 0.64 */
# define OSCCTRL_DPLLCTRLB_DCOFILTER5 (5 << OSCCTRL_DPLLCTRLB_DCOFILTER_SHIFT) /* 3 0.55 */
# define OSCCTRL_DPLLCTRLB_DCOFILTER6 (6 << OSCCTRL_DPLLCTRLB_DCOFILTER_SHIFT) /* 3.5 0.45 */
# define OSCCTRL_DPLLCTRLB_DCOFILTER7 (7 << OSCCTRL_DPLLCTRLB_DCOFILTER_SHIFT) /* 4 0.4 */
#define OSCCTRL_DPLLCTRLB_DCOEN (1 << 15) /* Bit 15: DCO Filter Enable */
#define OSCCTRL_DPLLCTRLB_DIV_SHIFT (16) /* Bits 16-26: Clock divider */
#define OSCCTRL_DPLLCTRLB_DIV_MASK (0x7ff << OSCCTRL_DPLLCTRLB_DIV_SHIFT)
# define OSCCTRL_DPLLCTRLB_DIV(n) ((uint32_t)(n) << OSCCTRL_DPLLCTRLB_DIV_SHIFT)
/* DPLL0 synchronization busy */
#define OSCCTRL_DPLL0STATUS_ENABLE (1 << 1) /* Bit 1: DPLL enable synchronization status */
#define OSCCTRL_DPLL0STATUS_DPLLRATIO (1 << 2) /* Bit 2: DPLL loop divider ratio synchronization status */
/* DPLL0 status */
#define OSCCTRL_DPLL0STATUS_LOCK (1 << 0) /* Bit 0: DPLL lock status */
#define OSCCTRL_DPLL0STATUS_CLKRDY (1 << 1) /* Bit 1: Output clock ready */
/********************************************************************************************
* Public Types
********************************************************************************************/
/********************************************************************************************
* Public Data
********************************************************************************************/
/********************************************************************************************
* Public Functions
********************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_OSCCTRL_H */

View File

@ -0,0 +1,268 @@
/********************************************************************************************
* arch/arm/src/samd5e5/chip/sam_pac.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_SAMD5E5_CHIP_SAM_PAC_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_PAC_H
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
#include "chip/sam_memorymap.h"
/********************************************************************************************
* Pre-processor Definitions
********************************************************************************************/
/* PAC register offsets *********************************************************************/
#define SAM_PAC_WRCTRL_OFFSET 0x0000 /* Write control */
#define SAM_PAC_EVCTRL_OFFSET 0x0004 /* Event control */
#define SAM_PAC_INTENCLR_OFFSET 0x0008 /* Interrupt enable clear */
#define SAM_PAC_INTENSET_OFFSET 0x0009 /* Interrupt enable set */
#define SAM_PAC_INTFLAGAHB_OFFSET 0x0010 /* Bridge interrupt flag status */
#define SAM_PAC_INTFLAGA_OFFSET 0x0014 /* Interrupt flag status bridge A */
#define SAM_PAC_INTFLAGB_OFFSET 0x0018 /* Interrupt flag status bridge B */
#define SAM_PAC_INTFLAGC_OFFSET 0x001c /* Interrupt flag status bridge C */
#define SAM_PAC_INTFLAGD_OFFSET 0x0020 /* Interrupt flag status bridge D */
#define SAM_PAC_STATUSA_OFFSET 0x0034 /* Write protection status bridge A */
#define SAM_PAC_STATUSB_OFFSET 0x0038 /* Write protection status bridge B */
#define SAM_PAC_STATUSC_OFFSET 0x003c /* Write protection status bridge C */
#define SAM_PAC_STATUSD_OFFSET 0x0040 /* Write protection status bridge D */
/* PAC register addresses *******************************************************************/
#define SAM_PAC_WRCTRL (SAM_PAC_BASE + SAM_PAC_WRCTRL_OFFSET)
#define SAM_PAC_EVCTRL (SAM_PAC_BASE + SAM_PAC_EVCTRL_OFFSET)
#define SAM_PAC_INTENCLR (SAM_PAC_BASE + SAM_PAC_INTENCLR_OFFSET)
#define SAM_PAC_INTENSET (SAM_PAC_BASE + SAM_PAC_INTENSET_OFFSET)
#define SAM_PAC_INTFLAGAHB (SAM_PAC_BASE + SAM_PAC_INTFLAGAHB_OFFSET)
#define SAM_PAC_INTFLAGA (SAM_PAC_BASE + SAM_PAC_INTFLAGA_OFFSET)
#define SAM_PAC_INTFLAGB (SAM_PAC_BASE + SAM_PAC_INTFLAGB_OFFSET)
#define SAM_PAC_INTFLAGC (SAM_PAC_BASE + SAM_PAC_INTFLAGC_OFFSET)
#define SAM_PAC_INTFLAGD (SAM_PAC_BASE + SAM_PAC_INTFLAGD_OFFSET)
#define SAM_PAC_STATUSA (SAM_PAC_BASE + SAM_PAC_STATUSA_OFFSET)
#define SAM_PAC_STATUSB (SAM_PAC_BASE + SAM_PAC_STATUSB_OFFSET)
#define SAM_PAC_STATUSC (SAM_PAC_BASE + SAM_PAC_STATUSC_OFFSET)
#define SAM_PAC_STATUSD (SAM_PAC_BASE + SAM_PAC_STATUSD_OFFSET)
/* PAC register bit definitions *************************************************************/
/* Write control */
#define PAC_WRCTRL_PERID_SHIFT (0) /* Bits 0-15: Peripheral Identifier */
#define PAC_WRCTRL_PERID_MASK (0xffff << PAC_WRCTRL_PERID_SHIFT)
# define PAC_WRCTRL_PERID(n) ((uint32_t)(n) << PAC_WRCTRL_PERID_SHIFT)
#define PAC_WRCTRL_KEY_SHIFT (16) /* Bits 16-23: Peripheral Access Control Key */
#define PAC_WRCTRL_KEY_MASK (0xff << PAC_WRCTRL_KEY_SHIFT)
# define PAC_WRCTRL_KEY_OFF (0 << PAC_WRCTRL_KEY_SHIFT) /* No action */
# define PAC_WRCTRL_KEY_CLEAR (1 << PAC_WRCTRL_KEY_SHIFT) /* Clear the peripheral write
* control */
# define PAC_WRCTRL_KEY_SET (2 << PAC_WRCTRL_KEY_SHIFT) /* Set the peripheral write
* control */
# define PAC_WRCTRL_KEY_LOCK (3 << PAC_WRCTRL_KEY_SHIFT) /* Set and lock the peripheral
* write control until the
* next hardware reset */
/* Event control */
#define PAC_EVCTRL_ERREO (1 << 0) /* Bit 0: Peripheral access error event output */
/* Interrupt enable clear, Interrupt enable set */
#define PAC_INTEN_ERR (1 << 0) /* Bit 0: Peripheral access error interrupt */
/* Bridge interrupt flag status */
#define PAC_INTFLAGAHB_NVMCTRL0 (1 << 0) /* Bit 0: Interrupt flag for NVMCTRL0 */
#define PAC_INTFLAGAHB_NVMCTRL1 (1 << 1) /* Bit 1: Interrupt flag for NVMCTRL1 */
#define PAC_INTFLAGAHB_NVMCTRL2 (1 << 2) /* Bit 2: Interrupt flag for NVMCTRL2 */
#define PAC_INTFLAGAHB_RAMCM4S (1 << 3) /* Bit 3: Interrupt flag for RAMCM4S */
#define PAC_INTFLAGAHB_RAMPPPDSU (1 << 4) /* Bit 4: Interrupt flag for RAMPPPDSU */
#define PAC_INTFLAGAHB_RAMDMAWR (1 << 5) /* Bit 5: Interrupt flag for RAMDMAWR */
#define PAC_INTFLAGAHB_RAMDMACICM (1 << 6) /* Bit 6: Interrupt flag for RAMDMACICM */
#define PAC_INTFLAGAHB_HPB0 (1 << 7) /* Bit 7: Interrupt flag for HPB0 */
#define PAC_INTFLAGAHB_HPB1 (1 << 8) /* Bit 8: Interrupt flag for HPB1 */
#define PAC_INTFLAGAHB_HPB2 (1 << 9) /* Bit 9: Interrupt flag for HPB2 */
#define PAC_INTFLAGAHB_HPB3 (1 << 0) /* Bit 10: Interrupt flag for HPB3 */
#define PAC_INTFLAGAHB_PUKCC (1 << 1) /* Bit 11: Interrupt flag for PUKCC */
#define PAC_INTFLAGAHB_SDHC0 (1 << 2) /* Bit 12: Interrupt flag for SDHC0 */
#define PAC_INTFLAGAHB_SDHC1 (1 << 3) /* Bit 13: Interrupt flag for SDHC1 */
#define PAC_INTFLAGAHB_QSPI (1 << 4) /* Bit 14: Interrupt flag for QSPI */
/* Interrupt flag status bridge A and Write protection status bridge A */
#define PAC_INTA_PAC (1 << 0) /* Bit 0: Interrupt for PAC */
#define PAC_INTA_PM (1 << 1) /* Bit 1: Interrupt for PM */
#define PAC_INTA_MCLK (1 << 2) /* Bit 2: Interrupt for MCLK */
#define PAC_INTA_RSTC (1 << 3) /* Bit 3: Interrupt for RSTC */
#define PAC_INTA_OSCCTRL (1 << 4) /* Bit 4: Interrupt for OSCCTRL */
#define PAC_INTA_OSC32KCTRL (1 << 5) /* Bit 5: Interrupt for OSC32KCTRL */
#define PAC_INTA_SUPC (1 << 6) /* Bit 6: Interrupt for SUPC */
#define PAC_INTA_GCLK (1 << 7) /* Bit 7: Interrupt for GCLK */
#define PAC_INTA_WDT (1 << 8) /* Bit 8: Interrupt for WDT */
#define PAC_INTA_RTC (1 << 9) /* Bit 9: Interrupt for RTC */
#define PAC_INTA_EIC (1 << 10) /* Bit 10: Interrupt for EIC */
#define PAC_INTA_FREQM (1 << 11) /* Bit 11: Interrupt for FREQM */
#define PAC_INTA_SERCOM0 (1 << 12) /* Bit 12: Interrupt for SERCOM0 */
#define PAC_INTA_SERCOM1 (1 << 13) /* Bit 13: Interrupt for SERCOM1 */
#define PAC_INTA_TC0 (1 << 14) /* Bit 14: Interrupt for TC0 */
#define PAC_INTA_TC1 (1 << 15) /* Bit 15: Interrupt for TC1 */
#define SAM_PAC_PERID ((0 << 5) + 0) /* PAC Peripheral IDs */
#define SAM_PM_PERID ((0 << 5) + 1)
#define SAM_MCLK_PERID ((0 << 5) + 2)
#define SAM_RSTC_PERID ((0 << 5) + 3)
#define SAM_OSCCTRL_PERID ((0 << 5) + 4)
#define SAM_OSC32KCTRL_PERID ((0 << 5) + 5)
#define SAM_SUPC_PERID ((0 << 5) + 6)
#define SAM_GCLK_PERID ((0 << 5) + 7)
#define SAM_WDT_PERID ((0 << 5) + 8)
#define SAM_RTC_PERID ((0 << 5) + 9)
#define SAM_EIC_PERID ((0 << 5) + 10)
#define SAM_FREQM_PERID ((0 << 5) + 11)
#define SAM_SERCOM0_PERID ((0 << 5) + 12)
#define SAM_SERCOM1_PERID ((0 << 5) + 13)
#define SAM_TC0_PERID ((0 << 5) + 14)
#define SAM_TC1_PERID ((0 << 5) + 15)
/* Interrupt flag status bridge B and Write protection status bridge B */
#define PAC_INTB_USB (1 << 0) /* Bit 0: Interrupt for USB */
#define PAC_INTB_DSU (1 << 1) /* Bit 1: Interrupt for DSU */
#define PAC_INTB_CMCC (1 << 2) /* Bit 3: Interrupt for CMCC */
#define PAC_INTB_NVMCTRL (1 << 3) /* Bit 2: Interrupt for NVMCTRL */
#define PAC_INTB_PORT (1 << 4) /* Bit 4: Interrupt for PORT */
#define PAC_INTB_DMAC (1 << 5) /* Bit 5: Interrupt for DMAC */
#define PAC_INTB_EVSYS (1 << 7) /* Bit 7: Interrupt for EVSYS */
#define PAC_INTB_SERCOM2 (1 << 9) /* Bit 9: Interrupt for SERCOM2 */
#define PAC_INTB_SERCOM3 (1 << 10) /* Bit 10: Interrupt for SERCOM3 */
#define PAC_INTB_TCC0 (1 << 11) /* Bit 11: Interrupt for TCC0 */
#define PAC_INTB_TCC1 (1 << 12) /* Bit 12: Interrupt for TCC1 */
#define PAC_INTB_TC2 (1 << 13) /* Bit 13: Interrupt for TC2 */
#define PAC_INTB_TC3 (1 << 14) /* Bit 14: Interrupt for TC3 */
#define PAC_INTB_RAMECC (1 << 16) /* Bit 16: Interrupt for RAMECC */
#define SAM_USB_PERID ((1 << 5) + 0) /* PAC Peripheral IDs */
#define SAM_DSU_PERID ((1 << 5) + 1)
#define SAM_NVMCTRL_PERID ((1 << 5) + 2)
#define SAM_CMCCC_PERID ((1 << 5) + 3)
#define SAM_PORT_PERID ((1 << 5) + 4)
#define SAM_DMAC_PERID ((1 << 5) + 5)
#define SAM_EVSYS_PERID ((1 << 5) + 7)
#define SAM_SERCOM2_PERID ((1 << 5) + 9)
#define SAM_SERCOM3_PERID ((1 << 5) + 10)
#define SAM_TCC0_PERID ((1 << 5) + 11)
#define SAM_TCC1_PERID ((1 << 5) + 12)
#define SAM_TC2_PERID ((1 << 5) + 13)
#define SAM_TC3_PERID ((1 << 5) + 14)
#define SAM_RAMECC_PERID ((1 << 5) + 16)
/* Interrupt flag status bridge C and Write protection status bridge C */
#define PAC_INTC_CAN0 (1 << 0) /* Bit 0: Interrupt for CAN0 */
#define PAC_INTC_CAN1 (1 << 1) /* Bit 1: Interrupt for CAN1 */
#define PAC_INTC_GMAC (1 << 2) /* Bit 2: Interrupt for GMAC */
#define PAC_INTC_TCC2 (1 << 3) /* Bit 3: Interrupt for TCC2 */
#define PAC_INTC_TCC3 (1 << 4) /* Bit 4: Interrupt for TCC3 */
#define PAC_INTC_TC4 (1 << 5) /* Bit 5: Interrupt for TC4 */
#define PAC_INTC_TC5 (1 << 6) /* Bit 6: Interrupt for TC5 */
#define PAC_INTC_PDEC (1 << 7) /* Bit 7: Interrupt for PDEC */
#define PAC_INTC_AES (1 << 9) /* Bit 9: Interrupt for AES */
#define PAC_INTC_TRNG (1 << 10) /* Bit 10: Interrupt for TRNG */
#define PAC_INTC_ICM (1 << 11) /* Bit 11: Interrupt for ICM */
#define PAC_INTC_PUKCC (1 << 12) /* Bit 12: Interrupt for PUKCC */
#define PAC_INTC_QSPI (1 << 13) /* Bit 13: Interrupt for QSPI */
#define PAC_INTC_CCL (1 << 14) /* Bit 14: Interrupt for CCL */
#define SAM_CAN0_PERID ((2 << 5) + 0) /* PAC Peripheral IDs */
#define SAM_CAN1_PERID ((2 << 5) + 1)
#define SAM_GMAC_PERID ((2 << 5) + 2)
#define SAM_TCC2_PERID ((2 << 5) + 3)
#define SAM_TCC3_PERID ((2 << 5) + 4)
#define SAM_TC4_PERID ((2 << 5) + 5)
#define SAM_TC5_PERID ((2 << 5) + 6)
#define SAM_PDEC_PERID ((2 << 5) + 7)
#define SAM_AC_PERID ((2 << 5) + 8)
#define SAM_AES_PERID ((2 << 5) + 9)
#define SAM_TRNG_PERID ((2 << 5) + 10)
#define SAM_ICM_PERID ((2 << 5) + 11)
#define SAM_PUKCC_PERID ((2 << 5) + 12)
#define SAM_QSPIC_PERID ((2 << 5) + 13)
#define SAM_CCL_PERID ((2 << 5) + 14)
/* Interrupt flag status bridge D and Write protection status bridge D */
#define PAC_INTD_SERCOM4 (1 << 0) /* Bit 0: Interrupt for SERCOM4 */
#define PAC_INTD_SERCOM5 (1 << 1) /* Bit 1: Interrupt for SERCOM5 */
#define PAC_INTD_SERCOM6 (1 << 2) /* Bit 2: Interrupt for SERCOM6 */
#define PAC_INTD_SERCOM7 (1 << 3) /* Bit 3: Interrupt for SERCOM7 */
#define PAC_INTD_TCC4 (1 << 4) /* Bit 4: Interrupt for TCC4 */
#define PAC_INTD_TC6 (1 << 5) /* Bit 5: Interrupt for TC6 */
#define PAC_INTD_TC7 (1 << 6) /* Bit 6: Interrupt for TC7 */
#define PAC_INTD_ADC0 (1 << 7) /* Bit 7: Interrupt for ADC0 */
#define PAC_INTD_ADC1 (1 << 8) /* Bit 8: Interrupt for ADC1 */
#define PAC_INTD_DAC (1 << 9) /* Bit 9: Interrupt for DAC */
#define PAC_INTD_I2S (1 << 10) /* Bit 10: Interrupt for I2S */
#define PAC_INTD_PCC (1 << 11) /* Bit 11: Interrupt for PCC */
#define SAM_SERCOM4_PERID ((3 << 5) + 0) /* PAC Peripheral IDs */
#define SAM_SERCOM5_PERID ((3 << 5) + 1)
#define SAM_SERCOM6_PERID ((3 << 5) + 2)
#define SAM_SERCOM7_PERID ((3 << 5) + 3)
#define SAM_TCC4_PERID ((3 << 5) + 4)
#define SAM_TC6_PERID ((3 << 5) + 5)
#define SAM_TC7_PERID ((3 << 5) + 6)
#define SAM_ADC0_PERID ((3 << 5) + 7)
#define SAM_ADC1_PERID ((3 << 5) + 8)
#define SAM_DAC_PERID ((3 << 5) + 9)
#define SAM_I2S_PERID ((3 << 5) + 10)
#define SAM_PCC_PERID ((3 << 5) + 11)
/********************************************************************************************
* Public Types
********************************************************************************************/
/********************************************************************************************
* Public Data
********************************************************************************************/
/********************************************************************************************
* Public Functions
********************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_PAC_H */

View File

@ -0,0 +1,52 @@
/************************************************************************************
* arch/arm/src/samd5e5/chip/sam_memorymap.h
*
* Copyright (C) 2018 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_SAMD5E5_CHIP_SAM_MEMORYMAP_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_MEMORYMAP_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#if defined(CONFIG_ARCH_CHIP_SAMD5X) || defined(ARCH_CHIP_SAME5X)
# include "chip/samd5e5_memorymap.h"
#else
# error "Unsupported SAMD5/E5 family"
#endif
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_MEMORYMAP_H */

View File

@ -0,0 +1,147 @@
/****************************************************************************************************
* arch/arm/src/samd5e5/chip/sam_pm.h
*
* Copyright (C) 2018 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_SAMD5E5_CHIP_SAM_PM_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_PM_H
/****************************************************************************************************
* Included Files
****************************************************************************************************/
#include <nuttx/config.h>
#include "chip/sam_memorymap.h"
/****************************************************************************************************
* Pre-processor Definitions
****************************************************************************************************/
/* PM register offsets ******************************************************************************/
#define SAM_PM_CTRLA_OFFSET 0x0000 /* Control A */
#define SAM_PM_SLEEPCFG_OFFSET 0x0001 /* Sleep configuration */
#define SAM_PM_INTENCLR_OFFSET 0x0004 /* Interrupt enable clear register */
#define SAM_PM_INTENSET_OFFSET 0x0005 /* Interrupt enable set register */
#define SAM_PM_INTFLAG_OFFSET 0x0006 /* Interrupt flag status and clear register */
#define SAM_PM_STDBYCFG_OFFSET 0x0008 /* Standy configuration */
#define SAM_PM_HIBCFG_OFFSET 0x0009 /* Hibernate configuration */
#define SAM_PM_BKUPCFG_OFFSET 0x000a /* Backup configuration */
/* PM register addresses ****************************************************************************/
#define SAM_PM_CTRLA (SAM_PM_BASE + SAM_PM_CTRLA_OFFSET)
#define SAM_PM_SLEEPCFG (SAM_PM_BASE + SAM_PM_SLEEPCFG_OFFSET)
#define SAM_PM_INTENCLR (SAM_PM_BASE + SAM_PM_INTENCLR_OFFSET)
#define SAM_PM_INTENSET (SAM_PM_BASE + SAM_PM_INTENSET_OFFSET)
#define SAM_PM_INTFLAG (SAM_PM_BASE + SAM_PM_INTFLAG_OFFSET)
#define SAM_PM_STDBYCFG (SAM_PM_BASE + SAM_PM_STDBYCFG_OFFSET)
#define SAM_PM_HIBCFG (SAM_PM_BASE + SAM_PM_HIBCFG_OFFSET)
#define SAM_PM_BKUPCFG (SAM_PM_BASE + SAM_PM_BKUPCFG_OFFSET)
/* PM register bit definitions **********************************************************************/
/* Control A register */
#define PM_CTRLA_IORET (1 << 2) /* Bit 2: I/O retention */
/* Sleep configuration register */
#define PM_SLEEPCFG_MODE_SHIFT (0) /* Bits 0-2: Idle Mode Configuration */
#define PM_SLEEPCFG_MODE_MASK (7 << PM_SLEEPCFG_MODE_SHIFT)
# define PM_SLEEPCFG_MODE_IDLE (2 << PM_SLEEPCFG_MODE_SHIFT) /* CPU, AHBx, APBx clocks OFF */
# define PM_SLEEPCFG_MODE_STANDBY (4 << PM_SLEEPCFG_MODE_SHIFT) /* All clocks OFF */
# define PM_SLEEPCFG_MODE_HIBERNATE (5 << PM_SLEEPCFG_MODE_SHIFT) /* Backup domain is ON as well as
* some PDRAMs */
# define PM_SLEEPCFG_MODE_BACKUP (6 << PM_SLEEPCFG_MODE_SHIFT) /* Only backup domain is
* powered ON */
# define PM_SLEEPCFG_MODE_OFF (7 << PM_SLEEPCFG_MODE_SHIFT) /* All power domains are
* powered OFF */
/* Interrupt enable clear, Interrupt enable set, and Interrupt flag status and clear registers */
#define PM_INT_SLEEPRDY (1 << 0) /* Bit 0: Sleep mode entry ready interrupt */
/* Standy configuration */
#define PM_STDBYCFG_RAMCFG_SHIFT (0) /* Bits 0-1: RAM Configuration */
#define PM_STDBYCFG_RAMCFG_MASK (3 << PM_STDBYCFG_RAMCFG_SHIFT)
# define PM_STDBYCFG_RAMCFG_RET (0 << PM_STDBYCFG_RAMCFG_SHIFT) /* System RAM is retained */
# define PM_STDBYCFG_RAMCFG_PARTIAL (1 << PM_STDBYCFG_RAMCFG_SHIFT) /* PD0 ACTIVE; PD1/2 handled by HW */
# define PM_STDBYCFG_RAMCFG_OFF (2 << PM_STDBYCFG_RAMCFG_SHIFT) /* Only the first 32Kb of system
* RAM is retained */
#define PM_STDBYCFG_FASTWKUP_SHIFT (4) /* Bits 4-5: Fast Wakeup */
#define PM_STDBYCFG_FASTWKUP_MASK (3 << PM_STDBYCFG_FASTWKUP_SHIFT)
# define PM_STDBYCFG_FASTWKUP_NO (0 << PM_STDBYCFG_FASTWKUP_SHIFT) /* Disabled */
# define PM_STDBYCFG_FASTWKUP_NVM (1 << PM_STDBYCFG_FASTWKUP_SHIFT) /* Enabled on NVM */
# define PM_STDBYCFG_FASTWKUP_MAINVREG (2 << PM_STDBYCFG_FASTWKUP_SHIFT) /* Enabled on MAINVREG */
# define PM_STDBYCFG_FASTWKUP_BOTH (3 << PM_STDBYCFG_FASTWKUP_SHIFT) /* Enabled on both */
/* Hibernate configuration */
#define PM_HIBCFG_RAMCFG_SHIFT (0) /* Bits 0-1: RAM Configuration */
#define PM_HIBCFG_RAMCFG_MASK (3 << PM_HIBCFG_RAMCFG_SHIFT)
# define PM_HIBCFG_RAMCFG_RET (0 << PM_HIBCFG_RAMCFG_SHIFT) /* System RAM is retained */
# define PM_HIBCFG_RAMCFG_PARTIAL (1 << PM_HIBCFG_RAMCFG_SHIFT) /* PD0 ACTIVE; PD1/2 handled by HW */
# define PM_HIBCFG_RAMCFG_OFF (2 << PM_HIBCFG_RAMCFG_SHIFT) /* Only the first 32Kb of system
* RAM is retained */
#define PM_HIBCFG_BRAMCFG_SHIFT (0) /* Bits 0-1: Backup RAM Configuration */
#define PM_HIBCFG_BRAMCFG_MASK (3 << PM_HIBCFG_BRAMCFG_SHIFT)
# define PM_HIBCFG_BRAMCFG_RET (0 << PM_HIBCFG_BRAMCFG_SHIFT) /* System RAM is retained */
# define PM_HIBCFG_BRAMCFG_PARTIAL (1 << PM_HIBCFG_BRAMCFG_SHIFT) /* PD0 ACTIVE; PD1/2 handled by HW */
# define PM_HIBCFG_BRAMCFG_OFF (2 << PM_HIBCFG_BRAMCFG_SHIFT) /* Only the first 32Kb of system
* RAM is retained */
/* Backup configuration */
#define PM_BKUPCFG_BRAMCFG_SHIFT (0) /* Bits 0-1: RAM Configuration */
#define PM_BKUPCFG_BRAMCFG_MASK (3 << PM_BKUPCFG_BRAMCFG_SHIFT)
# define PM_BKUPCFG_BRAMCFG_RET (0 << PM_BKUPCFG_BRAMCFG_SHIFT) /* System RAM is retained */
# define PM_BKUPCFG_BRAMCFG_PARTIAL (1 << PM_BKUPCFG_BRAMCFG_SHIFT) /* PD0 ACTIVE; PD1/2 handled by HW */
# define PM_BKUPCFG_BRAMCFG_OFF (2 << PM_BKUPCFG_BRAMCFG_SHIFT) /* Only the first 32Kb of system
* RAM is retained */
/****************************************************************************************************
* Public Types
****************************************************************************************************/
/****************************************************************************************************
* Public Data
****************************************************************************************************/
/****************************************************************************************************
* Public Functions
****************************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_PM_H */

View File

@ -0,0 +1,526 @@
/********************************************************************************************
* arch/arm/src/samd5e5/chip/sam_port.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_SAMD5E5_CHIP_SAM_PORT_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_PORT_H
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
#include "chip/sam_memorymap.h"
/********************************************************************************************
* Pre-processor Definitions
********************************************************************************************/
/* PORT register offsets ********************************************************************/
#define SAM_PORTA (0)
#define SAM_PORTB (1)
#define SAM_PORTC (2)
#define SAM_PORTD (3)
#define SAM_NPORTS (4)
#define SAM_PORTN_OFFSET(n) (0x0000 + ((n) << 7))
# define SAM_PORTA_OFFSET 0x0000 /* Port A register offset */
# define SAM_PORTB_OFFSET 0x0080 /* Port B register offset */
# define SAM_PORTC_OFFSET 0x0100 /* Port C register offset */
# define SAM_PORTD_OFFSET 0x0180 /* Port D register offset */
#define SAM_PORT_DIR_OFFSET 0x0000 /* Data direction register */
#define SAM_PORT_DIRCLR_OFFSET 0x0004 /* Data direction clear register */
#define SAM_PORT_DIRSET_OFFSET 0x0008 /* Data direction set register */
#define SAM_PORT_DIRTGL_OFFSET 0x000c /* Data direction toggle register */
#define SAM_PORT_OUT_OFFSET 0x0010 /* Data output value register */
#define SAM_PORT_OUTCLR_OFFSET 0x0014 /* Data output value clear register */
#define SAM_PORT_OUTSET_OFFSET 0x0018 /* Data output value set register */
#define SAM_PORT_OUTTGL_OFFSET 0x001c /* Data output value toggle register */
#define SAM_PORT_IN_OFFSET 0x0020 /* Data input value register */
#define SAM_PORT_CTRL_OFFSET 0x0024 /* Control register */
#define SAM_PORT_WRCONFIG_OFFSET 0x0028 /* Write configuration register */
#define SAM_PORT_EVCTRL_OFFSET 0x002c /* Event input control register */
#define SAM_PORT_PMUX_OFFSET(n) (0x0030+((n)>>1))
# define SAM_PORT_PMUX0_OFFSET 0x0030 /* Peripheral multiplexing register 0 */
# define SAM_PORT_PMUX1_OFFSET 0x0031 /* Peripheral multiplexing register 1 */
# define SAM_PORT_PMUX2_OFFSET 0x0032 /* Peripheral multiplexing register 2 */
# define SAM_PORT_PMUX3_OFFSET 0x0033 /* Peripheral multiplexing register 3 */
# define SAM_PORT_PMUX4_OFFSET 0x0034 /* Peripheral multiplexing register 4 */
# define SAM_PORT_PMUX5_OFFSET 0x0035 /* Peripheral multiplexing register 5 */
# define SAM_PORT_PMUX6_OFFSET 0x0036 /* Peripheral multiplexing register 6 */
# define SAM_PORT_PMUX7_OFFSET 0x0037 /* Peripheral multiplexing register 7 */
# define SAM_PORT_PMUX8_OFFSET 0x0038 /* Peripheral multiplexing register 8 */
# define SAM_PORT_PMUX9_OFFSET 0x0039 /* Peripheral multiplexing register 9 */
# define SAM_PORT_PMUX10_OFFSET 0x003a /* Peripheral multiplexing register 10 */
# define SAM_PORT_PMUX11_OFFSET 0x003b /* Peripheral multiplexing register 11 */
# define SAM_PORT_PMUX12_OFFSET 0x003c /* Peripheral multiplexing register 12 */
# define SAM_PORT_PMUX13_OFFSET 0x003d /* Peripheral multiplexing register 13 */
# define SAM_PORT_PMUX14_OFFSET 0x003e /* Peripheral multiplexing register 14 */
# define SAM_PORT_PMUX15_OFFSET 0x003f /* Peripheral multiplexing register 15 */
#define SAM_PORT_PINCFG_OFFSET(n) (0x0040+(n))
# define SAM_PORT_PINCFG0_OFFSET 0x0040 /* Pin configuration register 0 */
# define SAM_PORT_PINCFG1_OFFSET 0x0041 /* Pin configuration register 1 */
# define SAM_PORT_PINCFG2_OFFSET 0x0042 /* Pin configuration register 2 */
# define SAM_PORT_PINCFG3_OFFSET 0x0043 /* Pin configuration register 3 */
# define SAM_PORT_PINCFG4_OFFSET 0x0044 /* Pin configuration register 4 */
# define SAM_PORT_PINCFG5_OFFSET 0x0045 /* Pin configuration register 5 */
# define SAM_PORT_PINCFG6_OFFSET 0x0046 /* Pin configuration register 6 */
# define SAM_PORT_PINCFG7_OFFSET 0x0047 /* Pin configuration register 7 */
# define SAM_PORT_PINCFG8_OFFSET 0x0048 /* Pin configuration register 8 */
# define SAM_PORT_PINCFG9_OFFSET 0x0049 /* Pin configuration register 9 */
# define SAM_PORT_PINCFG10_OFFSET 0x004a /* Pin configuration register 10 */
# define SAM_PORT_PINCFG11_OFFSET 0x004b /* Pin configuration register 11 */
# define SAM_PORT_PINCFG12_OFFSET 0x004c /* Pin configuration register 12 */
# define SAM_PORT_PINCFG13_OFFSET 0x004d /* Pin configuration register 13 */
# define SAM_PORT_PINCFG14_OFFSET 0x004e /* Pin configuration register 14 */
# define SAM_PORT_PINCFG15_OFFSET 0x004f /* Pin configuration register 15 */
# define SAM_PORT_PINCFG16_OFFSET 0x0050 /* Pin configuration register 16 */
# define SAM_PORT_PINCFG17_OFFSET 0x0051 /* Pin configuration register 17 */
# define SAM_PORT_PINCFG18_OFFSET 0x0052 /* Pin configuration register 18 */
# define SAM_PORT_PINCFG19_OFFSET 0x0053 /* Pin configuration register 19 */
# define SAM_PORT_PINCFG20_OFFSET 0x0054 /* Pin configuration register 20 */
# define SAM_PORT_PINCFG21_OFFSET 0x0055 /* Pin configuration register 21 */
# define SAM_PORT_PINCFG22_OFFSET 0x0056 /* Pin configuration register 22 */
# define SAM_PORT_PINCFG23_OFFSET 0x0057 /* Pin configuration register 23 */
# define SAM_PORT_PINCFG24_OFFSET 0x0058 /* Pin configuration register 24 */
# define SAM_PORT_PINCFG25_OFFSET 0x0059 /* Pin configuration register 25 */
# define SAM_PORT_PINCFG26_OFFSET 0x005a /* Pin configuration register 26 */
# define SAM_PORT_PINCFG27_OFFSET 0x005b /* Pin configuration register 27 */
# define SAM_PORT_PINCFG28_OFFSET 0x005c /* Pin configuration register 28 */
# define SAM_PORT_PINCFG29_OFFSET 0x005d /* Pin configuration register 29 */
# define SAM_PORT_PINCFG30_OFFSET 0x005e /* Pin configuration register 30 */
# define SAM_PORT_PINCFG31_OFFSET 0x005f /* Pin configuration register 31 */
/* PORT register addresses ******************************************************************/
#define SAM_PORTN_BASE(n) (SAM_PORT_BASE + SAM_PORTN_OFFSET(n))
# define SAM_PORTA_BASE (SAM_PORT_BASE + SAM_PORTA_OFFSET)
# define SAM_PORTB_BASE (SAM_PORT_BASE + SAM_PORTB_OFFSET)
# define SAM_PORTC_BASE (SAM_PORT_BASE + SAM_PORTC_OFFSET)
# define SAM_PORTD_BASE (SAM_PORT_BASE + SAM_PORTD_OFFSET)
#define SAM_PORTA_DIR (SAM_PORTA_BASE + SAM_PORT_DIR_OFFSET)
#define SAM_PORTA_DIRCLR (SAM_PORTA_BASE + SAM_PORT_DIRCLR_OFFSET)
#define SAM_PORTA_DIRSET (SAM_PORTA_BASE + SAM_PORT_DIRSET_OFFSET)
#define SAM_PORTA_DIRTGL (SAM_PORTA_BASE + SAM_PORT_DIRTGL_OFFSET)
#define SAM_PORTA_OUT (SAM_PORTA_BASE + SAM_PORT_OUT_OFFSET)
#define SAM_PORTA_OUTCLR (SAM_PORTA_BASE + SAM_PORT_OUTCLR_OFFSET)
#define SAM_PORTA_OUTSET (SAM_PORTA_BASE + SAM_PORT_OUTSET_OFFSET)
#define SAM_PORTA_OUTTGL (SAM_PORTA_BASE + SAM_PORT_OUTTGL_OFFSET)
#define SAM_PORTA_IN (SAM_PORTA_BASE + SAM_PORT_IN_OFFSET)
#define SAM_PORTA_CTRL (SAM_PORTA_BASE + SAM_PORT_CTRL_OFFSET)
#define SAM_PORTA_WRCONFIG (SAM_PORTA_BASE + SAM_PORT_WRCONFIG_OFFSET)
#define SAM_PORT_EVCTRL (SAM_PORTA_BASE + SAM_PORT_EVCTRL_OFFSET)
#define SAM_PORTA_PMUX(n) (SAM_PORTA_BASE + SAM_PORT_PMUX_OFFSET(n))
# define SAM_PORTA_PMUX0 (SAM_PORTA_BASE + SAM_PORT_PMUX0_OFFSET)
# define SAM_PORTA_PMUX1 (SAM_PORTA_BASE + SAM_PORT_PMUX1_OFFSET)
# define SAM_PORTA_PMUX2 (SAM_PORTA_BASE + SAM_PORT_PMUX2_OFFSET)
# define SAM_PORTA_PMUX3 (SAM_PORTA_BASE + SAM_PORT_PMUX3_OFFSET)
# define SAM_PORTA_PMUX4 (SAM_PORTA_BASE + SAM_PORT_PMUX4_OFFSET)
# define SAM_PORTA_PMUX5 (SAM_PORTA_BASE + SAM_PORT_PMUX5_OFFSET)
# define SAM_PORTA_PMUX6 (SAM_PORTA_BASE + SAM_PORT_PMUX6_OFFSET)
# define SAM_PORTA_PMUX7 (SAM_PORTA_BASE + SAM_PORT_PMUX7_OFFSET)
# define SAM_PORTA_PMUX8 (SAM_PORTA_BASE + SAM_PORT_PMUX8_OFFSET)
# define SAM_PORTA_PMUX9 (SAM_PORTA_BASE + SAM_PORT_PMUX9_OFFSET)
# define SAM_PORTA_PMUX10 (SAM_PORTA_BASE + SAM_PORT_PMUX10_OFFSET)
# define SAM_PORTA_PMUX11 (SAM_PORTA_BASE + SAM_PORT_PMUX11_OFFSET)
# define SAM_PORTA_PMUX12 (SAM_PORTA_BASE + SAM_PORT_PMUX12_OFFSET)
# define SAM_PORTA_PMUX13 (SAM_PORTA_BASE + SAM_PORT_PMUX13_OFFSET)
# define SAM_PORTA_PMUX14 (SAM_PORTA_BASE + SAM_PORT_PMUX14_OFFSET)
# define SAM_PORTA_PMUX15 (SAM_PORTA_BASE + SAM_PORT_PMUX15_OFFSET)
#define SAM_PORTA_PINCFG(n) (SAM_PORTA_BASE + SAM_PORT_PINCFG_OFFSET(n))
# define SAM_PORTA_PINCFG0 (SAM_PORTA_BASE + SAM_PORT_PINCFG0_OFFSET)
# define SAM_PORTA_PINCFG1 (SAM_PORTA_BASE + SAM_PORT_PINCFG1_OFFSET)
# define SAM_PORTA_PINCFG2 (SAM_PORTA_BASE + SAM_PORT_PINCFG2_OFFSET)
# define SAM_PORTA_PINCFG3 (SAM_PORTA_BASE + SAM_PORT_PINCFG3_OFFSET)
# define SAM_PORTA_PINCFG4 (SAM_PORTA_BASE + SAM_PORT_PINCFG4_OFFSET)
# define SAM_PORTA_PINCFG5 (SAM_PORTA_BASE + SAM_PORT_PINCFG5_OFFSET)
# define SAM_PORTA_PINCFG6 (SAM_PORTA_BASE + SAM_PORT_PINCFG6_OFFSET)
# define SAM_PORTA_PINCFG7 (SAM_PORTA_BASE + SAM_PORT_PINCFG7_OFFSET)
# define SAM_PORTA_PINCFG8 (SAM_PORTA_BASE + SAM_PORT_PINCFG8_OFFSET)
# define SAM_PORTA_PINCFG9 (SAM_PORTA_BASE + SAM_PORT_PINCFG9_OFFSET)
# define SAM_PORTA_PINCFG10 (SAM_PORTA_BASE + SAM_PORT_PINCFG10_OFFSET)
# define SAM_PORTA_PINCFG11 (SAM_PORTA_BASE + SAM_PORT_PINCFG11_OFFSET)
# define SAM_PORTA_PINCFG12 (SAM_PORTA_BASE + SAM_PORT_PINCFG12_OFFSET)
# define SAM_PORTA_PINCFG13 (SAM_PORTA_BASE + SAM_PORT_PINCFG13_OFFSET)
# define SAM_PORTA_PINCFG14 (SAM_PORTA_BASE + SAM_PORT_PINCFG14_OFFSET)
# define SAM_PORTA_PINCFG15 (SAM_PORTA_BASE + SAM_PORT_PINCFG15_OFFSET)
# define SAM_PORTA_PINCFG16 (SAM_PORTA_BASE + SAM_PORT_PINCFG16_OFFSET)
# define SAM_PORTA_PINCFG17 (SAM_PORTA_BASE + SAM_PORT_PINCFG17_OFFSET)
# define SAM_PORTA_PINCFG18 (SAM_PORTA_BASE + SAM_PORT_PINCFG18_OFFSET)
# define SAM_PORTA_PINCFG19 (SAM_PORTA_BASE + SAM_PORT_PINCFG19_OFFSET)
# define SAM_PORTA_PINCFG20 (SAM_PORTA_BASE + SAM_PORT_PINCFG20_OFFSET)
# define SAM_PORTA_PINCFG21 (SAM_PORTA_BASE + SAM_PORT_PINCFG21_OFFSET)
# define SAM_PORTA_PINCFG22 (SAM_PORTA_BASE + SAM_PORT_PINCFG22_OFFSET)
# define SAM_PORTA_PINCFG23 (SAM_PORTA_BASE + SAM_PORT_PINCFG23_OFFSET)
# define SAM_PORTA_PINCFG24 (SAM_PORTA_BASE + SAM_PORT_PINCFG24_OFFSET)
# define SAM_PORTA_PINCFG25 (SAM_PORTA_BASE + SAM_PORT_PINCFG25_OFFSET)
# define SAM_PORTA_PINCFG26 (SAM_PORTA_BASE + SAM_PORT_PINCFG26_OFFSET)
# define SAM_PORTA_PINCFG27 (SAM_PORTA_BASE + SAM_PORT_PINCFG27_OFFSET)
# define SAM_PORTA_PINCFG28 (SAM_PORTA_BASE + SAM_PORT_PINCFG28_OFFSET)
# define SAM_PORTA_PINCFG29 (SAM_PORTA_BASE + SAM_PORT_PINCFG29_OFFSET)
# define SAM_PORTA_PINCFG30 (SAM_PORTA_BASE + SAM_PORT_PINCFG30_OFFSET)
# define SAM_PORTA_PINCFG31 (SAM_PORTA_BASE + SAM_PORT_PINCFG31_OFFSET)
#define SAM_PORTB_DIR (SAM_PORTB_BASE + SAM_PORT_DIR_OFFSET)
#define SAM_PORTB_DIRCLR (SAM_PORTB_BASE + SAM_PORT_DIRCLR_OFFSET)
#define SAM_PORTB_DIRSET (SAM_PORTB_BASE + SAM_PORT_DIRSET_OFFSET)
#define SAM_PORTB_DIRTGL (SAM_PORTB_BASE + SAM_PORT_DIRTGL_OFFSET)
#define SAM_PORTB_OUT (SAM_PORTB_BASE + SAM_PORT_OUT_OFFSET)
#define SAM_PORTB_OUTCLR (SAM_PORTB_BASE + SAM_PORT_OUTCLR_OFFSET)
#define SAM_PORTB_OUTSET (SAM_PORTB_BASE + SAM_PORT_OUTSET_OFFSET)
#define SAM_PORTB_OUTTGL (SAM_PORTB_BASE + SAM_PORT_OUTTGL_OFFSET)
#define SAM_PORTB_IN (SAM_PORTB_BASE + SAM_PORT_IN_OFFSET)
#define SAM_PORTB_CTRL (SAM_PORTB_BASE + SAM_PORT_CTRL_OFFSET)
#define SAM_PORTB_WRCONFIG (SAM_PORTB_BASE + SAM_PORT_WRCONFIG_OFFSET)
#define SAM_PORTB_PMUX(n) (SAM_PORTB_BASE + SAM_PORT_PMUX_OFFSET(n))
# define SAM_PORTB_PMUX0 (SAM_PORTB_BASE + SAM_PORT_PMUX0_OFFSET)
# define SAM_PORTB_PMUX1 (SAM_PORTB_BASE + SAM_PORT_PMUX1_OFFSET)
# define SAM_PORTB_PMUX2 (SAM_PORTB_BASE + SAM_PORT_PMUX2_OFFSET)
# define SAM_PORTB_PMUX3 (SAM_PORTB_BASE + SAM_PORT_PMUX3_OFFSET)
# define SAM_PORTB_PMUX4 (SAM_PORTB_BASE + SAM_PORT_PMUX4_OFFSET)
# define SAM_PORTB_PMUX5 (SAM_PORTB_BASE + SAM_PORT_PMUX5_OFFSET)
# define SAM_PORTB_PMUX6 (SAM_PORTB_BASE + SAM_PORT_PMUX6_OFFSET)
# define SAM_PORTB_PMUX7 (SAM_PORTB_BASE + SAM_PORT_PMUX7_OFFSET)
# define SAM_PORTB_PMUX8 (SAM_PORTB_BASE + SAM_PORT_PMUX8_OFFSET)
# define SAM_PORTB_PMUX9 (SAM_PORTB_BASE + SAM_PORT_PMUX9_OFFSET)
# define SAM_PORTB_PMUX10 (SAM_PORTB_BASE + SAM_PORT_PMUX10_OFFSET)
# define SAM_PORTB_PMUX11 (SAM_PORTB_BASE + SAM_PORT_PMUX11_OFFSET)
# define SAM_PORTB_PMUX12 (SAM_PORTB_BASE + SAM_PORT_PMUX12_OFFSET)
# define SAM_PORTB_PMUX13 (SAM_PORTB_BASE + SAM_PORT_PMUX13_OFFSET)
# define SAM_PORTB_PMUX14 (SAM_PORTB_BASE + SAM_PORT_PMUX14_OFFSET)
# define SAM_PORTB_PMUX15 (SAM_PORTB_BASE + SAM_PORT_PMUX15_OFFSET)
#define SAM_PORTB_PINCFG(n) (SAM_PORTB_BASE + SAM_PORT_PINCFG_OFFSET(n))
# define SAM_PORTB_PINCFG0 (SAM_PORTB_BASE + SAM_PORT_PINCFG0_OFFSET)
# define SAM_PORTB_PINCFG1 (SAM_PORTB_BASE + SAM_PORT_PINCFG1_OFFSET)
# define SAM_PORTB_PINCFG2 (SAM_PORTB_BASE + SAM_PORT_PINCFG2_OFFSET)
# define SAM_PORTB_PINCFG3 (SAM_PORTB_BASE + SAM_PORT_PINCFG3_OFFSET)
# define SAM_PORTB_PINCFG4 (SAM_PORTB_BASE + SAM_PORT_PINCFG4_OFFSET)
# define SAM_PORTB_PINCFG5 (SAM_PORTB_BASE + SAM_PORT_PINCFG5_OFFSET)
# define SAM_PORTB_PINCFG6 (SAM_PORTB_BASE + SAM_PORT_PINCFG6_OFFSET)
# define SAM_PORTB_PINCFG7 (SAM_PORTB_BASE + SAM_PORT_PINCFG7_OFFSET)
# define SAM_PORTB_PINCFG8 (SAM_PORTB_BASE + SAM_PORT_PINCFG8_OFFSET)
# define SAM_PORTB_PINCFG9 (SAM_PORTB_BASE + SAM_PORT_PINCFG9_OFFSET)
# define SAM_PORTB_PINCFG10 (SAM_PORTB_BASE + SAM_PORT_PINCFG10_OFFSET)
# define SAM_PORTB_PINCFG11 (SAM_PORTB_BASE + SAM_PORT_PINCFG11_OFFSET)
# define SAM_PORTB_PINCFG12 (SAM_PORTB_BASE + SAM_PORT_PINCFG12_OFFSET)
# define SAM_PORTB_PINCFG13 (SAM_PORTB_BASE + SAM_PORT_PINCFG13_OFFSET)
# define SAM_PORTB_PINCFG14 (SAM_PORTB_BASE + SAM_PORT_PINCFG14_OFFSET)
# define SAM_PORTB_PINCFG15 (SAM_PORTB_BASE + SAM_PORT_PINCFG15_OFFSET)
# define SAM_PORTB_PINCFG16 (SAM_PORTB_BASE + SAM_PORT_PINCFG16_OFFSET)
# define SAM_PORTB_PINCFG17 (SAM_PORTB_BASE + SAM_PORT_PINCFG17_OFFSET)
# define SAM_PORTB_PINCFG18 (SAM_PORTB_BASE + SAM_PORT_PINCFG18_OFFSET)
# define SAM_PORTB_PINCFG19 (SAM_PORTB_BASE + SAM_PORT_PINCFG19_OFFSET)
# define SAM_PORTB_PINCFG20 (SAM_PORTB_BASE + SAM_PORT_PINCFG20_OFFSET)
# define SAM_PORTB_PINCFG21 (SAM_PORTB_BASE + SAM_PORT_PINCFG21_OFFSET)
# define SAM_PORTB_PINCFG22 (SAM_PORTB_BASE + SAM_PORT_PINCFG22_OFFSET)
# define SAM_PORTB_PINCFG23 (SAM_PORTB_BASE + SAM_PORT_PINCFG23_OFFSET)
# define SAM_PORTB_PINCFG24 (SAM_PORTB_BASE + SAM_PORT_PINCFG24_OFFSET)
# define SAM_PORTB_PINCFG25 (SAM_PORTB_BASE + SAM_PORT_PINCFG25_OFFSET)
# define SAM_PORTB_PINCFG26 (SAM_PORTB_BASE + SAM_PORT_PINCFG26_OFFSET)
# define SAM_PORTB_PINCFG27 (SAM_PORTB_BASE + SAM_PORT_PINCFG27_OFFSET)
# define SAM_PORTB_PINCFG28 (SAM_PORTB_BASE + SAM_PORT_PINCFG28_OFFSET)
# define SAM_PORTB_PINCFG29 (SAM_PORTB_BASE + SAM_PORT_PINCFG29_OFFSET)
# define SAM_PORTB_PINCFG30 (SAM_PORTB_BASE + SAM_PORT_PINCFG30_OFFSET)
# define SAM_PORTB_PINCFG31 (SAM_PORTB_BASE + SAM_PORT_PINCFG31_OFFSET)
#define SAM_PORTC_DIR (SAM_PORTC_BASE + SAM_PORT_DIR_OFFSET)
#define SAM_PORTC_DIRCLR (SAM_PORTC_BASE + SAM_PORT_DIRCLR_OFFSET)
#define SAM_PORTC_DIRSET (SAM_PORTC_BASE + SAM_PORT_DIRSET_OFFSET)
#define SAM_PORTC_DIRTGL (SAM_PORTC_BASE + SAM_PORT_DIRTGL_OFFSET)
#define SAM_PORTC_OUT (SAM_PORTC_BASE + SAM_PORT_OUT_OFFSET)
#define SAM_PORTC_OUTCLR (SAM_PORTC_BASE + SAM_PORT_OUTCLR_OFFSET)
#define SAM_PORTC_OUTSET (SAM_PORTC_BASE + SAM_PORT_OUTSET_OFFSET)
#define SAM_PORTC_OUTTGL (SAM_PORTC_BASE + SAM_PORT_OUTTGL_OFFSET)
#define SAM_PORTC_IN (SAM_PORTC_BASE + SAM_PORT_IN_OFFSET)
#define SAM_PORTC_CTRL (SAM_PORTC_BASE + SAM_PORT_CTRL_OFFSET)
#define SAM_PORTC_WRCONFIG (SAM_PORTC_BASE + SAM_PORT_WRCONFIG_OFFSET)
#define SAM_PORTC_PMUX(n) (SAM_PORTC_BASE + SAM_PORT_PMUX_OFFSET(n))
# define SAM_PORTC_PMUX0 (SAM_PORTC_BASE + SAM_PORT_PMUX0_OFFSET)
# define SAM_PORTC_PMUX1 (SAM_PORTC_BASE + SAM_PORT_PMUX1_OFFSET)
# define SAM_PORTC_PMUX2 (SAM_PORTC_BASE + SAM_PORT_PMUX2_OFFSET)
# define SAM_PORTC_PMUX3 (SAM_PORTC_BASE + SAM_PORT_PMUX3_OFFSET)
# define SAM_PORTC_PMUX4 (SAM_PORTC_BASE + SAM_PORT_PMUX4_OFFSET)
# define SAM_PORTC_PMUX5 (SAM_PORTC_BASE + SAM_PORT_PMUX5_OFFSET)
# define SAM_PORTC_PMUX6 (SAM_PORTC_BASE + SAM_PORT_PMUX6_OFFSET)
# define SAM_PORTC_PMUX7 (SAM_PORTC_BASE + SAM_PORT_PMUX7_OFFSET)
# define SAM_PORTC_PMUX8 (SAM_PORTC_BASE + SAM_PORT_PMUX8_OFFSET)
# define SAM_PORTC_PMUX9 (SAM_PORTC_BASE + SAM_PORT_PMUX9_OFFSET)
# define SAM_PORTC_PMUX10 (SAM_PORTC_BASE + SAM_PORT_PMUX10_OFFSET)
# define SAM_PORTC_PMUX11 (SAM_PORTC_BASE + SAM_PORT_PMUX11_OFFSET)
# define SAM_PORTC_PMUX12 (SAM_PORTC_BASE + SAM_PORT_PMUX12_OFFSET)
# define SAM_PORTC_PMUX13 (SAM_PORTC_BASE + SAM_PORT_PMUX13_OFFSET)
# define SAM_PORTC_PMUX14 (SAM_PORTC_BASE + SAM_PORT_PMUX14_OFFSET)
# define SAM_PORTC_PMUX15 (SAM_PORTC_BASE + SAM_PORT_PMUX15_OFFSET)
#define SAM_PORTC_PINCFG(n) (SAM_PORTC_BASE + SAM_PORT_PINCFG_OFFSET(n))
# define SAM_PORTC_PINCFG0 (SAM_PORTC_BASE + SAM_PORT_PINCFG0_OFFSET)
# define SAM_PORTC_PINCFG1 (SAM_PORTC_BASE + SAM_PORT_PINCFG1_OFFSET)
# define SAM_PORTC_PINCFG2 (SAM_PORTC_BASE + SAM_PORT_PINCFG2_OFFSET)
# define SAM_PORTC_PINCFG3 (SAM_PORTC_BASE + SAM_PORT_PINCFG3_OFFSET)
# define SAM_PORTC_PINCFG4 (SAM_PORTC_BASE + SAM_PORT_PINCFG4_OFFSET)
# define SAM_PORTC_PINCFG5 (SAM_PORTC_BASE + SAM_PORT_PINCFG5_OFFSET)
# define SAM_PORTC_PINCFG6 (SAM_PORTC_BASE + SAM_PORT_PINCFG6_OFFSET)
# define SAM_PORTC_PINCFG7 (SAM_PORTC_BASE + SAM_PORT_PINCFG7_OFFSET)
# define SAM_PORTC_PINCFG8 (SAM_PORTC_BASE + SAM_PORT_PINCFG8_OFFSET)
# define SAM_PORTC_PINCFG9 (SAM_PORTC_BASE + SAM_PORT_PINCFG9_OFFSET)
# define SAM_PORTC_PINCFG10 (SAM_PORTC_BASE + SAM_PORT_PINCFG10_OFFSET)
# define SAM_PORTC_PINCFG11 (SAM_PORTC_BASE + SAM_PORT_PINCFG11_OFFSET)
# define SAM_PORTC_PINCFG12 (SAM_PORTC_BASE + SAM_PORT_PINCFG12_OFFSET)
# define SAM_PORTC_PINCFG13 (SAM_PORTC_BASE + SAM_PORT_PINCFG13_OFFSET)
# define SAM_PORTC_PINCFG14 (SAM_PORTC_BASE + SAM_PORT_PINCFG14_OFFSET)
# define SAM_PORTC_PINCFG15 (SAM_PORTC_BASE + SAM_PORT_PINCFG15_OFFSET)
# define SAM_PORTC_PINCFG16 (SAM_PORTC_BASE + SAM_PORT_PINCFG16_OFFSET)
# define SAM_PORTC_PINCFG17 (SAM_PORTC_BASE + SAM_PORT_PINCFG17_OFFSET)
# define SAM_PORTC_PINCFG18 (SAM_PORTC_BASE + SAM_PORT_PINCFG18_OFFSET)
# define SAM_PORTC_PINCFG19 (SAM_PORTC_BASE + SAM_PORT_PINCFG19_OFFSET)
# define SAM_PORTC_PINCFG20 (SAM_PORTC_BASE + SAM_PORT_PINCFG20_OFFSET)
# define SAM_PORTC_PINCFG21 (SAM_PORTC_BASE + SAM_PORT_PINCFG21_OFFSET)
# define SAM_PORTC_PINCFG22 (SAM_PORTC_BASE + SAM_PORT_PINCFG22_OFFSET)
# define SAM_PORTC_PINCFG23 (SAM_PORTC_BASE + SAM_PORT_PINCFG23_OFFSET)
# define SAM_PORTC_PINCFG24 (SAM_PORTC_BASE + SAM_PORT_PINCFG24_OFFSET)
# define SAM_PORTC_PINCFG25 (SAM_PORTC_BASE + SAM_PORT_PINCFG25_OFFSET)
# define SAM_PORTC_PINCFG26 (SAM_PORTC_BASE + SAM_PORT_PINCFG26_OFFSET)
# define SAM_PORTC_PINCFG27 (SAM_PORTC_BASE + SAM_PORT_PINCFG27_OFFSET)
# define SAM_PORTC_PINCFG28 (SAM_PORTC_BASE + SAM_PORT_PINCFG28_OFFSET)
# define SAM_PORTC_PINCFG29 (SAM_PORTC_BASE + SAM_PORT_PINCFG29_OFFSET)
# define SAM_PORTC_PINCFG30 (SAM_PORTC_BASE + SAM_PORT_PINCFG30_OFFSET)
# define SAM_PORTC_PINCFG31 (SAM_PORTC_BASE + SAM_PORT_PINCFG31_OFFSET)
#define SAM_PORTD_DIR (SAM_PORTD_BASE + SAM_PORT_DIR_OFFSET)
#define SAM_PORTD_DIRCLR (SAM_PORTD_BASE + SAM_PORT_DIRCLR_OFFSET)
#define SAM_PORTD_DIRSET (SAM_PORTD_BASE + SAM_PORT_DIRSET_OFFSET)
#define SAM_PORTD_DIRTGL (SAM_PORTD_BASE + SAM_PORT_DIRTGL_OFFSET)
#define SAM_PORTD_OUT (SAM_PORTD_BASE + SAM_PORT_OUT_OFFSET)
#define SAM_PORTD_OUTCLR (SAM_PORTD_BASE + SAM_PORT_OUTCLR_OFFSET)
#define SAM_PORTD_OUTSET (SAM_PORTD_BASE + SAM_PORT_OUTSET_OFFSET)
#define SAM_PORTD_OUTTGL (SAM_PORTD_BASE + SAM_PORT_OUTTGL_OFFSET)
#define SAM_PORTD_IN (SAM_PORTD_BASE + SAM_PORT_IN_OFFSET)
#define SAM_PORTD_CTRL (SAM_PORTD_BASE + SAM_PORT_CTRL_OFFSET)
#define SAM_PORTD_WRCONFIG (SAM_PORTD_BASE + SAM_PORT_WRCONFIG_OFFSET)
#define SAM_PORTD_PMUX(n) (SAM_PORTD_BASE + SAM_PORT_PMUX_OFFSET(n))
# define SAM_PORTD_PMUX0 (SAM_PORTD_BASE + SAM_PORT_PMUX0_OFFSET)
# define SAM_PORTD_PMUX1 (SAM_PORTD_BASE + SAM_PORT_PMUX1_OFFSET)
# define SAM_PORTD_PMUX2 (SAM_PORTD_BASE + SAM_PORT_PMUX2_OFFSET)
# define SAM_PORTD_PMUX3 (SAM_PORTD_BASE + SAM_PORT_PMUX3_OFFSET)
# define SAM_PORTD_PMUX4 (SAM_PORTD_BASE + SAM_PORT_PMUX4_OFFSET)
# define SAM_PORTD_PMUX5 (SAM_PORTD_BASE + SAM_PORT_PMUX5_OFFSET)
# define SAM_PORTD_PMUX6 (SAM_PORTD_BASE + SAM_PORT_PMUX6_OFFSET)
# define SAM_PORTD_PMUX7 (SAM_PORTD_BASE + SAM_PORT_PMUX7_OFFSET)
# define SAM_PORTD_PMUX8 (SAM_PORTD_BASE + SAM_PORT_PMUX8_OFFSET)
# define SAM_PORTD_PMUX9 (SAM_PORTD_BASE + SAM_PORT_PMUX9_OFFSET)
# define SAM_PORTD_PMUX10 (SAM_PORTD_BASE + SAM_PORT_PMUX10_OFFSET)
# define SAM_PORTD_PMUX11 (SAM_PORTD_BASE + SAM_PORT_PMUX11_OFFSET)
# define SAM_PORTD_PMUX12 (SAM_PORTD_BASE + SAM_PORT_PMUX12_OFFSET)
# define SAM_PORTD_PMUX13 (SAM_PORTD_BASE + SAM_PORT_PMUX13_OFFSET)
# define SAM_PORTD_PMUX14 (SAM_PORTD_BASE + SAM_PORT_PMUX14_OFFSET)
# define SAM_PORTD_PMUX15 (SAM_PORTD_BASE + SAM_PORT_PMUX15_OFFSET)
#define SAM_PORTD_PINCFG(n) (SAM_PORTD_BASE + SAM_PORT_PINCFG_OFFSET(n))
# define SAM_PORTD_PINCFG0 (SAM_PORTD_BASE + SAM_PORT_PINCFG0_OFFSET)
# define SAM_PORTD_PINCFG1 (SAM_PORTD_BASE + SAM_PORT_PINCFG1_OFFSET)
# define SAM_PORTD_PINCFG2 (SAM_PORTD_BASE + SAM_PORT_PINCFG2_OFFSET)
# define SAM_PORTD_PINCFG3 (SAM_PORTD_BASE + SAM_PORT_PINCFG3_OFFSET)
# define SAM_PORTD_PINCFG4 (SAM_PORTD_BASE + SAM_PORT_PINCFG4_OFFSET)
# define SAM_PORTD_PINCFG5 (SAM_PORTD_BASE + SAM_PORT_PINCFG5_OFFSET)
# define SAM_PORTD_PINCFG6 (SAM_PORTD_BASE + SAM_PORT_PINCFG6_OFFSET)
# define SAM_PORTD_PINCFG7 (SAM_PORTD_BASE + SAM_PORT_PINCFG7_OFFSET)
# define SAM_PORTD_PINCFG8 (SAM_PORTD_BASE + SAM_PORT_PINCFG8_OFFSET)
# define SAM_PORTD_PINCFG9 (SAM_PORTD_BASE + SAM_PORT_PINCFG9_OFFSET)
# define SAM_PORTD_PINCFG10 (SAM_PORTD_BASE + SAM_PORT_PINCFG10_OFFSET)
# define SAM_PORTD_PINCFG11 (SAM_PORTD_BASE + SAM_PORT_PINCFG11_OFFSET)
# define SAM_PORTD_PINCFG12 (SAM_PORTD_BASE + SAM_PORT_PINCFG12_OFFSET)
# define SAM_PORTD_PINCFG13 (SAM_PORTD_BASE + SAM_PORT_PINCFG13_OFFSET)
# define SAM_PORTD_PINCFG14 (SAM_PORTD_BASE + SAM_PORT_PINCFG14_OFFSET)
# define SAM_PORTD_PINCFG15 (SAM_PORTD_BASE + SAM_PORT_PINCFG15_OFFSET)
# define SAM_PORTD_PINCFG16 (SAM_PORTD_BASE + SAM_PORT_PINCFG16_OFFSET)
# define SAM_PORTD_PINCFG17 (SAM_PORTD_BASE + SAM_PORT_PINCFG17_OFFSET)
# define SAM_PORTD_PINCFG18 (SAM_PORTD_BASE + SAM_PORT_PINCFG18_OFFSET)
# define SAM_PORTD_PINCFG19 (SAM_PORTD_BASE + SAM_PORT_PINCFG19_OFFSET)
# define SAM_PORTD_PINCFG20 (SAM_PORTD_BASE + SAM_PORT_PINCFG20_OFFSET)
# define SAM_PORTD_PINCFG21 (SAM_PORTD_BASE + SAM_PORT_PINCFG21_OFFSET)
# define SAM_PORTD_PINCFG22 (SAM_PORTD_BASE + SAM_PORT_PINCFG22_OFFSET)
# define SAM_PORTD_PINCFG23 (SAM_PORTD_BASE + SAM_PORT_PINCFG23_OFFSET)
# define SAM_PORTD_PINCFG24 (SAM_PORTD_BASE + SAM_PORT_PINCFG24_OFFSET)
# define SAM_PORTD_PINCFG25 (SAM_PORTD_BASE + SAM_PORT_PINCFG25_OFFSET)
# define SAM_PORTD_PINCFG26 (SAM_PORTD_BASE + SAM_PORT_PINCFG26_OFFSET)
# define SAM_PORTD_PINCFG27 (SAM_PORTD_BASE + SAM_PORT_PINCFG27_OFFSET)
# define SAM_PORTD_PINCFG28 (SAM_PORTD_BASE + SAM_PORT_PINCFG28_OFFSET)
# define SAM_PORTD_PINCFG29 (SAM_PORTD_BASE + SAM_PORT_PINCFG29_OFFSET)
# define SAM_PORTD_PINCFG30 (SAM_PORTD_BASE + SAM_PORT_PINCFG30_OFFSET)
# define SAM_PORTD_PINCFG31 (SAM_PORTD_BASE + SAM_PORT_PINCFG31_OFFSET)
/* PORT register bit definitions ************************************************************/
/* Data direction, data direction clear, data direction set, and data direction toggle
* registers
*/
#define PORT_DIR(n) (1 << n) /* Port data n, direction, n=0-31 */
/* Data output value, data output value clear, data output value set, and data output
* value toggle registers
*/
#define PORT_OUT(n) (1 << n) /* Port data n output value, n=0-31 */
/* Data input value register */
#define PORT_IN(n) (1 << n) /* Port n data input value, n=0-31 */
/* Control register */
#define PORT_CTRL(n) (1 << n) /* Port n input sampling mode, n=0-31 */
/* Write configuration registers */
#define PORT_WRCONFIG_PINMASK_SHIFT (0) /* Bits 0-15: Pin Mask for Multiple Pin Configuration */
#define PORT_WRCONFIG_PINMASK_MASK (0xffff << PORT_WRCONFIG_PINMASK_SHIFT)
# define PORT_WRCONFIG_PINMASK(n) (1 << (PORT_WRCONFIG_PINMASK_SHIFT+(n)))
#define PORT_WRCONFIG_PMUXEN (1 << 16) /* Bit 16: Peripheral Multiplexer Enable */
#define PORT_WRCONFIG_INEN (1 << 17) /* Bit 17: Input Enable */
#define PORT_WRCONFIG_PULLEN (1 << 18) /* Bit 18: Pull Enable */
#define PORT_WRCONFIG_DRVSTR (1 << 22) /* Bit 22: Output Driver Strength Selection */
#define PORT_WRCONFIG_PMUX_SHIFT (24) /* Bits 24-27: Peripheral Multiplexing */
#define PORT_WRCONFIG_PMUX_MASK (15 << PORT_WRCONFIG_PMUX_SHIFT)
# define PORT_WRCONFIG_PMUX(n) ((uint32_t)(n) << PORT_WRCONFIG_PMUX_SHIFT)
#define PORT_WRCONFIG_WRPMUX (1 << 28) /* Bit 28: Write PMUX */
#define PORT_WRCONFIG_WRPINCFG (1 << 30) /* Bit 30: Write PINCFG */
#define PORT_WRCONFIG_HWSEL (1 << 31) /* Bit 31: Half-Word Select */
/* Event input control register */
#define PORT_EVCTRL_PID_SHIFT(n) ((n) << 3) /* Port event pin identifier n, n=0..3 */
#define PORT_EVCTRL_PID_MASK(n) (31 << PORT_EVCTRL_PID_SHIFT(n))
# define PORT_EVCTRL_PID(n,v) ((unint32_t)(v) << PORT_EVCTRL_PID_SHIFT(n))
#define PORT_EVCTRL_EVACT_SHIFT(n) (((n) << 3) + 5) /* Port event pin action n, n=0..3 */
#define PORT_EVCTRL_EVACT_MASK(n) (3 << PORT_EVCTRL_EVACT_SHIFT(n))
# define PORT_EVCTRL_EVACT(n,v) ((unint32_t)(v) << PORT_EVCTRL_EVACT_SHIFT(n))
#define PORT_EVCTRL_PORTEI(n) (((n) << 3) + 7) /* Port event input enable n, n=0..3 */
#define PORT_EVCTRL_PID0_SHIFT (0) /* Bits 0-4: Port event pin identifier 0 */
#define PORT_EVCTRL_PID0_MASK (31 << PORT_EVCTRL_PID0_SHIFT)
# define PORT_EVCTRL_PID0(v) ((unint32_t)(v) << PORT_EVCTRL_PID0_SHIFT)
#define PORT_EVCTRL_EVACT0_SHIFT (5) /* Bits 5-6: Port event pin action 0 */
#define PORT_EVCTRL_EVACT0_MASK (3 << PORT_EVCTRL_EVACT0_SHIFT)
# define PORT_EVCTRL_EVACT0(v) ((unint32_t)(v) << PORT_EVCTRL_EVACT0_SHIFT)
#define PORT_EVCTRL_PORTEI0 (1 << 7) /* Bit 7: Port event input enable 0 */
#define PORT_EVCTRL_PID1_SHIFT (8) /* Bits 8-12: Port event pin identifier 1 */
#define PORT_EVCTRL_PID1_MASK (31 << PORT_EVCTRL_PID1_SHIFT)
# define PORT_EVCTRL_PID1(v) ((unint32_t)(v) << PORT_EVCTRL_PID1_SHIFT)
#define PORT_EVCTRL_EVACT1_SHIFT (13) /* Bits 13-14: Port event pin action 1 */
#define PORT_EVCTRL_EVACT1_MASK (3 << PORT_EVCTRL_EVACT1_SHIFT)
# define PORT_EVCTRL_EVACT1(v) ((unint32_t)(v) << PORT_EVCTRL_EVACT1_SHIFT)
#define PORT_EVCTRL_PORTEI1 (1 << 15) /* Bit 15: Port event input enable 1 */
#define PORT_EVCTRL_PID2_SHIFT (16) /* Bits 16-20: Port event pin identifier 2 */
#define PORT_EVCTRL_PID2_MASK (31 << PORT_EVCTRL_PID2_SHIFT)
# define PORT_EVCTRL_PID2(v) ((unint32_t)(v) << PORT_EVCTRL_PID2_SHIFT)
#define PORT_EVCTRL_EVACT2_SHIFT (21) /* Bits 21-22: Port event pin action 2 */
#define PORT_EVCTRL_EVACT2_MASK (3 << PORT_EVCTRL_EVACT2_SHIFT)
# define PORT_EVCTRL_EVACT2(v) ((unint32_t)(v) << PORT_EVCTRL_EVACT2_SHIFT)
#define PORT_EVCTRL_PORTEI2 (1 << 23) /* Bit 23: Port event input enable 2 */
#define PORT_EVCTRL_PID3_SHIFT (24) /* Bits 24-28: Port event pin identifier 3 */
#define PORT_EVCTRL_PID3_MASK (31 << PORT_EVCTRL_PID3_SHIFT)
# define PORT_EVCTRL_PID3(v) ((unint32_t)(v) << PORT_EVCTRL_PID3_SHIFT)
#define PORT_EVCTRL_EVACT3_SHIFT (29) /* Bits 29-30: Port event pin action 3 */
#define PORT_EVCTRL_EVACT3_MASK (3 << PORT_EVCTRL_EVACT3_SHIFT)
# define PORT_EVCTRL_EVACT3(v) ((unint32_t)(v) << PORT_EVCTRL_EVACT3_SHIFT)
#define PORT_EVCTRL_PORTEI3 (1 << 31) /* Bit 31: Port event input enable 3 */
/* Peripheral multiplexing registers */
#define PORT_PMUXE_SHIFT (0) /* Bits 0-3: Peripheral multiplexing even */
#define PORT_PMUXE_MASK (15 << PORT_PMUXE_SHIFT)
# define PORT_PMUXE_PERIPHA (0 << PORT_PMUXE_SHIFT) /* Peripheral function A */
# define PORT_PMUXE_PERIPHB (1 << PORT_PMUXE_SHIFT) /* Peripheral function B */
# define PORT_PMUXE_PERIPHC (2 << PORT_PMUXE_SHIFT) /* Peripheral function C */
# define PORT_PMUXE_PERIPHD (3 << PORT_PMUXE_SHIFT) /* Peripheral function D */
# define PORT_PMUXE_PERIPHE (4 << PORT_PMUXE_SHIFT) /* Peripheral function E */
# define PORT_PMUXE_PERIPHF (5 << PORT_PMUXE_SHIFT) /* Peripheral function F */
# define PORT_PMUXE_PERIPHG (6 << PORT_PMUXE_SHIFT) /* Peripheral function G */
# define PORT_PMUXE_PERIPHH (7 << PORT_PMUXE_SHIFT) /* Peripheral function H */
# define PORT_PMUXE_PERIPHI (8 << PORT_PMUXE_SHIFT) /* Peripheral function I */
# define PORT_PMUXE_PERIPHJ (9 << PORT_PMUXE_SHIFT) /* Peripheral function J */
# define PORT_PMUXE_PERIPHK (10 << PORT_PMUXE_SHIFT) /* Peripheral function K */
# define PORT_PMUXE_PERIPHL (11 << PORT_PMUXE_SHIFT) /* Peripheral function L */
# define PORT_PMUXE_PERIPHM (12 << PORT_PMUXE_SHIFT) /* Peripheral function M */
# define PORT_PMUXE_PERIPHN (13 << PORT_PMUXE_SHIFT) /* Peripheral function N */
#define PORT_PMUXO_SHIFT (4) /* Bits 4-7: Peripheral multiplexing odd */
#define PORT_PMUXO_MASK (15 << PORT_PMUXO_SHIFT)
# define PORT_PMUXO_PERIPHA (0 << PORT_PMUXO_SHIFT) /* Peripheral function A */
# define PORT_PMUXO_PERIPHB (1 << PORT_PMUXO_SHIFT) /* Peripheral function B */
# define PORT_PMUXO_PERIPHC (2 << PORT_PMUXO_SHIFT) /* Peripheral function C */
# define PORT_PMUXO_PERIPHD (3 << PORT_PMUXO_SHIFT) /* Peripheral function D */
# define PORT_PMUXO_PERIPHE (4 << PORT_PMUXO_SHIFT) /* Peripheral function E */
# define PORT_PMUXO_PERIPHF (5 << PORT_PMUXO_SHIFT) /* Peripheral function F */
# define PORT_PMUXO_PERIPHG (6 << PORT_PMUXO_SHIFT) /* Peripheral function G */
# define PORT_PMUXO_PERIPHH (7 << PORT_PMUXO_SHIFT) /* Peripheral function H */
# define PORT_PMUXO_PERIPHI (8 << PORT_PMUXO_SHIFT) /* Peripheral function I */
# define PORT_PMUXO_PERIPHJ (9 << PORT_PMUXO_SHIFT) /* Peripheral function J */
# define PORT_PMUXO_PERIPHK (10 << PORT_PMUXO_SHIFT) /* Peripheral function K */
# define PORT_PMUXO_PERIPHL (11 << PORT_PMUXO_SHIFT) /* Peripheral function L */
# define PORT_PMUXO_PERIPHM (12 << PORT_PMUXO_SHIFT) /* Peripheral function M */
# define PORT_PMUXO_PERIPHN (13 << PORT_PMUXO_SHIFT) /* Peripheral function N */
/* Pin configuration registers */
#define PORT_PINCFG_PMUXEN (1 << 0) /* Bit 0: Peripheral Multiplexer Enable */
#define PORT_PINCFG_INEN (1 << 1) /* Bit 1: Input Enable */
#define PORT_PINCFG_PULLEN (1 << 2) /* Bit 2: Pull Enable */
#define PORT_PINCFG_DRVSTR (1 << 6) /* Bit 6: Output Driver Strength Selection */
/********************************************************************************************
* Public Types
********************************************************************************************/
/********************************************************************************************
* Public Data
********************************************************************************************/
/********************************************************************************************
* Public Functions
********************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_PORT_H */

View File

@ -0,0 +1,91 @@
/********************************************************************************************
* arch/arm/src/samd5e5/chip/sam_rstc.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_SAMD5E5_CHIP_SAM_RSTC_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_RSTC_H
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
#include "chip/sam_memorymap.h"
/********************************************************************************************
* Pre-processor Definitions
********************************************************************************************/
/* RSTC register offsets ********************************************************************/
#define SAM_RSTC_RCAUSE_OFFSET 0x0000 /* Reset cause */
#define SAM_RSTC_BKUPEXIT_OFFSET 0x0002 /* Backup exit source */
/* RSTC register addresses ******************************************************************/
#define SAM_RSTC_RCAUSE (SAM_RSTC_BASE + SAM_RSTC_RCAUSE_OFFSET)
#define SAM_RSTC_BKUPEXIT (SAM_RSTC_BASE + SAM_RSTC_BKUPEXIT_OFFSET)
/* RSTC register bit definitions ************************************************************/
/* Reset cause */
#define RSTC_RCAUSE_POR (1 << 0) /* Bit 0: Power on reset */
#define RSTC_RCAUSE_BOD12 (1 << 1) /* Bit 1: Brown out 12 detector reset */
#define RSTC_RCAUSE_BOD33 (1 << 2) /* Bit 2: Brown out 33 detector reset */
#define RSTC_RCAUSE_NVM (1 << 3) /* Bit 3: External reset */
#define RSTC_RCAUSE_EXT (1 << 4) /* Bit 4: External reset */
#define RSTC_RCAUSE_WDT (1 << 5) /* Bit 5: Watchdog reset */
#define RSTC_RCAUSE_SYST (1 << 6) /* Bit 6: System reset request */
#define RSTC_RCAUSE_BACKUP (1 << 7) /* Bit 7: Backup reset*/
/* Backup exit source */
#define RSTC_BKUPEXIT_RTC (1 << 1) /* Bit 1: Real time counter interrupt */
#define RSTC_BKUPEXIT_BBPS (1 << 2) /* Bit 2: Battery backup power switch */
#define RSTC_BKUPEXIT_HIB (1 << 7) /* Bit 7: Hibernate */
/********************************************************************************************
* Public Types
********************************************************************************************/
/********************************************************************************************
* Public Data
********************************************************************************************/
/********************************************************************************************
* Public Functions
********************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_RSTC_H */

View File

@ -0,0 +1,303 @@
/********************************************************************************************
* arch/arm/src/samd5e5/chip/sam_spi.h
*
* Copyright (C) 2018 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_SAMD5E5_CHIP_SAM_SPI_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_SPI_H
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
#include "chip/sam_memorymap.h"
/********************************************************************************************
* Pre-processor Definitions
********************************************************************************************/
/* SPI register offsets *********************************************************************/
#define SAM_SPI_CTRLA_OFFSET 0x0000 /* Control A register */
#define SAM_SPI_CTRLB_OFFSET 0x0004 /* Control B register */
#define SAM_SPI_CTRLC_OFFSET 0x0008 /* Control C register */
#define SAM_SPI_BAUD_OFFSET 0x000c /* Baud register */
#define SAM_SPI_INTENCLR_OFFSET 0x0014 /* Interrupt enable clear register */
#define SAM_SPI_INTENSET_OFFSET 0x0016 /* Interrupt enable set register */
#define SAM_SPI_INTFLAG_OFFSET 0x0018 /* Interrupt flag and status clear register */
#define SAM_SPI_STATUS_OFFSET 0x001a /* Status register */
#define SAM_SPI_SYNCBUSY_OFFSET 0x001c /* Synchronization busy register */
#define SAM_SPI_LENGTH_OFFSET 0x0022 /* Length register */
#define SAM_SPI_ADDR_OFFSET 0x0024 /* Address register */
#define SAM_SPI_DATA_OFFSET 0x0028 /* Data register */
#define SAM_SPI_DBGCTRL_OFFSET 0x0030 /* Debug control register */
/* SPI register addresses *******************************************************************/
#define SAM_SPI0_CTRLA (SAM_SERCOM0_BASE + SAM_SPI_CTRLA_OFFSET)
#define SAM_SPI0_CTRLB (SAM_SERCOM0_BASE + SAM_SPI_CTRLB_OFFSET)
#define SAM_SPI0_CTRLC (SAM_SERCOM0_BASE + SAM_SPI_CTRLC_OFFSET)
#define SAM_SPI0_BAUD (SAM_SERCOM0_BASE + SAM_SPI_BAUD_OFFSET)
#define SAM_SPI0_INTENCLR (SAM_SERCOM0_BASE + SAM_SPI_INTENCLR_OFFSET)
#define SAM_SPI0_INTENSET (SAM_SERCOM0_BASE + SAM_SPI_INTENSET_OFFSET)
#define SAM_SPI0_INTFLAG (SAM_SERCOM0_BASE + SAM_SPI_INTFLAG_OFFSET)
#define SAM_SPI0_STATUS (SAM_SERCOM0_BASE + SAM_SPI_STATUS_OFFSET)
#define SAM_SPI0_SYNCBUSY (SAM_SERCOM0_BASE + SAM_SPI_SYNCBUSY_OFFSET)
#define SAM_SPI0_LENGTH (SAM_SERCOM0_BASE + SAM_SPI_LENGTH_OFFSET)
#define SAM_SPI0_ADDR (SAM_SERCOM0_BASE + SAM_SPI_ADDR_OFFSET)
#define SAM_SPI0_DATA (SAM_SERCOM0_BASE + SAM_SPI_DATA_OFFSET)
#define SAM_SPI0_DBGCTRL (SAM_SERCOM0_BASE + SAM_SPI_DBGCTRL_OFFSET)
#define SAM_SPI1_CTRLA (SAM_SERCOM1_BASE + SAM_SPI_CTRLA_OFFSET)
#define SAM_SPI1_CTRLB (SAM_SERCOM1_BASE + SAM_SPI_CTRLB_OFFSET)
#define SAM_SPI1_CTRLC (SAM_SERCOM1_BASE + SAM_SPI_CTRLC_OFFSET)
#define SAM_SPI1_BAUD (SAM_SERCOM1_BASE + SAM_SPI_BAUD_OFFSET)
#define SAM_SPI1_INTENCLR (SAM_SERCOM1_BASE + SAM_SPI_INTENCLR_OFFSET)
#define SAM_SPI1_INTENSET (SAM_SERCOM1_BASE + SAM_SPI_INTENSET_OFFSET)
#define SAM_SPI1_INTFLAG (SAM_SERCOM1_BASE + SAM_SPI_INTFLAG_OFFSET)
#define SAM_SPI1_STATUS (SAM_SERCOM1_BASE + SAM_SPI_STATUS_OFFSET)
#define SAM_SPI1_SYNCBUSY (SAM_SERCOM1_BASE + SAM_SPI_SYNCBUSY_OFFSET)
#define SAM_SPI1_LENGTH (SAM_SERCOM1_BASE + SAM_SPI_LENGTH_OFFSET)
#define SAM_SPI1_ADDR (SAM_SERCOM1_BASE + SAM_SPI_ADDR_OFFSET)
#define SAM_SPI1_DATA (SAM_SERCOM1_BASE + SAM_SPI_DATA_OFFSET)
#define SAM_SPI1_DBGCTRL (SAM_SERCOM1_BASE + SAM_SPI_DBGCTRL_OFFSET)
#define SAM_SPI2_CTRLA (SAM_SERCOM2_BASE + SAM_SPI_CTRLA_OFFSET)
#define SAM_SPI2_CTRLB (SAM_SERCOM2_BASE + SAM_SPI_CTRLB_OFFSET)
#define SAM_SPI2_CTRLC (SAM_SERCOM2_BASE + SAM_SPI_CTRLC_OFFSET)
#define SAM_SPI2_BAUD (SAM_SERCOM2_BASE + SAM_SPI_BAUD_OFFSET)
#define SAM_SPI2_INTENCLR (SAM_SERCOM2_BASE + SAM_SPI_INTENCLR_OFFSET)
#define SAM_SPI2_INTENSET (SAM_SERCOM2_BASE + SAM_SPI_INTENSET_OFFSET)
#define SAM_SPI2_INTFLAG (SAM_SERCOM2_BASE + SAM_SPI_INTFLAG_OFFSET)
#define SAM_SPI2_STATUS (SAM_SERCOM2_BASE + SAM_SPI_STATUS_OFFSET)
#define SAM_SPI2_SYNCBUSY (SAM_SERCOM2_BASE + SAM_SPI_SYNCBUSY_OFFSET)
#define SAM_SPI2_LENGTH (SAM_SERCOM2_BASE + SAM_SPI_LENGTH_OFFSET)
#define SAM_SPI2_ADDR (SAM_SERCOM2_BASE + SAM_SPI_ADDR_OFFSET)
#define SAM_SPI2_DATA (SAM_SERCOM2_BASE + SAM_SPI_DATA_OFFSET)
#define SAM_SPI2_DBGCTRL (SAM_SERCOM2_BASE + SAM_SPI_DBGCTRL_OFFSET)
#define SAM_SPI3_CTRLA (SAM_SERCOM3_BASE + SAM_SPI_CTRLA_OFFSET)
#define SAM_SPI3_CTRLB (SAM_SERCOM3_BASE + SAM_SPI_CTRLB_OFFSET)
#define SAM_SPI3_CTRLC (SAM_SERCOM3_BASE + SAM_SPI_CTRLC_OFFSET)
#define SAM_SPI3_BAUD (SAM_SERCOM3_BASE + SAM_SPI_BAUD_OFFSET)
#define SAM_SPI3_INTENCLR (SAM_SERCOM3_BASE + SAM_SPI_INTENCLR_OFFSET)
#define SAM_SPI3_INTENSET (SAM_SERCOM3_BASE + SAM_SPI_INTENSET_OFFSET)
#define SAM_SPI3_INTFLAG (SAM_SERCOM3_BASE + SAM_SPI_INTFLAG_OFFSET)
#define SAM_SPI3_STATUS (SAM_SERCOM3_BASE + SAM_SPI_STATUS_OFFSET)
#define SAM_SPI3_SYNCBUSY (SAM_SERCOM3_BASE + SAM_SPI_SYNCBUSY_OFFSET)
#define SAM_SPI3_LENGTH (SAM_SERCOM3_BASE + SAM_SPI_LENGTH_OFFSET)
#define SAM_SPI3_ADDR (SAM_SERCOM3_BASE + SAM_SPI_ADDR_OFFSET)
#define SAM_SPI3_DATA (SAM_SERCOM3_BASE + SAM_SPI_DATA_OFFSET)
#define SAM_SPI3_DBGCTRL (SAM_SERCOM3_BASE + SAM_SPI_DBGCTRL_OFFSET)
#define SAM_SPI4_CTRLA (SAM_SERCOM4_BASE + SAM_SPI_CTRLA_OFFSET)
#define SAM_SPI4_CTRLB (SAM_SERCOM4_BASE + SAM_SPI_CTRLB_OFFSET)
#define SAM_SPI4_CTRLC (SAM_SERCOM4_BASE + SAM_SPI_CTRLC_OFFSET)
#define SAM_SPI4_BAUD (SAM_SERCOM4_BASE + SAM_SPI_BAUD_OFFSET)
#define SAM_SPI4_INTENCLR (SAM_SERCOM4_BASE + SAM_SPI_INTENCLR_OFFSET)
#define SAM_SPI4_INTENSET (SAM_SERCOM4_BASE + SAM_SPI_INTENSET_OFFSET)
#define SAM_SPI4_INTFLAG (SAM_SERCOM4_BASE + SAM_SPI_INTFLAG_OFFSET)
#define SAM_SPI4_STATUS (SAM_SERCOM4_BASE + SAM_SPI_STATUS_OFFSET)
#define SAM_SPI4_SYNCBUSY (SAM_SERCOM4_BASE + SAM_SPI_SYNCBUSY_OFFSET)
#define SAM_SPI4_LENGTH (SAM_SERCOM4_BASE + SAM_SPI_LENGTH_OFFSET)
#define SAM_SPI4_ADDR (SAM_SERCOM4_BASE + SAM_SPI_ADDR_OFFSET)
#define SAM_SPI4_DATA (SAM_SERCOM4_BASE + SAM_SPI_DATA_OFFSET)
#define SAM_SPI4_DBGCTRL (SAM_SERCOM4_BASE + SAM_SPI_DBGCTRL_OFFSET)
#define SAM_SPI5_CTRLA (SAM_SERCOM5_BASE + SAM_SPI_CTRLA_OFFSET)
#define SAM_SPI5_CTRLB (SAM_SERCOM5_BASE + SAM_SPI_CTRLB_OFFSET)
#define SAM_SPI5_BAUD (SAM_SERCOM5_BASE + SAM_SPI_BAUD_OFFSET)
#define SAM_SPI5_CTRLC (SAM_SERCOM5_BASE + SAM_SPI_CTRLC_OFFSET)
#define SAM_SPI5_INTENCLR (SAM_SERCOM5_BASE + SAM_SPI_INTENCLR_OFFSET)
#define SAM_SPI5_INTENSET (SAM_SERCOM5_BASE + SAM_SPI_INTENSET_OFFSET)
#define SAM_SPI5_INTFLAG (SAM_SERCOM5_BASE + SAM_SPI_INTFLAG_OFFSET)
#define SAM_SPI5_STATUS (SAM_SERCOM5_BASE + SAM_SPI_STATUS_OFFSET)
#define SAM_SPI5_SYNCBUSY (SAM_SERCOM5_BASE + SAM_SPI_SYNCBUSY_OFFSET)
#define SAM_SPI5_LENGTH (SAM_SERCOM5_BASE + SAM_SPI_LENGTH_OFFSET)
#define SAM_SPI5_ADDR (SAM_SERCOM5_BASE + SAM_SPI_ADDR_OFFSET)
#define SAM_SPI5_DATA (SAM_SERCOM5_BASE + SAM_SPI_DATA_OFFSET)
#define SAM_SPI5_DBGCTRL (SAM_SERCOM5_BASE + SAM_SPI_DBGCTRL_OFFSET)
#define SAM_SPI6_CTRLA (SAM_SERCOM6_BASE + SAM_SPI_CTRLA_OFFSET)
#define SAM_SPI6_CTRLB (SAM_SERCOM6_BASE + SAM_SPI_CTRLB_OFFSET)
#define SAM_SPI6_BAUD (SAM_SERCOM6_BASE + SAM_SPI_BAUD_OFFSET)
#define SAM_SPI6_CTRLC (SAM_SERCOM6_BASE + SAM_SPI_CTRLC_OFFSET)
#define SAM_SPI6_INTENCLR (SAM_SERCOM6_BASE + SAM_SPI_INTENCLR_OFFSET)
#define SAM_SPI6_INTENSET (SAM_SERCOM6_BASE + SAM_SPI_INTENSET_OFFSET)
#define SAM_SPI6_INTFLAG (SAM_SERCOM6_BASE + SAM_SPI_INTFLAG_OFFSET)
#define SAM_SPI6_STATUS (SAM_SERCOM6_BASE + SAM_SPI_STATUS_OFFSET)
#define SAM_SPI6_SYNCBUSY (SAM_SERCOM6_BASE + SAM_SPI_SYNCBUSY_OFFSET)
#define SAM_SPI6_LENGTH (SAM_SERCOM6_BASE + SAM_SPI_LENGTH_OFFSET)
#define SAM_SPI6_ADDR (SAM_SERCOM6_BASE + SAM_SPI_ADDR_OFFSET)
#define SAM_SPI6_DATA (SAM_SERCOM6_BASE + SAM_SPI_DATA_OFFSET)
#define SAM_SPI6_DBGCTRL (SAM_SERCOM6_BASE + SAM_SPI_DBGCTRL_OFFSET)
#define SAM_SPI7_CTRLA (SAM_SERCOM7_BASE + SAM_SPI_CTRLA_OFFSET)
#define SAM_SPI7_CTRLB (SAM_SERCOM7_BASE + SAM_SPI_CTRLB_OFFSET)
#define SAM_SPI7_BAUD (SAM_SERCOM7_BASE + SAM_SPI_BAUD_OFFSET)
#define SAM_SPI7_CTRLC (SAM_SERCOM7_BASE + SAM_SPI_CTRLC_OFFSET)
#define SAM_SPI7_INTENCLR (SAM_SERCOM7_BASE + SAM_SPI_INTENCLR_OFFSET)
#define SAM_SPI7_INTENSET (SAM_SERCOM7_BASE + SAM_SPI_INTENSET_OFFSET)
#define SAM_SPI7_INTFLAG (SAM_SERCOM7_BASE + SAM_SPI_INTFLAG_OFFSET)
#define SAM_SPI7_STATUS (SAM_SERCOM7_BASE + SAM_SPI_STATUS_OFFSET)
#define SAM_SPI7_SYNCBUSY (SAM_SERCOM7_BASE + SAM_SPI_SYNCBUSY_OFFSET)
#define SAM_SPI7_LENGTH (SAM_SERCOM7_BASE + SAM_SPI_LENGTH_OFFSET)
#define SAM_SPI7_ADDR (SAM_SERCOM7_BASE + SAM_SPI_ADDR_OFFSET)
#define SAM_SPI7_DATA (SAM_SERCOM7_BASE + SAM_SPI_DATA_OFFSET)
#define SAM_SPI7_DBGCTRL (SAM_SERCOM7_BASE + SAM_SPI_DBGCTRL_OFFSET)
/* SPI register bit definitions *************************************************************/
/* Control A register */
#define SPI_CTRLA_SWRST (1 << 0) /* Bit 0: Software reset */
#define SPI_CTRLA_ENABLE (1 << 1) /* Bit 1: Enable */
#define SPI_CTRLA_MODE_SHIFT (2) /* Bits 2-4: Operating Mode */
#define SPI_CTRLA_MODE_MASK (7 << SPI_CTRLA_MODE_SHIFT)
# define SPI_CTRLA_MODE_SLAVE (2 << SPI_CTRLA_MODE_SHIFT) /* SPI slave operation */
# define SPI_CTRLA_MODE_MASTER (3 << SPI_CTRLA_MODE_SHIFT) /* SPI master operation */
#define SPI_CTRLA_RUNSTDBY (1 << 7) /* Bit 7: Run in standby */
#define SPI_CTRLA_IBON (1 << 8) /* Bit 8: Immediate BUFOVF notification */
#define SPI_CTRLA_DOPO_SHIFT (16) /* Bit 16-17: Data out pinout */
#define SPI_CTRLA_DOPO_MASK (3 << SPI_CTRLA_DOPO_SHIFT) /* Bit 16-17: Data out pinout */
# define SPI_CTRLA_DOPO_DOPAD012 (0 << SPI_CTRLA_DOPO_SHIFT) /* D0=PAD0 SCK=PAD1 SS=PAD2 */
# define SPI_CTRLA_DOPO_DOPAD312 (2 << SPI_CTRLA_DOPO_SHIFT) /* D0=PAD3 SCK=PAD1 SS=PAD2 */
#define SPI_CTRLA_DIPO_SHIFT (20) /* Bits 20-21: Data in pinout */
#define SPI_CTRLA_DIPO_MASK (3 << SPI_CTRLA_DIPO_SHIFT)
# define SPI_CTRLA_DIPAD0 (0 << SPI_CTRLA_DIPO_SHIFT) /* SERCOM PAD0 for DI */
# define SPI_CTRLA_DIPAD1 (1 << SPI_CTRLA_DIPO_SHIFT) /* SERCOM PAD1 for DI */
# define SPI_CTRLA_DIPAD2 (2 << SPI_CTRLA_DIPO_SHIFT) /* SERCOM PAD2 for DI */
# define SPI_CTRLA_DIPAD3 (3 << SPI_CTRLA_DIPO_SHIFT) /* SERCOM PAD3 for DI */
#define SPI_CTRLA_FORM_SHIFT (24) /* Bits 24-27: Frame format */
#define SPI_CTRLA_FORM_MASK (7 << SPI_CTRLA_FORM_SHIFT)
# define SPI_CTRLA_FORM_SPI (0 << SPI_CTRLA_FORM_SHIFT) /* SPI frame (no address) */
# define SPI_CTRLA_FORM_ADDR (2 << SPI_CTRLA_FORM_SHIFT) /* SPI frame (w/address) */
#define SPI_CTRLA_CPHA (1 << 28) /* Bit 28: Clock phase */
#define SPI_CTRLA_CPOL (1 << 29) /* Bit 29: Clock polarity */
#define SPI_CTRLA_DORD (1 << 30) /* Bit 30: Data order */
# define SPI_CTRLA_MSBFIRST (0)
# define SPI_CTRLA_LSBFIRST SPI_CTRLA_DORD
/* Control B register */
#define SPI_CTRLB_CHSIZE_SHIFT (0) /* Bits 0-2: Character Size */
#define SPI_CTRLB_CHSIZE_MASK (7 << SPI_CTRLB_CHSIZE_SHIFT)
# define SPI_CTRLB_CHSIZE_8BITS (0 << SPI_CTRLB_CHSIZE_SHIFT) /* 8 bits */
# define SPI_CTRLB_CHSIZE_9BITS (1 << SPI_CTRLB_CHSIZE_SHIFT) /* 9 bits */
#define SPI_CTRLB_PLOADEN (1 << 6) /* Bit 6: Slave Data Preload Enable */
#define SPI_CTRLB_SSDE (1 << 9) /* Bit 9: Slave select low detect enable */
#define SPI_CTRLB_MSSEN (1 << 13) /* Bit 13: Master slave select enable */
#define SPI_CTRLB_AMODE_SHIFT (14) /* Bits 14-15: Address Mode */
#define SPI_CTRLB_AMODE_MASK (3 << SPI_CTRLB_AMODE_SHIFT)
# define SPI_CTRLB_AMODE_ADDRMASK (0 << SPI_CTRLB_AMODE_SHIFT) /* ADDRMASK used to mask ADDR */
# define SPI_CTRLB_AMODE_2ADDRS (1 << SPI_CTRLB_AMODE_SHIFT) /* Slave 2 addresses: ADDR & ADDRMASK */
# define SPI_CTRLB_AMODE_RANGE (2 << SPI_CTRLB_AMODE_SHIFT) /* Slave range of addresses: ADDRMASK-ADDR */
#define SPI_CTRLB_RXEN (1 << 17) /* Bit 17: Receiver enable */
/* Control C register */
#
#define SPI_CTRLC_ICSPACE_SHIFT (0) /* Bits 0-2: Inter-Character Spacing */
#define SPI_CTRLC_ICSPACE_MASK (7 << SPI_CTRLC_ICSPACE_SHIFT)
# define SPI_CTRLC_ICSPACE_DISABLE (0 << SPI_CTRLC_ICSPACE_SHIFT)
# define SPI_CTRLC_ICSPACE(n) ((uint32_t)(n) << SPI_CTRLC_ICSPACE_SHIFT)
#define SPI_CTRLC_DATA32B (1 << 24 /* Bit 24: Data 32 Bit */
# define SPI_CTRLC_DATA32B_8BIT (0) /* DATA register is 8-bit */
# define SPI_CTRLC_DATA32B_32BIT SPI_CTRLC_DATA32B /* DATA register is 32-bit */
/* Baud register (8-bit baud value) */
/* Interrupt enable clear, interrupt enable set, interrupt enable set, interrupt flag and
* status clear registers.
*/
#define SPI_INT_DRE (1 << 0) /* Bit 0: Data register empty interrupt */
#define SPI_INT_TXC (1 << 1) /* Bit 1: Transmit complete interrupt */
#define SPI_INT_RXC (1 << 2) /* Bit 2: Receive complete interrupt */
#define SPI_INT_SSL (1 << 3) /* Bit 3: Slave select low interrupt */
#define SPI_INT_ERROR (1 << 7) /* Bit 7: Error interrupt */
#define SPI_INT_ALL (0x8f)
/* Status register */
#define SPI_STATUS_BUFOVF (1 << 2) /* Bit 2: Buffer overflow */
#define SPI_STATUS_LENERR (1 << 11) /* Bit 11: Transaction Length Error */
#define SPI_STATUS_CLRALL (SPI_STATUS_BUFOVF | SPI_STATUS_LENERR)
/* Synchronization busy register */
#define SPI_SYNCBUSY_SWRST (1 << 0) /* Bit 0: Software reset synchronization busy */
#define SPI_SYNCBUSY_ENABLE (1 << 1) /* Bit 1: SERCOM enable synchronization busy */
#define SPI_SYNCBUSY_CTRLB (1 << 2) /* Bit 2: CTRLB synchronization busy */
#define SPI_SYNCBUSY_LENGTH (1 << 4) /* Bit 4: LENGTH synchronization busy */
/* Length register */
#define SPI_LENGTH_LEN_SHIFT (0) /* Bit 0-7: Data length enable */
#define SPI_LENGTH_LEN_MASK (0xff << SPI_LENGTH_LEN_SHIFT)
# define SPI_LENGTHLEN(n) ((uint32_t)(n) << SPI_LENGTH_LEN_SHIFT)
#define SPI_LENGTH_LENEN (1 << 8) /* Bit 8: Data Length Enable */
/* Address register */
#define SPI_ADDR_SHIFT (0) /* Bits 0-7: Address */
#define SPI_ADDR_MASK (0xff << SPI_ADDR_SHIFT)
# define SPI_ADDR(n) ((uint32_t)(n) << SPI_ADDR_SHIFT)
#define SPI_ADDRMASK_SHIFT (16) /* Bits 16-23: Address Mask */
#define SPI_ADDRMASK_MASK (0xff << SPI_ADDRMASK_SHIFT)
# define SPI_ADDRMASK(n) ((uint32_t)(n) << SPI_ADDRMASK_SHIFT)
/* Data register (8-, 9- or 32-bit data) */
#define SPI_DATA_MASK9 (0x1ff) /* Bits 0-8: 8- or 9-bit Data */
/* Debug control register */
#define SPI_DBGCTRL_DBGSTOP (1 << 0) /* Bit 0: Debug stop mode */
/********************************************************************************************
* Public Types
********************************************************************************************/
/********************************************************************************************
* Public Data
********************************************************************************************/
/********************************************************************************************
* Public Functions
********************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_SPI_H */

View File

@ -0,0 +1,231 @@
/********************************************************************************************
* arch/arm/src/samd5e5/chip/sam_supc.h
*
* Copyright (C) 2018 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_SAMD5E5_CHIP_SAM_SUPC_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_SUPC_H
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
#include "chip.h"
/********************************************************************************************
* Pre-processor Definitions
********************************************************************************************/
/* SUPC register offsets *********************************************************************/
#define SAM_SUPC_INTENCLR_OFFSET 0x0000 /* Interrupt enable clear */
#define SAM_SUPC_INTENSET_OFFSET 0x0004 /* Interrupt enable set */
#define SAM_SUPC_INTFLAG_OFFSET 0x0008 /* Interrupt flag status and clear */
#define SAM_SUPC_STATUS_OFFSET 0x000c /* Status */
#define SAM_SUPC_BOD33_OFFSET 0x0010 /* 3.3V brown-out detector control */
#define SAM_SUPC_BOD12_OFFSET 0x0014 /* 1.2V brown-out detctor control */
#define SAM_SUPC_VREG_OFFSET 0x0018 /* Voltage regulator system control */
#define SAM_SUPC_VREF_OFFSET 0x001c /* Voltage references system control */
#define SAM_SUPC_BBPS_OFFSET 0x0020 /* Battery backup power switch control */
#define SAM_SUPC_BKOUT_OFFSET 0x0024 /* Backup output control */
#define SAM_SUPC_BKIN_OFFSET 0x0028 /* Backup input value */
/* SUPC register addresses *******************************************************************/
#define SAM_SUPC_INTENCLR (SAM_SUPC_BASE + SAM_SUPC_INTENCLR_OFFSET)
#define SAM_SUPC_INTENSET (SAM_SUPC_BASE + SAM_SUPC_INTENSET_OFFSET)
#define SAM_SUPC_INTFLAG (SAM_SUPC_BASE + SAM_SUPC_INTFLAG_OFFSET)
#define SAM_SUPC_STATUS (SAM_SUPC_BASE + SAM_SUPC_STATUS_OFFSET)
#define SAM_SUPC_BOD33 (SAM_SUPC_BASE + SAM_SUPC_BOD33_OFFSET)
#define SAM_SUPC_BOD12 (SAM_SUPC_BASE + SAM_SUPC_BOD12_OFFSET)
#define SAM_SUPC_VREG (SAM_SUPC_BASE + SAM_SUPC_VREG_OFFSET)
#define SAM_SUPC_VREF (SAM_SUPC_BASE + SAM_SUPC_VREF_OFFSET)
#define SAM_SUPC_BBPS (SAM_SUPC_BASE + SAM_SUPC_BBPS_OFFSET)
#define SAM_SUPC_BKOUT (SAM_SUPC_BASE + SAM_SUPC_BKOUT_OFFSET)
#define SAM_SUPC_BKIN (SAM_SUPC_BASE + SAM_SUPC_BKIN_OFFSET)
/* SUPC register bit definitions *************************************************************/
/* Interrupt enable clear, Interrupt enable set, Interrupt flag status and clear, and
* Status registers.
*/
#define SUPC_INT_BOD33RDY (1 << 0) /* Bit 0: BOD33 ready interrupt */
#define SUPC_INT_BOD33DET (1 << 1) /* Bit 1: BOD33 detection interrupt */
#define SUPC_INT_B33SRDY (1 << 2) /* Bit 2: BOD33 synchronization ready interrupt */
#define SUPC_INT_BOD12RDY (1 << 3) /* Bit 3: BOD12 ready interrupt */
#define SUPC_INT_BOD12DET (1 << 4) /* Bit 4: BOD12 detection interrupt */
#define SUPC_INT_B12SRDY (1 << 5) /* Bit 5: BOD12 synchronization ready interrupt */
#define SUPC_INT_VREGRDY (1 << 8) /* Bit 8: Voltage regulator ready interrupt */
#define SUPC_INT_VCORERDY (1 << 10) /* Bit 10: VDDCORE voltage ready interrupt */
#define SUPC_INT_ALL (0x0000053f)
/* 3.3V brown-out detector control register */
#define SUPC_BOD33_ENABLE (1 << 1) /* Bit 1: Enable */
#define SUPC_BOD33_ACTION_SHIFT (2) /* Bits 2-3: BOD33 action */
#define SUPC_BOD33_ACTION_MASK (3 << SUPC_BOD33_ACTION_SHIFT)
# define SUPC_BOD33_ACTION(n) ((n) << SUPC_BOD33_ACTION_SHIFT)
# define SUPC_BOD33_ACTION_NONE (0 << SUPC_BOD33_ACTION_SHIFT) /* No action */
# define SUPC_BOD33_ACTION_RESET (1 << SUPC_BOD33_ACTION_SHIFT) /* BOD33 generates reset */
# define SUPC_BOD33_ACTION_INTR (2 << SUPC_BOD33_ACTION_SHIFT) /* BOD33 generates interrupt */
# define SUPC_BOD33_ACTION_BKUP (3 << SUPC_BOD33_ACTION_SHIFT) /* BOD33 backup sleep mode */
#define SUPC_BOD33_STDBYCFG (1 << 4) /* Bit 4: BOD33 configuration in standby sleep mode */
#define SUPC_BOD33_RUNSTDBY (1 << 5) /* Bit 5: Run in standby */
#define SUPC_BOD33_RUNHIB (1 << 6) /* Bit 6: BOD33 configuration in hibernate sleep mode */
#define SUPC_BOD33_RUNBKUP (1 << 7) /* Bit 7: BOD33 configuration in backup sleep */
#define SUPC_BOD33_HYST_SHIFT (8) /* Bits 8-11: BOD33 Hysteresis Voltage Value on VDD */
#define SUPC_BOD33_HYST_MASK (15 << SUPC_BOD33_HYST_SHIFT)
# define SUPC_BOD33_HYST_NONE (0 << SUPC_BOD33_HYST_SHIFT)
# define SUPC_BOD33_HYST(n) ((uint32_t)(n) << SUPC_BOD33_HYST_SHIFT)
#define SUPC_BOD33_PSEL_SHIFT (12) /* Bits 12-14: Prescaler select */
#define SUPC_BOD33_PSEL_MASK (7 << SUPC_BOD33_PSEL_SHIFT)
# define SUPC_BOD33_PSEL(n) ((uint32_t)(n) << SUPC_BOD33_PSEL_SHIFT)
# define SUPC_BOD33_PSEL_NODIV (0 << SUPC_BOD33_PSEL_SHIFT) /* Not divided: Sampling mode is OFF */
# define SUPC_BOD33_PSEL_DIV4 (1 << SUPC_BOD33_PSEL_SHIFT) /* Divide clock by 4 */
# define SUPC_BOD33_PSEL_DIV8 (2 << SUPC_BOD33_PSEL_SHIFT) /* Divide clock by 8 */
# define SUPC_BOD33_PSEL_DIV16 (3 << SUPC_BOD33_PSEL_SHIFT) /* Divide clock by 16 */
# define SUPC_BOD33_PSEL_DIV32 (4 << SUPC_BOD33_PSEL_SHIFT) /* Divide clock by 32 */
# define SUPC_BOD33_PSEL_DIV64 (5 << SUPC_BOD33_PSEL_SHIFT) /* Divide clock by 64 */
# define SUPC_BOD33_PSEL_DIV128 (6 << SUPC_BOD33_PSEL_SHIFT) /* Divide clock by 128 */
# define SUPC_BOD33_PSEL_DIV256 (7 << SUPC_BOD33_PSEL_SHIFT) /* Divide clock by 256 */
#define SUPC_BOD33_LEVEL_SHIFT (16) /* Bits 16-23: BOD33 threshold level VDD */
#define SUPC_BOD33_LEVEL_MASK (0xff << SUPC_BOD33_LEVEL_SHIFT)
# define SUPC_BOD33_LEVEL(n) ((uint32_t)(n) << SUPC_BOD33_LEVEL_SHIFT)
#define SUPC_BOD33_VBATLEVEL_SHIFT (24) /* Bits 24-31: BOD33 Threshold Level on VBAT */
#define SUPC_BOD33_VBATLEVEL_MASK (0xff << SUPC_BOD33_VBATLEVEL_SHIFT)
# define SUPC_BOD33_VBATLEVEL(n) ((uint32_t)(n) << SUPC_BOD33_VBATLEVEL_SHIFT)
/* 1.2V brown-out detector control */
#define SUPC_BOD12_ENABLE (1 << 1) /* Bit 1: Enable */
#define SUPC_BOD12_HYST (1 << 2) /* Bit 2: Hysteresis */
#define SUPC_BOD12_ACTION_SHIFT (3) /* Bits 3-4: BOD12 action */
#define SUPC_BOD12_ACTION_MASK (3 << SUPC_BOD12_ACTION_SHIFT)
# define SUPC_BOD12_ACTION(n) ((n) << SUPC_BOD12_ACTION_SHIFT)
# define SUPC_BOD12_ACTION_NONE (0 << SUPC_BOD12_ACTION_SHIFT) /* No action */
# define SUPC_BOD12_ACTION_RESET (1 << SUPC_BOD12_ACTION_SHIFT) /* BOD12 generates reset */
# define SUPC_BOD12_ACTION_INTR (2 << SUPC_BOD12_ACTION_SHIFT) /* BOD12 generates interrupt */
#define SUPC_BOD12_STDBYCFG (1 << 5) /* Bit 5: BOD12 configuration in standby sleep mode */
#define SUPC_BOD12_RUNSTDBY (1 << 6) /* Bit 6: Run in standby */
#define SUPC_BOD12_ACTCFG (1 << 8) /* Bit 8: BOD12 configuration in active sleep */
#define SUPC_BOD12_PSEL_SHIFT (12) /* Bits 12-15: Prescaler select */
#define SUPC_BOD12_PSEL_MASK (15 << SUPC_BOD12_PSEL_SHIFT)
# define SUPC_BOD12_PSEL(n) ((uint32_t)(n) << SUPC_BOD12_PSEL_SHIFT)
# define SUPC_BOD12_PSEL_DIV2 (0 << SUPC_BOD12_PSEL_SHIFT) /* Divide clock by 2 */
# define SUPC_BOD12_PSEL_DIV4 (1 << SUPC_BOD12_PSEL_SHIFT) /* Divide clock by 4 */
# define SUPC_BOD12_PSEL_DIV8 (2 << SUPC_BOD12_PSEL_SHIFT) /* Divide clock by 8 */
# define SUPC_BOD12_PSEL_DIV16 (3 << SUPC_BOD12_PSEL_SHIFT) /* Divide clock by 16 */
# define SUPC_BOD12_PSEL_DIV32 (4 << SUPC_BOD12_PSEL_SHIFT) /* Divide clock by 32 */
# define SUPC_BOD12_PSEL_DIV64 (5 << SUPC_BOD12_PSEL_SHIFT) /* Divide clock by 64 */
# define SUPC_BOD12_PSEL_DIV128 (6 << SUPC_BOD12_PSEL_SHIFT) /* Divide clock by 128 */
# define SUPC_BOD12_PSEL_DIV256 (7 << SUPC_BOD12_PSEL_SHIFT) /* Divide clock by 256 */
# define SUPC_BOD12_PSEL_DIV512 (8 << SUPC_BOD12_PSEL_SHIFT) /* Divide clock by 512 */
# define SUPC_BOD12_PSEL_DIV1K (9 << SUPC_BOD12_PSEL_SHIFT) /* Divide clock by 1024 */
# define SUPC_BOD12_PSEL_DIV2K (10 << SUPC_BOD12_PSEL_SHIFT) /* Divide clock by 2048 */
# define SUPC_BOD12_PSEL_DIV4K (11 << SUPC_BOD12_PSEL_SHIFT) /* Divide clock by 4096 */
# define SUPC_BOD12_PSEL_DIV8K (12 << SUPC_BOD12_PSEL_SHIFT) /* Divide clock by 8192 */
# define SUPC_BOD12_PSEL_DIV16K (13 << SUPC_BOD12_PSEL_SHIFT) /* Divide clock by 16384 */
# define SUPC_BOD12_PSEL_DIV32K (14 << SUPC_BOD12_PSEL_SHIFT) /* Divide clock by 32768 */
# define SUPC_BOD12_PSEL_DIV64K (15 << SUPC_BOD12_PSEL_SHIFT) /* Divide clock by 65536 */
/* Voltage regulator system control */
#define SUPC_VREG_SEL (1 << 2) /* Bit 2: Voltage regulator selection */
#define SUPC_VREG_RUNBKUP (1 << 7) /* Bit 7: Run in Backup */
#define SUPC_VREG_VSEN (1 << 16) /* Bit 16: Voltage Scaling Enable */
#define SUPC_VREG_VSPER_SHIFT (24) /* Bits 24-26: Voltage scaling period */
#define SUPC_VREG_VSPER_MASK (7 << SUPC_VREG_VSPER_SHIFT)
# define SUPC_VREG_VSPER(n) ((uint32_t)(n) << SUPC_VREG_VSPER_SHIFT)
/* Voltage references system control register */
#define SUPC_VREF_TSEN (1 << 1) /* Bit 1: Temperature sensor enable */
#define SUPC_VREF_VREFOE (1 << 2) /* Bit 2: Voltage reference output enable */
#define SUPC_VREF_TSSEL (1 << 3) /* Bit 3: Temperature Sensor Channel Selection */
#define SUPC_VREF_RUNSTDBY (1 << 6) /* Bit 6: Run in standby */
#define SUPC_VREF_ONDEMAND (1 << 7) /* Bit 7: On demand control */
#define SUPC_VREF_SEL_SHIFT (16) /* Bits 16-19: Voltage reference selection */
#define SUPC_VREF_SEL_MASK (15 << SUPC_VREF_SEL_SHIFT)
# define SUPC_VREF_SEL_1V0 (0 << SUPC_VREF_SEL_SHIFT) /* 1.0V voltage reference typical value */
# define SUPC_VREF_SEL_1V1 (1 << SUPC_VREF_SEL_SHIFT) /* 1.1V voltage reference typical value */
# define SUPC_VREF_SEL_1V2 (2 << SUPC_VREF_SEL_SHIFT) /* 1.2V voltage reference typical value */
# define SUPC_VREF_SEL_1V25 (3 << SUPC_VREF_SEL_SHIFT) /* 1.25V voltage reference typical value */
# define SUPC_VREF_SEL_2V0 (4 << SUPC_VREF_SEL_SHIFT) /* 2.0V voltage reference typical value */
# define SUPC_VREF_SEL_2V2 (5 << SUPC_VREF_SEL_SHIFT) /* 2.2V voltage reference typical value */
# define SUPC_VREF_SEL_2V4 (6 << SUPC_VREF_SEL_SHIFT) /* 2.4V voltage reference typical value */
# define SUPC_VREF_SEL_2V5 (7 << SUPC_VREF_SEL_SHIFT) /* 5.5V voltage reference typical value */
/* Battery backup power switch control */
#define SUPC_BBPS_WAKEEN (1 << 2) /* Bit 2: Wake enable */
/* Backup output control */
#define SUPC_BKOUT_EN_SHIFT (0) /* Bits 0-1: Output enable */
#define SUPC_BKOUT_EN_MASK (3 << SUPC_BKOUT_EN_SHIFT)
# define SUPC_BKOUT_DISABLE (0 << SUPC_BKOUT_EN_SHIFT)
# define SUPC_BKOUT_ENABLE (1 << SUPC_BKOUT_EN_SHIFT)
#define SUPC_BKOUT_CLR_SHIFT (8) /* Bits 8-9: Clear output */
#define SUPC_BKOUT_CLR_MASK (3 << SUPC_BKOUT_CLR_SHIFT)
# define SUPC_BKOUT_CLR (1 << SUPC_BKOUT_CLR_SHIFT)
#define SUPC_BKOUT_SET_SHIFT (16) /* Bits 16-17: Set output */
#define SUPC_BKOUT_SET_MASK (3 << SUPC_BKOUT_SET_SHIFT)
# define SUPC_BKOUT_SET (1 << SUPC_BKOUT_SET_SHIFT)
#define SUPC_BKOUT_RTCTGL_SHIFT (24) /* Bits 24-25: RTC toggle output */
#define SUPC_BKOUT_RTCTGL_MASK (3 << SUPC_BKOUT_RTCTGL_SHIFT)
# define SUPC_BKOUT_RTCTGL_NONE (0 << SUPC_BKOUT_EN_SHIFT) /* No toggle */
# define SUPC_BKOUT_RTCTGL_TOGGLE (1 << SUPC_BKOUT_EN_SHIFT) /* Toggle */
/* Backup input value */
#define SUPC_BKIN_SHIFT (0) /* Bits 0-1: Backup I/O data input value */
#define SUPC_BKIN_MASK (3 << SUPC_BKIN_SHIFT)
# define SUPC_BKIN_OUT0 (1 << SUPC_BKIN_SHIFT) /* Input value of OUT[0] pin */
# define SUPC_BKIN_OUT1 (2 << SUPC_BKIN_SHIFT) /* Input value of OUT[1] pin */
/********************************************************************************************
* Public Types
********************************************************************************************/
/********************************************************************************************
* Public Data
********************************************************************************************/
/********************************************************************************************
* Public Functions
********************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_SUPC_H */

View File

@ -0,0 +1,96 @@
/********************************************************************************************
* arch/arm/src/samd5e5/chip/sam_trng.h
*
* Copyright (C) 2018 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_SAMD5E5_CHIP_SAM_TRNG_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_TRNG_H
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
#include "chip/sam_memorymap.h"
/********************************************************************************************
* Pre-processor Definitions
********************************************************************************************/
/* TRNG register offsets ********************************************************************/
#define SAM_TRNG_CTRLA_OFFSET 0x0000 /* Control A register */
#define SAM_TRNG_EVCTRL_OFFSET 0x0004 /* Event control register */
#define SAM_TRNG_INTENCLR_OFFSET 0x0008 /* Interrupt enable clear register */
#define SAM_TRNG_INTENSET_OFFSET 0x0009 /* Interrupt enable set register */
#define SAM_TRNG_INTFLAG_OFFSET 0x000a /* Interrupt flag and status clear register */
#define SAM_TRNG_DATA_OFFSET 0x0020 /* Output data register */
/* TRNG register addresses ******************************************************************/
#define SAM_TRNG_CTRLA (SAM_TRNG_BASE+SAM_TRNG_CTRLA_OFFSET)
#define SAM_TRNG_EVCTRL (SAM_TRNG_BASE+SAM_TRNG_EVCTRL_OFFSET)
#define SAM_TRNG_INTENCLR (SAM_TRNG_BASE+SAM_TRNG_INTENCLR_OFFSET)
#define SAM_TRNG_INTENSET (SAM_TRNG_BASE+SAM_TRNG_INTENSET_OFFSET)
#define SAM_TRNG_INTFLAG (SAM_TRNG_BASE+SAM_TRNG_INTFLAG_OFFSET)
#define SAM_TRNG_DATA (SAM_TRNG_BASE+SAM_TRNG_DATA_OFFSET)
/* TRNG register bit definitions ************************************************************/
/* Control register */
#define TRNG_CTRLA_ENABLE (1 << 1) /* Bit 1: Enable */
#define TRNG_CTRLA_RUNSTDBY (1 << 6) /* Bit 6: Run in standby */
/* Event control register, Interrupt enable clear, interrupt enable set register, interrupt
* flag status registers.
*/
#define TRNG_EVCTRL_DATARDYEO (1 << 0) /* Bit 0: Data ready event output */
/* Data register (32-bit data) */
/********************************************************************************************
* Public Types
********************************************************************************************/
/********************************************************************************************
* Public Data
********************************************************************************************/
/********************************************************************************************
* Public Functions
********************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_TRNG_H */

View File

@ -0,0 +1,391 @@
/********************************************************************************************
* arch/arm/src/samd5e5/chip/sam_usart.h
*
* Copyright (C) 2018 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_SAMD5E5_CHIP_SAM_USART_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_USART_H
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
#include "chip/sam_memorymap.h"
/********************************************************************************************
* Pre-processor Definitions
********************************************************************************************/
/* USART register offsets *******************************************************************/
#define SAM_USART_CTRLA_OFFSET 0x0000 /* Control A register */
#define SAM_USART_CTRLB_OFFSET 0x0004 /* Control B register */
#define SAM_USART_CTRLC_OFFSET 0x0008 /* Control C register */
#define SAM_USART_BAUD_OFFSET 0x000c /* Baud register */
#define SAM_USART_RXPL_OFFSET 0x000e /* Receive pulse length register */
#define SAM_USART_INTENCLR_OFFSET 0x0014 /* Interrupt enable clear register */
#define SAM_USART_INTENSET_OFFSET 0x0016 /* Interrupt enable set register */
#define SAM_USART_INTFLAG_OFFSET 0x0018 /* Interrupt flag and status clear register */
#define SAM_USART_STATUS_OFFSET 0x001a /* Status register */
#define SAM_USART_SYNCBUSY_OFFSET 0x001c /* Synchronization busy register */
#define SAM_USART_RXERRCNT_OFFSET 0x0020 /* Receive error count register */
#define SAM_USART_LENGTH_OFFSET 0x0022 /* Length register */
#define SAM_USART_DATA_OFFSET 0x0028 /* Data register */
#define SAM_USART_DBGCTRL_OFFSET 0x0030 /* Debug control register */
/* USART register addresses *****************************************************************/
#define SAM_USART0_CTRLA (SAM_SERCOM0_BASE + SAM_USART_CTRLA_OFFSET)
#define SAM_USART0_CTRLB (SAM_SERCOM0_BASE + SAM_USART_CTRLB_OFFSET)
#define SAM_USART0_CTRLC (SAM_SERCOM0_BASE + SAM_USART_CTRLC_OFFSET)
#define SAM_USART0_BAUD (SAM_SERCOM0_BASE + SAM_USART_BAUD_OFFSET)
#define SAM_USART0_RXPL (SAM_SERCOM0_BASE + SAM_USART_RXPL_OFFSET)
#define SAM_USART0_INTENCLR (SAM_SERCOM0_BASE + SAM_USART_INTENCLR_OFFSET)
#define SAM_USART0_INTENSET (SAM_SERCOM0_BASE + SAM_USART_INTENSET_OFFSET)
#define SAM_USART0_INTFLAG (SAM_SERCOM0_BASE + SAM_USART_INTFLAG_OFFSET)
#define SAM_USART0_STATUS (SAM_SERCOM0_BASE + SAM_USART_STATUS_OFFSET)
#define SAM_USART0_SYNCBUSY (SAM_SERCOM0_BASE + SAM_USART_SYNCBUSY_OFFSET)
#define SAM_USART0_RXERRCNT (SAM_SERCOM0_BASE + SAM_USART_RXERRCNT_OFFSET)
#define SAM_USART0_LENGTH (SAM_SERCOM0_BASE + SAM_USART_LENGTH_OFFSET)
#define SAM_USART0_DATA (SAM_SERCOM0_BASE + SAM_USART_DATA_OFFSET)
#define SAM_USART0_DBGCTRL (SAM_SERCOM0_BASE + SAM_USART_DBGCTRL_OFFSET)
#define SAM_USART1_CTRLA (SAM_SERCOM1_BASE + SAM_USART_CTRLA_OFFSET)
#define SAM_USART1_CTRLB (SAM_SERCOM1_BASE + SAM_USART_CTRLB_OFFSET)
#define SAM_USART1_CTRLC (SAM_SERCOM1_BASE + SAM_USART_CTRLC_OFFSET)
#define SAM_USART1_BAUD (SAM_SERCOM1_BASE + SAM_USART_BAUD_OFFSET)
#define SAM_USART1_RXPL (SAM_SERCOM1_BASE + SAM_USART_RXPL_OFFSET)
#define SAM_USART1_INTENCLR (SAM_SERCOM1_BASE + SAM_USART_INTENCLR_OFFSET)
#define SAM_USART1_INTENSET (SAM_SERCOM1_BASE + SAM_USART_INTENSET_OFFSET)
#define SAM_USART1_INTFLAG (SAM_SERCOM1_BASE + SAM_USART_INTFLAG_OFFSET)
#define SAM_USART1_STATUS (SAM_SERCOM1_BASE + SAM_USART_STATUS_OFFSET)
#define SAM_USART1_SYNCBUSY (SAM_SERCOM1_BASE + SAM_USART_SYNCBUSY_OFFSET)
#define SAM_USART1_RXERRCNT (SAM_SERCOM1_BASE + SAM_USART_RXERRCNT_OFFSET)
#define SAM_USART1_LENGTH (SAM_SERCOM1_BASE + SAM_USART_LENGTH_OFFSET)
#define SAM_USART1_DATA (SAM_SERCOM1_BASE + SAM_USART_DATA_OFFSET)
#define SAM_USART1_DBGCTRL (SAM_SERCOM1_BASE + SAM_USART_DBGCTRL_OFFSET)
#define SAM_USART2_CTRLA (SAM_SERCOM2_BASE + SAM_USART_CTRLA_OFFSET)
#define SAM_USART2_CTRLB (SAM_SERCOM2_BASE + SAM_USART_CTRLB_OFFSET)
#define SAM_USART2_CTRLC (SAM_SERCOM2_BASE + SAM_USART_CTRLC_OFFSET)
#define SAM_USART2_BAUD (SAM_SERCOM2_BASE + SAM_USART_BAUD_OFFSET)
#define SAM_USART2_RXPL (SAM_SERCOM2_BASE + SAM_USART_RXPL_OFFSET)
#define SAM_USART2_INTENCLR (SAM_SERCOM2_BASE + SAM_USART_INTENCLR_OFFSET)
#define SAM_USART2_INTENSET (SAM_SERCOM2_BASE + SAM_USART_INTENSET_OFFSET)
#define SAM_USART2_INTFLAG (SAM_SERCOM2_BASE + SAM_USART_INTFLAG_OFFSET)
#define SAM_USART2_STATUS (SAM_SERCOM2_BASE + SAM_USART_STATUS_OFFSET)
#define SAM_USART2_SYNCBUSY (SAM_SERCOM2_BASE + SAM_USART_SYNCBUSY_OFFSET)
#define SAM_USART2_RXERRCNT (SAM_SERCOM2_BASE + SAM_USART_RXERRCNT_OFFSET)
#define SAM_USART2_LENGTH (SAM_SERCOM2_BASE + SAM_USART_LENGTH_OFFSET)
#define SAM_USART2_DATA (SAM_SERCOM2_BASE + SAM_USART_DATA_OFFSET)
#define SAM_USART2_DBGCTRL (SAM_SERCOM2_BASE + SAM_USART_DBGCTRL_OFFSET)
#define SAM_USART3_CTRLA (SAM_SERCOM3_BASE + SAM_USART_CTRLA_OFFSET)
#define SAM_USART3_CTRLB (SAM_SERCOM3_BASE + SAM_USART_CTRLB_OFFSET)
#define SAM_USART3_CTRLC (SAM_SERCOM3_BASE + SAM_USART_CTRLC_OFFSET)
#define SAM_USART3_BAUD (SAM_SERCOM3_BASE + SAM_USART_BAUD_OFFSET)
#define SAM_USART3_RXPL (SAM_SERCOM3_BASE + SAM_USART_RXPL_OFFSET)
#define SAM_USART3_INTENCLR (SAM_SERCOM3_BASE + SAM_USART_INTENCLR_OFFSET)
#define SAM_USART3_INTENSET (SAM_SERCOM3_BASE + SAM_USART_INTENSET_OFFSET)
#define SAM_USART3_INTFLAG (SAM_SERCOM3_BASE + SAM_USART_INTFLAG_OFFSET)
#define SAM_USART3_STATUS (SAM_SERCOM3_BASE + SAM_USART_STATUS_OFFSET)
#define SAM_USART3_SYNCBUSY (SAM_SERCOM3_BASE + SAM_USART_SYNCBUSY_OFFSET)
#define SAM_USART3_RXERRCNT (SAM_SERCOM3_BASE + SAM_USART_RXERRCNT_OFFSET)
#define SAM_USART3_LENGTH (SAM_SERCOM3_BASE + SAM_USART_LENGTH_OFFSET)
#define SAM_USART3_DATA (SAM_SERCOM3_BASE + SAM_USART_DATA_OFFSET)
#define SAM_USART3_DBGCTRL (SAM_SERCOM3_BASE + SAM_USART_DBGCTRL_OFFSET)
#define SAM_USART4_CTRLA (SAM_SERCOM4_BASE + SAM_USART_CTRLA_OFFSET)
#define SAM_USART4_CTRLB (SAM_SERCOM4_BASE + SAM_USART_CTRLB_OFFSET)
#define SAM_USART4_CTRLC (SAM_SERCOM4_BASE + SAM_USART_CTRLC_OFFSET)
#define SAM_USART4_BAUD (SAM_SERCOM4_BASE + SAM_USART_BAUD_OFFSET)
#define SAM_USART4_RXPL (SAM_SERCOM4_BASE + SAM_USART_RXPL_OFFSET)
#define SAM_USART4_INTENCLR (SAM_SERCOM4_BASE + SAM_USART_INTENCLR_OFFSET)
#define SAM_USART4_INTENSET (SAM_SERCOM4_BASE + SAM_USART_INTENSET_OFFSET)
#define SAM_USART4_INTFLAG (SAM_SERCOM4_BASE + SAM_USART_INTFLAG_OFFSET)
#define SAM_USART4_STATUS (SAM_SERCOM4_BASE + SAM_USART_STATUS_OFFSET)
#define SAM_USART4_SYNCBUSY (SAM_SERCOM4_BASE + SAM_USART_SYNCBUSY_OFFSET)
#define SAM_USART4_RXERRCNT (SAM_SERCOM4_BASE + SAM_USART_RXERRCNT_OFFSET)
#define SAM_USART4_LENGTH (SAM_SERCOM4_BASE + SAM_USART_LENGTH_OFFSET)
#define SAM_USART4_DATA (SAM_SERCOM4_BASE + SAM_USART_DATA_OFFSET)
#define SAM_USART4_DBGCTRL (SAM_SERCOM4_BASE + SAM_USART_DBGCTRL_OFFSET)
#define SAM_USART5_CTRLA (SAM_SERCOM5_BASE + SAM_USART_CTRLA_OFFSET)
#define SAM_USART5_CTRLB (SAM_SERCOM5_BASE + SAM_USART_CTRLB_OFFSET)
#define SAM_USART5_CTRLC (SAM_SERCOM5_BASE + SAM_USART_CTRLC_OFFSET)
#define SAM_USART5_BAUD (SAM_SERCOM5_BASE + SAM_USART_BAUD_OFFSET)
#define SAM_USART5_RXPL (SAM_SERCOM5_BASE + SAM_USART_RXPL_OFFSET)
#define SAM_USART5_INTENCLR (SAM_SERCOM5_BASE + SAM_USART_INTENCLR_OFFSET)
#define SAM_USART5_INTENSET (SAM_SERCOM5_BASE + SAM_USART_INTENSET_OFFSET)
#define SAM_USART5_INTFLAG (SAM_SERCOM5_BASE + SAM_USART_INTFLAG_OFFSET)
#define SAM_USART5_STATUS (SAM_SERCOM5_BASE + SAM_USART_STATUS_OFFSET)
#define SAM_USART5_SYNCBUSY (SAM_SERCOM5_BASE + SAM_USART_SYNCBUSY_OFFSET)
#define SAM_USART5_RXERRCNT (SAM_SERCOM5_BASE + SAM_USART_RXERRCNT_OFFSET)
#define SAM_USART5_LENGTH (SAM_SERCOM5_BASE + SAM_USART_LENGTH_OFFSET)
#define SAM_USART5_DATA (SAM_SERCOM5_BASE + SAM_USART_DATA_OFFSET)
#define SAM_USART5_DBGCTRL (SAM_SERCOM5_BASE + SAM_USART_DBGCTRL_OFFSET)
#define SAM_USART6_CTRLA (SAM_SERCOM6_BASE + SAM_USART_CTRLA_OFFSET)
#define SAM_USART6_CTRLB (SAM_SERCOM6_BASE + SAM_USART_CTRLB_OFFSET)
#define SAM_USART6_CTRLC (SAM_SERCOM6_BASE + SAM_USART_CTRLC_OFFSET)
#define SAM_USART6_BAUD (SAM_SERCOM6_BASE + SAM_USART_BAUD_OFFSET)
#define SAM_USART6_RXPL (SAM_SERCOM6_BASE + SAM_USART_RXPL_OFFSET)
#define SAM_USART6_INTENCLR (SAM_SERCOM6_BASE + SAM_USART_INTENCLR_OFFSET)
#define SAM_USART6_INTENSET (SAM_SERCOM6_BASE + SAM_USART_INTENSET_OFFSET)
#define SAM_USART6_INTFLAG (SAM_SERCOM6_BASE + SAM_USART_INTFLAG_OFFSET)
#define SAM_USART6_STATUS (SAM_SERCOM6_BASE + SAM_USART_STATUS_OFFSET)
#define SAM_USART6_SYNCBUSY (SAM_SERCOM6_BASE + SAM_USART_SYNCBUSY_OFFSET)
#define SAM_USART6_RXERRCNT (SAM_SERCOM6_BASE + SAM_USART_RXERRCNT_OFFSET)
#define SAM_USART6_LENGTH (SAM_SERCOM6_BASE + SAM_USART_LENGTH_OFFSET)
#define SAM_USART6_DATA (SAM_SERCOM6_BASE + SAM_USART_DATA_OFFSET)
#define SAM_USART6_DBGCTRL (SAM_SERCOM6_BASE + SAM_USART_DBGCTRL_OFFSET)
#define SAM_USART7_CTRLA (SAM_SERCOM7_BASE + SAM_USART_CTRLA_OFFSET)
#define SAM_USART7_CTRLB (SAM_SERCOM7_BASE + SAM_USART_CTRLB_OFFSET)
#define SAM_USART7_CTRLC (SAM_SERCOM7_BASE + SAM_USART_CTRLC_OFFSET)
#define SAM_USART7_BAUD (SAM_SERCOM7_BASE + SAM_USART_BAUD_OFFSET)
#define SAM_USART7_RXPL (SAM_SERCOM7_BASE + SAM_USART_RXPL_OFFSET)
#define SAM_USART7_INTENCLR (SAM_SERCOM7_BASE + SAM_USART_INTENCLR_OFFSET)
#define SAM_USART7_INTENSET (SAM_SERCOM7_BASE + SAM_USART_INTENSET_OFFSET)
#define SAM_USART7_INTFLAG (SAM_SERCOM7_BASE + SAM_USART_INTFLAG_OFFSET)
#define SAM_USART7_STATUS (SAM_SERCOM7_BASE + SAM_USART_STATUS_OFFSET)
#define SAM_USART7_SYNCBUSY (SAM_SERCOM7_BASE + SAM_USART_SYNCBUSY_OFFSET)
#define SAM_USART7_RXERRCNT (SAM_SERCOM7_BASE + SAM_USART_RXERRCNT_OFFSET)
#define SAM_USART7_LENGTH (SAM_SERCOM7_BASE + SAM_USART_LENGTH_OFFSET)
#define SAM_USART7_DATA (SAM_SERCOM7_BASE + SAM_USART_DATA_OFFSET)
#define SAM_USART7_DBGCTRL (SAM_SERCOM7_BASE + SAM_USART_DBGCTRL_OFFSET)
/* USART register bit definitions ***********************************************************/
/* Control A register */
#define USART_CTRLA_SWRST (1 << 0) /* Bit 0: Software reset */
#define USART_CTRLA_ENABLE (1 << 1) /* Bit 1: Enable */
#define USART_CTRLA_MODE_SHIFT (2) /* Bits 2-4: Operating Mode */
#define USART_CTRLA_MODE_MASK (7 << USART_CTRLA_MODE_SHIFT)
# define USART_CTRLA_MODE_EXTUSART (0 << USART_CTRLA_MODE_SHIFT) /* USART with external
* clock */
# define USART_CTRLA_MODE_INTUSART (1 << USART_CTRLA_MODE_SHIFT) /* USART with internal
* clock */
#define USART_CTRLA_RUNSTDBY (1 << 7) /* Bit 7: Run in standby */
#define USART_CTRLA_IBON (1 << 8) /* Bit 8: Immediate BUFOVF notification */
#define USART_CTRLA_TXINV (1 << 9) /* Bit 9: Transmit Data Invert */
#define USART_CTRLA_RXINV (1 << 10) /* Bit 10: Receive Data Invert */
#define USART_CTRLA_SAMPR_SHIFT (11) /* Bits 13-15: Sample rate */
#define USART_CTRLA_SAMPR_MASK (7 << USART_CTRLA_SAMPR_SHIFT)
# define USART_CTRLA_SAMPR_16XA (0 << USART_CTRLA_SAMPR_SHIFT) /* 16x oversampling;
* arithmetic baud */
# define USART_CTRLA_SAMPR_16XF (1 << USART_CTRLA_SAMPR_SHIFT) /* 16x oversampling;
* fractional baud */
# define USART_CTRLA_SAMPR_8XA (2 << USART_CTRLA_SAMPR_SHIFT) /* 8x oversampling;
* arithmetic baud */
# define USART_CTRLA_SAMPR_8XF (3 << USART_CTRLA_SAMPR_SHIFT) /* 8x oversampling;
* fractional baud */
# define USART_CTRLA_SAMPR_3XA (4 << USART_CTRLA_SAMPR_SHIFT) /* 3x oversampling;
* arithmetic baud */
#define USART_CTRLA_TXPO_SHIFT (16) /* Bits 16-17: Transmit data pinout */
#define USART_CTRLA_TXPO_MASK (3 << USART_CTRLA_TXPO_SHIFT)
# define USART_CTRLA_TXPAD0_1 (0 << USART_CTRLA_TXPO_SHIFT) /* TxD=PAD0 XCK=PAD1
* RTS/TE=N/A CTS=N/A */
# define USART_CTRLA_TXPAD0_2 (2 << USART_CTRLA_TXPO_SHIFT) /* TxD=PAD0 XCK=N/A
* RTS/TE=PAD2 CTS=PAD3 */
# define USART_CTRLA_TXPAD0_3 (3 << USART_CTRLA_TXPO_SHIFT) /* TxD=PAD0 RTS=PAD1
* RTS/PAD2 CTS=N/A */
#define USART_CTRLA_RXPO_SHIFT (20) /* Bits 20-21: Receive data pinout */
#define USART_CTRLA_RXPO_MASK (3 << USART_CTRLA_RXPO_SHIFT)
# define USART_CTRLA_RXPAD0 (0 << USART_CTRLA_RXPO_SHIFT) /* RxD=SERCOM PAD0 */
# define USART_CTRLA_RXPAD1 (1 << USART_CTRLA_RXPO_SHIFT) /* RxD=SERCOM PAD1 */
# define USART_CTRLA_RXPAD2 (2 << USART_CTRLA_RXPO_SHIFT) /* RxD=SERCOM PAD2 */
# define USART_CTRLA_RXPAD3 (3 << USART_CTRLA_RXPO_SHIFT) /* RxD=SERCOM PAD3 */
#define USART_CTRLA_SAMPA_SHIFT (22) /* Bits 22-23: Sample adjustment */
#define USART_CTRLA_SAMPA_MASK (3 << USART_CTRLA_SAMPA_SHIFT)
# define USART_CTRLA_SAMPA_789 (0 << USART_CTRLA_SAMPA_SHIFT) /* 16x oversampling 7-8-9 */
# define USART_CTRLA_SAMPA_91011 (1 << USART_CTRLA_SAMPA_SHIFT) /* 16x oversampling 9-10-11 */
# define USART_CTRLA_SAMPA_111213 (2 << USART_CTRLA_SAMPA_SHIFT) /* 16x oversampling 11-12-13 */
# define USART_CTRLA_SAMPA_131415 (3 << USART_CTRLA_SAMPA_SHIFT) /* 16x oversampling 13-14-15 */
# define USART_CTRLA_SAMPA_345 (0 << USART_CTRLA_SAMPA_SHIFT) /* 8x oversampling 3-4-5 */
# define USART_CTRLA_SAMPA_456 (1 << USART_CTRLA_SAMPA_SHIFT) /* 8x oversampling 4-5-6 */
# define USART_CTRLA_SAMPA_567 (2 << USART_CTRLA_SAMPA_SHIFT) /* 8x oversampling 5-6-7 */
# define USART_CTRLA_SAMPA_678 (3 << USART_CTRLA_SAMPA_SHIFT) /* 8x oversampling 6-7-8 */
#define USART_CTRLA_FORM_SHIFT (24) /* Bits 24-27: Frame format */
#define USART_CTRLA_FORM_MASK (7 << USART_CTRLA_FORM_SHIFT)
# define USART_CTRLA_FORM_NOPARITY (0 << USART_CTRLA_FORM_SHIFT) /* USART frame (no parity) */
# define USART_CTRLA_FORM_PARITY (1 << USART_CTRLA_FORM_SHIFT) /* USART frame (w/parity) */
# define USART_CTRLA_FORM_LINMSTR (2 << USART_CTRLA_FORM_SHIFT) /* LIN master */
# define USART_CTRLA_FORM_AUTOBAUD (4 << USART_CTRLA_FORM_SHIFT) /* Lin slave; Auto-baud (no parity) */
# define USART_CTRLA_FORM_AUTOBAUDP (5 << USART_CTRLA_FORM_SHIFT) /* Auto-baud (w/ parity) */
# define USART_CTRLA_FORM_ISO7816 (7 << USART_CTRLA_FORM_SHIFT) /* ISO 7816 */
#define USART_CTRLA_CMODE (1 << 28) /* Bit 28: Communication mode */
# define USART_CTRLA_ASYNCH (0)
# define USART_CTRLA_SYNCH USART_CTRLA_CMODE
#define USART_CTRLA_CPOL (1 << 29) /* Bit 29: Clock polarity */
# define USART_CTRLA_CPOL_NORMAL (0) /* Rising XCK edge Falling XCK edge */
# define USART_CTRLA_CPOL_INVERTED USART_CTRLA_CPOL /* Falling XCK edge Rising XCK edge */
#define USART_CTRLA_DORD (1 << 30) /* Bit 30: Data order */
# define USART_CTRLA_MSBFIRST (0)
# define USART_CTRLA_LSBFIRST USART_CTRLA_DORD
/* Control B register */
#define USART_CTRLB_CHSIZE_SHIFT (0) /* Bits 0-2: Character Size */
#define USART_CTRLB_CHSIZE_MASK (7 << USART_CTRLB_CHSIZE_SHIFT)
# define USART_CTRLB_CHSIZE_8BITS (0 << USART_CTRLB_CHSIZE_SHIFT) /* 8 bits */
# define USART_CTRLB_CHSIZE_9BITS (1 << USART_CTRLB_CHSIZE_SHIFT) /* 9 bits */
# define USART_CTRLB_CHSIZE_5BITS (5 << USART_CTRLB_CHSIZE_SHIFT) /* 5 bits */
# define USART_CTRLB_CHSIZE_6BITS (6 << USART_CTRLB_CHSIZE_SHIFT) /* 6 bits */
# define USART_CTRLB_CHSIZE_7BITS (7 << USART_CTRLB_CHSIZE_SHIFT) /* 7 bits */
#define USART_CTRLB_SBMODE (1 << 6) /* Bit 6: Stop bit mode */
# define USART_CTRLB_SBMODE_1 (0)
# define USART_CTRLB_SBMODE_2 USART_CTRLB_SBMODE
#define USART_CTRLB_COLDEN (1 << 8) /* Bit 8: Collision detection enable */
#define USART_CTRLB_SFDE (1 << 9) /* Bit 9: Start of frame detection enable */
#define USART_CTRLB_ENC (1 << 10) /* Bit 10: Encoding format */
# define USART_CTRLB_UNENCODED (0)
# define USART_CTRLB_IRDA USART_CTRLB_ENC
#define USART_CTRLB_PMODE (1 << 13) /* Bit 13: Parity mode */
# define USART_CTRLB_PEVEN (0)
# define USART_CTRLB_PODD USART_CTRLB_PMODE
#define USART_CTRLB_TXEN (1 << 16) /* Bit 16: Transmitter enable */
#define USART_CTRLB_RXEN (1 << 17) /* Bit 17: Receiver enable */
#define USART_CTRLB_LINCMD_SHIFT (24) /* Bits 24-25: Receiver enable */
#define USART_CTRLB_LINCMD_MASK (3 << USART_CTRLB_LINCMD_SHIFT)
# define USART_CTRLB_LINCMD_NORMAL (0 << USART_CTRLB_LINCMD_SHIFT) /* Normal USART transmission */
# define USART_CTRLB_LINCMD_BREAK (1 << USART_CTRLB_LINCMD_SHIFT) /* Break field is transmitted */
# define USART_CTRLB_LINCMD_BSI (2 << USART_CTRLB_LINCMD_SHIFT) /* Break, sync and identifier
* transmitted */
/* Control C register */
#define USART_CTRLC_GTIME_SHIFT (0) /* Bits 0-2: Guard Time */
#define USART_CTRLC_GTIME_MASK (7 << USART_CTRLC_GTIME_SHIFT)
# define USART_CTRLC_GTIME(n) ((uint32_t)(n) << USART_CTRLC_GTIME_SHIFT)
#define USART_CTRLC_BRKLEN_SHIFT (8) /* Bits 8-9: LIN Master Break Length */
#define USART_CTRLC_BRKLEN_MASK (3 << USART_CTRLC_BRKLEN_SHIFT)
# define USART_CTRLC_BRKLEN_13BITS (0 << USART_CTRLC_BRKLEN_SHIFT) /* 13 bit times */
# define USART_CTRLC_BRKLEN_17BITS (1 << USART_CTRLC_BRKLEN_SHIFT) /* 17 bit times */
# define USART_CTRLC_BRKLEN_21BITS (2 << USART_CTRLC_BRKLEN_SHIFT) /* 21 bit times */
# define USART_CTRLC_BRKLEN_26BITS (3 << USART_CTRLC_BRKLEN_SHIFT) /* 26 bit times */
#define USART_CTRLC_HDRDLY_SHIFT (10) /* Bits 10-11: LIN Master Header Delay */
#define USART_CTRLC_HDRDLY_MASK (3 << USART_CTRLC_HDRDLY_SHIFT)
# define USART_CTRLC_HDRDLY_1_1 (0 << USART_CTRLC_HDRDLY_SHIFT) /* 1, 1 bit times */
# define USART_CTRLC_HDRDLY_4_4 (1 << USART_CTRLC_HDRDLY_SHIFT) /* 4, 4 bit times */
# define USART_CTRLC_HDRDLY_8_4 (2 << USART_CTRLC_HDRDLY_SHIFT) /* 8, 4 bit times */
# define USART_CTRLC_HDRDLY_14_4 (3 << USART_CTRLC_HDRDLY_SHIFT) /* 14, 4 bit times */
#define USART_CTRLC_INACK (1 << 16) /* Bit 16: Inhibit Not Acknowledge */
# define USART_CTRLC_NACK (0) /* 0=NACK transmitted */
# define USART_CTRLC_NONACK USART_CTRLC_INACK /* 1=NACK not ransmitted */
#define USART_CTRLC_DSNACK (1 << 17) /* Bit 17: Disable Successive Not Acknowledge */
#define USART_CTRLC_MAXITER_SHIFT (20) /* Bits 20-22: Data 32 Bit */
#define USART_CTRLC_MAXITER_MASK (7 << USART_CTRLC_MAXITER_SHIFT)
# define USART_CTRLC_MAXITER(n) ((uint32_t)(n) << USART_CTRLC_MAXITER_SHIFT)
#define USART_CTRLC_DATA32B_SHIFT (24) /* Bits 24-25: Data 32 Bit */
#define USART_CTRLC_DATA32B_MASK (3 << USART_CTRLC_DATA32B_SHIFT)
# define USART_CTRLC_DATA32B_CHSIZE (0 << USART_CTRLC_DATA32B_SHIFT) /* Read/write per CHSIZE */
# define USART_CTRLC_DATA32B_WRITE (1 << USART_CTRLC_DATA32B_SHIFT) /* Read CHSIZE; Write 32b */
# define USART_CTRLC_DATA32B_READ (2 << USART_CTRLC_DATA32B_SHIFT) /* Write CHSIZE; Read 32b */
# define USART_CTRLC_DATA32B_BOTH (3 << USART_CTRLC_DATA32B_SHIFT) /* Both per 32-bit extension */
/* Baud register (16-bit baud value) */
/* Receive pulse length register (8-bit value) */
/* Interrupt enable clear, interrupt enable set, interrupt enable set, interrupt flag and
* status clear registers.
*/
#define USART_INT_DRE (1 << 0) /* Bit 0: Data register empty interrupt */
#define USART_INT_TXC (1 << 1) /* Bit 1: Transmit complete interrupt */
#define USART_INT_RXC (1 << 2) /* Bit 2: Receive complete interrupt */
#define USART_INT_RXS (1 << 3) /* Bit 3: Receive start interrupt */
#define USART_INT_CTSIC (1 << 4) /* Bit 4: Clear to send input change interrupt */
#define USART_INT_RXBRK (1 << 5) /* Bit 5: Receive break interrupt */
#define USART_INT_ERROR (1 << 6) /* Bit 7: Error interrupt */
#define USART_INT_ALL (0xbf)
/* Status register */
#define USART_STATUS_PERR (1 << 0) /* Bit 0: Parity error */
#define USART_STATUS_FERR (1 << 1) /* Bit 1: Frame error */
#define USART_STATUS_BUFOVF (1 << 2) /* Bit 2: Buffer overflow */
#define USART_STATUS_CTS (1 << 3) /* Bit 3: Clear to send */
#define USART_STATUS_ISF (1 << 4) /* Bit 4: Inconsistent sync field */
#define USART_STATUS_COLL (1 << 5) /* Bit 5: Collision detected */
#define USART_STATUS_TXE (1 << 6) /* Bit 6: Transmitter Empty */
#define USART_STATUS_ITER (1 << 7) /* Bit 7: Maximum Number of Repetitions Reached */
/* Synchronization busy register */
#define USART_SYNCBUSY_SWRST (1 << 0) /* Bit 0: Software reset synchronization busy */
#define USART_SYNCBUSY_ENABLE (1 << 1) /* Bit 1: SERCOM enable synchronization busy */
#define USART_SYNCBUSY_CTRLB (1 << 2) /* Bit 2: CTRLB synchronization busy */
#define USART_SYNCBUSY_RXERRCNT (1 << 3) /* Bit 3: Receive error count synchronization busy */
#define USART_SYNCBUSY_LENGTH (1 << 4) /* Bit 4: LENGTH synchronization busy */
#define USART_SYNCBUSY_ALL 0x001f
/* Receive error count register (8-bit value) */
/* Length register */
#define USART_LENGTH_LEN_SHIFT (0) /* Bit 0-7: Data length */
#define USART_LENGTH_LEN_MASK (0xff << USART_LENGTH_LEN_SHIFT)
# define USART_LENGTHLEN(n) ((uint32_t)(n) << USART_LENGTH_LEN_SHIFT)
#define USART_LENGTH_LENEN_SHIFT (8) /* Bits 8-9: Data Length Enable */
#define USART_LENGTH_LENEN_MASK (3 << USART_LENGTH_LENEN_SHIFT)
# define USART_LENGTH_LENEN_DISABLE (0 << USART_LENGTH_LENEN_SHIFT) /* Length counter disabled */
# define USART_LENGTH_LENEN_XMIT (1 << USART_LENGTH_LENEN_SHIFT) /* Enabled for transmit */
# define USART_LENGTH_LENEN_RECV (2 << USART_LENGTH_LENEN_SHIFT) /* Enabled for receive */
/* Data register (8-, 9- or 32-bit data) */
#define USART_DATA_MASK9 (0x1ff) /* Bits 0-8: 8- or 9-bit Data */
/* Debug control register */
#define USART_DBGCTRL_DBGSTOP (1 << 0) /* Bit 0: Debug stop mode */
/********************************************************************************************
* Public Types
********************************************************************************************/
/********************************************************************************************
* Public Data
********************************************************************************************/
/********************************************************************************************
* Public Functions
********************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_USART_H */

View File

@ -0,0 +1,160 @@
/********************************************************************************************
* arch/arm/src/samd5e5/chip/sam_wdt.h
*
* Copyright (C) 2018 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_SAMD5E5_CHIP_SAM_WDT_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_WDT_H
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
#include "chip/sam_memorymap.h"
/********************************************************************************************
* Pre-processor Definitions
********************************************************************************************/
/* WDT register offsets *********************************************************************/
#define SAM_WDT_CTRLA_OFFSET 0x0000 /* Control A register */
#define SAM_WDT_CONFIG_OFFSET 0x0001 /* Configuration register */
#define SAM_WDT_EWCTRL_OFFSET 0x0002 /* Early warning interrupt control register */
#define SAM_WDT_INTENCLR_OFFSET 0x0004 /* Interrupt enable clear register */
#define SAM_WDT_INTENSET_OFFSET 0x0005 /* Interrupt enable set register */
#define SAM_WDT_INTFLAG_OFFSET 0x0006 /* Interrupt flag and status clear register */
#define SAM_WDT_SYNCBUSY_OFFSET 0x0008 /* Synchronization busy register */
#define SAM_WDT_CLEAR_OFFSET 0x000c /* Clear register */
/* WDT register addresses *******************************************************************/
#define SAM_WDT_CTRLA (SAM_WDT_BASE + SAM_WDT_CTRLA_OFFSET)
#define SAM_WDT_CONFIG (SAM_WDT_BASE + SAM_WDT_CONFIG_OFFSET)
#define SAM_WDT_EWCTRL (SAM_WDT_BASE + SAM_WDT_EWCTRL_OFFSET)
#define SAM_WDT_INTENCLR (SAM_WDT_BASE + SAM_WDT_INTENCLR_OFFSET)
#define SAM_WDT_INTENSET (SAM_WDT_BASE + SAM_WDT_INTENSET_OFFSET)
#define SAM_WDT_INTFLAG (SAM_WDT_BASE + SAM_WDT_INTFLAG_OFFSET)
#define SAM_WDT_SYNCBUSY (SAM_WDT_BASE + SAM_WDT_SYNCBUSY_OFFSET)
#define SAM_WDT_CLEAR (SAM_WDT_BASE + SAM_WDT_CLEAR_OFFSET)
/* WDT register bit definitions *************************************************************/
/* Control register */
#define WDT_CTRLA_ENABLE (1 << 1) /* Bit 1: Enable */
#define WDT_CTRLA_WEN (1 << 2) /* Bit 2: Watchdog Timer Window Mode Enable */
#define WDT_CTRLA_ALWAYSON (1 << 7) /* Bit 7: Always-On */
/* Configuration register */
#define WDT_CONFIG_PER_SHIFT (0) /* Bits 03: Time-Out Period */
#define WDT_CONFIG_PER_MASK (15 << WDT_CONFIG_PER_SHIFT)
# define WDT_CONFIG_PER_8 (0 << WDT_CONFIG_PER_SHIFT) /* 8 clock cycles */
# define WDT_CONFIG_PER_16 (1 << WDT_CONFIG_PER_SHIFT) /* 16 clock cycles */
# define WDT_CONFIG_PER_32 (2 << WDT_CONFIG_PER_SHIFT) /* 32 clock cycles */
# define WDT_CONFIG_PER_64 (3 << WDT_CONFIG_PER_SHIFT) /* 64 clock cycles */
# define WDT_CONFIG_PER_128 (4 << WDT_CONFIG_PER_SHIFT) /* 128 clock cycles */
# define WDT_CONFIG_PER_256 (5 << WDT_CONFIG_PER_SHIFT) /* 256 clocks cycles */
# define WDT_CONFIG_PER_512 (6 << WDT_CONFIG_PER_SHIFT) /* 512 clocks cycles */
# define WDT_CONFIG_PER_1K (7 << WDT_CONFIG_PER_SHIFT) /* 1024 clock cycles */
# define WDT_CONFIG_PER_2K (8 << WDT_CONFIG_PER_SHIFT) /* 2048 clock cycles */
# define WDT_CONFIG_PER_4K (9 << WDT_CONFIG_PER_SHIFT) /* 4096 clock cycles */
# define WDT_CONFIG_PER_8k (10 << WDT_CONFIG_PER_SHIFT) /* 8192 clock cycles */
# define WDT_CONFIG_PER_16K (11 << WDT_CONFIG_PER_SHIFT) /* 16384 clock cycles */
#define WDT_CONFIG_WINDOW_SHIFT (4) /* Bits 4-7: Window Mode Time-Out Period */
#define WDT_CONFIG_WINDOW_MASK (15 << WDT_CONFIG_WINDOW_SHIFT)
# define WDT_CONFIG_WINDOW_8 (0 << WDT_CONFIG_WINDOW_SHIFT) /* 8 clock cycles */
# define WDT_CONFIG_WINDOW_16 (1 << WDT_CONFIG_WINDOW_SHIFT) /* 16 clock cycles */
# define WDT_CONFIG_WINDOW_32 (2 << WDT_CONFIG_WINDOW_SHIFT) /* 32 clock cycles */
# define WDT_CONFIG_WINDOW_64 (3 << WDT_CONFIG_WINDOW_SHIFT) /* 64 clock cycles */
# define WDT_CONFIG_WINDOW_128 (4 << WDT_CONFIG_WINDOW_SHIFT) /* 128 clock cycles */
# define WDT_CONFIG_WINDOW_256 (5 << WDT_CONFIG_WINDOW_SHIFT) /* 256 clocks cycles */
# define WDT_CONFIG_WINDOW_512 (6 << WDT_CONFIG_WINDOW_SHIFT) /* 512 clocks cycles */
# define WDT_CONFIG_WINDOW_1K (7 << WDT_CONFIG_WINDOW_SHIFT) /* 1024 clock cycles */
# define WDT_CONFIG_WINDOW_2K (8 << WDT_CONFIG_WINDOW_SHIFT) /* 2048 clock cycles */
# define WDT_CONFIG_WINDOW_4K (9 << WDT_CONFIG_WINDOW_SHIFT) /* 4096 clock cycles */
# define WDT_CONFIG_WINDOW_8k (10 << WDT_CONFIG_WINDOW_SHIFT) /* 8192 clock cycles */
/* Early warning interrupt control register */
#define WDT_EWCTRL_EWOFFSET_SHIFT (0) /* Bits 0-3: Early warning interrupt time offset */
#define WDT_EWCTRL_EWOFFSET_MASK (15 << WDT_EWCTRL_EWOFFSET_SHIFT)
# define WDT_EWCTRL_EWOFFSET_8 (0 << WDT_EWCTRL_EWOFFSET_SHIFT) /* 8 clock cycles */
# define WDT_EWCTRL_EWOFFSET_16 (1 << WDT_EWCTRL_EWOFFSET_SHIFT) /* 16 clock cycles */
# define WDT_EWCTRL_EWOFFSET_32 (2 << WDT_EWCTRL_EWOFFSET_SHIFT) /* 32 clock cycles */
# define WDT_EWCTRL_EWOFFSET_64 (3 << WDT_EWCTRL_EWOFFSET_SHIFT) /* 64 clock cycles */
# define WDT_EWCTRL_EWOFFSET_128 (4 << WDT_EWCTRL_EWOFFSET_SHIFT) /* 128 clock cycles */
# define WDT_EWCTRL_EWOFFSET_256 (5 << WDT_EWCTRL_EWOFFSET_SHIFT) /* 256 clocks cycles */
# define WDT_EWCTRL_EWOFFSET_512 (6 << WDT_EWCTRL_EWOFFSET_SHIFT) /* 512 clocks cycles */
# define WDT_EWCTRL_EWOFFSET_1K (7 << WDT_EWCTRL_EWOFFSET_SHIFT) /* 1024 clock cycles */
# define WDT_EWCTRL_EWOFFSET_2K (8 << WDT_EWCTRL_EWOFFSET_SHIFT) /* 2048 clock cycles */
# define WDT_EWCTRL_EWOFFSET_4K (9 << WDT_EWCTRL_EWOFFSET_SHIFT) /* 4096 clock cycles */
# define WDT_EWCTRL_EWOFFSET_8k (10 << WDT_EWCTRL_EWOFFSET_SHIFT) /* 8192 clock cycles */
# define WDT_EWCTRL_EWOFFSET_16K (11 << WDT_EWCTRL_EWOFFSET_SHIFT) /* 16384 clock cycles */
/* Interrupt enable clear, interrupt enable set register, interrupt flag status and clear
* registers
*/
#define WDT_INT_EW (1 << 0) /* Bit 0: Early warning interrupt */
#define WDT_INT_All (0x01)
/* Synchronization busy register */
#define WDT_SYNCBUSY_ENABLE (1 << 1) /* Bit 1: Enable syncrhonization busy */
#define WDT_SYNCBUSY_WEN (1 << 2) /* Bit 2: Window enable synchronization busy */
#define WDT_SYNCBUSY_ALWAYSON (1 << 3) /* Bit 3: Always-on synchronization busy */
#define WDT_SYNCBUSY_CLEAR (1 << 4) /* Bit 4: Clear syncrhonization busy */
/* Clear register */
#define WDT_CLEAR_CLEAR_SHIFT (0) /* Bits 0-7: Watchdog clear */
#define WDT_CLEAR_CLEAR_MASK (0xff << WDT_CLEAR_CLEAR_SHIFT)
# define WDT_CLEAR_CLEAR (0xa5 << WDT_CLEAR_CLEAR_SHIFT)
/********************************************************************************************
* Public Types
********************************************************************************************/
/********************************************************************************************
* Public Data
********************************************************************************************/
/********************************************************************************************
* Public Functions
********************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_WDT_H */

View File

@ -0,0 +1,157 @@
/********************************************************************************************
* arch/arm/src/samd5e5/chip/samd5e5_memorymap.h
*
* Copyright (C) 2018 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_SAMD5E5_CHIP_SAMD5E5_MEMORYMAP_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAMD5E5_MEMORYMAP_H
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
/********************************************************************************************
* Pre-processor Definitions
********************************************************************************************/
/* System Memory Map */
#define SAM_CODE_BASE 0x00000000 /* Code address space */
# define SAM_FLASH_BASE 0x00000000 /* FLASH address space */
# define SAM_CMCC_BASE 0x03000000 /* CMCC address space */
# define SAM_QSPI_BASE 0x04000000 /* QSPI address space */
#define SAM_SRAM_BASE 0x20000000 /* SRAM address space */
#define SAM_PERIPH_BASE 0x40000000 /* Peripherals memory space */
# define SAM_AHBA_BASE 0x40000000 /* AHB-APB Bridge A */
# define SAM_AHBB_BASE 0x41000000 /* AHB-APB Bridge B */
# define SAM_AHBC_BASE 0x42000000 /* AHB-APB Bridge C */
# define SAM_AHBD_BASE 0x43000000 /* AHB-APB Bridge D */
# define SAM_SEEPROM_BASE 0x44000000 /* SEEPROM */
# define SAM_SDHC0_BASE 0x45000000 /* Memory card interface (SDHC0) */
# define SAM_SDHC1_BASE 0x46000000 /* Memory card interface (SDHC1) */
# define SAM_BKPRAM_BASE 0x47000000 /* Backup RAM */
#define SAM_SYSTEM_BASE 0xe0000000 /* System address space */
# define SAM_SCS_BASE 0xe000e000 /* SCSS */
# define SAM_ROMTAB_BASE 0xe000ff00 /* ROM table */
/* AHB-APB Bridge A */
#define SAM_PAC_BASE 0x40000000 /* Peripheral Access Controller 0 */
#define SAM_PM_BASE 0x40000400 /* Power Manager (PM) */
#define SAM_MCLK_BASE 0x40000800 /* Main clock (MCLK) */
#define SAM_RSTC_BASE 0x40000c00 /* Reset Controller (RSTC) */
#define SAM_OSCCTRL_BASE 0x40001000 /* OSCCTRL */
#define SAM_OSC32KCTRL_BASE 0x40001400 /* OSC32KCTRL */
#define SAM_SUPC_BASE 0x40001800 /* Supply Controller (SUPC) */
#define SAM_GCLK_BASE 0x40001c00 /* Generic Clock Controller */
#define SAM_WDT_BASE 0x40002000 /* Watchdog Timer */
#define SAM_RTC_BASE 0x40002400 /* Real-Time Counter */
#define SAM_EIC_BASE 0x40002800 /* External Interrupt Controller */
#define SAM_FREQM_BASE 0x40002c00 /* Frequency Meter (FREQM) */
#define SAM_SERCOM0_BASE 0x40003000 /* Serial Communication Interface 0 */
#define SAM_SERCOM1_BASE 0x40003400 /* Serial Communication Interface 1 */
#define SAM_TC0_BASE 0x40003800 /* Timer/Counter 2 */
#define SAM_TC1_BASE 0x40003c00 /* Timer/Counter 3 */
/* Reserved */
/* AHB-APB Bridge B */
#define SAM_USB_BASE 0x41000000 /* USB */
#define SAM_DSU_BASE 0x41002000 /* Device Service Unit (DSU) */
#define SAM_NVMCTRL_BASE 0x41004000 /* Non-Volatile Memory Controller (NVMCTRL) */
#define SAM_CMCCC_BASE 0x41006000 /* Cortex-M Cache Controller (CMCC) */
#define SAM_PORT_BASE 0x41008000 /* Ports */
#define SAM_DMAC_BASE 0x4100a000 /* DMA Controller */
/* Reserved */
#define SAM_EVSYS_BASE 0x4100e000 /* Event System */
/* Reserved */
#define SAM_SERCOM2_BASE 0x41001200 /* Serial Communication Interface 2 */
#define SAM_SERCOM3_BASE 0x41001400 /* Serial Communication Interface 3 */
#define SAM_TCC0_BASE 0x41001600 /* Timer/Counter Control 0 */
#define SAM_TCC1_BASE 0x41001800 /* Timer/Counter Control 1 */
#define SAM_TC2_BASE 0x41001a00 /* Timer/Counter 2 */
#define SAM_TC3_BASE 0x41001c00 /* Timer/Counter 3 */
/* Reserved */
#define SAM_RAMECC_BASE 0x41002000 /* RAM Error Correction Code (RAMECC) */
/* Reserved */
/* AHB-APB Bridge C */
#define SAM_CAN0_BASE 0x42000000 /* CAN0 */
#define SAM_CAN1_BASE 0x42000400 /* CAN1 */
#define SAM_GMAC_BASE 0x42000800 /* GMAC */
#define SAM_TCC2_BASE 0x42000c00 /* Timer/Counter Control 2 */
#define SAM_TCC3_BASE 0x42001000 /* Timer/Counter Control 3 */
#define SAM_TC4_BASE 0x42001400 /* Timer/Counter 4 */
#define SAM_TC5_BASE 0x42001800 /* Timer/Counter 5 */
#define SAM_PDEC_BASE 0x42001c00 /* Position Decoder (PDEC) */
#define SAM_AC_BASE 0x42002000 /* Analog Comparator (AC) */
#define SAM_AES_BASE 0x42002400 /* Advanced Encryption Standard (AES) */
#define SAM_TRNG_BASE 0x42002800 /* True Random Number Generator (TRNG) */
#define SAM_ICM_BASE 0x42002c00 /* Integrity Check Monitor (ICM) */
#define SAM_PUKCC_BASE 0x42003000 /* Public-Key Cryptography Controller (PUKCC) */
#define SAM_QSPIC_BASE 0x42003400 /* QSPI controller */
#define SAM_CCL_BASE 0x42003800 /* Configurable Custom Logic (CCL) */
/* Reserved */
/* AHB-APB Bridge D */
#define SAM_SERCOM4_BASE 0x43000000 /* Serial Communication Interface 4 */
#define SAM_SERCOM5_BASE 0x43000400 /* Serial Communication Interface 5 */
#define SAM_SERCOM6_BASE 0x43000800 /* Serial Communication Interface 6 */
#define SAM_SERCOM7_BASE 0x43000c00 /* Serial Communication Interface 7 */
#define SAM_TCC4_BASE 0x43001000 /* Timer/Counter Control 4 */
#define SAM_TC6_BASE 0x43001400 /* Timer/Counter 6 */
#define SAM_TC7_BASE 0x43001800 /* Timer/Counter 7 */
#define SAM_ADC0_BASE 0x43001c00 /* Analog-to-Digital Converter 0 (ADC0) */
#define SAM_ADC1_BASE 0x43002000 /* Analog-to-Digital Converter 1 (ADC1) */
#define SAM_DAC_BASE 0x43002400 /* Digital-to-Analog Converter (DAC) */
#define SAM_I2S_BASE 0x43002800 /* Inter IC Sound (I2S) */
#define SAM_PCC_BASE 0x44002c00 /* Parallel Capture Controller (PCC) */
/* Reserved */
/********************************************************************************************
* Public Types
********************************************************************************************/
/********************************************************************************************
* Public Data
********************************************************************************************/
/********************************************************************************************
* Public Functions
********************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAMD5E5_MEMORYMAP_H */

View File

@ -0,0 +1,790 @@
/********************************************************************************************
* arch/arm/src/samd5e5/chip/samd5e5_pinmap.h
*
* Copyright (C) 2018 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_SAMD5E5_CHIP_SAM_PINMAP_H
#define __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_PINMAP_H
/********************************************************************************************
* Included Files
********************************************************************************************/
#include <nuttx/config.h>
/********************************************************************************************
* Pre-processor Definitions
********************************************************************************************/
/* GPIO pin definitions *********************************************************************/
/* Alternate Pin Functions.
*
* Alternative pin selections are provided with a numeric suffix like _1, _2, etc.
* Drivers, however, will use the pin selection without the numeric suffix.
* Additional definitions are required in the board.h file. For example, if we
* wanted the SERCOM0 PAD0 on PA8, then the following definition should appear in
* the board.h header file for that board:
*
* #define PORT_SERCOM0_PAD0 PORT_SERCOM0_PAD0_1
*
* The driver will then automatically configure PA8 as the SERCOM0 PAD0 pin.
*/
/* WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!! WARNING!!!
* Additional effort is required to select specific GPIO options such as frequency,
* open-drain/push-pull, and pull-up/down! Just the basics are defined for most
* pins in this file.
*/
/* Analog comparator (AC) */
#define PORT_AC_AIN0 (PORT_FUNCB | PORTA | PORT_PIN4)
#define PORT_AC_AIN1 (PORT_FUNCB | PORTA | PORT_PIN5)
#define PORT_AC_AIN2 (PORT_FUNCB | PORTA | PORT_PIN6)
#define PORT_AC_AIN3 (PORT_FUNCB | PORTA | PORT_PIN7)
#define PORT_AC_CMP0_1 (PORT_FUNCM | PORTA | PORT_PIN12)
#define PORT_AC_CMP0_2 (PORT_FUNCM | PORTA | PORT_PIN18)
#define PORT_AC_CMP0_3 (PORT_FUNCM | PORTB | PORT_PIN24)
#define PORT_AC_CMP1_1 (PORT_FUNCM | PORTA | PORT_PIN13)
#define PORT_AC_CMP1_2 (PORT_FUNCM | PORTA | PORT_PIN19)
#define PORT_AC_CMP1_3 (PORT_FUNCM | PORTB | PORT_PIN25)
/* Analog-to-Digital Conversion (ADC) */
#define PORT_ADC0_AIN0 (PORT_FUNCB | PORTA | PORT_PIN2)
#define PORT_ADC0_AIN1 (PORT_FUNCB | PORTA | PORT_PIN3)
#define PORT_ADC0_AIN2 (PORT_FUNCB | PORTB | PORT_PIN8)
#define PORT_ADC0_AIN3 (PORT_FUNCB | PORTB | PORT_PIN9)
#define PORT_ADC0_AIN4 (PORT_FUNCB | PORTA | PORT_PIN4)
#define PORT_ADC0_AIN5 (PORT_FUNCB | PORTA | PORT_PIN5)
#define PORT_ADC0_AIN6 (PORT_FUNCB | PORTA | PORT_PIN6)
#define PORT_ADC0_AIN7 (PORT_FUNCB | PORTA | PORT_PIN7)
#define PORT_ADC0_AIN8 (PORT_FUNCB | PORTA | PORT_PIN8)
#define PORT_ADC0_AIN9 (PORT_FUNCB | PORTA | PORT_PIN9)
#define PORT_ADC0_AIN10 (PORT_FUNCB | PORTA | PORT_PIN10)
#define PORT_ADC0_AIN11 (PORT_FUNCB | PORTA | PORT_PIN11)
#define PORT_ADC0_AIN12 (PORT_FUNCB | PORTB | PORT_PIN0)
#define PORT_ADC0_AIN13 (PORT_FUNCB | PORTB | PORT_PIN1)
#define PORT_ADC0_AIN14 (PORT_FUNCB | PORTB | PORT_PIN2)
#define PORT_ADC0_AIN15 (PORT_FUNCB | PORTB | PORT_PIN3)
#define PORT_ADC1_AIN0 (PORT_FUNCB | PORTB | PORT_PIN8)
#define PORT_ADC1_AIN1 (PORT_FUNCB | PORTB | PORT_PIN9)
#define PORT_ADC1_AIN2 (PORT_FUNCB | PORTA | PORT_PIN8)
#define PORT_ADC1_AIN3 (PORT_FUNCB | PORTA | PORT_PIN9)
#define PORT_ADC1_AIN4 (PORT_FUNCB | PORTC | PORT_PIN2)
#define PORT_ADC1_AIN5 (PORT_FUNCB | PORTC | PORT_PIN3)
#define PORT_ADC1_AIN6 (PORT_FUNCB | PORTB | PORT_PIN4)
#define PORT_ADC1_AIN7 (PORT_FUNCB | PORTB | PORT_PIN5)
#define PORT_ADC1_AIN8 (PORT_FUNCB | PORTB | PORT_PIN6)
#define PORT_ADC1_AIN9 (PORT_FUNCB | PORTB | PORT_PIN7)
#define PORT_ADC1_AIN10 (PORT_FUNCB | PORTC | PORT_PIN0)
#define PORT_ADC1_AIN11 (PORT_FUNCB | PORTC | PORT_PIN1)
#define PORT_ADC1_AIN12 (PORT_FUNCB | PORTC | PORT_PIN30)
#define PORT_ADC1_AIN13 (PORT_FUNCB | PORTC | PORT_PIN31)
#define PORT_ADC1_AIN14 (PORT_FUNCB | PORTD | PORT_PIN0)
#define PORT_ADC1_AIN15 (PORT_FUNCB | PORTD | PORT_PIN1)
/* Analog Voltage Reference (ANAREF) */
#define PORT_ANAREF_VREFA (PORT_FUNCB | PORTA | PORT_PIN3)
#define PORT_ANAREF_VREFB (PORT_FUNCB | PORTA | PORT_PIN4)
#define PORT_ANAREF_VREFC (PORT_FUNCB | PORTA | PORT_PIN6)
/* Controller Area Network (CAN) */
#define PORT_CAN0_RX_1 (PORT_FUNCI | PORTA | PORT_PIN23)
#define PORT_CAN0_RX_2 (PORT_FUNCI | PORTA | PORT_PIN25)
#define PORT_CAN0_TX_1 (PORT_FUNCI | PORTA | PORT_PIN22)
#define PORT_CAN0_TX_2 (PORT_FUNCI | PORTA | PORT_PIN24)
#define PORT_CAN1_RX_1 (PORT_FUNCH | PORTB | PORT_PIN13)
#define PORT_CAN1_RX_2 (PORT_FUNCH | PORTB | PORT_PIN15)
#define PORT_CAN1_TX_1 (PORT_FUNCH | PORTB | PORT_PIN12)
#define PORT_CAN1_TX_2 (PORT_FUNCH | PORTB | PORT_PIN14)
/* Configurable Custom Logic (CCL) */
#define PORT_CCL_IN0_1 (PORT_FUNCN | PORTA | PORT_PIN16)
#define PORT_CCL_IN0_2 (PORT_FUNCN | PORTA | PORT_PIN4)
#define PORT_CCL_IN0_3 (PORT_FUNCN | PORTB | PORT_PIN22)
#define PORT_CCL_IN1_1 (PORT_FUNCN | PORTA | PORT_PIN17)
#define PORT_CCL_IN1_2 (PORT_FUNCN | PORTA | PORT_PIN5)
#define PORT_CCL_IN1_3 (PORT_FUNCN | PORTB | PORT_PIN0)
#define PORT_CCL_IN2_1 (PORT_FUNCN | PORTA | PORT_PIN18)
#define PORT_CCL_IN2_2 (PORT_FUNCN | PORTA | PORT_PIN6)
#define PORT_CCL_IN2_3 (PORT_FUNCN | PORTB | PORT_PIN1)
#define PORT_CCL_IN3_1 (PORT_FUNCN | PORTA | PORT_PIN30)
#define PORT_CCL_IN3_2 (PORT_FUNCN | PORTA | PORT_PIN8)
#define PORT_CCL_IN4_1 (PORT_FUNCN | PORTA | PORT_PIN9)
#define PORT_CCL_IN4_2 (PORT_FUNCN | PORTC | PORT_PIN27)
#define PORT_CCL_IN5_1 (PORT_FUNCN | PORTA | PORT_PIN10)
#define PORT_CCL_IN5_2 (PORT_FUNCN | PORTC | PORT_PIN28)
#define PORT_CCL_IN6_1 (PORT_FUNCN | PORTA | PORT_PIN22)
#define PORT_CCL_IN6_2 (PORT_FUNCN | PORTB | PORT_PIN6)
#define PORT_CCL_IN7_1 (PORT_FUNCN | PORTA | PORT_PIN23)
#define PORT_CCL_IN7_2 (PORT_FUNCN | PORTB | PORT_PIN7)
#define PORT_CCL_IN8_1 (PORT_FUNCN | PORTA | PORT_PIN24)
#define PORT_CCL_IN8_2 (PORT_FUNCN | PORTB | PORT_PIN8)
#define PORT_CCL_IN9_1 (PORT_FUNCN | PORTB | PORT_PIN14)
#define PORT_CCL_IN9_2 (PORT_FUNCN | PORTC | PORT_PIN20)
#define PORT_CCL_IN10_1 (PORT_FUNCN | PORTB | PORT_PIN15)
#define PORT_CCL_IN10_2 (PORT_FUNCN | PORTC | PORT_PIN21)
#define PORT_CCL_IN11_1 (PORT_FUNCN | PORTB | PORT_PIN10)
#define PORT_CCL_IN11_2 (PORT_FUNCN | PORTB | PORT_PIN16)
#define PORT_CCL_OUT0_1 (PORT_FUNCN | PORTA | PORT_PIN19)
#define PORT_CCL_OUT0_2 (PORT_FUNCN | PORTA | PORT_PIN7)
#define PORT_CCL_OUT0_3 (PORT_FUNCN | PORTB | PORT_PIN2)
#define PORT_CCL_OUT0_4 (PORT_FUNCN | PORTB | PORT_PIN23)
#define PORT_CCL_OUT1_1 (PORT_FUNCN | PORTA | PORT_PIN11)
#define PORT_CCL_OUT1_2 (PORT_FUNCN | PORTA | PORT_PIN31)
#define PORT_CCL_OUT1_3 (PORT_FUNCN | PORTB | PORT_PIN11)
#define PORT_CCL_OUT2_1 (PORT_FUNCN | PORTA | PORT_PIN25)
#define PORT_CCL_OUT2_2 (PORT_FUNCN | PORTB | PORT_PIN9)
#define PORT_CCL_OUT3 (PORT_FUNCN | PORTB | PORT_PIN17)
/* Cortex-M4 JTAG/SWD */
#define PORT_CORTEX_CM4_SWCLK (PORT_FUNCH | PORTA | PORT_PIN30)
#define PORT_CORTEX_CM4_SWDIO (PORT_FUNCH | PORTA | PORT_PIN31)
#define PORT_CORTEX_CM4_SWO (PORT_FUNCH | PORTB | PORT_PIN30)
#define PORT_CORTEX_CM4_TRACECLK (PORT_FUNCH | PORTC | PORT_PIN27)
#define PORT_CORTEX_CM4_TRACEDATA0 (PORT_FUNCH | PORTC | PORT_PIN28)
#define PORT_CORTEX_CM4_TRACEDATA1 (PORT_FUNCH | PORTC | PORT_PIN26)
#define PORT_CORTEX_CM4_TRACEDATA2 (PORT_FUNCH | PORTC | PORT_PIN25)
#define PORT_CORTEX_CM4_TRACEDATA3 (PORT_FUNCH | PORTC | PORT_PIN24)
#define PORT_CORTEX_M4_SWO (PORT_FUNCM | PORTC | PORT_PIN27)
/* Digital-to-Analog Conversion (DAC) */
#define PORT_DAC_VOUT0 (PORT_FUNCB | PORTA | PORT_PIN2)
#define PORT_DAC_VOUT1 (PORT_FUNCB | PORTA | PORT_PIN5)
/* External Interrupt Controller (EIC) */
#define PORT_EIC_EXTINT0_1 (PORT_FUNCA | PORTA | PORT_PIN0)
#define PORT_EIC_EXTINT0_2 (PORT_FUNCA | PORTA | PORT_PIN16)
#define PORT_EIC_EXTINT0_3 (PORT_FUNCA | PORTB | PORT_PIN0)
#define PORT_EIC_EXTINT0_4 (PORT_FUNCA | PORTB | PORT_PIN16)
#define PORT_EIC_EXTINT0_5 (PORT_FUNCA | PORTC | PORT_PIN0)
#define PORT_EIC_EXTINT0_6 (PORT_FUNCA | PORTC | PORT_PIN16)
#define PORT_EIC_EXTINT0_7 (PORT_FUNCA | PORTD | PORT_PIN0)
#define PORT_EIC_EXTINT1_1 (PORT_FUNCA | PORTA | PORT_PIN1)
#define PORT_EIC_EXTINT1_2 (PORT_FUNCA | PORTA | PORT_PIN17)
#define PORT_EIC_EXTINT1_3 (PORT_FUNCA | PORTB | PORT_PIN1)
#define PORT_EIC_EXTINT1_4 (PORT_FUNCA | PORTB | PORT_PIN17)
#define PORT_EIC_EXTINT1_5 (PORT_FUNCA | PORTC | PORT_PIN1)
#define PORT_EIC_EXTINT1_6 (PORT_FUNCA | PORTC | PORT_PIN17)
#define PORT_EIC_EXTINT1_7 (PORT_FUNCA | PORTD | PORT_PIN1)
#define PORT_EIC_EXTINT2_1 (PORT_FUNCA | PORTA | PORT_PIN18)
#define PORT_EIC_EXTINT2_2 (PORT_FUNCA | PORTA | PORT_PIN2)
#define PORT_EIC_EXTINT2_3 (PORT_FUNCA | PORTB | PORT_PIN18)
#define PORT_EIC_EXTINT2_4 (PORT_FUNCA | PORTB | PORT_PIN2)
#define PORT_EIC_EXTINT2_5 (PORT_FUNCA | PORTC | PORT_PIN18)
#define PORT_EIC_EXTINT2_6 (PORT_FUNCA | PORTC | PORT_PIN2)
#define PORT_EIC_EXTINT3_1 (PORT_FUNCA | PORTA | PORT_PIN19)
#define PORT_EIC_EXTINT3_2 (PORT_FUNCA | PORTA | PORT_PIN3)
#define PORT_EIC_EXTINT3_3 (PORT_FUNCA | PORTB | PORT_PIN19)
#define PORT_EIC_EXTINT3_4 (PORT_FUNCA | PORTB | PORT_PIN3)
#define PORT_EIC_EXTINT3_5 (PORT_FUNCA | PORTC | PORT_PIN19)
#define PORT_EIC_EXTINT3_6 (PORT_FUNCA | PORTC | PORT_PIN3)
#define PORT_EIC_EXTINT3_7 (PORT_FUNCA | PORTD | PORT_PIN8)
#define PORT_EIC_EXTINT4_1 (PORT_FUNCA | PORTA | PORT_PIN20)
#define PORT_EIC_EXTINT4_2 (PORT_FUNCA | PORTA | PORT_PIN4)
#define PORT_EIC_EXTINT4_3 (PORT_FUNCA | PORTB | PORT_PIN20)
#define PORT_EIC_EXTINT4_4 (PORT_FUNCA | PORTB | PORT_PIN4)
#define PORT_EIC_EXTINT4_5 (PORT_FUNCA | PORTC | PORT_PIN20)
#define PORT_EIC_EXTINT4_6 (PORT_FUNCA | PORTC | PORT_PIN4)
#define PORT_EIC_EXTINT4_7 (PORT_FUNCA | PORTD | PORT_PIN9)
#define PORT_EIC_EXTINT5_1 (PORT_FUNCA | PORTA | PORT_PIN21)
#define PORT_EIC_EXTINT5_2 (PORT_FUNCA | PORTA | PORT_PIN5)
#define PORT_EIC_EXTINT5_3 (PORT_FUNCA | PORTB | PORT_PIN21)
#define PORT_EIC_EXTINT5_4 (PORT_FUNCA | PORTB | PORT_PIN5)
#define PORT_EIC_EXTINT5_5 (PORT_FUNCA | PORTC | PORT_PIN21)
#define PORT_EIC_EXTINT5_6 (PORT_FUNCA | PORTC | PORT_PIN5)
#define PORT_EIC_EXTINT5_7 (PORT_FUNCA | PORTD | PORT_PIN10)
#define PORT_EIC_EXTINT6_1 (PORT_FUNCA | PORTA | PORT_PIN22)
#define PORT_EIC_EXTINT6_2 (PORT_FUNCA | PORTA | PORT_PIN6)
#define PORT_EIC_EXTINT6_3 (PORT_FUNCA | PORTB | PORT_PIN22)
#define PORT_EIC_EXTINT6_4 (PORT_FUNCA | PORTB | PORT_PIN6)
#define PORT_EIC_EXTINT6_5 (PORT_FUNCA | PORTC | PORT_PIN22)
#define PORT_EIC_EXTINT6_6 (PORT_FUNCA | PORTC | PORT_PIN6)
#define PORT_EIC_EXTINT6_7 (PORT_FUNCA | PORTD | PORT_PIN11)
#define PORT_EIC_EXTINT7_1 (PORT_FUNCA | PORTA | PORT_PIN23)
#define PORT_EIC_EXTINT7_2 (PORT_FUNCA | PORTA | PORT_PIN7)
#define PORT_EIC_EXTINT7_3 (PORT_FUNCA | PORTB | PORT_PIN23)
#define PORT_EIC_EXTINT7_4 (PORT_FUNCA | PORTB | PORT_PIN7)
#define PORT_EIC_EXTINT7_5 (PORT_FUNCA | PORTC | PORT_PIN23)
#define PORT_EIC_EXTINT7_6 (PORT_FUNCA | PORTD | PORT_PIN12)
#define PORT_EIC_EXTINT8_1 (PORT_FUNCA | PORTA | PORT_PIN24)
#define PORT_EIC_EXTINT8_2 (PORT_FUNCA | PORTB | PORT_PIN24)
#define PORT_EIC_EXTINT8_3 (PORT_FUNCA | PORTB | PORT_PIN8)
#define PORT_EIC_EXTINT8_4 (PORT_FUNCA | PORTC | PORT_PIN24)
#define PORT_EIC_EXTINT9_1 (PORT_FUNCA | PORTA | PORT_PIN25)
#define PORT_EIC_EXTINT9_2 (PORT_FUNCA | PORTA | PORT_PIN9)
#define PORT_EIC_EXTINT9_3 (PORT_FUNCA | PORTB | PORT_PIN25)
#define PORT_EIC_EXTINT9_4 (PORT_FUNCA | PORTB | PORT_PIN9)
#define PORT_EIC_EXTINT9_5 (PORT_FUNCA | PORTC | PORT_PIN25)
#define PORT_EIC_EXTINT9_6 (PORT_FUNCA | PORTC | PORT_PIN7)
#define PORT_EIC_EXTINT10_1 (PORT_FUNCA | PORTA | PORT_PIN10)
#define PORT_EIC_EXTINT10_2 (PORT_FUNCA | PORTB | PORT_PIN10)
#define PORT_EIC_EXTINT10_3 (PORT_FUNCA | PORTC | PORT_PIN10)
#define PORT_EIC_EXTINT10_4 (PORT_FUNCA | PORTC | PORT_PIN26)
#define PORT_EIC_EXTINT10_5 (PORT_FUNCA | PORTD | PORT_PIN20)
#define PORT_EIC_EXTINT11_1 (PORT_FUNCA | PORTA | PORT_PIN11)
#define PORT_EIC_EXTINT11_2 (PORT_FUNCA | PORTA | PORT_PIN27)
#define PORT_EIC_EXTINT11_3 (PORT_FUNCA | PORTB | PORT_PIN11)
#define PORT_EIC_EXTINT11_4 (PORT_FUNCA | PORTC | PORT_PIN11)
#define PORT_EIC_EXTINT11_5 (PORT_FUNCA | PORTC | PORT_PIN27)
#define PORT_EIC_EXTINT11_6 (PORT_FUNCA | PORTD | PORT_PIN21)
#define PORT_EIC_EXTINT12_1 (PORT_FUNCA | PORTA | PORT_PIN12)
#define PORT_EIC_EXTINT12_2 (PORT_FUNCA | PORTB | PORT_PIN12)
#define PORT_EIC_EXTINT12_3 (PORT_FUNCA | PORTB | PORT_PIN26)
#define PORT_EIC_EXTINT12_4 (PORT_FUNCA | PORTC | PORT_PIN12)
#define PORT_EIC_EXTINT12_5 (PORT_FUNCA | PORTC | PORT_PIN28)
#define PORT_EIC_EXTINT13_1 (PORT_FUNCA | PORTA | PORT_PIN13)
#define PORT_EIC_EXTINT13_2 (PORT_FUNCA | PORTB | PORT_PIN13)
#define PORT_EIC_EXTINT13_3 (PORT_FUNCA | PORTB | PORT_PIN27)
#define PORT_EIC_EXTINT13_4 (PORT_FUNCA | PORTC | PORT_PIN13)
#define PORT_EIC_EXTINT14_1 (PORT_FUNCA | PORTA | PORT_PIN14)
#define PORT_EIC_EXTINT14_2 (PORT_FUNCA | PORTA | PORT_PIN30)
#define PORT_EIC_EXTINT14_3 (PORT_FUNCA | PORTB | PORT_PIN14)
#define PORT_EIC_EXTINT14_4 (PORT_FUNCA | PORTB | PORT_PIN28)
#define PORT_EIC_EXTINT14_5 (PORT_FUNCA | PORTB | PORT_PIN30)
#define PORT_EIC_EXTINT14_6 (PORT_FUNCA | PORTC | PORT_PIN14)
#define PORT_EIC_EXTINT14_7 (PORT_FUNCA | PORTC | PORT_PIN30)
#define PORT_EIC_EXTINT15_1 (PORT_FUNCA | PORTA | PORT_PIN15)
#define PORT_EIC_EXTINT15_2 (PORT_FUNCA | PORTA | PORT_PIN31)
#define PORT_EIC_EXTINT15_3 (PORT_FUNCA | PORTB | PORT_PIN15)
#define PORT_EIC_EXTINT15_4 (PORT_FUNCA | PORTB | PORT_PIN29)
#define PORT_EIC_EXTINT15_5 (PORT_FUNCA | PORTB | PORT_PIN31)
#define PORT_EIC_EXTINT15_6 (PORT_FUNCA | PORTC | PORT_PIN15)
#define PORT_EIC_EXTINT15_7 (PORT_FUNCA | PORTC | PORT_PIN31)
#define PORT_EIC_NMI (PORT_FUNCA | PORTA | PORT_PIN8)
/* Generic Clock Controller (GCLK) */
#define PORT_GCLK_IO0_1 (PORT_FUNCM | PORTA | PORT_PIN14)
#define PORT_GCLK_IO0_2 (PORT_FUNCM | PORTA | PORT_PIN30)
#define PORT_GCLK_IO0_3 (PORT_FUNCM | PORTB | PORT_PIN14)
#define PORT_GCLK_IO0_4 (PORT_FUNCM | PORTB | PORT_PIN22)
#define PORT_GCLK_IO1_1 (PORT_FUNCL | PORTA | PORT_PIN27)
#define PORT_GCLK_IO1_2 (PORT_FUNCM | PORTA | PORT_PIN15)
#define PORT_GCLK_IO1_3 (PORT_FUNCM | PORTB | PORT_PIN15)
#define PORT_GCLK_IO1_4 (PORT_FUNCM | PORTB | PORT_PIN23)
#define PORT_GCLK_IO2_1 (PORT_FUNCM | PORTA | PORT_PIN16)
#define PORT_GCLK_IO2_2 (PORT_FUNCM | PORTB | PORT_PIN16)
#define PORT_GCLK_IO3_1 (PORT_FUNCM | PORTA | PORT_PIN17)
#define PORT_GCLK_IO3_2 (PORT_FUNCM | PORTB | PORT_PIN17)
#define PORT_GCLK_IO4_1 (PORT_FUNCM | PORTA | PORT_PIN10)
#define PORT_GCLK_IO4_2 (PORT_FUNCM | PORTB | PORT_PIN10)
#define PORT_GCLK_IO4_3 (PORT_FUNCM | PORTB | PORT_PIN18)
#define PORT_GCLK_IO5_1 (PORT_FUNCM | PORTA | PORT_PIN11)
#define PORT_GCLK_IO5_2 (PORT_FUNCM | PORTB | PORT_PIN11)
#define PORT_GCLK_IO5_3 (PORT_FUNCM | PORTB | PORT_PIN19)
#define PORT_GCLK_IO6_1 (PORT_FUNCM | PORTB | PORT_PIN12)
#define PORT_GCLK_IO6_2 (PORT_FUNCM | PORTB | PORT_PIN20)
#define PORT_GCLK_IO7_1 (PORT_FUNCM | PORTB | PORT_PIN13)
#define PORT_GCLK_IO7_2 (PORT_FUNCM | PORTB | PORT_PIN21)
/* Ethernet (GMAC) */
#define PORT_GMAC_GCOL (PORT_FUNCL | PORTC | PORT_PIN21)
#define PORT_GMAC_GCRS (PORT_FUNCL | PORTA | PORT_PIN16)
#define PORT_GMAC_GMDC_1 (PORT_FUNCL | PORTA | PORT_PIN20)
#define PORT_GMAC_GMDC_2 (PORT_FUNCL | PORTB | PORT_PIN14)
#define PORT_GMAC_GMDC_3 (PORT_FUNCL | PORTC | PORT_PIN11)
#define PORT_GMAC_GMDC_4 (PORT_FUNCL | PORTC | PORT_PIN22)
#define PORT_GMAC_GMDIO_1 (PORT_FUNCL | PORTA | PORT_PIN21)
#define PORT_GMAC_GMDIO_2 (PORT_FUNCL | PORTB | PORT_PIN15)
#define PORT_GMAC_GMDIO_3 (PORT_FUNCL | PORTC | PORT_PIN12)
#define PORT_GMAC_GMDIO_4 (PORT_FUNCL | PORTC | PORT_PIN23)
#define PORT_GMAC_GRX0 (PORT_FUNCL | PORTA | PORT_PIN13)
#define PORT_GMAC_GRX1 (PORT_FUNCL | PORTA | PORT_PIN12)
#define PORT_GMAC_GRX2 (PORT_FUNCL | PORTC | PORT_PIN15)
#define PORT_GMAC_GRX3 (PORT_FUNCL | PORTC | PORT_PIN14)
#define PORT_GMAC_GRXCK (PORT_FUNCL | PORTC | PORT_PIN18)
#define PORT_GMAC_GRXDV (PORT_FUNCL | PORTC | PORT_PIN20)
#define PORT_GMAC_GRXER (PORT_FUNCL | PORTA | PORT_PIN15)
#define PORT_GMAC_GTX0 (PORT_FUNCL | PORTA | PORT_PIN18)
#define PORT_GMAC_GTX1 (PORT_FUNCL | PORTA | PORT_PIN19)
#define PORT_GMAC_GTX2 (PORT_FUNCL | PORTC | PORT_PIN16)
#define PORT_GMAC_GTX3 (PORT_FUNCL | PORTC | PORT_PIN17)
#define PORT_GMAC_GTXCK (PORT_FUNCL | PORTA | PORT_PIN14)
#define PORT_GMAC_GTXEN (PORT_FUNCL | PORTA | PORT_PIN17)
#define PORT_GMAC_GTXER (PORT_FUNCL | PORTC | PORT_PIN19)
/* Inter IC Sound (I2S) */
#define PORT_I2S_FS0_1 (PORT_FUNCJ | PORTA | PORT_PIN20)
#define PORT_I2S_FS0_2 (PORT_FUNCJ | PORTA | PORT_PIN9)
#define PORT_I2S_FS1_1 (PORT_FUNCJ | PORTA | PORT_PIN23)
#define PORT_I2S_FS1_2 (PORT_FUNCJ | PORTB | PORT_PIN11)
#define PORT_I2S_MCK0_1 (PORT_FUNCJ | PORTA | PORT_PIN8)
#define PORT_I2S_MCK0_2 (PORT_FUNCJ | PORTB | PORT_PIN17)
#define PORT_I2S_MCK1_1 (PORT_FUNCJ | PORTB | PORT_PIN13)
#define PORT_I2S_MCK1_2 (PORT_FUNCJ | PORTB | PORT_PIN29)
#define PORT_I2S_SCK0_1 (PORT_FUNCJ | PORTA | PORT_PIN10)
#define PORT_I2S_SCK0_2 (PORT_FUNCJ | PORTB | PORT_PIN16)
#define PORT_I2S_SCK1_1 (PORT_FUNCJ | PORTB | PORT_PIN12)
#define PORT_I2S_SCK1_2 (PORT_FUNCJ | PORTB | PORT_PIN28)
#define PORT_I2S_SDI_1 (PORT_FUNCJ | PORTA | PORT_PIN22)
#define PORT_I2S_SDI_2 (PORT_FUNCJ | PORTB | PORT_PIN10)
#define PORT_I2S_SDO_1 (PORT_FUNCJ | PORTA | PORT_PIN11)
#define PORT_I2S_SDO_2 (PORT_FUNCJ | PORTA | PORT_PIN21)
/* Parallel Capture Controller (PCC) */
#define PORT_PCC_CLK (PORT_FUNCK | PORTA | PORT_PIN14)
#define PORT_PCC_DATA0 (PORT_FUNCK | PORTA | PORT_PIN16)
#define PORT_PCC_DATA1 (PORT_FUNCK | PORTA | PORT_PIN17)
#define PORT_PCC_DATA2 (PORT_FUNCK | PORTA | PORT_PIN18)
#define PORT_PCC_DATA3 (PORT_FUNCK | PORTA | PORT_PIN19)
#define PORT_PCC_DATA4 (PORT_FUNCK | PORTA | PORT_PIN20)
#define PORT_PCC_DATA5 (PORT_FUNCK | PORTA | PORT_PIN21)
#define PORT_PCC_DATA6 (PORT_FUNCK | PORTA | PORT_PIN22)
#define PORT_PCC_DATA7 (PORT_FUNCK | PORTA | PORT_PIN23)
#define PORT_PCC_DATA8 (PORT_FUNCK | PORTB | PORT_PIN14)
#define PORT_PCC_DATA9 (PORT_FUNCK | PORTB | PORT_PIN15)
#define PORT_PCC_DATA10 (PORT_FUNCK | PORTC | PORT_PIN12)
#define PORT_PCC_DATA11 (PORT_FUNCK | PORTC | PORT_PIN13)
#define PORT_PCC_DATA12 (PORT_FUNCK | PORTC | PORT_PIN14)
#define PORT_PCC_DATA13 (PORT_FUNCK | PORTC | PORT_PIN15)
#define PORT_PCC_DEN1 (PORT_FUNCK | PORTA | PORT_PIN12)
#define PORT_PCC_DEN2 (PORT_FUNCK | PORTA | PORT_PIN13)
/* Position Decoder (PDEC) */
#define PORT_PDEC_QDI0_1 (PORT_FUNCG | PORTA | PORT_PIN24)
#define PORT_PDEC_QDI0_2 (PORT_FUNCG | PORTB | PORT_PIN18)
#define PORT_PDEC_QDI0_3 (PORT_FUNCG | PORTB | PORT_PIN23)
#define PORT_PDEC_QDI0_4 (PORT_FUNCG | PORTC | PORT_PIN16)
#define PORT_PDEC_QDI1_1 (PORT_FUNCG | PORTA | PORT_PIN25)
#define PORT_PDEC_QDI1_2 (PORT_FUNCG | PORTB | PORT_PIN19)
#define PORT_PDEC_QDI1_3 (PORT_FUNCG | PORTB | PORT_PIN24)
#define PORT_PDEC_QDI1_4 (PORT_FUNCG | PORTC | PORT_PIN17)
#define PORT_PDEC_QDI2_1 (PORT_FUNCG | PORTB | PORT_PIN20)
#define PORT_PDEC_QDI2_2 (PORT_FUNCG | PORTB | PORT_PIN22)
#define PORT_PDEC_QDI2_3 (PORT_FUNCG | PORTB | PORT_PIN25)
#define PORT_PDEC_QDI2_4 (PORT_FUNCG | PORTC | PORT_PIN18)
/* Peripheral Touch Controller (PTC) */
#define PORT_PTC_X0_Y0 (PORT_FUNCB | PORTA | PORT_PIN3)
#define PORT_PTC_X1_Y1 (PORT_FUNCB | PORTB | PORT_PIN8)
#define PORT_PTC_X2_Y2 (PORT_FUNCB | PORTB | PORT_PIN9)
#define PORT_PTC_X3_Y3 (PORT_FUNCB | PORTA | PORT_PIN4)
#define PORT_PTC_X4_Y4 (PORT_FUNCB | PORTA | PORT_PIN6)
#define PORT_PTC_X5_Y5 (PORT_FUNCB | PORTA | PORT_PIN7)
#define PORT_PTC_X6_Y6 (PORT_FUNCB | PORTA | PORT_PIN8)
#define PORT_PTC_X7_Y7 (PORT_FUNCB | PORTA | PORT_PIN9)
#define PORT_PTC_X8_Y8 (PORT_FUNCB | PORTA | PORT_PIN10)
#define PORT_PTC_X9_Y9 (PORT_FUNCB | PORTA | PORT_PIN11)
#define PORT_PTC_X10_Y10 (PORT_FUNCB | PORTA | PORT_PIN16)
#define PORT_PTC_X11_Y11 (PORT_FUNCB | PORTA | PORT_PIN17)
#define PORT_PTC_X12_Y12 (PORT_FUNCB | PORTA | PORT_PIN18)
#define PORT_PTC_X13_Y13 (PORT_FUNCB | PORTA | PORT_PIN19)
#define PORT_PTC_X14_Y14 (PORT_FUNCB | PORTA | PORT_PIN20)
#define PORT_PTC_X15_Y15 (PORT_FUNCB | PORTA | PORT_PIN21)
#define PORT_PTC_X16_Y16 (PORT_FUNCB | PORTA | PORT_PIN22)
#define PORT_PTC_X17_Y17 (PORT_FUNCB | PORTA | PORT_PIN23)
#define PORT_PTC_X18_Y18 (PORT_FUNCB | PORTA | PORT_PIN27)
#define PORT_PTC_X19_Y19 (PORT_FUNCB | PORTA | PORT_PIN30)
#define PORT_PTC_X20_Y20 (PORT_FUNCB | PORTB | PORT_PIN2)
#define PORT_PTC_X21_Y21 (PORT_FUNCB | PORTB | PORT_PIN3)
#define PORT_PTC_X22_Y22 (PORT_FUNCB | PORTB | PORT_PIN4)
#define PORT_PTC_X23_Y23 (PORT_FUNCB | PORTB | PORT_PIN5)
#define PORT_PTC_X24_Y24 (PORT_FUNCB | PORTB | PORT_PIN6)
#define PORT_PTC_X25_Y25 (PORT_FUNCB | PORTB | PORT_PIN7)
#define PORT_PTC_X26_Y26 (PORT_FUNCB | PORTB | PORT_PIN12)
#define PORT_PTC_X27_Y27 (PORT_FUNCB | PORTB | PORT_PIN13)
#define PORT_PTC_X28_Y28 (PORT_FUNCB | PORTB | PORT_PIN14)
#define PORT_PTC_X29_Y29 (PORT_FUNCB | PORTB | PORT_PIN15)
#define PORT_PTC_X30_Y30 (PORT_FUNCB | PORTB | PORT_PIN0)
#define PORT_PTC_X31_Y31 (PORT_FUNCB | PORTB | PORT_PIN1)
/* Quad SPI (QSPI) */
#define PORT_QSPI_CS (PORT_FUNCH | PORTB | PORT_PIN11)
#define PORT_QSPI_DATA0 (PORT_FUNCH | PORTA | PORT_PIN8)
#define PORT_QSPI_DATA1 (PORT_FUNCH | PORTA | PORT_PIN9)
#define PORT_QSPI_DATA2 (PORT_FUNCH | PORTA | PORT_PIN10)
#define PORT_QSPI_DATA3 (PORT_FUNCH | PORTA | PORT_PIN11)
#define PORT_QSPI_SCK (PORT_FUNCH | PORTB | PORT_PIN10)
/* SDHC Memory Card Controllers */
#define PORT_SDHC0_SDCD_1 (PORT_FUNCI | PORTA | PORT_PIN12)
#define PORT_SDHC0_SDCD_2 (PORT_FUNCI | PORTA | PORT_PIN6)
#define PORT_SDHC0_SDCD_3 (PORT_FUNCI | PORTB | PORT_PIN12)
#define PORT_SDHC0_SDCD_4 (PORT_FUNCI | PORTC | PORT_PIN6)
#define PORT_SDHC0_SDCK (PORT_FUNCI | PORTB | PORT_PIN11)
#define PORT_SDHC0_SDCMD (PORT_FUNCI | PORTA | PORT_PIN8)
#define PORT_SDHC0_SDDAT0 (PORT_FUNCI | PORTA | PORT_PIN9)
#define PORT_SDHC0_SDDAT1 (PORT_FUNCI | PORTA | PORT_PIN10)
#define PORT_SDHC0_SDDAT2 (PORT_FUNCI | PORTA | PORT_PIN11)
#define PORT_SDHC0_SDDAT3 (PORT_FUNCI | PORTB | PORT_PIN10)
#define PORT_SDHC0_SDWP_1 (PORT_FUNCI | PORTA | PORT_PIN13)
#define PORT_SDHC0_SDWP_2 (PORT_FUNCI | PORTA | PORT_PIN7)
#define PORT_SDHC0_SDWP_3 (PORT_FUNCI | PORTB | PORT_PIN13)
#define PORT_SDHC0_SDWP_4 (PORT_FUNCI | PORTC | PORT_PIN7)
#define PORT_SDHC1_SDCD_1 (PORT_FUNCI | PORTB | PORT_PIN16)
#define PORT_SDHC1_SDCD_2 (PORT_FUNCI | PORTC | PORT_PIN20)
#define PORT_SDHC1_SDCD_3 (PORT_FUNCI | PORTD | PORT_PIN20)
#define PORT_SDHC1_SDCK (PORT_FUNCI | PORTA | PORT_PIN21)
#define PORT_SDHC1_SDCMD (PORT_FUNCI | PORTA | PORT_PIN20)
#define PORT_SDHC1_SDDAT0 (PORT_FUNCI | PORTB | PORT_PIN18)
#define PORT_SDHC1_SDDAT1 (PORT_FUNCI | PORTB | PORT_PIN19)
#define PORT_SDHC1_SDDAT2 (PORT_FUNCI | PORTB | PORT_PIN20)
#define PORT_SDHC1_SDDAT3 (PORT_FUNCI | PORTB | PORT_PIN21)
#define PORT_SDHC1_SDWP_1 (PORT_FUNCI | PORTB | PORT_PIN17)
#define PORT_SDHC1_SDWP_2 (PORT_FUNCI | PORTC | PORT_PIN21)
#define PORT_SDHC1_SDWP_3 (PORT_FUNCI | PORTD | PORT_PIN21)
/* Serial Communication Interfaces (SERCOM) */
#define PORT_SERCOM0_PAD0_1 (PORT_FUNCC | PORTA | PORT_PIN8)
#define PORT_SERCOM0_PAD0_2 (PORT_FUNCC | PORTB | PORT_PIN24)
#define PORT_SERCOM0_PAD0_3 (PORT_FUNCD | PORTA | PORT_PIN4)
#define PORT_SERCOM0_PAD0_4 (PORT_FUNCD | PORTC | PORT_PIN17)
#define PORT_SERCOM0_PAD1_1 (PORT_FUNCC | PORTA | PORT_PIN9)
#define PORT_SERCOM0_PAD1_2 (PORT_FUNCC | PORTB | PORT_PIN25)
#define PORT_SERCOM0_PAD1_3 (PORT_FUNCD | PORTA | PORT_PIN5)
#define PORT_SERCOM0_PAD1_4 (PORT_FUNCD | PORTC | PORT_PIN16)
#define PORT_SERCOM0_PAD2_1 (PORT_FUNCC | PORTA | PORT_PIN10)
#define PORT_SERCOM0_PAD2_2 (PORT_FUNCC | PORTC | PORT_PIN24)
#define PORT_SERCOM0_PAD2_3 (PORT_FUNCD | PORTA | PORT_PIN6)
#define PORT_SERCOM0_PAD2_4 (PORT_FUNCD | PORTC | PORT_PIN18)
#define PORT_SERCOM0_PAD3_1 (PORT_FUNCC | PORTA | PORT_PIN11)
#define PORT_SERCOM0_PAD3_2 (PORT_FUNCC | PORTC | PORT_PIN25)
#define PORT_SERCOM0_PAD3_3 (PORT_FUNCD | PORTA | PORT_PIN7)
#define PORT_SERCOM0_PAD3_4 (PORT_FUNCD | PORTC | PORT_PIN19)
#define PORT_SERCOM1_PAD0_1 (PORT_FUNCC | PORTA | PORT_PIN16)
#define PORT_SERCOM1_PAD0_2 (PORT_FUNCC | PORTC | PORT_PIN22)
#define PORT_SERCOM1_PAD0_3 (PORT_FUNCC | PORTC | PORT_PIN27)
#define PORT_SERCOM1_PAD0_4 (PORT_FUNCD | PORTA | PORT_PIN0)
#define PORT_SERCOM1_PAD1_1 (PORT_FUNCC | PORTA | PORT_PIN17)
#define PORT_SERCOM1_PAD1_2 (PORT_FUNCC | PORTC | PORT_PIN23)
#define PORT_SERCOM1_PAD1_3 (PORT_FUNCC | PORTC | PORT_PIN28)
#define PORT_SERCOM1_PAD1_4 (PORT_FUNCD | PORTA | PORT_PIN1)
#define PORT_SERCOM1_PAD2_1 (PORT_FUNCC | PORTA | PORT_PIN18)
#define PORT_SERCOM1_PAD2_2 (PORT_FUNCC | PORTB | PORT_PIN22)
#define PORT_SERCOM1_PAD2_3 (PORT_FUNCC | PORTD | PORT_PIN20)
#define PORT_SERCOM1_PAD2_4 (PORT_FUNCD | PORTA | PORT_PIN30)
#define PORT_SERCOM1_PAD3_1 (PORT_FUNCC | PORTA | PORT_PIN19)
#define PORT_SERCOM1_PAD3_2 (PORT_FUNCC | PORTB | PORT_PIN23)
#define PORT_SERCOM1_PAD3_3 (PORT_FUNCC | PORTD | PORT_PIN21)
#define PORT_SERCOM1_PAD3_4 (PORT_FUNCD | PORTA | PORT_PIN31)
#define PORT_SERCOM2_PAD0_1 (PORT_FUNCC | PORTA | PORT_PIN12)
#define PORT_SERCOM2_PAD0_2 (PORT_FUNCC | PORTB | PORT_PIN26)
#define PORT_SERCOM2_PAD0_3 (PORT_FUNCD | PORTA | PORT_PIN9)
#define PORT_SERCOM2_PAD0_4 (PORT_FUNCD | PORTB | PORT_PIN25)
#define PORT_SERCOM2_PAD1_1 (PORT_FUNCC | PORTA | PORT_PIN13)
#define PORT_SERCOM2_PAD1_2 (PORT_FUNCC | PORTB | PORT_PIN27)
#define PORT_SERCOM2_PAD1_3 (PORT_FUNCD | PORTA | PORT_PIN8)
#define PORT_SERCOM2_PAD1_4 (PORT_FUNCD | PORTB | PORT_PIN24)
#define PORT_SERCOM2_PAD2_1 (PORT_FUNCC | PORTA | PORT_PIN14)
#define PORT_SERCOM2_PAD2_2 (PORT_FUNCC | PORTB | PORT_PIN28)
#define PORT_SERCOM2_PAD2_3 (PORT_FUNCD | PORTA | PORT_PIN10)
#define PORT_SERCOM2_PAD2_4 (PORT_FUNCD | PORTC | PORT_PIN24)
#define PORT_SERCOM2_PAD3_1 (PORT_FUNCC | PORTA | PORT_PIN15)
#define PORT_SERCOM2_PAD3_2 (PORT_FUNCC | PORTB | PORT_PIN29)
#define PORT_SERCOM2_PAD3_3 (PORT_FUNCD | PORTA | PORT_PIN11)
#define PORT_SERCOM2_PAD3_4 (PORT_FUNCD | PORTC | PORT_PIN25)
#define PORT_SERCOM3_PAD0_1 (PORT_FUNCC | PORTA | PORT_PIN22)
#define PORT_SERCOM3_PAD0_2 (PORT_FUNCC | PORTB | PORT_PIN20)
#define PORT_SERCOM3_PAD0_3 (PORT_FUNCD | PORTA | PORT_PIN17)
#define PORT_SERCOM3_PAD0_4 (PORT_FUNCD | PORTC | PORT_PIN23)
#define PORT_SERCOM3_PAD1_1 (PORT_FUNCC | PORTA | PORT_PIN23)
#define PORT_SERCOM3_PAD1_2 (PORT_FUNCC | PORTB | PORT_PIN21)
#define PORT_SERCOM3_PAD1_3 (PORT_FUNCD | PORTA | PORT_PIN16)
#define PORT_SERCOM3_PAD1_4 (PORT_FUNCD | PORTC | PORT_PIN22)
#define PORT_SERCOM3_PAD2_1 (PORT_FUNCC | PORTA | PORT_PIN24)
#define PORT_SERCOM3_PAD2_2 (PORT_FUNCD | PORTA | PORT_PIN18)
#define PORT_SERCOM3_PAD2_3 (PORT_FUNCD | PORTA | PORT_PIN20)
#define PORT_SERCOM3_PAD2_4 (PORT_FUNCD | PORTD | PORT_PIN20)
#define PORT_SERCOM3_PAD3_1 (PORT_FUNCC | PORTA | PORT_PIN25)
#define PORT_SERCOM3_PAD3_2 (PORT_FUNCD | PORTA | PORT_PIN19)
#define PORT_SERCOM3_PAD3_3 (PORT_FUNCD | PORTA | PORT_PIN21)
#define PORT_SERCOM3_PAD3_4 (PORT_FUNCD | PORTD | PORT_PIN21)
#define PORT_SERCOM4_PAD0_1 (PORT_FUNCC | PORTB | PORT_PIN12)
#define PORT_SERCOM4_PAD0_2 (PORT_FUNCD | PORTA | PORT_PIN13)
#define PORT_SERCOM4_PAD0_3 (PORT_FUNCD | PORTB | PORT_PIN27)
#define PORT_SERCOM4_PAD0_4 (PORT_FUNCD | PORTB | PORT_PIN8)
#define PORT_SERCOM4_PAD1_1 (PORT_FUNCC | PORTB | PORT_PIN13)
#define PORT_SERCOM4_PAD1_2 (PORT_FUNCD | PORTA | PORT_PIN12)
#define PORT_SERCOM4_PAD1_3 (PORT_FUNCD | PORTB | PORT_PIN26)
#define PORT_SERCOM4_PAD1_4 (PORT_FUNCD | PORTB | PORT_PIN9)
#define PORT_SERCOM4_PAD2_1 (PORT_FUNCC | PORTB | PORT_PIN14)
#define PORT_SERCOM4_PAD2_2 (PORT_FUNCD | PORTA | PORT_PIN14)
#define PORT_SERCOM4_PAD2_3 (PORT_FUNCD | PORTB | PORT_PIN10)
#define PORT_SERCOM4_PAD2_4 (PORT_FUNCD | PORTB | PORT_PIN28)
#define PORT_SERCOM4_PAD3_1 (PORT_FUNCC | PORTB | PORT_PIN15)
#define PORT_SERCOM4_PAD3_2 (PORT_FUNCD | PORTA | PORT_PIN15)
#define PORT_SERCOM4_PAD3_3 (PORT_FUNCD | PORTB | PORT_PIN11)
#define PORT_SERCOM4_PAD3_4 (PORT_FUNCD | PORTB | PORT_PIN29)
#define PORT_SERCOM5_PAD0_1 (PORT_FUNCC | PORTB | PORT_PIN16)
#define PORT_SERCOM5_PAD0_2 (PORT_FUNCD | PORTA | PORT_PIN23)
#define PORT_SERCOM5_PAD0_3 (PORT_FUNCD | PORTB | PORT_PIN2)
#define PORT_SERCOM5_PAD0_4 (PORT_FUNCD | PORTB | PORT_PIN31)
#define PORT_SERCOM5_PAD1_1 (PORT_FUNCC | PORTB | PORT_PIN17)
#define PORT_SERCOM5_PAD1_2 (PORT_FUNCD | PORTA | PORT_PIN22)
#define PORT_SERCOM5_PAD1_3 (PORT_FUNCD | PORTB | PORT_PIN3)
#define PORT_SERCOM5_PAD1_4 (PORT_FUNCD | PORTB | PORT_PIN30)
#define PORT_SERCOM5_PAD2_1 (PORT_FUNCC | PORTA | PORT_PIN20)
#define PORT_SERCOM5_PAD2_2 (PORT_FUNCC | PORTB | PORT_PIN18)
#define PORT_SERCOM5_PAD2_3 (PORT_FUNCD | PORTA | PORT_PIN24)
#define PORT_SERCOM5_PAD2_4 (PORT_FUNCD | PORTB | PORT_PIN0)
#define PORT_SERCOM5_PAD2_5 (PORT_FUNCD | PORTB | PORT_PIN22)
#define PORT_SERCOM5_PAD3_1 (PORT_FUNCC | PORTA | PORT_PIN21)
#define PORT_SERCOM5_PAD3_2 (PORT_FUNCC | PORTB | PORT_PIN19)
#define PORT_SERCOM5_PAD3_3 (PORT_FUNCD | PORTA | PORT_PIN25)
#define PORT_SERCOM5_PAD3_4 (PORT_FUNCD | PORTB | PORT_PIN1)
#define PORT_SERCOM5_PAD3_5 (PORT_FUNCD | PORTB | PORT_PIN23)
#define PORT_SERCOM6_PAD0_1 (PORT_FUNCC | PORTC | PORT_PIN16)
#define PORT_SERCOM6_PAD0_2 (PORT_FUNCC | PORTC | PORT_PIN4)
#define PORT_SERCOM6_PAD0_3 (PORT_FUNCD | PORTC | PORT_PIN13)
#define PORT_SERCOM6_PAD0_4 (PORT_FUNCD | PORTD | PORT_PIN9)
#define PORT_SERCOM6_PAD1_1 (PORT_FUNCC | PORTC | PORT_PIN17)
#define PORT_SERCOM6_PAD1_2 (PORT_FUNCC | PORTC | PORT_PIN5)
#define PORT_SERCOM6_PAD1_3 (PORT_FUNCD | PORTC | PORT_PIN12)
#define PORT_SERCOM6_PAD1_4 (PORT_FUNCD | PORTD | PORT_PIN8)
#define PORT_SERCOM6_PAD2_1 (PORT_FUNCC | PORTC | PORT_PIN10)
#define PORT_SERCOM6_PAD2_2 (PORT_FUNCC | PORTC | PORT_PIN18)
#define PORT_SERCOM6_PAD2_3 (PORT_FUNCC | PORTC | PORT_PIN6)
#define PORT_SERCOM6_PAD2_4 (PORT_FUNCD | PORTC | PORT_PIN14)
#define PORT_SERCOM6_PAD2_5 (PORT_FUNCD | PORTD | PORT_PIN10)
#define PORT_SERCOM6_PAD3_1 (PORT_FUNCC | PORTC | PORT_PIN11)
#define PORT_SERCOM6_PAD3_2 (PORT_FUNCC | PORTC | PORT_PIN19)
#define PORT_SERCOM6_PAD3_3 (PORT_FUNCC | PORTC | PORT_PIN7)
#define PORT_SERCOM6_PAD3_4 (PORT_FUNCD | PORTC | PORT_PIN15)
#define PORT_SERCOM6_PAD3_5 (PORT_FUNCD | PORTD | PORT_PIN11)
#define PORT_SERCOM7_PAD0_1 (PORT_FUNCC | PORTB | PORT_PIN30)
#define PORT_SERCOM7_PAD0_2 (PORT_FUNCC | PORTC | PORT_PIN12)
#define PORT_SERCOM7_PAD0_3 (PORT_FUNCC | PORTD | PORT_PIN8)
#define PORT_SERCOM7_PAD0_4 (PORT_FUNCD | PORTB | PORT_PIN21)
#define PORT_SERCOM7_PAD1_1 (PORT_FUNCC | PORTB | PORT_PIN31)
#define PORT_SERCOM7_PAD1_2 (PORT_FUNCC | PORTC | PORT_PIN13)
#define PORT_SERCOM7_PAD1_3 (PORT_FUNCC | PORTD | PORT_PIN9)
#define PORT_SERCOM7_PAD1_4 (PORT_FUNCD | PORTB | PORT_PIN20)
#define PORT_SERCOM7_PAD2_1 (PORT_FUNCC | PORTA | PORT_PIN30)
#define PORT_SERCOM7_PAD2_2 (PORT_FUNCC | PORTC | PORT_PIN14)
#define PORT_SERCOM7_PAD2_3 (PORT_FUNCC | PORTD | PORT_PIN10)
#define PORT_SERCOM7_PAD2_4 (PORT_FUNCD | PORTB | PORT_PIN18)
#define PORT_SERCOM7_PAD2_5 (PORT_FUNCD | PORTC | PORT_PIN10)
#define PORT_SERCOM7_PAD3_1 (PORT_FUNCC | PORTA | PORT_PIN31)
#define PORT_SERCOM7_PAD3_2 (PORT_FUNCC | PORTC | PORT_PIN15)
#define PORT_SERCOM7_PAD3_3 (PORT_FUNCC | PORTD | PORT_PIN11)
#define PORT_SERCOM7_PAD3_4 (PORT_FUNCD | PORTB | PORT_PIN19)
#define PORT_SERCOM7_PAD3_5 (PORT_FUNCD | PORTC | PORT_PIN11)
/* Timer/Counters (TC) */
#define PORT_TC0_WO0_1 (PORT_FUNCE | PORTA | PORT_PIN4)
#define PORT_TC0_WO0_2 (PORT_FUNCE | PORTA | PORT_PIN8)
#define PORT_TC0_WO0_3 (PORT_FUNCE | PORTB | PORT_PIN30)
#define PORT_TC0_WO1_1 (PORT_FUNCE | PORTA | PORT_PIN5)
#define PORT_TC0_WO1_2 (PORT_FUNCE | PORTA | PORT_PIN9)
#define PORT_TC0_WO1_3 (PORT_FUNCE | PORTB | PORT_PIN31)
#define PORT_TC1_WO0_1 (PORT_FUNCE | PORTA | PORT_PIN10)
#define PORT_TC1_WO0_2 (PORT_FUNCE | PORTA | PORT_PIN6)
#define PORT_TC1_WO1_1 (PORT_FUNCE | PORTA | PORT_PIN11)
#define PORT_TC1_WO1_2 (PORT_FUNCE | PORTA | PORT_PIN7)
#define PORT_TC2_WO0_1 (PORT_FUNCE | PORTA | PORT_PIN0)
#define PORT_TC2_WO0_2 (PORT_FUNCE | PORTA | PORT_PIN12)
#define PORT_TC2_WO0_3 (PORT_FUNCE | PORTA | PORT_PIN16)
#define PORT_TC2_WO1_1 (PORT_FUNCE | PORTA | PORT_PIN1)
#define PORT_TC2_WO1_2 (PORT_FUNCE | PORTA | PORT_PIN13)
#define PORT_TC2_WO1_3 (PORT_FUNCE | PORTA | PORT_PIN17)
#define PORT_TC3_WO0_1 (PORT_FUNCE | PORTA | PORT_PIN14)
#define PORT_TC3_WO0_2 (PORT_FUNCE | PORTA | PORT_PIN18)
#define PORT_TC3_WO1_1 (PORT_FUNCE | PORTA | PORT_PIN15)
#define PORT_TC3_WO1_2 (PORT_FUNCE | PORTA | PORT_PIN19)
#define PORT_TC4_WO0_1 (PORT_FUNCE | PORTA | PORT_PIN22)
#define PORT_TC4_WO0_2 (PORT_FUNCE | PORTB | PORT_PIN12)
#define PORT_TC4_WO0_3 (PORT_FUNCE | PORTB | PORT_PIN8)
#define PORT_TC4_WO1_1 (PORT_FUNCE | PORTA | PORT_PIN23)
#define PORT_TC4_WO1_2 (PORT_FUNCE | PORTB | PORT_PIN13)
#define PORT_TC4_WO1_3 (PORT_FUNCE | PORTB | PORT_PIN9)
#define PORT_TC5_WO0_1 (PORT_FUNCE | PORTA | PORT_PIN24)
#define PORT_TC5_WO0_2 (PORT_FUNCE | PORTB | PORT_PIN10)
#define PORT_TC5_WO0_3 (PORT_FUNCE | PORTB | PORT_PIN14)
#define PORT_TC5_WO1_1 (PORT_FUNCE | PORTA | PORT_PIN25)
#define PORT_TC5_WO1_2 (PORT_FUNCE | PORTB | PORT_PIN11)
#define PORT_TC5_WO1_3 (PORT_FUNCE | PORTB | PORT_PIN15)
#define PORT_TC6_WO0_1 (PORT_FUNCE | PORTA | PORT_PIN30)
#define PORT_TC6_WO0_2 (PORT_FUNCE | PORTB | PORT_PIN16)
#define PORT_TC6_WO0_3 (PORT_FUNCE | PORTB | PORT_PIN2)
#define PORT_TC6_WO1_1 (PORT_FUNCE | PORTA | PORT_PIN31)
#define PORT_TC6_WO1_2 (PORT_FUNCE | PORTB | PORT_PIN17)
#define PORT_TC6_WO1_3 (PORT_FUNCE | PORTB | PORT_PIN3)
#define PORT_TC7_WO0_1 (PORT_FUNCE | PORTA | PORT_PIN20)
#define PORT_TC7_WO0_2 (PORT_FUNCE | PORTB | PORT_PIN0)
#define PORT_TC7_WO0_3 (PORT_FUNCE | PORTB | PORT_PIN22)
#define PORT_TC7_WO1_1 (PORT_FUNCE | PORTA | PORT_PIN21)
#define PORT_TC7_WO1_2 (PORT_FUNCE | PORTB | PORT_PIN1)
#define PORT_TC7_WO1_3 (PORT_FUNCE | PORTB | PORT_PIN23)
/* Timer/Counters Control (TCC) */
#define PORT_TCC0_WO0_1 (PORT_FUNCF | PORTA | PORT_PIN8)
#define PORT_TCC0_WO0_2 (PORT_FUNCF | PORTC | PORT_PIN10)
#define PORT_TCC0_WO0_3 (PORT_FUNCF | PORTC | PORT_PIN16)
#define PORT_TCC0_WO0_4 (PORT_FUNCF | PORTC | PORT_PIN4)
#define PORT_TCC0_WO0_5 (PORT_FUNCG | PORTA | PORT_PIN20)
#define PORT_TCC0_WO0_6 (PORT_FUNCG | PORTB | PORT_PIN12)
#define PORT_TCC0_WO1_1 (PORT_FUNCF | PORTA | PORT_PIN9)
#define PORT_TCC0_WO1_2 (PORT_FUNCF | PORTC | PORT_PIN11)
#define PORT_TCC0_WO1_3 (PORT_FUNCF | PORTC | PORT_PIN17)
#define PORT_TCC0_WO1_4 (PORT_FUNCF | PORTD | PORT_PIN8)
#define PORT_TCC0_WO1_5 (PORT_FUNCG | PORTA | PORT_PIN21)
#define PORT_TCC0_WO1_6 (PORT_FUNCG | PORTB | PORT_PIN13)
#define PORT_TCC0_WO2_1 (PORT_FUNCF | PORTA | PORT_PIN10)
#define PORT_TCC0_WO2_2 (PORT_FUNCF | PORTC | PORT_PIN12)
#define PORT_TCC0_WO2_3 (PORT_FUNCF | PORTC | PORT_PIN18)
#define PORT_TCC0_WO2_4 (PORT_FUNCF | PORTD | PORT_PIN9)
#define PORT_TCC0_WO2_5 (PORT_FUNCG | PORTA | PORT_PIN22)
#define PORT_TCC0_WO2_6 (PORT_FUNCG | PORTB | PORT_PIN14)
#define PORT_TCC0_WO3_1 (PORT_FUNCF | PORTA | PORT_PIN11)
#define PORT_TCC0_WO3_2 (PORT_FUNCF | PORTC | PORT_PIN13)
#define PORT_TCC0_WO3_3 (PORT_FUNCF | PORTC | PORT_PIN19)
#define PORT_TCC0_WO3_4 (PORT_FUNCF | PORTD | PORT_PIN10)
#define PORT_TCC0_WO3_5 (PORT_FUNCG | PORTA | PORT_PIN23)
#define PORT_TCC0_WO3_6 (PORT_FUNCG | PORTB | PORT_PIN15)
#define PORT_TCC0_WO4_1 (PORT_FUNCF | PORTB | PORT_PIN10)
#define PORT_TCC0_WO4_2 (PORT_FUNCF | PORTC | PORT_PIN14)
#define PORT_TCC0_WO4_3 (PORT_FUNCF | PORTC | PORT_PIN20)
#define PORT_TCC0_WO4_4 (PORT_FUNCF | PORTD | PORT_PIN11)
#define PORT_TCC0_WO4_5 (PORT_FUNCG | PORTA | PORT_PIN16)
#define PORT_TCC0_WO4_6 (PORT_FUNCG | PORTB | PORT_PIN16)
#define PORT_TCC0_WO5_1 (PORT_FUNCF | PORTB | PORT_PIN11)
#define PORT_TCC0_WO5_2 (PORT_FUNCF | PORTC | PORT_PIN15)
#define PORT_TCC0_WO5_3 (PORT_FUNCF | PORTC | PORT_PIN21)
#define PORT_TCC0_WO5_4 (PORT_FUNCF | PORTD | PORT_PIN12)
#define PORT_TCC0_WO5_5 (PORT_FUNCG | PORTA | PORT_PIN17)
#define PORT_TCC0_WO5_6 (PORT_FUNCG | PORTB | PORT_PIN17)
#define PORT_TCC0_WO6_1 (PORT_FUNCF | PORTA | PORT_PIN12)
#define PORT_TCC0_WO6_2 (PORT_FUNCF | PORTC | PORT_PIN22)
#define PORT_TCC0_WO6_3 (PORT_FUNCG | PORTA | PORT_PIN18)
#define PORT_TCC0_WO6_4 (PORT_FUNCG | PORTB | PORT_PIN30)
#define PORT_TCC0_WO7_1 (PORT_FUNCF | PORTA | PORT_PIN13)
#define PORT_TCC0_WO7_2 (PORT_FUNCF | PORTC | PORT_PIN23)
#define PORT_TCC0_WO7_3 (PORT_FUNCG | PORTA | PORT_PIN19)
#define PORT_TCC0_WO7_4 (PORT_FUNCG | PORTB | PORT_PIN31)
#define PORT_TCC1_WO0_1 (PORT_FUNCF | PORTA | PORT_PIN16)
#define PORT_TCC1_WO0_2 (PORT_FUNCF | PORTB | PORT_PIN18)
#define PORT_TCC1_WO0_3 (PORT_FUNCF | PORTD | PORT_PIN20)
#define PORT_TCC1_WO0_4 (PORT_FUNCG | PORTB | PORT_PIN10)
#define PORT_TCC1_WO0_5 (PORT_FUNCG | PORTC | PORT_PIN14)
#define PORT_TCC1_WO1_1 (PORT_FUNCF | PORTA | PORT_PIN17)
#define PORT_TCC1_WO1_2 (PORT_FUNCF | PORTB | PORT_PIN19)
#define PORT_TCC1_WO1_3 (PORT_FUNCF | PORTD | PORT_PIN21)
#define PORT_TCC1_WO1_4 (PORT_FUNCG | PORTB | PORT_PIN11)
#define PORT_TCC1_WO1_5 (PORT_FUNCG | PORTC | PORT_PIN15)
#define PORT_TCC1_WO2_1 (PORT_FUNCF | PORTA | PORT_PIN18)
#define PORT_TCC1_WO2_2 (PORT_FUNCF | PORTB | PORT_PIN20)
#define PORT_TCC1_WO2_3 (PORT_FUNCF | PORTB | PORT_PIN26)
#define PORT_TCC1_WO2_4 (PORT_FUNCG | PORTA | PORT_PIN12)
#define PORT_TCC1_WO2_5 (PORT_FUNCG | PORTA | PORT_PIN14)
#define PORT_TCC1_WO3_1 (PORT_FUNCF | PORTA | PORT_PIN19)
#define PORT_TCC1_WO3_2 (PORT_FUNCF | PORTB | PORT_PIN21)
#define PORT_TCC1_WO3_3 (PORT_FUNCF | PORTB | PORT_PIN27)
#define PORT_TCC1_WO3_4 (PORT_FUNCG | PORTA | PORT_PIN13)
#define PORT_TCC1_WO3_5 (PORT_FUNCG | PORTA | PORT_PIN15)
#define PORT_TCC1_WO4_1 (PORT_FUNCF | PORTA | PORT_PIN20)
#define PORT_TCC1_WO4_2 (PORT_FUNCF | PORTB | PORT_PIN28)
#define PORT_TCC1_WO4_3 (PORT_FUNCG | PORTA | PORT_PIN8)
#define PORT_TCC1_WO4_4 (PORT_FUNCG | PORTC | PORT_PIN10)
#define PORT_TCC1_WO5_1 (PORT_FUNCF | PORTA | PORT_PIN21)
#define PORT_TCC1_WO5_2 (PORT_FUNCF | PORTB | PORT_PIN29)
#define PORT_TCC1_WO5_3 (PORT_FUNCG | PORTA | PORT_PIN9)
#define PORT_TCC1_WO5_4 (PORT_FUNCG | PORTC | PORT_PIN11)
#define PORT_TCC1_WO6_1 (PORT_FUNCF | PORTA | PORT_PIN22)
#define PORT_TCC1_WO6_2 (PORT_FUNCG | PORTA | PORT_PIN10)
#define PORT_TCC1_WO6_3 (PORT_FUNCG | PORTC | PORT_PIN12)
#define PORT_TCC1_WO7_1 (PORT_FUNCF | PORTA | PORT_PIN23)
#define PORT_TCC1_WO7_2 (PORT_FUNCG | PORTA | PORT_PIN11)
#define PORT_TCC1_WO7_3 (PORT_FUNCG | PORTC | PORT_PIN13)
#define PORT_TCC2_WO0_1 (PORT_FUNCF | PORTA | PORT_PIN14)
#define PORT_TCC2_WO0_2 (PORT_FUNCF | PORTA | PORT_PIN30)
#define PORT_TCC2_WO1_1 (PORT_FUNCF | PORTA | PORT_PIN15)
#define PORT_TCC2_WO1_2 (PORT_FUNCF | PORTA | PORT_PIN31)
#define PORT_TCC2_WO2_1 (PORT_FUNCF | PORTA | PORT_PIN24)
#define PORT_TCC2_WO2_2 (PORT_FUNCF | PORTB | PORT_PIN2)
#define PORT_TCC3_WO0_1 (PORT_FUNCF | PORTB | PORT_PIN12)
#define PORT_TCC3_WO0_2 (PORT_FUNCF | PORTB | PORT_PIN16)
#define PORT_TCC3_WO1_1 (PORT_FUNCF | PORTB | PORT_PIN13)
#define PORT_TCC3_WO1_2 (PORT_FUNCF | PORTB | PORT_PIN17)
#define PORT_TCC4_WO0_1 (PORT_FUNCF | PORTB | PORT_PIN14)
#define PORT_TCC4_WO0_2 (PORT_FUNCF | PORTB | PORT_PIN30)
#define PORT_TCC4_WO1_1 (PORT_FUNCF | PORTB | PORT_PIN15)
#define PORT_TCC4_WO1_2 (PORT_FUNCF | PORTB | PORT_PIN31)
/* USB */
#define PORT_USB_DM (PORT_FUNCH | PORTA | PORT_PIN24)
#define PORT_USB_DP (PORT_FUNCH | PORTA | PORT_PIN25)
#define PORT_USB_SOF_1KHZ_1 (PORT_FUNCH | PORTA | PORT_PIN23)
#define PORT_USB_SOF_1KHZ_2 (PORT_FUNCH | PORTB | PORT_PIN22)
/********************************************************************************************
* Public Types
********************************************************************************************/
/********************************************************************************************
* Public Data
********************************************************************************************/
/********************************************************************************************
* Public Functions
********************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_CHIP_SAM_PINMAP_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,94 @@
/************************************************************************************
* arch/arm/src/samd5e5/sam_clockconfig.h
*
* Copyright (C) 2018 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_SAMD5E5_SAM_CLOCKCONFIG_H
#define __ARCH_ARM_SRC_SAMD5E5_SAM_CLOCKCONFIG_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/************************************************************************************
* Public Types
************************************************************************************/
/************************************************************************************
* Inline Functions
************************************************************************************/
#ifndef __ASSEMBLY__
/************************************************************************************
* Public Data
************************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/************************************************************************************
* Public Function Prototypes
************************************************************************************/
/************************************************************************************
* Name: sam_clockconfig
*
* Description:
* Called to initialize the SAM3/4. This does whatever setup is needed to put the
* SoC in a usable state. This includes the initialization of clocking using the
* settings in board.h.
*
************************************************************************************/
void sam_clockconfig(void);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_SRC_SAMD5E5_SAM_CLOCKCONFIG_H */

View File

@ -0,0 +1,234 @@
/****************************************************************************
* arch/arm/src/samd5e5/sam_cmcc.c
*
* Copyright (C) 2018 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdint.h>
#include <assert.h>
#include "up_arch.h"
#include "chip/sam_cmcc.h"
#include "sam_cmcc.h"
#ifdef CONFIG_SAMD5E5_CMCC
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define CMCC_MASK (CMCC_CACHE_LINE_SIZE-1)
#if CMCC_CACHE_LINE_SIZE == 4
# define CMCC_SHIFT 2
#elif CMCC_CACHE_LINE_SIZE == 8
# define CMCC_SHIFT 3
#elif CMCC_CACHE_LINE_SIZE == 16
# define CMCC_SHIFT 4
#elif CMCC_CACHE_LINE_SIZE == 32
# define CMCC_SHIFT 5
#else
# error Unknown cache line size
#endif
#define ALIGN_UP(a) (((a)+CMCC_MASK) & ~CMCC_MASK)
#define ALIGN_DOWN(a) ((a) & ~CMCC_MASK)
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sam_cmcc_enable
*
* Description:
* Enable the Cortex-M Cache Controller
*
****************************************************************************/
void sam_cmcc_enable(void)
{
/* "On reset, the cache controller data entries are all invalidated and the
* cache is disabled. The cache is transparent to processor operations. The
* cache controller is activated with its configuration registers. The
* configuration interface is memory mapped in the private peripheral bus.
*
* "Use the following sequence to enable the cache controller.
*
* "1. Verify that the cache controller is disabled, reading the value of the
* CSTS (cache status) field of the CMCC_SR register.
* "2. Enable the cache controller, writing 1 to the CEN (cache enable) field
* of the CMCC_CTRL register."
*/
if ((getreg32(SAM_CMCC_SR) & CMCC_SR_CSTS) == 0)
{
putreg32(CMCC_CTRL_CEN, SAM_CMCC_CTRL);
}
}
/****************************************************************************
* Name: sam_cmcc_disable
*
* Description:
* Disable the Cortex-M Cache Controller
*
****************************************************************************/
void sam_cmcc_disable(void)
{
/* "1. Disable the cache controller, writing 0 to the CEN field of the
* CMCC_CTRL register.
* "2. Check CSTS field of the CMCC_SR to verify that the cache is
* successfully disabled.
*/
putreg32(0, SAM_CMCC_CTRL);
while ((getreg32(SAM_CMCC_SR) & CMCC_SR_CSTS) != 0);
}
/****************************************************************************
* Name: sam_cmcc_invalidate
*
* Description:
* Invalidate a range of addresses. Note: These addresses should be
* aligned with the beginning and end of cache lines. Otherwise, values
* at the edges of the region will also be invalidated!
*
****************************************************************************/
void sam_cmcc_invalidate(uintptr_t start, uintptr_t end)
{
uintptr_t addr;
uint32_t regval;
ssize_t size;
int index;
int way;
/* Get the aligned addresses and size (in bytes) for the memory region
* to be invalidated.
*/
start = ALIGN_DOWN(start);
end = ALIGN_UP(end);
size = end - start + 1;
/* If this is a large region (as big as the cache), then just invalidate
* the entire cache the easy way.
*
* CacheSize = CacheLineSize * NCacheLines * NWays
* CacheAddressRange = CacheLineSize * NCacheLines = CacheSize / NWays
*
* Example: CacheSize = 2048, CacheLineSize=16, NWays=4:
*
* CacheAddressRange = 2048 / 4 = 512
* NCacheLines = 32
*/
if (size >= (CMCC_CACHE_SIZE / CMCC_NWAYS))
{
sam_cmcc_invalidateall();
return;
}
/* "When an invalidate by line command is issued the cache controller resets
* the valid bit information of the decoded cache line. As the line is no
* longer valid the replacement counter points to that line.
*
* "Use the following sequence to invalidate one line of cache.
*
* "1. Disable the cache controller, writing 0 to the CEN field of the
* CMCC_CTRL register.
* "2. Check CSTS field of the CMCC_SR to verify that the cache is
* successfully disabled.
* "3. Perform an invalidate by line writing the bit set {index, way} in
* the CMCC_MAINT1 register.
* "4. Enable the cache controller, writing 1 to the CEN field of the
* CMCC_CTRL register."
*/
/* Disable the cache controller */
sam_cmcc_disable();
/* Invalidate the address region */
for (addr = start, index = (int)(start >> CMCC_SHIFT);
addr <= end;
addr += CMCC_CACHE_LINE_SIZE, index++)
{
regval = CMCC_MAINT1_INDEX(index);
for (way = 0; way < CMCC_NWAYS; way++)
{
putreg32(regval | CMCC_MAINT1_WAY(way), SAM_CMCC_MAINT1);
}
}
/* Re-enable the cache controller */
sam_cmcc_enable();
}
/****************************************************************************
* Name: sam_cmcc_invalidateall
*
* Description:
* Invalidate the entire cache
*
****************************************************************************/
void sam_cmcc_invalidateall(void)
{
/* "To invalidate all cache entries:
*
* " Write 1 to the INVALL field of the CMCC_MAINT0 register."
*/
putreg32(CMCC_MAINT0_INVALL, SAM_CMCC_MAINT0);
}
#endif /* CONFIG_SAMD5E5_CMCC */

View File

@ -0,0 +1,136 @@
/************************************************************************************
* arch/arm/src/samd5e5/sam_cmcc.h
*
* Copyright (C) 2018 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_SAMD5E5_SAM_CMCC_H
#define __ARCH_ARM_SRC_SAMD5E5_SAM_CMCC_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#ifdef CONFIG_SAMD5E5_CMCC
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/************************************************************************************
* Public Types
************************************************************************************/
/************************************************************************************
* Inline Functions
************************************************************************************/
#ifndef __ASSEMBLY__
/************************************************************************************
* Public Data
************************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/************************************************************************************
* Public Function Prototypes
************************************************************************************/
/****************************************************************************
* Name: sam_cmcc_enable
*
* Description:
* Enable the Cortex-M Cache Controller
*
****************************************************************************/
void sam_cmcc_enable(void);
/****************************************************************************
* Name: sam_cmcc_disable
*
* Description:
* Disable the Cortex-M Cache Controller
*
****************************************************************************/
void sam_cmcc_disable(void);
/****************************************************************************
* Name: sam_cmcc_invalidate
*
* Description:
* Invalidate a range of addresses. Note: These addresses should be
* aligned with the beginning and end of cache lines. Otherwise, values
* at the edges of the region will also be invalidated!
*
****************************************************************************/
void sam_cmcc_invalidate(uintptr_t start, uintptr_t end);
/****************************************************************************
* Name: sam_cmcc_invalidateall
*
* Description:
* Invalidate the entire cache
*
****************************************************************************/
void sam_cmcc_invalidateall(void);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#else /* CONFIG_SAMD5E5_CMCC */
/* Stubs so that we don't have to put condition compilation in driver source */
# define sam_cmcc_invalidate(start, end)
# define sam_cmcc_invalidateall()
#endif /* CONFIG_SAMD5E5_CMCC */
#endif /* __ARCH_ARM_SRC_SAMD5E5_SAM_CMCC_H */

View File

@ -0,0 +1,372 @@
/************************************************************************************
* arch/arm/src/samd5e5/sam_config.h
*
* Copyright (C) 2018 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_SAMD5E5_SAM_CONFIG_H
#define __ARCH_ARM_SRC_SAMD5E5_SAM_CONFIG_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* How many SERCOM peripherals are configured as USART peripherals? */
#define SAMD5E5_HAVE_USART0 1
#define SAMD5E5_HAVE_USART1 1
#define SAMD5E5_HAVE_USART2 1
#define SAMD5E5_HAVE_USART3 1
#define SAMD5E5_HAVE_USART4 1
#define SAMD5E5_HAVE_USART5 1
#define SAMD5E5_HAVE_USART6 1
#define SAMD5E5_HAVE_USART7 1
#if !defined(CONFIG_SAMD5E5_SERCOM0) || !defined(CONFIG_SAMD5E5_SERCOM0_ISUSART) || \
!defined(CONFIG_USART0_SERIALDRIVER)
# undef SAMD5E5_HAVE_USART0
# undef CONFIG_SAMD5E5_SERCOM0_ISUSART
# undef CONFIG_USART0_SERIAL_CONSOLE
# undef CONFIG_USART0_FLOWCONTROL
# undef CONFIG_USART0_IRDAMODE
# undef CONFIG_USART0_RS485MODE
#endif
#if !defined(CONFIG_SAMD5E5_SERCOM1) || !defined(CONFIG_SAMD5E5_SERCOM1_ISUSART) || \
!defined(CONFIG_USART1_SERIALDRIVER)
# undef SAMD5E5_HAVE_USART1
# undef CONFIG_SAMD5E5_SERCOM1_ISUSART
# undef CONFIG_USART1_SERIAL_CONSOLE
# undef CONFIG_USART1_FLOWCONTROL
# undef CONFIG_USART1_IRDAMODE
# undef CONFIG_USART1_RS485MODE
#endif
#if !defined(CONFIG_SAMD5E5_SERCOM2) || !defined(CONFIG_SAMD5E5_SERCOM2_ISUSART) || \
!defined(CONFIG_USART2_SERIALDRIVER)
# undef SAMD5E5_HAVE_USART2
# undef CONFIG_SAMD5E5_SERCOM2_ISUSART
# undef CONFIG_USART2_SERIAL_CONSOLE
# undef CONFIG_USART2_FLOWCONTROL
# undef CONFIG_USART2_IRDAMODE
# undef CONFIG_USART2_RS485MODE
#endif
#if !defined(CONFIG_SAMD5E5_SERCOM3) || !defined(CONFIG_SAMD5E5_SERCOM3_ISUSART) || \
!defined(CONFIG_USART3_SERIALDRIVER)
# undef SAMD5E5_HAVE_USART3
# undef CONFIG_SAMD5E5_SERCOM3_ISUSART
# undef CONFIG_USART3_SERIAL_CONSOLE
# undef CONFIG_USART3_FLOWCONTROL
# undef CONFIG_USART3_IRDAMODE
# undef CONFIG_USART3_RS485MODE
#endif
#if !defined(CONFIG_SAMD5E5_SERCOM4) || !defined(CONFIG_SAMD5E5_SERCOM4_ISUSART) || \
!defined(CONFIG_USART4_SERIALDRIVER)
# undef SAMD5E5_HAVE_USART4
# undef CONFIG_SAMD5E5_SERCOM4_ISUSART
# undef CONFIG_USART4_SERIAL_CONSOLE
# undef CONFIG_USART4_FLOWCONTROL
# undef CONFIG_USART4_IRDAMODE
# undef CONFIG_USART4_RS485MODE
#endif
#if !defined(CONFIG_SAMD5E5_SERCOM5) || !defined(CONFIG_SAMD5E5_SERCOM5_ISUSART) || \
!defined(CONFIG_USART5_SERIALDRIVER)
# undef SAMD5E5_HAVE_USART5
# undef CONFIG_SAMD5E5_SERCOM5_ISUSART
# undef CONFIG_USART5_SERIAL_CONSOLE
# undef CONFIG_USART5_FLOWCONTROL
# undef CONFIG_USART5_IRDAMODE
# undef CONFIG_USART5_RS485MODE
#endif
#if !defined(CONFIG_SAMD5E5_SERCOM6) || !defined(CONFIG_SAMD5E5_SERCOM6_ISUSART) || \
!defined(CONFIG_USART6_SERIALDRIVER)
# undef SAMD5E5_HAVE_USART6
# undef CONFIG_SAMD5E5_SERCOM6_ISUSART
# undef CONFIG_USART6_SERIAL_CONSOLE
# undef CONFIG_USART6_FLOWCONTROL
# undef CONFIG_USART6_IRDAMODE
# undef CONFIG_USART6_RS485MODE
#endif
#if !defined(CONFIG_SAMD5E5_SERCOM7) || !defined(CONFIG_SAMD5E5_SERCOM7_ISUSART) || \
!defined(CONFIG_USART7_SERIALDRIVER)
# undef SAMD5E5_HAVE_USART7
# undef CONFIG_SAMD5E5_SERCOM7_ISUSART
# undef CONFIG_USART7_SERIAL_CONSOLE
# undef CONFIG_USART7_FLOWCONTROL
# undef CONFIG_USART7_IRDAMODE
# undef CONFIG_USART7_RS485MODE
#endif
/* Are any USARTs enabled? */
#undef SAMD5E5_HAVE_USART
#if defined(SAMD5E5_HAVE_USART0) || defined(SAMD5E5_HAVE_USART1) || \
defined(SAMD5E5_HAVE_USART2) || defined(SAMD5E5_HAVE_USART3) || \
defined(SAMD5E5_HAVE_USART4) || defined(SAMD5E5_HAVE_USART5) || \
defined(SAMD5E5_HAVE_USART6) || defined(SAMD5E5_HAVE_USART7)
# define SAMD5E5_HAVE_USART 1
#endif
/* Is there a serial console? There should be at most one defined. It could be on
* any USARTn, n=0-5 - OR - there might not be any serial console at all.
*/
#if defined(CONFIG_USART0_SERIAL_CONSOLE)
# undef CONFIG_USART1_SERIAL_CONSOLE
# undef CONFIG_USART2_SERIAL_CONSOLE
# undef CONFIG_USART3_SERIAL_CONSOLE
# undef CONFIG_USART4_SERIAL_CONSOLE
# undef CONFIG_USART5_SERIAL_CONSOLE
# undef CONFIG_USART6_SERIAL_CONSOLE
# undef CONFIG_USART7_SERIAL_CONSOLE
# define HAVE_SERIAL_CONSOLE 1
#elif defined(CONFIG_USART1_SERIAL_CONSOLE)
# undef CONFIG_USART0_SERIAL_CONSOLE
# undef CONFIG_USART2_SERIAL_CONSOLE
# undef CONFIG_USART3_SERIAL_CONSOLE
# undef CONFIG_USART4_SERIAL_CONSOLE
# undef CONFIG_USART5_SERIAL_CONSOLE
# undef CONFIG_USART6_SERIAL_CONSOLE
# undef CONFIG_USART7_SERIAL_CONSOLE
# define HAVE_SERIAL_CONSOLE 1
#elif defined(CONFIG_USART2_SERIAL_CONSOLE)
# undef CONFIG_USART0_SERIAL_CONSOLE
# undef CONFIG_USART1_SERIAL_CONSOLE
# undef CONFIG_USART3_SERIAL_CONSOLE
# undef CONFIG_USART4_SERIAL_CONSOLE
# undef CONFIG_USART5_SERIAL_CONSOLE
# undef CONFIG_USART6_SERIAL_CONSOLE
# undef CONFIG_USART7_SERIAL_CONSOLE
# define HAVE_SERIAL_CONSOLE 1
#elif defined(CONFIG_USART3_SERIAL_CONSOLE)
# undef CONFIG_USART0_SERIAL_CONSOLE
# undef CONFIG_USART1_SERIAL_CONSOLE
# undef CONFIG_USART2_SERIAL_CONSOLE
# undef CONFIG_USART4_SERIAL_CONSOLE
# undef CONFIG_USART5_SERIAL_CONSOLE
# undef CONFIG_USART6_SERIAL_CONSOLE
# undef CONFIG_USART7_SERIAL_CONSOLE
# define HAVE_SERIAL_CONSOLE 1
#elif defined(CONFIG_USART4_SERIAL_CONSOLE)
# undef CONFIG_USART0_SERIAL_CONSOLE
# undef CONFIG_USART1_SERIAL_CONSOLE
# undef CONFIG_USART2_SERIAL_CONSOLE
# undef CONFIG_USART3_SERIAL_CONSOLE
# undef CONFIG_USART5_SERIAL_CONSOLE
# undef CONFIG_USART6_SERIAL_CONSOLE
# undef CONFIG_USART7_SERIAL_CONSOLE
# define HAVE_SERIAL_CONSOLE 1
#elif defined(CONFIG_USART5_SERIAL_CONSOLE)
# undef CONFIG_USART0_SERIAL_CONSOLE
# undef CONFIG_USART1_SERIAL_CONSOLE
# undef CONFIG_USART2_SERIAL_CONSOLE
# undef CONFIG_USART3_SERIAL_CONSOLE
# undef CONFIG_USART4_SERIAL_CONSOLE
# undef CONFIG_USART6_SERIAL_CONSOLE
# undef CONFIG_USART7_SERIAL_CONSOLE
# define HAVE_SERIAL_CONSOLE 1
#elif defined(CONFIG_USART6_SERIAL_CONSOLE)
# undef CONFIG_USART0_SERIAL_CONSOLE
# undef CONFIG_USART1_SERIAL_CONSOLE
# undef CONFIG_USART2_SERIAL_CONSOLE
# undef CONFIG_USART3_SERIAL_CONSOLE
# undef CONFIG_USART4_SERIAL_CONSOLE
# undef CONFIG_USART5_SERIAL_CONSOLE
# undef CONFIG_USART7_SERIAL_CONSOLE
# define HAVE_SERIAL_CONSOLE 1
#elif defined(CONFIG_USART7_SERIAL_CONSOLE)
# undef CONFIG_USART0_SERIAL_CONSOLE
# undef CONFIG_USART1_SERIAL_CONSOLE
# undef CONFIG_USART2_SERIAL_CONSOLE
# undef CONFIG_USART3_SERIAL_CONSOLE
# undef CONFIG_USART4_SERIAL_CONSOLE
# undef CONFIG_USART5_SERIAL_CONSOLE
# undef CONFIG_USART6_SERIAL_CONSOLE
# define HAVE_SERIAL_CONSOLE 1
#else
# undef CONFIG_USART0_SERIAL_CONSOLE
# undef CONFIG_USART1_SERIAL_CONSOLE
# undef CONFIG_USART2_SERIAL_CONSOLE
# undef CONFIG_USART3_SERIAL_CONSOLE
# undef CONFIG_USART4_SERIAL_CONSOLE
# undef CONFIG_USART5_SERIAL_CONSOLE
# undef CONFIG_USART6_SERIAL_CONSOLE
# undef CONFIG_USART7_SERIAL_CONSOLE
# undef HAVE_SERIAL_CONSOLE
#endif
/* Are any SERCOM peripherals are configured as SPI peripherals? */
#define SAMD5E5_HAVE_SPI0 1
#define SAMD5E5_HAVE_SPI1 1
#define SAMD5E5_HAVE_SPI2 1
#define SAMD5E5_HAVE_SPI3 1
#define SAMD5E5_HAVE_SPI4 1
#define SAMD5E5_HAVE_SPI5 1
#define SAMD5E5_HAVE_SPI6 1
#define SAMD5E5_HAVE_SPI7 1
#if !defined(CONFIG_SAMD5E5_SERCOM0) || !defined(CONFIG_SAMD5E5_SERCOM0_ISSPI)
# undef SAMD5E5_HAVE_SPI0
# undef CONFIG_SAMD5E5_SERCOM0_ISSPI
#endif
#if !defined(CONFIG_SAMD5E5_SERCOM1) || !defined(CONFIG_SAMD5E5_SERCOM1_ISSPI)
# undef SAMD5E5_HAVE_SPI1
# undef CONFIG_SAMD5E5_SERCOM1_ISSPI
#endif
#if !defined(CONFIG_SAMD5E5_SERCOM2) || !defined(CONFIG_SAMD5E5_SERCOM2_ISSPI)
# undef SAMD5E5_HAVE_SPI2
# undef CONFIG_SAMD5E5_SERCOM2_ISSPI
#endif
#if !defined(CONFIG_SAMD5E5_SERCOM3) || !defined(CONFIG_SAMD5E5_SERCOM3_ISSPI)
# undef SAMD5E5_HAVE_SPI3
# undef CONFIG_SAMD5E5_SERCOM3_ISSPI
#endif
#if !defined(CONFIG_SAMD5E5_SERCOM4) || !defined(CONFIG_SAMD5E5_SERCOM4_ISSPI)
# undef SAMD5E5_HAVE_SPI4
# undef CONFIG_SAMD5E5_SERCOM4_ISSPI
#endif
#if !defined(CONFIG_SAMD5E5_SERCOM5) || !defined(CONFIG_SAMD5E5_SERCOM5_ISSPI)
# undef SAMD5E5_HAVE_SPI5
# undef CONFIG_SAMD5E5_SERCOM5_ISSPI
#endif
#if !defined(CONFIG_SAMD5E5_SERCOM6) || !defined(CONFIG_SAMD5E5_SERCOM6_ISSPI)
# undef SAMD5E5_HAVE_SPI6
# undef CONFIG_SAMD5E5_SERCOM6_ISSPI
#endif
#if !defined(CONFIG_SAMD5E5_SERCOM7) || !defined(CONFIG_SAMD5E5_SERCOM7_ISSPI)
# undef SAMD5E5_HAVE_SPI7
# undef CONFIG_SAMD5E5_SERCOM7_ISSPI
#endif
/* Are any SERCOMs configured for SPI? */
#undef SAMD5E5_HAVE_SPI
#if defined(SAMD5E5_HAVE_SPI0) || defined(SAMD5E5_HAVE_SPI1) || \
defined(SAMD5E5_HAVE_SPI2) || defined(SAMD5E5_HAVE_SPI3) || \
defined(SAMD5E5_HAVE_SPI4) || defined(SAMD5E5_HAVE_SPI5) || \
defined(SAMD5E5_HAVE_SPI6) || defined(SAMD5E5_HAVE_SPI7)
# define SAMD5E5_HAVE_SPI 1
#endif
/* Are any SERCOM peripherals are configured as I2C peripherals? */
#define SAMD5E5_HAVE_I2C0 1
#define SAMD5E5_HAVE_I2C1 1
#define SAMD5E5_HAVE_I2C2 1
#define SAMD5E5_HAVE_I2C3 1
#define SAMD5E5_HAVE_I2C4 1
#define SAMD5E5_HAVE_I2C5 1
#define SAMD5E5_HAVE_I2C6 1
#define SAMD5E5_HAVE_I2C7 1
#if !defined(CONFIG_SAMD5E5_SERCOM0) || !defined(CONFIG_SAMD5E5_SERCOM0_ISI2C)
# undef SAMD5E5_HAVE_I2C0
# undef CONFIG_SAMD5E5_SERCOM0_ISI2C
#endif
#if !defined(CONFIG_SAMD5E5_SERCOM1) || !defined(CONFIG_SAMD5E5_SERCOM1_ISI2C)
# undef SAMD5E5_HAVE_I2C1
# undef CONFIG_SAMD5E5_SERCOM1_ISI2C
#endif
#if !defined(CONFIG_SAMD5E5_SERCOM2) || !defined(CONFIG_SAMD5E5_SERCOM2_ISI2C)
# undef SAMD5E5_HAVE_I2C2
# undef CONFIG_SAMD5E5_SERCOM2_ISI2C
#endif
#if !defined(CONFIG_SAMD5E5_SERCOM3) || !defined(CONFIG_SAMD5E5_SERCOM3_ISI2C)
# undef SAMD5E5_HAVE_I2C3
# undef CONFIG_SAMD5E5_SERCOM3_ISI2C
#endif
#if !defined(CONFIG_SAMD5E5_SERCOM4) || !defined(CONFIG_SAMD5E5_SERCOM4_ISI2C)
# undef SAMD5E5_HAVE_I2C4
# undef CONFIG_SAMD5E5_SERCOM4_ISI2C
#endif
#if !defined(CONFIG_SAMD5E5_SERCOM5) || !defined(CONFIG_SAMD5E5_SERCOM5_ISI2C)
# undef SAMD5E5_HAVE_I2C5
# undef CONFIG_SAMD5E5_SERCOM5_ISI2C
#endif
#if !defined(CONFIG_SAMD5E5_SERCOM6) || !defined(CONFIG_SAMD5E5_SERCOM6_ISI2C)
# undef SAMD5E5_HAVE_I2C6
# undef CONFIG_SAMD5E5_SERCOM6_ISI2C
#endif
#if !defined(CONFIG_SAMD5E5_SERCOM7) || !defined(CONFIG_SAMD5E5_SERCOM7_ISI2C)
# undef SAMD5E5_HAVE_I2C7
# undef CONFIG_SAMD5E5_SERCOM7_ISI2C
#endif
/* Are any SERCOMs configured for I2C? */
#undef SAMD5E5_HAVE_I2C
#if defined(SAMD5E5_HAVE_I2C0) || defined(SAMD5E5_HAVE_I2C1) || \
defined(SAMD5E5_HAVE_I2C2) || defined(SAMD5E5_HAVE_I2C3) || \
defined(SAMD5E5_HAVE_I2C4) || defined(SAMD5E5_HAVE_I2C5) || \
defined(SAMD5E5_HAVE_I2C6) || defined(SAMD5E5_HAVE_I2C7)
# define SAMD5E5_HAVE_I2C 1
#endif
/************************************************************************************
* Public Types
************************************************************************************/
/************************************************************************************
* Public Data
************************************************************************************/
/************************************************************************************
* Public Functions
************************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_SAM_CONFIG_H */

View File

@ -0,0 +1,273 @@
/****************************************************************************
* arch/arm/src/samd5e5/sam_eic.c
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Matt Thompson <matt@extent3d.com>
*
* 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <assert.h>
#include "up_arch.h"
#include "sam_gclk.h"
#include "sam_periphclks.h"
#include "sam_port.h"
#include "sam_eic.h"
#include <arch/board/board.h>
#ifdef CONFIG_SAMD5E5_EIC
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: sam_eic_syncwait
*
* Description:
* Wait until the ENABLE synchronization is complete
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
static void sam_eic_syncwait(void)
{
while ((getreg8(SAM_EIC_SYNCBUSY) & EIC_SYNCBUSY_ENABLE) != 0);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sam_eic_dumpregs
*
* Description:
* Dump all external interrupt controller (EIC) registers
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
void sam_eic_dumpregs(void)
{
irqinfo("EIC:\n");
irqinfo(" CTRLA: %02x\n", getreg8(SAM_EIC_CTRLA));
irqinfo(" NMICTRL: %02x\n", getreg8(SAM_EIC_NVMICTRL));
irqinfo(" NMIFLAG: %04x\n", getreg16(SAM_EIC_NMIFLAG));
irqinfo(" SYNCBUSY: %08x\n", getreg32(SAM_EIC_SYNCBUSY));
irqinfo(" EVCTRL: %08x\n", getreg32(SAM_EIC_EVCTRL));
irqinfo(" INTENCLR: %08x\n", getreg32(SAM_EIC_INTENCLR));
irqinfo(" INTENSET: %08x\n", getreg32(SAM_EIC_INTENSET));
irqinfo(" INTFLAG: %08x\n", getreg32(SAM_EIC_INTFLAG));
irqinfo(" ASYNCH: %08x\n", getreg32(SAM_EIC_ASYNCH));
irqinfo(" CONFIG0: %08x\n", getreg32(SAM_EIC_CONFIG0));
irqinfo(" CONFIG1: %08x\n", getreg32(SAM_EIC_CONFIG1));
irqinfo(" DEBOUNCEN: %08x\n", getreg32(SAM_EIC_DEBOUNCEN));
irqinfo(" DPRESCALER: %08x\n", getreg32(SAM_EIC_DPRESCALER));
irqinfo(" PINSTATE: %08x\n", getreg32(SAM_EIC_PINSTATE));
}
/****************************************************************************
* Name: sam_eic_initialize
*
* Description:
* Initialize the external interrupt controller (EIC).
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
int sam_eic_initialize(void)
{
uint16_t regval;
/* Configure the EIC APB clock */
sam_apb_eic_enableperiph();
regval = GCLK_CLKCTRL_ID_EIC |
GCLK_CLKCTRL_GEN(CONFIG_SAMD5E5_EIC_GCLKGEN) |
GCLK_CLKCTRL_CLKEN;
putreg16(regval, SAM_GCLK_CLKCTRL);
/* Enable the EIC APB clock */
putreg8(EIC_CTRLA_ENABLE, SAM_EIC_CTRLA);
sam_eic_syncwait();
sam_eic_dumpregs();
return OK;
}
/****************************************************************************
* Name: sam_eic_configure
*
* Description:
* Configure the interrupt edge sensitivity in CONFIGn register of the EIC
*
* Input Parameters:
* eirq - Pin to be configured
* pinset - Configuration of the pin
*
* Returned Value:
* None
*
****************************************************************************/
int sam_eic_configure(uint8_t eirq, port_pinset_t pinset)
{
uint32_t reg;
uint32_t val;
uint32_t config;
/* Determine which of the CONFIG[0:1] registers to write to */
if (eirq < 8)
{
reg = SAM_EIC_CONFIG0;
val = EIC_CONFIG0_SENSE_BOTH(eirq);
if (pinset & PORT_INT_RISING)
{
val = EIC_CONFIG0_SENSE_RISE(eirq);
}
if (pinset & PORT_INT_FALLING)
{
val = EIC_CONFIG0_SENSE_FALL(eirq);
}
val |= EIC_CONFIG0_FILTEN(eirq);
}
else /* if (eirq < 16) */
{
reg = SAM_EIC_CONFIG1;
val = EIC_CONFIG1_SENSE_BOTH(eirq);
if (pinset & PORT_INT_RISING)
{
val = EIC_CONFIG1_SENSE_RISE(eirq);
}
if (pinset & PORT_INT_FALLING)
{
val = EIC_CONFIG1_SENSE_FALL(eirq);
}
val |= EIC_CONFIG1_FILTEN(eirq);
}
/* Write the new config to the CONFIGn register */
config = getreg32(reg);
config |= val;
putreg32(config, reg);
/* Enable interrupt generation for this pin */
putreg32(EIC_EXTINT(eirq), SAM_EIC_INTENSET);
sam_eic_dumpregs();
return OK;
}
/****************************************************************************
* Name: sam_eic_irq_enable
*
* Description:
* Enable an external interrupt.
*
* Input Parameters:
* irq - SAM_IRQ_EXTINTn IRQ to be enabled
*
* Returned Value:
* None
*
****************************************************************************/
int sam_eic_irq_enable(int irq)
{
uint32_t config;
int eirq = irq - SAM_IRQ_EXTINT0;
config = getreg32(SAM_EIC_CONFIG0);
config |= EIC_CONFIG0_FILTEN(eirq) | EIC_CONFIG0_SENSE_FALL(eirq);
putreg32(config, SAM_EIC_CONFIG0);
putreg32(EIC_EXTINT(eirq), SAM_EIC_INTENSET);
sam_eic_dumpregs();
return OK;
}
/****************************************************************************
* Name: sam_eic_irq_ack
*
* Description:
* Acknowledge receipt of an external interrupt.
*
* Input Parameters:
* irq - SAM_IRQ_EXTINTn IRQ to be acknowledged
*
* Returned Value:
* None
*
****************************************************************************/
int sam_eic_irq_ack(int irq)
{
int eirq = irq - SAM_IRQ_EXTINT0;
putreg32(EIC_EXTINT(eirq), SAM_EIC_INTENCLR);
}
#endif /* CONFIG_SAMD5E5_EIC */

View File

@ -0,0 +1,137 @@
/****************************************************************************
* arch/arm/src/samd5e5/sam_eic.h
*
* Copyright (C) 2018 Gregory Nutt. All rights reserved.
* Author: Matt Thompson <matt@extent3d.com>
*
* 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_SAMD5E5_SAM_EIC_H
#define __ARCH_ARM_SRC_SAMD5E5_SAM_EIC_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include "sam_config.h"
#include "sam_port.h"
#include "chip/sam_eic.h"
#ifdef CONFIG_SAMD5E5_EIC
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Name: sam_eic_initialize
*
* Description:
* Initialize the EIC
*
* Input Parameters:
* None
*
* Returned Value:
* None
*
****************************************************************************/
int sam_eic_initialize(void);
/****************************************************************************
* Name: sam_eic_configure
*
* Description:
* Configure the interrupt edge sensitivity in CONFIGn register of the EIC
*
* Input Parameters:
* eirq - Pin to be configured
* pinset - Configuration of the pin
*
* Returned Value:
* None
*
****************************************************************************/
int sam_eic_configure(uint8_t eirq, port_pinset_t pinset);
/****************************************************************************
* Name: sam_eic_irq_enable
*
* Description:
* Enable a external interrupt.
*
* Input Parameters:
* irq - SAM_IRQ_EXTINTn IRQ to be enabled
*
* Returned Value:
* None
*
****************************************************************************/
int sam_eic_irq_enable(int irq);
/****************************************************************************
* Name: sam_eic_irq_ack
*
* Description:
* Acknowledge receipt of an external interrupt.
*
* Input Parameters:
* irq - SAM_IRQ_EXTINTn IRQ to be acknowledged
*
* Returned Value:
* None
*
****************************************************************************/
int sam_eic_irq_ack(int irq);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* CONFIG_SAMD5E5_EIC */
#endif /* __ARCH_ARM_SRC_SAMD5E5_SAM_EIC_H */

View File

@ -0,0 +1,284 @@
/****************************************************************************
* arch/arm/src/samd5e5/sam_glck.c
*
* Copyright (C) 2018 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <assert.h>
#include <nuttx/irq.h>
#include "up_arch.h"
#include "sam_gclk.h"
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: sam_gclck_waitsyncbusy
*
* Description:
* What until the SYNCBUSY bit is cleared. The SYNCBUSY bit was set when
* the synchronization of registers between clock domains is started. The
* SYNCBUSY bit is cleared when the synchronization of registers between
* the clock domains is complete.
*
* Input Parameters:
* glck - GCLK clock index
*
* Returned Value:
* None
*
****************************************************************************/
static void sam_gclck_waitsyncbusy(uint8_t gclk)
{
uintptr_t gclkbit = GCLK_SYNCHBUSY_GENCTRL(gclk);
while ((getreg8(SAM_GCLK_SYNCHBUSY) & gclkbit) != 0);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sam_gclk_config
*
* Description:
* Configure a single GCLK(s) based on settings in the config structure.
*
* Input Parameters:
* config - An instance of struct sam_gclkconfig describing the GCLK
* configuration.
*
* Returned Value:
* None
*
****************************************************************************/
void sam_gclk_config(FAR const struct sam_gclkconfig_s *config)
{
irqstate_t flags;
uintptr_t regaddr;
uint32_t regval;
uint32_t genctrl;
/* Select the requested source clock for the generator */
genctrl = ((uint32_t)config->clksrc << GCLK_GENCTRL_SRC_SHIFT);
#if 0 /* Not yet supported */
/* Configure the clock to be either high or low when disabled */
if (config->level)
{
genctrl |= GCLK_GENCTRL_OOV;
}
#endif
/* Configure if the clock output to I/O pin should be enabled */
if (config->output)
{
genctrl |= GCLK_GENCTRL_OE;
}
/* Set the prescaler division factor */
if (config->prescaler > 1)
{
/* Check if division is a power of two */
if (((config->prescaler & (config->prescaler - 1)) == 0))
{
/* Determine the index of the highest bit set to get the
* division factor that must be loaded into the division
* register.
*/
uint32_t count = 0;
uint32_t mask;
for (mask = 2; mask < (uint32_t)config->prescaler; mask <<= 1)
{
count++;
}
/* Set binary divider power of 2 division factor */
genctrl |= count << GCLK_GENCTRL_DIV_SHIFT;
genctrl |= GCLK_GENCTRL_DIVSEL;
}
else
{
/* Set integer division factor */
genctrl |= GCLK_GENCTRL_DIV((uint32_t)config->prescaler);
/* Enable non-binary division with increased duty cycle accuracy */
genctrl |= GCLK_GENCTRL_IDC;
}
}
/* Enable or disable the clock in standby mode */
if (config->runstandby)
{
genctrl |= GCLK_GENCTRL_RUNSTDBY;
}
/* Wait for synchronization */
sam_gclck_waitsyncbusy(config->gclk);
/* Preserve the GENEN bit */
regaddr = SAM_GCLK_GENCTRL(config->gclk);
flags = enter_critical_section();
regval = getreg32(regaddr);
regval &= GCLK_GENCTRL_GENEN;
genctrl |= regval;
/* Configure the generator */
putreg32(genctrl, regaddr);
/* Wait for synchronization */
sam_gclck_waitsyncbusy(config->gclk);
leave_critical_section(flags);
sam_gclck_waitsyncbusy(config->gclk);
/* Enable the clock generator */
flags = enter_critical_section();
genctrl |= GCLK_GENCTRL_GENEN;
putreg32(genctrl, regaddr);
/* Wait for synchronization */
sam_gclck_waitsyncbusy(config->gclk);
leave_critical_section(flags);
}
/****************************************************************************
* Name: sam_gclk_chan_enable
*
* Description:
* Configure and enable a GCLK peripheral channel.
*
* Input Parameters:
* channel - Index of the GCLK channel to be enabled
* srcgen - The GCLK source generator index
*
* Returned Value:
* None
*
****************************************************************************/
void sam_gclk_chan_enable(uint8_t channel, uint8_t srcgen)
{
irqstate_t flags;
uint32_t regaddr;
uint32_t regval;
/* Get the address of the peripheral channel control register */
regaddr = SAM_GCLK_PCHCTRL(channel);
/* Disable generic clock channel */
flags = enter_critical_section();
sam_gclk_chan_disable(channel);
/* Configure the peripheral channel */
regval = GCLK_PCHCTRL_GEN(srcgen);
putreg32(regval, regaddr);
/* Enable the peripheral channel */
regval |= GCLK_PCHCTRL_CHEN;
putreg32(regval, regaddr);
/* Wait for clock synchronization */
while ((getreg32(regaddr) &GCLK_PCHCTRL_CHEN) == 0);
leave_critical_section(flags);
}
/****************************************************************************
* Name: sam_gclk_chan_disable
*
* Description:
* Disable a GCLK peripheral channel.
*
* Input Parameters:
* channel - Index of the GCLK channel to be disabled
*
* Returned Value:
* None
*
****************************************************************************/
void sam_gclk_chan_disable(uint8_t channel)
{
irqstate_t flags;
uint32_t regaddr;
uint32_t regval;
/* Get the address of the peripheral channel control register */
regaddr = SAM_GCLK_PCHCTRL(channel);
/* Disable generic clock channel */
flags = enter_critical_section();
regval = getreg32(regaddr);
regval &= ~GCLK_PCHCTRL_CHEN;
putreg32(regval, regaddr);
/* Wait for clock synchronization */
while ((getreg32(regaddr) &GCLK_PCHCTRL_CHEN) != 0);
leave_critical_section(flags);
}

View File

@ -0,0 +1,148 @@
/****************************************************************************
* arch/arm/src/samd5e5/sam_gclk.h
*
* Copyright (C) 2018 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_SAMD5E5_SAM_GCLK_H
#define __ARCH_ARM_SRC_SAMD5E5_SAM_GCLK_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include "sam_config.h"
#include "chip/sam_gclk.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
#ifndef __ASSEMBLY__
/* This structure describes the configuration of one GCLK */
struct sam_gclkconfig_s
{
uint8_t gclk; /* Clock generator */
bool runstandby; /* Run clock in standby */
bool output; /* Output enable */
uint8_t clksrc; /* Encoded clock source */
uint16_t prescaler; /* Prescaler value */
};
/****************************************************************************
* Inline Functions
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: sam_gclk_config
*
* Description:
* Configure a single GCLK(s) based on settings in the config structure.
*
* Input Parameters:
* config - An instance of struct sam_gclkconfig describing the GCLK
* configuration.
*
* Returned Value:
* None
*
****************************************************************************/
void sam_gclk_config(FAR const struct sam_gclkconfig_s *config);
/****************************************************************************
* Name: sam_gclk_chan_enable
*
* Description:
* Configure and enable a GCLK peripheral channel.
*
* Input Parameters:
* channel - Index of the GCLK channel to be enabled
* srcgen - The GCLK source generator index
*
* Returned Value:
* None
*
****************************************************************************/
void sam_gclk_chan_enable(uint8_t channel, uint8_t srcgen);
/****************************************************************************
* Name: sam_gclk_chan_disable
*
* Description:
* Disable a GCLK peripheral channel.
*
* Input Parameters:
* channel - Index of the GCLK channel to be disabled
*
* Returned Value:
* None
*
****************************************************************************/
void sam_gclk_chan_disable(uint8_t channel);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_SRC_SAMD5E5_SAM_GCLK_H */

View File

@ -0,0 +1,186 @@
/****************************************************************************
* arch/arm/src/samd5e5/sam_idle.c
*
* Copyright (C) 2018 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <arch/board/board.h>
#include <nuttx/config.h>
#include <nuttx/arch.h>
#include <nuttx/board.h>
#include <nuttx/power/pm.h>
#include <nuttx/irq.h>
#include "chip.h"
#include "up_internal.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Does the board support an IDLE LED to indicate that the board is in the
* IDLE state?
*/
#if defined(CONFIG_ARCH_LEDS) && defined(LED_IDLE)
# define BEGIN_IDLE() board_autoled_on(LED_IDLE)
# define END_IDLE() board_autoled_off(LED_IDLE)
#else
# define BEGIN_IDLE()
# define END_IDLE()
#endif
#define PM_IDLE_DOMAIN 0 /* Revisit */
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: up_idlepm
*
* Description:
* Perform IDLE state power management.
*
****************************************************************************/
#ifdef CONFIG_PM
static void up_idlepm(void)
{
static enum pm_state_e oldstate = PM_NORMAL;
enum pm_state_e newstate;
irqstate_t flags;
int ret;
/* Decide, which power saving level can be obtained */
newstate = pm_checkstate(PM_IDLE_DOMAIN);
/* Check for state changes */
if (newstate != oldstate)
{
flags = enter_critical_section();
/* Perform board-specific, state-dependent logic here */
_info("newstate= %d oldstate=%d\n", newstate, oldstate);
/* Then force the global state change */
ret = pm_changestate(PM_IDLE_DOMAIN, newstate);
if (ret < 0)
{
/* The new state change failed, revert to the preceding state */
(void)pm_changestate(PM_IDLE_DOMAIN, oldstate);
}
else
{
/* Save the new state */
oldstate = newstate;
}
/* MCU-specific power management logic */
switch (newstate)
{
case PM_NORMAL:
break;
case PM_IDLE:
break;
case PM_STANDBY:
sam_pmstop(true);
break;
case PM_SLEEP:
(void)sam_pmstandby();
break;
default:
break;
}
leave_critical_section(flags);
}
}
#else
# define up_idlepm()
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_idle
*
* Description:
* up_idle() is the logic that will be executed when their is no other
* ready-to-run task. This is processor idle time and will continue until
* some interrupt occurs to cause a context switch from the idle task.
*
* Processing in this state may be processor-specific. e.g., this is where
* power management operations might be performed.
*
****************************************************************************/
void up_idle(void)
{
#if defined(CONFIG_SUPPRESS_INTERRUPTS) || defined(CONFIG_SUPPRESS_TIMER_INTS)
/* If the system is idle and there are no timer interrupts, then process
* "fake" timer interrupts. Hopefully, something will wake up.
*/
sched_process_timer();
#else
/* Perform IDLE mode power management */
up_idlepm();
/* Sleep until an interrupt occurs to save power. */
BEGIN_IDLE();
asm("WFI");
END_IDLE();
#endif
}

View File

@ -0,0 +1,708 @@
/****************************************************************************
* arch/arm/src/samd5e5/sam_irq.c
*
* Copyright (C) 2018 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <arch/irq.h>
#include "nvic.h"
#include "ram_vectors.h"
#include "up_arch.h"
#include "up_internal.h"
#ifdef CONFIG_SAMD5E5_EIC
# include "sam_eic.h"
#endif
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Get a 32-bit version of the default priority */
#define DEFPRIORITY32 \
(NVIC_SYSH_PRIORITY_DEFAULT << 24 | \
NVIC_SYSH_PRIORITY_DEFAULT << 16 | \
NVIC_SYSH_PRIORITY_DEFAULT << 8 | \
NVIC_SYSH_PRIORITY_DEFAULT)
/* Given the address of a NVIC ENABLE register, this is the offset to
* the corresponding CLEAR ENABLE register.
*/
#define NVIC_ENA_OFFSET (0)
#define NVIC_CLRENA_OFFSET (NVIC_IRQ0_31_CLEAR - NVIC_IRQ0_31_ENABLE)
/****************************************************************************
* Public Data
****************************************************************************/
/* g_current_regs[] holds a references to the current interrupt level
* register storage structure. If is non-NULL only during interrupt
* processing. Access to g_current_regs[] must be through the macro
* CURRENT_REGS for portability.
*/
#ifdef CONFIG_SMP
volatile uint32_t *g_current_regs[CONFIG_SMP_NCPUS];
#else
volatile uint32_t *g_current_regs[1];
#endif
/* This is the address of the exception vector table (determined by the
* linker script).
*/
extern uint32_t _vectors[];
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: sam_dumpnvic
*
* Description:
* Dump some interesting NVIC registers
*
****************************************************************************/
#if defined(CONFIG_DEBUG_IRQ_INFO)
static void sam_dumpnvic(const char *msg, int irq)
{
irqstate_t flags;
flags = enter_critical_section();
irqinfo("NVIC (%s, irq=%d):\n", msg, irq);
irqinfo(" INTCTRL: %08x VECTAB: %08x\n",
getreg32(NVIC_INTCTRL), getreg32(NVIC_VECTAB));
#if 0
irqinfo(" SYSH ENABLE MEMFAULT: %08x BUSFAULT: %08x USGFAULT: %08x SYSTICK: %08x\n",
getreg32(NVIC_SYSHCON_MEMFAULTENA), getreg32(NVIC_SYSHCON_BUSFAULTENA),
getreg32(NVIC_SYSHCON_USGFAULTENA), getreg32(NVIC_SYSTICK_CTRL_ENABLE));
#endif
irqinfo(" IRQ ENABLE: %08x %08x %08x\n",
getreg32(NVIC_IRQ0_31_ENABLE), getreg32(NVIC_IRQ32_63_ENABLE),
getreg32(NVIC_IRQ64_95_ENABLE));
#if SAM_IRQ_NEXTINT > 95
irqinfo(" : %08x %08x %08x\n",
getreg32(NVIC_IRQ96_127_ENABLE), getreg32(NVIC_IRQ128_159_ENABLE),
getreg32(NVIC_IRQ160_191_ENABLE));
#endif
#if SAM_IRQ_NEXTINT > 191
# warning Missing logic
#endif
irqinfo(" SYSH_PRIO: %08x %08x %08x\n",
getreg32(NVIC_SYSH4_7_PRIORITY), getreg32(NVIC_SYSH8_11_PRIORITY),
getreg32(NVIC_SYSH12_15_PRIORITY));
irqinfo(" IRQ PRIO: %08x %08x %08x %08x\n",
getreg32(NVIC_IRQ0_3_PRIORITY), getreg32(NVIC_IRQ4_7_PRIORITY),
getreg32(NVIC_IRQ8_11_PRIORITY), getreg32(NVIC_IRQ12_15_PRIORITY));
#if SAM_IRQ_NEXTINT > 15
irqinfo(" %08x %08x %08x %08x\n",
getreg32(NVIC_IRQ16_19_PRIORITY), getreg32(NVIC_IRQ20_23_PRIORITY),
getreg32(NVIC_IRQ24_27_PRIORITY), getreg32(NVIC_IRQ28_31_PRIORITY));
#endif
#if SAM_IRQ_NEXTINT > 31
irqinfo(" %08x %08x %08x %08x\n",
getreg32(NVIC_IRQ32_35_PRIORITY), getreg32(NVIC_IRQ36_39_PRIORITY),
getreg32(NVIC_IRQ40_43_PRIORITY), getreg32(NVIC_IRQ44_47_PRIORITY));
#endif
#if SAM_IRQ_NEXTINT > 47
irqinfo(" %08x %08x %08x %08x\n",
getreg32(NVIC_IRQ48_51_PRIORITY), getreg32(NVIC_IRQ52_55_PRIORITY),
getreg32(NVIC_IRQ56_59_PRIORITY), getreg32(NVIC_IRQ60_63_PRIORITY));
#endif
#if SAM_IRQ_NEXTINT > 63
irqinfo(" %08x %08x %08x %08x\n",
getreg32(NVIC_IRQ64_67_PRIORITY), getreg32(NVIC_IRQ68_71_PRIORITY),
getreg32(NVIC_IRQ72_75_PRIORITY), getreg32(NVIC_IRQ76_79_PRIORITY));
#endif
#if SAM_IRQ_NEXTINT > 79
irqinfo(" %08x %08x %08x %08x\n",
getreg32(NVIC_IRQ80_83_PRIORITY), getreg32(NVIC_IRQ84_87_PRIORITY),
getreg32(NVIC_IRQ88_91_PRIORITY), getreg32(NVIC_IRQ92_95_PRIORITY));
#endif
#if SAM_IRQ_NEXTINT > 95
irqinfo(" %08x %08x %08x %08x\n",
getreg32(NVIC_IRQ96_99_PRIORITY), getreg32(NVIC_IRQ100_103_PRIORITY),
getreg32(NVIC_IRQ104_107_PRIORITY), getreg32(NVIC_IRQ108_111_PRIORITY));
#endif
#if SAM_IRQ_NEXTINT > 111
irqinfo(" %08x %08x %08x %08x\n",
getreg32(NVIC_IRQ112_115_PRIORITY), getreg32(NVIC_IRQ116_119_PRIORITY),
getreg32(NVIC_IRQ120_123_PRIORITY), getreg32(NVIC_IRQ124_127_PRIORITY));
#endif
#if SAM_IRQ_NEXTINT > 127
irqinfo(" %08x %08x %08x %08x\n",
getreg32(NVIC_IRQ128_131_PRIORITY), getreg32(NVIC_IRQ132_135_PRIORITY),
getreg32(NVIC_IRQ136_139_PRIORITY), getreg32(NVIC_IRQ140_143_PRIORITY));
#endif
#if SAM_IRQ_NEXTINT > 143
# warning Missing logic
#endif
leave_critical_section(flags);
}
#else
# define sam_dumpnvic(msg, irq)
#endif
/****************************************************************************
* Name: sam_nmi, sam_busfault, sam_usagefault, sam_pendsv, sam_dbgmonitor,
* sam_pendsv, sam_reserved
*
* Description:
* Handlers for various exceptions. None are handled and all are fatal
* error conditions. The only advantage these provided over the default
* unexpected interrupt handler is that they provide a diagnostic output.
*
****************************************************************************/
#ifdef CONFIG_DEBUG_FEATURES
static int sam_nmi(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! NMI received\n");
PANIC();
return 0;
}
static int sam_busfault(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Bus fault received: %08x\n", getreg32(NVIC_CFAULTS));
PANIC();
return 0;
}
static int sam_usagefault(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Usage fault received: %08x\n", getreg32(NVIC_CFAULTS));
PANIC();
return 0;
}
static int sam_pendsv(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! PendSV received\n");
PANIC();
return 0;
}
static int sam_dbgmonitor(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Debug Monitor received\n");
PANIC();
return 0;
}
static int sam_reserved(int irq, FAR void *context, FAR void *arg)
{
(void)up_irq_save();
_err("PANIC!!! Reserved interrupt\n");
PANIC();
return 0;
}
#endif
/****************************************************************************
* Name: sam_prioritize_syscall
*
* Description:
* Set the priority of an exception. This function may be needed
* internally even if support for prioritized interrupts is not enabled.
*
****************************************************************************/
#ifdef CONFIG_ARMV7M_USEBASEPRI
static inline void sam_prioritize_syscall(int priority)
{
uint32_t regval;
/* SVCALL is system handler 11 */
regval = getreg32(NVIC_SYSH8_11_PRIORITY);
regval &= ~NVIC_SYSH_PRIORITY_PR11_MASK;
regval |= (priority << NVIC_SYSH_PRIORITY_PR11_SHIFT);
putreg32(regval, NVIC_SYSH8_11_PRIORITY);
}
#endif
/****************************************************************************
* Name: sam_irqinfo
*
* Description:
* Given an IRQ number, provide the register and bit setting to enable or
* disable the irq.
*
****************************************************************************/
static int sam_irqinfo(int irq, uintptr_t *regaddr, uint32_t *bit,
uintptr_t offset)
{
unsigned int extint = irq - SAM_IRQ_EXTINT;
DEBUGASSERT(irq >= SAM_IRQ_NMI && irq < NR_IRQS);
/* Check for external interrupt */
if (irq >= SAM_IRQ_EXTINT)
{
#if SAM_IRQ_NEXTINT <= 32
if (extint < SAM_IRQ_NEXTINT)
{
*regaddr = (NVIC_IRQ0_31_ENABLE + offset);
*bit = 1 << extint;
}
else
#elif SAM_IRQ_NEXTINT <= 64
if (extint < 32)
{
*regaddr = (NVIC_IRQ0_31_ENABLE + offset);
*bit = 1 << extint;
}
else if (extint < SAM_IRQ_NEXTINT)
{
*regaddr = (NVIC_IRQ32_63_ENABLE + offset);
*bit = 1 << (extint - 32);
}
else
#elif SAM_IRQ_NEXTINT <= 96
if (extint < 32)
{
*regaddr = (NVIC_IRQ0_31_ENABLE + offset);
*bit = 1 << extint;
}
else if (extint < 64)
{
*regaddr = (NVIC_IRQ32_63_ENABLE + offset);
*bit = 1 << (extint - 32);
}
else if (extint < SAM_IRQ_NEXTINT)
{
*regaddr = (NVIC_IRQ64_95_ENABLE + offset);
*bit = 1 << (extint - 64);
}
else
#elif SAM_IRQ_NEXTINT <= 128
if (extint < 32)
{
*regaddr = (NVIC_IRQ0_31_ENABLE + offset);
*bit = 1 << extint;
}
else if (extint < 64)
{
*regaddr = (NVIC_IRQ32_63_ENABLE + offset);
*bit = 1 << (extint - 32);
}
else if (extint < 96)
{
*regaddr = (NVIC_IRQ64_95_ENABLE + offset);
*bit = 1 << (extint - 64);
}
else if (extint < SAM_IRQ_NEXTINT)
{
*regaddr = (NVIC_IRQ96_127_ENABLE + offset);
*bit = 1 << (extint - 96);
}
else
#elif SAM_IRQ_NEXTINT <= 160
if (extint < 32)
{
*regaddr = (NVIC_IRQ0_31_ENABLE + offset);
*bit = 1 << extint;
}
else if (extint < 64)
{
*regaddr = (NVIC_IRQ32_63_ENABLE + offset);
*bit = 1 << (extint - 32);
}
else if (extint < 96)
{
*regaddr = (NVIC_IRQ64_95_ENABLE + offset);
*bit = 1 << (extint - 64);
}
else if (extint < 128)
{
*regaddr = (NVIC_IRQ96_127_ENABLE + offset);
*bit = 1 << (extint - 96);
}
else if (extint < SAM_IRQ_NEXTINT)
{
*regaddr = (NVIC_IRQ128_159_ENABLE + offset);
*bit = 1 << (extint - 128);
}
else
#else
# warning Missing logic
#endif
{
return ERROR; /* Invalid interrupt */
}
}
/* Handle processor exceptions. Only a few can be disabled */
else
{
*regaddr = NVIC_SYSHCON;
if (irq == SAM_IRQ_MEMFAULT)
{
*bit = NVIC_SYSHCON_MEMFAULTENA;
}
else if (irq == SAM_IRQ_BUSFAULT)
{
*bit = NVIC_SYSHCON_BUSFAULTENA;
}
else if (irq == SAM_IRQ_USAGEFAULT)
{
*bit = NVIC_SYSHCON_USGFAULTENA;
}
else if (irq == SAM_IRQ_SYSTICK)
{
*regaddr = NVIC_SYSTICK_CTRL;
*bit = NVIC_SYSTICK_CTRL_ENABLE;
}
else
{
return ERROR; /* Invalid or unsupported exception */
}
}
return OK;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: up_irqinitialize
****************************************************************************/
void up_irqinitialize(void)
{
uintptr_t regaddr;
#if defined(CONFIG_DEBUG_SYMBOLS) && !defined(CONFIG_ARMV7M_USEBASEPRI)
uint32_t regval;
#endif
int nintlines;
int i;
/* The NVIC ICTR register (bits 0-4) holds the number of of interrupt
* lines that the NVIC supports, defined in groups of 32. That is,
* the total number of interrupt lines is up to (32*(INTLINESNUM+1)).
*
* 0 -> 32 interrupt lines, 1 enable register, 8 priority registers
* 1 -> 64 " " " ", 2 enable registers, 16 priority registers
* 2 -> 96 " " " ", 3 enable registers, 24 priority registers
* ...
*/
nintlines = (getreg32(NVIC_ICTR) & NVIC_ICTR_INTLINESNUM_MASK) + 1;
/* Disable all interrupts. There are nintlines interrupt enable
* registers.
*/
for (i = nintlines, regaddr = NVIC_IRQ0_31_ENABLE;
i > 0;
i--, regaddr += 4)
{
putreg32(0, regaddr);
}
/* Make sure that we are using the correct vector table. The default
* vector address is 0x0000:0000 but if we are executing code that is
* positioned in SRAM or in external FLASH, then we may need to reset
* the interrupt vector so that it refers to the table in SRAM or in
* external FLASH.
*/
putreg32((uint32_t)_vectors, NVIC_VECTAB);
#ifdef CONFIG_ARCH_RAMVECTORS
/* If CONFIG_ARCH_RAMVECTORS is defined, then we are using a RAM-based
* vector table that requires special initialization.
*/
up_ramvec_initialize();
#endif
/* Set all interrupts (and exceptions) to the default priority */
putreg32(DEFPRIORITY32, NVIC_SYSH4_7_PRIORITY);
putreg32(DEFPRIORITY32, NVIC_SYSH8_11_PRIORITY);
putreg32(DEFPRIORITY32, NVIC_SYSH12_15_PRIORITY);
/* Now set all of the interrupt lines to the default priority. There are
* nintlines * 8 priority registers.
*/
for (i = (nintlines << 3), regaddr = NVIC_IRQ0_3_PRIORITY;
i > 0;
i--, regaddr += 4)
{
putreg32(DEFPRIORITY32, regaddr);
}
/* currents_regs is non-NULL only while processing an interrupt */
CURRENT_REGS = NULL;
/* Attach the SVCall and Hard Fault exception handlers. The SVCall
* exception is used for performing context switches; The Hard Fault
* must also be caught because a SVCall may show up as a Hard Fault
* under certain conditions.
*/
irq_attach(SAM_IRQ_SVCALL, up_svcall, NULL);
irq_attach(SAM_IRQ_HARDFAULT, up_hardfault, NULL);
/* Set the priority of the SVCall interrupt */
#ifdef CONFIG_ARCH_IRQPRIO
/* up_prioritize_irq(SAM_IRQ_PENDSV, NVIC_SYSH_PRIORITY_MIN); */
#endif
#ifdef CONFIG_ARMV7M_USEBASEPRI
sam_prioritize_syscall(NVIC_SYSH_SVCALL_PRIORITY);
#endif
/* If the MPU is enabled, then attach and enable the Memory Management
* Fault handler.
*/
#ifdef CONFIG_ARM_MPU
irq_attach(SAM_IRQ_MEMFAULT, up_memfault, NULL);
up_enable_irq(SAM_IRQ_MEMFAULT);
#endif
/* Attach all other processor exceptions (except reset and sys tick) */
#ifdef CONFIG_DEBUG_FEATURES
irq_attach(SAM_IRQ_NMI, sam_nmi, NULL);
#ifndef CONFIG_ARM_MPU
irq_attach(SAM_IRQ_MEMFAULT, up_memfault, NULL);
#endif
irq_attach(SAM_IRQ_BUSFAULT, sam_busfault, NULL);
irq_attach(SAM_IRQ_USAGEFAULT, sam_usagefault, NULL);
irq_attach(SAM_IRQ_PENDSV, sam_pendsv, NULL);
irq_attach(SAM_IRQ_DBGMONITOR, sam_dbgmonitor, NULL);
irq_attach(SAM_IRQ_RESERVED, sam_reserved, NULL);
#endif
sam_dumpnvic("initial", SAM_IRQ_NIRQS);
/* If a debugger is connected, try to prevent it from catching hardfaults.
* If CONFIG_ARMV7M_USEBASEPRI, no hardfaults are expected in normal
* operation.
*/
#if defined(CONFIG_DEBUG_SYMBOLS) && !defined(CONFIG_ARMV7M_USEBASEPRI)
regval = getreg32(NVIC_DEMCR);
regval &= ~NVIC_DEMCR_VCHARDERR;
putreg32(regval, NVIC_DEMCR);
#endif
#ifdef CONFIG_SAMD5E5_EIC
/* Initialize the external interrupt controller. */
sam_eic_initialize();
#endif
#ifndef CONFIG_SUPPRESS_INTERRUPTS
/* And finally, enable global interrupts */
up_irq_enable();
#endif
}
/****************************************************************************
* Name: up_disable_irq
*
* Description:
* Disable the IRQ specified by 'irq'
*
****************************************************************************/
void up_disable_irq(int irq)
{
uintptr_t regaddr;
uint32_t regval;
uint32_t bit;
if (sam_irqinfo(irq, &regaddr, &bit, NVIC_CLRENA_OFFSET) == 0)
{
/* Modify the appropriate bit in the register to disable the interrupt.
* For normal interrupts, we need to set the bit in the associated
* Interrupt Clear Enable register. For other exceptions, we need to
* clear the bit in the System Handler Control and State Register.
*/
if (irq >= SAM_IRQ_EXTINT)
{
putreg32(bit, regaddr);
}
else
{
regval = getreg32(regaddr);
regval &= ~bit;
putreg32(regval, regaddr);
}
}
#if 0 /* Might be useful in early bring-up */
sam_dumpnvic("disable", irq);
#endif
}
/****************************************************************************
* Name: up_enable_irq
*
* Description:
* Enable the IRQ specified by 'irq'
*
****************************************************************************/
void up_enable_irq(int irq)
{
uintptr_t regaddr;
uint32_t regval;
uint32_t bit;
if (sam_irqinfo(irq, &regaddr, &bit, NVIC_ENA_OFFSET) == 0)
{
/* Modify the appropriate bit in the register to enable the interrupt.
* For normal interrupts, we need to set the bit in the associated
* Interrupt Set Enable register. For other exceptions, we need to
* set the bit in the System Handler Control and State Register.
*/
if (irq >= SAM_IRQ_EXTINT)
{
putreg32(bit, regaddr);
}
else
{
regval = getreg32(regaddr);
regval |= bit;
putreg32(regval, regaddr);
}
}
#if 0 /* Might be useful in early bring-up */
sam_dumpnvic("enable", irq);
#endif
}
/****************************************************************************
* Name: up_ack_irq
*
* Description:
* Acknowledge the IRQ
*
****************************************************************************/
void up_ack_irq(int irq)
{
}
/****************************************************************************
* Name: up_prioritize_irq
*
* Description:
* Set the priority of an IRQ.
*
* Since this API is not supported on all architectures, it should be
* avoided in common implementations where possible.
*
****************************************************************************/
#ifdef CONFIG_ARCH_IRQPRIO
int up_prioritize_irq(int irq, int priority)
{
uint32_t regaddr;
uint32_t regval;
int shift;
DEBUGASSERT(irq >= SAM_IRQ_MEMFAULT && irq < SAM_IRQ_NIRQS &&
(unsigned)priority <= NVIC_SYSH_PRIORITY_MIN);
if (irq < SAM_IRQ_EXTINT)
{
/* NVIC_SYSH_PRIORITY() maps {0..15} to one of three priority
* registers (0-3 are invalid)
*/
regaddr = NVIC_SYSH_PRIORITY(irq);
irq -= 4;
}
else
{
/* NVIC_IRQ_PRIORITY() maps {0..} to one of many priority registers */
irq -= SAM_IRQ_EXTINT;
regaddr = NVIC_IRQ_PRIORITY(irq);
}
regval = getreg32(regaddr);
shift = ((irq & 3) << 3);
regval &= ~(0xff << shift);
regval |= (priority << shift);
putreg32(regval, regaddr);
sam_dumpnvic("prioritize", irq);
return OK;
}
#endif

View File

@ -0,0 +1,467 @@
/****************************************************************************
* arch/arm/src/samd5e5/sam_lowputc.c
*
* Copyright (C) 2018 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <assert.h>
#include <errno.h>
#include <nuttx/irq.h>
#include "up_arch.h"
#include "chip/sam_pm.h"
#include "sam_config.h"
#include "sam_gclk.h"
#include "sam_sercom.h"
#include "sam_usart.h"
#include "sam_lowputc.h"
#include <arch/board/board.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef OK
# define OK 0
#endif
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: sam_wait_synchronization
*
* Description:
* Wait until the SERCOM USART reports that it is synchronized.
*
****************************************************************************/
#ifdef SAMD5E5_HAVE_USART
static void
sam_wait_synchronization(const struct sam_usart_config_s * const config)
{
while (usart_syncbusy(config));
}
#endif
/****************************************************************************
* Name: sam_usart_configure
*
* Description:
* Configure the SERCOM USART operating mode (as a normal UART).
*
****************************************************************************/
#ifdef SAMD5E5_HAVE_USART
static inline int
sam_usart_configure(const struct sam_usart_config_s * const config)
{
uint32_t ctrla;
uint32_t ctrlb;
uint16_t baud;
uint64_t tmp;
/* Calculate BAUD divider from the source clock frequency and desired.
* baud. For asynchronous mode, the formula for the baud generation is
*
* Fbaud = (Frefclk / 16) * (1 - (BAUD / 65,536))
*
* Or,
*
* BAUD = 65,536 * (1 - 16 * (Fbaud / Fref))
* = 65,536 - 16 * 65,536 * Fbaud / Fref
*
* Example: Fref = 48MHz and Fbaud = 9600
*
* BAUD = 65,326
* Fbaud = 9600
*
* Example: Fref = 48MHz and Fbaud = 115,200
*
* BAUD = 63,019
* Fbaud = 115,219
*/
tmp = (uint64_t)config->baud << 20;
tmp = (tmp + (config->frequency >> 1)) / config->frequency;
/* Verify that the calculated result is within range */
if (tmp < 1 || tmp > UINT16_MAX)
{
return -ERANGE;
}
baud = 65536 - (uint16_t)tmp;
/* Disable all USART interrupts */
putreg8(USART_INT_ALL, config->base + SAM_USART_INTENCLR_OFFSET);
/* Wait until synchronization is complete */
sam_wait_synchronization(config);
/* Set baud divisor */
putreg16((uint16_t)baud, config->base + SAM_USART_BAUD_OFFSET);
/* Configure the USART CTRLA and CTRLB registers */
ctrla = (USART_CTRLA_MODE_INTUSART | (uint32_t)config->muxconfig |
USART_CTRLA_ASYNCH | USART_CTRLA_CPOL_NORMAL |
USART_CTRLA_LSBFIRST);
ctrlb = (USART_CTRLB_TXEN | USART_CTRLB_RXEN);
/* Set the number of stop bits */
if (config->stopbits2)
{
ctrlb |= USART_CTRLB_SBMODE;
}
/* Set the USART word size */
switch (config->bits)
{
case 5:
ctrlb |= USART_CTRLB_CHSIZE_5BITS;
break;
case 6:
ctrlb |= USART_CTRLB_CHSIZE_6BITS;
break;
case 7:
ctrlb |= USART_CTRLB_CHSIZE_7BITS;
break;
default:
case 8:
break;
case 9:
ctrlb |= USART_CTRLB_CHSIZE_9BITS;
break;
}
/* Set parity mode */
switch (config->parity)
{
default:
case 0: /* None */
break;
case 1: /* Odd */
ctrlb |= USART_CTRLB_PODD;
/* Fall through */
case 2: /* Even */
ctrla |= USART_CTRLA_FORM_PARITY;
break;
}
#if 0 /* Not supported */
/* Set run mode during device sleep */
if (config->runinstandby)
{
/* Enable in sleep mode */
ctrla |= USART_CTRLA_RUNSTDBY;
}
#endif
/* Wait until synchronization is complete */
sam_wait_synchronization(config);
/* Write configuration to CTRLB */
putreg32(ctrlb, config->base + SAM_USART_CTRLB_OFFSET);
/* Wait until synchronization is complete */
sam_wait_synchronization(config);
/* Write configuration to CTRLA */
putreg32(ctrla, config->base + SAM_USART_CTRLA_OFFSET);
return OK;
}
#endif
/****************************************************************************
* Name: sam_pad_configure
*
* Description:
* Configure the SERCOM USART pads.
*
****************************************************************************/
#ifdef SAMD5E5_HAVE_USART
static inline void
sam_pad_configure(const struct sam_usart_config_s * const config)
{
/* Configure SERCOM pads */
if (config->pad0 != 0)
{
sam_configport(config->pad0);
}
if (config->pad1 != 0)
{
sam_configport(config->pad1);
}
if (config->pad2 != 0)
{
sam_configport(config->pad2);
}
if (config->pad3 != 0)
{
sam_configport(config->pad3);
}
}
#endif
/****************************************************************************
* Name: sam_usart_internal
*
* Description:
* Set the configuration of a SERCOM for provided USART configuration.
* This configures the SERCOM as a USART, but does not configure USART
* interrupts or enable the USART.
*
****************************************************************************/
#ifdef SAMD5E5_HAVE_USART
int sam_usart_internal(const struct sam_usart_config_s * const config)
{
int channel;
int ret;
/* Enable clocking to the SERCOM module */
sercom_enable(config->sercom);
/* Configure the GCLKs for the SERCOM module */
sercom_coreclk_configure(config->sercom, config->gclkgen, false);
if (config->sercom == 5)
{
channel = GCLK_CHAN_SERCOM5_CORE;
}
else
{
channel = config->sercom + GCLK_CHAN_SERCOM0_CORE;
}
sam_gclk_chan_enable(channel, config->gclkgen);
sercom_slowclk_configure(config->sercom, config->slowgen);
/* Set USART configuration according to the board configuration */
ret = sam_usart_configure(config);
if (ret == OK)
{
/* Configure USART pins */
sam_pad_configure(config);
}
return ret;
}
#endif
/****************************************************************************
* Name: sam_usart_enable
*
* Description:
* Enable the SERCOM USART (without enabling interrupts).
*
****************************************************************************/
#ifdef SAMD5E5_HAVE_USART
static inline void
sam_usart_enable(const struct sam_usart_config_s * const config)
{
uintptr_t regaddr;
uint32_t regval;
/* Wait until synchronization is complete */
sam_wait_synchronization(config);
/* Enable USART module */
regaddr = config->base + SAM_USART_CTRLA_OFFSET;
regval = getreg32(regaddr);
regval |= USART_CTRLA_ENABLE;
putreg32(regval, regaddr);
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sam_lowsetup
*
* Description:
* Called at the very beginning of _start. Performs low level
* initialization.
*
****************************************************************************/
void sam_lowsetup(void)
{
#ifdef HAVE_SERIAL_CONSOLE
/* Configure and enable the console USART */
VERIFY(sam_usart_internal(&g_consoleconfig));
sam_usart_enable(&g_consoleconfig);
#endif
}
/****************************************************************************
* Name: sam_usart_initialize
*
* Description:
* Set the configuration of a SERCOM for provided USART configuration.
* This configures the SERCOM as a USART, but does not configure USART
* interrupts or enable the USART.
*
****************************************************************************/
#ifdef SAMD5E5_HAVE_USART
int sam_usart_initialize(const struct sam_usart_config_s * const config)
{
irqstate_t flags;
int ret;
/* Reset the SERCOM so that we know that it is in its initial state */
flags = enter_critical_section();
sam_usart_reset(config);
/* Just invoke the internal implementation, but with interrupts disabled
* so that the operation is atomic.
*/
ret = sam_usart_internal(config);
leave_critical_section(flags);
return ret;
}
#endif
/****************************************************************************
* Name: sam_usart_reset
*
* Description:
* Reset the USART SERCOM. This restores all SERCOM register to the
* initial state and disables the SERCOM.
*
****************************************************************************/
#ifdef SAMD5E5_HAVE_USART
void sam_usart_reset(const struct sam_usart_config_s * const config)
{
uintptr_t regaddr = config->base + SAM_USART_CTRLA_OFFSET;
uint32_t regval;
/* Reset the SERCOM by setting the SWRST bit in the CTRLA register. When
* the reset completes, the SERCOM will registers will be restored to there
* initial state and the SERCOM will be disabled.
*/
regval = getreg32(regaddr);
regval |= USART_CTRLA_SWRST;
putreg32(regval, regaddr);
/* Wait for the reset to complete */
while ((getreg32(regaddr) & USART_CTRLA_SWRST) != 0);
}
#endif
/****************************************************************************
* Name: sam_lowputc
*
* Description:
* Output one character to the USART using a simple polling method.
*
****************************************************************************/
#ifdef HAVE_SERIAL_CONSOLE
void sam_lowputc(uint32_t ch)
{
uintptr_t base = g_consoleconfig.base;
uintptr_t intflag = base + SAM_USART_INTFLAG_OFFSET;
/* Wait for the USART to be ready for new TX data */
while ((getreg8(intflag) & USART_INT_DRE) == 0);
/* Wait until synchronization is complete */
sam_wait_synchronization(&g_consoleconfig);
/* Write data to USART module */
putreg16((uint16_t)ch, base + SAM_USART_DATA_OFFSET);
/* Wait until data is sent */
while ((getreg8(intflag) & USART_INT_TXC) == 0);
}
#endif

View File

@ -0,0 +1,130 @@
/****************************************************************************
* arch/arm/src/samd5e5/sam_lowputc.h
*
* Copyright (C) 2018 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_SAMD5E5_SAM_LOWPUTC_H
#define __ARCH_ARM_SRC_SAMD5E5_SAM_LOWPUTC_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "sam_config.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: sam_lowsetup
*
* Description:
* Called at the very beginning of _start. Performs low level
* initialization.
*
****************************************************************************/
void sam_lowsetup(void);
/****************************************************************************
* Name: sam_usart_initialize
*
* Description:
* Set the configuration of a SERCOM for provided USART configuration.
* This configures the SERCOM as a USART, but does not configure USART
* interrupts or enable the USART.
*
****************************************************************************/
#ifdef SAMD5E5_HAVE_USART
struct sam_usart_config_s;
int sam_usart_initialize(const struct sam_usart_config_s * const config);
#endif
/****************************************************************************
* Name: sam_usart_reset
*
* Description:
* Reset the USART SERCOM. This restores all SERCOM register to the
* initial state and disables the SERCOM.
*
****************************************************************************/
#ifdef SAMD5E5_HAVE_USART
struct sam_usart_config_s;
void sam_usart_reset(const struct sam_usart_config_s * const config);
#endif
/****************************************************************************
* Name: sam_lowputc
*
* Description:
* Output one character to the USART using a simple polling method.
*
****************************************************************************/
#ifdef HAVE_SERIAL_CONSOLE
void sam_lowputc(uint32_t ch);
#endif
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_SRC_SAMD5E5_SAM_LOWPUTC_H */

View File

@ -0,0 +1,124 @@
/****************************************************************************
* arch/arm/src/samd5e5/sam_mpuinit.c
*
* Copyright (C) 2018 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <assert.h>
#include <nuttx/userspace.h>
#include "mpu.h"
#include "sam_mpuinit.h"
#if defined(CONFIG_BUILD_PROTECTED) && defined(CONFIG_ARM_MPU)
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef MAX
# define MAX(a,b) a > b ? a : b
#endif
#ifndef MIN
# define MIN(a,b) a < b ? a : b
#endif
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sam_mpuinitialize
*
* Description:
* Configure the MPU to permit user-space access to only restricted SAM3/4
* resources.
*
****************************************************************************/
void sam_mpuinitialize(void)
{
uintptr_t datastart = MIN(USERSPACE->us_datastart, USERSPACE->us_bssstart);
uintptr_t dataend = MAX(USERSPACE->us_dataend, USERSPACE->us_bssend);
DEBUGASSERT(USERSPACE->us_textend >= USERSPACE->us_textstart &&
dataend >= datastart);
/* Show MPU information */
mpu_showtype();
/* Configure user flash and SRAM space */
mpu_user_flash(USERSPACE->us_textstart,
USERSPACE->us_textend - USERSPACE->us_textstart);
mpu_user_intsram(datastart, dataend - datastart);
/* Then enable the MPU */
mpu_control(true, false, true);
}
/****************************************************************************
* Name: sam_mpu_uheap
*
* Description:
* Map the user-heap region.
*
* This logic may need an extension to handle external SDRAM).
*
****************************************************************************/
void sam_mpu_uheap(uintptr_t start, size_t size)
{
mpu_user_intsram(start, size);
}
#endif /* CONFIG_BUILD_PROTECTED && CONFIG_ARM_MPU */

View File

@ -0,0 +1,114 @@
/************************************************************************************
* arch/arm/src/samd5e5/sam_mpuinit.h
*
* Copyright (C) 2018 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_SAMD5E5_SAM_MPUINIT_H
#define __ARCH_ARM_SRC_SAMD5E5_SAM_MPUINIT_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <sys/types.h>
#include <stdint.h>
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/************************************************************************************
* Public Types
************************************************************************************/
/************************************************************************************
* Inline Functions
************************************************************************************/
#ifndef __ASSEMBLY__
/************************************************************************************
* Public Data
************************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/************************************************************************************
* Public Function Prototypes
************************************************************************************/
/****************************************************************************
* Name: sam_mpuinitialize
*
* Description:
* Configure the MPU to permit user-space access to only unrestricted SAM3/4
* resources.
*
****************************************************************************/
#ifdef CONFIG_BUILD_PROTECTED
void sam_mpuinitialize(void);
#else
# define sam_mpuinitialize()
#endif
/****************************************************************************
* Name: sam_mpu_uheap
*
* Description:
* Map the user heap region.
*
****************************************************************************/
#ifdef CONFIG_BUILD_PROTECTED
void sam_mpu_uheap(uintptr_t start, size_t size);
#else
# define sam_mpu_uheap(start,size)
#endif
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_SRC_SAMD5E5_SAM_MPUINIT_H */

View File

@ -0,0 +1,347 @@
/****************************************************************************
* arch/arm/src/samd5e5/sam_periphclks.h
*
* Copyright (C) 2018 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_SAMD5E5_SAM_PERIPHCLKS_H
#define __ARCH_ARM_SRC_SAMD5E5_SAM_PERIPHCLKS_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "chip/sam_mclk.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define sam_ahb_enableperiph(s) modifyreg32(SAM_MCLK_AHBMASK,0,s)
#define sam_ahb_hpb0_enableperiph() sam_ahb_enableperiph(MCLK_AHBMASK_HPB0)
#define sam_ahb_hpb1_enableperiph() sam_ahb_enableperiph(MCLK_AHBMASK_HPB1)
#define sam_ahb_hpb2_enableperiph() sam_ahb_enableperiph(MCLK_AHBMASK_HPB2)
#define sam_ahb_hpb3_enableperiph() sam_ahb_enableperiph(MCLK_AHBMASK_HPB3)
#define sam_ahb_dsu_enableperiph() sam_ahb_enableperiph(MCLK_AHBMASK_DSU)
#define sam_ahb_nvmctrl_enableperiph() sam_ahb_enableperiph(MCLK_AHBMASK_NVMCTRL)
#define sam_ahb_cmcc_enableperiph() sam_ahb_enableperiph(MCLK_AHBMASK_CMCC)
#define sam_ahb_dmac_enableperiph() sam_ahb_enableperiph(MCLK_AHBMASK_DMAC)
#define sam_ahb_usb_enableperiph() sam_ahb_enableperiph(MCLK_AHBMASK_USB)
#define sam_ahb_pac_enableperiph() sam_ahb_enableperiph(MCLK_AHBMASK_PAC)
#define sam_ahb_qspi_enableperiph() sam_ahb_enableperiph(MCLK_AHBMASK_QSPI)
#define sam_ahb_gmac_enableperiph() sam_ahb_enableperiph(MCLK_AHBMASK_GMAC)
#define sam_ahb_sdhc0_enableperiph() sam_ahb_enableperiph(MCLK_AHBMASK_SDHC0)
#define sam_ahb_sdhc1_enableperiph() sam_ahb_enableperiph(MCLK_AHBMASK_SDHC1)
#define sam_ahb_can0_enableperiph() sam_ahb_enableperiph(MCLK_AHBMASK_CAN0)
#define sam_ahb_can1_enableperiph() sam_ahb_enableperiph(MCLK_AHBMASK_CAN1)
#define sam_ahb_icm_enableperiph() sam_ahb_enableperiph(MCLK_AHBMASK_ICM)
#define sam_ahb_pukcc_enableperiph() sam_ahb_enableperiph(MCLK_AHBMASK_PUKCC)
#define sam_ahb_qspi2x_enableperiph() sam_ahb_enableperiph(MCLK_AHBMASK_QSPI2X)
#define sam_ahb_nvmctrl_smeeprom_enableperiph() sam_ahb_enableperiph(MCLK_AHBMASK_NVMCTRL_SMEEPROM)
#define sam_ahb_nvmctrl_cache_enableperiph() sam_ahb_enableperiph(MCLK_AHBMASK_NVMCTRL_CACHE)
#define sam_apba_enableperiph(s) modifyreg32(SAM_MCLK_APBAMASK,0,s)
#define sam_apb_pac_enableperiph() sam_apba_enableperiph(MCLK_APBAMASK_PAC)
#define sam_apb_pm_enableperiph() sam_apba_enableperiph(MCLK_APBAMASK_PM)
#define sam_apb_mclk_enableperiph() sam_apba_enableperiph(MCLK_APBAMASK_MCLK)
#define sam_apb_rstc_enableperiph() sam_apba_enableperiph(MCLK_APBAMASK_RSTC)
#define sam_apb_oscctrl_enableperiph() sam_apba_enableperiph(MCLK_APBAMASK_OSCCTRL)
#define sam_apb_osc32kctrl_enableperiph() sam_apba_enableperiph(MCLK_APBAMASK_OSC32KCTRL)
#define sam_apb_supc_enableperiph() sam_apba_enableperiph(MCLK_APBAMASK_SUPC)
#define sam_apb_gclk_enableperiph() sam_apba_enableperiph(MCLK_APBAMASK_GCLK)
#define sam_apb_wdt_enableperiph() sam_apba_enableperiph(MCLK_APBAMASK_WDT)
#define sam_apb_rtc_enableperiph() sam_apba_enableperiph(MCLK_APBAMASK_RTC)
#define sam_apb_eic_enableperiph() sam_apba_enableperiph(MCLK_APBAMASK_EIC)
#define sam_apb_freqm_enableperiph() sam_apba_enableperiph(MCLK_APBAMASK_FREQM)
#define sam_apb_sercom0_enableperiph() sam_apba_enableperiph(MCLK_APBAMASK_SERCOM0)
#define sam_apb_sercom1_enableperiph() sam_apba_enableperiph(MCLK_APBAMASK_SERCOM1)
#define sam_apb_tc0_enableperiph() sam_apba_enableperiph(MCLK_APBAMASK_TC0)
#define sam_apb_tc1_enableperiph() sam_apba_enableperiph(MCLK_APBAMASK_TC1)
#define sam_apbb_enableperiph(s) modifyreg32(SAM_MCLK_APBBMASK,0,s)
#define sam_apb_usb_enableperiph() sam_apbb_enableperiph(MCLK_APBBMASK_USB)
#define sam_apb_dsu_enableperiph() sam_apbb_enableperiph(MCLK_APBBMASK_DSU)
#define sam_apb_nvmctrl_enableperiph() sam_apbb_enableperiph(MCLK_APBBMASK_NVMCTRL)
#define sam_apb_port_enableperiph() sam_apbb_enableperiph(MCLK_APBBMASK_PORT)
#define sam_apb_evsys_enableperiph() sam_apbb_enableperiph(MCLK_APBBMASK_EVSYS)
#define sam_apb_sercom2_enableperiph() sam_apbb_enableperiph(MCLK_APBBMASK_SERCOM2)
#define sam_apb_sercom3_enableperiph() sam_apbb_enableperiph(MCLK_APBBMASK_SERCOM3)
#define sam_apb_tcc0_enableperiph() sam_apbb_enableperiph(MCLK_APBBMASK_TCC0)
#define sam_apb_tcc1_enableperiph() sam_apbb_enableperiph(MCLK_APBBMASK_TCC1)
#define sam_apb_tc2_enableperiph() sam_apbb_enableperiph(MCLK_APBBMASK_TC2)
#define sam_apb_tc3_enableperiph() sam_apbb_enableperiph(MCLK_APBBMASK_TC3)
#define sam_apb_ramecc_enableperiph() sam_apbb_enableperiph(MCLK_APBBMASK_RAMECC)
#define sam_apbc_enableperiph(s) modifyreg32(SAM_MCLK_APBCMASK,0,s)
#define sam_apb_gmac_enableperiph(n) sam_apbc_enableperiph(MCLK_APBCMASK_GMAC)
#define sam_apb_tcc2_enableperiph(n) sam_apbc_enableperiph(MCLK_APBCMASK_TCC2)
#define sam_apb_tcc3_enableperiph(n) sam_apbc_enableperiph(MCLK_APBCMASK_TCC3)
#define sam_apb_tc4_enableperiph(n) sam_apbc_enableperiph(MCLK_APBCMASK_TC4)
#define sam_apb_tc5_enableperiph(n) sam_apbc_enableperiph(MCLK_APBCMASK_TC5)
#define sam_apb_pdec_enableperiph(n) sam_apbc_enableperiph(MCLK_APBCMASK_PDEC)
#define sam_apb_ac_enableperiph(n) sam_apbc_enableperiph(MCLK_APBCMASK_AC)
#define sam_apb_aes_enableperiph(n) sam_apbc_enableperiph(MCLK_APBCMASK_AES)
#define sam_apb_trng_enableperiph(n) sam_apbc_enableperiph(MCLK_APBCMASK_TRNG)
#define sam_apb_icm_enableperiph(n) sam_apbc_enableperiph(MCLK_APBCMASK_ICM)
#define sam_apb_qspi_enableperiph(n) sam_apbc_enableperiph(MCLK_APBCMASK_QSPI)
#define sam_apb_ccl_enableperiph(n) sam_apbc_enableperiph(MCLK_APBCMASK_CCL)
#define sam_apbd_enableperiph(s) modifyreg32(SAM_MCLK_APBDMASK,0,s)
#define sam_apb_sercom4_enableperiph() sam_apbd_enableperiph(MCLK_APBDMASK_SERCOM4)
#define sam_apb_sercom5_enableperiph() sam_apbd_enableperiph(MCLK_APBDMASK_SERCOM5)
#define sam_apb_sercom6_enableperiph() sam_apbd_enableperiph(MCLK_APBDMASK_SERCOM6)
#define sam_apb_sercom7_enableperiph() sam_apbd_enableperiph(MCLK_APBDMASK_SERCOM7)
#define sam_apb_tcc4_enableperiph() sam_apbd_enableperiph(MCLK_APBDMASK_TCC4)
#define sam_apb_tc6_enableperiph() sam_apbd_enableperiph(MCLK_APBDMASK_TC6)
#define sam_apb_tc7_enableperiph() sam_apbd_enableperiph(MCLK_APBDMASK_TC7)
#define sam_apb_adc0_enableperiph() sam_apbd_enableperiph(MCLK_APBDMASK_ADC0)
#define sam_apb_adc1_enableperiph() sam_apbd_enableperiph(MCLK_APBDMASK_ADC1)
#define sam_apb_dac_enableperiph() sam_apbd_enableperiph(MCLK_APBDMASK_DAC)
#define sam_apb_i2c_enableperiph() sam_apbd_enableperiph(MCLK_APBDMASK_I2C)
#define sam_apb_pcc_enableperiph() sam_apbd_enableperiph(MCLK_APBDMASK_PCC)
#define sam_ahb_disableperiph(s) modifyreg32(SAM_MCLK_AHBMASK,s,0)
#define sam_ahb_hpb0_disableperiph() sam_ahb_disableperiph(MCLK_AHBMASK_HPB0)
#define sam_ahb_hpb1_disableperiph() sam_ahb_disableperiph(MCLK_AHBMASK_HPB1)
#define sam_ahb_hpb2_disableperiph() sam_ahb_disableperiph(MCLK_AHBMASK_HPB2)
#define sam_ahb_hpb3_disableperiph() sam_ahb_disableperiph(MCLK_AHBMASK_HPB3)
#define sam_ahb_dsu_disableperiph() sam_ahb_disableperiph(MCLK_AHBMASK_DSU)
#define sam_ahb_nvmctrl_disableperiph() sam_ahb_disableperiph(MCLK_AHBMASK_NVMCTRL)
#define sam_ahb_cmcc_disableperiph() sam_ahb_disableperiph(MCLK_AHBMASK_CMCC)
#define sam_ahb_dmac_disableperiph() sam_ahb_disableperiph(MCLK_AHBMASK_DMAC)
#define sam_ahb_usb_disableperiph() sam_ahb_disableperiph(MCLK_AHBMASK_USB)
#define sam_ahb_pac_disableperiph() sam_ahb_disableperiph(MCLK_AHBMASK_PAC)
#define sam_ahb_qspi_disableperiph() sam_ahb_disableperiph(MCLK_AHBMASK_QSPI)
#define sam_ahb_gmac_disableperiph() sam_ahb_disableperiph(MCLK_AHBMASK_GMAC)
#define sam_ahb_sdhc0_disableperiph() sam_ahb_disableperiph(MCLK_AHBMASK_SDHC0)
#define sam_ahb_sdhc1_disableperiph() sam_ahb_disableperiph(MCLK_AHBMASK_SDHC1)
#define sam_ahb_can0_disableperiph() sam_ahb_disableperiph(MCLK_AHBMASK_CAN0)
#define sam_ahb_can1_disableperiph() sam_ahb_disableperiph(MCLK_AHBMASK_CAN1)
#define sam_ahb_icm_disableperiph() sam_ahb_disableperiph(MCLK_AHBMASK_ICM)
#define sam_ahb_pukcc_disableperiph() sam_ahb_disableperiph(MCLK_AHBMASK_PUKCC)
#define sam_ahb_qspi2x_disableperiph() sam_ahb_disableperiph(MCLK_AHBMASK_QSPI2X)
#define sam_ahb_nvmctrl_smeeprom_disableperiph() sam_ahb_disableperiph(MCLK_AHBMASK_NVMCTRL_SMEEPROM)
#define sam_ahb_nvmctrl_cache_disableperiph() sam_ahb_disableperiph(MCLK_AHBMASK_NVMCTRL_CACHE)
#define sam_apba_disableperiph(s) modifyreg32(SAM_MCLK_APBAMASK,s,0)
#define sam_apb_pac_disableperiph() sam_apba_disableperiph(MCLK_APBAMASK_PAC)
#define sam_apb_pm_disableperiph() sam_apba_disableperiph(MCLK_APBAMASK_PM)
#define sam_apb_mclk_disableperiph() sam_apba_disableperiph(MCLK_APBAMASK_MCLK)
#define sam_apb_rstc_disableperiph() sam_apba_disableperiph(MCLK_APBAMASK_RSTC)
#define sam_apb_oscctrl_disableperiph() sam_apba_disableperiph(MCLK_APBAMASK_OSCCTRL)
#define sam_apb_osc32kctrl_disableperiph() sam_apba_disableperiph(MCLK_APBAMASK_OSC32KCTRL)
#define sam_apb_supc_disableperiph() sam_apba_disableperiph(MCLK_APBAMASK_SUPC)
#define sam_apb_gclk_disableperiph() sam_apba_disableperiph(MCLK_APBAMASK_GCLK)
#define sam_apb_wdt_disableperiph() sam_apba_disableperiph(MCLK_APBAMASK_WDT)
#define sam_apb_rtc_disableperiph() sam_apba_disableperiph(MCLK_APBAMASK_RTC)
#define sam_apb_eic_disableperiph() sam_apba_disableperiph(MCLK_APBAMASK_EIC)
#define sam_apb_freqm_disableperiph() sam_apba_disableperiph(MCLK_APBAMASK_FREQM)
#define sam_apb_sercom0_disableperiph() sam_apba_disableperiph(MCLK_APBAMASK_SERCOM0)
#define sam_apb_sercom1_disableperiph() sam_apba_disableperiph(MCLK_APBAMASK_SERCOM1)
#define sam_apb_tc0_disableperiph() sam_apba_disableperiph(MCLK_APBAMASK_TC0)
#define sam_apb_tc1_disableperiph() sam_apba_disableperiph(MCLK_APBAMASK_TC1)
#define sam_apbb_disableperiph(s) modifyreg32(SAM_MCLK_APBBMASK,s,0)
#define sam_apb_usb_disableperiph() sam_apbb_disableperiph(MCLK_APBBMASK_USB)
#define sam_apb_dsu_disableperiph() sam_apbb_disableperiph(MCLK_APBBMASK_DSU)
#define sam_apb_nvmctrl_disableperiph() sam_apbb_disableperiph(MCLK_APBBMASK_NVMCTRL)
#define sam_apb_port_disableperiph() sam_apbb_disableperiph(MCLK_APBBMASK_PORT)
#define sam_apb_evsys_disableperiph() sam_apbb_disableperiph(MCLK_APBBMASK_EVSYS)
#define sam_apb_sercom2_disableperiph() sam_apbb_disableperiph(MCLK_APBBMASK_SERCOM2)
#define sam_apb_sercom3_disableperiph() sam_apbb_disableperiph(MCLK_APBBMASK_SERCOM3)
#define sam_apb_tcc0_disableperiph() sam_apbb_disableperiph(MCLK_APBBMASK_TCC0)
#define sam_apb_tcc1_disableperiph() sam_apbb_disableperiph(MCLK_APBBMASK_TCC1)
#define sam_apb_tc2_disableperiph() sam_apbb_disableperiph(MCLK_APBBMASK_TC2)
#define sam_apb_tc3_disableperiph() sam_apbb_disableperiph(MCLK_APBBMASK_TC3)
#define sam_apb_ramecc_disableperiph() sam_apbb_disableperiph(MCLK_APBBMASK_RAMECC)
#define sam_apbc_disableperiph(s) modifyreg32(SAM_MCLK_APBCMASK,s,0)
#define sam_apb_gmac_disableperiph(n) sam_apbc_disableperiph(MCLK_APBCMASK_GMAC)
#define sam_apb_tcc2_disableperiph(n) sam_apbc_disableperiph(MCLK_APBCMASK_TCC2)
#define sam_apb_tcc3_disableperiph(n) sam_apbc_disableperiph(MCLK_APBCMASK_TCC3)
#define sam_apb_tc4_disableperiph(n) sam_apbc_disableperiph(MCLK_APBCMASK_TC4)
#define sam_apb_tc5_disableperiph(n) sam_apbc_disableperiph(MCLK_APBCMASK_TC5)
#define sam_apb_pdec_disableperiph(n) sam_apbc_disableperiph(MCLK_APBCMASK_PDEC)
#define sam_apb_ac_disableperiph(n) sam_apbc_disableperiph(MCLK_APBCMASK_AC)
#define sam_apb_aes_disableperiph(n) sam_apbc_disableperiph(MCLK_APBCMASK_AES)
#define sam_apb_trng_disableperiph(n) sam_apbc_disableperiph(MCLK_APBCMASK_TRNG)
#define sam_apb_icm_disableperiph(n) sam_apbc_disableperiph(MCLK_APBCMASK_ICM)
#define sam_apb_qspi_disableperiph(n) sam_apbc_disableperiph(MCLK_APBCMASK_QSPI)
#define sam_apb_ccl_disableperiph(n) sam_apbc_disableperiph(MCLK_APBCMASK_CCL)
#define sam_apbd_disableperiph(s) modifyreg32(SAM_MCLK_APBDMASK,s,0)
#define sam_apb_sercom4_disableperiph() sam_apbd_disableperiph(MCLK_APBDMASK_SERCOM4)
#define sam_apb_sercom5_disableperiph() sam_apbd_disableperiph(MCLK_APBDMASK_SERCOM5)
#define sam_apb_sercom6_disableperiph() sam_apbd_disableperiph(MCLK_APBDMASK_SERCOM6)
#define sam_apb_sercom7_disableperiph() sam_apbd_disableperiph(MCLK_APBDMASK_SERCOM7)
#define sam_apb_tcc4_disableperiph() sam_apbd_disableperiph(MCLK_APBDMASK_TCC4)
#define sam_apb_tc6_disableperiph() sam_apbd_disableperiph(MCLK_APBDMASK_TC6)
#define sam_apb_tc7_disableperiph() sam_apbd_disableperiph(MCLK_APBDMASK_TC7)
#define sam_apb_adc0_disableperiph() sam_apbd_disableperiph(MCLK_APBDMASK_ADC0)
#define sam_apb_adc1_disableperiph() sam_apbd_disableperiph(MCLK_APBDMASK_ADC1)
#define sam_apb_dac_disableperiph() sam_apbd_disableperiph(MCLK_APBDMASK_DAC)
#define sam_apb_i2c_disableperiph() sam_apbd_disableperiph(MCLK_APBDMASK_I2C)
#define sam_apb_pcc_disableperiph() sam_apbd_disableperiph(MCLK_APBDMASK_PCC)
#define sam_ahb_isenabled(s) (getreg32(SAM_MCLK_AHBMASK) & (s)) != 0)
#define sam_ahb_hpb0_isenabled() sam_ahb_isenabled(MCLK_AHBMASK_HPB0)
#define sam_ahb_hpb1_isenabled() sam_ahb_isenabled(MCLK_AHBMASK_HPB1)
#define sam_ahb_hpb2_isenabled() sam_ahb_isenabled(MCLK_AHBMASK_HPB2)
#define sam_ahb_hpb3_isenabled() sam_ahb_isenabled(MCLK_AHBMASK_HPB3)
#define sam_ahb_dsu_isenabled() sam_ahb_isenabled(MCLK_AHBMASK_DSU)
#define sam_ahb_nvmctrl_isenabled() sam_ahb_isenabled(MCLK_AHBMASK_NVMCTRL)
#define sam_ahb_cmcc_isenabled() sam_ahb_isenabled(MCLK_AHBMASK_CMCC)
#define sam_ahb_dmac_isenabled() sam_ahb_isenabled(MCLK_AHBMASK_DMAC)
#define sam_ahb_usb_isenabled() sam_ahb_isenabled(MCLK_AHBMASK_USB)
#define sam_ahb_pac_isenabled() sam_ahb_isenabled(MCLK_AHBMASK_PAC)
#define sam_ahb_qspi_isenabled() sam_ahb_isenabled(MCLK_AHBMASK_QSPI)
#define sam_ahb_gmac_isenabled() sam_ahb_isenabled(MCLK_AHBMASK_GMAC)
#define sam_ahb_sdhc0_isenabled() sam_ahb_isenabled(MCLK_AHBMASK_SDHC0)
#define sam_ahb_sdhc1_isenabled() sam_ahb_isenabled(MCLK_AHBMASK_SDHC1)
#define sam_ahb_can0_isenabled() sam_ahb_isenabled(MCLK_AHBMASK_CAN0)
#define sam_ahb_can1_isenabled() sam_ahb_isenabled(MCLK_AHBMASK_CAN1)
#define sam_ahb_icm_isenabled() sam_ahb_isenabled(MCLK_AHBMASK_ICM)
#define sam_ahb_pukcc_isenabled() sam_ahb_isenabled(MCLK_AHBMASK_PUKCC)
#define sam_ahb_qspi2x_isenabled() sam_ahb_isenabled(MCLK_AHBMASK_QSPI2X)
#define sam_ahb_nvmctrl_smeeprom_isenabled() sam_ahb_isenabled(MCLK_AHBMASK_NVMCTRL_SMEEPROM)
#define sam_ahb_nvmctrl_cache_isenabled() sam_ahb_isenabled(MCLK_AHBMASK_NVMCTRL_CACHE)
#define sam_apba_isenabled(s) (getreg32(SAM_MCLK_APBAMASK) & (s)) != 0)
#define sam_apb_pac_isenabled() sam_apba_isenabled(MCLK_APBAMASK_PAC)
#define sam_apb_pm_isenabled() sam_apba_isenabled(MCLK_APBAMASK_PM)
#define sam_apb_mclk_isenabled() sam_apba_isenabled(MCLK_APBAMASK_MCLK)
#define sam_apb_rstc_isenabled() sam_apba_isenabled(MCLK_APBAMASK_RSTC)
#define sam_apb_oscctrl_isenabled() sam_apba_isenabled(MCLK_APBAMASK_OSCCTRL)
#define sam_apb_osc32kctrl_isenabled() sam_apba_isenabled(MCLK_APBAMASK_OSC32KCTRL)
#define sam_apb_supc_isenabled() sam_apba_isenabled(MCLK_APBAMASK_SUPC)
#define sam_apb_gclk_isenabled() sam_apba_isenabled(MCLK_APBAMASK_GCLK)
#define sam_apb_wdt_isenabled() sam_apba_isenabled(MCLK_APBAMASK_WDT)
#define sam_apb_rtc_isenabled() sam_apba_isenabled(MCLK_APBAMASK_RTC)
#define sam_apb_eic_isenabled() sam_apba_isenabled(MCLK_APBAMASK_EIC)
#define sam_apb_freqm_isenabled() sam_apba_isenabled(MCLK_APBAMASK_FREQM)
#define sam_apb_sercom0_isenabled() sam_apba_isenabled(MCLK_APBAMASK_SERCOM0)
#define sam_apb_sercom1_isenabled() sam_apba_isenabled(MCLK_APBAMASK_SERCOM1)
#define sam_apb_tc0_isenabled() sam_apba_isenabled(MCLK_APBAMASK_TC0)
#define sam_apb_tc1_isenabled() sam_apba_isenabled(MCLK_APBAMASK_TC1)
#define sam_apbb_isenabled(s) (getreg32(SAM_MCLK_APBBMASK) & (s)) != 0)
#define sam_apb_usb_isenabled() sam_apbb_isenabled(MCLK_APBBMASK_USB)
#define sam_apb_dsu_isenabled() sam_apbb_isenabled(MCLK_APBBMASK_DSU)
#define sam_apb_nvmctrl_isenabled() sam_apbb_isenabled(MCLK_APBBMASK_NVMCTRL)
#define sam_apb_port_isenabled() sam_apbb_isenabled(MCLK_APBBMASK_PORT)
#define sam_apb_evsys_isenabled() sam_apbb_isenabled(MCLK_APBBMASK_EVSYS)
#define sam_apb_sercom2_isenabled() sam_apbb_isenabled(MCLK_APBBMASK_SERCOM2)
#define sam_apb_sercom3_isenabled() sam_apbb_isenabled(MCLK_APBBMASK_SERCOM3)
#define sam_apb_tcc0_isenabled() sam_apbb_isenabled(MCLK_APBBMASK_TCC0)
#define sam_apb_tcc1_isenabled() sam_apbb_isenabled(MCLK_APBBMASK_TCC1)
#define sam_apb_tc2_isenabled() sam_apbb_isenabled(MCLK_APBBMASK_TC2)
#define sam_apb_tc3_isenabled() sam_apbb_isenabled(MCLK_APBBMASK_TC3)
#define sam_apb_ramecc_isenabled() sam_apbb_isenabled(MCLK_APBBMASK_RAMECC)
#define sam_apbc_isenabled(s) (getreg32(SAM_MCLK_APBCMASK) & (s)) != 0)
#define sam_apb_gmac_isenabled(n) sam_apbc_isenabled(MCLK_APBCMASK_GMAC)
#define sam_apb_tcc2_isenabled(n) sam_apbc_isenabled(MCLK_APBCMASK_TCC2)
#define sam_apb_tcc3_isenabled(n) sam_apbc_isenabled(MCLK_APBCMASK_TCC3)
#define sam_apb_tc4_isenabled(n) sam_apbc_isenabled(MCLK_APBCMASK_TC4)
#define sam_apb_tc5_isenabled(n) sam_apbc_isenabled(MCLK_APBCMASK_TC5)
#define sam_apb_pdec_isenabled(n) sam_apbc_isenabled(MCLK_APBCMASK_PDEC)
#define sam_apb_ac_isenabled(n) sam_apbc_isenabled(MCLK_APBCMASK_AC)
#define sam_apb_aes_isenabled(n) sam_apbc_isenabled(MCLK_APBCMASK_AES)
#define sam_apb_trng_isenabled(n) sam_apbc_isenabled(MCLK_APBCMASK_TRNG)
#define sam_apb_icm_isenabled(n) sam_apbc_isenabled(MCLK_APBCMASK_ICM)
#define sam_apb_qspi_isenabled(n) sam_apbc_isenabled(MCLK_APBCMASK_QSPI)
#define sam_apb_ccl_isenabled(n) sam_apbc_isenabled(MCLK_APBCMASK_CCL)
#define sam_apbd_isenabled(s) (getreg32(SAM_MCLK_APBDMASK) & (s)) != 0)
#define sam_apb_sercom4_isenabled() sam_apbd_isenabled(MCLK_APBDMASK_SERCOM4)
#define sam_apb_sercom5_isenabled() sam_apbd_isenabled(MCLK_APBDMASK_SERCOM5)
#define sam_apb_sercom6_isenabled() sam_apbd_isenabled(MCLK_APBDMASK_SERCOM6)
#define sam_apb_sercom7_isenabled() sam_apbd_isenabled(MCLK_APBDMASK_SERCOM7)
#define sam_apb_tcc4_isenabled() sam_apbd_isenabled(MCLK_APBDMASK_TCC4)
#define sam_apb_tc6_isenabled() sam_apbd_isenabled(MCLK_APBDMASK_TC6)
#define sam_apb_tc7_isenabled() sam_apbd_isenabled(MCLK_APBDMASK_TC7)
#define sam_apb_adc0_isenabled() sam_apbd_isenabled(MCLK_APBDMASK_ADC0)
#define sam_apb_adc1_isenabled() sam_apbd_isenabled(MCLK_APBDMASK_ADC1)
#define sam_apb_dac_isenabled() sam_apbd_isenabled(MCLK_APBDMASK_DAC)
#define sam_apb_i2c_isenabled() sam_apbd_isenabled(MCLK_APBDMASK_I2C)
#define sam_apb_pcc_isenabled() sam_apbd_isenabled(MCLK_APBDMASK_PCC)
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Inline Functions
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Public Data
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_SRC_SAMD5E5_SAM_PERIPHCLKS_H */

View File

@ -0,0 +1,578 @@
/****************************************************************************
* arch/arm/src/samd5e5/sam_port.c
*
* Copyright (C) 2018 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <time.h>
#include <errno.h>
#include <debug.h>
#include <nuttx/irq.h>
#include <nuttx/arch.h>
#include <arch/board/board.h>
#include "up_internal.h"
#include "up_arch.h"
#include "sam_port.h"
#include "sam_eic.h"
/****************************************************************************
* Private Data
****************************************************************************/
#ifdef CONFIG_DEBUG_GPIO_INFO
static const char g_portchar[SAM_NPORTS] = { 'A', 'B', 'C', 'D' };
#endif
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: sam_portbase
*
* Description:
* Return the base address of the PORT register set
*
****************************************************************************/
static inline uintptr_t sam_portbase(port_pinset_t pinset)
{
int port = (pinset & PORT_MASK) >> PORT_SHIFT;
return SAM_PORTN_BASE(port);
}
/****************************************************************************
* Name: sam_portpin
*
* Description:
* Return the bit associated with the pin
*
****************************************************************************/
static inline int sam_portpin(port_pinset_t pinset)
{
return 1 << ((pinset & PORT_PIN_MASK) >> PORT_PIN_SHIFT);
}
/****************************************************************************
* Name: sam_configinput
*
* Description:
* Configure a PORT input pin based on bit-encoded description of the pin.
* This function serves the dual role of putting all pins into a known,
* initial state. Hence, it is overkill for what really needs to be done.
*
* Assumption:
* sam_configreset has been called to put the pin into the default reset
* state.
*
****************************************************************************/
static inline void sam_configinput(uintptr_t base, port_pinset_t pinset)
{
uint32_t regval;
uint32_t bit;
int pin;
/* Decode pin information */
pin = (pinset & PORT_PIN_MASK) >> PORT_PIN_SHIFT;
bit = (1 << pin);
/* Direction bit is already zero (input) */
/* Enable the I/O synchronizer? */
if ((pinset & PORT_SYNCHRONIZER_MASK) == PORT_SYNCHRONIZER_ON)
{
regval = getreg32(base + SAM_PORT_CTRL_OFFSET);
regval |= bit;
putreg32(regval, base + SAM_PORT_CTRL_OFFSET);
}
/* Set the pin configuration */
regval = (PORT_WRCONFIG_WRPINCFG | PORT_WRCONFIG_WRPMUX | PORT_WRCONFIG_INEN);
if (pin >= 16)
{
/* Select the upper half word and adjust the bit setting */
regval |= PORT_WRCONFIG_HWSEL;
pin -= 16;
}
regval |= PORT_WRCONFIG_PINMASK(pin);
/* Check for pull-up/down selection */
switch (pinset & PORT_PULL_MASK)
{
case PORT_PULL_UP:
{
/* Select pull-up by setting the corresponding bit in OUT
* register.
*/
putreg32(bit, base + SAM_PORT_OUTSET_OFFSET);
}
/* Fall through */
case PORT_PULL_DOWN:
{
regval |= PORT_WRCONFIG_PULLEN;
}
break;
default:
case PORT_PULL_NONE:
break;
}
/* Configure the pin as an input */
putreg32(regval, base + SAM_PORT_WRCONFIG_OFFSET);
}
/****************************************************************************
* Name: sam_configinterrupt
*
* Description:
* Configure a PORT interrupt pin based on bit-encoded description of the
* pin.
*
* Assumption:
* sam_configreset has been called to put the pin into the default reset
* state:
*
****************************************************************************/
static inline void sam_configinterrupt(uintptr_t base, port_pinset_t pinset)
{
#ifdef CONFIG_SAMD5E5_EIC
uint32_t func;
uint32_t regval;
int pin;
pin = (pinset & PORT_PIN_MASK) >> PORT_PIN_SHIFT;
regval = (PORT_WRCONFIG_WRPINCFG | PORT_WRCONFIG_WRPMUX |
PORT_WRCONFIG_PMUXEN | PORT_WRCONFIG_INEN);
regval |= PORT_WRCONFIG_PINMASK(pin);
func = (pinset & PORT_FUNC_MASK) >> PORT_FUNC_SHIFT;
regval |= (func << PORT_WRCONFIG_PMUX_SHIFT);
putreg32(regval, base + SAM_PORT_WRCONFIG_OFFSET);
/* Configure the interrupt edge sensitivity in CONFIGn register of the EIC */
sam_eic_configure(pin, pinset);
#ifdef CONFIG_DEBUG_GPIO_INFO
sam_dumpport(pinset, "extint");
#endif
#endif /* CONFIG_SAMD5E5_EIC */
}
/****************************************************************************
* Name: sam_configoutput
*
* Description:
* Configure a PORT output pin based on bit-encoded description of the pin.
*
* Assumption:
* sam_configreset has been called to put the pin into the default reset
* state.
*
****************************************************************************/
static inline void sam_configoutput(uintptr_t base, port_pinset_t pinset)
{
uint32_t regval;
uint32_t bit;
int pin;
/* Decode pin information */
pin = (pinset & PORT_PIN_MASK) >> PORT_PIN_SHIFT;
bit = (1 << pin);
/* Set the direction bit to configure the pin as an input */
putreg32(bit, base + SAM_PORT_DIRSET_OFFSET);
/* Set the initial output value to high? */
if ((pinset & PORT_OUTVALUE_MASK) == PORT_OUTPUT_SET)
{
putreg32(bit, base + SAM_PORT_OUTSET_OFFSET);
}
/* Set the pin configuration. This will be an output with the input
* buffer enabled.
*/
regval = (PORT_WRCONFIG_WRPINCFG | PORT_WRCONFIG_WRPMUX | PORT_WRCONFIG_INEN);
if (pin > 16)
{
/* Select the upper half word and adjust the bit setting */
regval |= PORT_WRCONFIG_HWSEL;
pin -= 16;
}
regval |= PORT_WRCONFIG_PINMASK(pin);
/* Check for pull-up/down selection */
switch (pinset & PORT_PULL_MASK)
{
case PORT_PULL_UP:
{
/* Select pull-up by setting the corresponding bit in OUT
* register.
*/
putreg32(bit, base + SAM_PORT_OUTSET_OFFSET);
}
/* Fall through */
case PORT_PULL_DOWN:
{
regval |= PORT_WRCONFIG_PULLEN;
}
break;
default:
case PORT_PULL_NONE:
break;
}
/* Select higher strength drive? */
if ((pinset & PORT_DRIVE_MASK) == PORT_DRIVE_HIGH)
{
regval |= PORT_WRCONFIG_DRVSTR;
}
/* Configure the pin as an output */
putreg32(regval, base + SAM_PORT_WRCONFIG_OFFSET);
}
/****************************************************************************
* Name: sam_configperiph
*
* Description:
* Configure a PORT pin driven by a peripheral based on bit-encoded
* description of the pin.
*
* Assumption:
* sam_configreset has been called to put the pin into the default reset
* state.
*
****************************************************************************/
static inline void sam_configperiph(uintptr_t base, port_pinset_t pinset)
{
uint32_t regval;
uint32_t bit;
uint32_t func;
int pin;
/* Decode pin information */
pin = (pinset & PORT_PIN_MASK) >> PORT_PIN_SHIFT;
bit = (1 << pin);
/* If pin is output with readback then set the pin as output */
if ((pinset & PORT_OUTREADBACK_MASK) == PORT_OUTREADBACK_ENABLE)
{
putreg32(bit, base + SAM_PORT_DIRSET_OFFSET);
}
/* Set the pin configuration. This will be an peripheral with the
* selected function.
*/
regval = (PORT_WRCONFIG_WRPINCFG | PORT_WRCONFIG_WRPMUX | PORT_WRCONFIG_PMUXEN);
/* If pin is output with readback then enable the input buffer */
if ((pinset & PORT_OUTREADBACK_MASK) == PORT_OUTREADBACK_ENABLE)
{
regval |= PORT_WRCONFIG_INEN;
}
if (pin >= 16)
{
/* Select the upper half word and adjust the bit setting */
regval |= PORT_WRCONFIG_HWSEL;
pin -= 16;
}
regval |= PORT_WRCONFIG_PINMASK(pin);
/* Set the pin function */
func = (pinset & PORT_FUNC_MASK) >> PORT_FUNC_SHIFT;
regval |= (func << PORT_WRCONFIG_PMUX_SHIFT);
/* Check for pull-up/down selection */
switch (pinset & PORT_PULL_MASK)
{
case PORT_PULL_UP:
{
/* Select pull-up by setting the corresponding bit in OUT
* register.
*/
putreg32(bit, base + SAM_PORT_OUTSET_OFFSET);
}
/* Fall through */
case PORT_PULL_DOWN:
{
regval |= PORT_WRCONFIG_PULLEN;
}
break;
default:
case PORT_PULL_NONE:
break;
}
/* Configure the pin for the peripheral function */
putreg32(regval, base + SAM_PORT_WRCONFIG_OFFSET);
}
/****************************************************************************
* Name: sam_configreset
*
* Description:
* Configure a PORT pin in the default, reset state.
*
****************************************************************************/
static inline void sam_configreset(uintptr_t base, port_pinset_t pinset)
{
uint32_t regval;
uint32_t bit;
int pin;
/* Decode pin information */
pin = (pinset & PORT_PIN_MASK) >> PORT_PIN_SHIFT;
bit = (1 << pin);
/* Set the direction bit to zero (input) */
putreg32(bit, base + SAM_PORT_DIRCLR_OFFSET);
/* Disable the I/O synchronizer */
regval = getreg32(base + SAM_PORT_CTRL_OFFSET);
regval &= ~bit;
putreg32(regval, base + SAM_PORT_CTRL_OFFSET);
/* Assume input pull-down or output value low */
putreg32(bit, base + SAM_PORT_OUTCLR_OFFSET);
/* Set the pin configuration */
regval = (PORT_WRCONFIG_WRPINCFG | PORT_WRCONFIG_WRPMUX);
if (pin > 16)
{
/* Select the upper half word and adjust the bit setting */
regval |= PORT_WRCONFIG_HWSEL;
pin -= 16;
}
regval |= PORT_WRCONFIG_PINMASK(pin);
/* Disable the peripheral multiplexor, disable the input, disable
* pull-up/down, reset driver strength, etc.
*/
putreg32(regval, base + SAM_PORT_WRCONFIG_OFFSET);
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sam_configport
*
* Description:
* Configure a PORT pin based on bit-encoded description of the pin.
*
****************************************************************************/
int sam_configport(port_pinset_t pinset)
{
uintptr_t base = sam_portbase(pinset);
irqstate_t flags;
/* Make sure that all operations on the port are atomic */
flags = enter_critical_section();
/* Put the PORT in the known, reset state. */
sam_configreset(base, pinset);
/* Then put the PORT into the requested state */
switch (pinset & PORT_MODE_MASK)
{
case PORT_INPUT:
sam_configinput(base, pinset);
break;
case PORT_OUTPUT:
sam_configoutput(base, pinset);
break;
case PORT_PERIPHERAL:
sam_configperiph(base, pinset);
break;
case PORT_INTERRUPT:
sam_configinterrupt(base, pinset);
break;
default:
break;
}
leave_critical_section(flags);
return OK;
}
/****************************************************************************
* Name: sam_portwrite
*
* Description:
* Write one or zero to the selected PORT pin
*
****************************************************************************/
void sam_portwrite(port_pinset_t pinset, bool value)
{
uintptr_t base = sam_portbase(pinset);
uint32_t pin = sam_portpin(pinset);
if (value)
{
putreg32(pin, base + SAM_PORT_OUTSET_OFFSET);
}
else
{
putreg32(pin, base + SAM_PORT_OUTCLR_OFFSET);
}
}
/****************************************************************************
* Name: sam_portread
*
* Description:
* Read one or zero from the selected PORT pin
*
****************************************************************************/
bool sam_portread(port_pinset_t pinset)
{
uintptr_t base = sam_portbase(pinset);
uint32_t pin = sam_portpin(pinset);
return (getreg32(base + SAM_PORT_IN_OFFSET) & pin) != 0;
}
/************************************************************************************
* Function: sam_dumpport
*
* Description:
* Dump all PORT registers associated with the base address of the provided pinset.
*
************************************************************************************/
#ifdef CONFIG_DEBUG_GPIO_INFO
int sam_dumpport(uint32_t pinset, const char *msg)
{
irqstate_t flags;
uintptr_t base;
unsigned int pin;
unsigned int port;
/* Get the base address associated with the PIO port */
pin = (pinset & PORT_PIN_MASK) >> PORT_PIN_SHIFT;
port = (pinset & PORT_MASK) >> PORT_SHIFT;
base = SAM_PORTN_BASE(port);
/* The following requires exclusive access to the PORT registers */
flags = enter_critical_section();
gpioinfo("PORT%c pin: %d pinset: %08x base: %08x -- %s\n",
g_portchar[port], pin, pinset, base, msg);
gpioinfo(" DIR: %08x OUT: %08x IN: %08x\n",
getreg32(base + SAM_PORT_DIR_OFFSET),
getreg32(base + SAM_PORT_OUT_OFFSET),
getreg32(base + SAM_PORT_IN_OFFSET));
gpioinfo(" CTRL: %08x WRCONFIG: %08x\n",
getreg32(base + SAM_PORT_CTRL_OFFSET),
getreg32(base + SAM_PORT_WRCONFIG_OFFSET));
gpioinfo(" PMUX[%08x]: %02x PINCFG[%08x]: %02x\n",
base + SAM_PORT_PMUX_OFFSET(pin),
getreg8(base + SAM_PORT_PMUX_OFFSET(pin)),
base + SAM_PORT_PINCFG_OFFSET(pin),
getreg8(base + SAM_PORT_PINCFG_OFFSET(pin)));
leave_critical_section(flags);
return OK;
}
#endif

View File

@ -0,0 +1,400 @@
/****************************************************************************
* arch/arm/src/samd5e5/sam_port.h
*
* Copyright (C) 2018 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_SAMD5E5_SAM_PORT_H
#define __ARCH_ARM_SRC_SAMD5E5_SAM_PORT_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#ifndef __ASSEMBLY__
# include <stdint.h>
# include <stdbool.h>
#endif
#include <nuttx/irq.h>
#include "chip/sam_port.h"
/****************************************************************************
* Pre-processor Declarations
****************************************************************************/
/* Bit-encoded input to sam_configport() */
/* 24-bit Encoding. This could be compacted into 16-bits by making the bit usage
* mode specific. However, by giving each bit field a unique position, we handle
* bad combinations of properties safely.
*
* MODE BITFIELDS
* ------------ -----------------------------
* 2222 1111 1111 1100 0000 0000
* 3210 9876 5432 1098 7654 3210
* ------------ -----------------------------
* PORT Input: MMRR .... .S.. .... .PPB BBBB
* PORT Output: MM.. .... D..V .... .PPB BBBB
* Peripheral: MM.. FFFF ..O. II.. .PPB BBBB
* ------------ -----------------------------
* MMRR FFFF DSOV II.. .PPB BBBB
*/
/* Input/output/peripheral mode:
*
* MODE BITFIELDS
* ------------ -----------------------------
* 2222 1111 1111 1100 0000 0000
* 3210 9876 5432 1098 7654 3210
* ------------ -----------------------------
* PORT Input: MM.. .... .... .... .... ....
* PORT Output: MM.. .... .... .... .... ....
* Peripheral: MM.. .... .... .... .... ....
*/
#define PORT_MODE_SHIFT (22) /* Bits 22-23: PORT mode */
#define PORT_MODE_MASK (3 << PORT_MODE_SHIFT)
# define PORT_INPUT (0 << PORT_MODE_SHIFT) /* PORT Input */
# define PORT_OUTPUT (1 << PORT_MODE_SHIFT) /* PORT Output */
# define PORT_PERIPHERAL (2 << PORT_MODE_SHIFT) /* Controlled by peripheral */
# define PORT_INTERRUPT (3 << PORT_MODE_SHIFT) /* Interrupting input */
/* Pull-up/down resistor control for inputs
*
* MODE BITFIELDS
* ------------ -----------------------------
* 2222 1111 1111 1100 0000 0000
* 3210 9876 5432 1098 7654 3210
* ------------ -----------------------------
* PORT Input: ..RR .... .... .... .... ....
* PORT Output: ..RR .... .... .... .... ....
* Peripheral: .... .... .... .... .... ....
*/
#define PORT_PULL_SHIFT (20) /* Bits 20-21: Pull-up/down resistor control */
#define PORT_PULL_MASK (3 << PORT_PULL_SHIFT)
# define PORT_PULL_NONE (0 << PORT_PULL_SHIFT)
# define PORT_PULL_UP (1 << PORT_PULL_SHIFT)
# define PORT_PULL_DOWN (2 << PORT_PULL_SHIFT)
/* Peripheral Function
*
* MODE BITFIELDS
* ------------ -----------------------------
* 2222 1111 1111 1100 0000 0000
* 3210 9876 5432 1098 7654 3210
* ------------ -----------------------------
* PORT Input: .... .... .... .... .... ....
* PORT Output: .... .... .... .... .... ....
* Peripheral: .... FFFF .... .... .... ....
*/
#define PORT_FUNC_SHIFT (16) /* Bits 16-19: Peripheral function */
#define PORT_FUNC_MASK (15 << PORT_FUNC_SHIFT)
# define _PORT_FUNCA (0 << PORT_FUNC_SHIFT) /* Function A */
# define _PORT_FUNCB (1 << PORT_FUNC_SHIFT) /* Function B */
# define _PORT_FUNCC (2 << PORT_FUNC_SHIFT) /* Function C */
# define _PORT_FUNCD (3 << PORT_FUNC_SHIFT) /* Function D */
# define _PORT_FUNCE (4 << PORT_FUNC_SHIFT) /* Function E */
# define _PORT_FUNCF (5 << PORT_FUNC_SHIFT) /* Function F */
# define _PORT_FUNCG (6 << PORT_FUNC_SHIFT) /* Function G */
# define _PORT_FUNCH (7 << PORT_FUNC_SHIFT) /* Function H */
# define _PORT_FUNCI (8 << PORT_FUNC_SHIFT) /* Function I */
# define _PORT_FUNCJ (9 << PORT_FUNC_SHIFT) /* Function J */
# define _PORT_FUNCK (10 << PORT_FUNC_SHIFT) /* Function K */
# define _PORT_FUNCL (11 << PORT_FUNC_SHIFT) /* Function L */
# define _PORT_FUNCM (12 << PORT_FUNC_SHIFT) /* Function M */
# define _PORT_FUNCN (13 << PORT_FUNC_SHIFT) /* Function N */
/* Extended input/output/peripheral mode:
*
* MODE BITFIELDS
* ------------ -----------------------------
* 2222 1111 1111 1100 0000 0000
* 3210 9876 5432 1098 7654 3210
* ------------ -----------------------------
* PORT Input: .... .... .... .... .... ....
* PORT Output: .... .... .... .... .... ....
* Peripheral: MM.. FFFF .... .... .... ....
*/
#define PORT_FUNCA (PORT_PERIPHERAL | _PORT_FUNCA) /* Function A */
#define PORT_FUNCB (PORT_PERIPHERAL | _PORT_FUNCB) /* Function B */
#define PORT_FUNCC (PORT_PERIPHERAL | _PORT_FUNCC) /* Function C */
#define PORT_FUNCD (PORT_PERIPHERAL | _PORT_FUNCD) /* Function D */
#define PORT_FUNCE (PORT_PERIPHERAL | _PORT_FUNCE) /* Function E */
#define PORT_FUNCF (PORT_PERIPHERAL | _PORT_FUNCF) /* Function F */
#define PORT_FUNCG (PORT_PERIPHERAL | _PORT_FUNCG) /* Function G */
#define PORT_FUNCH (PORT_PERIPHERAL | _PORT_FUNCH) /* Function H */
#define PORT_FUNCI (PORT_PERIPHERAL | _PORT_FUNCI) /* Function I */
#define PORT_FUNCJ (PORT_PERIPHERAL | _PORT_FUNCJ) /* Function J */
#define PORT_FUNCK (PORT_PERIPHERAL | _PORT_FUNCK) /* Function K */
#define PORT_FUNCL (PORT_PERIPHERAL | _PORT_FUNCL) /* Function L */
#define PORT_FUNCM (PORT_PERIPHERAL | _PORT_FUNCM) /* Function M */
#define PORT_FUNCN (PORT_PERIPHERAL | _PORT_FUNCN) /* Function N */
/* Output drive control
*
* MODE BITFIELDS
* ------------ -----------------------------
* 2222 1111 1111 1100 0000 0000
* 3210 9876 5432 1098 7654 3210
* ------------ -----------------------------
* PORT Input: .... .... .... .... .... ....
* PORT Output: .... .... D... .... .... ....
* Peripheral: .... .... .... .... .... ....
*/
#define PORT_DRIVE_SHIFT (15) /* Bit 15: Interrupting input control */
#define PORT_DRIVE_MASK (1 << PORT_INT_SHIFT)
# define PORT_DRIVE_LOW (0 << PORT_INT_SHIFT)
# define PORT_DRIVE_HIGH (1 << PORT_INT_SHIFT)
/* Input sampling
*
* MODE BITFIELDS
* ------------ -----------------------------
* 2222 1111 1111 1100 0000 0000
* 3210 9876 5432 1098 7654 3210
* ------------ -----------------------------
* PORT Input: .... .... .S.. .... .... ....
* PORT Output: .... .... .... .... .... ....
* Peripheral: .... .... .... .... .... ....
*/
#define PORT_SYNCHRONIZER_SHIFT (14) /* Bit 14: Input synchronizer input control */
#define PORT_SYNCHRONIZER_MASK (1 << PORT_SYNCHRONIZER_SHIFT)
# define PORT_SYNCHRONIZER_OFF (0 << PORT_SYNCHRONIZER_SHIFT)
# define PORT_SYNCHRONIZER_ON (1 << PORT_SYNCHRONIZER_SHIFT)
/* Output and Input Buffer both enabled to let readback
*
* MODE BITFIELDS
* ------------ -----------------------------
* 2222 1111 1111 1100 0000 0000
* 3210 9876 5432 1098 7654 3210
* ------------ -----------------------------
* PORT Input: .... .... .... .... .... ....
* PORT Output: .... .... .... .... .... ....
* Peripheral: .... .... ..O. .... .... ....
*/
#define PORT_OUTREADBACK_SHIFT (13) /* Bit 13: Pin output and input buffer enabled */
#define PORT_OUTREADBACK_MASK (1 << PORT_OUTREADBACK_SHIFT)
# define PORT_OUTREADBACK_DISABLE (0 << PORT_OUTREADBACK_SHIFT)
# define PORT_OUTREADBACK_ENABLE (1 << PORT_OUTREADBACK_SHIFT)
/* If the pin is an PORT output, then this identifies the initial output value:
*
* MODE BITFIELDS
* ------------ -----------------------------
* 2222 1111 1111 1100 0000 0000
* 3210 9876 5432 1098 7654 3210
* ------------ -----------------------------
* PORT Input: .... .... .... .... .... ....
* PORT Output: .... .... ...V .... .... ....
* Peripheral: .... .... .... .... .... ....
*/
#define PORT_OUTVALUE_SHIFT (12) /* Bit 12: Initial value of output */
#define PORT_OUTVALUE_MASK (1 << PORT_SYNCHRONIZER_SHIFT)
# define PORT_OUTPUT_CLEAR (0 << PORT_SYNCHRONIZER_SHIFT)
# define PORT_OUTPUT_SET (1 << PORT_SYNCHRONIZER_SHIFT)
/* Selections for external interrupts:
*
* MODE BITFIELDS
* ------------ -----------------------------
* 2222 1111 1111 1100 0000 0000
* 3210 9876 5432 1098 7654 3210
* ------------ -----------------------------
* PORT Input: .... .... .... .... .... ....
* PORT Output: .... .... .... .... .... ....
* Peripheral: .... .... .... II.. .... ....
*/
#define PORT_INT_SHIFT (10) /* Bits 10-11: Interrupting input control */
#define PORT_INT_MASK (3 << PORT_INT_SHIFT)
# define PORT_INT_CHANGE (0 << PORT_INT_SHIFT) /* Pin change */
# define PORT_INT_RISING (1 << PORT_INT_SHIFT) /* Rising edge */
# define PORT_INT_FALLING (2 << PORT_INT_SHIFT) /* Falling edge */
/* This identifies the PORT port:
*
* MODE BITFIELDS
* ------------ -----------------------------
* 2222 1111 1111 1100 0000 0000
* 3210 9876 5432 1098 7654 3210
* ------------ -----------------------------
* PORT Input: .... .... .... .... .PP. ....
* PORT Output: .... .... .... .... .PP. ....
* Peripheral: .... .... .... .... .PP. ....
*/
#define PORT_SHIFT (5) /* Bits 5-6: Port number */
#define PORT_MASK (3 << PORT_SHIFT)
# define PORTA (SAM_PORTA << PORT_SHIFT)
# define PORTB (SAM_PORTB << PORT_SHIFT)
# define PORTC (SAM_PORTC << PORT_SHIFT)
# define PORTD (SAM_PORTD << PORT_SHIFT)
/* This identifies the bit in the port:
*
* MODE BITFIELDS
* ------------ -----------------------------
* 2222 1111 1111 1100 0000 0000
* 3210 9876 5432 1098 7654 3210
* ------------ -----------------------------
* PORT Input: .... .... .... .... ...B BBBB
* PORT Output: .... .... .... .... ...B BBBB
* Peripheral: .... .... .... .... ...B BBBB
*/
#define PORT_PIN_SHIFT 0 /* Bits 0-4: PORT number: 0-31 */
#define PORT_PIN_MASK (31 << PORT_PIN_SHIFT)
#define PORT_PIN0 (0 << PORT_PIN_SHIFT)
#define PORT_PIN1 (1 << PORT_PIN_SHIFT)
#define PORT_PIN2 (2 << PORT_PIN_SHIFT)
#define PORT_PIN3 (3 << PORT_PIN_SHIFT)
#define PORT_PIN4 (4 << PORT_PIN_SHIFT)
#define PORT_PIN5 (5 << PORT_PIN_SHIFT)
#define PORT_PIN6 (6 << PORT_PIN_SHIFT)
#define PORT_PIN7 (7 << PORT_PIN_SHIFT)
#define PORT_PIN8 (8 << PORT_PIN_SHIFT)
#define PORT_PIN9 (9 << PORT_PIN_SHIFT)
#define PORT_PIN10 (10 << PORT_PIN_SHIFT)
#define PORT_PIN11 (11 << PORT_PIN_SHIFT)
#define PORT_PIN12 (12 << PORT_PIN_SHIFT)
#define PORT_PIN13 (13 << PORT_PIN_SHIFT)
#define PORT_PIN14 (14 << PORT_PIN_SHIFT)
#define PORT_PIN15 (15 << PORT_PIN_SHIFT)
#define PORT_PIN16 (16 << PORT_PIN_SHIFT)
#define PORT_PIN17 (17 << PORT_PIN_SHIFT)
#define PORT_PIN18 (18 << PORT_PIN_SHIFT)
#define PORT_PIN19 (19 << PORT_PIN_SHIFT)
#define PORT_PIN20 (20 << PORT_PIN_SHIFT)
#define PORT_PIN21 (21 << PORT_PIN_SHIFT)
#define PORT_PIN22 (22 << PORT_PIN_SHIFT)
#define PORT_PIN23 (23 << PORT_PIN_SHIFT)
#define PORT_PIN24 (24 << PORT_PIN_SHIFT)
#define PORT_PIN25 (25 << PORT_PIN_SHIFT)
#define PORT_PIN26 (26 << PORT_PIN_SHIFT)
#define PORT_PIN27 (27 << PORT_PIN_SHIFT)
#define PORT_PIN28 (28 << PORT_PIN_SHIFT)
#define PORT_PIN29 (29 << PORT_PIN_SHIFT)
#define PORT_PIN30 (30 << PORT_PIN_SHIFT)
#define PORT_PIN31 (31 << PORT_PIN_SHIFT)
/****************************************************************************
* Public Types
****************************************************************************/
typedef uint32_t port_pinset_t;
/****************************************************************************
* Public Data
****************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: sam_configport
*
* Description:
* Configure a PORT pin based on bit-encoded description of the pin.
*
* Returned Value:
* OK (always)
*
****************************************************************************/
int sam_configport(port_pinset_t pinset);
/****************************************************************************
* Name: sam_portwrite
*
* Description:
* Write one or zero to the selected PORT pin
*
****************************************************************************/
void sam_portwrite(port_pinset_t pinset, bool value);
/****************************************************************************
* Name: sam_portread
*
* Description:
* Read one or zero from the selected PORT pin
*
****************************************************************************/
bool sam_portread(port_pinset_t pinset);
/****************************************************************************
* Function: sam_dumpport
*
* Description:
* Dump all PORT registers associated with the provided pin description
* along with a descriptive message.
*
****************************************************************************/
#ifdef CONFIG_DEBUG_GPIO_INFO
int sam_dumpport(port_pinset_t pinset, const char *msg);
#else
# define sam_dumpport(p,m)
#endif
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_SRC_SAMD5E5_SAM_PORT_H */

View File

@ -0,0 +1,267 @@
/****************************************************************************
* arch/arm/src/samd5e5/sam_sercom.c
*
* Copyright (C) 2018 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <assert.h>
#include "up_arch.h"
#include "sam_config.h"
#include "sam_pm.h"
#include "sam_gclk.h"
#include "sam_sercom.h"
#include <arch/board/board.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#undef HAVE_SERCOM0_4
#if defined(CONFIG_SAMD5E5_SERCOM0) || defined(CONFIG_SAMD5E5_SERCOM1) || \
defined(CONFIG_SAMD5E5_SERCOM2) || defined(CONFIG_SAMD5E5_SERCOM3) || \
defined(CONFIG_SAMD5E5_SERCOM4)
# define HAVE_SERCOM0_4
#endif
/****************************************************************************
* Private Data
****************************************************************************/
static bool g_slowclk_configured = false;
#ifdef CONFIG_DEBUG_ASSERTIONS
static uint8_t g_slowclk_gclkgen = 0xff;
#endif
static const uint8_t g_corclk_channel[SAMD5E5_NSERCOM] =
{
GCLK_CHAN_SERCOM0_CORE
#if SAMD5E5_NSERCOM > 1
, GCLK_CHAN_SERCOM1_CORE
#endif
#if SAMD5E5_NSERCOM > 2
, GCLK_CHAN_SERCOM2_CORE
#endif
#if SAMD5E5_NSERCOM > 3
, GCLK_CHAN_SERCOM3_CORE
#endif
#if SAMD5E5_NSERCOM > 4
, GCLK_CHAN_SERCOM4_CORE
#endif
#if SAMD5E5_NSERCOM > 5
, GCLK_CHAN_SERCOM5_CORE
#endif
#if SAMD5E5_NSERCOM > 6
, GCLK_CHAN_SERCOM6_CORE
#endif
#if SAMD5E5_NSERCOM > 7
, GCLK_CHAN_SERCOM7_CORE
#endif
};
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sercom_enable
*
* Description:
* Enable clocking to a SERCOM module
*
* Assumptions/Limitation:
* This operation is global and atomic. Interrupts will be masked.
*
****************************************************************************/
void sercom_enable(int sercom)
{
DEBUGASSERT((unsigned)sercom < SAMD5E5_NSERCOM);
switch (sercom)
{
case 0:
sam_apb_sercom0_enableperiph();
break;
case 1:
sam_apb_sercom1_enableperiph();
break;
case 2:
sam_apb_sercom2_enableperiph();
break;
case 3:
sam_apb_sercom3_enableperiph();
break;
case 4:
sam_apb_sercom4_enableperiph();
break;
case 5:
sam_apb_sercom5_enableperiph();
break;
case 6:
sam_apb_sercom6_enableperiph();
break;
case 7:
sam_apb_sercom7_enableperiph();
break;
default:
break;
}
}
/****************************************************************************
* Name: sercom_coreclk_configure
*
* Description:
* Configure the SERCOM core source clock.
*
* Two generic clocks are used by the SERCOM: GCLK_SERCOMx_CORE and
* GCLK_SERCOM_SLOW. The core clock (GCLK_SERCOMx_CORE) is required to
* clock the SERCOM while operating as a master, while the slow clock
* (GCLK_SERCOM_SLOW) is only required for certain functions. SERCOM
* modules must share the same slow GCLK channel ID.
*
* The baud-rate generator runs off the GCLK_SERCOMx_CORE clock (or,
* optionally, external clock).
*
****************************************************************************/
void sercom_coreclk_configure(int sercom, int gclkgen, bool wrlock)
{
uint16_t regval;
uint8_t gclkcore;
DEBUGASSERT((unsigned)sercom < SAMD5E5_NSERCOM);
/* Set up the SERCOMn_GCLK_ID_CORE clock */
gclkcore = g_corclk_channel[sercom];
regval = ((uint16_t)gclkcore << GCLK_CLKCTRL_ID_SHIFT);
/* Select and disable the SERCOMn_GCLK_ID_CORE generic clock */
putreg16(regval, SAM_GCLK_CLKCTRL);
/* Wait for clock to become disabled */
while ((getreg16(SAM_GCLK_CLKCTRL) & GCLK_CLKCTRL_CLKEN) != 0);
/* Select the SERCOMn_GCLK_ID_CORE source clock generator */
regval |= (uint16_t)gclkgen << GCLK_CLKCTRL_GEN_SHIFT;
/* Write the new configuration */
putreg16(regval, SAM_GCLK_CLKCTRL);
/* Enable the SERCOMn_GCLK_ID_CORE generic clock, optionally locking
* further writes to this GCLK.
*/
regval |= GCLK_CLKCTRL_CLKEN;
if (wrlock)
{
regval |= GCLK_CLKCTRL_WRTLOCK;
}
putreg16(regval, SAM_GCLK_CLKCTRL);
}
/****************************************************************************
* Name: sercom_slowclk_configure
*
* Description:
* Configure the SERCOM slow source clock.
*
* Two generic clocks are used by the SERCOM: GCLK_SERCOMx_CORE and
* GCLK_SERCOM_SLOW. The core clock (GCLK_SERCOMx_CORE) is required to
* clock the SERCOM while operating as a master, while the slow clock
* (GCLK_SERCOM_SLOW) is only required for certain functions. SERCOM
* modules must share the same slow GCLK channel ID.
*
****************************************************************************/
void sercom_slowclk_configure(int sercom, int gclkgen)
{
DEBUGASSERT((unsigned)sercom < SAMD5E5_NSERCOM);
/* Setup the SERCOMn_GCLK channel. */
if (!g_slowclk_configured)
{
/* Configure the slow clock channel. The slow clock is shared for all
* of SERCOM modules and, hence, only need to configured once.
*/
sam_apb_gclk_chan_enable(GCLK_CHAN_SERCOMn_SLOW, gclkgen);
/* The slow clock is now configured and should not be re=configured
* again.
*/
g_slowclk_configured = true;
#ifdef CONFIG_DEBUG_ASSERTIONS
g_slowclk_gclkgen = (uint8_t)gclkgen;
#endif
}
#ifdef CONFIG_DEBUG_ASSERTIONS
/* Already g_slowclk_configured. This is okay provided that the same GCLK
* generator is being used. Otherwise, there is a problem.
*/
else
{
DEBUGASSERT((int)g_slowclk_gclkgen == gclkgen);
}
#endif
}

View File

@ -0,0 +1,132 @@
/****************************************************************************
* arch/arm/src/samd5e5/sam_sercom.h
*
* Copyright (C) 2018 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_SAMD5E5_SAM_SERCOM_H
#define __ARCH_ARM_SRC_SAMD5E5_SAM_SERCOM_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdbool.h>
#include "up_arch.h"
#include "sam_config.h"
#include "sam_periphclks.h"
#include "chip/sam_sercom.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/****************************************************************************
* Public Function Prototypes
****************************************************************************/
/****************************************************************************
* Name: sercom_enable
*
* Description:
* Enable clocking to a SERCOM module
*
* Assumptions/Limitation:
* This operation is global and atomic. Interrupts will be masked.
*
****************************************************************************/
void sercom_enable(int sercom);
/****************************************************************************
* Name: sercom_coreclk_configure
*
* Description:
* Configure the SERCOM core source clock.
*
* Two generic clocks are used by the SERCOM: GCLK_SERCOMx_CORE and
* GCLK_SERCOMx_SLOW. The core clock (GCLK_SERCOMx_CORE) is required to
* clock the SERCOM while operating as a master, while the slow clock
* (GCLK_SERCOM_SLOW) is only required for certain functions. SERCOM
* modules must share the same slow GCLK channel ID.
*
* The baud-rate generator runs off the GCLK_SERCOMx_CORE clock (or,
* optionally, an external clock).
*
****************************************************************************/
void sercom_coreclk_configure(int sercom, int gclkgen, bool wrlock);
/****************************************************************************
* Name: sercom_slowclk_configure
*
* Description:
* Configure the SERCOM slow source clock.
*
* Two generic clocks are used by the SERCOM: GCLK_SERCOMx_CORE and
* GCLK_SERCOMx_SLOW. The core clock (GCLK_SERCOMx_CORE) is required to
* clock the SERCOM while operating as a master, while the slow clock
* (GCLK_SERCOM_SLOW) is only required for certain functions. SERCOM
* modules must share the same slow GCLK channel ID.
*
****************************************************************************/
void sercom_slowclk_configure(int sercom, int gclkgen);
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_SRC_SAMD5E5_SAM_SERCOM_H */

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,67 @@
/****************************************************************************
* arch/arm/src/samd5e5/sam_serial.h
*
* Copyright (C) 2018 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_SAMD5E5_SAM_SERIAL_H
#define __ARCH_ARM_SRC_SAMD5E5_SAM_SERIAL_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include "sam_config.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
/****************************************************************************
* Inline Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
#endif /* __ARCH_ARM_SRC_SAMD5E5_SAM_SERIAL_H */

View File

@ -0,0 +1,375 @@
/****************************************************************************
* arch/arm/src/samd5e5/sam_start.c
*
* Copyright (C) 2018 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <assert.h>
#include <debug.h>
#include <nuttx/init.h>
#include "up_arch.h"
#include "up_internal.h"
#include "sam_clockconfig.h"
#include "sam_lowputc.h"
#include "sam_cmcc.h"
#include "sam_userspace.h"
#ifdef CONFIG_ARCH_FPU
# include "nvic.h"
#endif
#include "sam_start.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* .data is positioned first in the primary RAM followed immediately by .bss.
* The IDLE thread stack lies just after .bss and has size give by
* CONFIG_IDLETHREAD_STACKSIZE; The heap then begins just after the IDLE.
* ARM EABI requires 64 bit stack alignment.
*/
#define IDLE_STACKSIZE (CONFIG_IDLETHREAD_STACKSIZE & ~7)
#define IDLE_STACK ((uintptr_t)&_ebss + IDLE_STACKSIZE)
#define HEAP_BASE ((uintptr_t)&_ebss + IDLE_STACKSIZE)
/****************************************************************************
* Public Data
****************************************************************************/
/* g_idle_topstack: _sbss is the start of the BSS region as defined by the
* linker script. _ebss lies at the end of the BSS region. The idle task
* stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE.
* The IDLE thread is the thread that the system boots on and, eventually,
* becomes the IDLE, do nothing task that runs only when there is nothing
* else to run. The heap continues from there until the end of memory.
* g_idle_topstack is a read-only variable the provides this computed
* address.
*/
const uintptr_t g_idle_topstack = HEAP_BASE;
/****************************************************************************
* Private Function prototypes
****************************************************************************/
#ifdef CONFIG_ARCH_FPU
static inline void sam_fpuconfig(void);
#endif
#ifdef CONFIG_STACK_COLORATION
static void go_os_start(void *pv, unsigned int nbytes)
__attribute__ ((naked, no_instrument_function, noreturn));
#endif
#ifdef CONFIG_ARMV7M_STACKCHECK
/* We need to get r10 set before we can allow instrumentation calls */
void __start(void) __attribute__ ((no_instrument_function));
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: showprogress
*
* Description:
* Print a character on the UART to show boot status.
*
****************************************************************************/
#ifdef CONFIG_DEBUG_FEATURES
# define showprogress(c) up_lowputc(c)
#else
# define showprogress(c)
#endif
/****************************************************************************
* Name: sam_fpuconfig
*
* Description:
* Configure the FPU. Relative bit settings:
*
* CPACR: Enables access to CP10 and CP11
* CONTROL.FPCA: Determines whether the FP extension is active in the
* current context:
* FPCCR.ASPEN: Enables automatic FP state preservation, then the
* processor sets this bit to 1 on successful completion of any FP
* instruction.
* FPCCR.LSPEN: Enables lazy context save of FP state. When this is
* done, the processor reserves space on the stack for the FP state,
* but does not save that state information to the stack.
*
* Software must not change the value of the ASPEN bit or LSPEN bit while either:
* - the CPACR permits access to CP10 and CP11, that give access to the FP
* extension, or
* - the CONTROL.FPCA bit is set to 1
*
****************************************************************************/
#ifdef CONFIG_ARCH_FPU
#ifndef CONFIG_ARMV7M_LAZYFPU
static inline void sam_fpuconfig(void)
{
uint32_t regval;
/* Set CONTROL.FPCA so that we always get the extended context frame
* with the volatile FP registers stacked above the basic context.
*/
regval = getcontrol();
regval |= (1 << 2);
setcontrol(regval);
/* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend
* with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we
* are going to turn on CONTROL.FPCA for all contexts.
*/
regval = getreg32(NVIC_FPCCR);
regval &= ~((1 << 31) | (1 << 30));
putreg32(regval, NVIC_FPCCR);
/* Enable full access to CP10 and CP11 */
regval = getreg32(NVIC_CPACR);
regval |= ((3 << (2*10)) | (3 << (2*11)));
putreg32(regval, NVIC_CPACR);
}
#else
static inline void sam_fpuconfig(void)
{
uint32_t regval;
/* Clear CONTROL.FPCA so that we do not get the extended context frame
* with the volatile FP registers stacked in the saved context.
*/
regval = getcontrol();
regval &= ~(1 << 2);
setcontrol(regval);
/* Ensure that FPCCR.LSPEN is disabled, so that we don't have to contend
* with the lazy FP context save behaviour. Clear FPCCR.ASPEN since we
* are going to keep CONTROL.FPCA off for all contexts.
*/
regval = getreg32(NVIC_FPCCR);
regval &= ~((1 << 31) | (1 << 30));
putreg32(regval, NVIC_FPCCR);
/* Enable full access to CP10 and CP11 */
regval = getreg32(NVIC_CPACR);
regval |= ((3 << (2*10)) | (3 << (2*11)));
putreg32(regval, NVIC_CPACR);
}
#endif
#else
# define sam_fpuconfig()
#endif
/****************************************************************************
* Name: go_os_start
*
* Description:
* Set the IDLE stack to the
*
****************************************************************************/
#ifdef CONFIG_STACK_COLORATION
static void go_os_start(void *pv, unsigned int nbytes)
{
/* Set the IDLE stack to the stack coloration value then jump to
* os_start(). We take extreme care here because were currently
* executing on this stack.
*
* We want to avoid sneak stack access generated by the compiler.
*/
__asm__ __volatile__
(
"\tmovs r1, r1, lsr #2\n" /* R1 = nwords = nbytes >> 2 */
"\tbeq 2f\n" /* (should not happen) */
"\tbic r0, r0, #3\n" /* R0 = Aligned stackptr */
"\tmovw r2, #0xbeef\n" /* R2 = STACK_COLOR = 0xdeadbeef */
"\tmovt r2, #0xdead\n"
"1:\n" /* Top of the loop */
"\tsub r1, r1, #1\n" /* R1 nwords-- */
"\tcmp r1, #0\n" /* Check (nwords == 0) */
"\tstr r2, [r0], #4\n" /* Save stack color word, increment stackptr */
"\tbne 1b\n" /* Bottom of the loop */
"2:\n"
"\tmov r14, #0\n" /* LR = return address (none) */
"\tb os_start\n" /* Branch to os_start */
);
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: _start
*
* Description:
* This is the reset entry point.
*
****************************************************************************/
void __start(void)
{
const uint32_t *src;
uint32_t *dest;
#ifdef CONFIG_ARMV7M_STACKCHECK
/* Set the stack limit before we attempt to call any functions */
__asm__ volatile ("sub r10, sp, %0" : : "r" (CONFIG_IDLETHREAD_STACKSIZE - 64) : );
#endif
/* Clear .bss. We'll do this inline (vs. calling memset) just to be
* certain that there are no issues with the state of global variables.
*/
for (dest = &_sbss; dest < &_ebss; )
{
*dest++ = 0;
}
/* Move the initialized data section from his temporary holding spot in
* FLASH into the correct place in SRAM. The correct place in SRAM is
* give by _sdata and _edata. The temporary location is in FLASH at the
* end of all of the other read-only data (.text, .rodata) at _eronly.
*/
for (src = &_eronly, dest = &_sdata; dest < &_edata; )
{
*dest++ = *src++;
}
/* Copy any necessary code sections from FLASH to RAM. The correct
* destination in SRAM is geive by _sramfuncs and _eramfuncs. The
* temporary location is in flash after the data initalization code
* at _framfuncs. This must be done before sam_clockconfig() can be
* called (at least for the SAM4L family).
*/
#ifdef CONFIG_ARCH_RAMFUNCS
for (src = &_framfuncs, dest = &_sramfuncs; dest < &_eramfuncs; )
{
*dest++ = *src++;
}
#endif
/* Configure the UART so that we can get debug output as soon as possible */
sam_clockconfig();
sam_fpuconfig();
sam_lowsetup();
showprogress('A');
/* Perform early serial initialization */
#ifdef USE_EARLYSERIALINIT
up_earlyserialinit();
#endif
showprogress('B');
/* For the case of the separate user-/kernel-space build, perform whatever
* platform specific initialization of the user memory is required.
* Normally this just means initializing the user space .data and .bss
* segements.
*/
#ifdef CONFIG_BUILD_PROTECTED
sam_userspace();
showprogress('C');
#endif
/* Initialize onboard resources */
sam_board_initialize();
showprogress('D');
#ifdef CONFIG_SAM34_CMCC
/* Enable the Cortex-M Cache
*
* REVISIT: This logic is complete but I have not yet tried to enable it.
* I have some questions about how the cache will effect memory mapped
* register accesses.
*/
sam_cmcc_enable();
#endif
/* Then start NuttX */
showprogress('\r');
showprogress('\n');
#ifdef CONFIG_STACK_COLORATION
/* Set the IDLE stack to the coloration value and jump into os_start() */
go_os_start((FAR void *)&_ebss, CONFIG_IDLETHREAD_STACKSIZE);
#else
/* Call os_start() */
os_start();
/* Shouldn't get here */
for (; ; );
#endif
}

View File

@ -0,0 +1,78 @@
/************************************************************************************
* arch/arm/src/samd5e5/sam_start.h
*
* Copyright (C) 2018 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_SAMD5E5_SAM_START_H
#define __ARCH_ARM_SRC_SAMD5E5_SAM_START_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
/************************************************************************************
* Public Data
************************************************************************************/
/* g_idle_topstack: _sbss is the start of the BSS region as defined by the
* linker script. _ebss lies at the end of the BSS region. The idle task
* stack starts at the end of BSS and is of size CONFIG_IDLETHREAD_STACKSIZE.
* The IDLE thread is the thread that the system boots on and, eventually,
* becomes the IDLE, do nothing task that runs only when there is nothing
* else to run. The heap continues from there until the end of memory.
* g_idle_topstack is a read-only variable the provides this computed
* address.
*/
extern const uintptr_t g_idle_topstack;
/************************************************************************************
* Public Function Prototypes
************************************************************************************/
/************************************************************************************
* Name: sam_board_initialize
*
* Description:
* All SAMD5/E5 architectures must provide the following entry point. This entry
* point is called early in the initialization -- after clocking and memory have
* been configured but before caches have been enabled and before any devices have
* been initialized.
*
************************************************************************************/
void sam_board_initialize(void);
#endif /* __ARCH_ARM_SRC_SAMD5E5_SAM_START_H */

View File

@ -0,0 +1,154 @@
/****************************************************************************
* arch/arm/src/samd5e5/sam_timerisr.c
*
* Copyright (C) 2018 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <time.h>
#include <debug.h>
#include <nuttx/arch.h>
#include <arch/irq.h>
#include "nvic.h"
#include "clock/clock.h"
#include "up_internal.h"
#include "up_arch.h"
#include <arch/board/board.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* The SysTick is driven by the CPU clock. */
#define SAM_SYSTICK_CLOCK BOARD_CPU_FREQUENCY /* CPU frequency */
/* The desired timer interrupt frequency is provided by the definition
* CLK_TCK (see include/time.h). CLK_TCK defines the desired number of
* system clock ticks per second. That value is a user configurable setting
* that defaults to 100 (100 ticks per second = 10 MS interval).
*/
#define SYSTICK_RELOAD ((SAM_SYSTICK_CLOCK / CLK_TCK) - 1)
/* The size of the reload field is 24 bits. Verify that the reload value
* will fit in the reload register.
*/
#if SYSTICK_RELOAD > 0x00ffffff
# error SYSTICK_RELOAD exceeds the range of the RELOAD register
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Function: sam_timerisr
*
* Description:
* The timer ISR will perform a variety of services for various portions
* of the systems.
*
****************************************************************************/
static int sam_timerisr(int irq, uint32_t *regs, void *arg)
{
/* Process timer interrupt */
sched_process_timer();
return 0;
}
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Function: arm_timer_initialize
*
* Description:
* This function is called during start-up to initialize the timer
* interrupt.
*
****************************************************************************/
void arm_timer_initialize(void)
{
uint32_t regval;
/* Set the SysTick interrupt to the default priority */
regval = getreg32(NVIC_SYSH12_15_PRIORITY);
regval &= ~NVIC_SYSH_PRIORITY_PR15_MASK;
regval |= (NVIC_SYSH_PRIORITY_DEFAULT << NVIC_SYSH_PRIORITY_PR15_SHIFT);
putreg32(regval, NVIC_SYSH12_15_PRIORITY);
/* Make sure that the SysTick clock source is set correctly */
#if 0 /* Does not work. Comes up with HCLK source and I can't change it */
regval = getreg32(NVIC_SYSTICK_CTRL);
#ifdef CONFIG_SAM34_SYSTICK_HCLKd8
regval &= ~NVIC_SYSTICK_CTRL_CLKSOURCE;
#else
regval |= NVIC_SYSTICK_CTRL_CLKSOURCE;
#endif
putreg32(regval, NVIC_SYSTICK_CTRL);
#endif
/* Configure SysTick to interrupt at the requested rate */
putreg32(SYSTICK_RELOAD, NVIC_SYSTICK_RELOAD);
putreg32(0, NVIC_SYSTICK_CURRENT);
/* Attach the timer interrupt vector */
(void)irq_attach(SAM_IRQ_SYSTICK, (xcpt_t)sam_timerisr, NULL);
/* Enable SysTick interrupts */
putreg32((NVIC_SYSTICK_CTRL_CLKSOURCE | NVIC_SYSTICK_CTRL_TICKINT |
NVIC_SYSTICK_CTRL_ENABLE), NVIC_SYSTICK_CTRL);
/* And enable the timer interrupt */
up_enable_irq(SAM_IRQ_SYSTICK);
}

View File

@ -0,0 +1,260 @@
/****************************************************************************
* arch/arm/src/samd5e5/sam_usart.c
*
* Copyright (C) 2018 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <assert.h>
#include <arch/samd5e5/chip.h>
#include "sam_pinmap.h"
#include "sam_gclk.h"
#include "sam_usart.h"
#include <arch/board/board.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Public Data
****************************************************************************/
#ifdef SAMD5E5_HAVE_USART0
const struct sam_usart_config_s g_usart0config =
{
.sercom = 0,
.parity = CONFIG_USART0_PARITY,
.bits = CONFIG_USART0_BITS,
.irq = SAM_IRQ_SERCOM0,
.gclkgen = BOARD_SERCOM0_GCLKGEN,
.slowgen = BOARD_SERCOM0_SLOW_GCLKGEN,
.stopbits2 = CONFIG_USART0_2STOP,
.baud = CONFIG_USART0_BAUD,
.pad0 = BOARD_SERCOM0_PINMAP_PAD0,
.pad1 = BOARD_SERCOM0_PINMAP_PAD1,
.pad2 = BOARD_SERCOM0_PINMAP_PAD2,
.pad3 = BOARD_SERCOM0_PINMAP_PAD3,
.muxconfig = BOARD_SERCOM0_MUXCONFIG,
.frequency = BOARD_SERCOM0_FREQUENCY,
.base = SAM_SERCOM0_BASE,
};
#endif
#ifdef SAMD5E5_HAVE_USART1
const struct sam_usart_config_s g_usart1config =
{
.sercom = 1,
.parity = CONFIG_USART1_PARITY,
.bits = CONFIG_USART1_BITS,
.irq = SAM_IRQ_SERCOM1,
.gclkgen = BOARD_SERCOM1_GCLKGEN,
.slowgen = BOARD_SERCOM1_SLOW_GCLKGEN,
.stopbits2 = CONFIG_USART1_2STOP,
.baud = CONFIG_USART1_BAUD,
.pad0 = BOARD_SERCOM1_PINMAP_PAD0,
.pad1 = BOARD_SERCOM1_PINMAP_PAD1,
.pad2 = BOARD_SERCOM1_PINMAP_PAD2,
.pad3 = BOARD_SERCOM1_PINMAP_PAD3,
.muxconfig = BOARD_SERCOM1_MUXCONFIG,
.frequency = BOARD_SERCOM1_FREQUENCY,
.base = SAM_SERCOM1_BASE,
};
#endif
#ifdef SAMD5E5_HAVE_USART2
const struct sam_usart_config_s g_usart2config =
{
.sercom = 2,
.parity = CONFIG_USART2_PARITY,
.bits = CONFIG_USART2_BITS,
.irq = SAM_IRQ_SERCOM2,
.gclkgen = BOARD_SERCOM2_GCLKGEN,
.slowgen = BOARD_SERCOM2_SLOW_GCLKGEN,
.stopbits2 = CONFIG_USART2_2STOP,
.baud = CONFIG_USART2_BAUD,
.pad0 = BOARD_SERCOM2_PINMAP_PAD0,
.pad1 = BOARD_SERCOM2_PINMAP_PAD1,
.pad2 = BOARD_SERCOM2_PINMAP_PAD2,
.pad3 = BOARD_SERCOM2_PINMAP_PAD3,
.muxconfig = BOARD_SERCOM2_MUXCONFIG,
.frequency = BOARD_SERCOM2_FREQUENCY,
.base = SAM_SERCOM2_BASE,
};
#endif
#ifdef SAMD5E5_HAVE_USART3
const struct sam_usart_config_s g_usart3config =
{
.sercom = 3,
.parity = CONFIG_USART3_PARITY,
.bits = CONFIG_USART3_BITS,
.irq = SAM_IRQ_SERCOM3,
.gclkgen = BOARD_SERCOM3_GCLKGEN,
.slowgen = BOARD_SERCOM3_SLOW_GCLKGEN,
.stopbits2 = CONFIG_USART3_2STOP,
.baud = CONFIG_USART3_BAUD,
.pad0 = BOARD_SERCOM3_PINMAP_PAD0,
.pad1 = BOARD_SERCOM3_PINMAP_PAD1,
.pad2 = BOARD_SERCOM3_PINMAP_PAD2,
.pad3 = BOARD_SERCOM3_PINMAP_PAD3,
.muxconfig = BOARD_SERCOM3_MUXCONFIG,
.frequency = BOARD_SERCOM3_FREQUENCY,
.base = SAM_SERCOM3_BASE,
};
#endif
#ifdef SAMD5E5_HAVE_USART4
const struct sam_usart_config_s g_usart4config =
{
.sercom = 4,
.parity = CONFIG_USART4_PARITY,
.bits = CONFIG_USART4_BITS,
.irq = SAM_IRQ_SERCOM4,
.gclkgen = BOARD_SERCOM4_GCLKGEN,
.slowgen = BOARD_SERCOM4_SLOW_GCLKGEN,
.stopbits2 = CONFIG_USART4_2STOP,
.baud = CONFIG_USART4_BAUD,
.pad0 = BOARD_SERCOM4_PINMAP_PAD0,
.pad1 = BOARD_SERCOM4_PINMAP_PAD1,
.pad2 = BOARD_SERCOM4_PINMAP_PAD2,
.pad3 = BOARD_SERCOM4_PINMAP_PAD3,
.muxconfig = BOARD_SERCOM4_MUXCONFIG,
.frequency = BOARD_SERCOM4_FREQUENCY,
.base = SAM_SERCOM4_BASE,
};
#endif
#ifdef SAMD5E5_HAVE_USART5
const struct sam_usart_config_s g_usart5config =
{
.sercom = 5,
.parity = CONFIG_USART5_PARITY,
.bits = CONFIG_USART5_BITS,
.irq = SAM_IRQ_SERCOM5,
.gclkgen = BOARD_SERCOM5_GCLKGEN,
.slowgen = BOARD_SERCOM5_SLOW_GCLKGEN,
.stopbits2 = CONFIG_USART5_2STOP,
.baud = CONFIG_USART5_BAUD,
.pad0 = BOARD_SERCOM5_PINMAP_PAD0,
.pad1 = BOARD_SERCOM5_PINMAP_PAD1,
.pad2 = BOARD_SERCOM5_PINMAP_PAD2,
.pad3 = BOARD_SERCOM5_PINMAP_PAD3,
.muxconfig = BOARD_SERCOM5_MUXCONFIG,
.frequency = BOARD_SERCOM5_FREQUENCY,
.base = SAM_SERCOM5_BASE,
};
#endif
const struct sam_usart_config_s *g_usartconfig[SAMD5E5_NSERCOM] =
{
#if SAMD5E5_NSERCOM > 0
#ifdef SAMD5E5_HAVE_USART0
&g_usart0config,
#else
(const struct sam_usart_config_s *)0,
#endif
#endif
#if SAMD5E5_NSERCOM > 1
#ifdef SAMD5E5_HAVE_USART1
&g_usart1config,
#else
(const struct sam_usart_config_s *)0,
#endif
#endif
#if SAMD5E5_NSERCOM > 2
#ifdef SAMD5E5_HAVE_USART2
&g_usart2config,
#else
(const struct sam_usart_config_s *)0,
#endif
#endif
#if SAMD5E5_NSERCOM > 3
#ifdef SAMD5E5_HAVE_USART3
&g_usart3config,
#else
(const struct sam_usart_config_s *)0,
#endif
#endif
#if SAMD5E5_NSERCOM > 4
#ifdef SAMD5E5_HAVE_USART4
&g_usart4config,
#else
(const struct sam_usart_config_s *)0,
#endif
#endif
#if SAMD5E5_NSERCOM > 5
#ifdef SAMD5E5_HAVE_USART5
&g_usart5config,
#else
(const struct sam_usart_config_s *)0,
#endif
#endif
#if SAMD5E5_NSERCOM > 6
#ifdef SAMD5E5_HAVE_USART6
&g_usart6config,
#else
(const struct sam_usart_config_s *)0,
#endif
#endif
#if SAMD5E5_NSERCOM > 7
#ifdef SAMD5E5_HAVE_USART6
&g_usart7config,
#else
(const struct sam_usart_config_s *)0,
#endif
#endif
};
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/

View File

@ -0,0 +1,183 @@
/************************************************************************************
* arch/arm/src/samd5e5/sam_usart.h
*
* Copyright (C) 2018 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_SAMD5E5_SAM_USART_H
#define __ARCH_ARM_SRC_SAMD5E5_SAM_USART_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <arch/chip/chip.h>
#include "up_arch.h"
#include "chip.h"
#include "chip/sam_usart.h"
#include "sam_config.h"
#include "sam_port.h"
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* Pick the console USART configuration */
#if defined(CONFIG_USART0_SERIAL_CONSOLE)
# define g_consoleconfig (g_usart0config)
#elif defined(CONFIG_USART1_SERIAL_CONSOLE)
# define g_consoleconfig (g_usart1config)
#elif defined(CONFIG_USART2_SERIAL_CONSOLE)
# define g_consoleconfig (g_usart2config)
#elif defined(CONFIG_USART3_SERIAL_CONSOLE)
# define g_consoleconfig (g_usart3config)
#elif defined(CONFIG_USART4_SERIAL_CONSOLE)
# define g_consoleconfig (g_usart4config)
#elif defined(CONFIG_USART5_SERIAL_CONSOLE)
# define g_consoleconfig (g_usart5config)
#elif defined(CONFIG_USART6_SERIAL_CONSOLE)
# define g_consoleconfig (g_usart6config)
#elif defined(CONFIG_USART7_SERIAL_CONSOLE)
# define g_consoleconfig (g_usart7config)
#else
# undef g_consoleconfig
#endif
/************************************************************************************
* Public Types
************************************************************************************/
/* This structure describes the static configuration of a USART */
struct sam_usart_config_s
{
uint8_t sercom; /* Identifies the SERCOM peripheral */
uint8_t parity; /* 0=none, 1=odd, 2=even */
uint8_t bits; /* Number of bits (5-9) */
uint8_t irq; /* SERCOM IRQ number */
uint8_t gclkgen; /* Source GCLK generator */
uint8_t slowgen; /* Slow GCLK generator */
bool stopbits2; /* True: Configure with 2 stop bits instead of 1 */
uint32_t baud; /* Configured baud */
port_pinset_t pad0; /* Pin configuration for PAD0 */
port_pinset_t pad1; /* Pin configuration for PAD1 */
port_pinset_t pad2; /* Pin configuration for PAD2 */
port_pinset_t pad3; /* Pin configuration for PAD3 */
uint32_t muxconfig; /* Pad multiplexing configuration */
uint32_t frequency; /* Source clock frequency */
uintptr_t base; /* SERCOM base address */
};
/************************************************************************************
* Inline Functions
************************************************************************************/
/************************************************************************************
* Name: sam_wait_synchronization
*
* Description:
* Return true is the SERCOM USART reports that it is synchronizing.
*
***********************************************************************************/
#ifdef SAMD5E5_HAVE_USART
static inline bool usart_syncbusy(const struct sam_usart_config_s * const config)
{
return false;
}
#endif
/************************************************************************************
* Public Data
************************************************************************************/
#ifndef __ASSEMBLY__
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
#ifdef SAMD5E5_HAVE_USART0
EXTERN const struct sam_usart_config_s g_usart0config;
#endif
#ifdef SAMD5E5_HAVE_USART1
EXTERN const struct sam_usart_config_s g_usart1config;
#endif
#ifdef SAMD5E5_HAVE_USART2
EXTERN const struct sam_usart_config_s g_usart2config;
#endif
#ifdef SAMD5E5_HAVE_USART3
EXTERN const struct sam_usart_config_s g_usart3config;
#endif
#ifdef SAMD5E5_HAVE_USART4
EXTERN const struct sam_usart_config_s g_usart4config;
#endif
#ifdef SAMD5E5_HAVE_USART5
EXTERN const struct sam_usart_config_s g_usart5config;
#endif
#ifdef SAMD5E5_HAVE_USART6
EXTERN const struct sam_usart_config_s g_usart6config;
#endif
#ifdef SAMD5E5_HAVE_USART7
EXTERN const struct sam_usart_config_s g_usart7config;
#endif
EXTERN const struct sam_usart_config_s *g_usartconfig[SAMD5E5_NSERCOM];
/************************************************************************************
* Public Functions
************************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_SRC_SAMD5E5_SAM_USART_H */

View File

@ -0,0 +1,118 @@
/****************************************************************************
* arch/arm/src/samd5e5/sam_userspace.c
*
* Copyright (C) 2018 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <assert.h>
#include <nuttx/userspace.h>
#include "sam_mpuinit.h"
#include "sam_userspace.h"
#ifdef CONFIG_BUILD_PROTECTED
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sam_userspace
*
* Description:
* For the case of the separate user-/kernel-space build, perform whatever
* platform specific initialization of the user memory is required.
* Normally this just means initializing the user space .data and .bss
* segments.
*
****************************************************************************/
void sam_userspace(void)
{
uint8_t *src;
uint8_t *dest;
uint8_t *end;
/* Clear all of user-space .bss */
DEBUGASSERT(USERSPACE->us_bssstart != 0 && USERSPACE->us_bssend != 0 &&
USERSPACE->us_bssstart <= USERSPACE->us_bssend);
dest = (uint8_t *)USERSPACE->us_bssstart;
end = (uint8_t *)USERSPACE->us_bssend;
while (dest != end)
{
*dest++ = 0;
}
/* Initialize all of user-space .data */
DEBUGASSERT(USERSPACE->us_datasource != 0 &&
USERSPACE->us_datastart != 0 && USERSPACE->us_dataend != 0 &&
USERSPACE->us_datastart <= USERSPACE->us_dataend);
src = (uint8_t *)USERSPACE->us_datasource;
dest = (uint8_t *)USERSPACE->us_datastart;
end = (uint8_t *)USERSPACE->us_dataend;
while (dest != end)
{
*dest++ = *src++;
}
/* Configure the MPU to permit user-space access to its FLASH and RAM */
sam_mpuinitialize();
}
#endif /* CONFIG_BUILD_PROTECTED */

View File

@ -0,0 +1,105 @@
/************************************************************************************
* arch/arm/src/samd5e5/sam_userspace.h
*
* Copyright (C) 2018 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_SAMD5E5_SAM_USERSPACE_H
#define __ARCH_ARM_SRC_SAMD5E5_SAM_USERSPACE_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#include <nuttx/compiler.h>
#include <sys/types.h>
#include <stdint.h>
#include <stdbool.h>
#include "up_internal.h"
#include "chip.h"
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/************************************************************************************
* Public Types
************************************************************************************/
/************************************************************************************
* Inline Functions
************************************************************************************/
#ifndef __ASSEMBLY__
/************************************************************************************
* Public Data
************************************************************************************/
#undef EXTERN
#if defined(__cplusplus)
#define EXTERN extern "C"
extern "C"
{
#else
#define EXTERN extern
#endif
/************************************************************************************
* Public Function Prototypes
************************************************************************************/
/****************************************************************************
* Name: sam_userspace
*
* Description:
* For the case of the separate user-/kernel-space build, perform whatever
* platform specific initialization of the user memory is required.
* Normally this just means initializing the user space .data and .bss
* segments.
*
****************************************************************************/
#ifdef CONFIG_BUILD_PROTECTED
void sam_userspace(void);
#endif
#undef EXTERN
#if defined(__cplusplus)
}
#endif
#endif /* __ASSEMBLY__ */
#endif /* __ARCH_ARM_SRC_SAMD5E5_SAM_USERSPACE_H */

View File

@ -454,6 +454,16 @@ config ARCH_BOARD_MCU123_LPC214X
lpc214x development board. This OS is also built with the arm-nuttx-elf
toolchain*. The port supports serial, timer0, spi, and usb.
config ARCH_BOARD_METRO_M4
bool "Adafruit M4 Metro"
depends on ARCH_CHIP_SAMD51J19
select ARCH_HAVE_LEDS
---help---
---help---
This configuration is the port of NuttX to the Adafruit Metro M4.
The Metro M4 uses a Arduino form factor and and pinout. It's powered
with an ATSAMD51J19
config ARCH_BOARD_MICROPENDOUS3
bool "Opendous Micropendous 3 board"
depends on ARCH_CHIP_AT90USB646 || ARCH_CHIP_AT90USB647 || ARCH_CHIP_AT90USB1286 || ARCH_CHIP_AT90USB1287
@ -1691,6 +1701,7 @@ config ARCH_BOARD
default "mbed" if ARCH_BOARD_MBED
default "mcb1700" if ARCH_BOARD_MCB1700
default "mcu123-lpc214x" if ARCH_BOARD_MCU123_LPC214X
default "metro-m4" if ARCH_BOARD_METRO_M4
default "micropendous3" if ARCH_BOARD_MICROPENDOUS3
default "mirtoo" if ARCH_BOARD_MIRTOO
default "misoc" if ARCH_BOARD_MISOC
@ -1974,6 +1985,9 @@ endif
if ARCH_BOARD_MCU123_LPC214X
source "configs/mcu123-lpc214x/Kconfig"
endif
if ARCH_BOARD_METRO_M4
source "configs/metro-m4/Kconfig"
endif
if ARCH_BOARD_MICROPENDOUS3
source "configs/micropendous3/Kconfig"
endif

View File

@ -365,6 +365,11 @@ configs/mbed
configs/mcb1700
Board support for the Keil MCB1700
configs/metro-m4
Th configurations in this directory are part of the port of NuttX to the
Adafruit Metro M4. The Metro M4 uses a Arduino form factor and and pinout.
It's powered with an ATSAMD51J19
configs/mikroe-stm32f4
This is the port of NuttX to the MikroElektronika Mikromedia for STM32F4
development board. Contributed by Ken Petit.

7
configs/metro-m4/Kconfig Normal file
View File

@ -0,0 +1,7 @@
#
# For a description of the syntax of this configuration file,
# see the file kconfig-language.txt in the NuttX tools repository.
#
if ARCH_BOARD_METRO_M4
endif

View File

@ -0,0 +1,47 @@
README
======
This directory contains the port of NuttX to the Adafruit Metro M4. The
Metro M4 uses a Arduino form factor and and pinout. It's powered with an
ATSAMD51J19:
o Cortex M4 core running at 120 MHz
o Hardware DSP and floating point support
o 512 KB flash, 192 KB RAM
o 32-bit, 3.3V logic and power
o Dual 1 MSPS DAC (A0 and A1)
o Dual 1 MSPS ADC (8 analog pins)
o 6 x hardware SERCOM (I2C, SPI or UART)
o 16 x PWM outputs
o Stereo I2S input/output with MCK pin
o 10-bit Parallel capture controller (for camera/video in)
o Built in crypto engines with AES (256 bit), true RNG, Pubkey controller
o 64 QFN
Serial Console
==============
An Arduino compatible serial Shield is assumed (or equivalently, and
external RS-232 or serial-to-USB adapter connected on Arduino pins D0 and
D1):
------ ----------------- -----------
SHIELD SAMD5E5 FUNCTION
------ ----------------- -----------
D0 PA23 SERCOM3 PAD2 RXD
D1 PA22 SERCOM3 PAD0 TXD
LEDs
====
The Adafruit Metro M4 has four LEDs, but only two are controllable by software:
1. The red LED on the Arduino D13 pin, and
2. A NeoPixel RGB LED.
Currently, only the red LED is supported.
------ ----------------- -----------
SHIELD SAMD5E5 FUNCTION
------ ----------------- -----------
D13 PA16 GPIO output

View File

@ -0,0 +1,579 @@
/************************************************************************************
* configs/metro-m4/include/board.h
*
* Copyright (C) 2018 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 __CONFIG_METRO_M4_INCLUDE_BOARD_H
#define __CONFIG_METRO_M4_INCLUDE_BOARD_H
/************************************************************************************
* Included Files
************************************************************************************/
#include <nuttx/config.h>
#ifndef __ASSEMBLY__
# include <stdint.h>
# include <stdbool.h>
#endif
/************************************************************************************
* Pre-processor Definitions
************************************************************************************/
/* Clocking *************************************************************************/
/* Overview
*
* Since there is not high speed crystal, we will run from the OSC16M clock source.
* We will use its default, POR frequency of 4MHz to avoid an additional clock
* switch.
*
* OSC16M Output = 4MHz
* `- GCLK1 Input = 4MHz Prescaler = 1 output = 4MHz
* `- DFLL Input = 4MHz Multiplier = 12 output = 48MHz
* `- GCLK0 Input = 48MHz Prescaler = 1 output = 48MHz
* `- MCLK Input = 48Mhz CPU divider = 1 CPU frequency = 48MHz
* APBA divider = 1 APBA frequency = 48MHz
* APBB divider = 1 APBB frequency = 48MHz
* APBC divider = 1 APBC frequency = 48MHz
* APBD divider = 1 APBD frequency = 48MHz
* APBE divider = 1 APBE frequency = 48MHz
*
* The Adafruit Metro M4 has one on-board crystal:
*
* XC101 32.768KHz XOSC32
*
* REVISIT: Not currently used, may want to use as GCLK1 source with
* DFLL multiplier of ((48000000+16384)/32768) = 1465 which would yield
* a clock of 48,005,120 MHz.
*/
/* XOSC Configuration -- Not available
*
* BOARD_XOSC_ENABLE - Boolean (defined / not defined)
* BOARD_XOSC_FREQUENCY - In Hz
* BOARD_XOSC_STARTUPTIME - See SYSCTRL_XOSC_STARTUP_* definitions
* BOARD_XOSC_ISCRYSTAL - Boolean (defined / not defined)
* BOARD_XOSC_AMPGC - Boolean (defined / not defined)
* BOARD_XOSC_ONDEMAND - Boolean (defined / not defined)
* BOARD_XOSC_RUNINSTANDBY - Boolean (defined / not defined)
*/
#undef BOARD_XOSC_ENABLE
#define BOARD_XOSC_FREQUENCY 12000000UL
#define BOARD_XOSC_STARTUPTIME SYSCTRL_XOSC_STARTUP_1S
#define BOARD_XOSC_ISCRYSTAL 1
#define BOARD_XOSC_AMPGC 1
#define BOARD_XOSC_ONDEMAND 1
#undef BOARD_XOSC_RUNINSTANDBY
/* XOSC32 Configuration -- Not used
*
* BOARD_XOSC32K_ENABLE - Boolean (defined / not defined)
* BOARD_XOSC32K_FREQUENCY - In Hz
* BOARD_XOSC32K_STARTUPTIME - See SYSCTRL_XOSC32K_STARTUP_* definitions
* BOARD_XOSC32K_ISCRYSTAL - Boolean (defined / not defined)
* BOARD_XOSC32K_AAMPEN - Boolean (defined / not defined)
* BOARD_XOSC32K_EN1KHZ - Boolean (defined / not defined)
* BOARD_XOSC32K_EN32KHZ - Boolean (defined / not defined)
* BOARD_XOSC32K_ONDEMAND - Boolean (defined / not defined)
* BOARD_XOSC32K_RUNINSTANDBY - Boolean (defined / not defined)
* BOARD_XOSC32K_WRITELOCK - Boolean (defined / not defined)
*/
#undef BOARD_XOSC32K_ENABLE
#ifdef CONFIG_METRO_M4_XOSC32K
# define BOARD_XOSC32K_ENABLE 1
# define BOARD_XOSC32K_FREQUENCY 32768 /* 32.768KHz XTAL */
# define BOARD_XOSC32K_STARTUPTIME OSC32KCTRL_XOSC32K_STARTUP_100MS
# define BOARD_XOSC32K_ISCRYSTAL 1
# undef BOARD_XOSC32K_EN1KHZ
# define BOARD_XOSC32K_EN32KHZ 1
# define BOARD_XOSC32K_ONDEMAND 1
# undef BOARD_XOSC32K_RUNINSTANDBY
# undef BOARD_XOSC32K_WRITELOCK
#endif
/* OSC32 Configuration -- not used
*
* BOARD_OSC32K_ENABLE - Boolean (defined / not defined)
* BOARD_OSC32K_FREQUENCY - In Hz
* BOARD_OSC32K_STARTUPTIME - See SYSCTRL_OSC32K_STARTUP_* definitions
* BOARD_OSC32K_EN1KHZ - Boolean (defined / not defined)
* BOARD_OSC32K_EN32KHZ - Boolean (defined / not defined)
* BOARD_OSC32K_ONDEMAND - Boolean (defined / not defined)
* BOARD_OSC32K_RUNINSTANDBY - Boolean (defined / not defined)
* BOARD_OSC32K_WRITELOCK - Boolean (defined / not defined)
*/
#undef BOARD_OSC32K_ENABLE
#define BOARD_OSC32K_FREQUENCY 32768 /* 32.768kHz internal oscillator */
#define BOARD_OSC32K_STARTUPTIME SYSCTRL_OSC32K_STARTUP_4MS
#define BOARD_OSC32K_EN1KHZ 1
#define BOARD_OSC32K_EN32KHZ 1
#define BOARD_OSC32K_ONDEMAND 1
#undef BOARD_OSC32K_RUNINSTANDBY
#undef BOARD_OSC32K_WRITELOCK
/* OSC16M Configuration -- always enabled
*
* BOARD_OSC16M_FSEL - See OSCCTRL_OSC16MCTRL_FSEL_* definitions
* BOARD_OSC16M_ONDEMAND - Boolean (defined / not defined)
* BOARD_OSC16M_RUNINSTANDBY - Boolean (defined / not defined)
*/
#if defined(CONFIG_METRO_M4_OSC16M_4MHZ)
# define BOARD_OSC16M_FSEL OSCCTRL_OSC16MCTRL_FSEL_4MHZ
# define BOARD_OSC16M_ONDEMAND 1
# undef BOARD_OSC16M_RUNINSTANDBY
# define BOARD_OSC16M_FREQUENCY 4000000 /* 4MHz high-accuracy internal oscillator */
#elif defined(CONFIG_METRO_M4_OSC16M_8MHZ)
# define BOARD_OSC16M_FSEL OSCCTRL_OSC16MCTRL_FSEL_8MHZ
# define BOARD_OSC16M_ONDEMAND 1
# undef BOARD_OSC16M_RUNINSTANDBY
# define BOARD_OSC16M_FREQUENCY 8000000 /* 8MHz high-accuracy internal oscillator */
#elif defined(CONFIG_METRO_M4_OSC16M_12MHZ)
# define BOARD_OSC16M_FSEL OSCCTRL_OSC16MCTRL_FSEL_12MHZ
# define BOARD_OSC16M_ONDEMAND 1
# undef BOARD_OSC16M_RUNINSTANDBY
# define BOARD_OSC16M_FREQUENCY 12000000 /* 12MHz high-accuracy internal oscillator */
#elif defined(CONFIG_METRO_M4_OSC16M_16MHZ)
# define BOARD_OSC16M_FSEL OSCCTRL_OSC16MCTRL_FSEL_16MHZ
# define BOARD_OSC16M_ONDEMAND 1
# undef BOARD_OSC16M_RUNINSTANDBY
# define BOARD_OSC16M_FREQUENCY 16000000 /* 18MHz high-accuracy internal oscillator */
#else
# error OSC16M operating freqency not defined (CONFIG_METRO_M4_OSC16M_*MHZ)
#endif
/* OSCULP32K Configuration -- not used. */
#define BOARD_OSCULP32K_FREQUENCY 32000 /* 32kHz ultra-low-power internal oscillator */
/* Digital Frequency Locked Loop configuration. In closed-loop mode, the
* DFLL output frequency (Fdfll) is given by:
*
* Fdfll = DFLLmul * Frefclk
* = 12 * 4000000 = 48MHz
*
* Where the reference clock is Generic Clock Channel 0 output of GLCK1.
* GCLCK1 provides OSC16M, undivided.
*
* When operating in open-loop mode, the output frequency of the DFLL will
* be determined by the values written to the DFLL Coarse Value bit group
* and the DFLL Fine Value bit group in the DFLL Value register.
*
* BOARD_DFLL48M_CLOSEDLOOP - Boolean (defined / not defined)
* BOARD_DFLL48M_OPENLOOP - Boolean (defined / not defined)
* BOARD_DFLL48M_RECOVERY - Boolean (defined / not defined)
* BOARD_DFLL48M_TRACKAFTERFINELOCK - Boolean (defined / not defined)
* BOARD_DFLL48M_KEEPLOCKONWAKEUP - Boolean (defined / not defined)
* BOARD_DFLL48M_ENABLECHILLCYCLE - Boolean (defined / not defined)
* BOARD_DFLL48M_QUICKLOCK - Boolean (defined / not defined)
* BOARD_DFLL48M_RUNINSTDBY - Boolean (defined / not defined)
* BOARD_DFLL48M_ONDEMAND - Boolean (defined / not defined)
* BOARD_DFLL48M_COARSEVALUE - Value
* BOARD_DFLL48M_FINEVALUE - Value
*
* Open Loop mode only:
* BOARD_DFLL48M_COARSEVALUE - Value
* BOARD_DFLL48M_FINEVALUE - Value
*
* Closed loop mode only:
* BOARD_DFLL48M_REFCLK_CLKGEN - GCLK index in the range {0..8}
* BOARD_DFLL48M_MULTIPLIER - Value
* BOARD_DFLL48M_MAXCOARSESTEP - Value
* BOARD_DFLL48M_MAXFINESTEP - Value
*
* BOARD_DFLL48M_FREQUENCY - The resulting frequency
*/
#undef BOARD_DFLL48M_ENABLE 1 /* Assume not using the DFLL48M */
#undef BOARD_DFLL48M_CLOSEDLOOP
#undef BOARD_DFLL48M_OPENLOOP
#undef BOARD_DFLL48M_RECOVERY
#ifdef CONFIG_METRO_M4_DFLL
# define BOARD_DFLL48M_ENABLE 1 /* Using the DFLL48M */
/* DFLL mode of operation */
# if defined(CONFIG_METRO_M4_DFLL_OPENLOOP)
# define BOARD_DFLL48M_OPENLOOP 1 /* In open loop mode */
# elif defined(CONFIG_METRO_M4_DFLL_CLOSEDLOOP)
# define BOARD_DFLL48M_CLOSEDLOOP 1 /* In closed loop mode */
# elif defined(CONFIG_METRO_M4_DFLL_RECOVERY)
# define BOARD_DFLL48M_RECOVERY 1 /* In USB recover mode */
# else
# error DFLL mode not provided
# endif
/* DFLL source clock selection */
# if defined(CONFIG_METRO_M4_DFLL_OSC16MSRC)
# define BOARD_DFLL_SRC_FREQUENCY BOARD_OSC16M_FREQUENCY
# elif defined(CONFIG_METRO_M4_DFLL_XOSC32KSRC)
# define BOARD_DFLL_SRC_FREQUENCY BOARD_XOSC32K_FREQUENCY
# else
# error DFLL clock source not provided
# endif
/* Mode-independent options */
# undef BOARD_DFLL48M_RUNINSTDBY
# undef BOARD_DFLL48M_ONDEMAND
/* DFLL open loop mode configuration */
# define BOARD_DFLL48M_COARSEVALUE (0x1f / 4)
# define BOARD_DFLL48M_FINEVALUE (0xff / 4)
/* DFLL closed loop mode configuration */
# define BOARD_DFLL48M_REFCLK_CLKGEN 1
# define BOARD_DFLL48M_MULTIPLIER (48000000 / BOARD_DFLL_SRC_FREQUENCY)
# define BOARD_DFLL48M_QUICKLOCK 1
# define BOARD_DFLL48M_TRACKAFTERFINELOCK 1
# define BOARD_DFLL48M_KEEPLOCKONWAKEUP 1
# define BOARD_DFLL48M_ENABLECHILLCYCLE 1
# define BOARD_DFLL48M_MAXCOARSESTEP (0x1f / 4)
# define BOARD_DFLL48M_MAXFINESTEP (0xff / 4)
# ifdef CONFIG_METRO_M4_DFLL_OPENLOOP
# define BOARD_DFLL48M_FREQUENCY (13720000) /* REVISIT: Needs to be measured */
# else
# define BOARD_DFLL48M_FREQUENCY (BOARD_DFLL48M_MULTIPLIER * BOARD_DFLL_SRC_FREQUENCY)
# endif
#endif
/* Fractional Digital Phase Locked Loop configuration.
*
* BOARD_FDPLL96M_ENABLE - Boolean (defined / not defined)
* BOARD_FDPLL96M_RUNINSTDBY - Boolean (defined / not defined)
* BOARD_FDPLL96M_ONDEMAND - Boolean (defined / not defined)
* BOARD_FDPLL96M_LBYPASS - Boolean (defined / not defined)
* BOARD_FDPLL96M_WUF - Boolean (defined / not defined)
* BOARD_FDPLL96M_LPEN - Boolean (defined / not defined)
* BOARD_FDPLL96M_FILTER - See OSCCTRL_DPLLCTRLB_FILTER_* definitions
* BOARD_FDPLL96M_REFCLK - See OSCCTRL_DPLLCTRLB_REFLCK_* definitions
* BOARD_FDPLL96M_REFCLK_CLKGEN - GCLK index in the range {0..8}
* BOARD_FDPLL96M_LOCKTIME_ENABLE - Boolean (defined / not defined)
* BOARD_FDPLL96M_LOCKTIME - See OSCCTRL_DPLLCTRLB_LTIME_* definitions
* BOARD_FDPLL96M_LOCKTIME_CLKGEN - GCLK index in the range {0..8}
* BOARD_FDPLL96M_REFDIV - Numeric value, 1 - 2047
* BOARD_FDPLL96M_PRESCALER - See OSCCTRL_DPLLPRESC_* definitions
* BOARD_FDPLL96M_REFFREQ - Numeric value
* BOARD_FDPLL96M_FREQUENCY - Numeric value
*/
#undef BOARD_FDPLL96M_ENABLE
#undef BOARD_FDPLL96M_RUNINSTDBY
#define BOARD_FDPLL96M_ONDEMAND 1
#undef BOARD_FDPLL96M_LBYPASS
#undef BOARD_FDPLL96M_WUF
#undef BOARD_FDPLL96M_LPEN
#define BOARD_FDPLL96M_FILTER OSCCTRL_DPLLCTRLB_FILTER_DEFAULT
#define BOARD_FDPLL96M_REFCLK OSCCTRL_DPLLCTRLB_REFLCK_XOSCK32K
#define BOARD_FDPLL96M_REFCLK_CLKGEN 1
#undef BOARD_FDPLL96M_LOCKTIME_ENABLE
#define BOARD_FDPLL96M_LOCKTIME OSCCTRL_DPLLCTRLB_LTIME_NONE
#define BOARD_FDPLL96M_LOCKTIME_CLKGEN 1
#define BOARD_FDPLL96M_REFDIV 1
#define BOARD_FDPLL96M_PRESCALER OSCCTRL_DPLLPRESC_DIV1
#define BOARD_FDPLL96M_REFFREQ 32768
#define BOARD_FDPLL96M_FREQUENCY 48000000
/* GCLK Configuration
*
* Global enable/disable.
*
* BOARD_GCLK_ENABLE - *MUST* be defined
*
* For n=1-7:
* BOARD_GCLKn_ENABLE - Boolean (defined / not defined)
*
* For n=0-8:
* BOARD_GCLKn_RUN_IN_STANDBY - Boolean (defined / not defined)
* BOARD_GCLKn_CLOCK_SOURCE - See GCLK_GENCTRL_SRC_* definitions
* BOARD_GCLKn_PRESCALER - Value
* BOARD_GCLKn_OUTPUT_ENABLE - Boolean (defined / not defined)
*/
#define BOARD_GCLK_ENABLE 1
/* GCLK generator 0 (Main Clock) - Source is the DFLL */
#ifdef CONFIG_METRO_M4_DFLL
# undef BOARD_GCLK0_RUN_IN_STANDBY
# define BOARD_GCLK0_CLOCK_SOURCE GCLK_GENCTRL_SRC_DFLL48M
# define BOARD_GCLK0_PRESCALER 1
# undef BOARD_GCLK0_OUTPUT_ENABLE
# define BOARD_GCLK0_FREQUENCY (BOARD_DFLL48M_FREQUENCY / BOARD_GCLK0_PRESCALER)
#else
# undef BOARD_GCLK0_RUN_IN_STANDBY
# define BOARD_GCLK0_CLOCK_SOURCE GCLK_GENCTRL_SRC_OSC16M
# define BOARD_GCLK0_PRESCALER 1
# undef BOARD_GCLK0_OUTPUT_ENABLE
# define BOARD_GCLK0_FREQUENCY (BOARD_OSC16M_FREQUENCY / BOARD_GCLK0_PRESCALER)
#endif
/* Configure GCLK generator 1 - Drives the DFLL */
#if defined(CONFIG_METRO_M4_DFLL_OSC16MSRC)
# define BOARD_GCLK1_ENABLE 1
# undef BOARD_GCLK1_RUN_IN_STANDBY
# define BOARD_GCLK1_CLOCK_SOURCE GCLK_GENCTRL_SRC_OSC16M
# define BOARD_GCLK1_PRESCALER 1
# undef BOARD_GCLK1_OUTPUT_ENABLE
# define BOARD_GCLK1_FREQUENCY (BOARD_OSC16M_FREQUENCY / BOARD_GCLK1_PRESCALER)
#elif defined(CONFIG_METRO_M4_DFLL_XOSC32KSRC)
# define BOARD_GCLK1_ENABLE 1
# undef BOARD_GCLK1_RUN_IN_STANDBY
# define BOARD_GCLK1_CLOCK_SOURCE GCLK_GENCTRL_SRC_XOSC32K
# define BOARD_GCLK1_PRESCALER 1
# undef BOARD_GCLK1_OUTPUT_ENABLE
# define BOARD_GCLK1_FREQUENCY (BOARD_XOSC32K_FREQUENCY / BOARD_GCLK1_PRESCALER)
#else
# error DFLL clock source not provided
#endif
/* Configure GCLK generator 2 (RTC) */
#undef BOARD_GCLK2_ENABLE
#undef BOARD_GCLK2_RUN_IN_STANDBY
#define BOARD_GCLK2_CLOCK_SOURCE GCLK_GENCTRL_SRC_OSC32K
#define BOARD_GCLK2_PRESCALER 32
#undef BOARD_GCLK2_OUTPUT_ENABLE
#define BOARD_GCLK2_FREQUENCY (BOARD_OSC32K_FREQUENCY / BOARD_GCLK2_PRESCALER)
/* Configure GCLK generator 3 */
#undef BOARD_GCLK3_ENABLE
#undef BOARD_GCLK3_RUN_IN_STANDBY
#define BOARD_GCLK3_CLOCK_SOURCE GCLK_GENCTRL_SRC_OSC16M
#define BOARD_GCLK3_PRESCALER 1
#undef BOARD_GCLK3_OUTPUT_ENABLE
#define BOARD_GCLK3_FREQUENCY (BOARD_OSC16M_FREQUENCY / BOARD_GCLK3_PRESCALER)
/* Configure GCLK generator 4 */
#undef BOARD_GCLK4_ENABLE
#undef BOARD_GCLK4_RUN_IN_STANDBY
#define BOARD_GCLK4_CLOCK_SOURCE GCLK_GENCTRL_SRC_OSC16M
#define BOARD_GCLK4_PRESCALER 1
#undef BOARD_GCLK4_OUTPUT_ENABLE
#define BOARD_GCLK4_FREQUENCY (BOARD_OSC16M_FREQUENCY / BOARD_GCLK4_PRESCALER)
/* Configure GCLK generator 5 */
#undef BOARD_GCLK5_ENABLE
#undef BOARD_GCLK5_RUN_IN_STANDBY
#define BOARD_GCLK5_CLOCK_SOURCE GCLK_GENCTRL_SRC_OSC16M
#define BOARD_GCLK5_PRESCALER 1
#undef BOARD_GCLK5_OUTPUT_ENABLE
#define BOARD_GCLK5_FREQUENCY (BOARD_OSC16M_FREQUENCY / BOARD_GCLK5_PRESCALER)
/* Configure GCLK generator 6 */
#undef BOARD_GCLK6_ENABLE
#undef BOARD_GCLK6_RUN_IN_STANDBY
#define BOARD_GCLK6_CLOCK_SOURCE GCLK_GENCTRL_SRC_OSC16M
#define BOARD_GCLK6_PRESCALER 1
#undef BOARD_GCLK6_OUTPUT_ENABLE
#define BOARD_GCLK6_FREQUENCY (BOARD_OSC16M_FREQUENCY / BOARD_GCLK6_PRESCALER)
/* Configure GCLK generator 7 */
#undef BOARD_GCLK7_ENABLE
#undef BOARD_GCLK7_RUN_IN_STANDBY
#define BOARD_GCLK7_CLOCK_SOURCE GCLK_GENCTRL_SRC_OSC16M
#define BOARD_GCLK7_PRESCALER 1
#undef BOARD_GCLK7_OUTPUT_ENABLE
#define BOARD_GCLK7_FREQUENCY (BOARD_OSC16M_FREQUENCY / BOARD_GCLK7_PRESCALER)
/* Configure GCLK generator 8 */
#undef BOARD_GCLK8_ENABLE
#undef BOARD_GCLK8_RUN_IN_STANDBY
#define BOARD_GCLK8_CLOCK_SOURCE GCLK_GENCTRL_SRC_OSC16M
#define BOARD_GCLK8_PRESCALER 1
#undef BOARD_GCLK8_OUTPUT_ENABLE
#define BOARD_GCLK8_FREQUENCY (BOARD_OSC16M_FREQUENCY / BOARD_GCLK8_PRESCALER)
/* The source of the main clock is always GCLK_MAIN. Also called GCLKGEN[0], this is
* the clock feeding the Power Manager. The Power Manager, in turn, generates main
* clock which is divided down to produce the CPU, AHB, and APB clocks.
*
* The main clock is initially OSC16M divided by 8.
*/
#define BOARD_GCLK_MAIN_FREQUENCY BOARD_GCLK0_FREQUENCY
/* Main clock dividers
*
* BOARD_CPU_DIVIDER - See MCLK_CPUDIV_DIV* definitions
* BOARD_CPU_FRQUENCY - In Hz
* BOARD_CPU_FAILDECT - Boolean (defined / not defined)
* BOARD_LOWPOWER_DIVIDER - See MCLK_LPDIV_DIV_* definitions
* BOARD_LOWPOWER_FREQUENCY - In Hz
* BOARD_BACKUP_DIVIDER - See MCLK_BUPDIV_DIV_* definitions
* BOARD_BACKUP_FREQUENCY - In Hz
*/
#undef BOARD_CPU_FAILDECT
#define BOARD_CPU_DIVIDER MCLK_CPUDIV_DIV1
#define BOARD_LOWPOWER_DIVIDER MCLK_LPDIV_DIV1
#define BOARD_BACKUP_DIVIDER MCLK_BUPDIV_DIV1
/* Resulting frequencies */
#define BOARD_MCK_FREQUENCY (BOARD_GCLK_MAIN_FREQUENCY)
#define BOARD_CPU_FREQUENCY (BOARD_MCK_FREQUENCY)
#define BOARD_LOWPOWER_FREQUENCY (BOARD_MCK_FREQUENCY)
#define BOARD_BACKUP_FREQUENCY (BOARD_MCK_FREQUENCY)
#define BOARD_APBA_FREQUENCY (BOARD_MCK_FREQUENCY)
#define BOARD_APBB_FREQUENCY (BOARD_MCK_FREQUENCY)
#define BOARD_APBC_FREQUENCY (BOARD_MCK_FREQUENCY)
#define BOARD_APBD_FREQUENCY (BOARD_MCK_FREQUENCY)
#define BOARD_APBE_FREQUENCY (BOARD_MCK_FREQUENCY)
/* FLASH wait states
*
* REVISIT: These values come from the SAMD20
* Vdd Range Wait states Maximum Operating Frequency
* ------------- -------------- ---------------------------
* 1.62V to 2.7V 0 14 MHz
* 1 28 MHz
* 2 42 MHz
* 3 48 MHz
* 2.7V to 3.63V 0 24 MHz
* 1 48 MHz
*/
#if 0
# define BOARD_FLASH_WAITSTATES 3
#else
# define BOARD_FLASH_WAITSTATES 1
#endif
/* LED definitions ******************************************************************/
/* The Adafruit Metro M4 has four LEDs, but only two are controllable by software:
*
* 1. The red LED on the Arduino D13 pin, and
* 2. A NeoPixel RGB LED.
*
* Currently, only the red LED is supported.
*
* ------ ----------------- -----------
* SHIELD SAMD5E5 FUNCTION
* ------ ----------------- -----------
* D13 PA16 GPIO output
*/
/* LED index values for use with board_userled() */
#define BOARD_RED_LED 0
#define BOARD_NLEDS 1
/* LED bits for use with board_userled_all() */
#define BOARD_RED_LED_BIT (1 << BOARD_RED_LED)
/* This LED is not used by the board port unless CONFIG_ARCH_LEDS is
* defined. In that case, the usage by the board port is defined in
* include/board.h and src/sam_autoleds.c. The LEDs are used to encode
* OS-related events as follows:
*
* ------------------- ---------------------------- ------
* SYMBOL Meaning LED
* ------------------- ---------------------------- ------ */
#define LED_STARTED 0 /* NuttX has been started OFF */
#define LED_HEAPALLOCATE 0 /* Heap has been allocated OFF */
#define LED_IRQSENABLED 0 /* Interrupts enabled OFF */
#define LED_STACKCREATED 1 /* Idle stack created ON */
#define LED_INIRQ 2 /* In an interrupt N/C */
#define LED_SIGNAL 2 /* In a signal handler N/C */
#define LED_ASSERTION 2 /* An assertion failed N/C */
#define LED_PANIC 3 /* The system has crashed FLASH */
#undef LED_IDLE /* MCU is is sleep mode Not used */
/* Thus is LED is statically on, NuttX has successfully booted and is,
* apparently, running normally. If LED is flashing at approximately
* 2Hz, then a fatal error has been detected and the system has halted.
*/
/* Alternate function pin selections ************************************************/
/* SERCOM definitions ***************************************************************/
/* The SERCOM bus clock (CLK_SERCOMx_APB) can be enabled and disabled in the Main
* Clock Controller. The SERCOM uses two generic clocks: GCLK_SERCOMx_CORE and
* GCLK_SERCOMx_SLOW. The core clock (GCLK_SERCOMx_CORE) is required to clock the
* SERCOM while working as a master. The slow clock (GCLK_SERCOMx_SLOW) is only
* required for certain functions.
*
* These clocks must be configured and enabled in the Generic Clock Controller (GCLK)
* before using the SERCOM.
*/
/* SERCOM3
*
* An Arduino compatible serial Shield is assumed (or equivalently, an external
* RS-232 or serial-to-USB adapter connected on Arduino pins D0 and D1):
*
* ------ ----------------- ---------
* SHIELD SAMD5E5 FUNCTION
* ------ ----------------- ---------
* D0 PA23 SERCOM3 PAD2 RXD
* D1 PA22 SERCOM3 PAD0 TXD
*
* NOTES:
* USART_CTRLA_TXPAD0_1: TxD=PAD0 XCK=PAD1 RTS/TE=N/A CTS=N/A
* USART_CTRLA_RXPAD2: RxD=PAD2
*/
#define BOARD_SERCOM3_MUXCONFIG (USART_CTRLA_TXPAD0_1 | USART_CTRLA_RXPAD2)
#define BOARD_SERCOM3_PINMAP_PAD0 PORT_SERCOM3_PAD0_1 /* USART TX */
#define BOARD_SERCOM3_PINMAP_PAD1 PORT_SERCOM3_PAD2_1 /* USART RX */
#define BOARD_SERCOM3_PINMAP_PAD2 0 /* (not used) */
#define BOARD_SERCOM3_PINMAP_PAD3 0 /* (not used) */
#define BOARD_SERCOM3_FREQUENCY BOARD_GCLK0_FREQUENCY
#endif /* __CONFIG_METRO_M4_INCLUDE_BOARD_H */

View File

@ -0,0 +1,48 @@
# CONFIG_NSH_DISABLE_IFCONFIG is not set
# CONFIG_NSH_DISABLE_PS is not set
CONFIG_ARCH="arm"
CONFIG_ARCH_BOARD="metro-m4"
CONFIG_ARCH_BOARD_METRO_M4=y
CONFIG_ARCH_CHIP_SAMD51J19=y
CONFIG_ARCH_CHIP_SAMD5X=y
CONFIG_ARCH_STACKDUMP=y
CONFIG_BOARD_LOOPSPERMSEC=3410
CONFIG_BUILTIN=y
CONFIG_CXX_NEWLONG=y
CONFIG_DISABLE_ENVIRON=y
CONFIG_DISABLE_POLL=y
CONFIG_EXAMPLES_NSH=y
CONFIG_EXAMPLES_NSH_CXXINITIALIZE=y
CONFIG_HAVE_CXX=y
CONFIG_HAVE_CXXINITIALIZE=y
CONFIG_MAX_TASKS=16
CONFIG_MAX_WDOGPARMS=2
CONFIG_MM_REGIONS=3
CONFIG_NFILE_DESCRIPTORS=8
CONFIG_NFILE_STREAMS=8
CONFIG_NSH_BUILTIN_APPS=y
CONFIG_NSH_FILEIOSIZE=512
CONFIG_NSH_LINELEN=64
CONFIG_NSH_READLINE=y
CONFIG_PREALLOC_MQ_MSGS=4
CONFIG_PREALLOC_TIMERS=4
CONFIG_PREALLOC_WDOGS=4
CONFIG_PTHREAD_STACK_DEFAULT=1536
CONFIG_RAM_SIZE=32768
CONFIG_RAM_START=0x20000000
CONFIG_RAW_BINARY=y
CONFIG_RR_INTERVAL=200
CONFIG_SAMD5E5_EIC=y
CONFIG_SAMD5E5_SERCOM3=y
CONFIG_SCHED_WAITPID=y
CONFIG_SDCLONE_DISABLE=y
CONFIG_START_DAY=23
CONFIG_START_MONTH=7
CONFIG_TASK_NAME_SIZE=0
CONFIG_TASK_SPAWN_DEFAULT_STACKSIZE=1536
CONFIG_USART3_RXBUFSIZE=64
CONFIG_USART3_SERIAL_CONSOLE=y
CONFIG_USART3_TXBUFSIZE=64
CONFIG_USERMAIN_STACKSIZE=1536
CONFIG_USER_ENTRYPOINT="nsh_main"
CONFIG_WDOG_INTRESERVE=0

View File

@ -0,0 +1,124 @@
############################################################################
# configs/metro-m4/scripts/Make.defs
#
# Copyright (C) 2018 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.
#
############################################################################
include ${TOPDIR}/.config
include ${TOPDIR}/tools/Config.mk
include ${TOPDIR}/arch/arm/src/armv7-m/Toolchain.defs
LDSCRIPT = flash.ld
ifeq ($(WINTOOL),y)
# Windows-native toolchains
DIRLINK = $(TOPDIR)/tools/copydir.sh
DIRUNLINK = $(TOPDIR)/tools/unlink.sh
MKDEP = $(TOPDIR)/tools/mkwindeps.sh
ARCHINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}"
ARCHXXINCLUDES = -I. -isystem "${shell cygpath -w $(TOPDIR)/include}" -isystem "${shell cygpath -w $(TOPDIR)/include/cxx}"
ARCHSCRIPT = -T "${shell cygpath -w $(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)}"
else
# Linux/Cygwin-native toolchain
MKDEP = $(TOPDIR)/tools/mkdeps$(HOSTEXEEXT)
ARCHINCLUDES = -I. -isystem $(TOPDIR)/include
ARCHXXINCLUDES = -I. -isystem $(TOPDIR)/include -isystem $(TOPDIR)/include/cxx
ARCHSCRIPT = -T$(TOPDIR)/configs/$(CONFIG_ARCH_BOARD)/scripts/$(LDSCRIPT)
endif
CC = $(CROSSDEV)gcc
CXX = $(CROSSDEV)g++
CPP = $(CROSSDEV)gcc -E
LD = $(CROSSDEV)ld
STRIP = $(CROSSDEV)strip --strip-unneeded
AR = $(ARCROSSDEV)ar rcs
NM = $(ARCROSSDEV)nm
OBJCOPY = $(CROSSDEV)objcopy
OBJDUMP = $(CROSSDEV)objdump
ARCHCCVERSION = ${shell $(CC) -v 2>&1 | sed -n '/^gcc version/p' | sed -e 's/^gcc version \([0-9\.]\)/\1/g' -e 's/[-\ ].*//g' -e '1q'}
ARCHCCMAJOR = ${shell echo $(ARCHCCVERSION) | cut -d'.' -f1}
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
ARCHOPTIMIZATION = -g
endif
ifneq ($(CONFIG_DEBUG_NOOPT),y)
ARCHOPTIMIZATION += $(MAXOPTIMIZATION) -fno-strict-aliasing -fno-strength-reduce -fomit-frame-pointer
endif
ARCHCFLAGS = -fno-builtin
ARCHCXXFLAGS = -fno-builtin -fno-exceptions -fcheck-new -fno-rtti
ARCHWARNINGS = -Wall -Wstrict-prototypes -Wshadow -Wundef
ARCHWARNINGSXX = -Wall -Wshadow -Wundef
ARCHDEFINES =
ARCHPICFLAGS = -fpic -msingle-pic-base -mpic-register=r10
CFLAGS = $(ARCHCFLAGS) $(ARCHWARNINGS) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
CPICFLAGS = $(ARCHPICFLAGS) $(CFLAGS)
CXXFLAGS = $(ARCHCXXFLAGS) $(ARCHWARNINGSXX) $(ARCHOPTIMIZATION) $(ARCHCPUFLAGS) $(ARCHXXINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES) -pipe
CXXPICFLAGS = $(ARCHPICFLAGS) $(CXXFLAGS)
CPPFLAGS = $(ARCHINCLUDES) $(ARCHDEFINES) $(EXTRADEFINES)
AFLAGS = $(CFLAGS) -D__ASSEMBLY__
NXFLATLDFLAGS1 = -r -d -warn-common
NXFLATLDFLAGS2 = $(NXFLATLDFLAGS1) -T$(TOPDIR)/binfmt/libnxflat/gnu-nxflat-pcrel.ld -no-check-sections
LDNXFLATFLAGS = -e main -s 2048
# Loadable module definitions
CMODULEFLAGS = $(CFLAGS) -mlong-calls # --target1-abs
LDMODULEFLAGS = -r -e module_initialize
ifeq ($(WINTOOL),y)
LDMODULEFLAGS += -T "${shell cygpath -w $(TOPDIR)/libs/libc/modlib/gnu-elf.ld}"
else
LDMODULEFLAGS += -T $(TOPDIR)/libs/libc/modlib/gnu-elf.ld
endif
ASMEXT = .S
OBJEXT = .o
LIBEXT = .a
EXEEXT =
ifneq ($(CROSSDEV),arm-nuttx-elf-)
LDFLAGS += -nostartfiles -nodefaultlibs
endif
ifeq ($(CONFIG_DEBUG_SYMBOLS),y)
LDFLAGS += -g
endif
HOSTCC = gcc
HOSTINCLUDES = -I.
HOSTCFLAGS = -Wall -Wstrict-prototypes -Wshadow -Wundef -g -pipe
HOSTLDFLAGS =

View File

@ -0,0 +1,121 @@
/****************************************************************************
* configs/metro-m4/scripts/ld.script
*
* Copyright (C) 2018 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.
*
****************************************************************************/
/* The ATSAMD51J19 has 512Kb of FLASH beginning at address 0x0000:0000 and
* 192Kb of SRAM at address 0x2000:0000.
*/
MEMORY
{
flash (rx) : ORIGIN = 0x00000000, LENGTH = 512K
sram (rwx) : ORIGIN = 0x20000000, LENGTH = 64K
}
OUTPUT_ARCH(arm)
ENTRY(_stext)
EXTERN(_vectors)
SECTIONS
{
.text :
{
_stext = ABSOLUTE(.);
*(.vectors)
*(.text .text.*)
*(.fixup)
*(.gnu.warning)
*(.rodata .rodata.*)
*(.gnu.linkonce.t.*)
*(.glue_7)
*(.glue_7t)
*(.got)
*(.gcc_except_table)
*(.gnu.linkonce.r.*)
_etext = ABSOLUTE(.);
} > flash
.init_section :
{
_sinit = ABSOLUTE(.);
*(.init_array .init_array.*)
_einit = ABSOLUTE(.);
} > flash
.ARM.extab :
{
*(.ARM.extab*)
} > flash
__exidx_start = ABSOLUTE(.);
.ARM.exidx :
{
*(.ARM.exidx*)
} > flash
__exidx_end = ABSOLUTE(.);
_eronly = ABSOLUTE(.);
.data :
{
_sdata = ABSOLUTE(.);
*(.data .data.*)
*(.gnu.linkonce.d.*)
CONSTRUCTORS
_edata = ABSOLUTE(.);
} > sram AT > flash
.bss :
{
_sbss = ABSOLUTE(.);
*(.bss .bss.*)
*(.gnu.linkonce.b.*)
*(COMMON)
_ebss = ABSOLUTE(.);
} > sram
/* Stabs debugging sections. */
.stab 0 : { *(.stab) }
.stabstr 0 : { *(.stabstr) }
.stab.excl 0 : { *(.stab.excl) }
.stab.exclstr 0 : { *(.stab.exclstr) }
.stab.index 0 : { *(.stab.index) }
.stab.indexstr 0 : { *(.stab.indexstr) }
.comment 0 : { *(.comment) }
.debug_abbrev 0 : { *(.debug_abbrev) }
.debug_info 0 : { *(.debug_info) }
.debug_line 0 : { *(.debug_line) }
.debug_pubnames 0 : { *(.debug_pubnames) }
.debug_aranges 0 : { *(.debug_aranges) }
}

View File

@ -0,0 +1,51 @@
############################################################################
# configs/metro-m4/src/Makefile
#
# Copyright (C) 2018 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.
#
############################################################################
-include $(TOPDIR)/Make.defs
ASRCS =
CSRCS = sam_boot.c sam_bringup.c
ifeq ($(CONFIG_LIB_BOARDCTL),y)
CSRCS += sam_appinit.c
endif
ifeq ($(CONFIG_ARCH_LEDS),y)
CSRCS += sam_autoleds.c
else
CSRCS += sam_userleds.c
endif
include $(TOPDIR)/configs/Board.mk

View File

@ -0,0 +1,116 @@
/****************************************************************************
* configs/metro-m4/src/metro-m4.h
*
* Copyright (C) 2018 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 __CONFIGS_METRO_M4_SRC_METRO_M4_H
#define __CONFIGS_METRO_M4_SRC_METRO_M4_H
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/* Configuration ************************************************************/
/* Metro-M4 GPIOs ***********************************************************/
/* LEDs
*
* The Adafruit Metro M4 has four LEDs, but only two are controllable by software:
*
* 1. The red LED on the Arduino D13 pin, and
* 2. A NeoPixel RGB LED.
*
* Currently, only the red LED is supported.
*
* ------ ----------------- -----------
* SHIELD SAMD5E5 FUNCTION
* ------ ----------------- -----------
* D13 PA16 GPIO output
*/
#define PORT_RED_LED (PORT_OUTPUT | PORT_PULL_NONE | PORT_OUTPUT_SET | \
PORTA | PORT_PIN16)
/****************************************************************************
* Public Types
****************************************************************************/
/****************************************************************************
* Public data
****************************************************************************/
#ifndef __ASSEMBLY__
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sam_bringup
*
* Description:
* Perform architecture-specific initialization
*
* CONFIG_BOARD_INITIALIZE=y :
* Called from board_initialize().
*
* CONFIG_BOARD_INITIALIZE=y && CONFIG_LIB_BOARDCTL=y :
* Called from the NSH library
*
****************************************************************************/
int sam_bringup(void);
/****************************************************************************
* Name: sam_led_pminitialize
*
* Description:
* Register LED power management features.
*
****************************************************************************/
#ifdef CONFIG_PM
void sam_led_pminitialize(void);
#endif
#endif /* __ASSEMBLY__ */
#endif /* __CONFIGS_METRO_M4_SRC_METRO_M4_H */

View File

@ -0,0 +1,94 @@
/****************************************************************************
* config/metro-m4/src/sam_appinit.c
*
* Copyright (C) 2018 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <nuttx/board.h>
#include "metro-m4.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#ifndef OK
# define OK 0
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_app_initialize
*
* Description:
* Perform application specific initialization. This function is never
* called directly from application code, but only indirectly via the
* (non-standard) boardctl() interface using the command BOARDIOC_INIT.
*
* Input Parameters:
* arg - The boardctl() argument is passed to the board_app_initialize()
* implementation without modification. The argument has no
* meaning to NuttX; the meaning of the argument is a contract
* between the board-specific initialization logic and the
* matching application logic. The value cold be such things as a
* mode enumeration value, a set of DIP switch switch settings, a
* pointer to configuration data read from a file or serial FLASH,
* or whatever you would like to do with it. Every implementation
* should accept zero/NULL as a default configuration.
*
* Returned Value:
* Zero (OK) is returned on success; a negated errno value is returned on
* any failure to indicate the nature of the failure.
*
****************************************************************************/
int board_app_initialize(uintptr_t arg)
{
#ifdef CONFIG_BOARD_INITIALIZE
/* Board initialization already performed by board_initialize() */
return OK;
#else
/* Perform board-specific initialization */
return sam_bringup();
#endif
}

View File

@ -0,0 +1,294 @@
/****************************************************************************
* configs/metro-m4/src/sam_autoleds.c
*
* Copyright (C) 2018 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.
*
****************************************************************************/
/* The Adafruit Metro M4 has four LEDs, but only two are controllable by software:
*
* 1. The red LED on the Arduino D13 pin, and
* 2. A NeoPixel RGB LED.
*
* Currently, only the red LED is supported.
*
* ------ ----------------- -----------
* SHIELD SAMD5E5 FUNCTION
* ------ ----------------- -----------
* D13 PA16 GPIO output
*
* This LED is not used by the board port unless CONFIG_ARCH_LEDS is
* defined. In that case, the usage by the board port is defined in
* include/board.h and src/sam_autoleds.c. The LEDs are used to encode
* OS-related events as follows:
*
* ------------------- ---------------------------- ------
* SYMBOL Meaning LED
* ------------------- ---------------------------- ------
*
* LED_STARTED NuttX has been started OFF
* LED_HEAPALLOCATE Heap has been allocated OFF
* LED_IRQSENABLED Interrupts enabled OFF
* LED_STACKCREATED Idle stack created ON
* LED_INIRQ In an interrupt N/C
* LED_SIGNAL In a signal handler N/C
* LED_ASSERTION An assertion failed N/C
* LED_PANIC The system has crashed FLASH
* LED_IDLE MCU is is sleep mode Not used
*/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/board.h>
#include <nuttx/power/pm.h>
#include "up_arch.h"
#include "up_internal.h"
#include "metro-m4.h"
#include <arch/board/board.h>
#ifdef CONFIG_ARCH_LEDS
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/* LED Power Management */
#ifdef CONFIG_PM
static void led_pm_notify(struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate);
static int led_pm_prepare(struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate);
#endif
/****************************************************************************
* Private Data
****************************************************************************/
#ifdef CONFIG_PM
static struct pm_callback_s g_ledscb =
{
.notify = led_pm_notify,
.prepare = led_pm_prepare,
};
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: led_pm_notify
*
* Description:
* Notify the driver of new power state. This callback is called after
* all drivers have had the opportunity to prepare for the new power state.
*
****************************************************************************/
#ifdef CONFIG_PM
static void led_pm_notify(struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate)
{
switch (pmstate)
{
case(PM_NORMAL):
{
/* Restore normal LEDs operation */
}
break;
case(PM_IDLE):
{
/* Entering IDLE mode - Turn leds off */
}
break;
case(PM_STANDBY):
{
/* Entering STANDBY mode - Logic for PM_STANDBY goes here */
}
break;
case(PM_SLEEP):
{
/* Entering SLEEP mode - Logic for PM_SLEEP goes here */
}
break;
default:
{
/* Should not get here */
}
break;
}
}
#endif
/****************************************************************************
* Name: led_pm_prepare
*
* Description:
* Request the driver to prepare for a new power state. This is a warning
* that the system is about to enter into a new power state. The driver
* should begin whatever operations that may be required to enter power
* state. The driver may abort the state change mode by returning a
* non-zero value from the callback function.
*
****************************************************************************/
#ifdef CONFIG_PM
static int led_pm_prepare(struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate)
{
/* No preparation to change power modes is required by the LEDs driver.
* We always accept the state change by returning OK.
*/
return OK;
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_autoled_initialize
****************************************************************************/
void board_autoled_initialize(void)
{
(void)sam_configport(PORT_RED_LED);
}
/****************************************************************************
* Name: board_autoled_on
****************************************************************************/
void board_autoled_on(int led)
{
bool ledstate = true;
switch (led)
{
case 0: /* LED_STARTED: NuttX has been started STATUS LED=OFF */
/* LED_HEAPALLOCATE: Heap has been allocated STATUS LED=OFF */
/* LED_IRQSENABLED: Interrupts enabled STATUS LED=OFF */
break; /* Leave ledstate == true to turn OFF */
default:
case 2: /* LED_INIRQ: In an interrupt STATUS LED=N/C */
/* LED_SIGNAL: In a signal handler STATUS LED=N/C */
/* LED_ASSERTION: An assertion failed STATUS LED=N/C */
return; /* Return to leave STATUS LED unchanged */
case 3: /* LED_PANIC: The system has crashed STATUS LED=FLASH */
case 1: /* LED_STACKCREATED: Idle stack created STATUS LED=ON */
ledstate = false; /* Set ledstate == false to turn ON */
break;
}
sam_portwrite(PORT_RED_LED, ledstate);
}
/****************************************************************************
* Name: board_autoled_off
****************************************************************************/
void board_autoled_off(int led)
{
switch (led)
{
/* These should not happen and are ignored */
default:
case 0: /* LED_STARTED: NuttX has been started STATUS LED=OFF */
/* LED_HEAPALLOCATE: Heap has been allocated STATUS LED=OFF */
/* LED_IRQSENABLED: Interrupts enabled STATUS LED=OFF */
case 1: /* LED_STACKCREATED: Idle stack created STATUS LED=ON */
/* These result in no-change */
case 2: /* LED_INIRQ: In an interrupt STATUS LED=N/C */
/* LED_SIGNAL: In a signal handler STATUS LED=N/C */
/* LED_ASSERTION: An assertion failed STATUS LED=N/C */
return; /* Return to leave STATUS LED unchanged */
/* Turn STATUS LED off set driving the output high */
case 3: /* LED_PANIC: The system has crashed STATUS LED=FLASH */
sam_portwrite(PORT_RED_LED, true);
break;
}
}
/****************************************************************************
* Name: sam_led_pminitialize
*
* Description:
* Register LED power management features.
*
****************************************************************************/
#ifdef CONFIG_PM
void sam_led_pminitialize(void)
{
/* Register to receive power management callbacks */
int ret = pm_register(&g_ledscb);
if (ret != OK)
{
board_autoled_on(LED_ASSERTION);
}
}
#endif /* CONFIG_PM */
#endif /* CONFIG_ARCH_LEDS */

View File

@ -0,0 +1,94 @@
/****************************************************************************
* configs/metro-m4/src/sam_boot.c
*
* Copyright (C) 2018 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <debug.h>
#include <nuttx/board.h>
#include "metro-m4.h"
#include <arch/board/board.h>
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sam_boardinitialize
*
* Description:
* All SAMD5/E5 architectures must provide the following entry point.
* This entry point is called early in the initialization -- after all
* memory has been configured and mapped but before any devices have been
* initialized.
*
****************************************************************************/
void sam_boardinitialize(void)
{
#ifdef CONFIG_ARCH_LEDS
/* Configure on-board LEDs if LED support has been selected. */
board_autoled_initialize();
#endif
}
/****************************************************************************
* Name: board_initialize
*
* Description:
* If CONFIG_BOARD_INITIALIZE is selected, then an additional
* initialization call will be performed in the boot-up sequence to a
* function called board_initialize(). board_initialize() will be
* called immediately after up_initialize() is called and just before the
* initial application is started. This additional initialization phase
* may be used, for example, to initialize board-specific device drivers.
*
****************************************************************************/
#ifdef CONFIG_BOARD_INITIALIZE
void board_initialize(void)
{
/* Perform board-specific initialization */
(void)sam_bringup();
}
#endif

View File

@ -0,0 +1,91 @@
/****************************************************************************
* config/metro-m4/src/sam_bringup.c
*
* Copyright (C) 2018 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.
*
****************************************************************************/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <sys/mount.h>
#include <stdbool.h>
#include <stdio.h>
#include <debug.h>
#include <errno.h>
#include "metro-m4.h"
/****************************************************************************
* Pre-processor Definitions
****************************************************************************/
#define PROCFS_MOUNTPOINT "/proc"
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: sam_bringup
*
* Description:
* Perform architecture-specific initialization
*
* CONFIG_BOARD_INITIALIZE=y :
* Called from board_initialize().
*
* CONFIG_BOARD_INITIALIZE=n && CONFIG_LIB_BOARDCTL=y :
* Called from the NSH library
*
****************************************************************************/
int sam_bringup(void)
{
int ret = OK;
#ifdef CONFIG_FS_PROCFS
/* Mount the procfs file system */
ret = mount(NULL, PROCFS_MOUNTPOINT, "procfs", 0, NULL);
if (ret < 0)
{
syslot(LOG_ERR, "ERROR: Failed to mount procfs at %s: %d\n",
PROCFS_MOUNTPOINT, ret);
}
#endif
UNUSED(ret);
return OK;
}

View File

@ -0,0 +1,236 @@
/****************************************************************************
* configs/metro-m4/src/sam_userleds.c
*
* Copyright (C) 2018 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.
*
****************************************************************************/
/* The Adafruit Metro M4 has four LEDs, but only two are controllable by software:
*
* 1. The red LED on the Arduino D13 pin, and
* 2. A NeoPixel RGB LED.
*
* Currently, only the red LED is supported.
*
* ------ ----------------- -----------
* SHIELD SAMD5E5 FUNCTION
* ------ ----------------- -----------
* D13 PA16 GPIO output
*/
/****************************************************************************
* Included Files
****************************************************************************/
#include <nuttx/config.h>
#include <stdint.h>
#include <stdbool.h>
#include <debug.h>
#include <nuttx/board.h>
#include <nuttx/power/pm.h>
#include "up_arch.h"
#include "metro-m4.h"
#include <arch/board/board.h>
#ifndef CONFIG_ARCH_LEDS
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Function Prototypes
****************************************************************************/
/* LED Power Management */
#ifdef CONFIG_PM
static void led_pm_notify(struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate);
static int led_pm_prepare(struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate);
#endif
/****************************************************************************
* Private Data
****************************************************************************/
#ifdef CONFIG_PM
static struct pm_callback_s g_ledscb =
{
.notify = led_pm_notify,
.prepare = led_pm_prepare,
};
#endif
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Name: led_pm_notify
*
* Description:
* Notify the driver of new power state. This callback is called after
* all drivers have had the opportunity to prepare for the new power state.
*
****************************************************************************/
#ifdef CONFIG_PM
static void led_pm_notify(struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate)
{
switch (pmstate)
{
case(PM_NORMAL):
{
/* Restore normal LEDs operation */
}
break;
case(PM_IDLE):
{
/* Entering IDLE mode - Turn leds off */
}
break;
case(PM_STANDBY):
{
/* Entering STANDBY mode - Logic for PM_STANDBY goes here */
}
break;
case(PM_SLEEP):
{
/* Entering SLEEP mode - Logic for PM_SLEEP goes here */
}
break;
default:
{
/* Should not get here */
}
break;
}
}
#endif
/****************************************************************************
* Name: led_pm_prepare
*
* Description:
* Request the driver to prepare for a new power state. This is a warning
* that the system is about to enter into a new power state. The driver
* should begin whatever operations that may be required to enter power
* state. The driver may abort the state change mode by returning a
* non-zero value from the callback function.
*
****************************************************************************/
#ifdef CONFIG_PM
static int led_pm_prepare(struct pm_callback_s *cb, int domain,
enum pm_state_e pmstate)
{
/* No preparation to change power modes is required by the LEDs driver.
* We always accept the state change by returning OK.
*/
return OK;
}
#endif
/****************************************************************************
* Public Functions
****************************************************************************/
/****************************************************************************
* Name: board_userled_initialize
****************************************************************************/
void board_userled_initialize(void)
{
(void)sam_configport(PORT_STATUS_LED);
}
/****************************************************************************
* Name: board_userled
****************************************************************************/
void board_userled(int led, bool ledon)
{
if (led == BOARD_STATUS_LED)
{
sam_portwrite(PORT_STATUS_LED, !ledon);
}
}
/****************************************************************************
* Name: board_userled_all
****************************************************************************/
void board_userled_all(uint8_t ledset)
{
board_userled(BOARD_STATUS_LED, (ledset & BOARD_STATUS_LED_BIT) != 0);
}
/****************************************************************************
* Name: sam_led_pminitialize
*
* Description:
* Register LED power management features.
*
****************************************************************************/
#ifdef CONFIG_PM
void sam_led_pminitialize(void)
{
/* Register to receive power management callbacks */
int ret = pm_register(&g_ledscb);
if (ret != OK)
{
board_autoled_on(LED_ASSERTION);
}
}
#endif /* CONFIG_PM */
#endif /* !CONFIG_ARCH_LEDS */