arch/arm/src/samd2l2 serial: Fix SAMD2L2 serial driver it needs sam_usart_enable() to work
This commit is contained in:
parent
8763e51583
commit
db0b9b7c34
@ -90,7 +90,7 @@
|
||||
|
||||
#ifdef SAMD2L2_HAVE_USART
|
||||
static void
|
||||
sam_wait_synchronization(const struct sam_usart_config_s * const config)
|
||||
sam_wait_synchronization(const struct sam_usart_config_s *const config)
|
||||
{
|
||||
while (usart_syncbusy(config));
|
||||
}
|
||||
@ -106,7 +106,7 @@ sam_wait_synchronization(const struct sam_usart_config_s * const config)
|
||||
|
||||
#ifdef SAMD2L2_HAVE_USART
|
||||
static inline int
|
||||
sam_usart_configure(const struct sam_usart_config_s * const config)
|
||||
sam_usart_configure(const struct sam_usart_config_s *const config)
|
||||
{
|
||||
uint32_t ctrla;
|
||||
uint32_t ctrlb;
|
||||
@ -257,7 +257,7 @@ sam_usart_configure(const struct sam_usart_config_s * const config)
|
||||
|
||||
#ifdef SAMD2L2_HAVE_USART
|
||||
static inline void
|
||||
sam_pad_configure(const struct sam_usart_config_s * const config)
|
||||
sam_pad_configure(const struct sam_usart_config_s *const config)
|
||||
{
|
||||
/* Configure SERCOM pads */
|
||||
|
||||
@ -294,7 +294,7 @@ sam_pad_configure(const struct sam_usart_config_s * const config)
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef SAMD2L2_HAVE_USART
|
||||
int sam_usart_internal(const struct sam_usart_config_s * const config)
|
||||
int sam_usart_internal(const struct sam_usart_config_s *const config)
|
||||
{
|
||||
#ifdef CONFIG_ARCH_FAMILY_SAML21
|
||||
int channel;
|
||||
@ -339,34 +339,6 @@ int sam_usart_internal(const struct sam_usart_config_s * const config)
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_usart_enable
|
||||
*
|
||||
* Description:
|
||||
* Enable the SERCOM USART (without enabling interrupts).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef SAMD2L2_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
|
||||
****************************************************************************/
|
||||
@ -401,7 +373,7 @@ void sam_lowsetup(void)
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef SAMD2L2_HAVE_USART
|
||||
int sam_usart_initialize(const struct sam_usart_config_s * const config)
|
||||
int sam_usart_initialize(const struct sam_usart_config_s *const config)
|
||||
{
|
||||
irqstate_t flags;
|
||||
int ret;
|
||||
@ -431,7 +403,7 @@ int sam_usart_initialize(const struct sam_usart_config_s * const config)
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef SAMD2L2_HAVE_USART
|
||||
void sam_usart_reset(const struct sam_usart_config_s * const config)
|
||||
void sam_usart_reset(const struct sam_usart_config_s *const config)
|
||||
{
|
||||
uintptr_t regaddr = config->base + SAM_USART_CTRLA_OFFSET;
|
||||
uint32_t regval;
|
||||
@ -451,6 +423,33 @@ void sam_usart_reset(const struct sam_usart_config_s * const config)
|
||||
}
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_usart_enable
|
||||
*
|
||||
* Description:
|
||||
* Enable the SERCOM USART (without enabling interrupts).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef SAMD2L2_HAVE_USART
|
||||
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
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_lowputc
|
||||
*
|
||||
|
@ -93,7 +93,7 @@ void sam_lowsetup(void);
|
||||
|
||||
#ifdef SAMD2L2_HAVE_USART
|
||||
struct sam_usart_config_s;
|
||||
int sam_usart_initialize(const struct sam_usart_config_s * const config);
|
||||
int sam_usart_initialize(const struct sam_usart_config_s *const config);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
@ -107,7 +107,20 @@ int sam_usart_initialize(const struct sam_usart_config_s * const config);
|
||||
|
||||
#ifdef SAMD2L2_HAVE_USART
|
||||
struct sam_usart_config_s;
|
||||
void sam_usart_reset(const struct sam_usart_config_s * const config);
|
||||
void sam_usart_reset(const struct sam_usart_config_s *const config);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
* Name: sam_usart_enable
|
||||
*
|
||||
* Description:
|
||||
* Enable the SERCOM USART (without enabling interrupts).
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
#ifdef SAMD2L2_HAVE_USART
|
||||
struct sam_usart_config_s;
|
||||
void sam_usart_enable(const struct sam_usart_config_s *const config);
|
||||
#endif
|
||||
|
||||
/****************************************************************************
|
||||
|
@ -666,6 +666,10 @@ static int sam_setup(struct uart_dev_s *dev)
|
||||
if (!dev->isconsole)
|
||||
{
|
||||
ret = sam_usart_initialize(priv->config);
|
||||
if (ret >= 0)
|
||||
{
|
||||
sam_usart_enable(priv->config);
|
||||
}
|
||||
}
|
||||
#endif
|
||||
|
||||
|
@ -137,6 +137,19 @@ FAR const struct symtab_s *
|
||||
symtab_findbyvalue(FAR const struct symtab_s *symtab,
|
||||
FAR void *value, int nsyms);
|
||||
|
||||
/****************************************************************************
|
||||
* Name: symtab_sortbyname
|
||||
*
|
||||
* Description:
|
||||
* Sort the symbol table by name.
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void symtab_sortbyname(FAR struct symtab_s *symtab, int nsyms);
|
||||
|
||||
#undef EXTERN
|
||||
#if defined(__cplusplus)
|
||||
}
|
||||
|
@ -36,7 +36,7 @@
|
||||
# Symbol table source files
|
||||
|
||||
CSRCS += symtab_findbyname.c symtab_findbyvalue.c
|
||||
CSRCS += symtab_findorderedbyname.c
|
||||
CSRCS += symtab_findorderedbyname.c symtab_sortbyname.c
|
||||
|
||||
# Add the symtab directory to the build
|
||||
|
||||
|
79
libs/libc/symtab/symtab_sortbyname.c
Normal file
79
libs/libc/symtab/symtab_sortbyname.c
Normal file
@ -0,0 +1,79 @@
|
||||
/****************************************************************************
|
||||
* libs/libc/symtab/symtab_sortbyname.c
|
||||
*
|
||||
* Copyright (C) 2019 Pinecone Inc. All rights reserved.
|
||||
* Author: Xiang Xiao <xiaoxiang@pinecone.net>
|
||||
*
|
||||
* 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 <stdlib.h>
|
||||
#include <string.h>
|
||||
#include <assert.h>
|
||||
|
||||
#include <nuttx/symtab.h>
|
||||
|
||||
/****************************************************************************
|
||||
* Private Functions
|
||||
****************************************************************************/
|
||||
|
||||
static int symtab_comparename(FAR const void *arg1, FAR const void *arg2)
|
||||
{
|
||||
FAR const struct symtab_s *symtab1 = arg1;
|
||||
FAR const struct symtab_s *symtab2 = arg2;
|
||||
|
||||
return strcmp(symtab1->sym_name, symtab2->sym_name);
|
||||
}
|
||||
|
||||
/****************************************************************************
|
||||
* Public Functions
|
||||
****************************************************************************/
|
||||
|
||||
/****************************************************************************
|
||||
* Name: symtab_sortbyname
|
||||
*
|
||||
* Description:
|
||||
* Sort the symbol table by name.
|
||||
*
|
||||
* Returned Value:
|
||||
* None.
|
||||
*
|
||||
****************************************************************************/
|
||||
|
||||
void symtab_sortbyname(FAR struct symtab_s *symtab, int nsyms)
|
||||
{
|
||||
DEBUGASSERT(symtab != NULL && nsyms != 0);
|
||||
qsort(symtab, nsyms, sizeof(symtab[0]), symtab_comparename);
|
||||
}
|
Loading…
Reference in New Issue
Block a user