diff --git a/avr/usbload/commandline/opendevice.c b/avr/usbload/commandline/opendevice.c index d2a7b69..7706310 100644 --- a/avr/usbload/commandline/opendevice.c +++ b/avr/usbload/commandline/opendevice.c @@ -11,6 +11,7 @@ * open a device based on libusb or libusb-win32. */ + #include #include "opendevice.h" diff --git a/avr/usbload/commandline/snesuploader b/avr/usbload/commandline/snesuploader index 4c4cc76..ff16443 100755 Binary files a/avr/usbload/commandline/snesuploader and b/avr/usbload/commandline/snesuploader differ diff --git a/avr/usbload/config.h b/avr/usbload/config.h index 31752ba..1377182 100644 --- a/avr/usbload/config.h +++ b/avr/usbload/config.h @@ -1,10 +1,10 @@ -#ifndef __config_h__ -#define __config_h__ +#ifndef __CONFIH_H__ +#define __CONFIH_H__ #define DEBUG 1 #define DEBUG_USB 2 -#define DEBUG_USB_RAW 4 +#define DEBUG_USB_TRANS 4 #define DEBUG_SRAM 8 #define DEBUG_SRAM_RAW 16 #define DEBUG_SREG 32 diff --git a/avr/usbload/crc.h b/avr/usbload/crc.h index a563156..146ab4d 100644 --- a/avr/usbload/crc.h +++ b/avr/usbload/crc.h @@ -1,3 +1,7 @@ + +#ifndef __CRC_H__ +#define __CRC_H__ + #include #include @@ -8,3 +12,5 @@ uint16_t do_crc_update(uint16_t crc,uint8_t * data,uint16_t size); void crc_check_memory(uint32_t bottom_addr,uint32_t top_addr,uint8_t *buffer); uint16_t crc_check_memory_range(uint32_t start_addr, uint32_t size,uint8_t *buffer); void crc_check_bulk_memory(uint32_t bottom_addr,uint32_t top_addr); + +#endif diff --git a/avr/usbload/debug.c b/avr/usbload/debug.c index d95fdc0..17f77b8 100644 --- a/avr/usbload/debug.c +++ b/avr/usbload/debug.c @@ -13,7 +13,7 @@ extern int debug_level; /* the higher, the more messages... */ /* Nothing. debug has been "defined away" in debug.h already. */ #else void debug(int level, char* format, ...) { -#ifdef NDEBUG +#ifdef NO_DEBUG /* Empty body, so a good compiler will optimise calls to pmesg away */ #else diff --git a/avr/usbload/debug.h b/avr/usbload/debug.h index ff39127..fc3af63 100644 --- a/avr/usbload/debug.h +++ b/avr/usbload/debug.h @@ -1,5 +1,5 @@ -#ifndef DEBUG_H -#define DEBUG_H +#ifndef __DEBUG_H__ +#define __DEBUG_H__ #include #include diff --git a/avr/usbload/dump.h b/avr/usbload/dump.h index 9085274..a748341 100644 --- a/avr/usbload/dump.h +++ b/avr/usbload/dump.h @@ -1,5 +1,5 @@ -#ifndef DUMP_H -#define DUMP_H +#ifndef __DUMP_H__ +#define __DUMP_H__ #include #include diff --git a/avr/usbload/fifo.h b/avr/usbload/fifo.h index bcf9aad..2d05d4b 100644 --- a/avr/usbload/fifo.h +++ b/avr/usbload/fifo.h @@ -1,5 +1,5 @@ -#ifndef _FIFO_H_ -#define _FIFO_H_ +#ifndef __FIFO_H__ +#define __FIFO_H__ #include #include diff --git a/avr/usbload/main.c b/avr/usbload/main.c index 3a40f3b..d07e9d4 100644 --- a/avr/usbload/main.c +++ b/avr/usbload/main.c @@ -44,9 +44,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) if (rq->bRequest == USB_UPLOAD_INIT) { if (req_state != REQ_STATUS_IDLE){ -#if DEBUG_USB - printf("USB_UPLOAD_INIT: ERROR state is not REQ_STATUS_IDLE\n"); -#endif + debug(DEBUG_USB,"USB_UPLOAD_INIT: ERROR state is not REQ_STATUS_IDLE\n"); return 0; } @@ -55,9 +53,8 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) req_bank_size = 1 << rq->wValue.word; sync_errors = 0; crc = 0; -#if DEBUG_USB - printf("USB_UPLOAD_INIT: bank_size=0x%x\n", req_bank_size); -#endif + debug(DEBUG_USB,"USB_UPLOAD_INIT: bank_size=0x%x\n", req_bank_size); + /* * ------------------------------------------------------------------------- */ @@ -69,29 +66,24 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) req_addr = req_addr | rq->wIndex.word; if (rx_remaining) { sync_errors++; -#if DEBUG_USB - printf - ("USB_UPLOAD_ADDR: Out of sync addr=0x%lx remain=%i packet=%i sync_error=%i\n", + debug + (DEBUG_USB,"USB_UPLOAD_ADDR: Out of sync addr=0x%lx remain=%i packet=%i sync_error=%i\n", req_addr, rx_remaining, rq->wLength.word, sync_errors); -#endif ret_len = 0; } rx_remaining = rq->wLength.word; ret_len = USB_MAX_TRANS; -#if DEBUG_USB + if (req_addr && (req_addr % 0x1000) == 0) { - - printf("USB_UPLOAD_ADDR: bank=0x%02x addr=0x%08lx\n", + debug(DEBUG_USB,"USB_UPLOAD_ADDR: bank=0x%02x addr=0x%08lx\n", req_bank, req_addr); crc_check_bulk_memory(req_addr - 0x1000,req_addr); } -#endif if (req_addr && req_addr % req_bank_size == 0) { -#if DEBUG_USB - printf("USB_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx\n", + debug(DEBUG_USB,"USB_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx\n", req_bank, req_addr); -#endif + req_bank++; } ret_len = USB_MAX_TRANS; @@ -99,22 +91,19 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) * ------------------------------------------------------------------------- */ } else if (rq->bRequest == USB_DOWNLOAD_INIT) { -#if DEBUG_USB - printf("USB_DOWNLOAD_INIT\n"); -#endif + debug(DEBUG_USB,"USB_DOWNLOAD_INIT\n"); + /* * ------------------------------------------------------------------------- */ } else if (rq->bRequest == USB_DOWNLOAD_ADDR) { - printf("USB_DOWNLOAD_ADDR\n"); + debug(DEBUG_USB,"USB_DOWNLOAD_ADDR\n"); /* * ------------------------------------------------------------------------- */ } else if (rq->bRequest == USB_BULK_UPLOAD_INIT) { if (req_state != REQ_STATUS_IDLE){ -#if DEBUG_USB - printf("USB_BULK_UPLOAD_INIT: ERROR state is not REQ_STATUS_IDLE\n"); -#endif + debug(DEBUG_USB,"USB_BULK_UPLOAD_INIT: ERROR state is not REQ_STATUS_IDLE\n"); return 0; } @@ -122,27 +111,21 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) rx_remaining = 0; req_bank_size = (1 << rq->wValue.word) & 0xffff; sync_errors = 0; -#if DEBUG_USB - printf("USB_BULK_UPLOAD_INIT: bank_size=0x%x\n", req_bank_size); -#endif + debug(DEBUG_USB,"USB_BULK_UPLOAD_INIT: bank_size=0x%x\n", req_bank_size); /* * ------------------------------------------------------------------------- */ } else if (rq->bRequest == USB_BULK_UPLOAD_ADDR) { if (req_state != REQ_STATUS_IDLE){ -#if DEBUG_USB - printf("USB_BULK_UPLOAD_ADDR: ERROR state is not REQ_STATUS_IDLE\n"); -#endif + debug(DEBUG_USB,"USB_BULK_UPLOAD_ADDR: ERROR state is not REQ_STATUS_IDLE\n"); return 0; } req_state = REQ_STATUS_BULK_UPLOAD; req_addr = rq->wValue.word; req_addr = req_addr << 16; req_addr = req_addr | rq->wIndex.word; -#if DEBUG_USB - printf("USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx \n",req_bank,req_addr); -#endif + debug(DEBUG_USB,"USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx \n",req_bank,req_addr); ret_len = 0; /* @@ -151,27 +134,21 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) } else if (rq->bRequest == USB_BULK_UPLOAD_NEXT) { if (req_state != REQ_STATUS_BULK_UPLOAD){ -#if DEBUG_USB - printf("USB_BULK_UPLOAD_NEXT: ERROR state is not REQ_STATUS_BULK_UPLOAD\n"); -#endif + debug(DEBUG_USB,"USB_BULK_UPLOAD_NEXT: ERROR state is not REQ_STATUS_BULK_UPLOAD\n"); return 0; } if (rx_remaining) { sync_errors++; -#if DEBUG_USB - printf - ("USB_BULK_UPLOAD_NEXT: Out of sync addr=0x%lx remain=%i packet=%i sync_error=%i\n", + debug(DEBUG_USB, + "USB_BULK_UPLOAD_NEXT: Out of sync addr=0x%lx remain=%i packet=%i sync_error=%i\n", req_addr, rx_remaining, rq->wLength.word, sync_errors); -#endif ret_len = 0; } rx_remaining = rq->wLength.word; ret_len = USB_MAX_TRANS; if (req_addr && req_addr % req_bank_size == 0) { -#if DEBUG_USB - printf("USB_BULK_UPLOAD_NEXT: req_bank=0x%02x addr= 0x%08lx \n", + debug(DEBUG_USB,"USB_BULK_UPLOAD_NEXT: req_bank=0x%02x addr= 0x%08lx \n", req_bank, req_addr); -#endif req_bank++; } ret_len = USB_MAX_TRANS; @@ -179,17 +156,11 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) * ------------------------------------------------------------------------- */ } else if (rq->bRequest == USB_BULK_UPLOAD_END) { - if (req_state != REQ_STATUS_BULK_UPLOAD){ -#if DEBUG_USB - printf("USB_BULK_UPLOAD_END: ERROR state is not REQ_STATUS_BULK_UPLOAD\n"); -#endif + debug(DEBUG_USB,"USB_BULK_UPLOAD_END: ERROR state is not REQ_STATUS_BULK_UPLOAD\n"); return 0; } - -#if DEBUG_USB - printf("USB_BULK_UPLOAD_END:\n"); -#endif + debug(DEBUG_USB,"USB_BULK_UPLOAD_END:\n"); req_state = REQ_STATUS_IDLE; sram_bulk_write_end(); ret_len = 0; @@ -200,10 +171,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) req_addr = rq->wValue.word; req_addr = req_addr << 16; req_addr = req_addr | rq->wIndex.word; -#if DEBUG_USB - printf("USB_CRC: addr=0x%08lx \n", req_addr); -#endif - + debug(DEBUG_USB,"USB_CRC: addr=0x%08lx \n", req_addr); crc_check_bulk_memory(0x000000,req_addr); ret_len = 0; /* @@ -211,10 +179,8 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) */ } else if (rq->bRequest == USB_SNES_BOOT) { req_state = REQ_STATUS_BOOT; -#if DEBUG_USB - printf("USB_SNES_BOOT: "); + debug(DEBUG_USB,"USB_SNES_BOOT: "); ret_len = 0; -#endif /* * ------------------------------------------------------------------------- */ @@ -224,22 +190,16 @@ usbMsgLen_t usbFunctionSetup(uchar data[8]) req_addr = rq->wValue.word; req_addr = req_addr << 16; req_addr = req_addr | rq->wIndex.word; -#if DEBUG_USB - printf("USB_CRC_ADDR: addr=0x%lx size=%i\n", req_addr, + debug(DEBUG_USB,"USB_CRC_ADDR: addr=0x%lx size=%i\n", req_addr, rq->wLength.word); -#endif req_size = rq->wLength.word; req_size = req_size << 2; tx_remaining = 2; -#if DEBUG_USB - printf("USB_CRC_ADDR: addr=0x%lx size=%li\n", req_addr, req_size); -#endif + debug(DEBUG_USB,"USB_CRC_ADDR: addr=0x%lx size=%li\n", req_addr, req_size); - cli(); crc = crc_check_memory_range(req_addr,req_size,read_buffer); tx_buffer[0] = crc & 0xff; tx_buffer[1] = (crc >> 8) & 0xff; - sei(); ret_len = 2; req_state = REQ_STATUS_IDLE; } diff --git a/avr/usbload/requests.h b/avr/usbload/requests.h index 892144a..78da0a2 100644 --- a/avr/usbload/requests.h +++ b/avr/usbload/requests.h @@ -13,8 +13,8 @@ * communicate between the host and the device. */ -#ifndef __REQUESTS_H_INCLUDED__ -#define __REQUESTS_H_INCLUDED__ +#ifndef __REQUESTS_H__ +#define __REQUESTS_H__ #define USB_UPLOAD_INIT 0 #define USB_UPLOAD_ADDR 1 diff --git a/avr/usbload/sram.c b/avr/usbload/sram.c index 42ae2b0..1603ab7 100644 --- a/avr/usbload/sram.c +++ b/avr/usbload/sram.c @@ -57,6 +57,7 @@ void system_init(void) PORTD &= ~((1 << AVR_SNES_SW_PIN) | (1 << SNES_WR_EN_PIN)); + /*-------------------------------------------------*/ @@ -66,28 +67,19 @@ void system_init(void) void sreg_set(uint32_t addr) { uint8_t i = 24; -#if DEBUG_SREG - printf("sreg_set: addr=0x%08lx",addr); -#endif + debug(DEBUG_SREG,"sreg_set: addr=0x%08lx",addr); while(i--) { if ((addr & ( 1L << i))){ -#if DEBUG_SREG - printf("1"); -#endif + debug(DEBUG_SREG,"1"); AVR_ADDR_SER_PORT |= ( 1 << AVR_ADDR_SER_PIN); } else { AVR_ADDR_SER_PORT &= ~( 1 << AVR_ADDR_SER_PIN); -#if DEBUG_SREG - printf("0"); -#endif - + debug(DEBUG_SREG,"0"); } AVR_ADDR_SCK_PORT |= (1 << AVR_ADDR_SCK_PIN); AVR_ADDR_SCK_PORT &= ~(1 << AVR_ADDR_SCK_PIN); } -#if DEBUG_SREG - printf("\n"); -#endif + debug(DEBUG_SREG,"\n"); AVR_ADDR_LATCH_PORT |= (1 << AVR_ADDR_LATCH_PIN); AVR_ADDR_LATCH_PORT &= ~(1 << AVR_ADDR_LATCH_PIN); @@ -99,9 +91,7 @@ void sreg_set(uint32_t addr) void sram_bulk_read_start(uint32_t addr) { -#if DEBUG_SRAM - printf("sram_bulk_read_start: addr=0x%08lx\n\r", addr); -#endif + debug(DEBUG_SRAM,"sram_bulk_read_start: addr=0x%08lx\n\r", addr); avr_data_in(); AVR_CS_PORT &= ~(1 << AVR_CS_PIN); @@ -141,9 +131,8 @@ inline uint8_t sram_bulk_read(void) void sram_bulk_read_end(void) { -#if DEBUG_SRAM - printf("sram_bulk_read_end:"); -#endif + debug(DEBUG_SRAM,"sram_bulk_read_end:"); + AVR_RD_PORT |= (1 << AVR_RD_PIN); AVR_CS_PORT |= (1 << AVR_CS_PIN); avr_data_in(); @@ -152,9 +141,7 @@ void sram_bulk_read_end(void) uint8_t sram_read(uint32_t addr) { uint8_t byte; -#if DEBUG_SRAM_RAW - printf("sram_read: addr=0x%08lx\n\r", addr); -#endif + debug(DEBUG_SRAM_RAW,"sram_read: addr=0x%08lx\n\r", addr); avr_data_in(); @@ -186,9 +173,7 @@ uint8_t sram_read(uint32_t addr) void sram_bulk_write_start(uint32_t addr) { -#if DEBUG_SRAM - printf("sram_bulk_write_start: addr=0x%08lx\n\r", addr); -#endif + debug(DEBUG_SRAM,"sram_bulk_write_start: addr=0x%08lx\n\r", addr); avr_data_out(); @@ -215,9 +200,7 @@ inline void sram_bulk_write( uint8_t data) void sram_bulk_write_end(void) { -#if DEBUG_SRAM - printf("sram_bulk_write_end:"); -#endif + debug(DEBUG_SRAM,"sram_bulk_write_end:"); AVR_WR_PORT |= (1 << AVR_WR_PIN); AVR_CS_PORT |= (1 << AVR_CS_PIN); avr_data_in(); @@ -226,10 +209,7 @@ void sram_bulk_write_end(void) void sram_write(uint32_t addr, uint8_t data) { - -#if DEBUG_SRAM_RAW - printf("sram_write: addr=0x%08lx data=%x\n\r", addr, data); -#endif + debug(DEBUG_SRAM_RAW,"sram_write: addr=0x%08lx data=%x\n\r", addr, data); avr_data_out(); @@ -254,9 +234,7 @@ void sram_bulk_copy(uint32_t addr, uint8_t * src, uint32_t len) uint32_t i; uint8_t *ptr = src; -#if DEBUG_SRAM - printf("sram_copy: addr=0x%08lx src=0x%p len=%li\n\r", addr,src,len); -#endif + debug(DEBUG_SRAM,"sram_copy: addr=0x%08lx src=0x%p len=%li\n\r", addr,src,len); sram_bulk_write_start(addr); for (i = addr; i < (addr + len); i++){ sram_bulk_write(*ptr++); @@ -270,9 +248,7 @@ void sram_bulk_read_buffer(uint32_t addr, uint8_t * dst, uint32_t len) uint32_t i; uint8_t *ptr = dst; -#if DEBUG_SRAM - printf("sram_bulk_read_buffer: addr=0x%08lx dst=0x%p len=%li\n\r", addr,dst,len); -#endif + debug(DEBUG_SRAM,"sram_bulk_read_buffer: addr=0x%08lx dst=0x%p len=%li\n\r", addr,dst,len); sram_bulk_read_start(addr); for (i = addr; i < (addr + len); i++) { *ptr = sram_bulk_read(); @@ -284,15 +260,11 @@ void sram_bulk_read_buffer(uint32_t addr, uint8_t * dst, uint32_t len) void sram_bulk_set(uint32_t addr, uint32_t len,uint8_t value){ uint32_t i; -#if DEBUG_SRAM - printf("sram_bulk_set: addr=0x%08lx len=%li\n\r", addr,len); -#endif + debug(DEBUG_SRAM,"sram_bulk_set: addr=0x%08lx len=%li\n\r", addr,len); sram_bulk_write_start(addr); for (i = addr; i < (addr + len); i++) { if (0 == i % 0xfff) -#if DEBUG_SRAM - printf("sram_bulk_set: addr=0x%08lx\n\r", i); -#endif + debug(DEBUG_SRAM,"sram_bulk_set: addr=0x%08lx\n\r", i); sram_bulk_write(value); sram_bulk_write_next(); } @@ -302,14 +274,10 @@ void sram_bulk_set(uint32_t addr, uint32_t len,uint8_t value){ void sram_setr(uint32_t addr, uint32_t len,uint8_t value) { uint32_t i; -#if DEBUG_SRAM - printf("sram_clear: addr=0x%08lx len=%li\n\r", addr,len); -#endif + debug(DEBUG_SRAM,"sram_clear: addr=0x%08lx len=%li\n\r", addr,len); for (i = addr; i < (addr + len); i++) { if (0 == i % 0xfff) -#if DEBUG_SRAM - printf("sram_clear: addr=0x%08lx\n\r", i); -#endif + debug(DEBUG_SRAM,"sram_clear: addr=0x%08lx\n\r", i); sram_write(i, value); } } @@ -319,9 +287,7 @@ void sram_copy(uint32_t addr, uint8_t * src, uint32_t len) uint32_t i; uint8_t *ptr = src; -#if DEBUG_SRAM - printf("sram_copy: addr=0x%08lx src=0x%p len=%li\n\r", addr,src,len); -#endif + debug(DEBUG_SRAM,"sram_copy: addr=0x%08lx src=0x%p len=%li\n\r", addr,src,len); for (i = addr; i < (addr + len); i++) sram_write(i, *ptr++); } @@ -331,9 +297,7 @@ void sram_read_buffer(uint32_t addr, uint8_t * dst, uint32_t len) uint32_t i; uint8_t *ptr = dst; -#if DEBUG_SRAM - printf("sram_read_buffer: addr=0x%08lx dst=0x%p len=%li\n\r", addr,dst,len); -#endif + debug(DEBUG_SRAM,"sram_read_buffer: addr=0x%08lx dst=0x%p len=%li\n\r", addr,dst,len); for (i = addr; i < (addr + len); i++) { *ptr = sram_read(i); ptr++; @@ -344,9 +308,7 @@ void sram_read_buffer(uint32_t addr, uint8_t * dst, uint32_t len) uint8_t sram_check(uint8_t * buffer, uint32_t len) { uint16_t cnt; -#if DEBUG_SRAM - printf("sram_check: len=%li\n\r",len); -#endif + debug(DEBUG_SRAM,"sram_check: len=%li\n\r",len); for (cnt = 0; cnt < len; cnt++) if (buffer[cnt]) return 1; diff --git a/avr/usbload/sram.h b/avr/usbload/sram.h index 24e2620..cc6eb5f 100644 --- a/avr/usbload/sram.h +++ b/avr/usbload/sram.h @@ -1,3 +1,6 @@ +#ifndef __SRAM_H__ +#define __SRAM_H__ + #include #include #include @@ -142,7 +145,6 @@ void system_init(void); void sreg_set(uint32_t addr); - uint8_t sram_read(uint32_t addr); void sram_write(uint32_t addr, uint8_t data); void sram_set(uint32_t addr, uint32_t len, uint8_t value); @@ -162,3 +164,5 @@ void sram_bulk_write(uint8_t data); void sram_bulk_copy(uint32_t addr, uint8_t * src, uint32_t len); void sram_bulk_read_buffer(uint32_t addr, uint8_t * dst, uint32_t len); void sram_bulk_set(uint32_t addr, uint32_t len,uint8_t value); + +#endif diff --git a/avr/usbload/uart.h b/avr/usbload/uart.h index 7f559ec..e76fccc 100644 --- a/avr/usbload/uart.h +++ b/avr/usbload/uart.h @@ -1,9 +1,8 @@ -#ifndef _UART_H_ -#define _UART_H_ +#ifndef __UART_H__ +#define __UART_H__ #define CR "\r\n" - #include #include #include @@ -14,6 +13,6 @@ void uart_puts(const char *s); void uart_puts_P(PGM_P s); static int uart_stream(char c, FILE *stream); +#endif -#endif /* _UART_H_ */ diff --git a/avr/usbload/usb_bulk.c b/avr/usbload/usb_bulk.c index 8af1354..ab8fe66 100644 --- a/avr/usbload/usb_bulk.c +++ b/avr/usbload/usb_bulk.c @@ -33,26 +33,22 @@ uint8_t usbFunctionWrite(uint8_t * data, uint8_t len) uint8_t *ptr; uint8_t i; if (len > rx_remaining) { - printf("usbFunctionWrite more data than expected remain: %i len: %i\n", + printf("ERROR:usbFunctionWrite more data than expected remain: %i len: %i\n", rx_remaining, len); len = rx_remaining; } if (req_state == REQ_STATUS_UPLOAD) { rx_remaining -= len; -#if DEBUG_USB_RAW - printf("usbFunctionWrite REQ_STATUS_UPLOAD addr: 0x%08lx len: %i rx_remaining=%i\n", + debug(DEBUG_USB_TRANS,"usbFunctionWrite REQ_STATUS_UPLOAD addr: 0x%08lx len: %i rx_remaining=%i\n", req_addr, len, rx_remaining); -#endif sram_copy(req_addr, data, len); req_addr += len; } else if (req_state == REQ_STATUS_BULK_UPLOAD) { rx_remaining -= len; -#if DEBUG_USB_RAW - printf("usbFunctionWrite REQ_STATUS_BULK_UPLOAD addr: 0x%08lx len: %i rx_remaining=%i\n", + debug(DEBUG_USB_TRANS,"usbFunctionWrite REQ_STATUS_BULK_UPLOAD addr: 0x%08lx len: %i rx_remaining=%i\n", req_addr, len, rx_remaining); -#endif ptr = data; i = len; while(i--){ @@ -69,9 +65,8 @@ uint8_t usbFunctionRead(uint8_t * data, uint8_t len) if (len > tx_remaining) len = tx_remaining; tx_remaining -= len; -#if DEBUG_USB_RAW - printf("usbFunctionRead len=%i tx_remaining=%i \n", len, tx_remaining); -#endif + debug(DEBUG_USB_TRANS,"usbFunctionRead len=%i tx_remaining=%i \n", len, tx_remaining); + for (i = 0; i < len; i++) { *data = tx_buffer[len]; data++;