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

This commit is contained in:
Sebastian 'iggy' Steuer 2011-07-21 17:22:23 +02:00
commit a5b227b60e
215 changed files with 1948 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,53 @@
#ifndef CBITFIELD_H
#define CBITFIELD_H
#define BITSETCHUNKSIZE 32
#define one ((uint32_t)1)
struct bitset {
uint16_t size;
uint32_t bits[BITSET_SIZE/BITSETCHUNKSIZE+1];
};
static inline void bitset_set(struct bitset *bs,uint16_t index, uint8_t value) {
uint16_t base=index/BITSETCHUNKSIZE;
uint16_t offset=index%BITSETCHUNKSIZE;
if(value) {
bs->bits[base]|=(one<<offset);
} else {
bs->bits[base]&=~(one<<offset);
}
}
static inline void bitset_xor(struct bitset *bs,uint16_t index, uint8_t value) {
uint16_t base=index/BITSETCHUNKSIZE;
uint16_t offset=index%BITSETCHUNKSIZE;
if(value) {
bs->bits[base]^=(one<<offset);
}
}
static inline uint8_t bitset_get(struct bitset *bs,uint16_t index) {
uint16_t base=index/BITSETCHUNKSIZE;
uint16_t offset=index%BITSETCHUNKSIZE;
return (bs->bits[base]&(one<<offset))==(one<<offset);;
}
static inline uint16_t bitset_offset2(uint8_t x, uint8_t y) {
return ((uint16_t)x)+((uint16_t)y)*BITSET_X;
}
static inline void bitset_set2(struct bitset *bs, uint8_t x, uint8_t y, uint8_t value) {
bitset_set(bs,bitset_offset2(x,y),value);
}
static inline void bitset_xor2(struct bitset *bs, uint8_t x, uint8_t y, uint8_t value) {
bitset_xor(bs,bitset_offset2(x,y),value);
}
static inline uint8_t bitset_get2(struct bitset *bs,uint8_t x,uint8_t y) {
return bitset_get(bs,bitset_offset2(x,y));
}
#endif

View File

@ -0,0 +1,70 @@
#include "basic/basic.h"
#include "core/i2c/i2c.h"
#define FLAME_I2C_WRITE 0xC4
#define FLAME_I2C_READ 0xC5
#define FLAME_I2C_CR_INPUT 0x00
#define FLAME_I2C_CR_PSC0 0x01
#define FLAME_I2C_CR_PWM0 0x02
#define FLAME_I2C_CR_PSC1 0x03
#define FLAME_I2C_CR_PWM1 0x04
#define FLAME_I2C_CR_LS0 0x05
#define FLAME_I2C_LS0_OFF 0x00
#define FLAME_I2C_LS0_ON 0x01
#define FLAME_I2C_LS0_PWM0 0x02
#define FLAME_I2C_LS0_PWM1 0x03
#define FLAME_I2C_LS0_LED0 0x00
#define FLAME_I2C_LS0_LED1 0x02
#define FLAME_I2C_LS0_LED2 0x04
#define FLAME_I2C_LS0_LED3 0x06
#define FLAME_MODE_ON 0x00
#define FLAME_MODE_A 0x01
#define FLAME_MODE_B 0x02
#define FLAME_MODE_C 0x03
#define FLAME_MODE_MIN 0x00
#define FLAME_MODE_MAX 0x03
void ReinvokeISP(void);
/**************************************************************************/
void flameSetI2C(uint8_t cr, uint8_t value) {
I2CMasterBuffer[0] = FLAME_I2C_WRITE;
I2CMasterBuffer[1] = cr;
I2CMasterBuffer[2] = value;
I2CWriteLength = 3;
I2CReadLength = 0;
i2cEngine();
}
void tick_flame(void) { // every 10ms
}
void main_flame(void) {
i2cInit(I2CMASTER); // Init I2C
// flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_ON << FLAME_I2C_LS0_LED0); // set led to on
// flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_OFF << FLAME_I2C_LS0_LED0); // set led to off
flameSetI2C(FLAME_I2C_CR_PSC0, 0x66); // set prescaler
flameSetI2C(FLAME_I2C_CR_PWM0, 0x33); // set pwm
flameSetI2C(FLAME_I2C_CR_LS0, FLAME_I2C_LS0_PWM0 << FLAME_I2C_LS0_LED0); // set led to pwm
char key;
while (1) {
key = getInput();
if (key == BTN_LEFT) {
DoString(0,50,"ISP!");
lcdDisplay();
ISPandReset();
}
}
return;
}

