X-Git-Url: http://cvs.zerfleddert.de/cgi-bin/gitweb.cgi/proxmark3-svn/blobdiff_plain/d00a30d56fc4200a9a921d37ab7dc9e18e092bc0..e6158a48ecc4dbd344604fcb562315931c68d2ff:/armsrc/appmain.c?ds=inline diff --git a/armsrc/appmain.c b/armsrc/appmain.c index 70cabd2e..56bf67e0 100644 --- a/armsrc/appmain.c +++ b/armsrc/appmain.c @@ -13,7 +13,6 @@ #include #include "usb_cdc.h" -#include "cmd.h" #include "proxmark3.h" #include "apps.h" #include "fpga.h" @@ -312,6 +311,7 @@ void set_hw_capabilities(void) { void SendVersion(void) { + LED_A_ON(); set_hw_capabilities(); char temp[USB_CMD_DATA_SIZE]; /* Limited data payload in USB packets */ @@ -347,7 +347,8 @@ void SendVersion(void) { // Send Chip ID and used flash memory uint32_t text_and_rodata_section_size = (uint32_t)&__data_src_start__ - (uint32_t)&_flash_start; uint32_t compressed_data_section_size = common_area.arg1; - cmd_send(CMD_ACK, *(AT91C_DBGU_CIDR), text_and_rodata_section_size + compressed_data_section_size, hw_capabilities, VersionString, strlen(VersionString)); + cmd_send(CMD_ACK, *(AT91C_DBGU_CIDR), text_and_rodata_section_size + compressed_data_section_size, hw_capabilities, VersionString, strlen(VersionString) + 1); + LED_A_OFF(); } // measure the USB Speed by sending SpeedTestBufferSize bytes to client and measuring the elapsed time. @@ -363,13 +364,11 @@ void printUSBSpeed(void) { uint32_t start_time = end_time = GetTickCount(); uint32_t bytes_transferred = 0; - LED_B_ON(); - while(end_time < start_time + USB_SPEED_TEST_MIN_TIME) { + while (end_time < start_time + USB_SPEED_TEST_MIN_TIME) { cmd_send(CMD_DOWNLOADED_RAW_ADC_SAMPLES_125K, 0, USB_CMD_DATA_SIZE, 0, test_data, USB_CMD_DATA_SIZE); end_time = GetTickCount(); bytes_transferred += USB_CMD_DATA_SIZE; } - LED_B_OFF(); Dbprintf(" Time elapsed: %dms", end_time - start_time); Dbprintf(" Bytes transferred: %d", bytes_transferred); @@ -382,6 +381,7 @@ void printUSBSpeed(void) { * Prints runtime information about the PM3. **/ void SendStatus(void) { + LED_A_ON(); BigBuf_print_status(); Fpga_print_status(); #ifdef WITH_SMARTCARD @@ -394,7 +394,8 @@ void SendStatus(void) { Dbprintf(" ToSendMax..........%d", ToSendMax); Dbprintf(" ToSendBit..........%d", ToSendBit); - cmd_send(CMD_ACK,1,0,0,0,0); + cmd_send(CMD_ACK, 1, 0, 0, 0, 0); + LED_A_OFF(); } #if defined(WITH_ISO14443a_StandAlone) || defined(WITH_LF_StandAlone) @@ -936,9 +937,7 @@ void ListenReaderField(int limit) { } -void UsbPacketReceived(uint8_t *packet, int len) { - - UsbCommand *c = (UsbCommand *)packet; +void UsbPacketReceived(UsbCommand *c) { // Dbprintf("received %d bytes, with command: 0x%04x and args: %d %d %d",len,c->cmd,c->arg[0],c->arg[1],c->arg[2]); @@ -1337,9 +1336,11 @@ void UsbPacketReceived(uint8_t *packet, int len) { break; case CMD_FPGA_MAJOR_MODE_OFF: // ## FPGA Control + LED_A_ON(); FpgaWriteConfWord(FPGA_MAJOR_MODE_OFF); SpinDelay(200); LED_D_OFF(); // LED D indicates field ON or OFF + LED_A_OFF(); break; case CMD_DOWNLOAD_RAW_ADC_SAMPLES_125K: @@ -1428,7 +1429,7 @@ void UsbPacketReceived(uint8_t *packet, int len) { case CMD_DEVICE_INFO: { uint32_t dev_info = DEVICE_INFO_FLAG_OSIMAGE_PRESENT | DEVICE_INFO_FLAG_CURRENT_MODE_OS; if(common_area.flags.bootrom_present) dev_info |= DEVICE_INFO_FLAG_BOOTROM_PRESENT; - cmd_send(CMD_DEVICE_INFO,dev_info,0,0,0,0); + cmd_send_old(CMD_DEVICE_INFO,dev_info,0,0,0,0); break; } default: @@ -1466,26 +1467,25 @@ void __attribute__((noreturn)) AppMain(void) { // Reset SPI AT91C_BASE_SPI->SPI_CR = AT91C_SPI_SWRST; + AT91C_BASE_SPI->SPI_CR = AT91C_SPI_SWRST; // required twice on some AT91SAM Revisions (see Errata in AT91SAM datasheet) // Reset SSC AT91C_BASE_SSC->SSC_CR = AT91C_SSC_SWRST; - // Load the FPGA image, which we have stored in our flash. - // (the HF version by default) + // Load the FPGA image, which we have stored in our flash (HF version by default) FpgaDownloadAndGo(FPGA_BITSTREAM_HF); - + StartTickCount(); #ifdef WITH_LCD LCDInit(); #endif - uint8_t rx[sizeof(UsbCommand)]; - size_t rx_len; - + UsbCommand rx; + for(;;) { WDT_HIT(); - if (usb_poll() && (rx_len = usb_read(rx, sizeof(rx)))) { - UsbPacketReceived(rx, rx_len); + if (cmd_receive(&rx)) { + UsbPacketReceived(&rx); } else { #if defined(WITH_LF_StandAlone) && !defined(WITH_ISO14443a_StandAlone) if (BUTTON_HELD(1000) > 0)