Merge git://github.com/r0ket/r0ket

This commit is contained in:
bernd 2011-07-19 10:47:52 +02:00
commit 95c92d764c
4 changed files with 105 additions and 2 deletions

View File

@ -42,6 +42,22 @@ LIBFILE=lib$(LIBNAME).a
all: $(LIBFILE)
ifeq "$(APP)" "loadable"
ifndef LAPP
LAPP=blinktest
endif
LSRC=../loadable/$(LAPP).c
LOBJ=loadable_$(LAPP).o
.PHONY: $(LOBJ)
$(LOBJ):
$(CC) $(CFLAGS) -o $@ $(LSRC)
$(RM) $(LIBFILE)
OBJS += $(LOBJ)
endif
$(LIBFILE): $(OBJS) $(WRAPOBJ)
$(AR) rcs $@ $(OBJS) $(WRAPOBJ)

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
loadable_*) 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
loadable_*) continue;;
esac
base=${a%.o}
echo "main_$base();"
done
@ -19,6 +25,9 @@ echo "}"
echo "void tick_wrapper(void){"
for a in $* ; do
case $a in
loadable_*) continue;;
esac
base=${a%.o}
grep -q \ tick_$base ${base}.c && echo "tick_$base();"
done

View File

@ -6,7 +6,7 @@
#include "filesystem/ff.h"
//const uint32_t key[4] = {0xFFFF, 0xFFFF, 0xFFFF, 0xFFFF};
const uint32_t key[4] = { 0xB4595344,0xD3E119B6,0xA814D0EC,0xEFF5A24E };
const uint32_t openbeaconkey[4] = { 0xB4595344,0xD3E119B6,0xA814D0EC,0xEFF5A24E };
const uint8_t useencryption = 1;
const uint8_t mac[5] = {1,2,3,2,1};
@ -83,7 +83,7 @@ uint8_t openbeaconSendPacket(uint32_t id, uint32_t seq,
buf[12]=0xff; // salt (0xffff always?)
buf[13]=0xff;
return nrf_snd_pkt_crc_encr(16,buf,useencryption?key:NULL);
return nrf_snd_pkt_crc_encr(16,buf,useencryption?openbeaconkey:NULL);
}
uint8_t openbeaconSend(void)