View File

@ -142,7 +142,9 @@ void main_iggy(void) {
gpioSetValue (RB_LCD_BL, 0);
SCB_SCR |= SCB_SCR_SLEEPDEEP;
PMU_PMUCTRL = PMU_PMUCTRL_DPDEN_DEEPPOWERDOWN;
#ifdef ARM
__asm volatile ("WFI");
#endif
}else{
//DoString(0,yctr+30,"OK ");
;

View File

@ -0,0 +1,202 @@
#include <sysinit.h>
#include "basic/basic.h"
//#include "lcd/render.h"
#include "lcd/display.h"
//#include "lcd/allfonts.h"
#define BITSET_X (RESX+2)
#define BITSET_Y (RESY+2)
#define BITSET_SIZE (BITSET_X*BITSET_Y)
#include "cbitset.h"
typedef uint8_t uchar;
unsigned char rnd1();
void draw_rect(char x0, char y0, char x1, char y1) {
for(char x=x0; x<=x1; ++x) {
lcdSetPixel(x,y0,true);
lcdSetPixel(x,y1,true);
}
for(char y=y0+1; y<y1; ++y) {
lcdSetPixel(x0,y,true);
lcdSetPixel(x1,y,true);
}
}
void fill_rect(char x0, char y0, char x1, char y1) {
for(char x=x0; x<=x1; ++x) {
for(char y=y0; y<=y1; ++y) {
lcdSetPixel(x,y,true);
}
}
}
#define STARTVALUE 10
struct bitset _buf1,*buf1=&_buf1;
struct bitset _buf2,*buf2=&_buf2;
struct bitset *life =&_buf1;
struct bitset *new =&_buf2;
void swap_areas() {
struct bitset *tmp=life;
life=new;
new=tmp;
}
void fill_area(struct bitset *area, uchar x0, uchar y0, uchar x1, uchar y1,uchar value) {
for(uchar x=x0; x<=x1; ++x) {
for(uchar y=y0; y<=y1; ++y) {
bitset_set2(area,x,y,value);
}
}
}
bool find_area(struct bitset *area, uchar x0, uchar y0, uchar x1, uchar y1,uchar value) {
for(uchar x=x0; x<=x1; ++x) {
for(uchar y=y0; y<=y1; ++y) {
if(bitset_get2(area,x,y)==value) return true;
}
}
return false;
}
uint32_t sum_area(struct bitset *area, uchar x0, uchar y0, uchar x1, uchar y1) {
uint32_t sum=0;
for(uchar x=x0; x<=x1; ++x) {
for(uchar y=y0; y<=y1; ++y) {
sum+=bitset_get2(area,x,y);
}
}
return sum;
}
void draw_area() {
for(uchar x=0; x<RESX; ++x) {
for(uchar y=0; y<RESY; ++y) {
lcdSetPixel(x,y,bitset_get2(life,x+1,y+1));
}
}
}
void calc_area() {
#ifdef SIMULATOR
static unsigned long iter=0;
fprintf(stderr,"Iteration %d \n",++iter);
#endif
for(uchar x=1; x<=RESX; ++x) {
for(uchar y=1; y<=RESY; ++y) {
uchar sum=sum_area(life,x-1,y-1,x+1,y+1)-bitset_get2(life,x,y);
bitset_set2(new,x,y,sum==3||(sum==2&&bitset_get2(life,x,y)));
}
}
swap_areas();
}
int pattern=0;
#define PATTERNCOUNT 3
void reset_area() {
fill_area(life,0,0,RESX+1,RESY+1,0);
fill_area(new,0,0,RESX+1,RESY+1,0);
switch(pattern) {
case 0:
bitset_set2(life,41,40,1);
bitset_set2(life,42,40,1);
bitset_set2(life,41,41,1);
bitset_set2(life,40,41,1);
bitset_set2(life,41,42,1);
break;
case 1:
for(int i=0; i<RESX/2; ++i) bitset_set2(life,i,0,1);
bitset_set2(life,40,40,1);
bitset_set2(life,41,40,1);
bitset_set2(life,41,41,1);
break;
case 2:
bitset_set2(life,40,40,1);
bitset_set2(life,41,40,1);
bitset_set2(life,42,40,1);
bitset_set2(life,42,41,1);
bitset_set2(life,42,42,1);
bitset_set2(life,40,41,1);
bitset_set2(life,40,42,1);
break;
}
}
void random_area(struct bitset *area, uchar x0, uchar y0, uchar x1, uchar y1,uchar value) {
for(uchar x=x0; x<=x1; ++x) {
for(uchar y=y0; y<=y1; ++y) {
bitset_set2(area,x,y,rnd1()<value);
}
}
}
#define LEDINTERVAL 1
uint8_t ledcycle=3;
void nextledcycle() {
ledcycle=(ledcycle+1)%(8*LEDINTERVAL);
uint8_t a=ledcycle/LEDINTERVAL;
switch(a) {
case 0: gpioSetValue (RB_LED0, CFG_LED_ON); break;
case 4: gpioSetValue (RB_LED0, CFG_LED_OFF); break;
case 1: gpioSetValue (RB_LED1, CFG_LED_ON); break;
case 5: gpioSetValue (RB_LED1, CFG_LED_OFF); break;
case 2: gpioSetValue (RB_LED2, CFG_LED_ON); break;
case 6: gpioSetValue (RB_LED2, CFG_LED_OFF); break;
case 3: gpioSetValue (RB_LED3, CFG_LED_ON); break;
case 7: gpioSetValue (RB_LED3, CFG_LED_OFF); break;
}
}
uchar stepmode=0;
uchar randdensity=0;
void main_life(void) {
backlightInit();
reset_area();
gpioSetValue (RB_LED0, CFG_LED_ON);
gpioSetValue (RB_LED1, CFG_LED_ON);
gpioSetValue (RB_LED2, CFG_LED_ON);
gpioSetValue (RB_LED3, CFG_LED_ON);
while (1) {
// checkISP();
lcdFill(0);
uint32_t button=(stepmode?getInputWait():getInput());
if(button!=BTN_ENTER) randdensity=0;
switch(button) {
case BTN_DOWN:
stepmode=1;
nextledcycle();
break;
case BTN_RIGHT:
stepmode=0;
break;
case BTN_LEFT:
reset_area();
break;
case BTN_ENTER:
randdensity+=8;
random_area(life,1,1,RESX,RESY,randdensity);
stepmode=1;
break;
case BTN_UP:
pattern=(pattern+1)%PATTERNCOUNT;
reset_area();
stepmode=1;
break;
}
draw_area();
lcdDisplay();
delayms(10);
calc_area();
}
return;
}

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

@ -1937,8 +1937,13 @@ typedef struct
#define NVIC ((NVIC_Type *) NVIC_BASE_ADDRESS)
#ifdef ARM
static inline void __enable_irq() { __asm volatile ("cpsie i"); }
static inline void __disable_irq() { __asm volatile ("cpsid i"); }
#else
void __enable_irq();
void __disable_irq();
#endif
typedef enum IRQn
{

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)

27
simulat0r/Makefile Normal file
View File

@ -0,0 +1,27 @@
all : tui gui
.PHONY : tui gui tui-core clean
tui-core :
$(MAKE) -C firmware
$(MAKE) -C simcore
$(MAKE) -C tui
tui : tui-core
$(MAKE) -C gui/build clean # workaround for buggy dependency of gui build on libapp
.IGNORE : tui
gui : tui gui/build/Makefile
$(MAKE) -C gui/build VERBOSE=1
# bootstrap build directory
gui/build/Makefile : tui-core
install -d gui/build && cd gui/build && cmake ..
clean:
$(MAKE) -C firmware clean
$(MAKE) -C tui clean
$(MAKE) -C simcore clean
$(MAKE) -C gui/build clean # workaround for buggy dependency of gui build on libapp

View File

@ -0,0 +1,46 @@
#!/bin/sh
function verbmsg()
{
true
# echo $1
}
if test ! -d simulat0r/firmware -o ! -d firmware
then
echo ERROR:
echo This script must be run from toplevel r0ket directory
exit
fi
echo "Updating directories"
for i in `find firmware/ -type d `
do
if test -d simulat0r/$i
then verbmsg "OK Directory already exists: $i"
else mkdir -v simulat0r/$i
fi
done
echo "Updating bridge files for C source"
for i in `find firmware/ \! -path firmware/lcd/allfonts.h -type f -iname \*.[ch]`
do
if test -f simulat0r/$i;
then
verbmsg "OK File already exists: $i"
else
echo Writing bridge file simulat0r/$i
(printf "/* AUTOGENERATED SOURCE FILE */\n"; echo \#include \"`dirname $i | sed "s#[^/]*#..#g" `/../$i\") >simulat0r/$i
fi
done
echo "Updating bridge files for Makefiles"
for i in `find firmware/ -type f -iname Makefile`
do
if test -f simulat0r/$i;
then
verbmsg "OK File already exists: $i"
else
echo Writing bridge file simulat0r/$i
(printf "# GENERATED INCLUDE BRIDGE/\n"; echo include `dirname $i | sed "s#[^/]*#..#g" `/../$i) >simulat0r/$i
fi
done

View File

@ -0,0 +1,4 @@
# GENERATED INCLUDE BRIDGE/
include ../../firmware/Makefile
.IGNORE: $(OUTFILE).elf $(OUTFILE).bin

View File

@ -0,0 +1,46 @@
##########################################################################
# User configuration and firmware specific object files
##########################################################################
# The target, flash and ram of the LPC1xxx microprocessor.
# Use for the target the value: LPC11xx, LPC13xx or LPC17xx
TARGET = LPC13xx
FLASH = 32K
SRAM = 8K
RAMCODE=1K
# For USB HID support the LPC134x reserves 384 bytes from the sram,
# if you don't want to use the USB features, just use 0 here.
SRAM_USB = 384
##########################################################################
# GNU GCC compiler prefix and location
##########################################################################
#CROSS_COMPILE = arm-none-eabi-
AS = $(CROSS_COMPILE)gcc
CC = $(CROSS_COMPILE)gcc
LD = $(CROSS_COMPILE)ld
REALLD = $(CROSS_COMPILE)ld
SIZE = $(CROSS_COMPILE)size
OBJCOPY = $(CROSS_COMPILE)objcopy
OBJDUMP = $(CROSS_COMPILE)objdump
OUTFILE = firmware
LPCFIX = /bin/echo
ifeq (LPC11xx,$(TARGET))
CORTEX_TYPE=m0
else
CORTEX_TYPE=m3
endif
#CPU_TYPE = cortex-$(CORTEX_TYPE)
#CPU_TYPE=i686
##########################################################################
# Compiler settings, parameters and flags
##########################################################################
CFLAGS = -std=c99 -c -g -O0 $(INCLUDE_PATHS) -Wall -funsigned-char -ffunction-sections -fdata-sections -fmessage-length=0 -DRAMCODE=$(RAMCODE) -fno-builtin -DSIMULATOR -I$(ROOT_PATH)/../simcore -include libc-unc0llide.h
#LDFLAGS = -nostartfiles

View File

@ -0,0 +1 @@
include $(ROOT_PATH)/../../firmware/Makefile.util

View File

@ -0,0 +1,2 @@
# GENERATED INCLUDE BRIDGE/
include ../../../firmware/applications/Makefile

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/adc.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/bsx.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/cbitset.h"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/cdc.c"

View File

@ -0,0 +1,12 @@
/* AUTOGENERATED SOURCE FILE */
#define main_default _hideaway_main_default
#define lcdInitConfig _hide_lcdInitConfig
#include "../../../firmware/applications/default.c"
#undef lcdInitConfig
#undef main_default
int lcdInitConfig() {
}
void main_default() {
}

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/ecc.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/exe.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/executor.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/flame.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/font.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/fs.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/funk.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/iggy.c"

View File

@ -0,0 +1 @@
#include "../../../firmware/applications/life.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/lilafisch.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/loadable.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/mandelbrot.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/mandelbrot2.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/menutest.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/minimal.c"

View File

@ -0,0 +1,2 @@
#!/bin/sh
. ../../../firmware/applications/mkwrapper

View File

@ -0,0 +1 @@
#include "../../../firmware/applications/rect.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/remote.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/s.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/schneider.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/scroll.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/sec.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/spaceinvaders.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/applications/vcard.c"

View File

@ -0,0 +1 @@
#include "../../../firmware/applications/waldbrand.c"

View File

@ -0,0 +1,2 @@
# GENERATED INCLUDE BRIDGE/
include ../../../firmware/basic/Makefile

View File

@ -0,0 +1,2 @@
void rbInit() {
}

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/basic/basic.h"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/basic/byteorder.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/basic/byteorder.h"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/basic/crc.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/basic/delayms.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/basic/ecc.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/basic/ecc.h"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/basic/keyin.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/basic/menu.c"

View File

@ -0,0 +1,12 @@
#include <core/gpio/gpio.h>
void ReinvokeISP(void) {
}
void EnableWatchdog(uint32_t ms) {
}
void ISPandReset(int delay){
EnableWatchdog(1000*delay);
ReinvokeISP();
};

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/basic/uuid.c"

View File

@ -0,0 +1,12 @@
#include <sysinit.h>
#include "basic/basic.h"
uint32_t results=5000;
void VoltageCheck(void){
};
uint32_t GetVoltage(void){
return results;
};

View File

@ -0,0 +1,4 @@
/* use SAFE version instead of ARM asm */
#define SAFE
#include "../../../firmware/basic/xxtea.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/basic/xxtea.h"

View File

@ -0,0 +1,2 @@
# GENERATED INCLUDE BRIDGE/
include ../../../firmware/core/Makefile

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/adc/adc.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/adc/adc.h"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/cmd/cmd.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/cmd/cmd.h"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/cpu/cpu.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/cpu/cpu.h"

View File

@ -0,0 +1,65 @@
#include <core/gpio/gpio.h>
#include "basic/basic.h"
#include "../simcore/simulator.h"
static bool compair(uint32_t a1, uint32_t a2, uint32_t b1, uint32_t b2) {
return a1==b1 && a2==b2;
}
void gpioInit (void) {
printf("void gpioInit (void)\n");
}
void gpioSetDir (uint32_t portNum, uint32_t bitPos, gpioDirection_t dir) {
printf("void gpioSetDir (portNum %d, bitPos %d, dir %x)\n",portNum,bitPos,dir);
}
uint32_t gpioGetValue (uint32_t portNum, uint32_t bitPos) {
if(compair(portNum, bitPos, RB_BTN3)) return simButtonPressed(BTN_UP);
if(compair(portNum, bitPos, RB_BTN2)) return simButtonPressed(BTN_DOWN);
if(compair(portNum, bitPos, RB_BTN4)) return simButtonPressed(BTN_ENTER);
if(compair(portNum, bitPos, RB_BTN0)) return simButtonPressed(BTN_LEFT);
if(compair(portNum, bitPos, RB_BTN1)) return simButtonPressed(BTN_RIGHT);
if(compair(portNum, bitPos, RB_LED0)) return simGetLED(0);
if(compair(portNum, bitPos, RB_LED1)) return simGetLED(1);
if(compair(portNum, bitPos, RB_LED2)) return simGetLED(2);
if(compair(portNum, bitPos, RB_LED3)) return simGetLED(3);
fprintf(stderr,"Unimplemented gpioGetValue portNum %d %x bit %d\n",portNum, portNum, bitPos);
return 0;
}
void gpioSetValue (uint32_t portNum, uint32_t bitPos, uint32_t bitVal) {
if(compair(portNum, bitPos, RB_LED0)) return simSetLED(0,bitVal);
if(compair(portNum, bitPos, RB_LED1)) return simSetLED(1,bitVal);
if(compair(portNum, bitPos, RB_LED2)) return simSetLED(2,bitVal);
if(compair(portNum, bitPos, RB_LED3)) return simSetLED(3,bitVal);
fprintf(stderr,"Unimplemented gpioSetValue portNum %d %x bit %d\n",portNum, portNum, bitPos);
}
void gpioSetInterrupt (uint32_t portNum, uint32_t bitPos, gpioInterruptSense_t sense, gpioInterruptEdge_t edge, gpioInterruptEvent_t event) {
printf("void gpioSetInterrupt (uint32_t portNum, uint32_t bitPos, gpioInterruptSense_t sense, gpioInterruptEdge_t edge, gpioInterruptEvent_t event)\n");
}
void gpioIntEnable (uint32_t portNum, uint32_t bitPos) {
printf("void gpioIntEnable (uint32_t portNum, uint32_t bitPos)\n");
}
void gpioIntDisable (uint32_t portNum, uint32_t bitPos) {
printf("void gpioIntDisable (uint32_t portNum, uint32_t bitPos)\n");
}
uint32_t gpioIntStatus (uint32_t portNum, uint32_t bitPos) {
printf("uint32_t gpioIntStatus (uint32_t portNum, uint32_t bitPos)\n");
}
void gpioIntClear (uint32_t portNum, uint32_t bitPos) {
printf("void gpioIntClear (uint32_t portNum, uint32_t bitPos)\n");
}
void gpioSetPullup (volatile uint32_t *ioconRegister, gpioPullupMode_t mode) {
printf("void gpioSetPullup (volatile uint32_t *ioconRegister, gpioPullupMode_t mode)\n");
}

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/gpio/gpio.h"

View File

@ -0,0 +1,34 @@
// dummy implementation instead of #include "../../../../firmware/core/i2c/i2c.c"
#include "i2c.h"
volatile uint32_t I2CMasterState = I2CSTATE_IDLE;
volatile uint32_t I2CSlaveState = I2CSTATE_IDLE;
volatile uint8_t I2CMasterBuffer[I2C_BUFSIZE];
volatile uint8_t I2CSlaveBuffer[I2C_BUFSIZE];
volatile uint32_t I2CReadLength;
volatile uint32_t I2CWriteLength;
volatile uint32_t RdIndex = 0;
volatile uint32_t WrIndex = 0;
void I2C_IRQHandler(void) {
}
uint32_t i2cInit( uint32_t I2cMode ) {
return( TRUE );
}
uint32_t i2cEngine( void ) {
return I2CSTATE_IDLE;
}
/******************************************************************************
** End Of File
******************************************************************************/

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/i2c/i2c.h"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/iap/iap.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/iap/iap.h"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/libc/ctype.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/libc/stdio.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/libc/string.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/core/lpc134x.h"

View File

@ -0,0 +1,2 @@
#define volatile(x) volatile("nop")
#include "../../../../firmware/core/pmu/pmu.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/pmu/pmu.h"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/core/projectconfig.h"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/pwm/pwm.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/pwm/pwm.h"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/core/rom_drivers.h"

View File

@ -0,0 +1,23 @@
#define sspInit _hideaway_sspInit
#define sspSend _hideaway_sspSend
#define sspReceive _hideaway_sspReceive
#define sspSendReceive _hideaway_sspSendReceive
#include "../../../../firmware/core/ssp/ssp.c"
#undef sspInit
#undef sspSend
#undef sspReceive
#undef sspSendReceive
void sspInit (uint8_t portNum, sspClockPolarity_t polarity, sspClockPhase_t phase) {
}
void sspSend (uint8_t portNum, const uint8_t *buf, uint32_t length) {
}
void sspReceive (uint8_t portNum, uint8_t *buf, uint32_t length) {
}
void sspSendReceive(uint8_t portNum, uint8_t *buf, uint32_t length) {
}

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/ssp/ssp.h"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/core/sysdefs.h"

View File

@ -0,0 +1,83 @@
#include <sys/mman.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
//#define handle_error(msg) do { perror(msg); exit(EXIT_FAILURE); } while (0)
#define handle_error(msg) do { perror(msg); exit(EXIT_FAILURE); } while (0)
#include "core/lpc134x.h"
void testByte(void* addr) {
fprintf(stderr,"Testing address %x : read ",addr);
fprintf(stderr,"%x, write ",(int)(*((char*)addr)));
++(*((char*)addr));
fprintf(stderr,"%x",(int)(*((char*)addr)));
--(*((char*)addr));
fprintf(stderr," OK\n");
}
void testMemoryHack(void* addr,long size) {
fprintf(stderr,"Testing memory range %x - %x\n",addr,addr+size);
for(void* p=addr; p<addr+size; p+=sysconf(_SC_PAGE_SIZE)) {
testByte(p);
}
}
int setupMemoryHack(void* address, long size) {
char *addr;
int fd;
struct stat sb;
off_t offset, pa_offset;
size_t length;
ssize_t s;
FILE *tempfil=tmpfile();
fd = fileno(tempfil);
ftruncate(fd,size);
if (fd == -1)
handle_error("open");
if (fstat(fd, &sb) == -1) /* To obtain file size */
handle_error("fstat");
offset = 0;
pa_offset = offset & ~(sysconf(_SC_PAGE_SIZE) - 1);
/* offset for mmap() must be page aligned */
if (offset >= sb.st_size) {
fprintf(stderr, "offset is past end of file\n");
exit(EXIT_FAILURE);
}
length = size;
addr = mmap(address, length + offset - pa_offset, PROT_READ | PROT_WRITE,
MAP_PRIVATE, fd, pa_offset);
if (addr == MAP_FAILED)
handle_error("mmap");
if(addr!=address) {
fprintf(stderr, "mmap: wanted %x, got %x: ",address,addr);
handle_error("mmap address discrepancy");
}
// testMemoryHack(address,size);
fprintf(stderr,"Range %x tested\n",addr);
}
void systemInit()
{
// setupMemoryHack((void*)0x40000000,0x1000000);
// setupMemoryHack((void*)0x50000000,10*1024*1024);
// setupMemoryHack((void*)0x10000000,10*1024*1024);
// systick stuff unmappable setupMemoryHack((void*)0xe0000000,0x10000);
#if 0
printf("Test %d\n",SSP_SSP0CR0);
printf("Test2 %d\n",++SSP_SSP0CR0);
printf("Test3 pre %x\n",&SYSTICK_STRELOAD);
// printf("Test3 %d\n",++SYSTICK_STRELOAD);
#endif
}

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../firmware/core/sysinit.h"

View File

@ -0,0 +1,231 @@
#warning "cleanupthisfile"
#if 0
#include "../../firmware/core/systick/systick.c"
#else
/**************************************************************************/
/*!
@file systick.c
@author K. Townsend (microBuilder.eu)
@date 22 March 2010
@version 0.10
@section DESCRIPTION
Controls the 24-bit 'system tick' clock, which can be used as a
generic timer or to control time sharing with an embedded real-time
operating system (such as FreeRTOS).
@section Example
@code
#include "core/cpu/cpu.h"
#include "core/systick/systick.h"
void main (void)
{
cpuInit();
// Start systick timer with one tick every 10ms
systickInit(10);
while(1)
{
}
}
@endcode
@section LICENSE
Software License Agreement (BSD License)
Copyright (c) 2010, microBuilder SARL
All rights reserved.
Redistribution and use in source and binary forms, with or without
modification, are permitted provided that the following conditions are met:
1. Redistributions of source code must retain the above copyright
notice, this list of conditions and the following disclaimer.
2. Redistributions in binary form must reproduce the above copyright
notice, this list of conditions and the following disclaimer in the
documentation and/or other materials provided with the distribution.
3. Neither the name of the copyright holders nor the
names of its contributors may be used to endorse or promote products
derived from this software without specific prior written permission.
THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS ''AS IS'' AND ANY
EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED
WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER 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.
*/
/**************************************************************************/
#include "systick.h"
volatile uint32_t systickTicks = 0; // 1ms tick counter
volatile uint32_t systickRollovers = 0;
void tick_wrapper(void);
/**************************************************************************/
/*!
@brief Systick interrupt handler
*/
/**************************************************************************/
void SysTick_Handler (void)
{
systickTicks++;
// Increment rollover counter
if (systickTicks == 0xFFFFFFFF) systickRollovers++;
tick_wrapper();
}
/**************************************************************************/
/*!
@brief Configures the systick timer
@param[in] ticks
The number of clock cycles between each tick of the
systick timer. for example, 'CFG_CPU_CCLK / 1000' =
1 millisecond. This value must not exceed 0x00FFFFFF.
*/
/**************************************************************************/
static uint32_t systickConfig(uint32_t ticks)
{
fprintf(stderr,"systickConfig: unimplemented\n");
return 0;
// Check if 'ticks' is greater than maximum value
if (ticks > SYSTICK_STRELOAD_MASK)
{
return (1);
}
// Reset counter
systickTicks = 0;
// Set reload register
SYSTICK_STRELOAD = (ticks & SYSTICK_STRELOAD_MASK) - 1;
// Load the systick counter value
SYSTICK_STCURR = 0;
// Enable systick IRQ and timer
SYSTICK_STCTRL = SYSTICK_STCTRL_CLKSOURCE |
SYSTICK_STCTRL_TICKINT |
SYSTICK_STCTRL_ENABLE;
return (0);
}
/**************************************************************************/
/*!
@brief Initialises the systick timer
@param[in] delayMs
The number of milliseconds between each tick of the systick
timer.
@note The shortest possible delay is 1 millisecond, which will
allow fine grained delays, but will cause more load on the
system than a 10mS delay. The resolution of the systick
timer needs to be balanced with the amount of processing
time you can spare. The delay should really only be set
to 1 mS if you genuinely have a need for 1mS delays,
otherwise a higher value like 5 or 10 mS is probably
more appropriate.
*/
/**************************************************************************/
void systickInit (uint32_t delayMs)
{
systickConfig ((CFG_CPU_CCLK / 1000) * delayMs);
}
/**************************************************************************/
/*!
@brief Causes a blocking delay for 'delayTicks' ticks on the
systick timer. For example: systickDelay(100) would cause
a blocking delay for 100 ticks of the systick timer.
@param[in] delayTicks
The number of systick ticks to cause a blocking delay for
@Note This function takes into account the fact that the tick
counter may eventually roll over to 0 once it reaches
0xFFFFFFFF.
*/
/**************************************************************************/
void systickDelay (uint32_t delayTicks)
{
uint32_t curTicks;
curTicks = systickTicks;
// Make sure delay is at least 1 tick in case of division, etc.
if (delayTicks == 0) delayTicks = 1;
if (curTicks > 0xFFFFFFFF - delayTicks)
{
// Rollover will occur during delay
while (systickTicks >= curTicks)
{
while (systickTicks < (delayTicks - (0xFFFFFFFF - curTicks)));
}
}
else
{
while ((systickTicks - curTicks) < delayTicks);
}
}
/**************************************************************************/
/*!
@brief Returns the current value of the systick timer counter.
This value is incremented by one every time an interrupt
fires for the systick timer.
*/
/**************************************************************************/
uint32_t systickGetTicks(void)
{
return systickTicks;
}
/**************************************************************************/
/*!
@brief Returns the current value of the systick timer rollover
counter. This value is incremented by one every time the
tick counter rolls over from 0xFFFFFFFF to 0.
*/
/**************************************************************************/
uint32_t systickGetRollovers(void)
{
return systickRollovers;
}
/**************************************************************************/
/*!
@brief Returns the approximate number of seconds that the
systick timer has been running.
*/
/**************************************************************************/
uint32_t systickGetSecondsActive(void)
{
uint32_t currentTick = systickTicks;
uint32_t rollovers = systickRollovers;
uint32_t secsActive = currentTick / (1000 / CFG_SYSTICK_DELAY_IN_MS);
secsActive += rollovers * (0xFFFFFFFF / (1000 / CFG_SYSTICK_DELAY_IN_MS));
return secsActive;
}
#endif

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/systick/systick.h"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/timer16/timer16.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/timer16/timer16.h"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/timer32/timer32.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/timer32/timer32.h"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/uart/uart.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/uart/uart.h"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/uart/uart_buf.c"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/usbcdc/cdc.h"

View File

@ -0,0 +1,2 @@
/* AUTOGENERATED SOURCE FILE */
#include "../../../../firmware/core/usbcdc/cdc_buf.c"

Some files were not shown because too many files have changed in this diff Show More