From 4ef55456b0c0d862a104e717bd12a514420b3747 Mon Sep 17 00:00:00 2001 From: Bernhard Urban Date: Sat, 24 Apr 2010 21:13:29 +0200 Subject: [PATCH] nicer led output --- pkernel/main.c | 26 +++++++++++++++++++++----- 1 file changed, 21 insertions(+), 5 deletions(-) diff --git a/pkernel/main.c b/pkernel/main.c index 74d1659..8e92a3a 100644 --- a/pkernel/main.c +++ b/pkernel/main.c @@ -4,9 +4,24 @@ #define BUFSIZE 0x20 #define cleardata() memset(data,0,BUFSIZE) -static void increaseled(void) +void increaseled(void) { - PDR14 = ~(((~PDR14)+1)%256); +#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) @@ -68,7 +83,7 @@ void main(void) switch(recvbyte()) { case 0x15: //chip erase Putch4(0x45); - increaseled(); + PDR14 = ~(0x05); if(FLASH_ChipErase() != 1) { panic(); } @@ -85,13 +100,11 @@ void main(void) size = recvword(); increaseled(); - PDR14 = 0xff; for(i=0; i