SAML21: Several SERCOM fixes. No gets UART output, but at the wrong BAUD

This commit is contained in:
Gregory Nutt 2015-05-23 13:08:28 -06:00
parent 84ca7f4a46
commit d495834882
4 changed files with 16 additions and 10 deletions

View File

@ -56,7 +56,7 @@
/* GCLK register offsets ********************************************************************/ /* GCLK register offsets ********************************************************************/
#define SAM_GCLK_CTRLA_OFFSET 0x0000 /* Control register */ #define SAM_GCLK_CTRLA_OFFSET 0x0000 /* Control register */
#define SAM_GCLK_SYNCHBUSY_OFFSET 0x0004 /* Status 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_GENCTRL_OFFSET(n) (0x0020 + ((n) << 2)) /* General clock generator n */
#define SAM_GCLK_PCHCTRL_OFFSET(m) (0x0080 + ((m) << 2)) /* Peripheral channel control m */ #define SAM_GCLK_PCHCTRL_OFFSET(m) (0x0080 + ((m) << 2)) /* Peripheral channel control m */

View File

@ -65,7 +65,7 @@
#define SAM_USART_INTFLAG_OFFSET 0x0018 /* Interrupt flag and status clear register */ #define SAM_USART_INTFLAG_OFFSET 0x0018 /* Interrupt flag and status clear register */
#define SAM_USART_STATUS_OFFSET 0x001a /* Status register */ #define SAM_USART_STATUS_OFFSET 0x001a /* Status register */
#define SAM_USART_SYNCBUSY_OFFSET 0x001c /* Synchronization busy register */ #define SAM_USART_SYNCBUSY_OFFSET 0x001c /* Synchronization busy register */
#define SAM_USART_DATA_OFFSET 0x0018 /* Data register */ #define SAM_USART_DATA_OFFSET 0x0028 /* Data register */
#define SAM_USART_DBGCTRL_OFFSET 0x0030 /* Debug control register */ #define SAM_USART_DBGCTRL_OFFSET 0x0030 /* Debug control register */
/* USART register addresses *****************************************************************/ /* USART register addresses *****************************************************************/
@ -156,11 +156,11 @@
#define USART_CTRLA_IBON (1 << 8) /* Bit 8: Immediate BUFOVF notification */ #define USART_CTRLA_IBON (1 << 8) /* Bit 8: Immediate BUFOVF notification */
#define USART_CTRLA_SAMPR_SHIFT (11) /* Bits 11-12: Sample rate */ #define USART_CTRLA_SAMPR_SHIFT (11) /* Bits 11-12: Sample rate */
#define USART_CTRLA_SAMPR_MASK (3 << USART_CTRLA_SAMPR_SHIFT) #define USART_CTRLA_SAMPR_MASK (3 << USART_CTRLA_SAMPR_SHIFT)
# define USART_CTRLA_SAMPR_16XA (xx << USART_CTRLA_SAMPR_SHIFT) /* 16x oversampling; arithmetic baud */ # define USART_CTRLA_SAMPR_16XA (0 << USART_CTRLA_SAMPR_SHIFT) /* 16x oversampling; arithmetic baud */
# define USART_CTRLA_SAMPR_16XF (xx << USART_CTRLA_SAMPR_SHIFT) /* 16x oversampling; fractional baud */ # define USART_CTRLA_SAMPR_16XF (1 << USART_CTRLA_SAMPR_SHIFT) /* 16x oversampling; fractional baud */
# define USART_CTRLA_SAMPR_8XA (xx << USART_CTRLA_SAMPR_SHIFT) /* 8x oversampling; arithmetic baud */ # define USART_CTRLA_SAMPR_8XA (2 << USART_CTRLA_SAMPR_SHIFT) /* 8x oversampling; arithmetic baud */
# define USART_CTRLA_SAMPR_8XF (xx << USART_CTRLA_SAMPR_SHIFT) /* 8x oversampling; fractional baud */ # define USART_CTRLA_SAMPR_8XF (3 << USART_CTRLA_SAMPR_SHIFT) /* 8x oversampling; fractional baud */
# define USART_CTRLA_SAMPR_3XA (xx << USART_CTRLA_SAMPR_SHIFT) /* 3x oversampling; arithmetic 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_SHIFT (16) /* Bits 16-17: Transmit data pinout */
#define USART_CTRLA_TXPO_MASK (3 << USART_CTRLA_TXPO_SHIFT) #define USART_CTRLA_TXPO_MASK (3 << USART_CTRLA_TXPO_SHIFT)
# define USART_CTRLA_TXPAD0_1 (0 << USART_CTRLA_TXPO_SHIFT) /* TxD=SERCOM PAD[0]; XCK=PAD[1] */ # define USART_CTRLA_TXPAD0_1 (0 << USART_CTRLA_TXPO_SHIFT) /* TxD=SERCOM PAD[0]; XCK=PAD[1] */

View File

@ -132,6 +132,9 @@ sam_usart_configure(const struct sam_usart_config_s * const config)
* *
* BAUD = 63,019 * BAUD = 63,019
* Fbaud = 115,219 * Fbaud = 115,219
*
* REVISIT: For the SAML21, only 16x sampling with arithmetic BAUD is
* supported.
*/ */
tmp = (uint64_t)config->baud << 20; tmp = (uint64_t)config->baud << 20;

View File

@ -45,6 +45,7 @@
#include <stdint.h> #include <stdint.h>
#include <stdbool.h> #include <stdbool.h>
#include <assert.h>
#include "up_arch.h" #include "up_arch.h"
@ -54,6 +55,8 @@
#include "sam_gclk.h" #include "sam_gclk.h"
#include "sam_sercom.h" #include "sam_sercom.h"
#include <arch/board/board.h>
/**************************************************************************** /****************************************************************************
* Pre-processor Definitions * Pre-processor Definitions
****************************************************************************/ ****************************************************************************/
@ -145,7 +148,7 @@ void sercom_coreclk_configure(int sercom, int gclkgen, bool wrlock)
void sercom_slowclk_configure(int gclkgen) void sercom_slowclk_configure(int gclkgen)
{ {
#if defined(CONFIG_ARCH_FAMILY_SAMDL21) #if defined(CONFIG_ARCH_FAMILY_SAML21)
static bool configured = false; static bool configured = false;
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
static uint8_t slowgen = 0xff; static uint8_t slowgen = 0xff;
@ -165,7 +168,7 @@ void sercom_slowclk_configure(int gclkgen)
configured = true; configured = true;
#ifdef CONFIG_DEBUG #ifdef CONFIG_DEBUG
slowgen = (uint8_t)clkgen; slowgen = (uint8_t)gclkgen;
#endif #endif
} }
@ -176,7 +179,7 @@ void sercom_slowclk_configure(int gclkgen)
else else
{ {
DEBUGASSERT((int)slowgen == clkgen); DEBUGASSERT((int)slowgen == gclkgen);
} }
#endif #endif