summaryrefslogtreecommitdiff
path: root/usb-i2c-sl018
diff options
context:
space:
mode:
authorOthmar Gsenger <otti@wirdorange.org>2013-01-27 22:40:39 +0000
committerOthmar Gsenger <otti@wirdorange.org>2013-01-27 22:40:39 +0000
commit54e757961318de3599d9589a00d35f65a39a67f8 (patch)
tree408429da79d327ba9df75acd6bfe469f2781b99a /usb-i2c-sl018
parentadded update-keys (no csum function yet) (diff)
eeprom flashing working
git-svn-id: https://svn.spreadspace.org/avr/trunk@75 aa12f405-d877-488e-9caf-2d797e2a1cc7
Diffstat (limited to 'usb-i2c-sl018')
-rw-r--r--usb-i2c-sl018/tuer-rfid.c27
1 files changed, 17 insertions, 10 deletions
diff --git a/usb-i2c-sl018/tuer-rfid.c b/usb-i2c-sl018/tuer-rfid.c
index 1d85fbe..878e731 100644
--- a/usb-i2c-sl018/tuer-rfid.c
+++ b/usb-i2c-sl018/tuer-rfid.c
@@ -159,19 +159,27 @@ void flash_eeprom_from_usb(void)
{
keyslot_t keyslot;
uint8_t keyslot_pos=0;
- fprintf(usb,"Flashing keys: ");
-
+ uint8_t byte_pos=0;
+ fprintf(usb,"Flashing keys:\n\r");
+ fflush(usb);
for(keyslot_pos=0;keyslot_pos<EEPROM_SIZE/sizeof(keyslot);)
{
int16_t BytesReceived = CDC_Device_BytesReceived(&VirtualSerial_CDC_Interface);
- while(BytesReceived >= sizeof(keyslot)) {
- fread(&keyslot,sizeof(keyslot),1,usb);
- eeprom_update_block(&keyslot,&keyslots[keyslot_pos],sizeof(keyslot));
- BytesReceived-=sizeof(keyslot);
- keyslot_pos++;
- led_toggle();
- fprintf(usb,".");
+ while(BytesReceived >0) {
+ keyslot[byte_pos++]=fgetc(usb);
+ BytesReceived--;
+ if (byte_pos == sizeof(keyslot))
+ {
+ byte_pos=0;
+ eeprom_write_block(&keyslot,&keyslots[keyslot_pos],sizeof(keyslot));
+ keyslot_pos++;
+ fprintf(usb,".");
+ fflush(usb);
+ led_toggle();
+ }
}
+ CDC_Device_USBTask(&VirtualSerial_CDC_Interface);
+ USB_USBTask();
}
fprintf(usb,"\n");
}
@@ -265,7 +273,6 @@ int main(void)
cpu_init();
led_init();
- led_on();
USB_Init();
TWI_Init(TWI_BIT_PRESCALE_1, TWI_BITLENGTH_FROM_FREQ(1, 200000));
sei();