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

This commit is contained in:
Stefan `Sec` Zehl 2011-07-24 10:26:39 +02:00
commit 53ff9f468e
8 changed files with 24 additions and 88 deletions

View File

@ -33,8 +33,6 @@
#define FLAME_DOWN 0x03
#define FLAME_DOWN_WAIT 0x04
uint8_t isNight = 1; //TODO SEC implement me
void ReinvokeISP(void);
/**************************************************************************/
@ -58,7 +56,7 @@ void tick_flame(void) { // every 10ms
flameTicks++;
if (flameMode == FLAME_OFF) {
if (isNight == 1) {
if (isNight()) {
flameTicks = 0;
flameMode = FLAME_UP;
}

View File

@ -2,9 +2,9 @@
#include "basic/basic.h"
//#include "lcd/render.h"
#include "lcd/render.h"
#include "lcd/display.h"
//#include "lcd/allfonts.h"
#include "lcd/allfonts.h"
#define BITSET_X (RESX+2)
#define BITSET_Y (RESY+2)
@ -79,7 +79,7 @@ uint32_t sum_area(struct bitset *area, uchar x0, uchar y0, uchar x1, uchar y1) {
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));
lcdSetPixel(x,y,lcdGetPixel(x,y)^bitset_get2(life,x+1,y+1));
}
}
}
@ -162,13 +162,18 @@ uchar randdensity=0;
void main_life(void) {
backlightInit();
reset_area();
lcdFill(0);
font = &Font_Orbitron14pt;
int dx;
dx=DoString(20,20,"NICK");
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) {
@ -193,8 +198,9 @@ void main_life(void) {
stepmode=1;
break;
}
draw_area();
draw_area(); // xor life pattern over display content
lcdDisplay();
draw_area(); // xor life pattern again to restore original display content
delayms(10);
calc_area();
}

View File

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

View File

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

View File

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

View File

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

View File

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

View File

@ -1,83 +1,5 @@
#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);
}
#include "core/sysinit.h"
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
}