2014-02-15 21:22:56 +01:00
|
|
|
/****************************************************************************
|
2018-07-22 23:54:12 +02:00
|
|
|
* arch/arm/src/samd2l2/sam_usart.c
|
2014-02-15 21:22:56 +01:00
|
|
|
*
|
2021-03-24 09:34:53 +01:00
|
|
|
* Licensed to the Apache Software Foundation (ASF) under one or more
|
|
|
|
* contributor license agreements. See the NOTICE file distributed with
|
|
|
|
* this work for additional information regarding copyright ownership. The
|
|
|
|
* ASF licenses this file to you under the Apache License, Version 2.0 (the
|
|
|
|
* "License"); you may not use this file except in compliance with the
|
|
|
|
* License. You may obtain a copy of the License at
|
2014-02-15 21:22:56 +01:00
|
|
|
*
|
2021-03-24 09:34:53 +01:00
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
2014-02-15 21:22:56 +01:00
|
|
|
*
|
2021-03-24 09:34:53 +01:00
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS, WITHOUT
|
|
|
|
* WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. See the
|
|
|
|
* License for the specific language governing permissions and limitations
|
|
|
|
* under the License.
|
2014-02-15 21:22:56 +01:00
|
|
|
*
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Included Files
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
#include <nuttx/config.h>
|
|
|
|
|
|
|
|
#include <stdint.h>
|
|
|
|
#include <assert.h>
|
|
|
|
|
2015-05-17 23:34:51 +02:00
|
|
|
#include "sam_pinmap.h"
|
2015-05-17 16:06:56 +02:00
|
|
|
#include "sam_gclk.h"
|
2014-02-15 21:22:56 +01:00
|
|
|
#include "sam_usart.h"
|
|
|
|
|
2015-05-17 16:06:56 +02:00
|
|
|
#include <arch/board/board.h>
|
|
|
|
|
2014-02-15 21:22:56 +01:00
|
|
|
/****************************************************************************
|
|
|
|
* Pre-processor Definitions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Data
|
|
|
|
****************************************************************************/
|
|
|
|
|
2018-07-22 23:54:12 +02:00
|
|
|
#ifdef SAMD2L2_HAVE_USART0
|
2014-02-15 21:22:56 +01:00
|
|
|
const struct sam_usart_config_s g_usart0config =
|
|
|
|
{
|
|
|
|
.sercom = 0,
|
|
|
|
.parity = CONFIG_USART0_PARITY,
|
|
|
|
.bits = CONFIG_USART0_BITS,
|
|
|
|
.irq = SAM_IRQ_SERCOM0,
|
2015-06-10 16:38:35 +02:00
|
|
|
.gclkgen = BOARD_SERCOM0_GCLKGEN,
|
|
|
|
.slowgen = BOARD_SERCOM0_SLOW_GCLKGEN,
|
2014-02-15 21:22:56 +01:00
|
|
|
.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,
|
2014-02-16 00:53:55 +01:00
|
|
|
.frequency = BOARD_SERCOM0_FREQUENCY,
|
2014-02-15 21:22:56 +01:00
|
|
|
.base = SAM_SERCOM0_BASE,
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2018-07-22 23:54:12 +02:00
|
|
|
#ifdef SAMD2L2_HAVE_USART1
|
2014-02-15 21:22:56 +01:00
|
|
|
const struct sam_usart_config_s g_usart1config =
|
|
|
|
{
|
|
|
|
.sercom = 1,
|
|
|
|
.parity = CONFIG_USART1_PARITY,
|
|
|
|
.bits = CONFIG_USART1_BITS,
|
|
|
|
.irq = SAM_IRQ_SERCOM1,
|
2015-05-22 18:36:37 +02:00
|
|
|
.gclkgen = BOARD_SERCOM1_GCLKGEN,
|
2015-06-10 16:38:35 +02:00
|
|
|
.slowgen = BOARD_SERCOM1_SLOW_GCLKGEN,
|
2014-02-15 21:22:56 +01:00
|
|
|
.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,
|
2014-02-17 00:21:36 +01:00
|
|
|
.muxconfig = BOARD_SERCOM1_MUXCONFIG,
|
2014-02-16 00:53:55 +01:00
|
|
|
.frequency = BOARD_SERCOM1_FREQUENCY,
|
2014-02-15 21:22:56 +01:00
|
|
|
.base = SAM_SERCOM1_BASE,
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2018-07-22 23:54:12 +02:00
|
|
|
#ifdef SAMD2L2_HAVE_USART2
|
2014-02-15 21:22:56 +01:00
|
|
|
const struct sam_usart_config_s g_usart2config =
|
|
|
|
{
|
|
|
|
.sercom = 2,
|
|
|
|
.parity = CONFIG_USART2_PARITY,
|
|
|
|
.bits = CONFIG_USART2_BITS,
|
|
|
|
.irq = SAM_IRQ_SERCOM2,
|
2015-05-22 18:36:37 +02:00
|
|
|
.gclkgen = BOARD_SERCOM2_GCLKGEN,
|
2015-06-10 16:38:35 +02:00
|
|
|
.slowgen = BOARD_SERCOM2_SLOW_GCLKGEN,
|
2014-02-15 21:22:56 +01:00
|
|
|
.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,
|
2014-02-16 00:53:55 +01:00
|
|
|
.frequency = BOARD_SERCOM2_FREQUENCY,
|
2014-02-15 21:22:56 +01:00
|
|
|
.base = SAM_SERCOM2_BASE,
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2018-07-22 23:54:12 +02:00
|
|
|
#ifdef SAMD2L2_HAVE_USART3
|
2014-02-15 21:22:56 +01:00
|
|
|
const struct sam_usart_config_s g_usart3config =
|
|
|
|
{
|
|
|
|
.sercom = 3,
|
|
|
|
.parity = CONFIG_USART3_PARITY,
|
|
|
|
.bits = CONFIG_USART3_BITS,
|
|
|
|
.irq = SAM_IRQ_SERCOM3,
|
2015-05-22 18:36:37 +02:00
|
|
|
.gclkgen = BOARD_SERCOM3_GCLKGEN,
|
2015-06-10 16:38:35 +02:00
|
|
|
.slowgen = BOARD_SERCOM3_SLOW_GCLKGEN,
|
2014-02-15 21:22:56 +01:00
|
|
|
.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,
|
2014-02-16 00:53:55 +01:00
|
|
|
.frequency = BOARD_SERCOM3_FREQUENCY,
|
2014-02-15 21:22:56 +01:00
|
|
|
.base = SAM_SERCOM3_BASE,
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2018-07-22 23:54:12 +02:00
|
|
|
#ifdef SAMD2L2_HAVE_USART4
|
2014-02-15 21:22:56 +01:00
|
|
|
const struct sam_usart_config_s g_usart4config =
|
|
|
|
{
|
|
|
|
.sercom = 4,
|
|
|
|
.parity = CONFIG_USART4_PARITY,
|
|
|
|
.bits = CONFIG_USART4_BITS,
|
|
|
|
.irq = SAM_IRQ_SERCOM4,
|
2015-05-22 18:36:37 +02:00
|
|
|
.gclkgen = BOARD_SERCOM4_GCLKGEN,
|
2015-06-10 16:38:35 +02:00
|
|
|
.slowgen = BOARD_SERCOM4_SLOW_GCLKGEN,
|
2014-02-15 21:22:56 +01:00
|
|
|
.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,
|
2014-02-16 00:53:55 +01:00
|
|
|
.frequency = BOARD_SERCOM4_FREQUENCY,
|
2014-02-15 21:22:56 +01:00
|
|
|
.base = SAM_SERCOM4_BASE,
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2018-07-22 23:54:12 +02:00
|
|
|
#ifdef SAMD2L2_HAVE_USART5
|
2014-02-15 21:22:56 +01:00
|
|
|
const struct sam_usart_config_s g_usart5config =
|
|
|
|
{
|
|
|
|
.sercom = 5,
|
|
|
|
.parity = CONFIG_USART5_PARITY,
|
|
|
|
.bits = CONFIG_USART5_BITS,
|
|
|
|
.irq = SAM_IRQ_SERCOM5,
|
2015-05-22 18:36:37 +02:00
|
|
|
.gclkgen = BOARD_SERCOM5_GCLKGEN,
|
2015-06-10 16:38:35 +02:00
|
|
|
.slowgen = BOARD_SERCOM5_SLOW_GCLKGEN,
|
2014-02-15 21:22:56 +01:00
|
|
|
.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,
|
2014-02-16 00:53:55 +01:00
|
|
|
.frequency = BOARD_SERCOM5_FREQUENCY,
|
2014-02-15 21:22:56 +01:00
|
|
|
.base = SAM_SERCOM5_BASE,
|
|
|
|
};
|
|
|
|
#endif
|
|
|
|
|
2018-07-22 23:54:12 +02:00
|
|
|
const struct sam_usart_config_s *g_usartconfig[SAMD2L2_NSERCOM] =
|
2014-02-15 21:22:56 +01:00
|
|
|
{
|
2018-07-25 21:36:04 +02:00
|
|
|
#if SAMD2L2_NSERCOM > 0
|
|
|
|
#ifdef SAMD2L2_HAVE_USART0
|
|
|
|
&g_usart0config,
|
2014-02-15 21:22:56 +01:00
|
|
|
#else
|
|
|
|
(const struct sam_usart_config_s *)0,
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2018-07-22 23:54:12 +02:00
|
|
|
#if SAMD2L2_NSERCOM > 1
|
|
|
|
#ifdef SAMD2L2_HAVE_USART1
|
2014-02-15 21:22:56 +01:00
|
|
|
&g_usart1config,
|
|
|
|
#else
|
|
|
|
(const struct sam_usart_config_s *)0,
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2018-07-22 23:54:12 +02:00
|
|
|
#if SAMD2L2_NSERCOM > 2
|
|
|
|
#ifdef SAMD2L2_HAVE_USART2
|
2014-02-15 21:22:56 +01:00
|
|
|
&g_usart2config,
|
|
|
|
#else
|
|
|
|
(const struct sam_usart_config_s *)0,
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2018-07-22 23:54:12 +02:00
|
|
|
#if SAMD2L2_NSERCOM > 3
|
|
|
|
#ifdef SAMD2L2_HAVE_USART3
|
2014-02-15 21:22:56 +01:00
|
|
|
&g_usart3config,
|
|
|
|
#else
|
|
|
|
(const struct sam_usart_config_s *)0,
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2018-07-22 23:54:12 +02:00
|
|
|
#if SAMD2L2_NSERCOM > 4
|
|
|
|
#ifdef SAMD2L2_HAVE_USART4
|
2014-02-15 21:22:56 +01:00
|
|
|
&g_usart4config,
|
|
|
|
#else
|
|
|
|
(const struct sam_usart_config_s *)0,
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
|
2018-07-22 23:54:12 +02:00
|
|
|
#if SAMD2L2_NSERCOM > 5
|
|
|
|
#ifdef SAMD2L2_HAVE_USART5
|
2014-02-15 21:22:56 +01:00
|
|
|
&g_usart5config,
|
|
|
|
#else
|
|
|
|
(const struct sam_usart_config_s *)0,
|
|
|
|
#endif
|
|
|
|
#endif
|
|
|
|
};
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Private Functions
|
|
|
|
****************************************************************************/
|
|
|
|
|
|
|
|
/****************************************************************************
|
|
|
|
* Public Functions
|
|
|
|
****************************************************************************/
|