Merge branch 'master' of github.com:r0ket/r0ket

This commit is contained in:
kiu 2011-07-24 03:32:20 +02:00
commit cd1d43883d
8 changed files with 439 additions and 0 deletions

1
firmware/applications/.gitignore vendored Normal file
View File

@ -0,0 +1 @@
*.gen

View File

@ -58,6 +58,22 @@ $(LOBJ):
OBJS += $(LOBJ)
endif
ifeq "$(APP)" "tester"
TSRCS = $(wildcard $(APP)/*.c)
TOBJS = $(foreach mod,$(TSRCS),$(subst .c,.o,$(mod)))
TWRAP=tester.gen
.PHONY: $(TWRAP)
$(APP).o: $(TWRAP)
$(TWRAP):
./mktester $(TSRCS) > $@
OBJS += $(TOBJS)
endif
$(LIBFILE): $(OBJS) $(WRAPOBJ)
$(AR) rcs $@ $(OBJS) $(WRAPOBJ)

View File

@ -3,6 +3,7 @@
for a in $* ; do
case $a in
loadable_*) continue;;
*/*) continue;;
esac
base=${a%.o}
echo "void main_$base(void);"
@ -15,6 +16,7 @@ echo "void wrapper(void){"
for a in $* ; do
case $a in
loadable_*) continue;;
*/*) continue;;
esac
base=${a%.o}
echo "main_$base();"
@ -27,6 +29,7 @@ echo "void tick_wrapper(void){"
for a in $* ; do
case $a in
loadable_*) continue;;
*/*) continue;;
esac
base=${a%.o}
grep -q \ tick_$base ${base}.c && echo "tick_$base();"

View File

@ -0,0 +1,31 @@
#include <sysinit.h>
#include "basic/basic.h"
#include "lcd/print.h"
#include <string.h>
/**************************************************************************/
#include "tester.gen"
static const struct MENU mainmenu = {"Mainmenu", mentry};
void main_tester(void) {
handleMenu(&mainmenu);
gotoISP();
};
void no_tick_tester(void){
static int foo=0;
static int toggle=0;
if(foo++>80){
toggle=1-toggle;
foo=0;
gpioSetValue (RB_LED0, toggle);
};
return;
};

View File

@ -0,0 +1,129 @@
#include <sysinit.h>
#include "basic/basic.h"
#include "lcd/lcd.h"
#include "lcd/print.h"
#include "lcd/allfonts.h"
#include "filesystem/ff.h"
#include "filesystem/select.h"
#include "funk/nrf24l01p.h"
#include "usb/usbmsc.h"
#include <string.h>
/**************************************************************************/
#define MAXNICK 20
char nickname[MAXNICK];
void nick_init(void){
FIL file[2]; /* File objects */
UINT readbytes;
int res;
res=f_open(&file[0], "nick.cfg", FA_OPEN_EXISTING|FA_READ);
lcdPrint("open:");
lcdPrintln(f_get_rc_string(res));
if(res){
lcdPrintln("no nick.cfg...");
return;
};
res = f_read(&file[0], nickname, MAXNICK-1, &readbytes);
lcdPrint("read:");
lcdPrintln(f_get_rc_string(res));
if(res){
return;
};
nickname[MAXNICK-1]=0;
// truncate at newline (or other control chars)
for(int i=0;i<MAXNICK;i++){
if(nickname[i]<32)nickname[i]=0;
};
lcdPrint("<");
lcdPrint(nickname);
lcdPrint(">");
lcdNl();
res=f_close(&file[0]);
lcdPrint("close:");
lcdPrintln(f_get_rc_string(res));
if(res){
return;
};
lcdPrintln("Done.");
};
char fontname[15];
void f_nick(void){
static char ctr=0;
char key;
static signed char x=10;
static signed char y=10;
while (1) {
lcdClear();
lcdFill(255);
setExtFont(fontname);
DoString(x,y,nickname);
setIntFont(&Font_7x8);
lcdSetCrsr(50,50);
lcdPrintInt(x);
lcdPrint("x");
lcdPrintInt(y);
lcdDisplay();
__asm volatile ("WFI");
__asm volatile ("WFI");
__asm volatile ("WFI");
__asm volatile ("WFI");
key= getInputRaw();
if(key & BTN_UP){
--y;//if(--y<0) y=0;
};
if (key & BTN_DOWN){
++y;//if(++y>=RESY) y=RESY-1;
};
if (key & BTN_LEFT){
--x;//if(--x<0) x=0;
};
if (key & BTN_RIGHT){
++x;//if(++x>=RESX) x=RESX-1;
};
if (key == BTN_ENTER){
lcdClear();
lcdPrintln("Done.");
lcdDisplay();
ctr++;
break;
};
};
};
void f_font(void){
if( selectFile(fontname,"F0N") != 0){
lcdPrintln("No file selected.");
return;
};
lcdClear();
lcdPrintln(fontname);
setExtFont(fontname);
lcdPrintln("PUabc€");
setIntFont(&Font_7x8);
lcdPrintln("done.");
lcdDisplay();
while(!getInputRaw())delayms(10);
};

