From 06b5a2903d2dfe00d2340a93c369e6d61465caad Mon Sep 17 00:00:00 2001 From: bsongis Date: Tue, 12 Jun 2012 18:29:56 +0000 Subject: [PATCH] It now runs inside an RTOS task! Still a lot to do, but it's a good start! --- src/Makefile | 25 +++++--------- src/board_ersky9x.h | 7 +--- src/ersky9x/board.h | 48 +++++++++++++++++++++++++++ src/ersky9x/board_lowlevel.c | 2 +- src/ersky9x/chip.h | 64 +++++++++++++++++------------------- src/ersky9x/vectors_sam3s.c | 5 ++- src/open9x.cpp | 8 ----- 7 files changed, 90 insertions(+), 69 deletions(-) create mode 100644 src/ersky9x/board.h diff --git a/src/Makefile b/src/Makefile index 2bec50016..fdebad422 100644 --- a/src/Makefile +++ b/src/Makefile @@ -192,6 +192,7 @@ FORMAT = ihex TARGET = open9x # List C++ source files here. (C dependencies are automatically generated.) +SRC = CPPSRC = open9x.cpp $(PULSESSRC) stamp.cpp menus.cpp model_menus.cpp general_menus.cpp main_views.cpp statistics_views.cpp $(EEPROMSRC) lcd.cpp drivers.cpp translations.cpp ifeq ($(EXT), JETI) @@ -324,7 +325,8 @@ ifeq ($(PCB), ARM) CPPDEFS += -DPCBARM -DAUDIO -DHAPTIC -DPXX -DDSM2 -DDSM2_PPM EXTRAINCDIRS += ersky9x CoOS/kernel CoOS/portable BOARDSRC = board_ersky9x.cpp - EXTRABOARDSRC = ersky9x/core_cm3.c ersky9x/board_lowlevel.c ersky9x/crt.c ersky9x/vectors_sam3s.c + SRC += ersky9x/core_cm3.c ersky9x/board_lowlevel.c ersky9x/crt.c ersky9x/vectors_sam3s.c + SRC += CoOS/kernel/core.c CoOS/kernel/hook.c CoOS/kernel/task.c CoOS/kernel/event.c CoOS/kernel/time.c CoOS/kernel/timer.c CoOS/kernel/serviceReq.c CoOS/portable/GCC/port.c CoOS/portable/arch.c CPPSRC += ersky9x/ff.cpp ersky9x/diskio.cpp ersky9x/gtime.cpp EEPROMSRC = eeprom_arm.cpp PULSESSRC = pulses_arm.cpp @@ -674,25 +676,14 @@ remallsrc: # Link: create ELF output file from object files. ifeq ($(PCB), ARM) -%.elf: allsrc.cpp +%.o: %.c + $(CC) $(ALL_CPPFLAGS) $< -o $@ +OBJS = $(SRC:.c=.o) +%.elf: allsrc.cpp $(OBJS) @echo @echo $(MSG_COMPILING) $@ - $(CC) $(ALL_CPPFLAGS) CoOS/kernel/core.c -o core.o - $(CC) $(ALL_CPPFLAGS) CoOS/kernel/hook.c -o hook.o - $(CC) $(ALL_CPPFLAGS) CoOS/kernel/task.c -o task.o - #$(CC) $(ALL_CPPFLAGS) CoOS/kernel/mutex.c -o mutex.o - #$(CC) $(ALL_CPPFLAGS) CoOS/kernel/sem.c -o sem.o - #$(CC) $(ALL_CPPFLAGS) CoOS/kernel/queue.c -o queue.o - #$(CC) $(ALL_CPPFLAGS) CoOS/kernel/mbox.c -o mbox.o - #$(CC) $(ALL_CPPFLAGS) CoOS/kernel/flag.c -o flag.o - $(CC) $(ALL_CPPFLAGS) CoOS/kernel/event.c -o event.o - $(CC) $(ALL_CPPFLAGS) CoOS/kernel/time.c -o time.o - $(CC) $(ALL_CPPFLAGS) CoOS/kernel/timer.c -o timer.o - $(CC) $(ALL_CPPFLAGS) CoOS/kernel/serviceReq.c -o serviceReq.o - $(CC) $(ALL_CPPFLAGS) CoOS/portable/GCC/port.c -o port.o - $(CC) $(ALL_CPPFLAGS) CoOS/portable/arch.c -o arch.o $(CC) $(ALL_CPPFLAGS) $< -o allsrc.o - $(CC) allsrc.o core.o hook.o task.o event.o time.o timer.o serviceReq.o port.o arch.o -mcpu=cortex-m3 -mthumb -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref,--no-warn-mismatch -o $@ + $(CC) allsrc.o $(OBJS) -mcpu=cortex-m3 -mthumb -nostartfiles -T$(LDSCRIPT) -Wl,-Map=$(TARGET).map,--cref,--no-warn-mismatch -o $@ else %.elf: allsrc.cpp @echo diff --git a/src/board_ersky9x.h b/src/board_ersky9x.h index 5585511e6..77816198c 100644 --- a/src/board_ersky9x.h +++ b/src/board_ersky9x.h @@ -34,12 +34,7 @@ #ifndef board_ersky9x_h #define board_ersky9x_h -#ifdef REVA -#include "ersky9x/AT91SAM3S2.h" -#else -#include "ersky9x/AT91SAM3S4.h" -#endif - +#include "ersky9x/board.h" #include "ersky9x/sound_driver.h" #include "ersky9x/haptic_driver.h" #include "ersky9x/sdcard_driver.h" diff --git a/src/ersky9x/board.h b/src/ersky9x/board.h new file mode 100644 index 000000000..469531d2a --- /dev/null +++ b/src/ersky9x/board.h @@ -0,0 +1,48 @@ +/* + * Authors (alphabetical order) + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer + * + * open9x is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ + * + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. + * + * 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. + * + */ + +#ifndef board_h +#define board_h + +#include +#include + +#ifdef REVA +#include "AT91SAM3S2.h" +#else +#include "chip.h" +#include "AT91SAM3S4.h" +#endif + +#endif + diff --git a/src/ersky9x/board_lowlevel.c b/src/ersky9x/board_lowlevel.c index 1634cba95..a97fde941 100644 --- a/src/ersky9x/board_lowlevel.c +++ b/src/ersky9x/board_lowlevel.c @@ -39,7 +39,7 @@ * Headers *----------------------------------------------------------------------------*/ -//#include "board.h" +#include "board.h" /*---------------------------------------------------------------------------- * Local definitions diff --git a/src/ersky9x/chip.h b/src/ersky9x/chip.h index d216db6d1..2b4606f90 100644 --- a/src/ersky9x/chip.h +++ b/src/ersky9x/chip.h @@ -1,30 +1,34 @@ -/* ---------------------------------------------------------------------------- - * ATMEL Microcontroller Software Support - * ---------------------------------------------------------------------------- - * Copyright (c) 2008, Atmel Corporation +/* + * Authors (alphabetical order) + * - Bertrand Songis + * - Bryan J. Rentoul (Gruvin) + * - Cameron Weeks + * - Erez Raviv + * - Jean-Pierre Parisy + * - Karl Szmutny + * - Michael Blandford + * - Michal Hlavinka + * - Pat Mackenzie + * - Philip Moss + * - Rob Thomson + * - Romolo Manfredini + * - Thomas Husterer * - * All rights reserved. + * open9x is based on code named + * gruvin9x by Bryan J. Rentoul: http://code.google.com/p/gruvin9x/, + * er9x by Erez Raviv: http://code.google.com/p/er9x/, + * and the original (and ongoing) project by + * Thomas Husterer, th9x: http://code.google.com/p/th9x/ * - * Redistribution and use in source and binary forms, with or without - * modification, are permitted provided that the following conditions are met: + * This program is free software; you can redistribute it and/or modify + * it under the terms of the GNU General Public License version 2 as + * published by the Free Software Foundation. * - * - Redistributions of source code must retain the above copyright notice, - * this list of conditions and the disclaimer below. + * 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. * - * Atmel's name may not be used to endorse or promote products derived from - * this software without specific prior written permission. - * - * DISCLAIMER: THIS SOFTWARE IS PROVIDED BY ATMEL "AS IS" AND ANY EXPRESS OR - * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF - * MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NON-INFRINGEMENT ARE - * DISCLAIMED. IN NO EVENT SHALL ATMEL BE LIABLE FOR ANY DIRECT, INDIRECT, - * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, - * OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF - * LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING - * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, - * EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. - * ---------------------------------------------------------------------------- */ //------------------------------------------------------------------------------ @@ -39,16 +43,8 @@ /// -# For misc, see "AT91SAM3S4 - Misc". //------------------------------------------------------------------------------ -#ifndef CHIP_H -#define CHIP_H - -//------------------------------------------------------------------------------ -// Headers -//------------------------------------------------------------------------------ - -//------------------------------------------------------------------------------ -// Definitions -//------------------------------------------------------------------------------ +#ifndef chip_h +#define chip_h //------------------------------------------------------------------------------ /// \page "AT91SAM3S4 - ARM core features" @@ -126,5 +122,5 @@ //Misc -#endif //#ifndef CHIP_H +#endif //#ifndef chip_h diff --git a/src/ersky9x/vectors_sam3s.c b/src/ersky9x/vectors_sam3s.c index 8287363c0..680d01c63 100644 --- a/src/ersky9x/vectors_sam3s.c +++ b/src/ersky9x/vectors_sam3s.c @@ -51,9 +51,8 @@ void BusFault_Handler (void) __attribute__((weak)); void UsageFault_Handler (void) __attribute__((weak)); void SVC_Handler (void) __attribute__((weak)); void DebugMon_Handler (void) __attribute__((weak)); -extern void PendSV_Handler (void) __attribute__((weak)); -extern void SysTick_Handler (void) __attribute__((weak)); - +void PendSV_Handler(void) __attribute__((weak)); +void SysTick_Handler (void) __attribute__((weak)); void SUPC_IRQHandler (void) __attribute__((weak)); void RSTC_IRQHandler (void) __attribute__((weak)); void RTC_IRQHandler (void) __attribute__((weak)); diff --git a/src/open9x.cpp b/src/open9x.cpp index 25f6b78b3..295686d8c 100644 --- a/src/open9x.cpp +++ b/src/open9x.cpp @@ -2661,7 +2661,6 @@ OS_STK uartprintf_stk[1024]; extern "C" { void vMainTask(void *) { - alert("START", "START"); while(1) { #if defined(PCBARM) @@ -2858,16 +2857,9 @@ int main(void) uint8_t shutdown_state = 0; #endif if ((shutdown_state=check_soft_power()) <= e_power_trainer) { - alert("COOS", "START"); CoInitOS(); - alert("COOS", "INIT"); - //xTaskHandle taskHandle; - //xTaskCreate ((pdTASK_CODE)&vMainTask, (const signed portCHAR * const) "Main", 2048, NULL, (tskIDLE_PRIORITY + 1), &taskHandle); - //vTaskStartScheduler (); uartprintfTask = CoCreateTask(vMainTask,NULL,0,&uartprintf_stk[1023],100); - alert("COOS", "TASK"); CoStartOS(); - alert("COOS", "FIN"); } #if defined(PCBARM) || defined(PCBV4)