X-Git-Url: http://wien.tomnetworks.com/gitweb/?a=blobdiff_plain;f=pkernel%2Fmain.c;h=3676387a43694582dcf5e33e73b4d59a5a15f63e;hb=53f7a41d712ea632f433699ad64900fd23d42a89;hp=89fc2c85f0a415eb04839d99c4a7a0b86e154905;hpb=ccf858667cbb6492aeb2f8ec5d6c05492e926ec3;p=pyfrprog.git diff --git a/pkernel/main.c b/pkernel/main.c index 89fc2c8..3676387 100644 --- a/pkernel/main.c +++ b/pkernel/main.c @@ -3,89 +3,136 @@ #pragma section CODE=IRAM,attr=CODE -void increaseled(void) +#define BUFSIZE 0x20 +#define cleardata() memset(data,0,BUFSIZE) + +static void increaseled(void) { - PDR14 = (PDR14+1)%256; + PDR14 = ~(((~PDR14)+1)%256); HWWD_CL = 0; } +static unsigned char recvbyte(void) +{ + return Getch4(); +} + +static unsigned short recvword(void) +{ + static unsigned char b1, b2; + static unsigned int ret; + b1 = recvbyte(); + b2 = recvbyte(); + ret = (b2 << 8) | b1; + return ret; +} + +static unsigned int recvdword(void) +{ + static unsigned char b1, b2, b3, b4; + static unsigned int ret; + b1 = recvbyte(); + b2 = recvbyte(); + b3 = recvbyte(); + b4 = recvbyte(); + ret = (b4 << 24) | (b3 << 16) | (b2 << 8) | b1; + return ret; +} + +static void halt(void) +{ + while(1) { + HWWD_CL = 0; + } +} + +static void panic(void) +{ + PDR14 = 0xff; + PDR14 = 0x22; + halt(); +} + void main(void) { - unsigned char error = 0; - unsigned char global_error = 0; - unsigned int i, baseaddr; - unsigned int toflash[] = {0x9b00, - 0x0d4e, - 0xcff1, - 0x1601, - 0x9b05, - 0x04c7, - 0xc106, - 0x1656, - 0xe0fb}; //len = 9 + unsigned int address; + unsigned short i, size; + unsigned char running = 1, data[BUFSIZE] = {0}; - PORTEN = 0x3; /* enable I/O Ports */ - /* This feature is not supported by MB91V460A */ - /* For all other devices the I/O Ports must be enabled*/ + PORTEN = 0x3; /* enable I/O Ports */ - /* Enable LEDs */ + /*Enable LEDs*/ DDR14 = 0xFF; PDR14 = 0xff; - /* Initialize UART4 */ + /*Initialize UART4*/ InitUart4(); - /* Output Welcome Message */ - Puts4(" \n\n"); - Puts4("\n\n********** Welcome to FUJITSU FLASH Programming Demo **********\n"); + while(running) { + cleardata(); + increaseled(); + switch(recvbyte()) { + case 0x13: //receive + Putch4(0x37); + increaseled(); -#if 1 - i = 0; - baseaddr = 0xf4000; - for (; i <0x30; i+=4) { - error = FLASH_SectorErase(baseaddr + i); - Puts4("\nerased: "); - Puts4(error == 1 ? "[success] " : "[failed] "); - Puthex4(baseaddr + i, 6); - } -#endif - i=0; - Puts4("\nCurrent Content of FLASH at 0xf4000 ... 0xf401F:\n"); - while(i < 0x20) - { - Puts4("0x"); Puthex4( *(unsigned char *)(0xf4000 + i), 2); Puts4(" "); - i++; - if( (i % 0x10) == 0 ) Puts4("\n"); + address = recvdword(); + increaseled(); + + size = recvword(); + increaseled(); + + Putch4(0x04); //Received Metadata. + PDR14 = 0xff; + for(i=0; i