X-Git-Url: http://wien.tomnetworks.com/gitweb/?p=pyfrprog.git;a=blobdiff_plain;f=pkernel%2Fmain.c;h=8e92a3a7616c8ca4e4b7c52e2aa5f98b48dd5da9;hp=78ca2dc6851ba8ca9e93fc149f0b355aa72dfd97;hb=HEAD;hpb=179d0a77f47e6b4c1e5f72d19352d121511812ab diff --git a/pkernel/main.c b/pkernel/main.c index 78ca2dc..8e92a3a 100644 --- a/pkernel/main.c +++ b/pkernel/main.c @@ -1,15 +1,27 @@ #include "mb91465k.h" #include "flash.h" -#pragma section CODE=IRAM,attr=CODE - #define BUFSIZE 0x20 #define cleardata() memset(data,0,BUFSIZE) -static void increaseled(void) +void increaseled(void) { - PDR14 = ~(((~PDR14)+1)%256); - HWWD_CL = 0; +#define T_INIT 1100 + static unsigned int t = T_INIT; + static unsigned char l = (1<<0); + static unsigned char s = 1; + if(t == 0) { + if(l & (1<<0)) { + s = 1; + } else if (l & (1<<7)) { + s = 0; + } + l = s ? l << 1 : l >> 1; + PDR14 = ~l; + t = T_INIT; + } else { + t--; + } } static unsigned char recvbyte(void) @@ -58,8 +70,6 @@ void main(void) unsigned short i, size, next; unsigned char running = 1, data[BUFSIZE] = {0}; - PORTEN = 0x3; /* enable I/O Ports */ - /*Enable LEDs*/ DDR14 = 0xFF; PDR14 = 0xff; @@ -73,31 +83,13 @@ void main(void) switch(recvbyte()) { case 0x15: //chip erase Putch4(0x45); - increaseled(); + PDR14 = ~(0x05); if(FLASH_ChipErase() != 1) { panic(); } Putch4(0x23); break; - case 0x12: //erase - Putch4(0x11); - address = recvdword(); - increaseled(); - - size = recvword(); - increaseled(); - - PDR14 = 0xff; - for(i=0; i<(size+4); i+=4) { /* erase */ - if(FLASH_SectorErase(address + i) != 1) { - panic(); - } - increaseled(); - } - Putch4(0x18); //Erasing done. - break; - case 0x13: //receive Putch4(0x37); increaseled(); @@ -108,15 +100,11 @@ void main(void) size = recvword(); increaseled(); - Putch4(0x04); //Received Metadata. - PDR14 = 0xff; for(i=0; i