diff options
author | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-02-26 00:40:44 +0000 |
---|---|---|
committer | patacongo <patacongo@42af7a65-404d-4744-a932-0658087f49c3> | 2009-02-26 00:40:44 +0000 |
commit | e18f7074133d20097fa3d520e7cea6d8144f18b1 (patch) | |
tree | 666a0f33d45be73c2802fd9e773cd5d1a1927b11 /nuttx/arch/z80 | |
parent | a70abf0ba1552acbff40d59e90e4ff10412a3238 (diff) | |
download | px4-nuttx-e18f7074133d20097fa3d520e7cea6d8144f18b1.tar.gz px4-nuttx-e18f7074133d20097fa3d520e7cea6d8144f18b1.tar.bz2 px4-nuttx-e18f7074133d20097fa3d520e7cea6d8144f18b1.zip |
Fix error in calculating baud rate generation value
git-svn-id: svn://svn.code.sf.net/p/nuttx/code/trunk@1524 42af7a65-404d-4744-a932-0658087f49c3
Diffstat (limited to 'nuttx/arch/z80')
-rw-r--r-- | nuttx/arch/z80/src/ez80/Make.defs | 2 | ||||
-rw-r--r-- | nuttx/arch/z80/src/ez80/chip.h | 10 | ||||
-rw-r--r-- | nuttx/arch/z80/src/ez80/ez80_clock.c | 65 | ||||
-rw-r--r-- | nuttx/arch/z80/src/ez80/ez80_lowuart.c | 7 | ||||
-rw-r--r-- | nuttx/arch/z80/src/ez80/ez80_serial.c | 9 |
5 files changed, 78 insertions, 15 deletions
diff --git a/nuttx/arch/z80/src/ez80/Make.defs b/nuttx/arch/z80/src/ez80/Make.defs index 5d8153da5..d729a84df 100644 --- a/nuttx/arch/z80/src/ez80/Make.defs +++ b/nuttx/arch/z80/src/ez80/Make.defs @@ -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) diff --git a/nuttx/arch/z80/src/ez80/chip.h b/nuttx/arch/z80/src/ez80/chip.h index 692b0220f..ca5745f31 100644 --- a/nuttx/arch/z80/src/ez80/chip.h +++ b/nuttx/arch/z80/src/ez80/chip.h @@ -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 diff --git a/nuttx/arch/z80/src/ez80/ez80_clock.c b/nuttx/arch/z80/src/ez80/ez80_clock.c new file mode 100644 index 000000000..4f3134624 --- /dev/null +++ b/nuttx/arch/z80/src/ez80/ez80_clock.c @@ -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 + ****************************************************************************/ diff --git a/nuttx/arch/z80/src/ez80/ez80_lowuart.c b/nuttx/arch/z80/src/ez80/ez80_lowuart.c index bddf693a1..fcc57293c 100644 --- a/nuttx/arch/z80/src/ez80/ez80_lowuart.c +++ b/nuttx/arch/z80/src/ez80/ez80_lowuart.c @@ -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 */ diff --git a/nuttx/arch/z80/src/ez80/ez80_serial.c b/nuttx/arch/z80/src/ez80/ez80_serial.c index 75a780153..face96e42 100644 --- a/nuttx/arch/z80/src/ez80/ez80_serial.c +++ b/nuttx/arch/z80/src/ez80/ez80_serial.c @@ -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 */ |