Skip to content
Permalink
Browse files

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

Conflicts:
	firmware/filesystem/select.c
	firmware/l0dable/Makefile
  • Loading branch information...
penma committed Feb 7, 2012
2 parents 0d62813 + 3e67b6b commit 8ac335b1d74cec94903b6ed65cd04392525064ce
Showing with 1,906 additions and 387 deletions.
  1. +3 −2 firmware/.gitignore
  2. +4 −4 firmware/Makefile
  3. +1 −1 firmware/Makefile.inc
  4. +11 −2 firmware/README.building
  5. +6 −0 firmware/applications/final/mesh.c
  6. +1 −1 firmware/basic/basic.c
  7. +2 −2 firmware/basic/basic.h
  8. +1 −0 firmware/basic/ecc.h
  9. +25 −9 firmware/basic/voltage.c
  10. 0 firmware/core/libc/stdio.c
  11. +5 −0 firmware/core/libc/string.c
  12. +2 −10 firmware/core/sysdefs.h
  13. +40 −16 firmware/funk/mesh.c
  14. +1 −3 firmware/funk/openbeacon.c
  15. +1 −1 firmware/l0dable/1boot.c
  16. +1 −1 firmware/l0dable/EXPORTS
  17. +9 −2 firmware/l0dable/Makefile
  18. +9 −0 firmware/l0dable/dbgmesh.c
  19. +10 −0 firmware/l0dable/help/memcpy.c
  20. +3 −1 firmware/l0dable/jeopardy.c
  21. +1 −1 firmware/l0dable/jump.c
  22. +7 −0 firmware/l0dable/mktable.pl
  23. +169 −0 firmware/l0dable/nick_w0rpcore.c
  24. +2 −1 firmware/l0dable/nick_work.c
  25. +1 −1 firmware/l0dable/people.c
  26. +4 −1 firmware/l0dable/pongo.c
  27. +6 −6 firmware/l0dable/r_player.c
  28. +1 −1 firmware/l0dable/scope.c
  29. +322 −0 firmware/l0dable/snake.c
  30. +0 −194 firmware/l0dable/snake.c.disabled
  31. +3 −3 firmware/l0dable/system-include-hack.h
  32. +106 −0 firmware/l0dable/tron.c
  33. +93 −23 firmware/l0dable/voltage.c
  34. +48 −20 firmware/lcd/display.c
  35. +5 −2 firmware/main.c
  36. +10 −4 firmware/release-all
  37. +3 −12 firmware/sysdefs.h
  38. +118 −0 tools/mesh/beacontrace.pl
  39. +177 −58 tools/mesh/dbg.pl
  40. +63 −0 tools/mesh/meshtrace.pl
  41. +345 −0 tools/mesh/r0ket.pm
  42. +266 −0 tools/mesh/rf
  43. +2 −0 tools/smartflash/.gitignore
  44. +19 −5 tools/smartflash/Makefile
@@ -1,5 +1,6 @@
firmware.bin
firmware.elf
*.bin
*.elf
*.map
lpc1xxx/memory.ld
applications/wrapper.c
lcd/allfonts.h
@@ -37,13 +37,13 @@ ifdef APP
OUTFILE=$(APP)
endif

LDFLAGS+= -Wl,--gc-sections
LDFLAGS+= --gc-sections
OBJS += lpc1xxx/$(TARGET)_handlers.o lpc1xxx/LPC1xxx_startup.o

##########################################################################
# Startup files
##########################################################################
LDLIBS = -lm
LDLIBS =
LDLIBS += -Lapplications -lapp
LDLIBS += -Lfunk -lfunk
LDLIBS += -Lusbcdc -lusbcdc
@@ -74,7 +74,7 @@ l0dables: table.c
@cd l0dable && $(MAKE)

clean:
rm -f $(OBJS) $(LD_TEMP) $(OUTFILE).elf $(OUTFILE).bin $(OUTFILE).hex table.c table.h
rm -f $(OBJS) $(LD_TEMP) $(OUTFILE).elf $(OUTFILE).bin $(OUTFILE).hex $(OUTFILE).map table.c table.h
for dir in $(SUBDIRS); do \
$(MAKE) $(CONFIG_MAKE_PRINTDIRECTORY) -C $$dir clean; \
done
@@ -111,7 +111,7 @@ $(LD_TEMP):
-@echo "INCLUDE $(LD_SCRIPT)" >> $(LD_TEMP)

