From 5a5d083e50fd0e5ad9e1b51b2086aff7fc6eeae4 Mon Sep 17 00:00:00 2001 From: Kaspar Schleiser Date: Mon, 6 Dec 2010 16:06:14 +0100 Subject: [PATCH] * msba2: updated pttu port, refactored common code into msba2-common --- board/msba2-common/Jamfile | 6 + board/{msba2 => msba2-common}/Jamfile.msba2 | 3 +- board/msba2-common/Jamrules.msba2 | 34 +++ board/msba2-common/board_common_init.c | 160 ++++++++++++++ board/{msba2 => msba2-common}/config.c | 0 board/msba2-common/drivers/Jamfile | 5 + .../drivers/include/sht11-board.h | 0 .../drivers/include/uart0.h | 0 .../drivers/msba2-cc1100.c | 0 .../drivers/msba2-ltc4150.c | 0 .../drivers/msba2-uart0.c | 0 .../include/msba2_common.h} | 33 +-- .../{msba2 => msba2-common}/lpc2387-timer3.c | 0 board/{msba2 => msba2-common}/tools/CHANGES | 0 board/{msba2 => msba2-common}/tools/COPYING | 0 board/{msba2 => msba2-common}/tools/Makefile | 0 .../{msba2 => msba2-common}/tools/README.txt | 0 .../tools/armtools.txt | 0 board/{msba2 => msba2-common}/tools/flash.cmd | 0 .../tools/flashutil.sh | 0 board/{msba2 => msba2-common}/tools/mkbootc | 0 .../tools/mkstaticlist | 0 .../tools/obj/boot_23xx.d | 0 .../tools/obj/boot_2xxx.d | 0 .../tools/obj/chipinfo.d | 0 .../tools/obj/control_2xxx.d | 0 .../tools/obj/download.d | 0 .../{msba2 => msba2-common}/tools/obj/ihex.d | 0 .../tools/obj/lpc2k_pgm.d | 0 .../tools/obj/pseudoterm.d | 0 .../tools/obj/serial.d | 0 .../tools/obj/uuencode.d | 0 .../{msba2 => msba2-common}/tools/src/Jamfile | 0 .../{msba2 => msba2-common}/tools/src/boot.h | 0 .../tools/src/boot_23xx.armasm | 0 .../tools/src/boot_23xx.c | 0 .../tools/src/boot_23xx.h | 0 .../tools/src/boot_2xxx.armasm | 0 .../tools/src/boot_2xxx.c | 0 .../tools/src/boot_2xxx.h | 0 .../tools/src/chipinfo.c | 0 .../tools/src/chipinfo.h | 0 .../tools/src/cksum_test.c | 0 .../tools/src/control_2xxx.c | 0 .../tools/src/control_2xxx.h | 0 .../tools/src/download.c | 0 .../tools/src/download.h | 0 board/{msba2 => msba2-common}/tools/src/gui.c | 0 board/{msba2 => msba2-common}/tools/src/gui.h | 0 .../{msba2 => msba2-common}/tools/src/ihex.c | 0 .../{msba2 => msba2-common}/tools/src/ihex.h | 0 .../tools/src/lpc2k_pgm.c | 0 .../tools/src/lpc2k_pgm.h | 0 .../tools/src/pseudoterm.c | 0 .../tools/src/serial.c | 0 .../tools/src/serial.h | 0 .../tools/src/settings.c | 0 .../tools/src/settings.h | 0 .../tools/src/uuencode.c | 0 .../tools/src/uuencode.h | 0 .../{msba2 => msba2-common}/tools/termctrl.sh | 0 board/msba2/Jamfile | 10 +- board/msba2/Jamrules.msba2 | 34 +-- board/msba2/board_init.c | 153 ++----------- board/msba2/drivers/Jamfile | 7 - board/msba2/include/board-conf.h | 68 ------ board/msba2/include/board.h | 51 +---- board/pttu/Jamfile | 9 +- board/pttu/Jamrules.pttu | 5 +- board/pttu/board_init.c | 86 +------- board/pttu/drivers/Jamfile | 2 - board/pttu/drivers/pttu-uart0.c | 204 ------------------ 72 files changed, 252 insertions(+), 618 deletions(-) create mode 100644 board/msba2-common/Jamfile rename board/{msba2 => msba2-common}/Jamfile.msba2 (90%) create mode 100644 board/msba2-common/Jamrules.msba2 create mode 100644 board/msba2-common/board_common_init.c rename board/{msba2 => msba2-common}/config.c (100%) create mode 100644 board/msba2-common/drivers/Jamfile rename board/{msba2 => msba2-common}/drivers/include/sht11-board.h (100%) rename board/{msba2 => msba2-common}/drivers/include/uart0.h (100%) rename board/{msba2 => msba2-common}/drivers/msba2-cc1100.c (100%) rename board/{msba2 => msba2-common}/drivers/msba2-ltc4150.c (100%) rename board/{msba2 => msba2-common}/drivers/msba2-uart0.c (100%) rename board/{msba2/drivers/include/hal-board.h => msba2-common/include/msba2_common.h} (74%) rename board/{msba2 => msba2-common}/lpc2387-timer3.c (100%) rename board/{msba2 => msba2-common}/tools/CHANGES (100%) rename board/{msba2 => msba2-common}/tools/COPYING (100%) rename board/{msba2 => msba2-common}/tools/Makefile (100%) rename board/{msba2 => msba2-common}/tools/README.txt (100%) rename board/{msba2 => msba2-common}/tools/armtools.txt (100%) rename board/{msba2 => msba2-common}/tools/flash.cmd (100%) rename board/{msba2 => msba2-common}/tools/flashutil.sh (100%) rename board/{msba2 => msba2-common}/tools/mkbootc (100%) rename board/{msba2 => msba2-common}/tools/mkstaticlist (100%) rename board/{msba2 => msba2-common}/tools/obj/boot_23xx.d (100%) rename board/{msba2 => msba2-common}/tools/obj/boot_2xxx.d (100%) rename board/{msba2 => msba2-common}/tools/obj/chipinfo.d (100%) rename board/{msba2 => msba2-common}/tools/obj/control_2xxx.d (100%) rename board/{msba2 => msba2-common}/tools/obj/download.d (100%) rename board/{msba2 => msba2-common}/tools/obj/ihex.d (100%) rename board/{msba2 => msba2-common}/tools/obj/lpc2k_pgm.d (100%) rename board/{msba2 => msba2-common}/tools/obj/pseudoterm.d (100%) rename board/{msba2 => msba2-common}/tools/obj/serial.d (100%) rename board/{msba2 => msba2-common}/tools/obj/uuencode.d (100%) rename board/{msba2 => msba2-common}/tools/src/Jamfile (100%) rename board/{msba2 => msba2-common}/tools/src/boot.h (100%) rename board/{msba2 => msba2-common}/tools/src/boot_23xx.armasm (100%) rename board/{msba2 => msba2-common}/tools/src/boot_23xx.c (100%) rename board/{msba2 => msba2-common}/tools/src/boot_23xx.h (100%) rename board/{msba2 => msba2-common}/tools/src/boot_2xxx.armasm (100%) rename board/{msba2 => msba2-common}/tools/src/boot_2xxx.c (100%) rename board/{msba2 => msba2-common}/tools/src/boot_2xxx.h (100%) rename board/{msba2 => msba2-common}/tools/src/chipinfo.c (100%) rename board/{msba2 => msba2-common}/tools/src/chipinfo.h (100%) rename board/{msba2 => msba2-common}/tools/src/cksum_test.c (100%) rename board/{msba2 => msba2-common}/tools/src/control_2xxx.c (100%) rename board/{msba2 => msba2-common}/tools/src/control_2xxx.h (100%) rename board/{msba2 => msba2-common}/tools/src/download.c (100%) rename board/{msba2 => msba2-common}/tools/src/download.h (100%) rename board/{msba2 => msba2-common}/tools/src/gui.c (100%) rename board/{msba2 => msba2-common}/tools/src/gui.h (100%) rename board/{msba2 => msba2-common}/tools/src/ihex.c (100%) rename board/{msba2 => msba2-common}/tools/src/ihex.h (100%) rename board/{msba2 => msba2-common}/tools/src/lpc2k_pgm.c (100%) rename board/{msba2 => msba2-common}/tools/src/lpc2k_pgm.h (100%) rename board/{msba2 => msba2-common}/tools/src/pseudoterm.c (100%) rename board/{msba2 => msba2-common}/tools/src/serial.c (100%) rename board/{msba2 => msba2-common}/tools/src/serial.h (100%) rename board/{msba2 => msba2-common}/tools/src/settings.c (100%) rename board/{msba2 => msba2-common}/tools/src/settings.h (100%) rename board/{msba2 => msba2-common}/tools/src/uuencode.c (100%) rename board/{msba2 => msba2-common}/tools/src/uuencode.h (100%) rename board/{msba2 => msba2-common}/tools/termctrl.sh (100%) delete mode 100644 board/msba2/drivers/Jamfile delete mode 100644 board/msba2/include/board-conf.h delete mode 100644 board/pttu/drivers/pttu-uart0.c diff --git a/board/msba2-common/Jamfile b/board/msba2-common/Jamfile new file mode 100644 index 0000000000..8b3d8febcc --- /dev/null +++ b/board/msba2-common/Jamfile @@ -0,0 +1,6 @@ +SubDir TOP board msba2-common ; + +Module board_common : board_common_init.c ; + +SubInclude TOP board msba2-common drivers ; + diff --git a/board/msba2/Jamfile.msba2 b/board/msba2-common/Jamfile.msba2 similarity index 90% rename from board/msba2/Jamfile.msba2 rename to board/msba2-common/Jamfile.msba2 index 44014a6c96..e9e291c906 100644 --- a/board/msba2/Jamfile.msba2 +++ b/board/msba2-common/Jamfile.msba2 @@ -25,7 +25,6 @@ # ****************************************************************************** # $Id$ -#LinkLibraries $(BOARD).elf : sys-drivers.a net_mm.a sys-lib.a fat-lib.a -# cpu_drivers.a board_drivers.a cc110x.a hal.a hal_drivers.a lpc2387_hal.a ; +Module msba2_common : board_init.c ; include [ FPath $(TOP) cpu arm_common Jamfile.arm_common ] ; diff --git a/board/msba2-common/Jamrules.msba2 b/board/msba2-common/Jamrules.msba2 new file mode 100644 index 0000000000..1bce8075c4 --- /dev/null +++ b/board/msba2-common/Jamrules.msba2 @@ -0,0 +1,34 @@ +# ****************************************************************************** +# Copyright 2009, Freie Universitaet Berlin (FUB). All rights reserved. +# +# These sources were developed at the Freie Universitaet Berlin, Computer +# Systems and Telematics group (http://cst.mi.fu-berlin.de). +# ------------------------------------------------------------------------------ +# This file is part of FeuerWare. +# +# This program is free software: you can redistribute it and/or modify it under +# the terms of the GNU General Public License as published by the Free Software +# Foundation, either version 3 of the License, or (at your option) any later +# version. +# +# FeuerWare is distributed in the hope that it will be useful, but WITHOUT +# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. +# +# You should have received a copy of the GNU General Public License along with +# this program. If not, see http://www.gnu.org/licenses/ . +# ------------------------------------------------------------------------------ +# For further information and questions please use the web site +# http://scatterweb.mi.fu-berlin.de +# and the mailinglist (subscription via web site) +# scatterweb@lists.spline.inf.fu-berlin.de +# ****************************************************************************** +# $Id$ + +CPU = lpc2387 ; + +HDRS += [ FPath $(TOP) board msba2-common include ] ; +HDRS += [ FPath $(TOP) board msba2-common drivers include ] ; + +FLASHER ?= $(POSIXSHELL) lpc2k_pgm ; +FLASHFLAGS ?= "$(PORT)" ; diff --git a/board/msba2-common/board_common_init.c b/board/msba2-common/board_common_init.c new file mode 100644 index 0000000000..0823a71bc9 --- /dev/null +++ b/board/msba2-common/board_common_init.c @@ -0,0 +1,160 @@ +/****************************************************************************** +Copyright 2008-2009, Freie Universitaet Berlin (FUB). All rights reserved. + +These sources were developed at the Freie Universitaet Berlin, Computer Systems +and Telematics group (http://cst.mi.fu-berlin.de). +------------------------------------------------------------------------------- +This file is part of FeuerWare. + +This program is free software: you can redistribute it and/or modify it under +the terms of the GNU General Public License as published by the Free Software +Foundation, either version 3 of the License, or (at your option) any later +version. + +FeuerWare is distributed in the hope that it will be useful, but WITHOUT +ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS +FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. + +You should have received a copy of the GNU General Public License along with +this program. If not, see http://www.gnu.org/licenses/ . +-------------------------------------------------------------------------------- +For further information and questions please use the web site + http://scatterweb.mi.fu-berlin.de +and the mailinglist (subscription via web site) + scatterweb@lists.spline.inf.fu-berlin.de +*******************************************************************************/ + +/** + * @ingroup msba2 + * @{ + */ + +/** + * @file + * @brief MSB-A2 board initialization + * + * @author Freie Universität Berlin, Computer Systems & Telematics, FeuerWhere project + * @author Heiko Will + * @author Kaspar Schleiser + * @author Michael Baar + * + * @note $Id$ + */ +#include +#include +#include +#include +#include +#include +#include + +#define PCRTC BIT9 +#define CL_CPU_DIV 4 + +config_t sysconfig = { + 0, ///< default ID + 0, ///< default radio address + 0, ///< default radio channel +}; + +/*---------------------------------------------------------------------------*/ +/** + * @brief Enabling MAM and setting number of clocks used for Flash memory fetch + * @internal + */ +static void +init_mam(void) +{ + MAMCR = 0x0000; + MAMTIM = 0x0003; + MAMCR = 0x0002; +} +/*---------------------------------------------------------------------------*/ +static inline void +pllfeed(void) +{ + PLLFEED = 0xAA; + PLLFEED = 0x55; +} +/*---------------------------------------------------------------------------*/ +void init_clks1(void) +{ + // Disconnect PLL + PLLCON &= ~0x0002; + pllfeed(); + + // Disable PLL + PLLCON &= ~0x0001; + pllfeed(); + + SCS |= 0x20; // Enable main OSC + while( !(SCS & 0x40) ); // Wait until main OSC is usable + + /* select main OSC, 16MHz, as the PLL clock source */ + CLKSRCSEL = 0x0001; + + // Setting Multiplier and Divider values + PLLCFG = 0x0008; // M=9 N=1 Fcco = 288 MHz + pllfeed(); + + // Enabling the PLL */ + PLLCON = 0x0001; + pllfeed(); + + /* Set clock divider to 4 (value+1) */ + CCLKCFG = CL_CPU_DIV - 1; // Fcpu = 72 MHz + +#if USE_USB + USBCLKCFG = USBCLKDivValue; /* usbclk = 288 MHz/6 = 48 MHz */ +#endif +} + +void init_clks2(void){ + // Wait for the PLL to lock to set frequency + while(!(PLLSTAT & BIT26)); + + // Connect the PLL as the clock source + PLLCON = 0x0003; + pllfeed(); + + /* Check connect bit status */ + while (!(PLLSTAT & BIT25)); +} + +void bl_init_clks(void) +{ + PCONP = PCRTC; // switch off everything except RTC + init_clks1(); + init_clks2(); + init_mam(); +} + +void loop_delay(void) { + volatile uint16_t i, j; + for (i = 1; i < 30; i++) { + for (j = 1; j != 0; j++) { + asm volatile (" nop "); + } + } +} + +/*void bl_blink(void) { + LED_RED_ON; + LED_GREEN_ON; + + loop_delay(); + + LED_RED_OFF; + LED_GREEN_OFF; +}*/ + +// void bl_config_init(void) { +// extern char configmem[]; +// if (*((uint16_t*) configmem) == CONFIG_KEY) { +// memcpy(&sysconfig, (configmem + sizeof(CONFIG_KEY)), sizeof(sysconfig)); +// LED_GREEN_TOGGLE; +// } +// else { +// config_save(); +// } +// } diff --git a/board/msba2/config.c b/board/msba2-common/config.c similarity index 100% rename from board/msba2/config.c rename to board/msba2-common/config.c diff --git a/board/msba2-common/drivers/Jamfile b/board/msba2-common/drivers/Jamfile new file mode 100644 index 0000000000..9637982162 --- /dev/null +++ b/board/msba2-common/drivers/Jamfile @@ -0,0 +1,5 @@ +SubDir TOP board msba2-common drivers ; + +Module board_cc1100 : msba2-cc1100.c ; +Module board_ltc4150 : msba2-ltc4150.c : gpioint ; +Module board_uart : msba2-uart0.c : chardev_thread ringbuffer ; diff --git a/board/msba2/drivers/include/sht11-board.h b/board/msba2-common/drivers/include/sht11-board.h similarity index 100% rename from board/msba2/drivers/include/sht11-board.h rename to board/msba2-common/drivers/include/sht11-board.h diff --git a/board/msba2/drivers/include/uart0.h b/board/msba2-common/drivers/include/uart0.h similarity index 100% rename from board/msba2/drivers/include/uart0.h rename to board/msba2-common/drivers/include/uart0.h diff --git a/board/msba2/drivers/msba2-cc1100.c b/board/msba2-common/drivers/msba2-cc1100.c similarity index 100% rename from board/msba2/drivers/msba2-cc1100.c rename to board/msba2-common/drivers/msba2-cc1100.c diff --git a/board/msba2/drivers/msba2-ltc4150.c b/board/msba2-common/drivers/msba2-ltc4150.c similarity index 100% rename from board/msba2/drivers/msba2-ltc4150.c rename to board/msba2-common/drivers/msba2-ltc4150.c diff --git a/board/msba2/drivers/msba2-uart0.c b/board/msba2-common/drivers/msba2-uart0.c similarity index 100% rename from board/msba2/drivers/msba2-uart0.c rename to board/msba2-common/drivers/msba2-uart0.c diff --git a/board/msba2/drivers/include/hal-board.h b/board/msba2-common/include/msba2_common.h similarity index 74% rename from board/msba2/drivers/include/hal-board.h rename to board/msba2-common/include/msba2_common.h index a4dfc293ab..a9d9d3e72c 100644 --- a/board/msba2/drivers/include/hal-board.h +++ b/board/msba2-common/include/msba2_common.h @@ -24,45 +24,28 @@ and the mailinglist (subscription via web site) scatterweb@lists.spline.inf.fu-berlin.de *******************************************************************************/ -#ifndef HALPLATFORM_H_ -#define HALPLATFORM_H_ +#ifndef __BOARD_H +#define __BOARD_H /** - * @ingroup msba2 + * @ingroup msb_a2 * @{ */ /** * @file - * @brief + * @brief MSB-A2 Common Board Definitions * * @author Freie Universität Berlin, Computer Systems & Telematics, FeuerWhere project - * @author baar + * @author Kaspar Schleiser * @version $Revision$ * * @note $Id$ */ -#include "vdevice.h" -#include "device-gpio.h" -#include "device-rs232.h" -#include "device-serial.h" +#include -VDEVICE_NAME(vdevice_gpio, gpio_led_green); -VDEVICE_NAME(vdevice_gpio, gpio_led_red); -VDEVICE_NAME(vdevice_gpio, gpio_led_usb); - -/** - * @var tty0 - * @brief RS232 TTY0 device on UART0 - */ -VDEVICE_NAME(vdevice_rs232, tty0); - -/** - * @var console0 - * @brief console device on tty0 - */ -VDEVICE_NAME(vdevice_serial, console0); +#define VICIntEnClear VICIntEnClr /** @} */ -#endif /* HALPLATFORM_H_ */ +#endif // __BOARD_H diff --git a/board/msba2/lpc2387-timer3.c b/board/msba2-common/lpc2387-timer3.c similarity index 100% rename from board/msba2/lpc2387-timer3.c rename to board/msba2-common/lpc2387-timer3.c diff --git a/board/msba2/tools/CHANGES b/board/msba2-common/tools/CHANGES similarity index 100% rename from board/msba2/tools/CHANGES rename to board/msba2-common/tools/CHANGES diff --git a/board/msba2/tools/COPYING b/board/msba2-common/tools/COPYING similarity index 100% rename from board/msba2/tools/COPYING rename to board/msba2-common/tools/COPYING diff --git a/board/msba2/tools/Makefile b/board/msba2-common/tools/Makefile similarity index 100% rename from board/msba2/tools/Makefile rename to board/msba2-common/tools/Makefile diff --git a/board/msba2/tools/README.txt b/board/msba2-common/tools/README.txt similarity index 100% rename from board/msba2/tools/README.txt rename to board/msba2-common/tools/README.txt diff --git a/board/msba2/tools/armtools.txt b/board/msba2-common/tools/armtools.txt similarity index 100% rename from board/msba2/tools/armtools.txt rename to board/msba2-common/tools/armtools.txt diff --git a/board/msba2/tools/flash.cmd b/board/msba2-common/tools/flash.cmd similarity index 100% rename from board/msba2/tools/flash.cmd rename to board/msba2-common/tools/flash.cmd diff --git a/board/msba2/tools/flashutil.sh b/board/msba2-common/tools/flashutil.sh similarity index 100% rename from board/msba2/tools/flashutil.sh rename to board/msba2-common/tools/flashutil.sh diff --git a/board/msba2/tools/mkbootc b/board/msba2-common/tools/mkbootc similarity index 100% rename from board/msba2/tools/mkbootc rename to board/msba2-common/tools/mkbootc diff --git a/board/msba2/tools/mkstaticlist b/board/msba2-common/tools/mkstaticlist similarity index 100% rename from board/msba2/tools/mkstaticlist rename to board/msba2-common/tools/mkstaticlist diff --git a/board/msba2/tools/obj/boot_23xx.d b/board/msba2-common/tools/obj/boot_23xx.d similarity index 100% rename from board/msba2/tools/obj/boot_23xx.d rename to board/msba2-common/tools/obj/boot_23xx.d diff --git a/board/msba2/tools/obj/boot_2xxx.d b/board/msba2-common/tools/obj/boot_2xxx.d similarity index 100% rename from board/msba2/tools/obj/boot_2xxx.d rename to board/msba2-common/tools/obj/boot_2xxx.d diff --git a/board/msba2/tools/obj/chipinfo.d b/board/msba2-common/tools/obj/chipinfo.d similarity index 100% rename from board/msba2/tools/obj/chipinfo.d rename to board/msba2-common/tools/obj/chipinfo.d diff --git a/board/msba2/tools/obj/control_2xxx.d b/board/msba2-common/tools/obj/control_2xxx.d similarity index 100% rename from board/msba2/tools/obj/control_2xxx.d rename to board/msba2-common/tools/obj/control_2xxx.d diff --git a/board/msba2/tools/obj/download.d b/board/msba2-common/tools/obj/download.d similarity index 100% rename from board/msba2/tools/obj/download.d rename to board/msba2-common/tools/obj/download.d diff --git a/board/msba2/tools/obj/ihex.d b/board/msba2-common/tools/obj/ihex.d similarity index 100% rename from board/msba2/tools/obj/ihex.d rename to board/msba2-common/tools/obj/ihex.d diff --git a/board/msba2/tools/obj/lpc2k_pgm.d b/board/msba2-common/tools/obj/lpc2k_pgm.d similarity index 100% rename from board/msba2/tools/obj/lpc2k_pgm.d rename to board/msba2-common/tools/obj/lpc2k_pgm.d diff --git a/board/msba2/tools/obj/pseudoterm.d b/board/msba2-common/tools/obj/pseudoterm.d similarity index 100% rename from board/msba2/tools/obj/pseudoterm.d rename to board/msba2-common/tools/obj/pseudoterm.d diff --git a/board/msba2/tools/obj/serial.d b/board/msba2-common/tools/obj/serial.d similarity index 100% rename from board/msba2/tools/obj/serial.d rename to board/msba2-common/tools/obj/serial.d diff --git a/board/msba2/tools/obj/uuencode.d b/board/msba2-common/tools/obj/uuencode.d similarity index 100% rename from board/msba2/tools/obj/uuencode.d rename to board/msba2-common/tools/obj/uuencode.d diff --git a/board/msba2/tools/src/Jamfile b/board/msba2-common/tools/src/Jamfile similarity index 100% rename from board/msba2/tools/src/Jamfile rename to board/msba2-common/tools/src/Jamfile diff --git a/board/msba2/tools/src/boot.h b/board/msba2-common/tools/src/boot.h similarity index 100% rename from board/msba2/tools/src/boot.h rename to board/msba2-common/tools/src/boot.h diff --git a/board/msba2/tools/src/boot_23xx.armasm b/board/msba2-common/tools/src/boot_23xx.armasm similarity index 100% rename from board/msba2/tools/src/boot_23xx.armasm rename to board/msba2-common/tools/src/boot_23xx.armasm diff --git a/board/msba2/tools/src/boot_23xx.c b/board/msba2-common/tools/src/boot_23xx.c similarity index 100% rename from board/msba2/tools/src/boot_23xx.c rename to board/msba2-common/tools/src/boot_23xx.c diff --git a/board/msba2/tools/src/boot_23xx.h b/board/msba2-common/tools/src/boot_23xx.h similarity index 100% rename from board/msba2/tools/src/boot_23xx.h rename to board/msba2-common/tools/src/boot_23xx.h diff --git a/board/msba2/tools/src/boot_2xxx.armasm b/board/msba2-common/tools/src/boot_2xxx.armasm similarity index 100% rename from board/msba2/tools/src/boot_2xxx.armasm rename to board/msba2-common/tools/src/boot_2xxx.armasm diff --git a/board/msba2/tools/src/boot_2xxx.c b/board/msba2-common/tools/src/boot_2xxx.c similarity index 100% rename from board/msba2/tools/src/boot_2xxx.c rename to board/msba2-common/tools/src/boot_2xxx.c diff --git a/board/msba2/tools/src/boot_2xxx.h b/board/msba2-common/tools/src/boot_2xxx.h similarity index 100% rename from board/msba2/tools/src/boot_2xxx.h rename to board/msba2-common/tools/src/boot_2xxx.h diff --git a/board/msba2/tools/src/chipinfo.c b/board/msba2-common/tools/src/chipinfo.c similarity index 100% rename from board/msba2/tools/src/chipinfo.c rename to board/msba2-common/tools/src/chipinfo.c diff --git a/board/msba2/tools/src/chipinfo.h b/board/msba2-common/tools/src/chipinfo.h similarity index 100% rename from board/msba2/tools/src/chipinfo.h rename to board/msba2-common/tools/src/chipinfo.h diff --git a/board/msba2/tools/src/cksum_test.c b/board/msba2-common/tools/src/cksum_test.c similarity index 100% rename from board/msba2/tools/src/cksum_test.c rename to board/msba2-common/tools/src/cksum_test.c diff --git a/board/msba2/tools/src/control_2xxx.c b/board/msba2-common/tools/src/control_2xxx.c similarity index 100% rename from board/msba2/tools/src/control_2xxx.c rename to board/msba2-common/tools/src/control_2xxx.c diff --git a/board/msba2/tools/src/control_2xxx.h b/board/msba2-common/tools/src/control_2xxx.h similarity index 100% rename from board/msba2/tools/src/control_2xxx.h rename to board/msba2-common/tools/src/control_2xxx.h diff --git a/board/msba2/tools/src/download.c b/board/msba2-common/tools/src/download.c similarity index 100% rename from board/msba2/tools/src/download.c rename to board/msba2-common/tools/src/download.c diff --git a/board/msba2/tools/src/download.h b/board/msba2-common/tools/src/download.h similarity index 100% rename from board/msba2/tools/src/download.h rename to board/msba2-common/tools/src/download.h diff --git a/board/msba2/tools/src/gui.c b/board/msba2-common/tools/src/gui.c similarity index 100% rename from board/msba2/tools/src/gui.c rename to board/msba2-common/tools/src/gui.c diff --git a/board/msba2/tools/src/gui.h b/board/msba2-common/tools/src/gui.h similarity index 100% rename from board/msba2/tools/src/gui.h rename to board/msba2-common/tools/src/gui.h diff --git a/board/msba2/tools/src/ihex.c b/board/msba2-common/tools/src/ihex.c similarity index 100% rename from board/msba2/tools/src/ihex.c rename to board/msba2-common/tools/src/ihex.c diff --git a/board/msba2/tools/src/ihex.h b/board/msba2-common/tools/src/ihex.h similarity index 100% rename from board/msba2/tools/src/ihex.h rename to board/msba2-common/tools/src/ihex.h diff --git a/board/msba2/tools/src/lpc2k_pgm.c b/board/msba2-common/tools/src/lpc2k_pgm.c similarity index 100% rename from board/msba2/tools/src/lpc2k_pgm.c rename to board/msba2-common/tools/src/lpc2k_pgm.c diff --git a/board/msba2/tools/src/lpc2k_pgm.h b/board/msba2-common/tools/src/lpc2k_pgm.h similarity index 100% rename from board/msba2/tools/src/lpc2k_pgm.h rename to board/msba2-common/tools/src/lpc2k_pgm.h diff --git a/board/msba2/tools/src/pseudoterm.c b/board/msba2-common/tools/src/pseudoterm.c similarity index 100% rename from board/msba2/tools/src/pseudoterm.c rename to board/msba2-common/tools/src/pseudoterm.c diff --git a/board/msba2/tools/src/serial.c b/board/msba2-common/tools/src/serial.c similarity index 100% rename from board/msba2/tools/src/serial.c rename to board/msba2-common/tools/src/serial.c diff --git a/board/msba2/tools/src/serial.h b/board/msba2-common/tools/src/serial.h similarity index 100% rename from board/msba2/tools/src/serial.h rename to board/msba2-common/tools/src/serial.h diff --git a/board/msba2/tools/src/settings.c b/board/msba2-common/tools/src/settings.c similarity index 100% rename from board/msba2/tools/src/settings.c rename to board/msba2-common/tools/src/settings.c diff --git a/board/msba2/tools/src/settings.h b/board/msba2-common/tools/src/settings.h similarity index 100% rename from board/msba2/tools/src/settings.h rename to board/msba2-common/tools/src/settings.h diff --git a/board/msba2/tools/src/uuencode.c b/board/msba2-common/tools/src/uuencode.c similarity index 100% rename from board/msba2/tools/src/uuencode.c rename to board/msba2-common/tools/src/uuencode.c diff --git a/board/msba2/tools/src/uuencode.h b/board/msba2-common/tools/src/uuencode.h similarity index 100% rename from board/msba2/tools/src/uuencode.h rename to board/msba2-common/tools/src/uuencode.h diff --git a/board/msba2/tools/termctrl.sh b/board/msba2-common/tools/termctrl.sh similarity index 100% rename from board/msba2/tools/termctrl.sh rename to board/msba2-common/tools/termctrl.sh diff --git a/board/msba2/Jamfile b/board/msba2/Jamfile index 468b453066..553522ba68 100644 --- a/board/msba2/Jamfile +++ b/board/msba2/Jamfile @@ -25,12 +25,12 @@ # ****************************************************************************** # $Id$ -SubDir TOP board msba2 ; +SubDir TOP board $(BOARD) ; -Module board : board_init.c ; -Module config : config.c ; +Module board : board_init.c : board_common board_uart ; UseModule board ; -UseModule board_common ; -SubInclude TOP board $(BOARD) drivers ; +Module config : config.c ; + +SubInclude TOP board $(BOARD)-common ; SubInclude TOP cpu $(CPU) ; diff --git a/board/msba2/Jamrules.msba2 b/board/msba2/Jamrules.msba2 index b0ad55f759..22c8a88060 100644 --- a/board/msba2/Jamrules.msba2 +++ b/board/msba2/Jamrules.msba2 @@ -1,33 +1 @@ -# ****************************************************************************** -# Copyright 2009, Freie Universitaet Berlin (FUB). All rights reserved. -# -# These sources were developed at the Freie Universitaet Berlin, Computer -# Systems and Telematics group (http://cst.mi.fu-berlin.de). -# ------------------------------------------------------------------------------ -# This file is part of FeuerWare. -# -# This program is free software: you can redistribute it and/or modify it under -# the terms of the GNU General Public License as published by the Free Software -# Foundation, either version 3 of the License, or (at your option) any later -# version. -# -# FeuerWare is distributed in the hope that it will be useful, but WITHOUT -# ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -# FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. -# -# You should have received a copy of the GNU General Public License along with -# this program. If not, see http://www.gnu.org/licenses/ . -# ------------------------------------------------------------------------------ -# For further information and questions please use the web site -# http://scatterweb.mi.fu-berlin.de -# and the mailinglist (subscription via web site) -# scatterweb@lists.spline.inf.fu-berlin.de -# ****************************************************************************** -# $Id$ - -CPU = lpc2387 ; - -HDRS += [ FPath $(TOP) board $(BOARD) drivers include ] ; - -FLASHER ?= $(POSIXSHELL) lpc2k_pgm ; -FLASHFLAGS ?= "$(PORT)" ; +include board/msba2-common/Jamrules.msba2 ; diff --git a/board/msba2/board_init.c b/board/msba2/board_init.c index 469c8fe7cd..f250109c08 100644 --- a/board/msba2/board_init.c +++ b/board/msba2/board_init.c @@ -1,140 +1,6 @@ -/****************************************************************************** -Copyright 2008-2009, Freie Universitaet Berlin (FUB). All rights reserved. - -These sources were developed at the Freie Universitaet Berlin, Computer Systems -and Telematics group (http://cst.mi.fu-berlin.de). -------------------------------------------------------------------------------- -This file is part of FeuerWare. - -This program is free software: you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -FeuerWare is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program. If not, see http://www.gnu.org/licenses/ . --------------------------------------------------------------------------------- -For further information and questions please use the web site - http://scatterweb.mi.fu-berlin.de -and the mailinglist (subscription via web site) - scatterweb@lists.spline.inf.fu-berlin.de -*******************************************************************************/ - -/** - * @ingroup msba2 - * @{ - */ - -/** - * @file - * @brief MSB-A2 board initialization - * - * @author Freie Universität Berlin, Computer Systems & Telematics, FeuerWhere project - * @author Heiko Will - * @author Kaspar Schleiser - * @author Michael Baar - * - * @note $Id$ - */ #include -#include -#include #include -#define PCRTC BIT9 -#define CL_CPU_DIV 4 - -/*---------------------------------------------------------------------------*/ -/** - * @brief Enabling MAM and setting number of clocks used for Flash memory fetch - * @internal - */ -static void -init_mam(void) -{ - MAMCR = 0x0000; - MAMTIM = 0x0003; - MAMCR = 0x0002; -} -/*---------------------------------------------------------------------------*/ -static inline void -pllfeed(void) -{ - PLLFEED = 0xAA; - PLLFEED = 0x55; -} -/*---------------------------------------------------------------------------*/ -void init_clks1(void) -{ - // Disconnect PLL - PLLCON &= ~0x0002; - pllfeed(); - - // Disable PLL - PLLCON &= ~0x0001; - pllfeed(); - - SCS |= 0x20; // Enable main OSC - while( !(SCS & 0x40) ); // Wait until main OSC is usable - - /* select main OSC, 16MHz, as the PLL clock source */ - CLKSRCSEL = 0x0001; - - // Setting Multiplier and Divider values - PLLCFG = 0x0008; // M=9 N=1 Fcco = 288 MHz - pllfeed(); - - // Enabling the PLL */ - PLLCON = 0x0001; - pllfeed(); - - /* Set clock divider to 4 (value+1) */ - CCLKCFG = CL_CPU_DIV - 1; // Fcpu = 72 MHz - -#if USE_USB - USBCLKCFG = USBCLKDivValue; /* usbclk = 288 MHz/6 = 48 MHz */ -#endif -} - -void init_clks2(void){ - // Wait for the PLL to lock to set frequency - while(!(PLLSTAT & BIT26)); - - // Connect the PLL as the clock source - PLLCON = 0x0003; - pllfeed(); - - /* Check connect bit status */ - while (!(PLLSTAT & BIT25)); -} - -void bl_init_clks(void) -{ - PCONP = PCRTC; // switch off everything except RTC - init_clks1(); - init_clks2(); - init_mam(); -} - -void bl_init_ports(void) -{ - SCS |= BIT0; // Set IO Ports to fast switching mode - - /* UART0 */ - PINSEL0 |= BIT4 + BIT6; // RxD0 and TxD0 - PINSEL0 &= ~(BIT5 + BIT7); - - /* LEDS */ - FIO3DIR |= LED_RED_PIN; - FIO3DIR |= LED_GREEN_PIN; - LED_RED_OFF; - LED_GREEN_OFF; -} - void loop_delay(void) { volatile uint16_t i, j; for (i = 1; i < 30; i++) { @@ -153,3 +19,22 @@ void bl_blink(void) { LED_RED_OFF; LED_GREEN_OFF; } + +void bl_init_ports(void) +{ + SCS |= BIT0; // Set IO Ports to fast switching mode + + /* UART0 */ + PINSEL0 |= BIT4 + BIT6; // RxD0 and TxD0 + PINSEL0 &= ~(BIT5 + BIT7); + + /* LEDS */ + FIO3DIR |= LED_RED_PIN; + FIO3DIR |= LED_GREEN_PIN; + LED_RED_OFF; + LED_GREEN_OFF; + + /* short blinking of both of the LEDs on startup */ + bl_blink(); +} + diff --git a/board/msba2/drivers/Jamfile b/board/msba2/drivers/Jamfile deleted file mode 100644 index 50f2ddbf01..0000000000 --- a/board/msba2/drivers/Jamfile +++ /dev/null @@ -1,7 +0,0 @@ -SubDir TOP board msba2 drivers ; - -Module board_cc1100 : msba2-cc1100.c : gpioint cc110x_spi ; -Module board_hal : msba2-hal.c ; -Module board_ltc4150 : msba2-ltc4150.c : gpioint ; -Module board_common : msba2-uart0.c : ringbuffer ; -Module board_uart : msba2-uart0_thread.c : chardev_thread ringbuffer ; diff --git a/board/msba2/include/board-conf.h b/board/msba2/include/board-conf.h deleted file mode 100644 index 2c8824f1fc..0000000000 --- a/board/msba2/include/board-conf.h +++ /dev/null @@ -1,68 +0,0 @@ -/****************************************************************************** -Copyright 2008, Freie Universitaet Berlin (FUB). All rights reserved. - -These sources were developed at the Freie Universitaet Berlin, Computer Systems -and Telematics group (http://cst.mi.fu-berlin.de). -------------------------------------------------------------------------------- -This file is part of FeuerWare. - -This program is free software: you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -FeuerWare is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program. If not, see http://www.gnu.org/licenses/ . --------------------------------------------------------------------------------- -For further information and questions please use the web site - http://scatterweb.mi.fu-berlin.de -and the mailinglist (subscription via web site) - scatterweb@lists.spline.inf.fu-berlin.de -*******************************************************************************/ - -#ifndef BOARDCONF_H_ -#define BOARDCONF_H_ - -/** - * @ingroup conf - * @ingroup msba2 - * - * @{ - */ - -/** - * @file - * @brief MSB-A2 board configuration - * - * @author Freie Universität Berlin, Computer Systems & Telematics, FeuerWhere project - * @author baar - * @version $Revision$ - * - * @note $Id$ - */ - -#define FEUERWARE_CONF_BOARD_NAME "FU Berlin MSB-A2" - -#ifdef MODULE_CC110X -#define FEUERWARE_CONF_NUM_RADIOS 1 -#else -#define FEUERWARE_CONF_NUM_RADIOS 0 -#endif - -// if FAT is enabled this board supports files -#define FEUERWARE_CONF_CORE_SUPPORTS_FILES defined(MODULE_FAT) - -#ifdef MODULE_FAT -#define CFG_CONF_MEM_SIZE 0x7FFFFFFF -#define SYSLOG_CONF_NUM_INTERFACES 2 -#else -#define SYSLOG_CONF_NUM_INTERFACES 1 -#endif - - -/** @} */ -#endif /* BOARDCONF_H_ */ diff --git a/board/msba2/include/board.h b/board/msba2/include/board.h index 4356e4423f..bf596f0ee1 100644 --- a/board/msba2/include/board.h +++ b/board/msba2/include/board.h @@ -1,51 +1,7 @@ -/****************************************************************************** -Copyright 2008, Freie Universitaet Berlin (FUB). All rights reserved. - -These sources were developed at the Freie Universitaet Berlin, Computer Systems -and Telematics group (http://cst.mi.fu-berlin.de). -------------------------------------------------------------------------------- -This file is part of FeuerWare. - -This program is free software: you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -FeuerWare is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program. If not, see http://www.gnu.org/licenses/ . --------------------------------------------------------------------------------- -For further information and questions please use the web site - http://scatterweb.mi.fu-berlin.de -and the mailinglist (subscription via web site) - scatterweb@lists.spline.inf.fu-berlin.de -*******************************************************************************/ - #ifndef __BOARD_H -#define __BOARD_H +#define __BOARD_H -/** - * @ingroup msb_a2 - * @{ - */ - -/** - * @file - * @brief MSB-A2 Board - * - * @author Freie Universität Berlin, Computer Systems & Telematics, FeuerWhere project - * @author Kaspar Schleiser - * @version $Revision$ - * - * @note $Id$ - */ - -#include - -#define VICIntEnClear VICIntEnClr +#include #define LED_RED_PIN (BIT25) #define LED_GREEN_PIN (BIT26) @@ -58,5 +14,4 @@ and the mailinglist (subscription via web site) #define LED_RED_ON (FIO3CLR = LED_RED_PIN) #define LED_RED_TOGGLE (FIO3PIN ^= LED_RED_PIN) -/** @} */ -#endif // __BOARD_H +#endif /* __BOARD_H */ diff --git a/board/pttu/Jamfile b/board/pttu/Jamfile index a7b4d6df11..11b4a77e7e 100644 --- a/board/pttu/Jamfile +++ b/board/pttu/Jamfile @@ -23,13 +23,12 @@ # and the mailinglist (subscription via web site) # scatterweb@lists.spline.inf.fu-berlin.de # ****************************************************************************** -# $Id: Jamfile 922 2009-03-26 12:52:27Z baar $ +# $Id$ -SubDir TOP board pttu ; +SubDir TOP board $(BOARD) ; -Module board : board_init.c ; +Module board : board_init.c : board_common board_uart ; UseModule board ; -UseModule board_common ; -SubInclude TOP board $(BOARD) drivers ; +SubInclude TOP board msba2-common ; SubInclude TOP cpu $(CPU) ; diff --git a/board/pttu/Jamrules.pttu b/board/pttu/Jamrules.pttu index 7eff15f0bb..53e71c71f1 100644 --- a/board/pttu/Jamrules.pttu +++ b/board/pttu/Jamrules.pttu @@ -25,13 +25,10 @@ # ****************************************************************************** # $Id: Jamrules.msba2 881 2009-03-20 12:24:58Z kaspar $ -CPU = lpc2387 ; +include board/msba2-common/Jamrules.msba2 ; HDRS += [ FPath $(TOP) board $(BOARD) drivers include ] ; -FLASHER = $(POSIXSHELL) $(TOP)/board/msba2/tools/flashutil.sh ; -FLASHFLAGS = --basedir $(TOP)/board/msba2/tools --id PTTU --ports "$(PORT)" --openocd $(TOP)/board/pttu/tools/openocd-pttu.sh --openocd-if $(OPENOCD_IF) ; - GDB = arm-elf-gdb ; GDBFLAGS = -x board/pttu/tools/pttu_debug.gdb ; diff --git a/board/pttu/board_init.c b/board/pttu/board_init.c index 3070bdfce7..b5b78bde25 100644 --- a/board/pttu/board_init.c +++ b/board/pttu/board_init.c @@ -33,94 +33,18 @@ and the mailinglist (subscription via web site) * @file * @brief PTTU board initialization * - * @author Freie Universit�t Berlin, Computer Systems & Telematics, FeuerWhere project + * @author Freie Universität Berlin, Computer Systems & Telematics, FeuerWhere project * @author Heiko Will - * @author Kaspar Schleise - * @author Michael Baar + * @author Kaspar Schleiser * - * @note $Id: cmdengine-out.c 971 2009-04-07 13:41:36Z baar $ */ -#include "lpc23xx.h" -#include "VIC.h" -#include "cpu.h" +#include +#include +#include #define PCRTC BIT9 #define CL_CPU_DIV 4 -/*---------------------------------------------------------------------------*/ -/** - * @brief Enabling MAM and setting number of clocks used for Flash memory fetch - * @internal - */ -void -init_mam(void) -{ - MAMCR = 0x0000; - MAMTIM = 0x0003; - MAMCR = 0x0002; -} -/*---------------------------------------------------------------------------*/ -static inline void -pllfeed(void) -{ - PLLFEED = 0xAA; - PLLFEED = 0x55; -} -/*---------------------------------------------------------------------------*/ -void init_clks1(void) -{ - // Disconnect PLL - PLLCON &= ~0x0002; - pllfeed(); - - // Disable PLL - PLLCON &= ~0x0001; - pllfeed(); - - SCS |= 0x20; // Enable main OSC - while( !(SCS & 0x40) ); // Wait until main OSC is usable - - /* select main OSC, 16MHz, as the PLL clock source */ - CLKSRCSEL = 0x0001; - - // Setting Multiplier and Divider values - PLLCFG = 0x0008; // M=9 N=1 Fcco = 288 MHz - pllfeed(); - - // Enabling the PLL */ - PLLCON = 0x0001; - pllfeed(); - - /* Set clock divider to 4 (value+1) */ - CCLKCFG = CL_CPU_DIV - 1; // Fcpu = 72 MHz - -#if USE_USB - USBCLKCFG = USBCLKDivValue; /* usbclk = 288 MHz/6 = 48 MHz */ -#endif -} - -void init_clks2(void){ - // Wait for the PLL to lock to set frequency - while(!(PLLSTAT & BIT26)); - - // Connect the PLL as the clock source - PLLCON = 0x0003; - pllfeed(); - - /* Check connect bit status */ - while (!(PLLSTAT & BIT25)); -} - -void bl_init_clks(void) -{ - PCONP = PCRTC; // switch off everything except RTC - init_clks1(); - init_clks2(); - init_mam(); -} - - -// Michael, Do not change anything here! even not the redundant parts! void bl_init_ports(void) { SCS |= BIT0; // Set IO Ports to fast switching mode diff --git a/board/pttu/drivers/Jamfile b/board/pttu/drivers/Jamfile index 26a8b7c2af..31d6db1d6d 100644 --- a/board/pttu/drivers/Jamfile +++ b/board/pttu/drivers/Jamfile @@ -1,4 +1,2 @@ SubDir TOP board pttu drivers ; -Module board_common : pttu-uart0.c ; - diff --git a/board/pttu/drivers/pttu-uart0.c b/board/pttu/drivers/pttu-uart0.c deleted file mode 100644 index d542f22602..0000000000 --- a/board/pttu/drivers/pttu-uart0.c +++ /dev/null @@ -1,204 +0,0 @@ -/****************************************************************************** -Copyright 2008-2009, Freie Universitaet Berlin (FUB). All rights reserved. - -These sources were developed at the Freie Universitaet Berlin, Computer Systems -and Telematics group (http://cst.mi.fu-berlin.de). -------------------------------------------------------------------------------- -This file is part of FeuerWare. - -This program is free software: you can redistribute it and/or modify it under -the terms of the GNU General Public License as published by the Free Software -Foundation, either version 3 of the License, or (at your option) any later -version. - -FeuerWare is distributed in the hope that it will be useful, but WITHOUT -ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or FITNESS -FOR A PARTICULAR PURPOSE. See the GNU General Public License for more details. - -You should have received a copy of the GNU General Public License along with -this program. If not, see http://www.gnu.org/licenses/ . --------------------------------------------------------------------------------- -For further information and questions please use the web site - http://scatterweb.mi.fu-berlin.de -and the mailinglist (subscription via web site) - scatterweb@lists.spline.inf.fu-berlin.de -*******************************************************************************/ - -/* - * debug_uart.c: provides initial serial debug output - * - * Copyright (C) 2008, 2009 Kaspar Schleiser - * Heiko Will - */ -#include -#include -#include -#include "lpc23xx.h" -#include "VIC.h" - -/** - * @file - * @ingroup lpc2387 - * - * @author Freie Universität Berlin, Computer Systems & Telematics, FeuerWhere project - * @version $Revision$ - * - * @note $Id$ - */ - -typedef struct toprint { - unsigned int len; - char content[]; -}toprint; - -#define QUEUESIZE 255 -static volatile toprint* queue[QUEUESIZE]; -static volatile unsigned char queue_head = 0; -static volatile unsigned char queue_tail = 0; -static volatile unsigned char queue_items = 0; - -static volatile unsigned int actual_pos = 0; -static volatile unsigned int running = 0; -static volatile unsigned int fifo = 0; - -static volatile toprint* actual = NULL; -void (*uart0_callback)(int); - -static inline void enqueue(void) { - queue_items++; - queue_tail++; -} - -static inline void dequeue(void) { - actual = (queue[queue_head]); - queue_items--; - queue_head++; -} - -static void push_queue(void) { - running = 1; -start: - if (!actual) { - if (queue_items) { - dequeue(); - } else { - running = 0; - if (!fifo) - while(!(U0LSR & BIT6)){}; - return; - } - } - while ((actual_pos < actual->len) && (fifo++ < 16)){ - U0THR = actual->content[actual_pos++]; - } - if (actual_pos == actual->len) { - free((void*)actual); - actual = NULL; - actual_pos = 0; - goto start; - } -} - -int uart_active(void){ - return (running || fifo); -} - -static inline void receive(int c) -{ - if (uart0_callback != NULL) uart0_callback(c); -} - -void stdio_flush(void) -{ - U0IER &= ~BIT1; // disable THRE interrupt - while(running) { - while(!(U0LSR & (BIT5|BIT6))){}; // transmit fifo - fifo=0; - push_queue(); // dequeue to fifo - } - U0IER |= BIT1; // enable THRE interrupt -} - -void UART0_IRQHandler(void) __attribute__((interrupt("IRQ"))); -void UART0_IRQHandler(void) -{ - int iir; - iir = U0IIR; - - switch(iir & UIIR_ID_MASK) { - case UIIR_THRE_INT: // Transmit Holding Register Empty - fifo=0; - push_queue(); - break; - - case UIIR_CTI_INT: // Character Timeout Indicator - case UIIR_RDA_INT: // Receive Data Available - do { - int c = U0RBR; - receive(c); - } while (U0LSR & ULSR_RDR); - break; - - default: - U0LSR; - U0RBR; - break; - } // switch - VICVectAddr = 0; // Acknowledge Interrupt -} - -static inline int uart0_puts(char *astring,int length) -{ - while (queue_items == (QUEUESIZE-1)) {} ; - U0IER = 0; - queue[queue_tail] = malloc(length+sizeof(unsigned int)); - queue[queue_tail]->len = length; - memcpy(&queue[queue_tail]->content,astring,length); - enqueue(); - if (!running) - push_queue(); - U0IER |= BIT0 | BIT1; // enable RX irq - - // alternative without queue: -// int i; -// for (i=0;iconfig->speed - /* - * Baudrate calculation - * BR = PCLK (9 MHz) / (16 x 256 x DLM + DLL) x (1/(DIVADDVAL/MULVAL)) - */ - U0FDR = 0x92; // DIVADDVAL = 0010 = 2, MULVAL = 1001 = 9 - U0DLM = 0x00; - U0DLL = 0x04; - - U0LCR = 0x03; // DLAB = 0 - U0FCR = 0x07; // Enable and reset TX and RX FIFO - - /* irq */ - install_irq(UART0_INT, UART0_IRQHandler, 6); - U0IER |= BIT0 | BIT1; // enable RX+TX irq - return 1; -} -