diff --git a/arch/z80/src/ez80/Make.defs b/arch/z80/src/ez80/Make.defs index 5d8153da56..d729a84df0 100644 --- a/arch/z80/src/ez80/Make.defs +++ b/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/arch/z80/src/ez80/chip.h b/arch/z80/src/ez80/chip.h index 692b0220f3..ca5745f31e 100644 --- a/arch/z80/src/ez80/chip.h +++ b/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/arch/z80/src/ez80/ez80_clock.c b/arch/z80/src/ez80/ez80_clock.c new file mode 100644 index 0000000000..4f3134624e --- /dev/null +++ b/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 + * + * 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 +#include + +#include "arch/board/board.h" + +/**************************************************************************** + * Definitions + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +/**************************************************************************** + * Private Data + ****************************************************************************/ + +uint32 ez80_systemclock = EZ80_SYS_CLK_FREQ; + +/**************************************************************************** + * Private Functions + ****************************************************************************/ + +/**************************************************************************** + * Public Functions + ****************************************************************************/ diff --git a/arch/z80/src/ez80/ez80_lowuart.c b/arch/z80/src/ez80/ez80_lowuart.c index bddf693a1e..fcc57293c5 100644 --- a/arch/z80/src/ez80/ez80_lowuart.c +++ b/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/arch/z80/src/ez80/ez80_serial.c b/arch/z80/src/ez80/ez80_serial.c index 75a780153d..face96e424 100644 --- a/arch/z80/src/ez80/ez80_serial.c +++ b/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 */ diff --git a/configs/ez80f910200zco/include/board.h b/configs/ez80f910200zco/include/board.h index e43c337c1f..ffb8d239b6 100644 --- a/configs/ez80f910200zco/include/board.h +++ b/configs/ez80f910200zco/include/board.h @@ -44,6 +44,10 @@ * Definitions ****************************************************************************/ +/* Clocking */ + +#define EZ80_SYS_CLK_FREQ 50000000 + /* LED pattern definitions ON OFF */ #define LED_STARTED 0 /* '0' N/A */