$(OUTFILE).elf: $(OBJS) $(SYS_OBJS) $(SUBDIRS) $(LPCFIX) $(LD_TEMP)
$(CC) $(LDFLAGS) -T $(LD_TEMP) -o $(OUTFILE).elf $(OBJS) $(LDLIBS)
$(LD) $(LDFLAGS) -Map=$(OUTFILE).map -T $(LD_TEMP) -o $(OUTFILE).elf $(OBJS) $(LDLIBS)
-@echo ""
$(SIZE) $(OUTFILE).elf
-@echo ""
@@ -42,7 +42,7 @@ CPU_TYPE = cortex-$(CORTEX_TYPE)
# Compiler settings, parameters and flags
##########################################################################

CFLAGS = -std=c99 -c -g -Os $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -DTARGET=$(TARGET) -DRAMCODE=$(RAMCODE) -fno-builtin -Wno-unused-function
CFLAGS = -std=c99 -c -g -Os $(INCLUDE_PATHS) -Wall -mthumb -ffunction-sections -fdata-sections -fmessage-length=0 -mcpu=$(CPU_TYPE) -DTARGET=$(TARGET) -DRAMCODE=$(RAMCODE) -fno-builtin -Wno-unused-function -ffreestanding
LDFLAGS = -nostartfiles