View File

@ -0,0 +1,166 @@
#include <sysinit.h>
#include "basic/basic.h"
#include "lcd/lcd.h"
#include "lcd/print.h"
#include "funk/nrf24l01p.h"
#include <string.h>
#include "funk/rftransfer.h"
#include "funk/openbeacon.h"
/**************************************************************************/
#define BEACON_CHANNEL 81
#define BEACON_MAC "\x1\x2\x3\x2\1"
uint32_t const testkey[4] = {
0xB4595344,0xD3E119B6,0xA814D0EC,0xEFF5A24E
};
int enctoggle=0;
void f_init(void){
nrf_init();
struct NRF_CFG config = {
.channel= BEACON_CHANNEL,
.txmac= BEACON_MAC,
.nrmacs=1,
.mac0= BEACON_MAC,
.maclen ="\x10",
};
nrf_config_set(&config);
lcdPrintln("Done.");
};
void f_status(void){
int dx=0;
int dy=8;
uint8_t buf[4];
buf[0]=C_R_REGISTER | R_CONFIG;
buf[1]=0;
buf[2]=0;
buf[3]=0;
dx=DoString(0,dy,"S:");
dx=DoCharX(dx,dy,buf[0]);
dx=DoCharX(dx,dy,buf[1]);
dx=DoCharX(dx,dy,buf[2]);
dx=DoCharX(dx,dy,buf[3]);
dy+=8;
nrf_cmd_rw_long(buf,2);
dx=DoString(0,dy,"R:");
dx=DoCharX(dx,dy,buf[0]);
dx=DoCharX(dx,dy,buf[1]);
dx=DoCharX(dx,dy,buf[2]);
dx=DoCharX(dx,dy,buf[3]);
dy+=8;
int status=nrf_cmd_status(C_NOP);
dx=DoString(0,dy,"St:"); DoCharX(dx,dy,status);dy+=8;
};
void f_recv(void){
__attribute__ ((aligned (4))) uint8_t buf[32];
int len;
do{
lcdClear();
len=nrf_rcv_pkt_time_encr(1000,sizeof(buf),buf,enctoggle?testkey:NULL);
if(len==0){
lcdPrintln("No pkt (Timeout)");
};
lcdPrint("Size:");lcdPrintInt(len);lcdNl();
lcdPrint("1:");lcdPrintIntHex( *(int*)(buf+ 0) ); lcdNl();
lcdPrint("2:");lcdPrintIntHex( *(int*)(buf+ 4) ); lcdNl();
lcdPrint("3:");lcdPrintIntHex( *(int*)(buf+ 8) ); lcdNl();
lcdPrint("4:");lcdPrintIntHex( *(int*)(buf+12) ); lcdNl();
len=crc16(buf,14);
lcdPrint("crc:");lcdPrintShortHex(len); lcdNl();
lcdDisplay();
}while ((getInputRaw())==BTN_NONE);
};
void f_cfg(void){
struct NRF_CFG config;
nrfconfig cfg=&config;
nrf_config_get(cfg);
lcdPrint("ch:");lcdPrintInt( cfg->channel ); lcdNl();
lcdPrint("nr:");lcdPrintInt( cfg->nrmacs ); lcdNl();
lcdPrint("0:");
lcdPrintCharHex(cfg->mac0[0]);
lcdPrintCharHex(cfg->mac0[1]);
lcdPrintCharHex(cfg->mac0[2]);
lcdPrintCharHex(cfg->mac0[3]);
lcdPrintCharHex(cfg->mac0[4]);
lcdNl();
lcdPrint("1:");
lcdPrintCharHex(cfg->mac1[0]);
lcdPrintCharHex(cfg->mac1[1]);
lcdPrintCharHex(cfg->mac1[2]);
lcdPrintCharHex(cfg->mac1[3]);
lcdPrintCharHex(cfg->mac1[4]);
lcdNl();
lcdPrint("2345:");
lcdPrintCharHex(cfg->mac2345[0]);
lcdPrintCharHex(cfg->mac2345[1]);
lcdPrintCharHex(cfg->mac2345[2]);
lcdPrintCharHex(cfg->mac2345[3]);
lcdNl();
lcdPrint("tx:");
lcdPrintCharHex(cfg->txmac[0]);
lcdPrintCharHex(cfg->txmac[1]);
lcdPrintCharHex(cfg->txmac[2]);
lcdPrintCharHex(cfg->txmac[3]);
lcdPrintCharHex(cfg->txmac[4]);
lcdNl();
lcdPrint("len:");
lcdPrintCharHex(cfg->maclen[0]);
lcdPrintCharHex(cfg->maclen[1]);
lcdPrintCharHex(cfg->maclen[2]);
lcdPrintCharHex(cfg->maclen[3]);
lcdPrintCharHex(cfg->maclen[4]);
lcdNl();
};
void f_cfg_set(void){
struct NRF_CFG config = {
.channel= 13,
.txmac= "R0KET",
.nrmacs=1,
.mac0= "R0KET",
.maclen ="\x10",
};
nrf_config_set(&config);
};
void f_enctog(void){
enctoggle=1-enctoggle;
if(enctoggle)
lcdPrintln("Encrypt ON!");
else
lcdPrintln("encrypt off!");
};
void f_send(void){
uint8_t status;
status = openbeaconSend();
lcdPrint("Status:");
lcdPrintCharHex(status);
lcdNl();
};

