include bertos/config.mk
#Include subtargets
-include app/demo/demo.mk
-#include app/at91sam7s/at91sam7s.mk
-#include app/triface/triface.mk
+include examples/demo/demo.mk
+#include examples/at91sam7s/at91sam7s.mk
+#include examples/triface/triface.mk
include bertos/rules.mk
default: all
include bertos/config.mk
-include ./app/test/avrtest.mk
-include ./app/test/armtest.mk
+include ./examples/test/avrtest.mk
+include ./examples/test/armtest.mk
include bertos/rules.mk
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2007 Develer S.r.l. (http://www.develer.com/)
- *
- * -->
- *
- * \version $Id$
- *
- * \author Francesco Sacchi <batt@develer.com>
- *
- * \brief AT91SAM7S-EK porting test.
- */
-
-#include <cfg/macros.h>
-#include <drv/timer.h>
-#include <drv/sysirq_at91.h>
-#include <kern/proc.h>
-#include <drv/ser.h>
-#include <cfg/macros.h>
-#include <io/arm.h>
-
-Timer leds_timer;
-Serial ser_fd;
-
-static void leds_toggle(void)
-{
- uint8_t a = (~PIOA_ODSR & 0x0f);
-
- if (a)
- {
- PIOA_SODR = a;
- PIOA_CODR = a << 1;
- }
- else
- {
- PIOA_SODR = 0x0f;
- /* turn first led on */
- PIOA_CODR = 0x00000001;
- }
-
- /* Wait for interval time */
- timer_setDelay(&leds_timer, ms_to_ticks(100));
- timer_add(&leds_timer);
-}
-
-
-int main(void)
-{
- char msg[]="BeRTOS, be fast be beatiful be realtime";
- kdbg_init();
- timer_init();
-
- proc_init();
- ASSERT(!IRQ_ENABLED());
-
- /* Open the main communication port */
- ser_init(&ser_fd, 0);
- ser_setbaudrate(&ser_fd, 115200);
- ser_setparity(&ser_fd, SER_PARITY_NONE);
-
-
- IRQ_ENABLE;
- ASSERT(IRQ_ENABLED());
-
- /* Disable all pullups */
- PIOA_PUDR = 0xffffffff;
- /* Set PA0..3 connected to PIOA */
- PIOA_PER = 0x0000001f;
- /* Set PA0..3 as output */
- PIOA_OER = 0x0000001f;
- /* Disable multidrive on all pins */
- PIOA_MDDR = 0x0000001f;
-
- /* Set PA0..3 to 1 to turn off leds */
- PIOA_SODR = 0x0000000f;
- /* turn first led on */
- PIOA_CODR = 0x00000001;
-
- timer_setSoftint(&leds_timer, (Hook)leds_toggle, 0);
- timer_setDelay(&leds_timer, ms_to_ticks(100));
- timer_add(&leds_timer);
-
- ASSERT(proc_testRun() == 0);
- // Main loop
- for(;;)
- {
- kfile_printf(&ser_fd.fd, "From serial 0: %s\r\n", msg);
- }
- return 0;
-}
+++ /dev/null
-#
-# $Id: at91sam7s.mk 18234 2007-10-08 13:39:48Z rasky $
-# Copyright 2006 Develer S.r.l. (http://www.develer.com/)
-# All rights reserved.
-#
-# Makefile fragment for DevLib at91sam7s application.
-#
-# Author: Bernie Innocenti <bernie@codewiz.org>
-#
-#
-
-# Set to 1 for debug builds
-at91sam7s_DEBUG = 1
-
-# Our target application
-TRG += at91sam7s
-
-at91sam7s_CSRC = \
- app/at91sam7s/at91sam7s.c \
- bertos/drv/timer.c \
- bertos/drv/ser.c \
- bertos/cpu/arm/drv/sysirq_at91.c \
- bertos/cpu/arm/drv/ser_at91.c \
- bertos/mware/event.c \
- bertos/mware/formatwr.c \
- bertos/mware/hex.c \
- bertos/kern/kfile.c \
- bertos/kern/proc.c \
- bertos/kern/coop.c \
- bertos/kern/proc_test.c \
- bertos/kern/monitor.c \
- bertos/kern/signal.c
-
-at91sam7s_CPPASRC = \
- bertos/cpu/arm/hw/crtat91sam7_rom.S \
- bertos/cpu/arm/hw/switch_arm.S
-
-at91sam7s_CROSS = arm-none-eabi-
-
-at91sam7s_CPPAFLAGS = -O0 -g -gdwarf-2 -g -gen-debug
-at91sam7s_CPPFLAGS = -O0 -D'ARCH=0' -D__ARM_AT91SAM7S256__ -g3 -gdwarf-2 -fverbose-asm -Iapp/at91sam7s/hw -Iapp/at91sam7s -Ibertos/cpu/arm
-at91sam7s_LDFLAGS = -nostartfiles -T bertos/cpu/arm/scripts/at91sam7_256_ram.ld -Wl,--no-warn-mismatch
-
-at91sam7s_CPU = arm7tdmi
-
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2001, 2004 Develer S.r.l. (http://www.develer.com/)
- * Copyright 1999, 2000, 2001, 2008 Bernie Innocenti <bernie@codewiz.org>
- * -->
- *
- * \brief Kernel configuration parameters
- *
- * \version $Id$
- * \author Bernie Innocenti <bernie@codewiz.org>
- */
-
-#ifndef CFG_KERN_H
-#define CFG_KERN_H
-
-/**
- * Enable the multithreading kernel.
- */
-#define CONFIG_KERN 1
-
-/**
- * \name Optional kernel features
- * \{
- */
-#define CONFIG_KERN_SCHED 1 ///< Process schedling
-#define CONFIG_KERN_SIGNALS 1 ///< Inter-process signals
-#define CONFIG_KERN_IRQ 0 ///< Interrupt supervisor
-#define CONFIG_KERN_HEAP 0 ///< Dynamic memory allocation
-#define CONFIG_KERN_SEMAPHORES 1 ///< Re-entrant mutual exclusion primitives
-#define CONFIG_KERN_MONITOR 1 ///< Process monitor
-#define CONFIG_KERN_PREEMPT 0 ///< Preemptive process scheduling
-#define CONFIG_KERN_PRI 0 ///< Priority-based scheduling policy
-/*\}*/
-
-/// [ms] Time sharing quantum (a prime number prevents interference effects)
-#define CONFIG_KERN_QUANTUM 47
-
-/// Module logging level.
-#define KERN_LOG_LEVEL LOG_LVL_ERR
-
-/// Module logging format.
-#define KERN_LOG_FORMAT LOG_FMT_VERBOSE
-
-#endif /* CFG_KERN_H */
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
- * All Rights Reserved.
- * -->
- *
- * \brief Hardware-specific definitions
- *
- * \version $Id$
- *
- * \author Bernie Innocenti <bernie@codewiz.org>
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.1 2006/05/18 00:41:47 bernie
- *#* New triface devlib application.
- *#*
- *#*/
-
-#ifndef AT91SAM7SEK_HW_H
-#define AT91SAM7SEK_HW_H
-
-/// CPU Clock frequency (48.023 MHz)
-#define CLOCK_FREQ (48023000UL)
-
-
-/* Timer IRQ strobe */
-//#if CONFIG_TIMER_STROBE
-// #define TIMER_STROBE_ON ATOMIC(PORTD |= BV(PD0))
-// #define TIMER_STROBE_OFF ATOMIC(PORTD &= ~BV(PD0))
-// #define TIMER_STROBE_INIT ATOMIC(PORTD &= ~BV(PD0); DDRD |= BV(PD0))
-//#endif /* CONFIG_TIMER_STROBE */
-
-#endif /* AT91SAM7SEK_HW_H */
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
- * All Rights Reserved.
- * -->
- *
- * \brief Serial hardware-specific definitions
- *
- * \version $Id$
- *
- * \author Daniele Basile <asterix@develer.com>
- */
-
-
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2003, 2004, 2005, 2006 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2001, 2002, 2003 by Bernie Innocenti <bernie@codewiz.org>
- *
- * -->
- *
- * \version $Id$
- *
- * \author Bernie Innocenti <bernie@codewiz.org>
- *
- * \brief Declare application version strings
- */
-#ifndef DEVLIB_VERSTAG_H
-#define DEVLIB_VERSTAG_H
-
-#ifndef ARCH_CONFIG_H
- #include "cfg/arch_config.h"
-#endif
-
-#define APP_NAME "AT91SAM7S-EK porting test"
-#define APP_DESCRIPTION "AT91SAM7S-EK porting test"
-#define APP_AUTHOR "Develer"
-#define APP_COPYRIGHT "Copyright 2007 Develer (http://www.develer.com/)"
-
-#define VERS_MAJOR 0
-#define VERS_MINOR 1
-#define VERS_REV 0
-#define VERS_LETTER ""
-
-/**
- * If _SNAPSHOT is defined, \c VERS_TAG contains the build date
- * date instead of a numeric version string.
- */
-//#define _SNAPSHOT
-
-#ifdef _DEBUG
- #define VERS_DBG "D"
-#else
- #define VERS_DBG ""
-#endif
-
-#define __STRINGIZE(x) #x
-#define _STRINGIZE(x) __STRINGIZE(x)
-
-/** Build application version string (i.e.: "1.7.0") */
-#define MAKE_VERS(maj,min,rev) _STRINGIZE(maj) "." _STRINGIZE(min) "." _STRINGIZE(rev) VERS_LETTER VERS_DBG
-#ifdef _SNAPSHOT
- #define VERS_TAG "snapshot" " " __DATE__ " " __TIME__ " " VERS_LETTER " " VERS_DBG
-#else
- #define VERS_TAG MAKE_VERS(VERS_MAJOR,VERS_MINOR,VERS_REV)
-#endif
-
-/** Build application version string suitable for MS windows resource files (i.e.: "1, 7, 0, 1") */
-#define MAKE_RCVERS(maj,min,rev,bld) _STRINGIZE(maj) ", " _STRINGIZE(min) ", " _STRINGIZE(rev) ", " _STRINGIZE(bld)
-#define RCVERSION_TAG MAKE_VERS(VERS_MAJOR,VERS_MINOR,VERS_REV)
-
-/** The revision string (contains VERS_TAG) */
-extern const char vers_tag[];
-
-/** Sequential build number (contains VERS_BUILD) */
-extern const int vers_build_nr;
-//extern const char vers_build_str[];
-
-/** Hostname of the machine used to build this binary (contains VERS_HOST) */
-extern const char vers_host[];
-
-#endif /* DEVLIB_VERSTAG_H */
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2001, 2004 Develer S.r.l. (http://www.develer.com/)
- * Copyright 1999, 2000, 2001, 2008 Bernie Innocenti <bernie@codewiz.org>
- * -->
- *
- * \brief Kernel configuration parameters
- *
- * \version $Id$
- * \author Bernie Innocenti <bernie@codewiz.org>
- */
-
-#ifndef CFG_KERN_H
-#define CFG_KERN_H
-
-/**
- * Enable the multithreading kernel.
- */
-#define CONFIG_KERN 1
-
-/**
- * \name Optional kernel features
- * \{
- */
-#define CONFIG_KERN_SCHED 1 ///< Process schedling
-#define CONFIG_KERN_SIGNALS 1 ///< Inter-process signals
-#define CONFIG_KERN_IRQ 1 ///< Interrupt supervisor
-#define CONFIG_KERN_HEAP 0 ///< Dynamic memory allocation
-#define CONFIG_KERN_SEMAPHORES 0 ///< Re-entrant mutual exclusion primitives
-#define CONFIG_KERN_MONITOR 1 ///< Process monitor
-#define CONFIG_KERN_PREEMPT 1 ///< Preemptive process scheduling
-#define CONFIG_KERN_PRI 1 ///< Priority-based scheduling policy
-/*\}*/
-
-/// [ms] Time sharing quantum (a prime number prevents interference effects)
-#define CONFIG_KERN_QUANTUM 47
-
-/// Module logging level.
-#define KERN_LOG_LEVEL LOG_LVL_ERR
-
-/// Module logging format.
-#define KERN_LOG_FORMAT LOG_FMT_VERBOSE
-
-#endif /* CFG_KERN_H */
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2006, 2008 Develer S.r.l. (http://www.develer.com/)
- * -->
- *
- * \brief Multifunction system test for BeRTOS modules.
- *
- * \version $Id: demo.c 18242 2007-10-08 17:35:23Z marco $
- * \author Bernie Innocenti <bernie@codewiz.org>
- */
-
-#include <cfg/macros.h>
-
-#include <emul/emul.h>
-
-#include <kern/irq.h>
-#include <kern/proc.h>
-#include <kern/monitor.h>
-#include <kern/msg.h>
-
-#include <drv/timer.h>
-#include <drv/buzzer.h>
-#include <drv/lcd_gfx.h>
-#include <drv/kbd.h>
-
-#include <gfx/gfx.h>
-#include <gfx/win.h>
-#include <gfx/text.h>
-#include <gfx/font.h>
-
-#include <gui/menu.h>
-#include <icons/logo.h>
-
-/**
- * Draw a pentacle in the provided bitmap.
- *
- * This is invoked by the keyboard polling routine, as a poor man's surrogate
- * of true task switching.
- */
-void schedule(void)
-{
- lcd_blitBitmap(&lcd_bitmap);
- emul_idle();
-}
-
-/**
- * Draw a pentacle in the provided bitmap.
- */
-static void magic(struct Bitmap *bitmap, coord_t x, coord_t y)
-{
- static const coord_t coords[] = { 120, 34, 90, 90, 30, 90, 0, 34, 60, 0, 90, 90, 0, 34, 120, 34, 30, 90, 60, 0 };
- unsigned int i;
-
- gfx_moveTo(bitmap, coords[countof(coords)-2]/2 + x, coords[countof(coords)-1]/3 + y);
- for (i = 0; i < countof(coords); i += 2)
- gfx_lineTo(bitmap, coords[i]/2 + x, coords[i+1]/3 + y);
-}
-
-static void hello_world(Bitmap *bm)
-{
- extern const Font font_ncenB18;
- const Font *old_font = bm->font;
-
- gfx_bitmapClear(bm);
-
- /* Set big font */
- gfx_setFont(bm, &font_ncenB18);
-
- text_xprintf(bm, 1, 0, STYLEF_BOLD | TEXT_FILL | TEXT_CENTER,
- "Hello, world!");
-
- lcd_blitBitmap(bm);
- timer_delay(1000);
-
- /* Restore old font */
- gfx_setFont(bm, old_font);
-}
-
-/**
- * Show the splash screen
- */
-static void bouncing_logo(Bitmap *bm)
-{
- const long SPEED_SCALE = 1000;
- const long GRAVITY_ACCEL = 10;
- const long BOUNCE_ELASTICITY = 2;
- long h = (long)(-bertos_logo.height) * SPEED_SCALE;
- long speed = 1000;
-
- /* Repeat until logo stands still on the bottom edge */
- while (!((speed == 0) && (h == 0)))
- {
- /* Move */
- h += speed;
-
- /* Gravity acceleration */
- speed += GRAVITY_ACCEL;
-
- if (h > 0 && speed > 0)
- {
- /* Bounce */
- speed = - (speed / BOUNCE_ELASTICITY);
-
- }
-
- /* Update graphics */
- gfx_bitmapClear(bm);
- gfx_blitImage(bm,
- (bm->width - bertos_logo.width) / 2,
- h / SPEED_SCALE,
- &bertos_logo);
- lcd_blitBitmap(bm);
-
- timer_delay(10);
- }
-}
-
-void win_demo(Bitmap *bm)
-{
- const coord_t small_left = 45, small_top = 30, small_width = 50, small_height = 30;
- const coord_t large_left = -10, large_top = 10, large_width = 85, large_height = 41;
-
- Window root_win, small_win, large_win;
- Bitmap small_bm, large_bm;
- uint8_t small_raster[RAST_SIZE(small_width, small_height)];
- uint8_t large_raster[RAST_SIZE(large_width, large_height)];
-
- win_create(&root_win, bm);
-
- gfx_bitmapInit(&large_bm, large_raster, large_width, large_height);
- win_create(&large_win, &large_bm);
- win_open(&large_win, &root_win);
- win_move(&large_win, large_left, large_top);
-
- gfx_bitmapInit(&small_bm, small_raster, small_width, small_height);
- win_create(&small_win, &small_bm);
- win_open(&small_win, &root_win);
- win_move(&small_win, small_left, small_top);
-
-
- coord_t x = 0, y = LCD_WIDTH / 2;
- coord_t xdir = +1, ydir = -1;
- coord_t xdir_large = +1;
- coord_t ydir_small = +1;
- int raise_counter = 0;
- int i;
-
- for(;;)
- {
- /* Background animation */
- bm = root_win.bitmap;
- gfx_bitmapClear(bm);
-// gfx_setClipRect(bm, 0, 0, bm->width, bm->height);
-// gfx_rectDraw(bm, 10, 10, bm->width-10, bm->height-10);
-// gfx_setClipRect(bm, 11, 11, bm->width-11, bm->height-11);
- magic(bm, x, y);
- x += xdir;
- y += ydir;
- if (x >= bm->width) xdir = -1;
- if (x <= -50) xdir = +1;
- if (y >= bm->height) ydir = -1;
- if (y <= -50) ydir = +1;
-
- /* Large window animation */
- bm = large_win.bitmap;
- gfx_bitmapClear(bm);
- for (i = 0; i < bm->height / 2; i += 2)
- gfx_rectDraw(bm, 0 + i, 0 + i, bm->width - i, bm->height - i);
-
-
- /* Small window animation */
- bm = small_win.bitmap;
- gfx_bitmapClear(bm);
- gfx_rectDraw(bm, 0, 0, bm->width, bm->height);
- gfx_line(bm, 0, 0, bm->width, bm->height);
- gfx_line(bm, bm->width, 0, 0, bm->height);
-
- /* Move windows around */
- win_move(&large_win, large_win.geom.xmin + xdir_large, large_top);
- if (large_win.geom.xmin < -20) xdir_large = +1;
- if (large_win.geom.xmin > RECT_WIDTH(&root_win.geom) - 5) xdir_large = -1;
-
- win_move(&small_win, small_left, small_win.geom.ymin + ydir_small);
- if (small_win.geom.ymin < -20) ydir_small = +1;
- if (small_win.geom.ymin > RECT_HEIGHT(&root_win.geom) - 5) ydir_small = -1;
-
- ++raise_counter;
- if (raise_counter % 997 == 0)
- win_raise(&small_win);
- else if (raise_counter % 731 == 0)
- win_raise(&large_win);
-
- win_compose(&root_win);
-
- /* Also does LCD refresh, etc. */
- if (kbd_peek())
- break;
- }
-}
-
-void proc_demo(void)
-{
- proc_testRun();
-}
-
-void timer_demo(void)
-{
- timer_testRun();
- timer_testTearDown();
-}
-
-
-/* SETTINGS SUBMENU */
-
-static struct MenuItem settings_items[] =
-{
- { (const_iptr_t)"System", 0, (MenuHook)0, (iptr_t)0 },
- { (const_iptr_t)"Language", 0, (MenuHook)0, (iptr_t)0 },
- { (const_iptr_t)"Networking", 0, (MenuHook)0, (iptr_t)0 },
- { (const_iptr_t)"Date & Time",0, (MenuHook)0, (iptr_t)0 },
- { (const_iptr_t)"Power Saving", MIF_TOGGLE, (MenuHook)0, (iptr_t)0 },
- { (const_iptr_t)0, 0, NULL, (iptr_t)0 }
-};
-static struct Menu settings_menu = { settings_items, "Settings Menu", MF_STICKY | MF_SAVESEL, &lcd_bitmap, 0 };
-
-
-/* MX SUBMENU */
-
-static struct MenuItem mx_items[] =
-{
- { (const_iptr_t)"Mouse", MIF_CHECKIT | MIF_EXCLUDE_1 | MIF_EXCLUDE_2, (MenuHook)0, (iptr_t)0 },
- { (const_iptr_t)"Keyboard", MIF_CHECKED | MIF_CHECKIT | MIF_EXCLUDE_0 | MIF_EXCLUDE_2, (MenuHook)0, (iptr_t)0 },
- { (const_iptr_t)"Joystick", MIF_CHECKIT | MIF_EXCLUDE_0 | MIF_EXCLUDE_1, (MenuHook)0, (iptr_t)0 },
- { (const_iptr_t)"Autosave", MIF_CHECKED | MIF_CHECKIT | MIF_TOGGLE, (MenuHook)0, (iptr_t)0 },
- { (const_iptr_t)0, 0, NULL, (iptr_t)0 }
-};
-
-static struct Menu mx_menu = { mx_items, (const_iptr_t)0, MF_STICKY | MF_SAVESEL, &lcd_bitmap, 0 };
-
-
-/* DISPLAY SUBMENU */
-
-static struct MenuItem display_items[] =
-{
- { (const_iptr_t)"Background", 0, (MenuHook)0, (iptr_t)0 },
- { (const_iptr_t)"Colors", 0, (MenuHook)0, (iptr_t)0 },
- { (const_iptr_t)"Style", 0, (MenuHook)0, (iptr_t)0 },
- { (const_iptr_t)"Icon Theme", 0, (MenuHook)0, (iptr_t)0 },
- { (const_iptr_t)0, 0, NULL, (iptr_t)0 }
-};
-static struct Menu display_menu = { display_items, "Display Menu", MF_SAVESEL, &lcd_bitmap, 0 };
-
-
-/* MAIN MENU */
-
-static struct MenuItem main_items[] =
-{
- { (const_iptr_t)"Win Fly", 0, (MenuHook)win_demo, (iptr_t)&lcd_bitmap },
- { (const_iptr_t)"Bounce!", 0, (MenuHook)bouncing_logo,(iptr_t)&lcd_bitmap },
- { (const_iptr_t)"Hello World", 0, (MenuHook)hello_world, (iptr_t)&lcd_bitmap },
- { (const_iptr_t)"Scheduling", 0, (MenuHook)proc_demo, (iptr_t)&lcd_bitmap },
- { (const_iptr_t)"Timer Test", 0, (MenuHook)timer_demo, (iptr_t)&lcd_bitmap },
- { (const_iptr_t)"Menu MX", 0, (MenuHook)menu_handle, (iptr_t)&mx_menu },
- { (const_iptr_t)"Display", 0, (MenuHook)menu_handle, (iptr_t)&display_menu },
- { (const_iptr_t)"Settings", 0, (MenuHook)menu_handle, (iptr_t)&settings_menu },
- { (const_iptr_t)0, 0, NULL, (iptr_t)0 }
-};
-static struct Menu main_menu = { main_items, "Main Menu", MF_STICKY, &lcd_bitmap, 0 };
-
-
-static cpu_stack_t monitor_stack[CONFIG_KERN_MINSTACKSIZE / sizeof(cpu_stack_t)];
-
-int main(int argc, char *argv[])
-{
- emul_init(&argc, argv);
- irq_init();
- timer_init();
- buz_init();
- kbd_init();
- lcd_init();
- proc_init();
- monitor_start(sizeof(monitor_stack), monitor_stack);
-
- menu_handle(&main_menu);
-
- timer_cleanup();
- emul_cleanup();
- return 0;
-}
+++ /dev/null
-#
-# Copyright 2003, 2004, 2005, 2006 Develer S.r.l. (http://www.develer.com/)
-# Copyright 2008 Bernie Innocenti <bernie@codewiz.org>
-#
-# Makefile fragment for DevLib demo application.
-#
-# Version: $Id: demo.mk 18234 2007-10-08 13:39:48Z rasky $
-# Author: Bernie Innocenti <bernie@codewiz.org>
-#
-
-include bertos/fonts/fonts.mk
-include bertos/emul/emul.mk
-
-# Set to 1 for debug builds
-demo_DEBUG = 1
-
-# Our target application
-TRG += demo
-
-# FIXME: we want to use g++ for C source too
-CC = g++
-CXX = g++
-
-demo_CXXSRC = \
- bertos/emul/emul.cpp \
- bertos/emul/emulwin.cpp \
- bertos/emul/emulkbd.cpp \
- bertos/drv/lcd_gfx_qt.cpp
-
-demo_CSRC = \
- app/demo/demo.c \
- bertos/os/hptime.c \
- bertos/gfx/bitmap.c \
- bertos/gfx/line.c \
- bertos/gfx/win.c \
- bertos/gfx/text.c \
- bertos/gfx/text_format.c \
- bertos/gui/menu.c \
- bertos/fonts/helvB10.c \
- bertos/fonts/luBS14.c \
- bertos/fonts/ncenB18.c \
- bertos/icons/logo.c \
- bertos/drv/kbd.c \
- bertos/drv/timer.c \
- bertos/drv/timer_test.c \
- bertos/drv/buzzer.c \
- bertos/drv/ser.c \
- bertos/emul/ser_posix.c \
- bertos/mware/formatwr.c \
- bertos/mware/hex.c \
- bertos/mware/event.c \
- bertos/mware/observer.c \
- bertos/mware/resource.c \
- bertos/mware/sprintf.c \
- bertos/kern/idle.c \
- bertos/kern/irq.c \
- bertos/kern/preempt.c \
- bertos/kern/proc.c \
- bertos/kern/proc_test.c \
- bertos/kern/sem.c \
- bertos/kern/signal.c \
- bertos/kern/monitor.c \
- bertos/verstag.c
-
-demo_CPPASRC = \
- bertos/emul/switch.S
-
-# FIXME: maybe this junk should go in emul/emul.mk?
-$(OBJDIR)/demo/bertos/emul/emulwin.o: bertos/emul/emulwin_moc.cpp
-$(OBJDIR)/demo/bertos/drv/lcd_gfx_qt.o: bertos/drv/lcd_gfx_qt_moc.cpp
-$(OBJDIR)/demo/bertos/drv/timer.o: bertos/emul/timer_qt_moc.cpp
-$(OBJDIR)/demo/bertos/emul/emulkbd.o: bertos/emul/emulkbd_moc.cpp
-
-#FIXME: isn't there a way to avoid repeating the pattern rule?
-bertos/emul/timer_qt_moc.cpp: bertos/emul/timer_qt.c
- $(QT_MOC) -o $@ $<
-
-
-demo_CFLAGS = -Iapp/demo $(EMUL_CFLAGS)
-demo_CXXFLAGS = -Iapp/demo $(EMUL_CFLAGS)
-demo_LDFLAGS = $(EMUL_LDFLAGS)
-
-# Debug stuff
-ifeq ($(demo_DEBUG),0)
- demo_CFLAGS += -Os
- demo_CXXFLAGS += -Os
-endif
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2003, 2004, 2005, 2006, 2008 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2000 Bernie Innocenti
- * All Rights Reserved.
- * -->
- *
- * \brief Keyboard map definitions.
- *
- * \version $Id$
- *
- * \author Francesco Sacchi <batt@develer.com>
- * \author Stefano Fedrigo <a@develer.com>
- */
-
-#ifndef HW_KBD_MAP_H
-#define HW_KBD_MAP_H
-
-#include <cfg/macros.h>
-
-
-/**
- * Type for keyboard mask.
- */
-typedef uint16_t keymask_t;
-
-/**
- * \name Keycodes.
- */
-/*@{*/
-#define K_UP BV(0)
-#define K_DOWN BV(1)
-#define K_OK BV(2)
-#define K_CANCEL BV(3)
-
-#define K_REPEAT BV(14) /**< This is a repeated keyevent. */
-#define K_TIMEOUT BV(15) /**< Fake key event for timeouts. */
-/*@}*/
-
-
-#endif /* HW_KBD_MAP_H */
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2003, 2004, 2005, 2006 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2001, 2002, 2003 by Bernie Innocenti <bernie@codewiz.org>
- *
- * -->
- *
- * \version $Id: verstag.h 18242 2007-10-08 17:35:23Z marco $
- *
- * \author Bernie Innocenti <bernie@codewiz.org>
- *
- * \brief Declare application version strings
- */
-
-#ifndef BERTOS_VERSTAG_H
-#define BERTOS_VERSTAG_H
-
-#ifndef CFG_ARCH_CONFIG_H
- #include "cfg/cfg_arch.h"
-#endif
-
-#define APP_NAME "BeRTOS Demo"
-#define APP_DESCRIPTION "BeRTOS Multidemo Application"
-#define APP_AUTHOR "Develer"
-#define APP_COPYRIGHT "Copyright 2006 Develer (http://www.develer.com/)"
-
-#define VERS_MAJOR 0
-#define VERS_MINOR 1
-#define VERS_REV 0
-#define VERS_LETTER ""
-
-/**
- * If _SNAPSHOT is defined, \c VERS_TAG contains the build date
- * date instead of a numeric version string.
- */
-#define _SNAPSHOT
-
-#ifdef _DEBUG
- #define VERS_DBG "D"
-#else
- #define VERS_DBG ""
-#endif
-
-#define __STRINGIZE(x) #x
-#define _STRINGIZE(x) __STRINGIZE(x)
-
-/** Build application version string (i.e.: "1.7.0") */
-#define MAKE_VERS(maj,min,rev) _STRINGIZE(maj) "." _STRINGIZE(min) "." _STRINGIZE(rev) VERS_LETTER VERS_DBG
-#ifdef _SNAPSHOT
- #define VERS_TAG "snapshot" " " __DATE__ " " __TIME__ " " VERS_LETTER " " VERS_DBG
-#else
- #define VERS_TAG MAKE_VERS(VERS_MAJOR,VERS_MINOR,VERS_REV)
-#endif
-
-/** Build application version string suitable for MS windows resource files (i.e.: "1, 7, 0, 1") */
-#define MAKE_RCVERS(maj,min,rev,bld) _STRINGIZE(maj) ", " _STRINGIZE(min) ", " _STRINGIZE(rev) ", " _STRINGIZE(bld)
-#define RCVERSION_TAG MAKE_VERS(VERS_MAJOR,VERS_MINOR,VERS_REV)
-
-/** The revision string (contains VERS_TAG) */
-extern const char vers_tag[];
-
-/** Sequential build number (contains VERS_BUILD) */
-extern const int vers_build_nr;
-//extern const char vers_build_str[];
-
-/** Hostname of the machine used to build this binary (contains VERS_HOST) */
-extern const char vers_host[];
-
-#endif /* BERTOS_VERSTAG_H */
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2006, 2008 Develer S.r.l. (http://www.develer.com/)
- * All Rights Reserved.
- * -->
- *
- * \brief Hardware-specific definitions
- *
- * \version $Id$
- *
- * \author Bernie Innocenti <bernie@codewiz.org>
- */
-
-#ifndef HW_CPU_H
-#define HW_CPU_H
-
-#warning TODO:This is an example implementation, you must implement it!
-
-/// CPU Clock frequency
-#define CLOCK_FREQ (48023000L/* Implement me! */)
-
-
-/* Timer IRQ strobe */
-//#if CONFIG_TIMER_STROBE
-// #define TIMER_STROBE_ON /* Implement me! */
-// #define TIMER_STROBE_OFF /* Implement me! */
-// #define TIMER_STROBE_INIT /* Implement me! */
-//#endif /* CONFIG_TIMER_STROBE */
-
-#endif /* HW_CPU_H */
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2007 Develer S.r.l. (http://www.develer.com/)
- *
- * -->
- *
- * \version $Id$
- *
- * \author Manuele Fanelli <qwert@develer.com>
- *
- * \brief LM3S168 porting test.
- */
-
-#include "bertos/cpu/detect.h"
-
-int main (void)
-{
- int c;
-
- for (;;)
- c++;
- return 0;
-}
+++ /dev/null
-#
-# $Id: lm3s1968.mk 18234 2007-10-08 13:39:48Z rasky $
-# Copyright 2006 Develer S.r.l. (http://www.develer.com/)
-# All rights reserved.
-#
-# Makefile fragment for DevLib lm3s1968 application.
-#
-# Author: Manuele Fanelli <qwert@develer.com>
-#
-#
-
-# Set to 1 for debug builds
-lm3s1968_DEBUG = 0
-
-
-# Our target application
-TRG += lm3s1968
-
-lm3s1968_CSRC = \
- app/lm3s1968/lm3s1968.c \
- #bertos/cpu/cortex-m3/startup_lm3s.c
-
-
-lm3s1968_CROSS = arm-none-eabi-
-
-lm3s1968_CPPAFLAGS = -O0 -g -gdwarf-2 -g -gen-debug -mthumb
-lm3s1968_CPPFLAGS = -O0 -D'ARCH=0' -D__ARM_LM3S1968__ -g3 -gdwarf-2 -fverbose-asm -mthumb -Iapp/lm3s1968 -Ibertos/cpu/cortex-m3
-lm3s1968_LDFLAGS = -nostartfiles -T app/lm3s1968/standalone.ld -Wl,--no-warn-mismatch
-
-lm3s1968_CPU = cortex-m3
-
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
- *
- * -->
- *
- * \brief DevLib configuration options
- *
- * You should copy this header in your project and rename it to
- * "config.h" and delete the CONFIG_ macros for the modules
- * you're not using.
- *
- * <h2>Working with multiple applications</h2>
- *
- * If your project is made of multiple DevLib-based applications,
- * create a custom "config.h" file in each application subdirectory
- * and play with the compiler include path to get the desired result.
- * You can share common options by creationg a "config_common.h" header
- * and including it from all your "config.h" copies.
- *
- * <h2>Configuration style</h2>
- *
- * For improved compile-time checking of configuration options,
- * the preferred way to use a \c CONFIG_ symbol is keeping it
- * always defined with a value of either 0 or 1. This lets
- * you write tests like this:
- *
- * \code
- * #if CONFIG_FOO
- * void foo(void)
- * {
- * if (CONFIG_BAR)
- * bar();
- * }
- * #endif // CONFIG_FOO
- * \endcode
- *
- * In most cases, we rely on the optimizer to discard checks
- * on constant values and performing dead-code elimination.
- *
- * \version $Id$
- * \author Bernie Innocenti <bernie@codewiz.org>
- * \author Stefano Fedrigo <aleph@develer.com>
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.1 2007/02/15 18:17:51 asterix
- *#* Add randpool test program.
- *#*
- *#* Revision 1.16 2007/02/12 15:29:41 asterix
- *#* Add CONFIG_RANDPOOL_TIMER macro to swich on or off timer support in randpool.
- *#*
- *#* Revision 1.15 2007/02/08 14:20:35 asterix
- *#* Add CONFIG_SIZE_ENTROPY_POOL.
- *#*
- *#* Revision 1.14 2007/02/06 11:37:26 asterix
- *#* Add CONFIG_MD2_STD_PERM for use standard permutation in MD2.
- *#*
- *#* Revision 1.13 2007/01/31 13:49:40 asterix
- *#* Add config size block for MD2
- *#*
- *#* Revision 1.3 2006/09/13 18:29:22 bernie
- *#* Add a few missing CONFIG_ definitions.
- *#*
- *#* Revision 1.2 2006/07/19 12:56:24 bernie
- *#* Convert to new Doxygen style.
- *#*
- *#* Revision 1.1 2006/05/18 00:40:43 bernie
- *#* Rename appconfig.h to appconfig_common.h.
- *#*
- *#* Revision 1.11 2006/04/11 00:08:53 bernie
- *#* Add smooth scrolling for menus.
- *#*
- *#* Revision 1.10 2006/03/22 09:48:51 bernie
- *#* Add a few more config options.
- *#*
- *#* Revision 1.9 2006/02/24 00:27:35 bernie
- *#* Enable kernel and fix Doxygen markup.
- *#*
- *#* Revision 1.8 2006/02/21 16:06:05 bernie
- *#* Update copyright info.
- *#*
- *#* Revision 1.7 2006/02/17 22:28:19 bernie
- *#* Add missing UART definitions.
- *#*
- *#* Revision 1.6 2006/02/15 09:12:56 bernie
- *#* Switch to BITMAP_FMT_PLANAR_V_LSB.
- *#*
- *#* Revision 1.5 2006/02/10 12:34:33 bernie
- *#* Add missing config options for gfx and kbd.
- *#*
- *#* Revision 1.4 2006/01/23 23:12:27 bernie
- *#* Enable CONFIG_GFX_VCOORDS.
- *#*
- *#* Revision 1.3 2006/01/17 02:30:06 bernie
- *#* Add new config vars.
- *#*
- *#* Revision 1.2 2005/11/27 03:04:57 bernie
- *#* CONFIG_WATCHDOG: New config option.
- *#*
- *#* Revision 1.1 2005/11/04 17:42:12 bernie
- *#* Move cfg/config.h to appconfig.h.
- *#*/
-
-#ifndef APPCONFIG_H
-#define APPCONFIG_H
-
-/** Baud-rate for the kdebug console */
-#define CONFIG_KDEBUG_BAUDRATE 19200
-
-/**
- * printf()-style formatter configuration.
- *
- * \sa PRINTF_DISABLED
- * \sa PRINTF_NOMODIFIERS
- * \sa PRINTF_REDUCED
- * \sa PRINTF_NOFLOAT
- * \sa PRINTF_FULL
- */
-#define CONFIG_PRINTF PRINTF_FULL
-
-/**
- * Multithreading kernel.
- *
- * \sa config_kern.h
- */
-#define CONFIG_KERN 0
-
-/**
- * \name Serial driver parameters
- * \{
- */
- /** [bytes] Size of the outbound FIFO buffer for port 0. */
- #define CONFIG_UART0_TXBUFSIZE 32
-
- /** [bytes] Size of the inbound FIFO buffer for port 0. */
- #define CONFIG_UART0_RXBUFSIZE 64
-
- /** [bytes] Size of the outbound FIFO buffer for port 1. */
- #define CONFIG_UART1_TXBUFSIZE 32
-
- /** [bytes] Size of the inbound FIFO buffer for port 1. */
- #define CONFIG_UART1_RXBUFSIZE 64
-
- /** [bytes] Size of the outbound FIFO buffer for SPI port (AVR only). */
- #define CONFIG_SPI_TXBUFSIZE 16
-
- /** [bytes] Size of the inbound FIFO buffer for SPI port (AVR only). */
- #define CONFIG_SPI_RXBUFSIZE 32
-
- /** SPI data order (AVR only). */
- #define CONFIG_SPI_DATA_ORDER SER_MSB_FIRST
-
- /** SPI clock division factor (AVR only). */
- #define CONFIG_SPI_CLOCK_DIV 16
-
- /** SPI clock polarity: 0 = normal low, 1 = normal high (AVR only). */
- #define CONFIG_SPI_CLOCK_POL 0
-
- /** SPI clock phase: 0 = sample on first edge, 1 = sample on second clock edge (AVR only). */
- #define CONFIG_SPI_CLOCK_PHASE 0
-
- /** Default transmit timeout (ms). Set to -1 to disable timeout support */
- #define CONFIG_SER_TXTIMEOUT -1
-
- /** Default receive timeout (ms). Set to -1 to disable timeout support */
- #define CONFIG_SER_RXTIMEOUT -1
-
- /** Use RTS/CTS handshake */
- #define CONFIG_SER_HWHANDSHAKE 0
-
- /** Default baud rate (set to 0 to disable) */
- #define CONFIG_SER_DEFBAUDRATE 0
-
- /** Enable ser_gets() and ser_gets_echo() */
- #define CONFIG_SER_GETS 0
-
- /** Enable second serial port in emulator. */
- #define CONFIG_EMUL_UART1 0
-
- /**
- * Transmit always something on serial port 0 TX
- * to avoid interference when sending burst of data,
- * using AVR multiprocessor serial mode
- */
- #define CONFIG_SER_TXFILL 0
-
- #define CONFIG_SER_STROBE 0
-/*\}*/
-
-/// Hardware timer selection for drv/timer.c
-#define CONFIG_TIMER TIMER_ON_OUTPUT_COMPARE2
-
-/// Debug timer interrupt using a strobe pin.
-#define CONFIG_TIMER_STROBE 0
-
-/// Enable ADS strobe.
-#define CONFIG_ADC_STROBE 0
-
-/// Enable watchdog timer.
-#define CONFIG_WATCHDOG 0
-
-/// EEPROM type for drv/eeprom.c
-#define CONFIG_EEPROM_TYPE EEPROM_24XX256
-
-/// Select bitmap pixel format.
-#define CONFIG_BITMAP_FMT BITMAP_FMT_PLANAR_V_LSB
-
-/// Enable line clipping algorithm.
-#define CONFIG_GFX_CLIPPING 1
-
-/// Enable text rendering in bitmaps.
-#define CONFIG_GFX_TEXT 1
-
-/// Enable virtual coordinate system.
-#define CONFIG_GFX_VCOORDS 1
-
-/// Keyboard polling method
-#define CONFIG_KBD_POLL KBD_POLL_SOFTINT
-
-/// Enable keyboard event delivery to observers
-#define CONFIG_KBD_OBSERVER 0
-
-/// Enable key beeps
-#define CONFIG_KBD_BEEP 1
-
-/// Enable long pression handler for keys
-#define CONFIG_KBD_LONGPRESS 1
-
-/**
- * \name Type for the chart dataset
- * \{
- */
-#define CONFIG_CHART_TYPE_X uint8_t
-#define CONFIG_CHART_TYPE_Y uint8_t
-/*\}*/
-
-/// Enable button bar behind menus
-#define CONFIG_MENU_MENUBAR 0
-
-/// Enable smooth scrolling in menus
-#define CONFIG_MENU_SMOOTH 1
-
-/// Size of block for MD2 algorithm.
-#define CONFIG_MD2_BLOCK_LEN 16
-
-/// Use standard permutation in MD2 algorithm.
-#define CONFIG_MD2_STD_PERM 0
-
-/// Define a size, in byte, of entropy pool.
-#define CONFIG_SIZE_ENTROPY_POOL 256
-
-/// Turn on or off timer support in Randpool.
-#define CONFIG_RANDPOOL_TIMER 1
-
-#endif /* APPCONFIG_H */
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2007 Develer S.r.l. (http://www.develer.com/)
- *
- * -->
- *
- * \brief Test function for randpool API.
- *
- * This program return a rand number generate from randpool function.
- * For use randpool function you need a souce of entropy. In this
- * program you can choose from:
- * - /dev/random
- * - /dev/urandom
- * - /dev/input/mouse0
- *
- * There are 3 mode of output:
- * - binmode: program generate a sequenze of random byte.
- * - Matrix of random number for octave program.
- * - Vector of random number for octave program.
- *
- * \version $Id$
- * \author Daniele Basile <asterix@develer.com>
- */
-
-/*#*
- *#* $Log$
- *#* Revision 1.1 2007/02/15 18:17:51 asterix
- *#* Add randpool test program.
- *#*
- *#*/
-
-#include <stdlib.h>
-#include <stdio.h>
-#include <string.h>
-#include <cfg/compiler.h>
-#include <drv/timer.h>
-#include <algo/md2.h>
-#include <algo/randpool.h>
-#include <unistd.h>
-
-#define LEN 256 //Size of buffer containing a random number.
-#define SAMPLE 1000 //Defoult number of byte that put in entropy pool.
-
-int main (int argc, char *argv[])
-{
- EntropyPool pool;
- uint8_t ch;
- uint8_t buff[LEN];
- FILE *pdev;
- int opt = getopt (argc, argv, "murh");
- int samp = SAMPLE;
- int round = 10;
- int mode = 0;
- int pass = 0;
-
- timer_init();
-
- randpool_init(&pool, NULL, 0); //Init a entropy pool.
-
- /*
- * Chose a source of entropy.
- */
- switch(opt)
- {
- case 'm':
- {
- pdev = fopen("/dev/input/mouse0", "r");
- break;
- }
- case 'u':
- {
- pdev = fopen("/dev/urandom", "r");
- break;
- }
- case 'r':
- {
- pdev = fopen("/dev/random", "r");
- break;
- }
- case 'h':
- {
- }
- default:
- {
- printf("\n");
- printf("\n");
- printf("randpool_demo [OPTION] [SAMPLE] [ROUND] [MODE]\n");
- printf("\n");
- printf("OPTION:\n");
- printf(" -r /dev/random\n");
- printf(" -u /dev/urandom\n");
- printf(" -m /dev/input/mouse0\n");
- printf("\n");
- printf("SAMPLE:\n");
- printf(" num number of entropy byte to put in etropy pool.\n");
- printf("\n");
- printf("ROUND:\n");
- printf(" num number call of randpool_get function.\n");
- printf("\n");
- printf("MODE:\n");
- printf(" 0 binmode\n");
- printf(" 1 vector mode\n");
- printf(" 2 matrix mode\n");
- printf("\n");
- printf("Test program of randpool API.\n");
- printf("This program create an entropy pool of 256byte, and fill it\n");
- printf("with entropy from a exsternal source. This source can be:\n");
- printf(" - /dev/random (option: -r)\n");
- printf(" - /dev/urandom (option: -u)\n");
- printf(" - /dev/input/mouse0 (option: -m)\n");
- printf("\n");
- printf("Once the pool is full, program call a randpool_get ROUND time,\n");
- printf("printing on STDOUT random value, in accord with a select mode.\n");
- printf("The mode are:\n");
- printf(" - binmode: program print on STDOUT random byte. (option: 0 (defaul mode)\n");
- printf(" - vector mode: program print on STDOUT a ROUND vector of random value.\n");
- printf(" The output is format for octave program. (option: 1)\n");
- printf(" - matrix mode: program print on STDOUT a matrix of random value.\n");
- printf(" The output is format for octave program. (option: 2)\n");
- printf("\n");
- exit(1);
- }
-
- }
-
- /*
- *
- */
- if(argc > 2)
- {
- if(argv[2])
- samp = atoi(argv[2]); //Number of byte take from entropy source
- if(argv[3])
- round = atoi(argv[3]); //Number of time we call randpool_get.
- if(argv[4])
- {
- switch(atoi(argv[4]))
- {
- case 1:
- {
- mode = 1;
- printf("# Created by Asterix.\n");
- printf("# name: __nargin__\n");
- printf("# type: scalar\n");
- printf("0\n");
- break;
- }
- case 2:
- {
- mode = 2;
- printf("# Created by Asterix.\n");
- printf("# name: __nargin__\n");
- printf("# type: scalar\n");
- printf("0\n");
- break;
- }
- default:
- {
- break;
- }
-
- }
-
- }
-
- }
-
- /*
- * Add byte to entropy pool from a source of entropy.
- */
- for(int i = 0; i < samp; i++)
- {
-
- ch = fgetc(pdev);
- randpool_add(&pool, &ch, sizeof(ch));
-
- }
-
- fclose(pdev);
-
-
- for(int k = 0; k < round; k++)
- {
- switch(mode)
- {
- case 1:
- {
- printf("\n");
- printf("\n# name: vet%d",k);
- printf("\n# type: matrix");
- printf("\n# rows: 1");
- printf("\n# columns: %d\n", LEN);
- pass = 1;
- break;
- }
- case 2:
- {
- printf("\n");
- printf("\n# name: randMatrix");
- printf("\n# type: matrix");
- printf("\n# rows: %d",round);
- printf("\n# columns: %d\n", LEN);
- pass = 1;
- mode = 0;
- break;
- }
- }
-
- randpool_get(&pool, buff, LEN);
-
- if(pass)
- {
- for(int j = 0; j < LEN; j++)
- {
- printf("%d ", buff[j]);
- }
- printf("\n");
- }
- else
- fwrite(buff, sizeof(uint8_t), LEN, stdout);
- }
-
-
-}
-
+++ /dev/null
-#
-# $Id$
-# Copyright 2006 Develer S.r.l. (http://www.develer.com/)
-# All rights reserved.
-#
-# Makefile fragment for DevLib randpool_demo application.
-#
-# Author: Daniele Basile <asterix@develer.com>
-#
-# $Log$
-# Revision 1.1 2007/02/15 18:17:51 asterix
-# Add randpool test program.
-#
-#
-
-
-# Set to 1 for debug builds
-randpool_demo_DEBUG = 0
-
-# Our target application
-TRG += randpool_demo
-
-randpool_demo_CSRC = \
- app/randpool/randpool_demo.c \
- algos/randpool.c \
- algos/md2.c \
- drv/timer.c \
- os/hptime.c
-
-randpool_demo_CFLAGS = -O0 -D'ARCH=0' -Iapp/randpool/ -Iapp/randpool/hw
-
-# Debug stuff
-ifeq ($(randpool_demo_DEBUG),1)
- randpool_demo_CFLAGS += -D_DEBUG
- randpool_demo_PCSRC += drv/kdebug.c
-endif
-
+++ /dev/null
-#
-# $Id: armtest.mk 18234 2007-10-08 13:39:48Z rasky $
-# Copyright 2006 Develer S.r.l. (http://www.develer.com/)
-# All rights reserved.
-#
-# Makefile fragment for DevLib armtest application.
-#
-# Author: Bernie Innocenti <bernie@codewiz.org>
-#
-#
-
-# Set to 1 for debug builds
-armtest_DEBUG = 1
-
-# Our target application
-TRG += armtest
-
-#include arm c and asm sources
-include ./app/test/arm_src.mk
-
-armtest_CSRC = $(arm_CSRC) app/test/empty_main.c
-
-armtest_CPPASRC = $(arm_ASRC)
-
-armtest_CROSS = arm-elf-
-
-armtest_CPPAFLAGS = -O0 -g -gdwarf-2 -g -gen-debug
-armtest_CPPFLAGS = -O0 -D'ARCH=ARCH_NIGHTTEST' -D__ARM_AT91SAM7S256__ -g3 -gdwarf-2 -fverbose-asm -Iapp/test -Ibertos/cpu/arm
-armtest_LDFLAGS = -nostartfiles -T bertos/cpu/arm/scripts/at91sam7_256_rom.ld -Wl,--no-warn-mismatch
-
-armtest_CPU = arm7tdmi
-
+++ /dev/null
-#
-# $Id: avrtest.mk,v 1.3 2006/06/12 21:37:02 marco Exp $
-# Copyright 2006 Develer S.r.l. (http://www.develer.com/)
-# All rights reserved.
-#
-# Makefile fragment for DevLib avrtest application.
-#
-# Author: Bernie Innocenti <bernie@codewiz.org>
-#
-
-
-
-# Set to 1 for debug builds
-avrtest_DEBUG = 1
-
-# Our target application
-TRG += avrtest
-
-avrtest_MCU = atmega64
-
-#include avr c and asm sources
-include app/test/avr_src.mk
-
-avrtest_CSRC = $(avr_CSRC) app/test/empty_main.c
-
-avrtest_CPPASRC = $(avr_ASRC)
-
-avrtest_PCSRC += bertos/mware/formatwr.c
-
-avrtest_CROSS = avr-
-avrtest_CPPFLAGS = -D'ARCH=ARCH_NIGHTTEST' -Iapp/test -Ibertos/cpu/avr
-avrtest_CFLAGS = -Os -mcall-prologues -fno-strict-aliasing
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
- * All Rights Reserved.
- * -->
- *
- * \brief Hardware-specific definitions
- *
- * \version $Id$
- *
- * \author Daniele Basile <asterix@develer.com>
- */
-
-int main(void)
-{
- for(;;)
- {
- }
-
- return 0;
-}
+++ /dev/null
-/* Linker script for boot loader */
-
-OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
-OUTPUT_ARCH(avr:5)
-MEMORY
-{
- text (rx) : ORIGIN = 0xE000, LENGTH = 8K
- data (rw!x) : ORIGIN = 0x800060, LENGTH = 4000
- eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 2K
-}
-SECTIONS
-{
- /* Read-only sections, merged into text segment: */
- .hash : { *(.hash) }
- .dynsym : { *(.dynsym) }
- .dynstr : { *(.dynstr) }
- .gnu.version : { *(.gnu.version) }
- .gnu.version_d : { *(.gnu.version_d) }
- .gnu.version_r : { *(.gnu.version_r) }
- .rel.init : { *(.rel.init) }
- .rela.init : { *(.rela.init) }
- .rel.text :
- {
- *(.rel.text)
- *(.rel.text.*)
- *(.rel.gnu.linkonce.t*)
- }
- .rela.text :
- {
- *(.rela.text)
- *(.rela.text.*)
- *(.rela.gnu.linkonce.t*)
- }
- .rel.fini : { *(.rel.fini) }
- .rela.fini : { *(.rela.fini) }
- .rel.rodata :
- {
- *(.rel.rodata)
- *(.rel.rodata.*)
- *(.rel.gnu.linkonce.r*)
- }
- .rela.rodata :
- {
- *(.rela.rodata)
- *(.rela.rodata.*)
- *(.rela.gnu.linkonce.r*)
- }
- .rel.data :
- {
- *(.rel.data)
- *(.rel.data.*)
- *(.rel.gnu.linkonce.d*)
- }
- .rela.data :
- {
- *(.rela.data)
- *(.rela.data.*)
- *(.rela.gnu.linkonce.d*)
- }
- .rel.ctors : { *(.rel.ctors) }
- .rela.ctors : { *(.rela.ctors) }
- .rel.dtors : { *(.rel.dtors) }
- .rela.dtors : { *(.rela.dtors) }
- .rel.got : { *(.rel.got) }
- .rela.got : { *(.rela.got) }
- .rel.bss : { *(.rel.bss) }
- .rela.bss : { *(.rela.bss) }
- .rel.plt : { *(.rel.plt) }
- .rela.plt : { *(.rela.plt) }
- /* Internal text space or external memory */
- .text :
- {
- KEEP(*(.vectors))
- __ctors_start = . ;
- *(.ctors)
- __ctors_end = . ;
- __dtors_start = . ;
- *(.dtors)
- __dtors_end = . ;
- *(.progmem.gcc*)
- *(.progmem*)
- . = ALIGN(2);
- KEEP(*(.init0)) /* Start here after reset. */
- KEEP(*(.init1))
- KEEP(*(.init2)) /* Clear __zero_reg__, set up stack pointer. */
- KEEP(*(.init3))
- KEEP(*(.init4)) /* Initialize data and BSS. */
- KEEP(*(.init5))
- KEEP(*(.init6)) /* C++ constructors. */
- KEEP(*(.init7))
- KEEP(*(.init8))
- KEEP(*(.init9)) /* Call main(). */
- *(.text)
- . = ALIGN(2);
- *(.text.*)
- . = ALIGN(2);
- *(.fini9) /* _exit() starts here. */
- *(.fini8)
- *(.fini7)
- *(.fini6) /* C++ destructors. */
- *(.fini5)
- *(.fini4)
- *(.fini3)
- *(.fini2)
- *(.fini1)
- *(.fini0) /* Infinite loop after program termination. */
- _etext = . ;
- } > text
- .data : AT (ADDR (.text) + SIZEOF (.text))
- {
- PROVIDE (__data_start = .) ;
- *(.data .data.* .rodata .rodata.*)
- *(.gnu.linkonce.d*)
- . = ALIGN(2);
- _edata = . ;
- PROVIDE (__data_end = .) ;
- } > data
- .bss SIZEOF(.data) + ADDR(.data) :
- {
- PROVIDE (__bss_start = .) ;
- *(.bss .bss.*)
- *(COMMON)
- PROVIDE (__bss_end = .) ;
- } > data
- __data_load_start = LOADADDR(.data);
- __data_load_end = __data_load_start + SIZEOF(.data);
- /* Global data not cleared after reset. */
- .noinit SIZEOF(.bss) + ADDR(.bss) :
- {
- PROVIDE (__noinit_start = .) ;
- *(.noinit*)
- PROVIDE (__noinit_end = .) ;
- _end = . ;
- PROVIDE (__heap_start = .) ;
- } > data
- .eeprom :
- AT (ADDR (.text) + SIZEOF (.text) + SIZEOF (.data))
- {
- *(.eeprom*)
- __eeprom_end = . ;
- } > eeprom
- /* Stabs debugging sections. */
- .stab 0 : { *(.stab) }
- .stabstr 0 : { *(.stabstr) }
- .stab.excl 0 : { *(.stab.excl) }
- .stab.exclstr 0 : { *(.stab.exclstr) }
- .stab.index 0 : { *(.stab.index) }
- .stab.indexstr 0 : { *(.stab.indexstr) }
- .comment 0 : { *(.comment) }
- /* DWARF debug sections.
- Symbols in the DWARF debugging sections are relative to the beginning
- of the section so we begin them at 0. */
- /* DWARF 1 */
- .debug 0 : { *(.debug) }
- .line 0 : { *(.line) }
- /* GNU DWARF 1 extensions */
- .debug_srcinfo 0 : { *(.debug_srcinfo) }
- .debug_sfnames 0 : { *(.debug_sfnames) }
- /* DWARF 1.1 and DWARF 2 */
- .debug_aranges 0 : { *(.debug_aranges) }
- .debug_pubnames 0 : { *(.debug_pubnames) }
- /* DWARF 2 */
- .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
- .debug_abbrev 0 : { *(.debug_abbrev) }
- .debug_line 0 : { *(.debug_line) }
- .debug_frame 0 : { *(.debug_frame) }
- .debug_str 0 : { *(.debug_str) }
- .debug_loc 0 : { *(.debug_loc) }
- .debug_macinfo 0 : { *(.debug_macinfo) }
-}
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2001,2002,2003 Bernie Innocenti <bernie@codewiz.org>
- *
- * -->
- *
- * \brief Set system configuration
- *
- * \version $Id$
- *
- * \author Bernie Innocenti <bernie@codewiz.org>
- *
- */
-
-
-#ifndef CFG_ARCH_CONFIG_H
-#define CFG_ARCH_CONFIG_H
-
-#include <cfg/macros.h>
-
-/**
- * \name Architectures
- * \{
- */
-#define ARCH_TRIFACE BV(0)
-#define ARCH_BOOT BV(1)
-#define ARCH_EMUL BV(2)
-/*\}*/
-
-#endif /* CFG_ARCH_CONFIG_H */
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
- * All Rights Reserved.
- * -->
- *
- * \brief Configuration file for boot module.
- *
- * \version $Id$
- *
- * \author Manuele Fanelli <qwert@develer.com>
- */
-
-#ifndef CFG_BOOT_H
-#define CFG_BOOT_H
-
-#define CONFIG_SER_HOSTPORT 1 ///< Triface comunication host port
-
-#define CONFIG_SER_HOSTPORTBAUDRATE 115200 ///< Serial host port baudrate
-
-#endif /* CFG_BOOT_H */
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
- * All Rights Reserved.
- * -->
- *
- * \brief Configuration file for formatted write module.
- *
- * \version $Id$
- *
- * \author Daniele Basile <asterix@develer.com>
- */
-
-#ifndef CFG_FORMTWR_H
-#define CFG_FORMTWR_H
-
-/**
- * printf()-style formatter configuration.
- *
- * \sa PRINTF_DISABLED
- * \sa PRINTF_NOMODIFIERS
- * \sa PRINTF_REDUCED
- * \sa PRINTF_NOFLOAT
- * \sa PRINTF_FULL
- */
-#define CONFIG_PRINTF PRINTF_REDUCED
-
-
-#endif /* CFG_FORMTWR_H */
-
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2001, 2004 Develer S.r.l. (http://www.develer.com/)
- * Copyright 1999, 2000, 2001, 2008 Bernie Innocenti <bernie@codewiz.org>
- * -->
- *
- * \brief Kernel configuration parameters
- *
- * \version $Id$
- * \author Bernie Innocenti <bernie@codewiz.org>
- */
-
-#ifndef CFG_KERN_H
-#define CFG_KERN_H
-
-/**
- * Enable the multithreading kernel.
- */
-#define CONFIG_KERN 0
-
-/**
- * \name Optional kernel features
- * \{
- */
-#define CONFIG_KERN_SCHED 0 ///< Process schedling
-#define CONFIG_KERN_SIGNALS 0 ///< Inter-process signals
-#define CONFIG_KERN_IRQ 0 ///< Interrupt supervisor
-#define CONFIG_KERN_HEAP 0 ///< Dynamic memory allocation
-#define CONFIG_KERN_SEMAPHORES 0 ///< Re-entrant mutual exclusion primitives
-#define CONFIG_KERN_MONITOR 0 ///< Process monitor
-#define CONFIG_KERN_PREEMPT 0 ///< Preemptive process scheduling
-#define CONFIG_KERN_PRI 0 ///< Priority-based scheduling policy
-/*\}*/
-
-/// [ms] Time sharing quantum (a prime number prevents interference effects)
-#define CONFIG_KERN_QUANTUM 47
-
-/// Module logging level.
-#define KERN_LOG_LEVEL LOG_LVL_ERR
-
-/// Module logging format.
-#define KERN_LOG_FORMAT LOG_FMT_VERBOSE
-
-#endif /* CFG_KERN_H */
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
- * All Rights Reserved.
- * -->
- *
- * \brief Configuration file for KFile interface module.
- *
- * \version $Id$
- * \author Daniele Basile <asterix@develer.com>
- */
-
-#ifndef CFG_KFILE_H
-#define CFG_KFILE_H
-
-/// Module logging level definition.
-#define KFILE_LOG_LEVEL LOG_LVL_INFO
-
-/// Module logging verbosity.
-#define KFILE_LOG_FORMAT LOG_FMT_TERSE
-
-/// Enable the gets function with echo.
-#define CONFIG_KFILE_GETS 1
-
-#endif /* CFG_KFILE_H */
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
- * All Rights Reserved.
- * -->
- *
- * \brief Configuration file for serial module.
- *
- * \version $Id$
- *
- * \author Daniele Basile <asterix@develer.com>
- */
-
-#ifndef CFG_SER_H
-#define CFG_SER_H
-
-
-/// Kdebug console on debug unit
-#define CONFIG_TRIFACE_PORT 0
-
-/// Baud-rate for the kdebug console
-#define CONFIG_TRIFACE_BAUDRATE 115200
-
-/// [bytes] Size of the outbound FIFO buffer for port 0.
-#define CONFIG_UART0_TXBUFSIZE 32
-
-/// [bytes] Size of the inbound FIFO buffer for port 0.
-#define CONFIG_UART0_RXBUFSIZE 64
-
-/// [bytes] Size of the outbound FIFO buffer for port 1.
-#define CONFIG_UART1_TXBUFSIZE 32
-
-/// [bytes] Size of the inbound FIFO buffer for port 1.
-#define CONFIG_UART1_RXBUFSIZE 64
-
-
-/// [bytes] Size of the outbound FIFO buffer for SPI port (AVR only)
-#define CONFIG_SPI_TXBUFSIZE 32
-
-/// [bytes] Size of the inbound FIFO buffer for SPI port (AVR only)
-#define CONFIG_SPI_RXBUFSIZE 32
-
-/// [bytes] Size of the outbound FIFO buffer for SPI port 0.
-#define CONFIG_SPI0_TXBUFSIZE 32
-
-/// [bytes] Size of the inbound FIFO buffer for SPI port 0.
-#define CONFIG_SPI0_RXBUFSIZE 32
-
-/// [bytes] Size of the outbound FIFO buffer for SPI port 1.
-#define CONFIG_SPI1_TXBUFSIZE 32
-
-/// [bytes] Size of the inbound FIFO buffer for SPI port 1.
-#define CONFIG_SPI1_RXBUFSIZE 32
-
-/// SPI data order (AVR only).
-#define CONFIG_SPI_DATA_ORDER SER_MSB_FIRST
-
-/// SPI clock division factor (AVR only).
-#define CONFIG_SPI_CLOCK_DIV 16
-
-/// SPI clock polarity: 0 = normal low, 1 = normal high (AVR only).
-#define CONFIG_SPI_CLOCK_POL 0
-
-/// SPI clock phase: 0 = sample on first edge, 1 = sample on second clock edge (AVR only).
-#define CONFIG_SPI_CLOCK_PHASE 0
-
-/// Default transmit timeout (ms). Set to -1 to disable timeout support.
-#define CONFIG_SER_TXTIMEOUT 100
-
-/// Default receive timeout (ms). Set to -1 to disable timeout support.
-#define CONFIG_SER_RXTIMEOUT 100
-
-/// Use RTS/CTS handshake
-#define CONFIG_SER_HWHANDSHAKE 0
-
-/// Default baud rate (set to 0 to disable).
-#define CONFIG_SER_DEFBAUDRATE 0
-
-/// Enable second serial port in emulator.
-#define CONFIG_EMUL_UART1 0
-
-/**
- * Transmit always something on serial port 0 TX
- * to avoid interference when sending burst of data,
- * using AVR multiprocessor serial mode
- */
-#define CONFIG_SER_TXFILL 0
-
-/// For serial debug.
-#define CONFIG_SER_STROBE 0
-
-#endif /* CFG_SER_H */
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
- *
- * -->
- *
- * \brief Macro for boot loader.
- *
- *
- * \version $Id$
- *
- * \author Daniele Basile <asterix@develer.com>
- * \author Francesco Sacchi <batt@develer.com>
- */
-
-#ifndef HW_BOOT_H
-#define HW_BOOT_H
-
-#include <avr/io.h>
-
-/* Set up function pointer to RESET vector */
-void (*rom_start)(void) NORETURN = 0x0000;
-
-#define START_APP() rom_start()
-
-#define BOOT_INIT do \
-{ \
- /* Enable change of Interrupt Vectors */ \
- MCUCR = BV(IVCE); \
- /* Move interrupts to boot Flash section */ \
- MCUCR = BV(IVSEL); \
-} while(0)
-
-#define BOOT_END do \
-{ \
- /* Enable change of Interrupt Vectors */ \
- MCUCR = BV(IVCE); \
- /* Move interrupts to boot Flash section */ \
- MCUCR = 0; \
-} while(0)
-
-#endif // HW_BOOT_H
-
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
- *
- * --> Rights Reserved.
- *
- * \brief Hardware-specific definitions
- *
- * \version $Id$
- *
- * \author Bernie Innocenti <bernie@codewiz.org>
- */
-
-#ifndef TRIFACE_HW_H
-#define TRIFACE_HW_H
-
-/// CPU Clock frequency (14.7456 MHz)
-#define CLOCK_FREQ (14745600UL)
-
-
-/* Timer IRQ strobe */
-//#if CONFIG_TIMER_STROBE
-// #define TIMER_STROBE_ON ATOMIC(PORTD |= BV(PD0))
-// #define TIMER_STROBE_OFF ATOMIC(PORTD &= ~BV(PD0))
-// #define TIMER_STROBE_INIT ATOMIC(PORTD &= ~BV(PD0); DDRD |= BV(PD0))
-//#endif /* CONFIG_TIMER_STROBE */
-
-#endif /* TRIFACE_HW_H */
-
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
- * All Rights Reserved.
- * -->
- *
- * \brief Serial hardware-specific definitions
- *
- * \version $Id$
- *
- * \author Daniele Basile <asterix@develer.com>
- */
-
-#ifndef HW_SER_H
-#define HW_SER_H
-
-
-
-#endif /* HW_SER_H */
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
- *
- * -->
- *
- * \brief Flash boot loader main.
- * This is a simple generic bootloader app.
- * It requires only a serial port to work.
- * Try to receive a file through XMODEM protocol
- * and flash it on program memory.
- * BOOT_INIT, BOOT_END are macros used to perform special operations
- * respectively at boot start and boot end and are CPU dependant.
- * The macro START_APP() jumps to main application start.
- *
- * \version $Id$
- * \author Stefano Fedrigo <aleph@develer.com>
- * \author Francesco Sacchi <batt@develer.com>
- * \author Daniele Basile <asterix@develer.com>
- */
-
-#include <net/xmodem.h>
-#include <cfg/compiler.h>
-#include <cfg/debug.h>
-#include <cfg/macros.h> /* BV() */
-
-#include <drv/wdt.h>
-#include <drv/ser.h>
-#include <drv/timer.h>
-#include <drv/flash_avr.h>
-
-#include "hw/hw_boot.h"
-#include "cfg/cfg_boot.h"
-
-#include <string.h>
-
-int main(void)
-{
- FlashAvr flash;
- Serial ser;
-
-
- // Set up flash programming functions.
- flash_avr_init(&flash);
-
- IRQ_ENABLE;
-
- BOOT_INIT;
-
- kdbg_init();
- timer_init();
-
-
- /* Open the main communication port */
-
- ser_init(&ser, CONFIG_SER_HOSTPORT);
- ser_setbaudrate(&ser, CONFIG_SER_HOSTPORTBAUDRATE);
-
- xmodem_recv(&ser, &flash.fd);
- kfile_close(&flash.fd);
- kfile_close(&ser.fd);
-
- IRQ_DISABLE;
-
- BOOT_END;
-
- START_APP();
-
-}
-
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2001,2002,2003 Bernie Innocenti <bernie@codewiz.org>
- *
- * -->
- *
- * \brief Set system configuration
- *
- * \version $Id$
- *
- * \author Bernie Innocenti <bernie@codewiz.org>
- *
- */
-
-
-#ifndef CFG_ARCH_CONFIG_H
-#define CFG_ARCH_CONFIG_H
-
-#include <cfg/macros.h>
-
-/**
- * \name Architectures
- * \{
- */
-#define ARCH_TRIFACE BV(0)
-#define ARCH_BOOT BV(1)
-#define ARCH_EMUL BV(2)
-/*\}*/
-
-#endif /* CFG_ARCH_CONFIG_H */
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
- * All Rights Reserved.
- * -->
- *
- * \brief Configuration file for Debug module.
- *
- * \version $Id$
- *
- * \author Daniele Basile <asterix@develer.com>
- */
-
-#ifndef CFG_DEBUG_H
-#define CFG_DEBUG_H
-
-/// kdebug console.
-#define CONFIG_KDEBUG_PORT 1
-
-/// Baud-rate for the kdebug console.
-#define CONFIG_KDEBUG_BAUDRATE 115200
-
-#endif /* CFG_DEBUG_H */
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2001, 2004 Develer S.r.l. (http://www.develer.com/)
- * Copyright 1999, 2000, 2001, 2008 Bernie Innocenti <bernie@codewiz.org>
- * -->
- *
- * \brief Kernel configuration parameters
- *
- * \version $Id$
- * \author Bernie Innocenti <bernie@codewiz.org>
- */
-
-#ifndef CFG_KERN_H
-#define CFG_KERN_H
-
-/**
- * Enable the multithreading kernel.
- */
-#define CONFIG_KERN 0
-
-/**
- * \name Optional kernel features
- * \{
- */
-#define CONFIG_KERN_SCHED 0 ///< Process schedling
-#define CONFIG_KERN_SIGNALS 0 ///< Inter-process signals
-#define CONFIG_KERN_IRQ 0 ///< Interrupt supervisor
-#define CONFIG_KERN_HEAP 0 ///< Dynamic memory allocation
-#define CONFIG_KERN_SEMAPHORES 0 ///< Re-entrant mutual exclusion primitives
-#define CONFIG_KERN_MONITOR 0 ///< Process monitor
-#define CONFIG_KERN_PREEMPT 0 ///< Preemptive process scheduling
-#define CONFIG_KERN_PRI 0 ///< Priority-based scheduling policy
-/*\}*/
-
-/// [ms] Time sharing quantum (a prime number prevents interference effects)
-#define CONFIG_KERN_QUANTUM 47
-
-/// Module logging level.
-#define KERN_LOG_LEVEL LOG_LVL_ERR
-
-/// Module logging format.
-#define KERN_LOG_FORMAT LOG_FMT_VERBOSE
-
-#endif /* CFG_KERN_H */
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
- *
- * -->
- *
- * \brief Configuration file for KFile interface module.
- *
- * \version $Id$
- * \author Daniele Basile <asterix@develer.com>
- */
-
-#ifndef CFG_KFILE_H
-#define CFG_KFILE_H
-
-/// Module logging level definition.
-#define KFILE_LOG_LEVEL LOG_LVL_INFO
-
-/// Module logging format.
-#define KFILE_LOG_FORMAT LOG_FMT_TERSE
-
-/// Enable the gets function with echo.
-#define CONFIG_KFILE_GETS 1
-
-#endif /* CFG_KFILE_H */
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
- * All Rights Reserved.
- * -->
- *
- * \brief Configuration file for serial module.
- *
- * \version $Id$
- *
- * \author Daniele Basile <asterix@develer.com>
- */
-
-#ifndef CFG_SER_H
-#define CFG_SER_H
-
-
-/// Kdebug console on debug unit
-#define CONFIG_TRIFACE_PORT 1
-
-/// Baud-rate for the kdebug console
-#define CONFIG_TRIFACE_BAUDRATE 115200
-/// Triface serial tag port
-#define TAG_SER_PORT 0
-///Baud-rate for triface serial tag port
-#define TAG_SER_BAUDRATE 9600
-
-/// [bytes] Size of the outbound FIFO buffer for port 0.
-#define CONFIG_UART0_TXBUFSIZE 32
-
-/// [bytes] Size of the inbound FIFO buffer for port 0.
-#define CONFIG_UART0_RXBUFSIZE 64
-
-/// [bytes] Size of the outbound FIFO buffer for port 1.
-#define CONFIG_UART1_TXBUFSIZE 32
-
-/// [bytes] Size of the inbound FIFO buffer for port 1.
-#define CONFIG_UART1_RXBUFSIZE 64
-
-
-/// [bytes] Size of the outbound FIFO buffer for SPI port (AVR only)
-#define CONFIG_SPI_TXBUFSIZE 32
-
-/// [bytes] Size of the inbound FIFO buffer for SPI port (AVR only)
-#define CONFIG_SPI_RXBUFSIZE 32
-
-/// [bytes] Size of the outbound FIFO buffer for SPI port 0.
-#define CONFIG_SPI0_TXBUFSIZE 32
-
-/// [bytes] Size of the inbound FIFO buffer for SPI port 0.
-#define CONFIG_SPI0_RXBUFSIZE 32
-
-/// [bytes] Size of the outbound FIFO buffer for SPI port 1.
-#define CONFIG_SPI1_TXBUFSIZE 32
-
-/// [bytes] Size of the inbound FIFO buffer for SPI port 1.
-#define CONFIG_SPI1_RXBUFSIZE 32
-
-/// SPI data order (AVR only).
-#define CONFIG_SPI_DATA_ORDER SER_MSB_FIRST
-
-/// SPI clock division factor (AVR only).
-#define CONFIG_SPI_CLOCK_DIV 16
-
-/// SPI clock polarity: 0 = normal low, 1 = normal high (AVR only).
-#define CONFIG_SPI_CLOCK_POL 0
-
-/// SPI clock phase: 0 = sample on first edge, 1 = sample on second clock edge (AVR only).
-#define CONFIG_SPI_CLOCK_PHASE 0
-
-/// Default transmit timeout (ms). Set to -1 for infinite timeout, 0 for null timeout
-#define CONFIG_SER_TXTIMEOUT 0
-
-/// Default receive timeout (ms). Set to -1 for infinite timeout, 0 for null timeout
-#define CONFIG_SER_RXTIMEOUT 0
-
-/// Use RTS/CTS handshake
-#define CONFIG_SER_HWHANDSHAKE 0
-
-/// Default baud rate (set to 0 to disable).
-#define CONFIG_SER_DEFBAUDRATE 0
-
-/// Enable second serial port in emulator.
-#define CONFIG_EMUL_UART1 0
-
-/**
- * Transmit always something on serial port 0 TX
- * to avoid interference when sending burst of data,
- * using AVR multiprocessor serial mode
- */
-#define CONFIG_SER_TXFILL 0
-
-/// For serial debug.
-#define CONFIG_SER_STROBE 0
-
-#endif /* CFG_SER_H */
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
- * All Rights Reserved.
- * -->
- *
- * \brief Configuration file for watchdog module.
- *
- * \version $Id$
- *
- * \author Daniele Basile <asterix@develer.com>
- */
-
-#ifndef CFG_WDT_H
-#define CFG_WDT_H
-
-/// Enable watchdog timer.
-#define CONFIG_WATCHDOG 1
-
-#endif /* CFG_WDT_H */
-
-
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
- * -->
- *
- * \brief Macro for defining command for protocol.
- *
- *
- * \version $Id$
- *
- * \author Marco Benelli <marco@develer.com>
- */
-
-#ifndef CMD_CTOR_H
-#define CMD_CTOR_H
-
-#include <mware/parser.h>
-
-#define REGISTER_FUNCTION parser_register_cmd
-
-#define REGISTER_CMD(NAME) REGISTER_FUNCTION(&cmd_ ## NAME ## _template)
-
-#define MAKE_TEMPLATE(NAME, ARGS, RES, FLAGS) \
-const struct CmdTemplate cmd_ ## NAME ## _template = \
-{ \
- #NAME, ARGS, RES, cmd_ ## NAME, FLAGS \
-};
-
-#define MAKE_CMD(NAME, ARGS, RES, BODY, FLAGS) \
-static ResultCode cmd_ ## NAME (parms *args) \
-{ \
- return (ResultCode)BODY; \
-} \
-MAKE_TEMPLATE(NAME, ARGS, RES, FLAGS)
-
-#endif // CMD_CTOR_H
+++ /dev/null
-
-Command format:
-
- <command><SP><arg1><SP>...<argN><CR><LF>
-
-Where:
- command - alphanumeric command name
- argN - numeric argument (unsigned base 10, 0-65535)
-
-Positive response format:
-
- 0<SP><arg1><SP>...<argN><CR><LF>
-
-Where:
- argN - numeric value (unsigned base 10, 0-65535)
-
-Negative response format:
-
- -N<SP>"<desc>"<CR><LF>
-
-Where:
- -N - numeric error code (negative number)
- desc - verbose error description
-
-# Write digital outputs (masked)
-> dout 120 240
-< 0
-
-# Read digital inputs
-> din
-< 0 125
-
-# Read analog inputs
-> ain
-< 0 32 121 35 31
-
-# Wait specified amount of milliseconds
-> sleep 300
-< 0
-
-# Return firmware major version, minor version and revision
-> vers
-< 0 1 42 0
-
-# Reset board
-< reset
-> 0
-
-# Ping/nop
-< ping
-> 0
-
-# NOP (empty command)
->
-< (ignored)
-
-# Comments
-> # foo bar foobar
-< (ignored)
-
-# Unknown command
-> sing
-< -1 "Unknown command"
-
-# Missing parameter
-> dout
-< -2 "Required parameter missing"
-
-# Too many parameters
-> din 42 666
-< -3 "Too many parameters"
-
-# Malformed command
-> dout %'I!
-< -4 "Invalid parameter"
-
-# Attention
-> <CTRL-C> or <CTRL-D>
-< 1 "Uh?"
-
-
-To recover from a possibly unknown board status,
-a client should begin the conversation by issuing
-an attention sequence, eventually followed by a reset.
+++ /dev/null
-(ExpressProject "triface"\r
- (ProjectVersion "19981106")\r
- (ProjectType "PCB")\r
- (Folder "Design Resources"\r
- (Folder "Library")\r
- (NoModify)\r
- (File ".\triface.dsn"\r
- (Type "Schematic Design"))\r
- (BuildFileAddedOrDeleted "x")\r
- (CompileFileAddedOrDeleted "x")\r
- (ANNOTATE_Scope "0")\r
- (ANNOTATE_Mode "1")\r
- (ANNOTATE_Action "0")\r
- (Annotate_Page_Order "0")\r
- (ANNOTATE_Reset_References_to_1 "FALSE")\r
- (ANNOTATE_No_Page_Number_Change "FALSE")\r
- (ANNOTATE_Property_Combine "{Value}{Source Package}{POWER_GROUP}")\r
- (ANNOTATE_IncludeNonPrimitive "FALSE"))\r
- (Folder "Outputs")\r
- (Folder "Referenced Projects")\r
- (PartMRUSelector)\r
- (GlobalState\r
- (FileView\r
- (Path "Design Resources")\r
- (Path "Design Resources"\r
- "c:\documents and settings\administrator\desktop\new triface\triface.dsn")\r
- (Path "Design Resources"\r
- "c:\documents and settings\administrator\desktop\new triface\triface.dsn"\r
- "TRIFACE BOARD"))\r
- (HierarchyView)\r
- (Doc\r
- (Type "COrCapturePMDoc")\r
- (Frame\r
- (Placement "44 2 3 -1 -1 -4 -23 214 743 2 443"))\r
- (Tab 0)))\r
- (MPSSessionName "Administrator"))\r
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
- *
- * -->
- *
- * \brief ADC: Analogic to Digital Converter
- *
- *
- * \version $Id$
- *
- * \author Andrea Grandi <andrea@develer.com>
- */
-
-#include "hw/hw_adc.h"
-
-
-#include <cfg/macros.h>
-
-#include <drv/timer.h>
-
-#include <avr/io.h>
-
-/** Set the active AI channel */
-void adc_set_active_ain(int ai)
-{
- /* If number of channels is <= 4 we use the first two MUX bits */
- STATIC_ASSERT(ADC_CHANNEL_NUM <= 4);
-
- ai &= BV(0) | BV(1);
- ADMUX &= ~BV(MUX0);
- ADMUX &= ~BV(MUX1);
- ADMUX |= ai;
-}
-
-/** Initialize the ADC */
-void adc_init(void)
-{
- /* Set analog IN as input */
- DDRF &= ~(BV(PF0) | BV(PF1) | BV(PF2) | BV(PF3));
-
- /* Disable pull-up */
- PORTF &= ~(BV(PF0) | BV(PF1) | BV(PF2) | BV(PF3));
-
- ENABLE_ADC;
- adc_set_vref_avcc();
- SET_AI_ADLAR;
-
- /* Set the Division Factor to 128 */
- ADCSRA |= (BV(ADPS0) | BV(ADPS1) | BV(ADPS2));
-}
-
-/** Set the initial reference */
-void adc_set_vref_avcc(void)
-{
- ADMUX &= ~BV(REFS1);
- ADMUX |= BV(REFS0);
-}
-
-/** Read the specified AI channel */
-int adc_read_ai_channel(int channel)
-{
- adc_set_active_ain(channel);
- timer_udelay(STABILIZING_AI_CHANNEL_TIME);
- START_CONVERTION;
-
- while(ADCSRA & BV(ADSC))
- {
- /*
- * Intentionally empty loop.
- * It waits the convertion to be completed by ADC
- */
- }
-
- ADCSRA |= BV(ADIF);
-
- uint16_t val;
- val = ADCL;
- val |= (uint16_t)ADCH << 8;
-
- return val;
-}
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
- *
- * -->ght 2006 Develer S.r.l. (http://www.develer.com/)
- *
- * \brief Macro for HW_AIN_H
- *
- *
- * \version $Id$
- *
- * \author Andrea Grandi <andrea@develer.com>
- */
-
-#ifndef HW_ADC_H
-#define HW_ADC_H
-
-#include <avr/io.h>
-
-#define START_CONVERTION (ADCSRA |= BV(ADSC))
-#define ENABLE_ADC (ADCSRA |= BV(ADEN))
-#define SET_AI_ADLAR (ADMUX &= ~BV(ADLAR))
-
-/** Microseconds to wait before starting conversion after changing a channel */
-#define STABILIZING_AI_CHANNEL_TIME 125
-
-/** Number of AIN channels */
-#define ADC_CHANNEL_NUM 4
-
-void adc_set_active_ain(int ai);
-void adc_init(void);
-void adc_set_vref_avcc(void);
-int adc_read_ai_channel(int channel);
-
-#endif // HW_ADC_H
-
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
- *
- * -->
- *
- * \brief Buzzer hardware-specific definitions
- *
- * \version $Id$
- *
- * \author Francesco Sacchi <batt@develer.com>
- * Andrea Grandi <andrea@develer.com>
- */
-
-#ifndef HW_BUZZER_H
-#define HW_BUZZER_H
-
-#include <avr/io.h>
-#include <cfg/macros.h>
-
-#define BUZZER_BIT BV(PE3)
-#define IS_BUZZER_ON (PORTE & BUZZER_BIT)
-#define BUZZER_HW_INIT do { DDRE |= BV(DDE3); } while (0)
-#define BUZZER_ON do { PORTE |= BUZZER_BIT; } while (0)
-#define BUZZER_OFF do { PORTE &= ~BUZZER_BIT; } while (0)
-
-#endif /* HW_BUZZER_H */
-
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
- *
- * --> Rights Reserved.
- *
- * \brief Hardware-specific definitions
- *
- * \version $Id$
- *
- * \author Bernie Innocenti <bernie@codewiz.org>
- */
-
-#ifndef TRIFACE_HW_H
-#define TRIFACE_HW_H
-
-/// CPU Clock frequency (14.7456 MHz)
-#define CLOCK_FREQ (14745600UL)
-
-
-/* Timer IRQ strobe */
-//#if CONFIG_TIMER_STROBE
-// #define TIMER_STROBE_ON ATOMIC(PORTD |= BV(PD0))
-// #define TIMER_STROBE_OFF ATOMIC(PORTD &= ~BV(PD0))
-// #define TIMER_STROBE_INIT ATOMIC(PORTD &= ~BV(PD0); DDRD |= BV(PD0))
-//#endif /* CONFIG_TIMER_STROBE */
-
-#endif /* TRIFACE_HW_H */
-
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
- *
- * -->
- *
- * \brief Macro for HW_INPUT_H
- *
- *
- * \version $Id$
- *
- * \author Andrea Grandi <andrea@develer.com>
- */
-
-#ifndef HW_INPUT_H
-#define HW_INPUT_H
-
-#include <avr/io.h>
-
-/* Set pins as input and enable pull-up */
-#define INPUT_INIT_D do \
-{ \
- (DDRD &= ~(BV(PD4) | BV(PD5) | BV(PD6) | BV(PD7))); \
- (PORTD |= (BV(PD4) | BV(PD5) | BV(PD6) | BV(PD7))); \
-} while(0)
-
-#define INPUT_INIT_E do \
-{ \
- (DDRE &= ~(BV(PE4) | BV(PE5) | BV(PE6) | BV(PE7))); \
- ATOMIC((PORTE |= (BV(PE4) | BV(PE5) | BV(PE6) | BV(PE7)))); \
-} while(0)
-
-#define INPUT_INIT do { INPUT_INIT_D; INPUT_INIT_E;} while(0)
-
-INLINE uint8_t INPUT_GET(void)
-{
- uint8_t out_d, out_e;
- out_d = PIND;
- out_e = PINE;
-
- out_d >>= 4;
- out_e = out_e & 0xF0;
-
- return out_e | out_d;
-}
-
-#endif // HW_INPUT_H
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
- * All Rights Reserved.
- * -->
- *
- * \brief Macro for STROBE signal
- *
- * \version $Id$
- *
- * \author Manuele Fanelli <qwert@develer.com>
- */
-
-#ifndef HW_SER_H
-#define HW_SER_H
-
-#include "cfg/cfg_ser.h"
-
-#if CONFIG_SER_STROBE
-
- #define SER_STROBE_ON do {PORTC |= BV(0);} while(0)
- #define SER_STROBE_OFF do {PORTC &= ~BV(0);} while(0)
- #define SER_STROBE_INIT do {DDRC |= BV(0); } while(0)
-#endif
-
-#endif //HW_SER_H
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
- *
- * -->
- *
- * \brief Macro for HW_SIPO_H
- *
- *
- * \version $Id$
- *
- * \author Andrea Grandi <andrea@develer.com>
- */
-#ifndef HW_SIPO_H
-#define HW_SIPO_H
-
-#define LOAD_HIGH (PORTB |= BV(PB3))
-#define LOAD_LOW (PORTB &= ~BV(PB3))
-#define LOAD_INIT (DDRB |= BV(PB3))
-#define SET_SCK_OUT (DDRB |= BV(PB1))
-#define SET_SOUT_OUT (DDRB |= BV(PB2))
-#define CLOCK_HIGH (PORTB |= BV(PB1))
-#define CLOCK_LOW (PORTB &= ~BV(PB1))
-#define SET_SOUT_HIGH (PORTB |= BV(PB2))
-#define SET_SOUT_LOW (PORTB &= ~BV(PB2))
-#define CLOCK_PULSE do { CLOCK_HIGH; CLOCK_LOW; } while(0)
-
-#define OE_OUT (DDRG |= BV(PG3))
-#define OE_LOW (PORTG &= BV(PG3))
-
-
-#endif // HW_SIPO_H
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
- *
- * -->
- *
- * \brief Implementation of the command protocol between the board and the host
- *
- *
- * \version $Id$
- *
- * \author Giovanni Bajo <rasky@develer.com>
- * \author Marco Benelli <marco@develer.com>
- * \author Bernie Innocenti <bernie@codewiz.org>
- * \author Daniele Basile <asterix@develer.com>
- */
-
-#include "protocol.h"
-#include "cmd_ctor.h" // MAKE_CMD, REGISTER_CMD
-#include "verstag.h"
-#include "hw/hw_adc.h"
-#include "hw/hw_input.h"
-
-#include <drv/timer.h>
-#include <drv/ser.h>
-#include <drv/sipo.h>
-#include <drv/wdt.h>
-#include <drv/buzzer.h>
-
-#include <mware/readline.h>
-#include <mware/parser.h>
-
-#include <cfg/compiler.h>
-#include <cfg/debug.h>
-
-#include <kern/kfile.h>
-
-#include <stdlib.h>
-#include <string.h>
-
-// Define the format string for ADC
-#define ADC_FORMAT_STR "dddd"
-
-// DEBUG: set to 1 to force interactive mode
-#define FORCE_INTERACTIVE 1
-
-/**
- * True if we are in interactive mode, false if we are in protocol mode.
- * In interactive mode, commands are read through readline() (prompt,
- * completion, history) without IDs, and replies/errors are sent to the serial
- * output.
- * In protocol mode, we implement the default protocol
- */
-static bool interactive;
-
-/// Readline context, used for interactive mode.
-static struct RLContext rl_ctx;
-
-uint8_t reg_status_dout;
-/**
- * Send a NAK asking the host to send the current message again.
- *
- * \a fd kfile handler for serial.
- * \a err human-readable description of the error for debug purposes.
- */
-INLINE void NAK(KFile *fd, const char *err)
-{
-#ifdef _DEBUG
- kfile_printf(fd, "NAK \"%s\"\r\n", err);
-#else
- kfile_printf(fd, "NAK\r\n");
-#endif
-}
-
-static void protocol_prompt(KFile *fd)
-{
- kfile_print(fd, ">> ");
-}
-
-/*
- * Print args on s, with format specified in t->result_fmt.
- * Return number of valid arguments or -1 in case of error.
- */
-static bool protocol_reply(KFile *fd, const struct CmdTemplate *t,
- const parms *args)
-{
- unsigned short offset = strlen(t->arg_fmt) + 1;
- unsigned short nres = strlen(t->result_fmt);
-
- for (unsigned short i = 0; i < nres; ++i)
- {
- if (t->result_fmt[i] == 'd')
- {
- kfile_printf(fd, " %ld", args[offset+i].l);
- }
- else if (t->result_fmt[i] == 's')
- {
- kfile_printf(fd, " %s", args[offset+i].s);
- }
-
- else
- {
- abort();
- }
- }
- kfile_printf(fd, "\r\n");
- return true;
-}
-
-static void protocol_parse(KFile *fd, const char *buf)
-{
- const struct CmdTemplate *templ;
-
- /* Command check. */
- templ = parser_get_cmd_template(buf);
- if (!templ)
- {
- kfile_print(fd, "-1 Invalid command.\r\n");
- protocol_prompt(fd);
- return;
- }
-
- parms args[PARSER_MAX_ARGS];
-
- /* Args Check. TODO: Handle different case. see doc/PROTOCOL . */
- if (!parser_get_cmd_arguments(buf, templ, args))
- {
- kfile_print(fd, "-2 Invalid arguments.\r\n");
- protocol_prompt(fd);
- return;
- }
-
- /* Execute. */
- if(!parser_execute_cmd(templ, args))
- {
- NAK(fd, "Error in executing command.");
- }
- if (!protocol_reply(fd, templ, args))
- {
- NAK(fd, "Invalid return format.");
- }
-
- protocol_prompt(fd);
- return;
-}
-
-void protocol_run(KFile *fd)
-{
- /**
- * \todo to be removed, we could probably access the serial FIFO
- * directly
- */
- static char linebuf[80];
-
- if (!interactive)
- {
- kfile_gets(fd, linebuf, sizeof(linebuf));
-
- // reset serial port error anyway
- kfile_clearerr(fd);
-
- // check message minimum length
- if (linebuf[0])
- {
- /* If we enter lines beginning with sharp(#)
- they are stripped out from commands */
- if(linebuf[0] != '#')
- {
- if (linebuf[0] == 0x1B && linebuf[1] == 0x1B) // ESC
- {
- interactive = true;
- kfile_printf(fd, "Entering interactive mode\r\n");
- }
- else
- {
- protocol_parse(fd, linebuf);
- }
- }
- }
- }
- else
- {
- const char *buf;
-
- /*
- * Read a line from serial. We use a temporary buffer
- * because otherwise we would have to extract a message
- * from the port immediately: there might not be any
- * available, and one might get free while we read
- * the line. We also add a fake ID at the start to
- * fool the parser.
- */
- buf = rl_readline(&rl_ctx);
-
- /* If we enter lines beginning with sharp(#)
- they are stripped out from commands */
- if(buf && buf[0] != '#')
- {
- if (buf[0] != '\0')
- {
- // exit special case to immediately change serial input
- if (!strcmp(buf, "exit") || !strcmp(buf, "quit"))
- {
- rl_clear_history(&rl_ctx);
- kfile_printf(fd, "Leaving interactive mode...\r\n");
- interactive = FORCE_INTERACTIVE;
- }
- else
- {
- //TODO: remove sequence numbers
- linebuf[0] = '0';
- linebuf[1] = ' ';
-
- strncpy(linebuf + 2, buf, sizeof(linebuf) - 3);
- linebuf[sizeof(linebuf) - 1] = '\0';
- protocol_parse(fd, linebuf);
- }
- }
- }
- }
-}
-
-/*
- * Commands.
- * TODO: Command declarations and definitions should be in another file(s).
- * Maybe we should use CMD_HUNK_TEMPLATE.
- *
- */
-
-MAKE_CMD(ver, "", "ddd",
-({
- args[1].l = VERS_MAJOR;
- args[2].l = VERS_MINOR;
- args[3].l = VERS_REV;
- 0;
-}), 0);
-
-/* Sleep. Example of declaring function body directly in macro call. */
-MAKE_CMD(sleep, "d", "",
-({
- timer_delay((mtime_t)args[1].l);
- 0;
-}), 0)
-
-/* Ping. */
-MAKE_CMD(ping, "", "",
-({
- //Silence "args not used" warning.
- (void)args;
- 0;
-}), 0)
-
-/* Dout */
-MAKE_CMD(dout, "d", "",
-({
- sipo_putchar((uint8_t)args[1].l);
-
- //Store status of dout ports.
- reg_status_dout = (uint8_t)args[1].l;
- 0;
-}), 0)
-
-/* rdout read the status of out ports.*/
-MAKE_CMD(rdout, "", "d",
-({
- args[1].l = reg_status_dout;
- 0;
-}), 0)
-
-
-/* Reset */
-MAKE_CMD(reset, "", "",
-({
- //Silence "args not used" warning.
- (void)args;
- wdt_init(7);
- wdt_start();
-
- /*We want to have an infinite loop that lock access on watchdog timer.
- This piece of code it's equivalent to a while(true), but we have done this because
- gcc generate a warning message that suggest to use "noreturn" parameter in function reset.*/
- ASSERT(args);
- while(args);
- 0;
-
-}), 0)
-
-/* Din */
-MAKE_CMD(din, "", "d",
-({
- args[1].l = INPUT_GET();
- 0;
-}), 0)
-
-
-
-/* Ain */
-MAKE_CMD(ain, "", ADC_FORMAT_STR,
-({
- STATIC_ASSERT((sizeof(ADC_FORMAT_STR) - 1) == ADC_CHANNEL_NUM);
- for(int i = 0; i < ADC_CHANNEL_NUM; i++)
- args[i+1].l = adc_read_ai_channel(i);
-
- 0;
-}), 0)
-
-/* Beep */
-MAKE_CMD(beep, "d", "",
-({
- buz_beep(args[1].l);
- 0;
-}), 0)
-
-/* Register commands. */
-static void protocol_registerCmds(void)
-{
- REGISTER_CMD(ver);
- REGISTER_CMD(sleep);
- REGISTER_CMD(ping);
- REGISTER_CMD(dout);
- //Set off all dout ports.
- reg_status_dout = 0;
- REGISTER_CMD(rdout);
- REGISTER_CMD(reset);
- REGISTER_CMD(din);
- REGISTER_CMD(ain);
- REGISTER_CMD(beep);
-}
-
-/* Initialization: readline context, parser and register commands. */
-void protocol_init(KFile *fd)
-{
- interactive = FORCE_INTERACTIVE;
-
- rl_init_ctx(&rl_ctx);
- //rl_setprompt(&rl_ctx, ">> ");
- rl_sethook_get(&rl_ctx, (getc_hook)kfile_getc, fd);
- rl_sethook_put(&rl_ctx, (putc_hook)kfile_putc, fd);
- rl_sethook_match(&rl_ctx, parser_rl_match, NULL);
- rl_sethook_clear(&rl_ctx, (clear_hook)kfile_clearerr,fd);
-
- parser_init();
-
- protocol_registerCmds();
-
- protocol_prompt(fd);
-}
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
- *
- * -->
- *
- * \brief Implementation of the command protocol between the board and the host
- *
- * \version $Id$
- *
- * \author Marco Benelli <marco@develer.com>
- */
-
-
-#ifndef PROTOCOL_H
-#define PROTOCOL_H
-
-#include <kern/kfile.h>
-
-void protocol_init(KFile *fd);
-void protocol_run(KFile *fd);
-
-#endif // PROTOOCOL_H
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2003, 2004, 2006, 2008 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
- *
- * -->
- *
- * \version $Id$
- *
- * \author Marco Benelli <marco@develer.com>
- * \author Bernie Innocenti <bernie@codewiz.org>
- * \author Daniele Basile <asterix@develer.com>
- *
- * \brief Windowing system test.
- */
-
-
-#include "protocol.h"
-#include "hw/hw_input.h"
-#include "hw/hw_adc.h"
-#include "cfg/cfg_ser.h"
-
-#include <cfg/macros.h>
-
-#include <drv/timer.h>
-#include <drv/buzzer.h>
-#include <drv/ser.h>
-#include <drv/sipo.h>
-
-#include <mware/parser.h>
-#include <net/keytag.h>
-
-
-
-static Serial fd_ser;
-static Serial tag_ser;
-
-int main(void)
-{
- /* SPI Port Initialization */
- sipo_init();
-
- kdbg_init();
- timer_init();
- adc_init();
- buz_init();
-
- IRQ_ENABLE;
- INPUT_INIT;
-
- /* Initialize Tag serial port and data structure */
- TagPacket pkt;
-
- /* Open the main communication port */
- ser_init(&fd_ser, CONFIG_TRIFACE_PORT);
- ser_setbaudrate(&fd_ser, CONFIG_TRIFACE_BAUDRATE);
-
- ser_init(&tag_ser, TAG_SER_PORT);
- ser_setbaudrate(&tag_ser, TAG_SER_BAUDRATE);
-
- keytag_init(&pkt, &fd_ser.fd, &tag_ser.fd);
-
- protocol_init(&fd_ser.fd);
-
- // Main loop
- for(;;)
- {
- protocol_run(&fd_ser.fd);
- keytag_poll(&pkt);
- }
-
- return 0;
-}
-
-
+++ /dev/null
-#
-# $Id$
-# Copyright 2006 Develer S.r.l. (http://www.develer.com/)
-# All rights reserved.
-#
-# Makefile fragment for DevLib triface application.
-#
-# Author: Bernie Innocenti <bernie@codewiz.org>
-#
-#
-
-# Set to 1 for debug builds
-triface_DEBUG = 1
-
-# Our target application
-TRG += triface
-
-triface_hfuse = 0x88
-triface_lfuse = 0xff
-triface_efuse = 0xff
-triface_lock = 0x2f
-triface_CSRC = \
- app/triface/triface.c \
- app/triface/protocol.c \
- app/triface/hw/hw_adc.c \
- bertos/drv/timer.c \
- bertos/drv/ser.c \
- bertos/drv/buzzer.c \
- bertos/cpu/avr/drv/ser_avr.c \
- bertos/cpu/avr/drv/sipo.c \
- bertos/mware/formatwr.c \
- bertos/mware/hex.c \
- bertos/struct/hashtable.c \
- bertos/mware/readline.c \
- bertos/mware/parser.c \
- bertos/mware/event.c \
- bertos/kern/kfile.c \
- bertos/net/keytag.c \
- #
-
-triface_PCSRC += bertos/mware/formatwr.c
-
-
-triface_CFLAGS = -O2 -D'ARCH=(ARCH_TRIFACE)' -fno-strict-aliasing -Iapp/triface -Ibertos/cpu/avr
-triface_LDFLAGS = -Wl
-
-triface_MCU = atmega64
-triface_CROSS = avr-
-
-# Set to 1 for debug builds
-boot_DEBUG = 0
-
-# Our target application
-TRG += boot
-
-boot_MCU = atmega64
-boot_CSRC = \
- app/triface/boot/main.c \
- bertos/net/xmodem.c \
- bertos/drv/ser.c \
- bertos/cpu/avr/drv/ser_avr.c \
- bertos/cpu/avr/drv/flash_avr.c \
- bertos/drv/timer.c \
- bertos/algo/crc.c \
- bertos/mware/hex.c \
- bertos/kern/kfile.c \
- #
-boot_CROSS = avr-
-boot_CPPFLAGS = -D'ARCH=(ARCH_TRIFACE|ARCH_BOOT)' -Iapp/triface/boot -Ibertos/cpu/avr
-boot_CFLAGS = -Os -mcall-prologues
-boot_LDSCRIPT = app/triface/boot/boot.ld
-boot_LDFLAGS = -Wl,--relax
+++ /dev/null
-/**
- * \file
- * <!--
- * This file is part of BeRTOS.
- *
- * Bertos 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 2 of the License, or
- * (at your option) any later version.
- *
- * This program 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, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- *
- * As a special exception, you may use this file as part of a free software
- * library without restriction. Specifically, if other files instantiate
- * templates or use macros or inline functions from this file, or you compile
- * this file and link it with other files to produce an executable, this
- * file does not by itself cause the resulting executable to be covered by
- * the GNU General Public License. This exception does not however
- * invalidate any other reasons why the executable file might be covered by
- * the GNU General Public License.
- *
- * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
- * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
- *
- * -->
- *
- * \version $Id$
- *
- * \author Bernie Innocenti <bernie@codewiz.org>
- *
- * \brief Declare application version strings
- */
-
-#ifndef BERTOS_VERSTAG_H
-#define BERTOS_VERSTAG_H
-
-#ifndef CFG_ARCH_CONFIG_H
- #include "cfg/cfg_arch.h"
-#endif
-
-#define APP_NAME "Triface"
-#define APP_DESCRIPTION "Trinity Interface Board"
-#define APP_AUTHOR "Develer"
-#define APP_COPYRIGHT "Copyright 2006, 2007, 2008, Develer (http://www.develer.com/)"
-
-#define VERS_MAJOR 2
-#define VERS_MINOR 1
-#define VERS_REV 0
-#define VERS_LETTER ""
-
-/**
- * If _SNAPSHOT is defined, \c VERS_TAG contains the build date
- * date instead of a numeric version string.
- */
-//#define _SNAPSHOT
-
-#ifdef _DEBUG
- #define VERS_DBG "D"
-#else
- #define VERS_DBG ""
-#endif
-
-#define __STRINGIZE(x) #x
-#define _STRINGIZE(x) __STRINGIZE(x)
-
-/** Build application version string (i.e.: "1.7.0") */
-#define MAKE_VERS(maj,min,rev) _STRINGIZE(maj) "." _STRINGIZE(min) "." _STRINGIZE(rev) VERS_LETTER VERS_DBG
-#ifdef _SNAPSHOT
- #define VERS_TAG "snapshot" " " __DATE__ " " __TIME__ " " VERS_LETTER " " VERS_DBG
-#else
- #define VERS_TAG MAKE_VERS(VERS_MAJOR,VERS_MINOR,VERS_REV)
-#endif
-
-/** Build application version string suitable for MS windows resource files (i.e.: "1, 7, 0, 1") */
-#define MAKE_RCVERS(maj,min,rev,bld) _STRINGIZE(maj) ", " _STRINGIZE(min) ", " _STRINGIZE(rev) ", " _STRINGIZE(bld)
-#define RCVERSION_TAG MAKE_VERS(VERS_MAJOR,VERS_MINOR,VERS_REV)
-
-/** The revision string (contains VERS_TAG) */
-extern const char vers_tag[];
-
-/** Sequential build number (contains VERS_BUILD) */
-extern const int vers_build_nr;
-//extern const char vers_build_str[];
-
-/** Hostname of the machine used to build this binary (contains VERS_HOST) */
-extern const char vers_host[];
-
-#endif /* BERTOS_VERSTAG_H */
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2007 Develer S.r.l. (http://www.develer.com/)
+ *
+ * -->
+ *
+ * \version $Id$
+ *
+ * \author Francesco Sacchi <batt@develer.com>
+ *
+ * \brief AT91SAM7S-EK porting test.
+ */
+
+#include <cfg/macros.h>
+#include <drv/timer.h>
+#include <drv/sysirq_at91.h>
+#include <kern/proc.h>
+#include <drv/ser.h>
+#include <cfg/macros.h>
+#include <io/arm.h>
+
+Timer leds_timer;
+Serial ser_fd;
+
+static void leds_toggle(void)
+{
+ uint8_t a = (~PIOA_ODSR & 0x0f);
+
+ if (a)
+ {
+ PIOA_SODR = a;
+ PIOA_CODR = a << 1;
+ }
+ else
+ {
+ PIOA_SODR = 0x0f;
+ /* turn first led on */
+ PIOA_CODR = 0x00000001;
+ }
+
+ /* Wait for interval time */
+ timer_setDelay(&leds_timer, ms_to_ticks(100));
+ timer_add(&leds_timer);
+}
+
+
+int main(void)
+{
+ char msg[]="BeRTOS, be fast be beatiful be realtime";
+ kdbg_init();
+ timer_init();
+
+ proc_init();
+ ASSERT(!IRQ_ENABLED());
+
+ /* Open the main communication port */
+ ser_init(&ser_fd, 0);
+ ser_setbaudrate(&ser_fd, 115200);
+ ser_setparity(&ser_fd, SER_PARITY_NONE);
+
+
+ IRQ_ENABLE;
+ ASSERT(IRQ_ENABLED());
+
+ /* Disable all pullups */
+ PIOA_PUDR = 0xffffffff;
+ /* Set PA0..3 connected to PIOA */
+ PIOA_PER = 0x0000001f;
+ /* Set PA0..3 as output */
+ PIOA_OER = 0x0000001f;
+ /* Disable multidrive on all pins */
+ PIOA_MDDR = 0x0000001f;
+
+ /* Set PA0..3 to 1 to turn off leds */
+ PIOA_SODR = 0x0000000f;
+ /* turn first led on */
+ PIOA_CODR = 0x00000001;
+
+ timer_setSoftint(&leds_timer, (Hook)leds_toggle, 0);
+ timer_setDelay(&leds_timer, ms_to_ticks(100));
+ timer_add(&leds_timer);
+
+ ASSERT(proc_testRun() == 0);
+ // Main loop
+ for(;;)
+ {
+ kfile_printf(&ser_fd.fd, "From serial 0: %s\r\n", msg);
+ }
+ return 0;
+}
--- /dev/null
+#
+# $Id: at91sam7s.mk 18234 2007-10-08 13:39:48Z rasky $
+# Copyright 2006 Develer S.r.l. (http://www.develer.com/)
+# All rights reserved.
+#
+# Makefile fragment for DevLib at91sam7s application.
+#
+# Author: Bernie Innocenti <bernie@codewiz.org>
+#
+#
+
+# Set to 1 for debug builds
+at91sam7s_DEBUG = 1
+
+# Our target application
+TRG += at91sam7s
+
+at91sam7s_CSRC = \
+ examples/at91sam7s/at91sam7s.c \
+ bertos/drv/timer.c \
+ bertos/drv/ser.c \
+ bertos/cpu/arm/drv/sysirq_at91.c \
+ bertos/cpu/arm/drv/ser_at91.c \
+ bertos/mware/event.c \
+ bertos/mware/formatwr.c \
+ bertos/mware/hex.c \
+ bertos/kern/kfile.c \
+ bertos/kern/proc.c \
+ bertos/kern/coop.c \
+ bertos/kern/proc_test.c \
+ bertos/kern/monitor.c \
+ bertos/kern/signal.c
+
+at91sam7s_CPPASRC = \
+ bertos/cpu/arm/hw/crtat91sam7_rom.S \
+ bertos/cpu/arm/hw/switch_arm.S
+
+at91sam7s_CROSS = arm-none-eabi-
+
+at91sam7s_CPPAFLAGS = -O0 -g -gdwarf-2 -g -gen-debug
+at91sam7s_CPPFLAGS = -O0 -D'ARCH=0' -D__ARM_AT91SAM7S256__ -g3 -gdwarf-2 -fverbose-asm -Iexamples/at91sam7s/hw -Iexamples/at91sam7s -Ibertos/cpu/arm
+at91sam7s_LDFLAGS = -nostartfiles -T bertos/cpu/arm/scripts/at91sam7_256_ram.ld -Wl,--no-warn-mismatch
+
+at91sam7s_CPU = arm7tdmi
+
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2001, 2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 1999, 2000, 2001, 2008 Bernie Innocenti <bernie@codewiz.org>
+ * -->
+ *
+ * \brief Kernel configuration parameters
+ *
+ * \version $Id$
+ * \author Bernie Innocenti <bernie@codewiz.org>
+ */
+
+#ifndef CFG_KERN_H
+#define CFG_KERN_H
+
+/**
+ * Enable the multithreading kernel.
+ */
+#define CONFIG_KERN 1
+
+/**
+ * \name Optional kernel features
+ * \{
+ */
+#define CONFIG_KERN_SCHED 1 ///< Process schedling
+#define CONFIG_KERN_SIGNALS 1 ///< Inter-process signals
+#define CONFIG_KERN_IRQ 0 ///< Interrupt supervisor
+#define CONFIG_KERN_HEAP 0 ///< Dynamic memory allocation
+#define CONFIG_KERN_SEMAPHORES 1 ///< Re-entrant mutual exclusion primitives
+#define CONFIG_KERN_MONITOR 1 ///< Process monitor
+#define CONFIG_KERN_PREEMPT 0 ///< Preemptive process scheduling
+#define CONFIG_KERN_PRI 0 ///< Priority-based scheduling policy
+/*\}*/
+
+/// [ms] Time sharing quantum (a prime number prevents interference effects)
+#define CONFIG_KERN_QUANTUM 47
+
+/// Module logging level.
+#define KERN_LOG_LEVEL LOG_LVL_ERR
+
+/// Module logging format.
+#define KERN_LOG_FORMAT LOG_FMT_VERBOSE
+
+#endif /* CFG_KERN_H */
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
+ * All Rights Reserved.
+ * -->
+ *
+ * \brief Hardware-specific definitions
+ *
+ * \version $Id$
+ *
+ * \author Bernie Innocenti <bernie@codewiz.org>
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2006/05/18 00:41:47 bernie
+ *#* New triface devlib application.
+ *#*
+ *#*/
+
+#ifndef AT91SAM7SEK_HW_H
+#define AT91SAM7SEK_HW_H
+
+/// CPU Clock frequency (48.023 MHz)
+#define CLOCK_FREQ (48023000UL)
+
+
+/* Timer IRQ strobe */
+//#if CONFIG_TIMER_STROBE
+// #define TIMER_STROBE_ON ATOMIC(PORTD |= BV(PD0))
+// #define TIMER_STROBE_OFF ATOMIC(PORTD &= ~BV(PD0))
+// #define TIMER_STROBE_INIT ATOMIC(PORTD &= ~BV(PD0); DDRD |= BV(PD0))
+//#endif /* CONFIG_TIMER_STROBE */
+
+#endif /* AT91SAM7SEK_HW_H */
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
+ * All Rights Reserved.
+ * -->
+ *
+ * \brief Serial hardware-specific definitions
+ *
+ * \version $Id$
+ *
+ * \author Daniele Basile <asterix@develer.com>
+ */
+
+
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2003, 2004, 2005, 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2001, 2002, 2003 by Bernie Innocenti <bernie@codewiz.org>
+ *
+ * -->
+ *
+ * \version $Id$
+ *
+ * \author Bernie Innocenti <bernie@codewiz.org>
+ *
+ * \brief Declare application version strings
+ */
+#ifndef DEVLIB_VERSTAG_H
+#define DEVLIB_VERSTAG_H
+
+#ifndef ARCH_CONFIG_H
+ #include "cfg/arch_config.h"
+#endif
+
+#define APP_NAME "AT91SAM7S-EK porting test"
+#define APP_DESCRIPTION "AT91SAM7S-EK porting test"
+#define APP_AUTHOR "Develer"
+#define APP_COPYRIGHT "Copyright 2007 Develer (http://www.develer.com/)"
+
+#define VERS_MAJOR 0
+#define VERS_MINOR 1
+#define VERS_REV 0
+#define VERS_LETTER ""
+
+/**
+ * If _SNAPSHOT is defined, \c VERS_TAG contains the build date
+ * date instead of a numeric version string.
+ */
+//#define _SNAPSHOT
+
+#ifdef _DEBUG
+ #define VERS_DBG "D"
+#else
+ #define VERS_DBG ""
+#endif
+
+#define __STRINGIZE(x) #x
+#define _STRINGIZE(x) __STRINGIZE(x)
+
+/** Build application version string (i.e.: "1.7.0") */
+#define MAKE_VERS(maj,min,rev) _STRINGIZE(maj) "." _STRINGIZE(min) "." _STRINGIZE(rev) VERS_LETTER VERS_DBG
+#ifdef _SNAPSHOT
+ #define VERS_TAG "snapshot" " " __DATE__ " " __TIME__ " " VERS_LETTER " " VERS_DBG
+#else
+ #define VERS_TAG MAKE_VERS(VERS_MAJOR,VERS_MINOR,VERS_REV)
+#endif
+
+/** Build application version string suitable for MS windows resource files (i.e.: "1, 7, 0, 1") */
+#define MAKE_RCVERS(maj,min,rev,bld) _STRINGIZE(maj) ", " _STRINGIZE(min) ", " _STRINGIZE(rev) ", " _STRINGIZE(bld)
+#define RCVERSION_TAG MAKE_VERS(VERS_MAJOR,VERS_MINOR,VERS_REV)
+
+/** The revision string (contains VERS_TAG) */
+extern const char vers_tag[];
+
+/** Sequential build number (contains VERS_BUILD) */
+extern const int vers_build_nr;
+//extern const char vers_build_str[];
+
+/** Hostname of the machine used to build this binary (contains VERS_HOST) */
+extern const char vers_host[];
+
+#endif /* DEVLIB_VERSTAG_H */
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2001, 2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 1999, 2000, 2001, 2008 Bernie Innocenti <bernie@codewiz.org>
+ * -->
+ *
+ * \brief Kernel configuration parameters
+ *
+ * \version $Id$
+ * \author Bernie Innocenti <bernie@codewiz.org>
+ */
+
+#ifndef CFG_KERN_H
+#define CFG_KERN_H
+
+/**
+ * Enable the multithreading kernel.
+ */
+#define CONFIG_KERN 1
+
+/**
+ * \name Optional kernel features
+ * \{
+ */
+#define CONFIG_KERN_SCHED 1 ///< Process schedling
+#define CONFIG_KERN_SIGNALS 1 ///< Inter-process signals
+#define CONFIG_KERN_IRQ 1 ///< Interrupt supervisor
+#define CONFIG_KERN_HEAP 0 ///< Dynamic memory allocation
+#define CONFIG_KERN_SEMAPHORES 0 ///< Re-entrant mutual exclusion primitives
+#define CONFIG_KERN_MONITOR 1 ///< Process monitor
+#define CONFIG_KERN_PREEMPT 1 ///< Preemptive process scheduling
+#define CONFIG_KERN_PRI 1 ///< Priority-based scheduling policy
+/*\}*/
+
+/// [ms] Time sharing quantum (a prime number prevents interference effects)
+#define CONFIG_KERN_QUANTUM 47
+
+/// Module logging level.
+#define KERN_LOG_LEVEL LOG_LVL_ERR
+
+/// Module logging format.
+#define KERN_LOG_FORMAT LOG_FMT_VERBOSE
+
+#endif /* CFG_KERN_H */
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2006, 2008 Develer S.r.l. (http://www.develer.com/)
+ * -->
+ *
+ * \brief Multifunction system test for BeRTOS modules.
+ *
+ * \version $Id: demo.c 18242 2007-10-08 17:35:23Z marco $
+ * \author Bernie Innocenti <bernie@codewiz.org>
+ */
+
+#include <cfg/macros.h>
+
+#include <emul/emul.h>
+
+#include <kern/irq.h>
+#include <kern/proc.h>
+#include <kern/monitor.h>
+#include <kern/msg.h>
+
+#include <drv/timer.h>
+#include <drv/buzzer.h>
+#include <drv/lcd_gfx.h>
+#include <drv/kbd.h>
+
+#include <gfx/gfx.h>
+#include <gfx/win.h>
+#include <gfx/text.h>
+#include <gfx/font.h>
+
+#include <gui/menu.h>
+#include <icons/logo.h>
+
+/**
+ * Draw a pentacle in the provided bitmap.
+ *
+ * This is invoked by the keyboard polling routine, as a poor man's surrogate
+ * of true task switching.
+ */
+void schedule(void)
+{
+ lcd_blitBitmap(&lcd_bitmap);
+ emul_idle();
+}
+
+/**
+ * Draw a pentacle in the provided bitmap.
+ */
+static void magic(struct Bitmap *bitmap, coord_t x, coord_t y)
+{
+ static const coord_t coords[] = { 120, 34, 90, 90, 30, 90, 0, 34, 60, 0, 90, 90, 0, 34, 120, 34, 30, 90, 60, 0 };
+ unsigned int i;
+
+ gfx_moveTo(bitmap, coords[countof(coords)-2]/2 + x, coords[countof(coords)-1]/3 + y);
+ for (i = 0; i < countof(coords); i += 2)
+ gfx_lineTo(bitmap, coords[i]/2 + x, coords[i+1]/3 + y);
+}
+
+static void hello_world(Bitmap *bm)
+{
+ extern const Font font_ncenB18;
+ const Font *old_font = bm->font;
+
+ gfx_bitmapClear(bm);
+
+ /* Set big font */
+ gfx_setFont(bm, &font_ncenB18);
+
+ text_xprintf(bm, 1, 0, STYLEF_BOLD | TEXT_FILL | TEXT_CENTER,
+ "Hello, world!");
+
+ lcd_blitBitmap(bm);
+ timer_delay(1000);
+
+ /* Restore old font */
+ gfx_setFont(bm, old_font);
+}
+
+/**
+ * Show the splash screen
+ */
+static void bouncing_logo(Bitmap *bm)
+{
+ const long SPEED_SCALE = 1000;
+ const long GRAVITY_ACCEL = 10;
+ const long BOUNCE_ELASTICITY = 2;
+ long h = (long)(-bertos_logo.height) * SPEED_SCALE;
+ long speed = 1000;
+
+ /* Repeat until logo stands still on the bottom edge */
+ while (!((speed == 0) && (h == 0)))
+ {
+ /* Move */
+ h += speed;
+
+ /* Gravity acceleration */
+ speed += GRAVITY_ACCEL;
+
+ if (h > 0 && speed > 0)
+ {
+ /* Bounce */
+ speed = - (speed / BOUNCE_ELASTICITY);
+
+ }
+
+ /* Update graphics */
+ gfx_bitmapClear(bm);
+ gfx_blitImage(bm,
+ (bm->width - bertos_logo.width) / 2,
+ h / SPEED_SCALE,
+ &bertos_logo);
+ lcd_blitBitmap(bm);
+
+ timer_delay(10);
+ }
+}
+
+void win_demo(Bitmap *bm)
+{
+ const coord_t small_left = 45, small_top = 30, small_width = 50, small_height = 30;
+ const coord_t large_left = -10, large_top = 10, large_width = 85, large_height = 41;
+
+ Window root_win, small_win, large_win;
+ Bitmap small_bm, large_bm;
+ uint8_t small_raster[RAST_SIZE(small_width, small_height)];
+ uint8_t large_raster[RAST_SIZE(large_width, large_height)];
+
+ win_create(&root_win, bm);
+
+ gfx_bitmapInit(&large_bm, large_raster, large_width, large_height);
+ win_create(&large_win, &large_bm);
+ win_open(&large_win, &root_win);
+ win_move(&large_win, large_left, large_top);
+
+ gfx_bitmapInit(&small_bm, small_raster, small_width, small_height);
+ win_create(&small_win, &small_bm);
+ win_open(&small_win, &root_win);
+ win_move(&small_win, small_left, small_top);
+
+
+ coord_t x = 0, y = LCD_WIDTH / 2;
+ coord_t xdir = +1, ydir = -1;
+ coord_t xdir_large = +1;
+ coord_t ydir_small = +1;
+ int raise_counter = 0;
+ int i;
+
+ for(;;)
+ {
+ /* Background animation */
+ bm = root_win.bitmap;
+ gfx_bitmapClear(bm);
+// gfx_setClipRect(bm, 0, 0, bm->width, bm->height);
+// gfx_rectDraw(bm, 10, 10, bm->width-10, bm->height-10);
+// gfx_setClipRect(bm, 11, 11, bm->width-11, bm->height-11);
+ magic(bm, x, y);
+ x += xdir;
+ y += ydir;
+ if (x >= bm->width) xdir = -1;
+ if (x <= -50) xdir = +1;
+ if (y >= bm->height) ydir = -1;
+ if (y <= -50) ydir = +1;
+
+ /* Large window animation */
+ bm = large_win.bitmap;
+ gfx_bitmapClear(bm);
+ for (i = 0; i < bm->height / 2; i += 2)
+ gfx_rectDraw(bm, 0 + i, 0 + i, bm->width - i, bm->height - i);
+
+
+ /* Small window animation */
+ bm = small_win.bitmap;
+ gfx_bitmapClear(bm);
+ gfx_rectDraw(bm, 0, 0, bm->width, bm->height);
+ gfx_line(bm, 0, 0, bm->width, bm->height);
+ gfx_line(bm, bm->width, 0, 0, bm->height);
+
+ /* Move windows around */
+ win_move(&large_win, large_win.geom.xmin + xdir_large, large_top);
+ if (large_win.geom.xmin < -20) xdir_large = +1;
+ if (large_win.geom.xmin > RECT_WIDTH(&root_win.geom) - 5) xdir_large = -1;
+
+ win_move(&small_win, small_left, small_win.geom.ymin + ydir_small);
+ if (small_win.geom.ymin < -20) ydir_small = +1;
+ if (small_win.geom.ymin > RECT_HEIGHT(&root_win.geom) - 5) ydir_small = -1;
+
+ ++raise_counter;
+ if (raise_counter % 997 == 0)
+ win_raise(&small_win);
+ else if (raise_counter % 731 == 0)
+ win_raise(&large_win);
+
+ win_compose(&root_win);
+
+ /* Also does LCD refresh, etc. */
+ if (kbd_peek())
+ break;
+ }
+}
+
+void proc_demo(void)
+{
+ proc_testRun();
+}
+
+void timer_demo(void)
+{
+ timer_testRun();
+ timer_testTearDown();
+}
+
+
+/* SETTINGS SUBMENU */
+
+static struct MenuItem settings_items[] =
+{
+ { (const_iptr_t)"System", 0, (MenuHook)0, (iptr_t)0 },
+ { (const_iptr_t)"Language", 0, (MenuHook)0, (iptr_t)0 },
+ { (const_iptr_t)"Networking", 0, (MenuHook)0, (iptr_t)0 },
+ { (const_iptr_t)"Date & Time",0, (MenuHook)0, (iptr_t)0 },
+ { (const_iptr_t)"Power Saving", MIF_TOGGLE, (MenuHook)0, (iptr_t)0 },
+ { (const_iptr_t)0, 0, NULL, (iptr_t)0 }
+};
+static struct Menu settings_menu = { settings_items, "Settings Menu", MF_STICKY | MF_SAVESEL, &lcd_bitmap, 0 };
+
+
+/* MX SUBMENU */
+
+static struct MenuItem mx_items[] =
+{
+ { (const_iptr_t)"Mouse", MIF_CHECKIT | MIF_EXCLUDE_1 | MIF_EXCLUDE_2, (MenuHook)0, (iptr_t)0 },
+ { (const_iptr_t)"Keyboard", MIF_CHECKED | MIF_CHECKIT | MIF_EXCLUDE_0 | MIF_EXCLUDE_2, (MenuHook)0, (iptr_t)0 },
+ { (const_iptr_t)"Joystick", MIF_CHECKIT | MIF_EXCLUDE_0 | MIF_EXCLUDE_1, (MenuHook)0, (iptr_t)0 },
+ { (const_iptr_t)"Autosave", MIF_CHECKED | MIF_CHECKIT | MIF_TOGGLE, (MenuHook)0, (iptr_t)0 },
+ { (const_iptr_t)0, 0, NULL, (iptr_t)0 }
+};
+
+static struct Menu mx_menu = { mx_items, (const_iptr_t)0, MF_STICKY | MF_SAVESEL, &lcd_bitmap, 0 };
+
+
+/* DISPLAY SUBMENU */
+
+static struct MenuItem display_items[] =
+{
+ { (const_iptr_t)"Background", 0, (MenuHook)0, (iptr_t)0 },
+ { (const_iptr_t)"Colors", 0, (MenuHook)0, (iptr_t)0 },
+ { (const_iptr_t)"Style", 0, (MenuHook)0, (iptr_t)0 },
+ { (const_iptr_t)"Icon Theme", 0, (MenuHook)0, (iptr_t)0 },
+ { (const_iptr_t)0, 0, NULL, (iptr_t)0 }
+};
+static struct Menu display_menu = { display_items, "Display Menu", MF_SAVESEL, &lcd_bitmap, 0 };
+
+
+/* MAIN MENU */
+
+static struct MenuItem main_items[] =
+{
+ { (const_iptr_t)"Win Fly", 0, (MenuHook)win_demo, (iptr_t)&lcd_bitmap },
+ { (const_iptr_t)"Bounce!", 0, (MenuHook)bouncing_logo,(iptr_t)&lcd_bitmap },
+ { (const_iptr_t)"Hello World", 0, (MenuHook)hello_world, (iptr_t)&lcd_bitmap },
+ { (const_iptr_t)"Scheduling", 0, (MenuHook)proc_demo, (iptr_t)&lcd_bitmap },
+ { (const_iptr_t)"Timer Test", 0, (MenuHook)timer_demo, (iptr_t)&lcd_bitmap },
+ { (const_iptr_t)"Menu MX", 0, (MenuHook)menu_handle, (iptr_t)&mx_menu },
+ { (const_iptr_t)"Display", 0, (MenuHook)menu_handle, (iptr_t)&display_menu },
+ { (const_iptr_t)"Settings", 0, (MenuHook)menu_handle, (iptr_t)&settings_menu },
+ { (const_iptr_t)0, 0, NULL, (iptr_t)0 }
+};
+static struct Menu main_menu = { main_items, "Main Menu", MF_STICKY, &lcd_bitmap, 0 };
+
+
+static cpu_stack_t monitor_stack[CONFIG_KERN_MINSTACKSIZE / sizeof(cpu_stack_t)];
+
+int main(int argc, char *argv[])
+{
+ emul_init(&argc, argv);
+ irq_init();
+ timer_init();
+ buz_init();
+ kbd_init();
+ lcd_init();
+ proc_init();
+ monitor_start(sizeof(monitor_stack), monitor_stack);
+
+ menu_handle(&main_menu);
+
+ timer_cleanup();
+ emul_cleanup();
+ return 0;
+}
--- /dev/null
+#
+# Copyright 2003, 2004, 2005, 2006 Develer S.r.l. (http://www.develer.com/)
+# Copyright 2008 Bernie Innocenti <bernie@codewiz.org>
+#
+# Makefile fragment for DevLib demo application.
+#
+# Version: $Id: demo.mk 18234 2007-10-08 13:39:48Z rasky $
+# Author: Bernie Innocenti <bernie@codewiz.org>
+#
+
+include bertos/fonts/fonts.mk
+include bertos/emul/emul.mk
+
+# Set to 1 for debug builds
+demo_DEBUG = 1
+
+# Our target application
+TRG += demo
+
+# FIXME: we want to use g++ for C source too
+CC = g++
+CXX = g++
+
+demo_CXXSRC = \
+ bertos/emul/emul.cpp \
+ bertos/emul/emulwin.cpp \
+ bertos/emul/emulkbd.cpp \
+ bertos/drv/lcd_gfx_qt.cpp
+
+demo_CSRC = \
+ examples/demo/demo.c \
+ bertos/os/hptime.c \
+ bertos/gfx/bitmap.c \
+ bertos/gfx/line.c \
+ bertos/gfx/win.c \
+ bertos/gfx/text.c \
+ bertos/gfx/text_format.c \
+ bertos/gui/menu.c \
+ bertos/fonts/helvB10.c \
+ bertos/fonts/luBS14.c \
+ bertos/fonts/ncenB18.c \
+ bertos/icons/logo.c \
+ bertos/drv/kbd.c \
+ bertos/drv/timer.c \
+ bertos/drv/timer_test.c \
+ bertos/drv/buzzer.c \
+ bertos/drv/ser.c \
+ bertos/emul/ser_posix.c \
+ bertos/mware/formatwr.c \
+ bertos/mware/hex.c \
+ bertos/mware/event.c \
+ bertos/mware/observer.c \
+ bertos/mware/resource.c \
+ bertos/mware/sprintf.c \
+ bertos/kern/idle.c \
+ bertos/kern/irq.c \
+ bertos/kern/preempt.c \
+ bertos/kern/proc.c \
+ bertos/kern/proc_test.c \
+ bertos/kern/sem.c \
+ bertos/kern/signal.c \
+ bertos/kern/monitor.c \
+ bertos/verstag.c
+
+demo_CPPASRC = \
+ bertos/emul/switch.S
+
+# FIXME: maybe this junk should go in emul/emul.mk?
+$(OBJDIR)/demo/bertos/emul/emulwin.o: bertos/emul/emulwin_moc.cpp
+$(OBJDIR)/demo/bertos/drv/lcd_gfx_qt.o: bertos/drv/lcd_gfx_qt_moc.cpp
+$(OBJDIR)/demo/bertos/drv/timer.o: bertos/emul/timer_qt_moc.cpp
+$(OBJDIR)/demo/bertos/emul/emulkbd.o: bertos/emul/emulkbd_moc.cpp
+
+#FIXME: isn't there a way to avoid repeating the pattern rule?
+bertos/emul/timer_qt_moc.cpp: bertos/emul/timer_qt.c
+ $(QT_MOC) -o $@ $<
+
+
+demo_CFLAGS = -Iexamples/demo $(EMUL_CFLAGS)
+demo_CXXFLAGS = -Iexamples/demo $(EMUL_CFLAGS)
+demo_LDFLAGS = $(EMUL_LDFLAGS)
+
+# Debug stuff
+ifeq ($(demo_DEBUG),0)
+ demo_CFLAGS += -Os
+ demo_CXXFLAGS += -Os
+endif
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2003, 2004, 2005, 2006, 2008 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000 Bernie Innocenti
+ * All Rights Reserved.
+ * -->
+ *
+ * \brief Keyboard map definitions.
+ *
+ * \version $Id$
+ *
+ * \author Francesco Sacchi <batt@develer.com>
+ * \author Stefano Fedrigo <a@develer.com>
+ */
+
+#ifndef HW_KBD_MAP_H
+#define HW_KBD_MAP_H
+
+#include <cfg/macros.h>
+
+
+/**
+ * Type for keyboard mask.
+ */
+typedef uint16_t keymask_t;
+
+/**
+ * \name Keycodes.
+ */
+/*@{*/
+#define K_UP BV(0)
+#define K_DOWN BV(1)
+#define K_OK BV(2)
+#define K_CANCEL BV(3)
+
+#define K_REPEAT BV(14) /**< This is a repeated keyevent. */
+#define K_TIMEOUT BV(15) /**< Fake key event for timeouts. */
+/*@}*/
+
+
+#endif /* HW_KBD_MAP_H */
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2003, 2004, 2005, 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2001, 2002, 2003 by Bernie Innocenti <bernie@codewiz.org>
+ *
+ * -->
+ *
+ * \version $Id: verstag.h 18242 2007-10-08 17:35:23Z marco $
+ *
+ * \author Bernie Innocenti <bernie@codewiz.org>
+ *
+ * \brief Declare application version strings
+ */
+
+#ifndef BERTOS_VERSTAG_H
+#define BERTOS_VERSTAG_H
+
+#ifndef CFG_ARCH_CONFIG_H
+ #include "cfg/cfg_arch.h"
+#endif
+
+#define APP_NAME "BeRTOS Demo"
+#define APP_DESCRIPTION "BeRTOS Multidemo Application"
+#define APP_AUTHOR "Develer"
+#define APP_COPYRIGHT "Copyright 2006 Develer (http://www.develer.com/)"
+
+#define VERS_MAJOR 0
+#define VERS_MINOR 1
+#define VERS_REV 0
+#define VERS_LETTER ""
+
+/**
+ * If _SNAPSHOT is defined, \c VERS_TAG contains the build date
+ * date instead of a numeric version string.
+ */
+#define _SNAPSHOT
+
+#ifdef _DEBUG
+ #define VERS_DBG "D"
+#else
+ #define VERS_DBG ""
+#endif
+
+#define __STRINGIZE(x) #x
+#define _STRINGIZE(x) __STRINGIZE(x)
+
+/** Build application version string (i.e.: "1.7.0") */
+#define MAKE_VERS(maj,min,rev) _STRINGIZE(maj) "." _STRINGIZE(min) "." _STRINGIZE(rev) VERS_LETTER VERS_DBG
+#ifdef _SNAPSHOT
+ #define VERS_TAG "snapshot" " " __DATE__ " " __TIME__ " " VERS_LETTER " " VERS_DBG
+#else
+ #define VERS_TAG MAKE_VERS(VERS_MAJOR,VERS_MINOR,VERS_REV)
+#endif
+
+/** Build application version string suitable for MS windows resource files (i.e.: "1, 7, 0, 1") */
+#define MAKE_RCVERS(maj,min,rev,bld) _STRINGIZE(maj) ", " _STRINGIZE(min) ", " _STRINGIZE(rev) ", " _STRINGIZE(bld)
+#define RCVERSION_TAG MAKE_VERS(VERS_MAJOR,VERS_MINOR,VERS_REV)
+
+/** The revision string (contains VERS_TAG) */
+extern const char vers_tag[];
+
+/** Sequential build number (contains VERS_BUILD) */
+extern const int vers_build_nr;
+//extern const char vers_build_str[];
+
+/** Hostname of the machine used to build this binary (contains VERS_HOST) */
+extern const char vers_host[];
+
+#endif /* BERTOS_VERSTAG_H */
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2006, 2008 Develer S.r.l. (http://www.develer.com/)
+ * All Rights Reserved.
+ * -->
+ *
+ * \brief Hardware-specific definitions
+ *
+ * \version $Id$
+ *
+ * \author Bernie Innocenti <bernie@codewiz.org>
+ */
+
+#ifndef HW_CPU_H
+#define HW_CPU_H
+
+#warning TODO:This is an example implementation, you must implement it!
+
+/// CPU Clock frequency
+#define CLOCK_FREQ (48023000L/* Implement me! */)
+
+
+/* Timer IRQ strobe */
+//#if CONFIG_TIMER_STROBE
+// #define TIMER_STROBE_ON /* Implement me! */
+// #define TIMER_STROBE_OFF /* Implement me! */
+// #define TIMER_STROBE_INIT /* Implement me! */
+//#endif /* CONFIG_TIMER_STROBE */
+
+#endif /* HW_CPU_H */
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2007 Develer S.r.l. (http://www.develer.com/)
+ *
+ * -->
+ *
+ * \version $Id$
+ *
+ * \author Manuele Fanelli <qwert@develer.com>
+ *
+ * \brief LM3S168 porting test.
+ */
+
+#include "bertos/cpu/detect.h"
+
+int main (void)
+{
+ int c;
+
+ for (;;)
+ c++;
+ return 0;
+}
--- /dev/null
+#
+# $Id: lm3s1968.mk 18234 2007-10-08 13:39:48Z rasky $
+# Copyright 2006 Develer S.r.l. (http://www.develer.com/)
+# All rights reserved.
+#
+# Makefile fragment for DevLib lm3s1968 application.
+#
+# Author: Manuele Fanelli <qwert@develer.com>
+#
+#
+
+# Set to 1 for debug builds
+lm3s1968_DEBUG = 0
+
+
+# Our target application
+TRG += lm3s1968
+
+lm3s1968_CSRC = \
+ examples/lm3s1968/lm3s1968.c \
+ #bertos/cpu/cortex-m3/startup_lm3s.c
+
+
+lm3s1968_CROSS = arm-none-eabi-
+
+lm3s1968_CPPAFLAGS = -O0 -g -gdwarf-2 -g -gen-debug -mthumb
+lm3s1968_CPPFLAGS = -O0 -D'ARCH=0' -D__ARM_LM3S1968__ -g3 -gdwarf-2 -fverbose-asm -mthumb -Iexamples/lm3s1968 -Ibertos/cpu/cortex-m3
+lm3s1968_LDFLAGS = -nostartfiles -T examples/lm3s1968/standalone.ld -Wl,--no-warn-mismatch
+
+lm3s1968_CPU = cortex-m3
+
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
+ *
+ * -->
+ *
+ * \brief DevLib configuration options
+ *
+ * You should copy this header in your project and rename it to
+ * "config.h" and delete the CONFIG_ macros for the modules
+ * you're not using.
+ *
+ * <h2>Working with multiple applications</h2>
+ *
+ * If your project is made of multiple DevLib-based applications,
+ * create a custom "config.h" file in each application subdirectory
+ * and play with the compiler include path to get the desired result.
+ * You can share common options by creationg a "config_common.h" header
+ * and including it from all your "config.h" copies.
+ *
+ * <h2>Configuration style</h2>
+ *
+ * For improved compile-time checking of configuration options,
+ * the preferred way to use a \c CONFIG_ symbol is keeping it
+ * always defined with a value of either 0 or 1. This lets
+ * you write tests like this:
+ *
+ * \code
+ * #if CONFIG_FOO
+ * void foo(void)
+ * {
+ * if (CONFIG_BAR)
+ * bar();
+ * }
+ * #endif // CONFIG_FOO
+ * \endcode
+ *
+ * In most cases, we rely on the optimizer to discard checks
+ * on constant values and performing dead-code elimination.
+ *
+ * \version $Id$
+ * \author Bernie Innocenti <bernie@codewiz.org>
+ * \author Stefano Fedrigo <aleph@develer.com>
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2007/02/15 18:17:51 asterix
+ *#* Add randpool test program.
+ *#*
+ *#* Revision 1.16 2007/02/12 15:29:41 asterix
+ *#* Add CONFIG_RANDPOOL_TIMER macro to swich on or off timer support in randpool.
+ *#*
+ *#* Revision 1.15 2007/02/08 14:20:35 asterix
+ *#* Add CONFIG_SIZE_ENTROPY_POOL.
+ *#*
+ *#* Revision 1.14 2007/02/06 11:37:26 asterix
+ *#* Add CONFIG_MD2_STD_PERM for use standard permutation in MD2.
+ *#*
+ *#* Revision 1.13 2007/01/31 13:49:40 asterix
+ *#* Add config size block for MD2
+ *#*
+ *#* Revision 1.3 2006/09/13 18:29:22 bernie
+ *#* Add a few missing CONFIG_ definitions.
+ *#*
+ *#* Revision 1.2 2006/07/19 12:56:24 bernie
+ *#* Convert to new Doxygen style.
+ *#*
+ *#* Revision 1.1 2006/05/18 00:40:43 bernie
+ *#* Rename appconfig.h to appconfig_common.h.
+ *#*
+ *#* Revision 1.11 2006/04/11 00:08:53 bernie
+ *#* Add smooth scrolling for menus.
+ *#*
+ *#* Revision 1.10 2006/03/22 09:48:51 bernie
+ *#* Add a few more config options.
+ *#*
+ *#* Revision 1.9 2006/02/24 00:27:35 bernie
+ *#* Enable kernel and fix Doxygen markup.
+ *#*
+ *#* Revision 1.8 2006/02/21 16:06:05 bernie
+ *#* Update copyright info.
+ *#*
+ *#* Revision 1.7 2006/02/17 22:28:19 bernie
+ *#* Add missing UART definitions.
+ *#*
+ *#* Revision 1.6 2006/02/15 09:12:56 bernie
+ *#* Switch to BITMAP_FMT_PLANAR_V_LSB.
+ *#*
+ *#* Revision 1.5 2006/02/10 12:34:33 bernie
+ *#* Add missing config options for gfx and kbd.
+ *#*
+ *#* Revision 1.4 2006/01/23 23:12:27 bernie
+ *#* Enable CONFIG_GFX_VCOORDS.
+ *#*
+ *#* Revision 1.3 2006/01/17 02:30:06 bernie
+ *#* Add new config vars.
+ *#*
+ *#* Revision 1.2 2005/11/27 03:04:57 bernie
+ *#* CONFIG_WATCHDOG: New config option.
+ *#*
+ *#* Revision 1.1 2005/11/04 17:42:12 bernie
+ *#* Move cfg/config.h to appconfig.h.
+ *#*/
+
+#ifndef APPCONFIG_H
+#define APPCONFIG_H
+
+/** Baud-rate for the kdebug console */
+#define CONFIG_KDEBUG_BAUDRATE 19200
+
+/**
+ * printf()-style formatter configuration.
+ *
+ * \sa PRINTF_DISABLED
+ * \sa PRINTF_NOMODIFIERS
+ * \sa PRINTF_REDUCED
+ * \sa PRINTF_NOFLOAT
+ * \sa PRINTF_FULL
+ */
+#define CONFIG_PRINTF PRINTF_FULL
+
+/**
+ * Multithreading kernel.
+ *
+ * \sa config_kern.h
+ */
+#define CONFIG_KERN 0
+
+/**
+ * \name Serial driver parameters
+ * \{
+ */
+ /** [bytes] Size of the outbound FIFO buffer for port 0. */
+ #define CONFIG_UART0_TXBUFSIZE 32
+
+ /** [bytes] Size of the inbound FIFO buffer for port 0. */
+ #define CONFIG_UART0_RXBUFSIZE 64
+
+ /** [bytes] Size of the outbound FIFO buffer for port 1. */
+ #define CONFIG_UART1_TXBUFSIZE 32
+
+ /** [bytes] Size of the inbound FIFO buffer for port 1. */
+ #define CONFIG_UART1_RXBUFSIZE 64
+
+ /** [bytes] Size of the outbound FIFO buffer for SPI port (AVR only). */
+ #define CONFIG_SPI_TXBUFSIZE 16
+
+ /** [bytes] Size of the inbound FIFO buffer for SPI port (AVR only). */
+ #define CONFIG_SPI_RXBUFSIZE 32
+
+ /** SPI data order (AVR only). */
+ #define CONFIG_SPI_DATA_ORDER SER_MSB_FIRST
+
+ /** SPI clock division factor (AVR only). */
+ #define CONFIG_SPI_CLOCK_DIV 16
+
+ /** SPI clock polarity: 0 = normal low, 1 = normal high (AVR only). */
+ #define CONFIG_SPI_CLOCK_POL 0
+
+ /** SPI clock phase: 0 = sample on first edge, 1 = sample on second clock edge (AVR only). */
+ #define CONFIG_SPI_CLOCK_PHASE 0
+
+ /** Default transmit timeout (ms). Set to -1 to disable timeout support */
+ #define CONFIG_SER_TXTIMEOUT -1
+
+ /** Default receive timeout (ms). Set to -1 to disable timeout support */
+ #define CONFIG_SER_RXTIMEOUT -1
+
+ /** Use RTS/CTS handshake */
+ #define CONFIG_SER_HWHANDSHAKE 0
+
+ /** Default baud rate (set to 0 to disable) */
+ #define CONFIG_SER_DEFBAUDRATE 0
+
+ /** Enable ser_gets() and ser_gets_echo() */
+ #define CONFIG_SER_GETS 0
+
+ /** Enable second serial port in emulator. */
+ #define CONFIG_EMUL_UART1 0
+
+ /**
+ * Transmit always something on serial port 0 TX
+ * to avoid interference when sending burst of data,
+ * using AVR multiprocessor serial mode
+ */
+ #define CONFIG_SER_TXFILL 0
+
+ #define CONFIG_SER_STROBE 0
+/*\}*/
+
+/// Hardware timer selection for drv/timer.c
+#define CONFIG_TIMER TIMER_ON_OUTPUT_COMPARE2
+
+/// Debug timer interrupt using a strobe pin.
+#define CONFIG_TIMER_STROBE 0
+
+/// Enable ADS strobe.
+#define CONFIG_ADC_STROBE 0
+
+/// Enable watchdog timer.
+#define CONFIG_WATCHDOG 0
+
+/// EEPROM type for drv/eeprom.c
+#define CONFIG_EEPROM_TYPE EEPROM_24XX256
+
+/// Select bitmap pixel format.
+#define CONFIG_BITMAP_FMT BITMAP_FMT_PLANAR_V_LSB
+
+/// Enable line clipping algorithm.
+#define CONFIG_GFX_CLIPPING 1
+
+/// Enable text rendering in bitmaps.
+#define CONFIG_GFX_TEXT 1
+
+/// Enable virtual coordinate system.
+#define CONFIG_GFX_VCOORDS 1
+
+/// Keyboard polling method
+#define CONFIG_KBD_POLL KBD_POLL_SOFTINT
+
+/// Enable keyboard event delivery to observers
+#define CONFIG_KBD_OBSERVER 0
+
+/// Enable key beeps
+#define CONFIG_KBD_BEEP 1
+
+/// Enable long pression handler for keys
+#define CONFIG_KBD_LONGPRESS 1
+
+/**
+ * \name Type for the chart dataset
+ * \{
+ */
+#define CONFIG_CHART_TYPE_X uint8_t
+#define CONFIG_CHART_TYPE_Y uint8_t
+/*\}*/
+
+/// Enable button bar behind menus
+#define CONFIG_MENU_MENUBAR 0
+
+/// Enable smooth scrolling in menus
+#define CONFIG_MENU_SMOOTH 1
+
+/// Size of block for MD2 algorithm.
+#define CONFIG_MD2_BLOCK_LEN 16
+
+/// Use standard permutation in MD2 algorithm.
+#define CONFIG_MD2_STD_PERM 0
+
+/// Define a size, in byte, of entropy pool.
+#define CONFIG_SIZE_ENTROPY_POOL 256
+
+/// Turn on or off timer support in Randpool.
+#define CONFIG_RANDPOOL_TIMER 1
+
+#endif /* APPCONFIG_H */
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2007 Develer S.r.l. (http://www.develer.com/)
+ *
+ * -->
+ *
+ * \brief Test function for randpool API.
+ *
+ * This program return a rand number generate from randpool function.
+ * For use randpool function you need a souce of entropy. In this
+ * program you can choose from:
+ * - /dev/random
+ * - /dev/urandom
+ * - /dev/input/mouse0
+ *
+ * There are 3 mode of output:
+ * - binmode: program generate a sequenze of random byte.
+ * - Matrix of random number for octave program.
+ * - Vector of random number for octave program.
+ *
+ * \version $Id$
+ * \author Daniele Basile <asterix@develer.com>
+ */
+
+/*#*
+ *#* $Log$
+ *#* Revision 1.1 2007/02/15 18:17:51 asterix
+ *#* Add randpool test program.
+ *#*
+ *#*/
+
+#include <stdlib.h>
+#include <stdio.h>
+#include <string.h>
+#include <cfg/compiler.h>
+#include <drv/timer.h>
+#include <algo/md2.h>
+#include <algo/randpool.h>
+#include <unistd.h>
+
+#define LEN 256 //Size of buffer containing a random number.
+#define SAMPLE 1000 //Defoult number of byte that put in entropy pool.
+
+int main (int argc, char *argv[])
+{
+ EntropyPool pool;
+ uint8_t ch;
+ uint8_t buff[LEN];
+ FILE *pdev;
+ int opt = getopt (argc, argv, "murh");
+ int samp = SAMPLE;
+ int round = 10;
+ int mode = 0;
+ int pass = 0;
+
+ timer_init();
+
+ randpool_init(&pool, NULL, 0); //Init a entropy pool.
+
+ /*
+ * Chose a source of entropy.
+ */
+ switch(opt)
+ {
+ case 'm':
+ {
+ pdev = fopen("/dev/input/mouse0", "r");
+ break;
+ }
+ case 'u':
+ {
+ pdev = fopen("/dev/urandom", "r");
+ break;
+ }
+ case 'r':
+ {
+ pdev = fopen("/dev/random", "r");
+ break;
+ }
+ case 'h':
+ {
+ }
+ default:
+ {
+ printf("\n");
+ printf("\n");
+ printf("randpool_demo [OPTION] [SAMPLE] [ROUND] [MODE]\n");
+ printf("\n");
+ printf("OPTION:\n");
+ printf(" -r /dev/random\n");
+ printf(" -u /dev/urandom\n");
+ printf(" -m /dev/input/mouse0\n");
+ printf("\n");
+ printf("SAMPLE:\n");
+ printf(" num number of entropy byte to put in etropy pool.\n");
+ printf("\n");
+ printf("ROUND:\n");
+ printf(" num number call of randpool_get function.\n");
+ printf("\n");
+ printf("MODE:\n");
+ printf(" 0 binmode\n");
+ printf(" 1 vector mode\n");
+ printf(" 2 matrix mode\n");
+ printf("\n");
+ printf("Test program of randpool API.\n");
+ printf("This program create an entropy pool of 256byte, and fill it\n");
+ printf("with entropy from a exsternal source. This source can be:\n");
+ printf(" - /dev/random (option: -r)\n");
+ printf(" - /dev/urandom (option: -u)\n");
+ printf(" - /dev/input/mouse0 (option: -m)\n");
+ printf("\n");
+ printf("Once the pool is full, program call a randpool_get ROUND time,\n");
+ printf("printing on STDOUT random value, in accord with a select mode.\n");
+ printf("The mode are:\n");
+ printf(" - binmode: program print on STDOUT random byte. (option: 0 (defaul mode)\n");
+ printf(" - vector mode: program print on STDOUT a ROUND vector of random value.\n");
+ printf(" The output is format for octave program. (option: 1)\n");
+ printf(" - matrix mode: program print on STDOUT a matrix of random value.\n");
+ printf(" The output is format for octave program. (option: 2)\n");
+ printf("\n");
+ exit(1);
+ }
+
+ }
+
+ /*
+ *
+ */
+ if(argc > 2)
+ {
+ if(argv[2])
+ samp = atoi(argv[2]); //Number of byte take from entropy source
+ if(argv[3])
+ round = atoi(argv[3]); //Number of time we call randpool_get.
+ if(argv[4])
+ {
+ switch(atoi(argv[4]))
+ {
+ case 1:
+ {
+ mode = 1;
+ printf("# Created by Asterix.\n");
+ printf("# name: __nargin__\n");
+ printf("# type: scalar\n");
+ printf("0\n");
+ break;
+ }
+ case 2:
+ {
+ mode = 2;
+ printf("# Created by Asterix.\n");
+ printf("# name: __nargin__\n");
+ printf("# type: scalar\n");
+ printf("0\n");
+ break;
+ }
+ default:
+ {
+ break;
+ }
+
+ }
+
+ }
+
+ }
+
+ /*
+ * Add byte to entropy pool from a source of entropy.
+ */
+ for(int i = 0; i < samp; i++)
+ {
+
+ ch = fgetc(pdev);
+ randpool_add(&pool, &ch, sizeof(ch));
+
+ }
+
+ fclose(pdev);
+
+
+ for(int k = 0; k < round; k++)
+ {
+ switch(mode)
+ {
+ case 1:
+ {
+ printf("\n");
+ printf("\n# name: vet%d",k);
+ printf("\n# type: matrix");
+ printf("\n# rows: 1");
+ printf("\n# columns: %d\n", LEN);
+ pass = 1;
+ break;
+ }
+ case 2:
+ {
+ printf("\n");
+ printf("\n# name: randMatrix");
+ printf("\n# type: matrix");
+ printf("\n# rows: %d",round);
+ printf("\n# columns: %d\n", LEN);
+ pass = 1;
+ mode = 0;
+ break;
+ }
+ }
+
+ randpool_get(&pool, buff, LEN);
+
+ if(pass)
+ {
+ for(int j = 0; j < LEN; j++)
+ {
+ printf("%d ", buff[j]);
+ }
+ printf("\n");
+ }
+ else
+ fwrite(buff, sizeof(uint8_t), LEN, stdout);
+ }
+
+
+}
+
--- /dev/null
+#
+# $Id$
+# Copyright 2006 Develer S.r.l. (http://www.develer.com/)
+# All rights reserved.
+#
+# Makefile fragment for DevLib randpool_demo application.
+#
+# Author: Daniele Basile <asterix@develer.com>
+#
+# $Log$
+# Revision 1.1 2007/02/15 18:17:51 asterix
+# Add randpool test program.
+#
+#
+
+
+# Set to 1 for debug builds
+randpool_demo_DEBUG = 0
+
+# Our target application
+TRG += randpool_demo
+
+randpool_demo_CSRC = \
+ examples/randpool/randpool_demo.c \
+ algos/randpool.c \
+ algos/md2.c \
+ drv/timer.c \
+ os/hptime.c
+
+randpool_demo_CFLAGS = -O0 -D'ARCH=0' -Iexamples/randpool/ -Iexamples/randpool/hw
+
+# Debug stuff
+ifeq ($(randpool_demo_DEBUG),1)
+ randpool_demo_CFLAGS += -D_DEBUG
+ randpool_demo_PCSRC += drv/kdebug.c
+endif
+
--- /dev/null
+#
+# $Id: armtest.mk 18234 2007-10-08 13:39:48Z rasky $
+# Copyright 2006 Develer S.r.l. (http://www.develer.com/)
+# All rights reserved.
+#
+# Makefile fragment for DevLib armtest application.
+#
+# Author: Bernie Innocenti <bernie@codewiz.org>
+#
+#
+
+# Set to 1 for debug builds
+armtest_DEBUG = 1
+
+# Our target application
+TRG += armtest
+
+#include arm c and asm sources
+include ./examples/test/arm_src.mk
+
+armtest_CSRC = $(arm_CSRC) examples/test/empty_main.c
+
+armtest_CPPASRC = $(arm_ASRC)
+
+armtest_CROSS = arm-elf-
+
+armtest_CPPAFLAGS = -O0 -g -gdwarf-2 -g -gen-debug
+armtest_CPPFLAGS = -O0 -D'ARCH=ARCH_NIGHTTEST' -D__ARM_AT91SAM7S256__ -g3 -gdwarf-2 -fverbose-asm -Iexamples/test -Ibertos/cpu/arm
+armtest_LDFLAGS = -nostartfiles -T bertos/cpu/arm/scripts/at91sam7_256_rom.ld -Wl,--no-warn-mismatch
+
+armtest_CPU = arm7tdmi
+
--- /dev/null
+#
+# $Id: avrtest.mk,v 1.3 2006/06/12 21:37:02 marco Exp $
+# Copyright 2006 Develer S.r.l. (http://www.develer.com/)
+# All rights reserved.
+#
+# Makefile fragment for DevLib avrtest application.
+#
+# Author: Bernie Innocenti <bernie@codewiz.org>
+#
+
+
+
+# Set to 1 for debug builds
+avrtest_DEBUG = 1
+
+# Our target application
+TRG += avrtest
+
+avrtest_MCU = atmega64
+
+#include avr c and asm sources
+include examples/test/avr_src.mk
+
+avrtest_CSRC = $(avr_CSRC) examples/test/empty_main.c
+
+avrtest_CPPASRC = $(avr_ASRC)
+
+avrtest_PCSRC += bertos/mware/formatwr.c
+
+avrtest_CROSS = avr-
+avrtest_CPPFLAGS = -D'ARCH=ARCH_NIGHTTEST' -Iexamples/test -Ibertos/cpu/avr
+avrtest_CFLAGS = -Os -mcall-prologues -fno-strict-aliasing
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
+ * All Rights Reserved.
+ * -->
+ *
+ * \brief Hardware-specific definitions
+ *
+ * \version $Id$
+ *
+ * \author Daniele Basile <asterix@develer.com>
+ */
+
+int main(void)
+{
+ for(;;)
+ {
+ }
+
+ return 0;
+}
--- /dev/null
+/* Linker script for boot loader */
+
+OUTPUT_FORMAT("elf32-avr","elf32-avr","elf32-avr")
+OUTPUT_ARCH(avr:5)
+MEMORY
+{
+ text (rx) : ORIGIN = 0xE000, LENGTH = 8K
+ data (rw!x) : ORIGIN = 0x800060, LENGTH = 4000
+ eeprom (rw!x) : ORIGIN = 0x810000, LENGTH = 2K
+}
+SECTIONS
+{
+ /* Read-only sections, merged into text segment: */
+ .hash : { *(.hash) }
+ .dynsym : { *(.dynsym) }
+ .dynstr : { *(.dynstr) }
+ .gnu.version : { *(.gnu.version) }
+ .gnu.version_d : { *(.gnu.version_d) }
+ .gnu.version_r : { *(.gnu.version_r) }
+ .rel.init : { *(.rel.init) }
+ .rela.init : { *(.rela.init) }
+ .rel.text :
+ {
+ *(.rel.text)
+ *(.rel.text.*)
+ *(.rel.gnu.linkonce.t*)
+ }
+ .rela.text :
+ {
+ *(.rela.text)
+ *(.rela.text.*)
+ *(.rela.gnu.linkonce.t*)
+ }
+ .rel.fini : { *(.rel.fini) }
+ .rela.fini : { *(.rela.fini) }
+ .rel.rodata :
+ {
+ *(.rel.rodata)
+ *(.rel.rodata.*)
+ *(.rel.gnu.linkonce.r*)
+ }
+ .rela.rodata :
+ {
+ *(.rela.rodata)
+ *(.rela.rodata.*)
+ *(.rela.gnu.linkonce.r*)
+ }
+ .rel.data :
+ {
+ *(.rel.data)
+ *(.rel.data.*)
+ *(.rel.gnu.linkonce.d*)
+ }
+ .rela.data :
+ {
+ *(.rela.data)
+ *(.rela.data.*)
+ *(.rela.gnu.linkonce.d*)
+ }
+ .rel.ctors : { *(.rel.ctors) }
+ .rela.ctors : { *(.rela.ctors) }
+ .rel.dtors : { *(.rel.dtors) }
+ .rela.dtors : { *(.rela.dtors) }
+ .rel.got : { *(.rel.got) }
+ .rela.got : { *(.rela.got) }
+ .rel.bss : { *(.rel.bss) }
+ .rela.bss : { *(.rela.bss) }
+ .rel.plt : { *(.rel.plt) }
+ .rela.plt : { *(.rela.plt) }
+ /* Internal text space or external memory */
+ .text :
+ {
+ KEEP(*(.vectors))
+ __ctors_start = . ;
+ *(.ctors)
+ __ctors_end = . ;
+ __dtors_start = . ;
+ *(.dtors)
+ __dtors_end = . ;
+ *(.progmem.gcc*)
+ *(.progmem*)
+ . = ALIGN(2);
+ KEEP(*(.init0)) /* Start here after reset. */
+ KEEP(*(.init1))
+ KEEP(*(.init2)) /* Clear __zero_reg__, set up stack pointer. */
+ KEEP(*(.init3))
+ KEEP(*(.init4)) /* Initialize data and BSS. */
+ KEEP(*(.init5))
+ KEEP(*(.init6)) /* C++ constructors. */
+ KEEP(*(.init7))
+ KEEP(*(.init8))
+ KEEP(*(.init9)) /* Call main(). */
+ *(.text)
+ . = ALIGN(2);
+ *(.text.*)
+ . = ALIGN(2);
+ *(.fini9) /* _exit() starts here. */
+ *(.fini8)
+ *(.fini7)
+ *(.fini6) /* C++ destructors. */
+ *(.fini5)
+ *(.fini4)
+ *(.fini3)
+ *(.fini2)
+ *(.fini1)
+ *(.fini0) /* Infinite loop after program termination. */
+ _etext = . ;
+ } > text
+ .data : AT (ADDR (.text) + SIZEOF (.text))
+ {
+ PROVIDE (__data_start = .) ;
+ *(.data .data.* .rodata .rodata.*)
+ *(.gnu.linkonce.d*)
+ . = ALIGN(2);
+ _edata = . ;
+ PROVIDE (__data_end = .) ;
+ } > data
+ .bss SIZEOF(.data) + ADDR(.data) :
+ {
+ PROVIDE (__bss_start = .) ;
+ *(.bss .bss.*)
+ *(COMMON)
+ PROVIDE (__bss_end = .) ;
+ } > data
+ __data_load_start = LOADADDR(.data);
+ __data_load_end = __data_load_start + SIZEOF(.data);
+ /* Global data not cleared after reset. */
+ .noinit SIZEOF(.bss) + ADDR(.bss) :
+ {
+ PROVIDE (__noinit_start = .) ;
+ *(.noinit*)
+ PROVIDE (__noinit_end = .) ;
+ _end = . ;
+ PROVIDE (__heap_start = .) ;
+ } > data
+ .eeprom :
+ AT (ADDR (.text) + SIZEOF (.text) + SIZEOF (.data))
+ {
+ *(.eeprom*)
+ __eeprom_end = . ;
+ } > eeprom
+ /* Stabs debugging sections. */
+ .stab 0 : { *(.stab) }
+ .stabstr 0 : { *(.stabstr) }
+ .stab.excl 0 : { *(.stab.excl) }
+ .stab.exclstr 0 : { *(.stab.exclstr) }
+ .stab.index 0 : { *(.stab.index) }
+ .stab.indexstr 0 : { *(.stab.indexstr) }
+ .comment 0 : { *(.comment) }
+ /* DWARF debug sections.
+ Symbols in the DWARF debugging sections are relative to the beginning
+ of the section so we begin them at 0. */
+ /* DWARF 1 */
+ .debug 0 : { *(.debug) }
+ .line 0 : { *(.line) }
+ /* GNU DWARF 1 extensions */
+ .debug_srcinfo 0 : { *(.debug_srcinfo) }
+ .debug_sfnames 0 : { *(.debug_sfnames) }
+ /* DWARF 1.1 and DWARF 2 */
+ .debug_aranges 0 : { *(.debug_aranges) }
+ .debug_pubnames 0 : { *(.debug_pubnames) }
+ /* DWARF 2 */
+ .debug_info 0 : { *(.debug_info) *(.gnu.linkonce.wi.*) }
+ .debug_abbrev 0 : { *(.debug_abbrev) }
+ .debug_line 0 : { *(.debug_line) }
+ .debug_frame 0 : { *(.debug_frame) }
+ .debug_str 0 : { *(.debug_str) }
+ .debug_loc 0 : { *(.debug_loc) }
+ .debug_macinfo 0 : { *(.debug_macinfo) }
+}
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2001,2002,2003 Bernie Innocenti <bernie@codewiz.org>
+ *
+ * -->
+ *
+ * \brief Set system configuration
+ *
+ * \version $Id$
+ *
+ * \author Bernie Innocenti <bernie@codewiz.org>
+ *
+ */
+
+
+#ifndef CFG_ARCH_CONFIG_H
+#define CFG_ARCH_CONFIG_H
+
+#include <cfg/macros.h>
+
+/**
+ * \name Architectures
+ * \{
+ */
+#define ARCH_TRIFACE BV(0)
+#define ARCH_BOOT BV(1)
+#define ARCH_EMUL BV(2)
+/*\}*/
+
+#endif /* CFG_ARCH_CONFIG_H */
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
+ * All Rights Reserved.
+ * -->
+ *
+ * \brief Configuration file for boot module.
+ *
+ * \version $Id$
+ *
+ * \author Manuele Fanelli <qwert@develer.com>
+ */
+
+#ifndef CFG_BOOT_H
+#define CFG_BOOT_H
+
+#define CONFIG_SER_HOSTPORT 1 ///< Triface comunication host port
+
+#define CONFIG_SER_HOSTPORTBAUDRATE 115200 ///< Serial host port baudrate
+
+#endif /* CFG_BOOT_H */
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
+ * All Rights Reserved.
+ * -->
+ *
+ * \brief Configuration file for formatted write module.
+ *
+ * \version $Id$
+ *
+ * \author Daniele Basile <asterix@develer.com>
+ */
+
+#ifndef CFG_FORMTWR_H
+#define CFG_FORMTWR_H
+
+/**
+ * printf()-style formatter configuration.
+ *
+ * \sa PRINTF_DISABLED
+ * \sa PRINTF_NOMODIFIERS
+ * \sa PRINTF_REDUCED
+ * \sa PRINTF_NOFLOAT
+ * \sa PRINTF_FULL
+ */
+#define CONFIG_PRINTF PRINTF_REDUCED
+
+
+#endif /* CFG_FORMTWR_H */
+
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2001, 2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 1999, 2000, 2001, 2008 Bernie Innocenti <bernie@codewiz.org>
+ * -->
+ *
+ * \brief Kernel configuration parameters
+ *
+ * \version $Id$
+ * \author Bernie Innocenti <bernie@codewiz.org>
+ */
+
+#ifndef CFG_KERN_H
+#define CFG_KERN_H
+
+/**
+ * Enable the multithreading kernel.
+ */
+#define CONFIG_KERN 0
+
+/**
+ * \name Optional kernel features
+ * \{
+ */
+#define CONFIG_KERN_SCHED 0 ///< Process schedling
+#define CONFIG_KERN_SIGNALS 0 ///< Inter-process signals
+#define CONFIG_KERN_IRQ 0 ///< Interrupt supervisor
+#define CONFIG_KERN_HEAP 0 ///< Dynamic memory allocation
+#define CONFIG_KERN_SEMAPHORES 0 ///< Re-entrant mutual exclusion primitives
+#define CONFIG_KERN_MONITOR 0 ///< Process monitor
+#define CONFIG_KERN_PREEMPT 0 ///< Preemptive process scheduling
+#define CONFIG_KERN_PRI 0 ///< Priority-based scheduling policy
+/*\}*/
+
+/// [ms] Time sharing quantum (a prime number prevents interference effects)
+#define CONFIG_KERN_QUANTUM 47
+
+/// Module logging level.
+#define KERN_LOG_LEVEL LOG_LVL_ERR
+
+/// Module logging format.
+#define KERN_LOG_FORMAT LOG_FMT_VERBOSE
+
+#endif /* CFG_KERN_H */
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
+ * All Rights Reserved.
+ * -->
+ *
+ * \brief Configuration file for KFile interface module.
+ *
+ * \version $Id$
+ * \author Daniele Basile <asterix@develer.com>
+ */
+
+#ifndef CFG_KFILE_H
+#define CFG_KFILE_H
+
+/// Module logging level definition.
+#define KFILE_LOG_LEVEL LOG_LVL_INFO
+
+/// Module logging verbosity.
+#define KFILE_LOG_FORMAT LOG_FMT_TERSE
+
+/// Enable the gets function with echo.
+#define CONFIG_KFILE_GETS 1
+
+#endif /* CFG_KFILE_H */
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
+ * All Rights Reserved.
+ * -->
+ *
+ * \brief Configuration file for serial module.
+ *
+ * \version $Id$
+ *
+ * \author Daniele Basile <asterix@develer.com>
+ */
+
+#ifndef CFG_SER_H
+#define CFG_SER_H
+
+
+/// Kdebug console on debug unit
+#define CONFIG_TRIFACE_PORT 0
+
+/// Baud-rate for the kdebug console
+#define CONFIG_TRIFACE_BAUDRATE 115200
+
+/// [bytes] Size of the outbound FIFO buffer for port 0.
+#define CONFIG_UART0_TXBUFSIZE 32
+
+/// [bytes] Size of the inbound FIFO buffer for port 0.
+#define CONFIG_UART0_RXBUFSIZE 64
+
+/// [bytes] Size of the outbound FIFO buffer for port 1.
+#define CONFIG_UART1_TXBUFSIZE 32
+
+/// [bytes] Size of the inbound FIFO buffer for port 1.
+#define CONFIG_UART1_RXBUFSIZE 64
+
+
+/// [bytes] Size of the outbound FIFO buffer for SPI port (AVR only)
+#define CONFIG_SPI_TXBUFSIZE 32
+
+/// [bytes] Size of the inbound FIFO buffer for SPI port (AVR only)
+#define CONFIG_SPI_RXBUFSIZE 32
+
+/// [bytes] Size of the outbound FIFO buffer for SPI port 0.
+#define CONFIG_SPI0_TXBUFSIZE 32
+
+/// [bytes] Size of the inbound FIFO buffer for SPI port 0.
+#define CONFIG_SPI0_RXBUFSIZE 32
+
+/// [bytes] Size of the outbound FIFO buffer for SPI port 1.
+#define CONFIG_SPI1_TXBUFSIZE 32
+
+/// [bytes] Size of the inbound FIFO buffer for SPI port 1.
+#define CONFIG_SPI1_RXBUFSIZE 32
+
+/// SPI data order (AVR only).
+#define CONFIG_SPI_DATA_ORDER SER_MSB_FIRST
+
+/// SPI clock division factor (AVR only).
+#define CONFIG_SPI_CLOCK_DIV 16
+
+/// SPI clock polarity: 0 = normal low, 1 = normal high (AVR only).
+#define CONFIG_SPI_CLOCK_POL 0
+
+/// SPI clock phase: 0 = sample on first edge, 1 = sample on second clock edge (AVR only).
+#define CONFIG_SPI_CLOCK_PHASE 0
+
+/// Default transmit timeout (ms). Set to -1 to disable timeout support.
+#define CONFIG_SER_TXTIMEOUT 100
+
+/// Default receive timeout (ms). Set to -1 to disable timeout support.
+#define CONFIG_SER_RXTIMEOUT 100
+
+/// Use RTS/CTS handshake
+#define CONFIG_SER_HWHANDSHAKE 0
+
+/// Default baud rate (set to 0 to disable).
+#define CONFIG_SER_DEFBAUDRATE 0
+
+/// Enable second serial port in emulator.
+#define CONFIG_EMUL_UART1 0
+
+/**
+ * Transmit always something on serial port 0 TX
+ * to avoid interference when sending burst of data,
+ * using AVR multiprocessor serial mode
+ */
+#define CONFIG_SER_TXFILL 0
+
+/// For serial debug.
+#define CONFIG_SER_STROBE 0
+
+#endif /* CFG_SER_H */
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
+ *
+ * -->
+ *
+ * \brief Macro for boot loader.
+ *
+ *
+ * \version $Id$
+ *
+ * \author Daniele Basile <asterix@develer.com>
+ * \author Francesco Sacchi <batt@develer.com>
+ */
+
+#ifndef HW_BOOT_H
+#define HW_BOOT_H
+
+#include <avr/io.h>
+
+/* Set up function pointer to RESET vector */
+void (*rom_start)(void) NORETURN = 0x0000;
+
+#define START_APP() rom_start()
+
+#define BOOT_INIT do \
+{ \
+ /* Enable change of Interrupt Vectors */ \
+ MCUCR = BV(IVCE); \
+ /* Move interrupts to boot Flash section */ \
+ MCUCR = BV(IVSEL); \
+} while(0)
+
+#define BOOT_END do \
+{ \
+ /* Enable change of Interrupt Vectors */ \
+ MCUCR = BV(IVCE); \
+ /* Move interrupts to boot Flash section */ \
+ MCUCR = 0; \
+} while(0)
+
+#endif // HW_BOOT_H
+
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
+ *
+ * --> Rights Reserved.
+ *
+ * \brief Hardware-specific definitions
+ *
+ * \version $Id$
+ *
+ * \author Bernie Innocenti <bernie@codewiz.org>
+ */
+
+#ifndef TRIFACE_HW_H
+#define TRIFACE_HW_H
+
+/// CPU Clock frequency (14.7456 MHz)
+#define CLOCK_FREQ (14745600UL)
+
+
+/* Timer IRQ strobe */
+//#if CONFIG_TIMER_STROBE
+// #define TIMER_STROBE_ON ATOMIC(PORTD |= BV(PD0))
+// #define TIMER_STROBE_OFF ATOMIC(PORTD &= ~BV(PD0))
+// #define TIMER_STROBE_INIT ATOMIC(PORTD &= ~BV(PD0); DDRD |= BV(PD0))
+//#endif /* CONFIG_TIMER_STROBE */
+
+#endif /* TRIFACE_HW_H */
+
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
+ * All Rights Reserved.
+ * -->
+ *
+ * \brief Serial hardware-specific definitions
+ *
+ * \version $Id$
+ *
+ * \author Daniele Basile <asterix@develer.com>
+ */
+
+#ifndef HW_SER_H
+#define HW_SER_H
+
+
+
+#endif /* HW_SER_H */
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
+ *
+ * -->
+ *
+ * \brief Flash boot loader main.
+ * This is a simple generic bootloader app.
+ * It requires only a serial port to work.
+ * Try to receive a file through XMODEM protocol
+ * and flash it on program memory.
+ * BOOT_INIT, BOOT_END are macros used to perform special operations
+ * respectively at boot start and boot end and are CPU dependant.
+ * The macro START_APP() jumps to main application start.
+ *
+ * \version $Id$
+ * \author Stefano Fedrigo <aleph@develer.com>
+ * \author Francesco Sacchi <batt@develer.com>
+ * \author Daniele Basile <asterix@develer.com>
+ */
+
+#include <net/xmodem.h>
+#include <cfg/compiler.h>
+#include <cfg/debug.h>
+#include <cfg/macros.h> /* BV() */
+
+#include <drv/wdt.h>
+#include <drv/ser.h>
+#include <drv/timer.h>
+#include <drv/flash_avr.h>
+
+#include "hw/hw_boot.h"
+#include "cfg/cfg_boot.h"
+
+#include <string.h>
+
+int main(void)
+{
+ FlashAvr flash;
+ Serial ser;
+
+
+ // Set up flash programming functions.
+ flash_avr_init(&flash);
+
+ IRQ_ENABLE;
+
+ BOOT_INIT;
+
+ kdbg_init();
+ timer_init();
+
+
+ /* Open the main communication port */
+
+ ser_init(&ser, CONFIG_SER_HOSTPORT);
+ ser_setbaudrate(&ser, CONFIG_SER_HOSTPORTBAUDRATE);
+
+ xmodem_recv(&ser, &flash.fd);
+ kfile_close(&flash.fd);
+ kfile_close(&ser.fd);
+
+ IRQ_DISABLE;
+
+ BOOT_END;
+
+ START_APP();
+
+}
+
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2003,2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2001,2002,2003 Bernie Innocenti <bernie@codewiz.org>
+ *
+ * -->
+ *
+ * \brief Set system configuration
+ *
+ * \version $Id$
+ *
+ * \author Bernie Innocenti <bernie@codewiz.org>
+ *
+ */
+
+
+#ifndef CFG_ARCH_CONFIG_H
+#define CFG_ARCH_CONFIG_H
+
+#include <cfg/macros.h>
+
+/**
+ * \name Architectures
+ * \{
+ */
+#define ARCH_TRIFACE BV(0)
+#define ARCH_BOOT BV(1)
+#define ARCH_EMUL BV(2)
+/*\}*/
+
+#endif /* CFG_ARCH_CONFIG_H */
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
+ * All Rights Reserved.
+ * -->
+ *
+ * \brief Configuration file for Debug module.
+ *
+ * \version $Id$
+ *
+ * \author Daniele Basile <asterix@develer.com>
+ */
+
+#ifndef CFG_DEBUG_H
+#define CFG_DEBUG_H
+
+/// kdebug console.
+#define CONFIG_KDEBUG_PORT 1
+
+/// Baud-rate for the kdebug console.
+#define CONFIG_KDEBUG_BAUDRATE 115200
+
+#endif /* CFG_DEBUG_H */
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2001, 2004 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 1999, 2000, 2001, 2008 Bernie Innocenti <bernie@codewiz.org>
+ * -->
+ *
+ * \brief Kernel configuration parameters
+ *
+ * \version $Id$
+ * \author Bernie Innocenti <bernie@codewiz.org>
+ */
+
+#ifndef CFG_KERN_H
+#define CFG_KERN_H
+
+/**
+ * Enable the multithreading kernel.
+ */
+#define CONFIG_KERN 0
+
+/**
+ * \name Optional kernel features
+ * \{
+ */
+#define CONFIG_KERN_SCHED 0 ///< Process schedling
+#define CONFIG_KERN_SIGNALS 0 ///< Inter-process signals
+#define CONFIG_KERN_IRQ 0 ///< Interrupt supervisor
+#define CONFIG_KERN_HEAP 0 ///< Dynamic memory allocation
+#define CONFIG_KERN_SEMAPHORES 0 ///< Re-entrant mutual exclusion primitives
+#define CONFIG_KERN_MONITOR 0 ///< Process monitor
+#define CONFIG_KERN_PREEMPT 0 ///< Preemptive process scheduling
+#define CONFIG_KERN_PRI 0 ///< Priority-based scheduling policy
+/*\}*/
+
+/// [ms] Time sharing quantum (a prime number prevents interference effects)
+#define CONFIG_KERN_QUANTUM 47
+
+/// Module logging level.
+#define KERN_LOG_LEVEL LOG_LVL_ERR
+
+/// Module logging format.
+#define KERN_LOG_FORMAT LOG_FMT_VERBOSE
+
+#endif /* CFG_KERN_H */
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
+ *
+ * -->
+ *
+ * \brief Configuration file for KFile interface module.
+ *
+ * \version $Id$
+ * \author Daniele Basile <asterix@develer.com>
+ */
+
+#ifndef CFG_KFILE_H
+#define CFG_KFILE_H
+
+/// Module logging level definition.
+#define KFILE_LOG_LEVEL LOG_LVL_INFO
+
+/// Module logging format.
+#define KFILE_LOG_FORMAT LOG_FMT_TERSE
+
+/// Enable the gets function with echo.
+#define CONFIG_KFILE_GETS 1
+
+#endif /* CFG_KFILE_H */
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
+ * All Rights Reserved.
+ * -->
+ *
+ * \brief Configuration file for serial module.
+ *
+ * \version $Id$
+ *
+ * \author Daniele Basile <asterix@develer.com>
+ */
+
+#ifndef CFG_SER_H
+#define CFG_SER_H
+
+
+/// Kdebug console on debug unit
+#define CONFIG_TRIFACE_PORT 1
+
+/// Baud-rate for the kdebug console
+#define CONFIG_TRIFACE_BAUDRATE 115200
+/// Triface serial tag port
+#define TAG_SER_PORT 0
+///Baud-rate for triface serial tag port
+#define TAG_SER_BAUDRATE 9600
+
+/// [bytes] Size of the outbound FIFO buffer for port 0.
+#define CONFIG_UART0_TXBUFSIZE 32
+
+/// [bytes] Size of the inbound FIFO buffer for port 0.
+#define CONFIG_UART0_RXBUFSIZE 64
+
+/// [bytes] Size of the outbound FIFO buffer for port 1.
+#define CONFIG_UART1_TXBUFSIZE 32
+
+/// [bytes] Size of the inbound FIFO buffer for port 1.
+#define CONFIG_UART1_RXBUFSIZE 64
+
+
+/// [bytes] Size of the outbound FIFO buffer for SPI port (AVR only)
+#define CONFIG_SPI_TXBUFSIZE 32
+
+/// [bytes] Size of the inbound FIFO buffer for SPI port (AVR only)
+#define CONFIG_SPI_RXBUFSIZE 32
+
+/// [bytes] Size of the outbound FIFO buffer for SPI port 0.
+#define CONFIG_SPI0_TXBUFSIZE 32
+
+/// [bytes] Size of the inbound FIFO buffer for SPI port 0.
+#define CONFIG_SPI0_RXBUFSIZE 32
+
+/// [bytes] Size of the outbound FIFO buffer for SPI port 1.
+#define CONFIG_SPI1_TXBUFSIZE 32
+
+/// [bytes] Size of the inbound FIFO buffer for SPI port 1.
+#define CONFIG_SPI1_RXBUFSIZE 32
+
+/// SPI data order (AVR only).
+#define CONFIG_SPI_DATA_ORDER SER_MSB_FIRST
+
+/// SPI clock division factor (AVR only).
+#define CONFIG_SPI_CLOCK_DIV 16
+
+/// SPI clock polarity: 0 = normal low, 1 = normal high (AVR only).
+#define CONFIG_SPI_CLOCK_POL 0
+
+/// SPI clock phase: 0 = sample on first edge, 1 = sample on second clock edge (AVR only).
+#define CONFIG_SPI_CLOCK_PHASE 0
+
+/// Default transmit timeout (ms). Set to -1 for infinite timeout, 0 for null timeout
+#define CONFIG_SER_TXTIMEOUT 0
+
+/// Default receive timeout (ms). Set to -1 for infinite timeout, 0 for null timeout
+#define CONFIG_SER_RXTIMEOUT 0
+
+/// Use RTS/CTS handshake
+#define CONFIG_SER_HWHANDSHAKE 0
+
+/// Default baud rate (set to 0 to disable).
+#define CONFIG_SER_DEFBAUDRATE 0
+
+/// Enable second serial port in emulator.
+#define CONFIG_EMUL_UART1 0
+
+/**
+ * Transmit always something on serial port 0 TX
+ * to avoid interference when sending burst of data,
+ * using AVR multiprocessor serial mode
+ */
+#define CONFIG_SER_TXFILL 0
+
+/// For serial debug.
+#define CONFIG_SER_STROBE 0
+
+#endif /* CFG_SER_H */
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
+ * All Rights Reserved.
+ * -->
+ *
+ * \brief Configuration file for watchdog module.
+ *
+ * \version $Id$
+ *
+ * \author Daniele Basile <asterix@develer.com>
+ */
+
+#ifndef CFG_WDT_H
+#define CFG_WDT_H
+
+/// Enable watchdog timer.
+#define CONFIG_WATCHDOG 1
+
+#endif /* CFG_WDT_H */
+
+
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2006 Develer S.r.l. (http://www.develer.com/)
+ * -->
+ *
+ * \brief Macro for defining command for protocol.
+ *
+ *
+ * \version $Id$
+ *
+ * \author Marco Benelli <marco@develer.com>
+ */
+
+#ifndef CMD_CTOR_H
+#define CMD_CTOR_H
+
+#include <mware/parser.h>
+
+#define REGISTER_FUNCTION parser_register_cmd
+
+#define REGISTER_CMD(NAME) REGISTER_FUNCTION(&cmd_ ## NAME ## _template)
+
+#define MAKE_TEMPLATE(NAME, ARGS, RES, FLAGS) \
+const struct CmdTemplate cmd_ ## NAME ## _template = \
+{ \
+ #NAME, ARGS, RES, cmd_ ## NAME, FLAGS \
+};
+
+#define MAKE_CMD(NAME, ARGS, RES, BODY, FLAGS) \
+static ResultCode cmd_ ## NAME (parms *args) \
+{ \
+ return (ResultCode)BODY; \
+} \
+MAKE_TEMPLATE(NAME, ARGS, RES, FLAGS)
+
+#endif // CMD_CTOR_H
--- /dev/null
+
+Command format:
+
+ <command><SP><arg1><SP>...<argN><CR><LF>
+
+Where:
+ command - alphanumeric command name
+ argN - numeric argument (unsigned base 10, 0-65535)
+
+Positive response format:
+
+ 0<SP><arg1><SP>...<argN><CR><LF>
+
+Where:
+ argN - numeric value (unsigned base 10, 0-65535)
+
+Negative response format:
+
+ -N<SP>"<desc>"<CR><LF>
+
+Where:
+ -N - numeric error code (negative number)
+ desc - verbose error description
+
+# Write digital outputs (masked)
+> dout 120 240
+< 0
+
+# Read digital inputs
+> din
+< 0 125
+
+# Read analog inputs
+> ain
+< 0 32 121 35 31
+
+# Wait specified amount of milliseconds
+> sleep 300
+< 0
+
+# Return firmware major version, minor version and revision
+> vers
+< 0 1 42 0
+
+# Reset board
+< reset
+> 0
+
+# Ping/nop
+< ping
+> 0
+
+# NOP (empty command)
+>
+< (ignored)
+
+# Comments
+> # foo bar foobar
+< (ignored)
+
+# Unknown command
+> sing
+< -1 "Unknown command"
+
+# Missing parameter
+> dout
+< -2 "Required parameter missing"
+
+# Too many parameters
+> din 42 666
+< -3 "Too many parameters"
+
+# Malformed command
+> dout %'I!
+< -4 "Invalid parameter"
+
+# Attention
+> <CTRL-C> or <CTRL-D>
+< 1 "Uh?"
+
+
+To recover from a possibly unknown board status,
+a client should begin the conversation by issuing
+an attention sequence, eventually followed by a reset.
--- /dev/null
+(ExpressProject "triface"\r
+ (ProjectVersion "19981106")\r
+ (ProjectType "PCB")\r
+ (Folder "Design Resources"\r
+ (Folder "Library")\r
+ (NoModify)\r
+ (File ".\triface.dsn"\r
+ (Type "Schematic Design"))\r
+ (BuildFileAddedOrDeleted "x")\r
+ (CompileFileAddedOrDeleted "x")\r
+ (ANNOTATE_Scope "0")\r
+ (ANNOTATE_Mode "1")\r
+ (ANNOTATE_Action "0")\r
+ (Annotate_Page_Order "0")\r
+ (ANNOTATE_Reset_References_to_1 "FALSE")\r
+ (ANNOTATE_No_Page_Number_Change "FALSE")\r
+ (ANNOTATE_Property_Combine "{Value}{Source Package}{POWER_GROUP}")\r
+ (ANNOTATE_IncludeNonPrimitive "FALSE"))\r
+ (Folder "Outputs")\r
+ (Folder "Referenced Projects")\r
+ (PartMRUSelector)\r
+ (GlobalState\r
+ (FileView\r
+ (Path "Design Resources")\r
+ (Path "Design Resources"\r
+ "c:\documents and settings\administrator\desktop\new triface\triface.dsn")\r
+ (Path "Design Resources"\r
+ "c:\documents and settings\administrator\desktop\new triface\triface.dsn"\r
+ "TRIFACE BOARD"))\r
+ (HierarchyView)\r
+ (Doc\r
+ (Type "COrCapturePMDoc")\r
+ (Frame\r
+ (Placement "44 2 3 -1 -1 -4 -23 214 743 2 443"))\r
+ (Tab 0)))\r
+ (MPSSessionName "Administrator"))\r
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
+ *
+ * -->
+ *
+ * \brief ADC: Analogic to Digital Converter
+ *
+ *
+ * \version $Id$
+ *
+ * \author Andrea Grandi <andrea@develer.com>
+ */
+
+#include "hw/hw_adc.h"
+
+
+#include <cfg/macros.h>
+
+#include <drv/timer.h>
+
+#include <avr/io.h>
+
+/** Set the active AI channel */
+void adc_set_active_ain(int ai)
+{
+ /* If number of channels is <= 4 we use the first two MUX bits */
+ STATIC_ASSERT(ADC_CHANNEL_NUM <= 4);
+
+ ai &= BV(0) | BV(1);
+ ADMUX &= ~BV(MUX0);
+ ADMUX &= ~BV(MUX1);
+ ADMUX |= ai;
+}
+
+/** Initialize the ADC */
+void adc_init(void)
+{
+ /* Set analog IN as input */
+ DDRF &= ~(BV(PF0) | BV(PF1) | BV(PF2) | BV(PF3));
+
+ /* Disable pull-up */
+ PORTF &= ~(BV(PF0) | BV(PF1) | BV(PF2) | BV(PF3));
+
+ ENABLE_ADC;
+ adc_set_vref_avcc();
+ SET_AI_ADLAR;
+
+ /* Set the Division Factor to 128 */
+ ADCSRA |= (BV(ADPS0) | BV(ADPS1) | BV(ADPS2));
+}
+
+/** Set the initial reference */
+void adc_set_vref_avcc(void)
+{
+ ADMUX &= ~BV(REFS1);
+ ADMUX |= BV(REFS0);
+}
+
+/** Read the specified AI channel */
+int adc_read_ai_channel(int channel)
+{
+ adc_set_active_ain(channel);
+ timer_udelay(STABILIZING_AI_CHANNEL_TIME);
+ START_CONVERTION;
+
+ while(ADCSRA & BV(ADSC))
+ {
+ /*
+ * Intentionally empty loop.
+ * It waits the convertion to be completed by ADC
+ */
+ }
+
+ ADCSRA |= BV(ADIF);
+
+ uint16_t val;
+ val = ADCL;
+ val |= (uint16_t)ADCH << 8;
+
+ return val;
+}
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
+ *
+ * -->ght 2006 Develer S.r.l. (http://www.develer.com/)
+ *
+ * \brief Macro for HW_AIN_H
+ *
+ *
+ * \version $Id$
+ *
+ * \author Andrea Grandi <andrea@develer.com>
+ */
+
+#ifndef HW_ADC_H
+#define HW_ADC_H
+
+#include <avr/io.h>
+
+#define START_CONVERTION (ADCSRA |= BV(ADSC))
+#define ENABLE_ADC (ADCSRA |= BV(ADEN))
+#define SET_AI_ADLAR (ADMUX &= ~BV(ADLAR))
+
+/** Microseconds to wait before starting conversion after changing a channel */
+#define STABILIZING_AI_CHANNEL_TIME 125
+
+/** Number of AIN channels */
+#define ADC_CHANNEL_NUM 4
+
+void adc_set_active_ain(int ai);
+void adc_init(void);
+void adc_set_vref_avcc(void);
+int adc_read_ai_channel(int channel);
+
+#endif // HW_ADC_H
+
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
+ *
+ * -->
+ *
+ * \brief Buzzer hardware-specific definitions
+ *
+ * \version $Id$
+ *
+ * \author Francesco Sacchi <batt@develer.com>
+ * Andrea Grandi <andrea@develer.com>
+ */
+
+#ifndef HW_BUZZER_H
+#define HW_BUZZER_H
+
+#include <avr/io.h>
+#include <cfg/macros.h>
+
+#define BUZZER_BIT BV(PE3)
+#define IS_BUZZER_ON (PORTE & BUZZER_BIT)
+#define BUZZER_HW_INIT do { DDRE |= BV(DDE3); } while (0)
+#define BUZZER_ON do { PORTE |= BUZZER_BIT; } while (0)
+#define BUZZER_OFF do { PORTE &= ~BUZZER_BIT; } while (0)
+
+#endif /* HW_BUZZER_H */
+
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
+ *
+ * --> Rights Reserved.
+ *
+ * \brief Hardware-specific definitions
+ *
+ * \version $Id$
+ *
+ * \author Bernie Innocenti <bernie@codewiz.org>
+ */
+
+#ifndef TRIFACE_HW_H
+#define TRIFACE_HW_H
+
+/// CPU Clock frequency (14.7456 MHz)
+#define CLOCK_FREQ (14745600UL)
+
+
+/* Timer IRQ strobe */
+//#if CONFIG_TIMER_STROBE
+// #define TIMER_STROBE_ON ATOMIC(PORTD |= BV(PD0))
+// #define TIMER_STROBE_OFF ATOMIC(PORTD &= ~BV(PD0))
+// #define TIMER_STROBE_INIT ATOMIC(PORTD &= ~BV(PD0); DDRD |= BV(PD0))
+//#endif /* CONFIG_TIMER_STROBE */
+
+#endif /* TRIFACE_HW_H */
+
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
+ *
+ * -->
+ *
+ * \brief Macro for HW_INPUT_H
+ *
+ *
+ * \version $Id$
+ *
+ * \author Andrea Grandi <andrea@develer.com>
+ */
+
+#ifndef HW_INPUT_H
+#define HW_INPUT_H
+
+#include <avr/io.h>
+
+/* Set pins as input and enable pull-up */
+#define INPUT_INIT_D do \
+{ \
+ (DDRD &= ~(BV(PD4) | BV(PD5) | BV(PD6) | BV(PD7))); \
+ (PORTD |= (BV(PD4) | BV(PD5) | BV(PD6) | BV(PD7))); \
+} while(0)
+
+#define INPUT_INIT_E do \
+{ \
+ (DDRE &= ~(BV(PE4) | BV(PE5) | BV(PE6) | BV(PE7))); \
+ ATOMIC((PORTE |= (BV(PE4) | BV(PE5) | BV(PE6) | BV(PE7)))); \
+} while(0)
+
+#define INPUT_INIT do { INPUT_INIT_D; INPUT_INIT_E;} while(0)
+
+INLINE uint8_t INPUT_GET(void)
+{
+ uint8_t out_d, out_e;
+ out_d = PIND;
+ out_e = PINE;
+
+ out_d >>= 4;
+ out_e = out_e & 0xF0;
+
+ return out_e | out_d;
+}
+
+#endif // HW_INPUT_H
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2008 Develer S.r.l. (http://www.develer.com/)
+ * All Rights Reserved.
+ * -->
+ *
+ * \brief Macro for STROBE signal
+ *
+ * \version $Id$
+ *
+ * \author Manuele Fanelli <qwert@develer.com>
+ */
+
+#ifndef HW_SER_H
+#define HW_SER_H
+
+#include "cfg/cfg_ser.h"
+
+#if CONFIG_SER_STROBE
+
+ #define SER_STROBE_ON do {PORTC |= BV(0);} while(0)
+ #define SER_STROBE_OFF do {PORTC &= ~BV(0);} while(0)
+ #define SER_STROBE_INIT do {DDRC |= BV(0); } while(0)
+#endif
+
+#endif //HW_SER_H
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
+ *
+ * -->
+ *
+ * \brief Macro for HW_SIPO_H
+ *
+ *
+ * \version $Id$
+ *
+ * \author Andrea Grandi <andrea@develer.com>
+ */
+#ifndef HW_SIPO_H
+#define HW_SIPO_H
+
+#define LOAD_HIGH (PORTB |= BV(PB3))
+#define LOAD_LOW (PORTB &= ~BV(PB3))
+#define LOAD_INIT (DDRB |= BV(PB3))
+#define SET_SCK_OUT (DDRB |= BV(PB1))
+#define SET_SOUT_OUT (DDRB |= BV(PB2))
+#define CLOCK_HIGH (PORTB |= BV(PB1))
+#define CLOCK_LOW (PORTB &= ~BV(PB1))
+#define SET_SOUT_HIGH (PORTB |= BV(PB2))
+#define SET_SOUT_LOW (PORTB &= ~BV(PB2))
+#define CLOCK_PULSE do { CLOCK_HIGH; CLOCK_LOW; } while(0)
+
+#define OE_OUT (DDRG |= BV(PG3))
+#define OE_LOW (PORTG &= BV(PG3))
+
+
+#endif // HW_SIPO_H
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
+ *
+ * -->
+ *
+ * \brief Implementation of the command protocol between the board and the host
+ *
+ *
+ * \version $Id$
+ *
+ * \author Giovanni Bajo <rasky@develer.com>
+ * \author Marco Benelli <marco@develer.com>
+ * \author Bernie Innocenti <bernie@codewiz.org>
+ * \author Daniele Basile <asterix@develer.com>
+ */
+
+#include "protocol.h"
+#include "cmd_ctor.h" // MAKE_CMD, REGISTER_CMD
+#include "verstag.h"
+#include "hw/hw_adc.h"
+#include "hw/hw_input.h"
+
+#include <drv/timer.h>
+#include <drv/ser.h>
+#include <drv/sipo.h>
+#include <drv/wdt.h>
+#include <drv/buzzer.h>
+
+#include <mware/readline.h>
+#include <mware/parser.h>
+
+#include <cfg/compiler.h>
+#include <cfg/debug.h>
+
+#include <kern/kfile.h>
+
+#include <stdlib.h>
+#include <string.h>
+
+// Define the format string for ADC
+#define ADC_FORMAT_STR "dddd"
+
+// DEBUG: set to 1 to force interactive mode
+#define FORCE_INTERACTIVE 1
+
+/**
+ * True if we are in interactive mode, false if we are in protocol mode.
+ * In interactive mode, commands are read through readline() (prompt,
+ * completion, history) without IDs, and replies/errors are sent to the serial
+ * output.
+ * In protocol mode, we implement the default protocol
+ */
+static bool interactive;
+
+/// Readline context, used for interactive mode.
+static struct RLContext rl_ctx;
+
+uint8_t reg_status_dout;
+/**
+ * Send a NAK asking the host to send the current message again.
+ *
+ * \a fd kfile handler for serial.
+ * \a err human-readable description of the error for debug purposes.
+ */
+INLINE void NAK(KFile *fd, const char *err)
+{
+#ifdef _DEBUG
+ kfile_printf(fd, "NAK \"%s\"\r\n", err);
+#else
+ kfile_printf(fd, "NAK\r\n");
+#endif
+}
+
+static void protocol_prompt(KFile *fd)
+{
+ kfile_print(fd, ">> ");
+}
+
+/*
+ * Print args on s, with format specified in t->result_fmt.
+ * Return number of valid arguments or -1 in case of error.
+ */
+static bool protocol_reply(KFile *fd, const struct CmdTemplate *t,
+ const parms *args)
+{
+ unsigned short offset = strlen(t->arg_fmt) + 1;
+ unsigned short nres = strlen(t->result_fmt);
+
+ for (unsigned short i = 0; i < nres; ++i)
+ {
+ if (t->result_fmt[i] == 'd')
+ {
+ kfile_printf(fd, " %ld", args[offset+i].l);
+ }
+ else if (t->result_fmt[i] == 's')
+ {
+ kfile_printf(fd, " %s", args[offset+i].s);
+ }
+
+ else
+ {
+ abort();
+ }
+ }
+ kfile_printf(fd, "\r\n");
+ return true;
+}
+
+static void protocol_parse(KFile *fd, const char *buf)
+{
+ const struct CmdTemplate *templ;
+
+ /* Command check. */
+ templ = parser_get_cmd_template(buf);
+ if (!templ)
+ {
+ kfile_print(fd, "-1 Invalid command.\r\n");
+ protocol_prompt(fd);
+ return;
+ }
+
+ parms args[PARSER_MAX_ARGS];
+
+ /* Args Check. TODO: Handle different case. see doc/PROTOCOL . */
+ if (!parser_get_cmd_arguments(buf, templ, args))
+ {
+ kfile_print(fd, "-2 Invalid arguments.\r\n");
+ protocol_prompt(fd);
+ return;
+ }
+
+ /* Execute. */
+ if(!parser_execute_cmd(templ, args))
+ {
+ NAK(fd, "Error in executing command.");
+ }
+ if (!protocol_reply(fd, templ, args))
+ {
+ NAK(fd, "Invalid return format.");
+ }
+
+ protocol_prompt(fd);
+ return;
+}
+
+void protocol_run(KFile *fd)
+{
+ /**
+ * \todo to be removed, we could probably access the serial FIFO
+ * directly
+ */
+ static char linebuf[80];
+
+ if (!interactive)
+ {
+ kfile_gets(fd, linebuf, sizeof(linebuf));
+
+ // reset serial port error anyway
+ kfile_clearerr(fd);
+
+ // check message minimum length
+ if (linebuf[0])
+ {
+ /* If we enter lines beginning with sharp(#)
+ they are stripped out from commands */
+ if(linebuf[0] != '#')
+ {
+ if (linebuf[0] == 0x1B && linebuf[1] == 0x1B) // ESC
+ {
+ interactive = true;
+ kfile_printf(fd, "Entering interactive mode\r\n");
+ }
+ else
+ {
+ protocol_parse(fd, linebuf);
+ }
+ }
+ }
+ }
+ else
+ {
+ const char *buf;
+
+ /*
+ * Read a line from serial. We use a temporary buffer
+ * because otherwise we would have to extract a message
+ * from the port immediately: there might not be any
+ * available, and one might get free while we read
+ * the line. We also add a fake ID at the start to
+ * fool the parser.
+ */
+ buf = rl_readline(&rl_ctx);
+
+ /* If we enter lines beginning with sharp(#)
+ they are stripped out from commands */
+ if(buf && buf[0] != '#')
+ {
+ if (buf[0] != '\0')
+ {
+ // exit special case to immediately change serial input
+ if (!strcmp(buf, "exit") || !strcmp(buf, "quit"))
+ {
+ rl_clear_history(&rl_ctx);
+ kfile_printf(fd, "Leaving interactive mode...\r\n");
+ interactive = FORCE_INTERACTIVE;
+ }
+ else
+ {
+ //TODO: remove sequence numbers
+ linebuf[0] = '0';
+ linebuf[1] = ' ';
+
+ strncpy(linebuf + 2, buf, sizeof(linebuf) - 3);
+ linebuf[sizeof(linebuf) - 1] = '\0';
+ protocol_parse(fd, linebuf);
+ }
+ }
+ }
+ }
+}
+
+/*
+ * Commands.
+ * TODO: Command declarations and definitions should be in another file(s).
+ * Maybe we should use CMD_HUNK_TEMPLATE.
+ *
+ */
+
+MAKE_CMD(ver, "", "ddd",
+({
+ args[1].l = VERS_MAJOR;
+ args[2].l = VERS_MINOR;
+ args[3].l = VERS_REV;
+ 0;
+}), 0);
+
+/* Sleep. Example of declaring function body directly in macro call. */
+MAKE_CMD(sleep, "d", "",
+({
+ timer_delay((mtime_t)args[1].l);
+ 0;
+}), 0)
+
+/* Ping. */
+MAKE_CMD(ping, "", "",
+({
+ //Silence "args not used" warning.
+ (void)args;
+ 0;
+}), 0)
+
+/* Dout */
+MAKE_CMD(dout, "d", "",
+({
+ sipo_putchar((uint8_t)args[1].l);
+
+ //Store status of dout ports.
+ reg_status_dout = (uint8_t)args[1].l;
+ 0;
+}), 0)
+
+/* rdout read the status of out ports.*/
+MAKE_CMD(rdout, "", "d",
+({
+ args[1].l = reg_status_dout;
+ 0;
+}), 0)
+
+
+/* Reset */
+MAKE_CMD(reset, "", "",
+({
+ //Silence "args not used" warning.
+ (void)args;
+ wdt_init(7);
+ wdt_start();
+
+ /*We want to have an infinite loop that lock access on watchdog timer.
+ This piece of code it's equivalent to a while(true), but we have done this because
+ gcc generate a warning message that suggest to use "noreturn" parameter in function reset.*/
+ ASSERT(args);
+ while(args);
+ 0;
+
+}), 0)
+
+/* Din */
+MAKE_CMD(din, "", "d",
+({
+ args[1].l = INPUT_GET();
+ 0;
+}), 0)
+
+
+
+/* Ain */
+MAKE_CMD(ain, "", ADC_FORMAT_STR,
+({
+ STATIC_ASSERT((sizeof(ADC_FORMAT_STR) - 1) == ADC_CHANNEL_NUM);
+ for(int i = 0; i < ADC_CHANNEL_NUM; i++)
+ args[i+1].l = adc_read_ai_channel(i);
+
+ 0;
+}), 0)
+
+/* Beep */
+MAKE_CMD(beep, "d", "",
+({
+ buz_beep(args[1].l);
+ 0;
+}), 0)
+
+/* Register commands. */
+static void protocol_registerCmds(void)
+{
+ REGISTER_CMD(ver);
+ REGISTER_CMD(sleep);
+ REGISTER_CMD(ping);
+ REGISTER_CMD(dout);
+ //Set off all dout ports.
+ reg_status_dout = 0;
+ REGISTER_CMD(rdout);
+ REGISTER_CMD(reset);
+ REGISTER_CMD(din);
+ REGISTER_CMD(ain);
+ REGISTER_CMD(beep);
+}
+
+/* Initialization: readline context, parser and register commands. */
+void protocol_init(KFile *fd)
+{
+ interactive = FORCE_INTERACTIVE;
+
+ rl_init_ctx(&rl_ctx);
+ //rl_setprompt(&rl_ctx, ">> ");
+ rl_sethook_get(&rl_ctx, (getc_hook)kfile_getc, fd);
+ rl_sethook_put(&rl_ctx, (putc_hook)kfile_putc, fd);
+ rl_sethook_match(&rl_ctx, parser_rl_match, NULL);
+ rl_sethook_clear(&rl_ctx, (clear_hook)kfile_clearerr,fd);
+
+ parser_init();
+
+ protocol_registerCmds();
+
+ protocol_prompt(fd);
+}
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
+ *
+ * -->
+ *
+ * \brief Implementation of the command protocol between the board and the host
+ *
+ * \version $Id$
+ *
+ * \author Marco Benelli <marco@develer.com>
+ */
+
+
+#ifndef PROTOCOL_H
+#define PROTOCOL_H
+
+#include <kern/kfile.h>
+
+void protocol_init(KFile *fd);
+void protocol_run(KFile *fd);
+
+#endif // PROTOOCOL_H
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2003, 2004, 2006, 2008 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
+ *
+ * -->
+ *
+ * \version $Id$
+ *
+ * \author Marco Benelli <marco@develer.com>
+ * \author Bernie Innocenti <bernie@codewiz.org>
+ * \author Daniele Basile <asterix@develer.com>
+ *
+ * \brief Windowing system test.
+ */
+
+
+#include "protocol.h"
+#include "hw/hw_input.h"
+#include "hw/hw_adc.h"
+#include "cfg/cfg_ser.h"
+
+#include <cfg/macros.h>
+
+#include <drv/timer.h>
+#include <drv/buzzer.h>
+#include <drv/ser.h>
+#include <drv/sipo.h>
+
+#include <mware/parser.h>
+#include <net/keytag.h>
+
+
+
+static Serial fd_ser;
+static Serial tag_ser;
+
+int main(void)
+{
+ /* SPI Port Initialization */
+ sipo_init();
+
+ kdbg_init();
+ timer_init();
+ adc_init();
+ buz_init();
+
+ IRQ_ENABLE;
+ INPUT_INIT;
+
+ /* Initialize Tag serial port and data structure */
+ TagPacket pkt;
+
+ /* Open the main communication port */
+ ser_init(&fd_ser, CONFIG_TRIFACE_PORT);
+ ser_setbaudrate(&fd_ser, CONFIG_TRIFACE_BAUDRATE);
+
+ ser_init(&tag_ser, TAG_SER_PORT);
+ ser_setbaudrate(&tag_ser, TAG_SER_BAUDRATE);
+
+ keytag_init(&pkt, &fd_ser.fd, &tag_ser.fd);
+
+ protocol_init(&fd_ser.fd);
+
+ // Main loop
+ for(;;)
+ {
+ protocol_run(&fd_ser.fd);
+ keytag_poll(&pkt);
+ }
+
+ return 0;
+}
+
+
--- /dev/null
+#
+# $Id$
+# Copyright 2006 Develer S.r.l. (http://www.develer.com/)
+# All rights reserved.
+#
+# Makefile fragment for DevLib triface application.
+#
+# Author: Bernie Innocenti <bernie@codewiz.org>
+#
+#
+
+# Set to 1 for debug builds
+triface_DEBUG = 1
+
+# Our target application
+TRG += triface
+
+triface_hfuse = 0x88
+triface_lfuse = 0xff
+triface_efuse = 0xff
+triface_lock = 0x2f
+triface_CSRC = \
+ examples/triface/triface.c \
+ examples/triface/protocol.c \
+ examples/triface/hw/hw_adc.c \
+ bertos/drv/timer.c \
+ bertos/drv/ser.c \
+ bertos/drv/buzzer.c \
+ bertos/cpu/avr/drv/ser_avr.c \
+ bertos/cpu/avr/drv/sipo.c \
+ bertos/mware/formatwr.c \
+ bertos/mware/hex.c \
+ bertos/struct/hashtable.c \
+ bertos/mware/readline.c \
+ bertos/mware/parser.c \
+ bertos/mware/event.c \
+ bertos/kern/kfile.c \
+ bertos/net/keytag.c \
+ #
+
+triface_PCSRC += bertos/mware/formatwr.c
+
+
+triface_CFLAGS = -O2 -D'ARCH=(ARCH_TRIFACE)' -fno-strict-aliasing -Iexamples/triface -Ibertos/cpu/avr
+triface_LDFLAGS = -Wl
+
+triface_MCU = atmega64
+triface_CROSS = avr-
+
+# Set to 1 for debug builds
+boot_DEBUG = 0
+
+# Our target application
+TRG += boot
+
+boot_MCU = atmega64
+boot_CSRC = \
+ examples/triface/boot/main.c \
+ bertos/net/xmodem.c \
+ bertos/drv/ser.c \
+ bertos/cpu/avr/drv/ser_avr.c \
+ bertos/cpu/avr/drv/flash_avr.c \
+ bertos/drv/timer.c \
+ bertos/algo/crc.c \
+ bertos/mware/hex.c \
+ bertos/kern/kfile.c \
+ #
+boot_CROSS = avr-
+boot_CPPFLAGS = -D'ARCH=(ARCH_TRIFACE|ARCH_BOOT)' -Iexamples/triface/boot -Ibertos/cpu/avr
+boot_CFLAGS = -Os -mcall-prologues
+boot_LDSCRIPT = examples/triface/boot/boot.ld
+boot_LDFLAGS = -Wl,--relax
--- /dev/null
+/**
+ * \file
+ * <!--
+ * This file is part of BeRTOS.
+ *
+ * Bertos 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 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program 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, write to the Free Software
+ * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
+ *
+ * As a special exception, you may use this file as part of a free software
+ * library without restriction. Specifically, if other files instantiate
+ * templates or use macros or inline functions from this file, or you compile
+ * this file and link it with other files to produce an executable, this
+ * file does not by itself cause the resulting executable to be covered by
+ * the GNU General Public License. This exception does not however
+ * invalidate any other reasons why the executable file might be covered by
+ * the GNU General Public License.
+ *
+ * Copyright 2003, 2004, 2006 Develer S.r.l. (http://www.develer.com/)
+ * Copyright 2000 Bernie Innocenti <bernie@codewiz.org>
+ *
+ * -->
+ *
+ * \version $Id$
+ *
+ * \author Bernie Innocenti <bernie@codewiz.org>
+ *
+ * \brief Declare application version strings
+ */
+
+#ifndef BERTOS_VERSTAG_H
+#define BERTOS_VERSTAG_H
+
+#ifndef CFG_ARCH_CONFIG_H
+ #include "cfg/cfg_arch.h"
+#endif
+
+#define APP_NAME "Triface"
+#define APP_DESCRIPTION "Trinity Interface Board"
+#define APP_AUTHOR "Develer"
+#define APP_COPYRIGHT "Copyright 2006, 2007, 2008, Develer (http://www.develer.com/)"
+
+#define VERS_MAJOR 2
+#define VERS_MINOR 1
+#define VERS_REV 0
+#define VERS_LETTER ""
+
+/**
+ * If _SNAPSHOT is defined, \c VERS_TAG contains the build date
+ * date instead of a numeric version string.
+ */
+//#define _SNAPSHOT
+
+#ifdef _DEBUG
+ #define VERS_DBG "D"
+#else
+ #define VERS_DBG ""
+#endif
+
+#define __STRINGIZE(x) #x
+#define _STRINGIZE(x) __STRINGIZE(x)
+
+/** Build application version string (i.e.: "1.7.0") */
+#define MAKE_VERS(maj,min,rev) _STRINGIZE(maj) "." _STRINGIZE(min) "." _STRINGIZE(rev) VERS_LETTER VERS_DBG
+#ifdef _SNAPSHOT
+ #define VERS_TAG "snapshot" " " __DATE__ " " __TIME__ " " VERS_LETTER " " VERS_DBG
+#else
+ #define VERS_TAG MAKE_VERS(VERS_MAJOR,VERS_MINOR,VERS_REV)
+#endif
+
+/** Build application version string suitable for MS windows resource files (i.e.: "1, 7, 0, 1") */
+#define MAKE_RCVERS(maj,min,rev,bld) _STRINGIZE(maj) ", " _STRINGIZE(min) ", " _STRINGIZE(rev) ", " _STRINGIZE(bld)
+#define RCVERSION_TAG MAKE_VERS(VERS_MAJOR,VERS_MINOR,VERS_REV)
+
+/** The revision string (contains VERS_TAG) */
+extern const char vers_tag[];
+
+/** Sequential build number (contains VERS_BUILD) */
+extern const int vers_build_nr;
+//extern const char vers_build_str[];
+
+/** Hostname of the machine used to build this binary (contains VERS_HOST) */
+extern const char vers_host[];
+
+#endif /* BERTOS_VERSTAG_H */