ifeq "$(USBSERIAL)" "YES"
@@ -1,4 +1,13 @@
make flags supported by this Makefile
### A note on the compiler
We are currently using the CodeSourcery gcc (see wiki for link).
You can also use a standard arm cross-gcc
(https://github.com/esden/summon-arm-toolchain)
but please note that this creates larger binaries.
We are talking about 100-200 bytes for firmware.bin,
you will run into space problems with the default firmware.
Sorry about that.

### Make flags supported by this Makefile

APP=<foo>
- builds "application" foo (check <foo>.c and the <foo> subdir in applications/)
@@ -28,5 +37,5 @@ make APP=l0dable LAPP=<l0dablename> (=l0dable.bin)
# build all l0dables
make l0dables

#build one l0dable
# build one l0dable
cd l0dables && make <l0dablename>.c0d
@@ -186,6 +186,9 @@ void m_choose(){
case('r'):
strcpy(p,"r0type");
break;
case('s'):
strcpy(p,"Snake");
break;
#endif
default:
p[0]=*mm;
@@ -233,6 +236,9 @@ void m_choose(){
case('r'):
strcpy(p,"r0type");
break;
case('s'):
strcpy(p,"Snake");
break;
#endif
};
if(tmm[i]>='a' && tmm[i]<='z'){
@@ -18,7 +18,7 @@ void rbInit() {
gpioSetDir(USB_CONNECT, gpioDirection_Output);
gpioSetValue(USB_CONNECT, 1);

uint8_t ports[] = { RB_BTN0, RB_BTN1, RB_BTN2, RB_BTN3, RB_BTN4,
static uint8_t ports[] = { RB_BTN0, RB_BTN1, RB_BTN2, RB_BTN3, RB_BTN4,
RB_LED0, RB_LED1, RB_LED2,
RB_SPI_SS0, RB_SPI_SS1, RB_SPI_SS2,
RB_SPI_SS3, RB_SPI_SS4, RB_SPI_SS5,
@@ -171,12 +171,12 @@ uint16_t crc16(uint8_t * buf, int len);
// menu.c

struct MENU_DEF {
char *text;
const char *text;
void (*callback)(void);
};

struct MENU {
char *title;
const char *title;
struct MENU_DEF entries[];
};

@@ -1,5 +1,6 @@
#ifndef _ECC_H_
#define _ECC_H_H
#include <sysdefs.h>
#include <stdint.h>

/******************************************************************************/
@@ -3,29 +3,45 @@
#include "basic/basic.h"
#include "funk/nrf24l01p.h"

static uint32_t results=5000;
#define VOLTAGE_SAMPLES 8
static uint32_t voltage=5000*VOLTAGE_SAMPLES;
static uint8_t chrg=1;

void VoltageCheck(void){

uint32_t v;
chrg=gpioGetValue(RB_PWR_CHRG);
//slow down the adc for our high impedance voltage devider
ADC_AD0CR = ((CFG_CPU_CCLK / SCB_SYSAHBCLKDIV) / 100000 - 1 ) << 8;
v = adcRead(1);
//speed it up again
ADC_AD0CR = ((CFG_CPU_CCLK / SCB_SYSAHBCLKDIV) / 1000000 - 1 ) << 8;

v *= 10560;
v /= 1024;

//add the drop over the voltage switch
v += 50;

voltage -= voltage/VOLTAGE_SAMPLES;
voltage += v;

results = adcRead(1);
results *= 10560;
results /= 1024;
results += 50;
if( results < 3500 ){
//battery is assumed empty if the volatge falls bellow 3.5V
if( voltage < (3500*VOLTAGE_SAMPLES) ){
//if( voltage < 3500 ){
nrf_off();
gpioSetValue (RB_PWR_GOOD, 0);
gpioSetValue (RB_LCD_BL, 0);
gpioSetValue (RB_LCD_BL, 0);

//put the chip into deep power down
SCB_SCR |= SCB_SCR_SLEEPDEEP;
PMU_PMUCTRL = PMU_PMUCTRL_DPDEN_DEEPPOWERDOWN;
__asm volatile ("WFI");
};
};

uint32_t GetVoltage(void){
return results;
return voltage/8;
//return voltage;
};

uint8_t GetChrgStat(void){
0 firmware/core/libc/stdio.c 100755 → 100644
No changes.
5 firmware/core/libc/string.c 100755 → 100644
@@ -52,6 +52,7 @@ void * memcpy(void *pDestination, const void *pSource, size_t num)
{
unsigned char *pByteDestination;
unsigned char *pByteSource;
#ifdef FAST_MEMCPY
unsigned int *pAlignedSource = (unsigned int *) pSource;
unsigned int *pAlignedDestination = (unsigned int *) pDestination;

@@ -71,6 +72,10 @@ void * memcpy(void *pDestination, const void *pSource, size_t num)
// Copy remaining bytes
pByteDestination = (unsigned char *) pAlignedDestination;
pByteSource = (unsigned char *) pAlignedSource;
#else
pByteDestination = (unsigned char *) pDestination;
pByteSource = (unsigned char *) pSource;
#endif
while (num--) {

*pByteDestination++ = *pByteSource++;
@@ -39,20 +39,12 @@
#ifndef _SYSDEFS_H_
#define _SYSDEFS_H_

#include "../sysdefs.h"

#include <stdio.h>
#include <stdint.h>
#include <stdbool.h>

// Stay compatible with ugly "windows" style
#define BOOL bool
#define TRUE true
#define FALSE false

typedef volatile uint8_t REG8;
typedef volatile uint16_t REG16;
typedef volatile uint32_t REG32;
typedef unsigned char byte_t;

#define pREG8 (REG8 *)
#define pREG16 (REG16 *)
#define pREG32 (REG32 *)
@@ -13,6 +13,10 @@ char meshgen=0; // Generation
char meshincctr=0;
char meshmsg=0;
char meshnice=0;

char mesh_mode=0;
#define MM_TIME (1<<0)
#define MM_ENC (1<<1)
MPKT meshbuffer[MESHBUFSIZE];

#include "SECRETS"
@@ -23,6 +27,8 @@ static int mesh_gt(char curgen, char newgen){
unsigned char dif=curgen-newgen;
if(curgen==0)
return 1;
if(newgen==0)
return 0;
return (dif>128);
};

@@ -43,21 +49,24 @@ void initMesh(void){
int mesh_sanity(uint8_t * pkt){
if(MO_TYPE(pkt)>0x7f || MO_TYPE(pkt)<0x20)
return MP_SEND;
if(MO_TYPE(pkt)=='T' && MO_BODY(pkt)[5])
return MP_SEND;
if(MO_TYPE(pkt)=='T' && MO_TIME(pkt)<86400)
return MP_OK;
if(MO_TYPE(pkt)>='A' && MO_TYPE(pkt)<='Z'){
if(MO_TIME(pkt)>1326409200)
if(MO_TIME(pkt)>1370340000) /* 4.Jun 2013 */
return MP_SEND;
if(MO_TIME(pkt)<1324602000)
if(MO_TIME(pkt)<1325376000) /* 1.1.2012 */
return MP_SEND;
}else if(MO_TYPE(pkt)>='a' && MO_TYPE(pkt)<='z'){
if(MO_TIME(pkt)>16777216)
if(MO_TIME(pkt)>16777216) /* 3-byte only */
return MP_SEND;
if(MO_TIME(pkt)<0)
return MP_SEND;
};
if(MO_TYPE(pkt)!='A' &&
MO_TYPE(pkt)!='a' &&
MO_TYPE(pkt)!='i' &&
MO_TYPE(pkt)!='B' &&
MO_TYPE(pkt)!='E' &&
MO_TYPE(pkt)!='F' &&
@@ -97,6 +106,7 @@ void meshPanic(uint8_t * pkt,int bufno){
#if 0
static int done=0;
if(!done){
gpioSetValue (RB_LED0, 1-gpioGetValue(RB_LED0));
setSystemFont();
lcdClear();
lcdPrint("PANIC[");
@@ -105,9 +115,15 @@ void meshPanic(uint8_t * pkt,int bufno){
lcdNl();
for(int i=0;i<32;i++){
lcdPrint(IntToStrX(pkt[i],2));
if(i%6==5)
if(i%6==2){
lcdPrint(" ");
};
if(i%6==5){
lcdNl();
};
}
lcdPrint(" ");
lcdPrint(IntToStrX(crc16(pkt,30),4));
lcdRefresh();
while ((getInputRaw())==BTN_NONE);
};
@@ -156,10 +172,13 @@ void mesh_sendloop(void){
// Update [T]ime packet
MO_TIME_set(meshbuffer[0].pkt,getSeconds());
MO_GEN_set(meshbuffer[0].pkt,meshgen);
if(GLOBAL(privacy)==0)
if(GLOBAL(privacy)==0){
uint32touint8p(GetUUID32(),meshbuffer[0].pkt+26);
else
uint32touint8p(getrelease(),meshbuffer[0].pkt+22);
}else{
uint32touint8p(0,meshbuffer[0].pkt+26);
uint32touint8p(0,meshbuffer[0].pkt+22);
};

MO_BODY(meshbuffer[0].pkt)[4]=meshnice;

@@ -223,7 +242,7 @@ uint8_t mesh_recvqloop_work(void){
if(mesh_sanity(buf)){
meshincctr++;
if((mesh_sanity(buf)&MP_RECV)!=0){
meshPanic(buf,-1);
meshPanic(buf,-len);
};
return 0;
};
@@ -235,6 +254,7 @@ uint8_t mesh_recvqloop_work(void){
meshincctr=0;
meshnice=MO_BODY(buf)[4];
meshgen=MO_GEN(buf);
mesh_mode&=~MM_TIME;
};
};

@@ -243,15 +263,19 @@ uint8_t mesh_recvqloop_work(void){
return 0;
};

// Set new time iff newer
if(MO_TYPE(buf)=='T'){
time_t toff=MO_TIME(buf)-((getTimer()+(600/SYSTICKSPEED))/(1000/SYSTICKSPEED));
if (toff>_timet){ // Do not live in the past.
_timet = toff;
meshincctr++;
};
return 1;
};
// Set new time iff I don't have a valid one.
if((mesh_mode & MM_TIME)==0){
if(MO_TYPE(buf)=='T'){
time_t toff=MO_TIME(buf)-((getTimer()+(600/SYSTICKSPEED))/(1000/SYSTICKSPEED));
_timet = toff;
if(meshgen==0 && MO_TIME(buf)<60*60*24){
; // still not valid
}else{
mesh_mode|=MM_TIME; // Got a time now.
};
return 1;
};
};

// Safety: Truncate ascii packets by 0-ing the CRC
buf[MESHPKTSIZE-2]=0;
@@ -137,8 +137,6 @@ static void openbeaconSendPacket(uint32_t id, uint32_t seq,

void openbeaconSend(void)
{
//uint8_t status;

nrf_config_get(&oldconfig);

nrf_set_channel(OPENBEACON_CHANNEL);
@@ -153,6 +151,6 @@ void openbeaconSend(void)
openbeaconSaveBlock();
#endif
nrf_config_set(&oldconfig);
//return status;
nrf_set_strength(3);
}

@@ -117,7 +117,7 @@ static bool screen_overview() {
while (key != BTN_ENTER) {
lcdClear();
lcdPrintln("Privacy:");
lcdPrintln(levels[GLOBAL(privacy)]);
lcdPrintln(levels[(int)GLOBAL(privacy)]);
lcdPrintln("");
lcdPrintln("Nickname:");
lcdPrintln(GLOBAL(nickname));
@@ -83,7 +83,7 @@ meshnice
#external
strcpy
strlen
memcpy
memmove
memset
#stuff
GetLight
Oops, something went wrong.

0 comments on commit 8ac335b

Please sign in to comment.
You can’t perform that action at this time.