9
0
Fork 0

Fix error in calculating baud rate generation value

git-svn-id: https://nuttx.svn.sourceforge.net/svnroot/nuttx/trunk@1524 7fd9a85b-ad96-42d3-883c-3090e2eb8679
This commit is contained in:
patacongo 2009-02-26 00:40:44 +00:00
parent d42c1c837d
commit 8dc2132ab3
6 changed files with 82 additions and 15 deletions

View File

@ -50,7 +50,7 @@ CHIP_ASRCS += ez80f91_init.asm
endif
CHIP_SSRCS =
CHIP_CSRCS = ez80_initialstate.c ez80_irq.c ez80_copystate.c \
CHIP_CSRCS = ez80_clock.c ez80_initialstate.c ez80_irq.c ez80_copystate.c \
ez80_schedulesigaction.c ez80_sigdeliver.c ez80_timerisr.c \
ez80_lowuart.c ez80_serial.c ez80_registerdump.c
ifeq ($(CONFIG_ARCH_CHIP_EZ80F91),y)

View File

@ -67,7 +67,7 @@
#endif
/************************************************************************************
* Public Function Prototypes
* Public Data
************************************************************************************/
#ifndef __ASSEMBLY__
@ -78,7 +78,13 @@ extern "C" {
#define EXTERN extern
#endif
#undef EXTERN
EXTERN uint32 ez80_systemclock;
/************************************************************************************
* Public Function Prototypes
************************************************************************************/
#undef EXTERN
#ifdef __cplusplus
}
#endif

View File

@ -0,0 +1,65 @@
/****************************************************************************
* arch/z80/src/ez80/ez80_clock.c
*
* Copyright (C) 2009 Gregory Nutt. All rights reserved.
* Author: Gregory Nutt <spudmonkey@racsa.co.cr>
*
* 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 "arch/board/board.h"
/****************************************************************************
* Definitions
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
/****************************************************************************
* Private Data
****************************************************************************/
uint32 ez80_systemclock = EZ80_SYS_CLK_FREQ;
/****************************************************************************
* Private Functions
****************************************************************************/
/****************************************************************************
* Public Functions
****************************************************************************/

View File

@ -57,9 +57,6 @@
/* The system clock frequency is defined in the linkcmd file */
extern unsigned long SYS_CLK_FREQ;
#define _DEFCLK ((unsigned long)&SYS_CLK_FREQ)
#ifdef CONFIG_UART0_SERIAL_CONSOLE
# define ez80_inp(offs) inp((EZ80_UART0_BASE+(offs)))
# define ez80_outp(offs,val) outp((EZ80_UART0_BASE+(offs)), (val))
@ -115,7 +112,7 @@ extern unsigned long SYS_CLK_FREQ;
#ifndef CONFIG_SUPPRESS_UART_CONFIG
static void ez80_setbaud(void)
{
uint24 brg_divisor;
uint32 brg_divisor;
ubyte lctl;
/* The resulting BAUD and depends on the system clock frequency and the
@ -128,7 +125,7 @@ static void ez80_setbaud(void)
* BRG_Divisor = SYSTEM_CLOCK_FREQUENCY / 16 / BAUD
*/
brg_divisor = ( _DEFCLK + (CONFIG_UART_BAUD << 3)) / (CONFIG_UART_BAUD << 4);
brg_divisor = (ez80_systemclock + (CONFIG_UART_BAUD << 3)) / (CONFIG_UART_BAUD << 4);
/* Set the DLAB bit to enable access to the BRG registers */

View File

@ -62,11 +62,6 @@
* Definitions
****************************************************************************/
/* The system clock frequency is defined in the linkcmd file */
extern unsigned long SYS_CLK_FREQ;
#define _DEFCLK ((unsigned long)&SYS_CLK_FREQ)
/****************************************************************************
* Private Types
****************************************************************************/
@ -291,7 +286,7 @@ static inline void ez80_waittxready(struct ez80_dev_s *priv)
static inline void ez80_setbaud(struct ez80_dev_s *priv, uint24 baud)
{
uint24 brg_divisor;
uint32 brg_divisor;
ubyte lctl;
/* The resulting BAUD and depends on the system clock frequency and the
@ -304,7 +299,7 @@ static inline void ez80_setbaud(struct ez80_dev_s *priv, uint24 baud)
* BRG_Divisor = SYSTEM_CLOCK_FREQUENCY / 16 / BAUD
*/
brg_divisor = ( _DEFCLK + (baud << 3)) / (baud << 4);
brg_divisor = (ez80_systemclock + (baud << 3)) / (baud << 4);
/* Set the DLAB bit to enable access to the BRG registers */

View File

@ -44,6 +44,10 @@
* Definitions
****************************************************************************/
/* Clocking */
#define EZ80_SYS_CLK_FREQ 50000000
/* LED pattern definitions ON OFF */
#define LED_STARTED 0 /* '0' N/A */