View File

@ -0,0 +1,67 @@
#include <sysinit.h>
#include "basic/basic.h"
#include "lcd/lcd.h"
#include "lcd/print.h"
#include "lcd/allfonts.h"
#include "filesystem/ff.h"
#include "filesystem/select.h"
#include "funk/nrf24l01p.h"
#include "usb/usbmsc.h"
#include <string.h>
/**************************************************************************/
void adc_light(void) {
int dx=0;
int dy=8;
dx=DoString(0,dy,"Light:");
DoString(0,dy+8,"Night:");
while ((getInputRaw())==BTN_NONE){
DoInt(dx,dy,GetLight());
DoInt(dx,dy+8,isNight());
lcdDisplay();
};
dy+=8;
dx=DoString(0,dy,"Done.");
};
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();
};

View File

@ -0,0 +1,26 @@
#include <sysinit.h>
#include "basic/basic.h"
#include "lcd/lcd.h"
#include "lcd/print.h"
#include "funk/nrf24l01p.h"
#include <string.h>
#include "funk/rftransfer.h"
#include "funk/openbeacon.h"
#include "core/iap/iap.h"
/**************************************************************************/
void f_uuid(void) {
IAP_return_t iap_return;
iap_return = iapReadSerialNumber();
lcdPrintIntHex(iap_return.Result[0]); lcdNl();
lcdPrintIntHex(iap_return.Result[1]); lcdNl();
lcdPrintIntHex(iap_return.Result[2]); lcdNl();
lcdPrintIntHex(iap_return.Result[3]); lcdNl();
}