Add APP=loadable, simple loadable module wrapper to run them as app.

Build with "make APP=loadable LAPP=spaceinvaders"
This commit is contained in:
Stefan `Sec` Zehl 2011-07-19 10:01:00 +02:00
parent c5e8b92c4a
commit 6a8da54274
3 changed files with 91 additions and 0 deletions

View File

@ -21,6 +21,13 @@ endif
OBJS += $(ME_OBJ).o
endif
ifeq "$(APP)" "loadable"
ifndef LAPP
LAPP=blinktest
endif
OBJS += ../loadable/$(LAPP).o
endif
WRAP=wrapper
LIBNAME=app

View File

@ -0,0 +1,78 @@
#include <sysinit.h>
#include <string.h>
#include "basic/basic.h"
#include "lcd/lcd.h"
#include "lcd/print.h"
#include "usb/usbmsc.h"
/**************************************************************************/
void gotoISP(void) {
DoString(0,0,"Enter ISP!");
lcdDisplay();
ISPandReset();
}
void lcd_mirror(void) {
lcdToggleFlag(LCD_MIRRORX);
};
void lcd_invert(void) {
lcdToggleFlag(LCD_INVERTED);
};
void adc_check(void) {
int dx=0;
int dy=8;
// Print Voltage
dx=DoString(0,dy,"Voltage:");
while ((getInputRaw())==BTN_NONE){
DoInt(dx,dy,GetVoltage());
lcdDisplay();
};
dy+=8;
dx=DoString(0,dy,"Done.");
};
void msc_menu(void){
DoString(0,8,"MSC Enabled.");
lcdDisplay();
usbMSCInit();
while(!getInputRaw())delayms(10);
DoString(0,16,"MSC Disabled.");
usbMSCOff();
};
extern void (*ram)(void);
const struct MENU_DEF menu_ISP = {"Invoke ISP", &gotoISP};
const struct MENU_DEF menu_again = {"Run Loadable", &ram};
const struct MENU_DEF menu_nop = {"---", NULL};
const struct MENU_DEF menu_msc = {"MSC", &msc_menu};
const struct MENU_DEF menu_volt = {"Akku", &adc_check};
const struct MENU_DEF menu_mirror = {"Mirror", &lcd_mirror};
const struct MENU_DEF menu_invert = {"Invert", &lcd_invert};
static menuentry menu[] = {
&menu_again,
&menu_ISP,
&menu_nop,
&menu_msc,
&menu_mirror,
&menu_invert,
&menu_volt,
NULL,
};
static const struct MENU mainmenu = {"Mainmenu", menu};
/**************************************************************************/
void main_loadable(void) {
lcdFill(0); // clear display buffer
lcdDisplay();
handleMenu(&mainmenu);
gotoISP();
};

View File

@ -1,6 +1,9 @@
#!/bin/sh
for a in $* ; do
case $a in
*/*) continue;;
esac
base=${a%.o}
echo "void main_$base(void);"
echo "void tick_$base(void);"
@ -10,6 +13,9 @@ echo
echo "void wrapper(void){"
for a in $* ; do
case $a in
*/*) continue;;
esac
base=${a%.o}
echo "main_$base();"
done