Merge branch 'progmem'

Conflicts:
	avr/usbload/rle.c
This commit is contained in:
optixx 2009-08-29 14:32:16 +02:00
commit 68b882acfb
15 changed files with 187 additions and 120 deletions

View File

@ -34,7 +34,7 @@ extern uint32_t req_bank_size;
void send_reset() void send_reset()
{ {
info("Reset SNES\n"); info_P(PSTR("Reset SNES\n"));
cli(); cli();
snes_reset_on(); snes_reset_on();
snes_reset_lo(); snes_reset_lo();
@ -57,9 +57,9 @@ void set_rom_mode()
{ {
if (req_bank_size == 0x8000) { if (req_bank_size == 0x8000) {
snes_lorom(); snes_lorom();
info("Set SNES lowrom \n"); info_P(PSTR("Set SNES lowrom \n"));
} else { } else {
snes_hirom(); snes_hirom();
info("Set SNES hirom \n"); info_P(PSTR("Set SNES hirom \n"));
} }
} }

View File

@ -43,7 +43,7 @@
#define USB_CRC_CHECK 0x01 #define USB_CRC_CHECK 0x01
#define TRANSFER_BUFFER_SIZE 0x200 #define TRANSFER_BUFFER_SIZE 0x200
#define FORMAT_BUFFER_LEN 0x0FF
#define HW_VERSION "2.6" #define HW_VERSION "2.6"
#define SW_VERSION "1.0" #define SW_VERSION "1.0"

View File

@ -71,12 +71,12 @@ uint16_t crc_check_bulk_memory(uint32_t bottom_addr, uint32_t top_addr, uint32_t
uint32_t addr = 0; uint32_t addr = 0;
uint8_t req_bank = 0; uint8_t req_bank = 0;
sram_bulk_read_start(bottom_addr); sram_bulk_read_start(bottom_addr);
debug(DEBUG_CRC,"crc_check_bulk_memory: bottom_addr=0x%08lx top_addr=0x%08lx\n", debug_P(DEBUG_CRC, PSTR("crc_check_bulk_memory: bottom_addr=0x%08lx top_addr=0x%08lx\n"),
bottom_addr,top_addr); bottom_addr,top_addr);
for (addr = bottom_addr; addr < top_addr; addr++) { for (addr = bottom_addr; addr < top_addr; addr++) {
if (addr && addr % bank_size == 0) { if (addr && addr % bank_size == 0) {
debug(DEBUG_CRC,"crc_check_bulk_memory: bank=0x%02x addr=0x%08lx crc=0x%04x\n", debug_P(DEBUG_CRC, PSTR("crc_check_bulk_memory: bank=0x%02x addr=0x%08lx crc=0x%04x\n"),
req_bank,addr,crc); req_bank,addr,crc);
req_bank++; req_bank++;
crc = 0; crc = 0;
@ -85,7 +85,7 @@ uint16_t crc_check_bulk_memory(uint32_t bottom_addr, uint32_t top_addr, uint32_t
sram_bulk_read_next(); sram_bulk_read_next();
} }
if (addr % 0x8000 == 0) if (addr % 0x8000 == 0)
debug(DEBUG_CRC,"crc_check_bulk_memory: bank=0x%02x addr=0x%08lx crc=0x%04x\n", debug_P(DEBUG_CRC, PSTR("crc_check_bulk_memory: bank=0x%02x addr=0x%08lx crc=0x%04x\n"),
req_bank,addr,crc); req_bank,addr,crc);
sram_bulk_read_end(); sram_bulk_read_end();
return crc; return crc;

View File

@ -20,11 +20,11 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <avr/pgmspace.h>
#include "debug.h" #include "debug.h"
#include "uart.h" #include "uart.h"
#include "config.h"
extern FILE uart_stdout; extern FILE uart_stdout;
@ -46,4 +46,23 @@ void debug(int level, char* format, ...) {
} }
#endif #endif
#ifndef NO_INFO
uint8_t buffer_debug[FORMAT_BUFFER_LEN];
#endif
#if defined(NO_DEBUG) && defined(__GNUC__)
#else
void debug_P(int level, PGM_P format, ...) {
#ifdef NO_DEBUG
#else
va_list args;
if (!(debug_level & level))
return;
strlcpy_P(buffer_debug,format,FORMAT_BUFFER_LEN);
va_start(args, format);
vprintf(buffer_debug, args);
va_end(args);
#endif
}
#endif

View File

@ -26,7 +26,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <stdarg.h> #include <stdarg.h>
#include <avr/pgmspace.h>
#if defined(NO_DEBUG) && defined(__GNUC__) #if defined(NO_DEBUG) && defined(__GNUC__)
/* gcc's cpp has extensions; it allows for macros with a variable number of /* gcc's cpp has extensions; it allows for macros with a variable number of
@ -39,5 +39,17 @@ void debug(int level, char *format, ...);
#endif #endif
#if defined(NO_DEBUG) && defined(__GNUC__)
/* gcc's cpp has extensions; it allows for macros with a variable number of
arguments. We use this extension here to preprocess pmesg away. */
#define debug_P(level, format, args...) ((void)0)
#else
void debug_P(int level, PGM_P format, ...);
/* print a message, if it is considered significant enough.
Adapted from [K&R2], p. 174 */
#endif
#endif /* DEBUG_H */ #endif /* DEBUG_H */

View File

@ -47,21 +47,21 @@ void dump_packet(uint32_t addr, uint32_t len, uint8_t * packet)
continue; continue;
} }
if (clear) { if (clear) {
info("*\n"); info_P(PSTR("*\n"));
clear = 0; clear = 0;
} }
info("%08lx:", addr + i); info_P(PSTR("%08lx:"), addr + i);
for (j = 0; j < 16; j++) { for (j = 0; j < 16; j++) {
info(" %02x", packet[i + j]); info_P(PSTR(" %02x"), packet[i + j]);
} }
info(" |"); info_P(PSTR(" |"));
for (j = 0; j < 16; j++) { for (j = 0; j < 16; j++) {
if (packet[i + j] >= 33 && packet[i + j] <= 126) if (packet[i + j] >= 33 && packet[i + j] <= 126)
info("%c", packet[i + j]); info_P(PSTR("%c"), packet[i + j]);
else else
info("."); info_P(PSTR("."));
} }
info("|\n"); info_P(PSTR("|\n"));
} }
} }
@ -72,11 +72,11 @@ void dump_memory(uint32_t bottom_addr, uint32_t top_addr)
sram_bulk_read_start(bottom_addr); sram_bulk_read_start(bottom_addr);
for ( addr = bottom_addr; addr < top_addr; addr++) { for ( addr = bottom_addr; addr < top_addr; addr++) {
if (addr%0x10 == 0) if (addr%0x10 == 0)
info("\n%08lx:", addr); info_P(PSTR("\n%08lx:"), addr);
byte = sram_bulk_read(); byte = sram_bulk_read();
sram_bulk_read_next(); sram_bulk_read_next();
info(" %02x", byte); info_P(PSTR(" %02x"), byte);
} }
info("\n"); info_P(PSTR("\n"));
sram_bulk_read_end(); sram_bulk_read_end();
} }

View File

@ -20,9 +20,12 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <avr/pgmspace.h>
#include "info.h" #include "info.h"
#include "uart.h" #include "uart.h"
#include "config.h"
@ -46,4 +49,26 @@ void info(char* format, ...) {
} }
#endif #endif
#ifndef NO_INFO
uint8_t buffer_info[FORMAT_BUFFER_LEN];
#endif
#if defined(NO_INFO) && defined(__GNUC__)
#define info(format, args...) ((void)0)
#else
void info_P(PGM_P format, ...) {
#ifdef NO_INFO
#else
strlcpy_P(buffer_info,format,FORMAT_BUFFER_LEN);
va_list args;
va_start(args, format);
vprintf(buffer_info, args);
va_end(args);
#endif
}
#endif

View File

@ -26,7 +26,7 @@
#include <stdlib.h> #include <stdlib.h>
#include <stdint.h> #include <stdint.h>
#include <stdarg.h> #include <stdarg.h>
#include <avr/pgmspace.h>
#if defined(NO_INFO) && defined(__GNUC__) #if defined(NO_INFO) && defined(__GNUC__)
/* gcc's cpp has extensions; it allows for macros with a variable number of /* gcc's cpp has extensions; it allows for macros with a variable number of
@ -39,4 +39,15 @@ void info(char *format, ...);
#endif #endif
#if defined(NO_INFO) && defined(__GNUC__)
/* gcc's cpp has extensions; it allows for macros with a variable number of
arguments. We use this extension here to preprocess pmesg away. */
#define info_P(format, args...) ((void)0)
#else
void info_P(PGM_P format, ...);
/* print a message, if it is considered significant enough.
Adapted from [K&R2], p. 174 */
#endif
#endif #endif

View File

@ -64,8 +64,8 @@ void leave_application(void)
ISR (SIG_PIN_CHANGE3) ISR (SIG_PIN_CHANGE3)
{ {
if (snes_reset_test()){ if (snes_reset_test()){
info("Catch SNES reset button\n"); info_P(PSTR("Catch SNES reset button\n"));
info("Set watchdog...\n"); info_P(PSTR("Set watchdog...\n"));
leave_application(); leave_application();
} }
} }

View File

@ -85,7 +85,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
req_bank = 0; req_bank = 0;
rx_remaining = 0; rx_remaining = 0;
debug(DEBUG_USB, "USB_BULK_UPLOAD_INIT: %i %i\n", rq->wValue.word, debug_P(DEBUG_USB, PSTR("USB_BULK_UPLOAD_INIT: %i %i\n"), rq->wValue.word,
rq->wIndex.word); rq->wIndex.word);
req_bank_size = (uint32_t) (1L << rq->wValue.word); req_bank_size = (uint32_t) (1L << rq->wValue.word);
req_bank_cnt = rq->wIndex.word; req_bank_cnt = rq->wIndex.word;
@ -93,8 +93,8 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
req_percent = 0; req_percent = 0;
req_percent_last = 0; req_percent_last = 0;
sync_errors = 0; sync_errors = 0;
debug(DEBUG_USB, debug_P(DEBUG_USB,
"USB_BULK_UPLOAD_INIT: bank_size=0x%08lx bank_cnt=0x%x end_addr=0x%08lx\n", PSTR("USB_BULK_UPLOAD_INIT: bank_size=0x%08lx bank_cnt=0x%x end_addr=0x%08lx\n"),
req_bank_size, req_bank_cnt, req_addr_end); req_bank_size, req_bank_cnt, req_addr_end);
shared_memory_write(SHARED_MEM_TX_CMD_BANK_COUNT, req_bank_cnt); shared_memory_write(SHARED_MEM_TX_CMD_BANK_COUNT, req_bank_cnt);
@ -115,12 +115,12 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
if (req_addr && req_addr % req_bank_size == 0) { if (req_addr && req_addr % req_bank_size == 0) {
#ifdef FLT_DEBUG #ifdef FLT_DEBUG
debug(DEBUG_USB, debug_P(DEBUG_USB,
"USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx time=%.4f\n", PSTR("USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx time=%.4f\n"),
req_bank, req_addr, timer_stop()); req_bank, req_addr, timer_stop());
#else #else
debug(DEBUG_USB, debug_P(DEBUG_USB,
"USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx time=%i\n", PSTR("USB_BULK_UPLOAD_ADDR: req_bank=0x%02x addr=0x%08lx time=%i\n"),
req_bank, req_addr, timer_stop_int()); req_bank, req_addr, timer_stop_int());
#endif #endif
req_bank++; req_bank++;
@ -146,8 +146,8 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
req_percent = (uint32_t)( 100 * req_addr ) / req_addr_end; req_percent = (uint32_t)( 100 * req_addr ) / req_addr_end;
if (req_percent!=req_percent_last){ if (req_percent!=req_percent_last){
//debug(DEBUG_USB, //debug_P(DEBUG_USB,
// "USB_BULK_UPLOAD_ADDR: precent=%i\n", req_percent); // PSTR("USB_BULK_UPLOAD_ADDR: precent=%i\n", req_percent);
shared_memory_write(SHARED_MEM_TX_CMD_UPLOAD_PROGESS, req_percent); shared_memory_write(SHARED_MEM_TX_CMD_UPLOAD_PROGESS, req_percent);
sram_bulk_write_start(req_addr); sram_bulk_write_start(req_addr);
} }
@ -155,8 +155,8 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
#if 0 #if 0
if (req_addr && (req_addr % 0x1000) == 0) { if (req_addr && (req_addr % 0x1000) == 0) {
debug(DEBUG_USB, debug_P(DEBUG_USB,
"USB_BULK_UPLOAD_NEXT: bank=0x%02x addr=0x%08lx crc=%04x\n", PSTR("USB_BULK_UPLOAD_NEXT: bank=0x%02x addr=0x%08lx crc=%04x\n",
req_bank, req_addr, crc_check_bulk_memory(req_addr - 0x1000, req_bank, req_addr, crc_check_bulk_memory(req_addr - 0x1000,
req_addr, req_addr,
req_bank_size)); req_bank_size));
@ -167,8 +167,8 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
#if SHM_SCRATCHPAD #if SHM_SCRATCHPAD
if (!shared_memory_scratchpad_region_save_helper(req_addr)){ if (!shared_memory_scratchpad_region_save_helper(req_addr)){
debug(DEBUG_USB, debug_P(DEBUG_USB,
"USB_BULK_UPLOAD_NEXT: scratchpad_region_save_helper was dirty\n"); PSTR("USB_BULK_UPLOAD_NEXT: scratchpad_region_save_helper was dirty\n"));
sram_bulk_write_start(req_addr); sram_bulk_write_start(req_addr);
} }
#endif #endif
@ -176,12 +176,12 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
if (req_addr && (req_addr % req_bank_size) == 0) { if (req_addr && (req_addr % req_bank_size) == 0) {
#ifdef FLT_DEBUG #ifdef FLT_DEBUG
debug(DEBUG_USB, debug_P(DEBUG_USB,
"USB_BULK_UPLOAD_NEXT: req_bank=0x%02x addr=0x%08lx time=%.4f\n", PSTR("USB_BULK_UPLOAD_NEXT: req_bank=0x%02x addr=0x%08lx time=%.4f\n"),
req_bank, req_addr, timer_stop()); req_bank, req_addr, timer_stop());
#else #else
debug(DEBUG_USB, debug_P(DEBUG_USB,
"USB_BULK_UPLOAD_NEXT: req_bank=0x%02x addr=0x%08lx time=%i\n", PSTR("USB_BULK_UPLOAD_NEXT: req_bank=0x%02x addr=0x%08lx time=%i\n"),
req_bank, req_addr, timer_stop_int()); req_bank, req_addr, timer_stop_int());
#endif #endif
req_bank++; req_bank++;
@ -196,11 +196,11 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
*/ */
} else if (rq->bRequest == USB_BULK_UPLOAD_END) { } else if (rq->bRequest == USB_BULK_UPLOAD_END) {
if (req_state != REQ_STATUS_BULK_UPLOAD) { if (req_state != REQ_STATUS_BULK_UPLOAD) {
debug(DEBUG_USB, debug_P(DEBUG_USB,
"USB_BULK_UPLOAD_END: ERROR state is not REQ_STATUS_BULK_UPLOAD\n"); PSTR("USB_BULK_UPLOAD_END: ERROR state is not REQ_STATUS_BULK_UPLOAD\n"));
return 0; return 0;
} }
debug(DEBUG_USB, "USB_BULK_UPLOAD_END:\n"); debug_P(DEBUG_USB, PSTR("USB_BULK_UPLOAD_END:\n"));
req_state = REQ_STATUS_IDLE; req_state = REQ_STATUS_IDLE;
sram_bulk_write_end(); sram_bulk_write_end();
shared_memory_write(SHARED_MEM_TX_CMD_UPLOAD_END, 0); shared_memory_write(SHARED_MEM_TX_CMD_UPLOAD_END, 0);
@ -213,7 +213,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
req_addr = rq->wValue.word; req_addr = rq->wValue.word;
req_addr = req_addr << 16; req_addr = req_addr << 16;
req_addr = req_addr | rq->wIndex.word; req_addr = req_addr | rq->wIndex.word;
debug(DEBUG_USB, "USB_CRC: addr=0x%08lx \n", req_addr); debug_P(DEBUG_USB, PSTR("USB_CRC: addr=0x%08lx \n"), req_addr);
crc_check_bulk_memory(0x000000, req_addr, req_bank_size); crc_check_bulk_memory(0x000000, req_addr, req_bank_size);
ret_len = 0; ret_len = 0;
/* /*
@ -221,20 +221,20 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
*/ */
} else if (rq->bRequest == USB_MODE_SNES) { } else if (rq->bRequest == USB_MODE_SNES) {
req_state = REQ_STATUS_SNES; req_state = REQ_STATUS_SNES;
debug(DEBUG_USB, "USB_MODE_SNES:\n"); debug_P(DEBUG_USB, PSTR("USB_MODE_SNES:\n"));
ret_len = 0; ret_len = 0;
/* /*
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
*/ */
} else if (rq->bRequest == USB_MODE_AVR) { } else if (rq->bRequest == USB_MODE_AVR) {
req_state = REQ_STATUS_AVR; req_state = REQ_STATUS_AVR;
debug(DEBUG_USB, "USB_MODE_AVR:\n"); debug_P(DEBUG_USB, PSTR("USB_MODE_AVR:\n"));
ret_len = 0; ret_len = 0;
/* /*
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
*/ */
} else if (rq->bRequest == USB_AVR_RESET) { } else if (rq->bRequest == USB_AVR_RESET) {
debug(DEBUG_USB, "USB_AVR_RESET:\n"); debug_P(DEBUG_USB, PSTR("USB_AVR_RESET:\n"));
soft_reset(); soft_reset();
ret_len = 0; ret_len = 0;
/* /*
@ -246,12 +246,12 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
req_addr = rq->wValue.word; req_addr = rq->wValue.word;
req_addr = req_addr << 16; req_addr = req_addr << 16;
req_addr = req_addr | rq->wIndex.word; req_addr = req_addr | rq->wIndex.word;
debug(DEBUG_USB, "USB_CRC_ADDR: addr=0x%lx size=%i\n", req_addr, debug_P(DEBUG_USB, PSTR("USB_CRC_ADDR: addr=0x%lx size=%i\n"), req_addr,
rq->wLength.word); rq->wLength.word);
req_size = rq->wLength.word; req_size = rq->wLength.word;
req_size = req_size << 2; req_size = req_size << 2;
tx_remaining = 2; tx_remaining = 2;
debug(DEBUG_USB, "USB_CRC_ADDR: addr=0x%lx size=%li\n", req_addr, debug_P(DEBUG_USB, PSTR("USB_CRC_ADDR: addr=0x%lx size=%li\n"), req_addr,
req_size); req_size);
crc = crc_check_memory_range(req_addr, req_size, read_buffer); crc = crc_check_memory_range(req_addr, req_size, read_buffer);
@ -274,10 +274,10 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
void usb_connect() void usb_connect()
{ {
uint8_t i = 0; uint8_t i = 0;
info("USB init\n"); info_P(PSTR("USB init\n"));
usbDeviceDisconnect(); /* enforce re-enumeration, do this while */ usbDeviceDisconnect(); /* enforce re-enumeration, do this while */
cli(); cli();
info("USB disconnect\n"); info_P(PSTR("USB disconnect\n"));
i = 10; i = 10;
while (--i) { /* fake USB disconnect for > 250 ms */ while (--i) { /* fake USB disconnect for > 250 ms */
led_on(); led_on();
@ -287,28 +287,28 @@ void usb_connect()
} }
led_on(); led_on();
usbDeviceConnect(); usbDeviceConnect();
info("USB connect\n"); info_P(PSTR("USB connect\n"));
} }
void boot_startup_rom() void boot_startup_rom()
{ {
info("Boot startup rom\n"); info_P(PSTR("Boot startup rom\n"));
info("Activate AVR bus\n"); info_P(PSTR("Activate AVR bus\n"));
avr_bus_active(); avr_bus_active();
info("IRQ off\n"); info_P(PSTR("IRQ off\n"));
snes_irq_lo(); snes_irq_lo();
snes_irq_off(); snes_irq_off();
snes_lorom(); snes_lorom();
rle_decode(&_rom, ROM_BUFFER_SIZE, 0x000000); rle_decode(&_rom, ROM_BUFFER_SIZE, 0x000000);
info("\n"); info_P(PSTR("\n"));
#if 1 #if 1
dump_memory(0x10000 - 0x100, 0x10000); dump_memory(0x10000 - 0x100, 0x10000);
#endif #endif
snes_hirom(); snes_hirom();
snes_wr_disable(); snes_wr_disable();
snes_bus_active(); snes_bus_active();
info("Activate SNES bus\n"); info_P(PSTR("Activate SNES bus\n"));
send_reset(); send_reset();
_delay_ms(50); _delay_ms(50);
send_reset(); send_reset();
@ -318,17 +318,17 @@ void boot_startup_rom()
void banner(){ void banner(){
uint8_t i; uint8_t i;
for (i=0;i<40;i++) for (i=0;i<40;i++)
info("\n"); info_P(PSTR("\n"));
info(" ________ .__ __ ________ ____ ________\n"); info_P(PSTR(" ________ .__ __ ________ ____ ________\n"));
info(" \\_____ \\ __ __|__| ____ | | __\\______ \\ _______ _/_ |/ _____/\n"); info_P(PSTR(" \\_____ \\ __ __|__| ____ | | __\\______ \\ _______ _/_ |/ _____/\n"));
info(" / / \\ \\| | \\ |/ ___\\| |/ / | | \\_/ __ \\ \\/ /| / __ \\ \n"); info_P(PSTR(" / / \\ \\| | \\ |/ ___\\| |/ / | | \\_/ __ \\ \\/ /| / __ \\ \n"));
info(" / \\_/. \\ | / \\ \\___| < | ` \\ ___/\\ / | \\ |__\\ \\ \n"); info_P(PSTR(" / \\_/. \\ | / \\ \\___| < | ` \\ ___/\\ / | \\ |__\\ \\ \n"));
info(" \\_____\\ \\_/____/|__|\\___ >__|_ \\/_______ /\\___ >\\_/ |___|\\_____ / \n"); info_P(PSTR(" \\_____\\ \\_/____/|__|\\___ >__|_ \\/_______ /\\___ >\\_/ |___|\\_____ / \n"));
info(" \\__> \\/ \\/ \\/ \\/ \\/ \n"); info_P(PSTR(" \\__> \\/ \\/ \\/ \\/ \\/ \n"));
info("\n"); info_P(PSTR("\n"));
info(" www.optixx.org\n"); info_P(PSTR(" www.optixx.org\n"));
info("\n"); info_P(PSTR("\n"));
info("System Hw: %s Sw: %s\n",HW_VERSION,SW_VERSION); info_P(PSTR("System Hw: %s Sw: %s\n"),HW_VERSION,SW_VERSION);
} }
@ -357,12 +357,12 @@ int main(void)
usb_connect(); usb_connect();
while (1) { while (1) {
avr_bus_active(); avr_bus_active();
info("Activate AVR bus\n"); info_P(PSTR("Activate AVR bus\n"));
snes_lorom(); snes_lorom();
info("Disable SNES WR\n"); info_P(PSTR("Disable SNES WR\n"));
snes_wr_disable(); snes_wr_disable();
sei(); sei();
info("USB poll\n"); info_P(PSTR("USB poll\n"));
while (req_state != REQ_STATUS_SNES) { while (req_state != REQ_STATUS_SNES) {
usbPoll(); usbPoll();
} }
@ -372,15 +372,15 @@ int main(void)
shared_memory_scratchpad_region_tx_restore(); shared_memory_scratchpad_region_tx_restore();
shared_memory_scratchpad_region_rx_restore(); shared_memory_scratchpad_region_rx_restore();
#endif #endif
info("USB poll done\n"); info_P(PSTR("USB poll done\n"));
set_rom_mode(); set_rom_mode();
snes_wr_disable(); snes_wr_disable();
info("Disable SNES WR\n"); info_P(PSTR("Disable SNES WR\n"));
snes_bus_active(); snes_bus_active();
info("Activate SNES bus\n"); info_P(PSTR("Activate SNES bus\n"));
irq_stop(); irq_stop();
send_reset(); send_reset();
info("Poll USB\n"); info_P(PSTR("Poll USB\n"));
while ((req_state != REQ_STATUS_AVR)) { while ((req_state != REQ_STATUS_AVR)) {
usbPoll(); usbPoll();
@ -391,7 +391,7 @@ int main(void)
while (--i) { while (--i) {
_delay_ms(100); _delay_ms(100);
} }
info("Send IRQ %i\n", ++irq_count); info_P(PSTR("Send IRQ %i\n"), ++irq_count);
send_irq(); send_irq();
#endif #endif
@ -402,7 +402,7 @@ int main(void)
i = 5; i = 5;
while (--i) { while (--i) {
_delay_ms(500); _delay_ms(500);
info("Wait to switch to snes mode %i\n", i); info_P(PSTR("Wait to switch to snes mode %i\n"), i);
} }
if (req_bank_size == 0x8000) { if (req_bank_size == 0x8000) {
@ -411,10 +411,10 @@ int main(void)
snes_hirom(); snes_hirom();
} }
snes_wr_disable(); snes_wr_disable();
info("Disable SNES WR\n"); info_P(PSTR("Disable SNES WR\n"));
snes_bus_active(); snes_bus_active();
info("Activate SNES bus\n"); info_P(PSTR("Activate SNES bus\n"));
info("Read 0x3000=%c\n", c); info_P(PSTR("Read 0x3000=%c\n"), c);
#endif #endif
} }
irq_init(); irq_init();

View File

@ -35,7 +35,7 @@
uint8_t rle_decode(PGM_VOID_P in_addr, int32_t in_len, uint32_t out_addr) uint8_t rle_decode(PGM_VOID_P in_addr, int32_t in_len, uint32_t out_addr)
{ {
uint8_t in_byte, in_repeat, last_byte; uint8_t in_byte, in_repeat, last_byte;
info("RLE decode len=%li addr=0x%08lx\n", in_len, out_addr); info_P(PSTR("RLE decode len=%li addr=0x%08lx\n"), in_len, out_addr);
last_byte = 0; last_byte = 0;
sram_bulk_write_start(out_addr); sram_bulk_write_start(out_addr);
@ -61,7 +61,7 @@ uint8_t rle_decode(PGM_VOID_P in_addr, int32_t in_len, uint32_t out_addr)
if (in_byte == RUNCHAR) { if (in_byte == RUNCHAR) {
INBYTE(in_repeat); INBYTE(in_repeat);
if (in_repeat != 0) { if (in_repeat != 0) {
info("Orphaned RLE code at start\n"); info_P(PSTR("Orphaned RLE code at start\n"));
return 1; return 1;
} }
OUTBYTE(RUNCHAR); OUTBYTE(RUNCHAR);
@ -72,7 +72,7 @@ uint8_t rle_decode(PGM_VOID_P in_addr, int32_t in_len, uint32_t out_addr)
while (in_len > 0) { while (in_len > 0) {
INBYTE(in_byte); INBYTE(in_byte);
if (in_len % 1024 == 0) if (in_len % 1024 == 0)
info("."); info_P(PSTR("."));
if (in_byte == RUNCHAR) { if (in_byte == RUNCHAR) {
INBYTE(in_repeat); INBYTE(in_repeat);
if (in_repeat == 0) { if (in_repeat == 0) {

View File

@ -51,12 +51,12 @@ uint8_t scratchpad_locked_tx = 1;
uint8_t shared_memory_scratchpad_region_save_helper(uint32_t addr){ uint8_t shared_memory_scratchpad_region_save_helper(uint32_t addr){
if(addr > (SHARED_MEM_TX_LOC_STATE + SHARED_MEM_TX_LOC_SIZE) && scratchpad_locked_tx){ if(addr > (SHARED_MEM_TX_LOC_STATE + SHARED_MEM_TX_LOC_SIZE) && scratchpad_locked_tx){
debug(DEBUG_SHM,"shared_memory_scratchpad_region_save_helper: open tx addr=0x%06lx\n",addr); debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_save_helper: open tx addr=0x%06lx\n"),addr);
shared_memory_scratchpad_region_tx_save(); shared_memory_scratchpad_region_tx_save();
return 0; return 0;
} }
if(addr > (SHARED_MEM_RX_LOC_STATE + SHARED_MEM_RX_LOC_SIZE) && scratchpad_locked_rx){ if(addr > (SHARED_MEM_RX_LOC_STATE + SHARED_MEM_RX_LOC_SIZE) && scratchpad_locked_rx){
debug(DEBUG_SHM,"shared_memory_scratchpad_region_save_helper: open rx addr=0x%06lx\n",addr); debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_save_helper: open rx addr=0x%06lx\n"),addr);
shared_memory_scratchpad_region_rx_save(); shared_memory_scratchpad_region_rx_save();
return 0; return 0;
} }
@ -70,10 +70,10 @@ void shared_memory_scratchpad_region_tx_save()
uint16_t crc; uint16_t crc;
crc = crc_check_bulk_memory((uint32_t)SHARED_MEM_TX_LOC_STATE, crc = crc_check_bulk_memory((uint32_t)SHARED_MEM_TX_LOC_STATE,
(uint32_t)(SHARED_MEM_TX_LOC_STATE + SHARED_MEM_TX_LOC_SIZE), 0x8000); (uint32_t)(SHARED_MEM_TX_LOC_STATE + SHARED_MEM_TX_LOC_SIZE), 0x8000);
debug(DEBUG_SHM,"shared_memory_scratchpad_region_tx_save: crc=%x\n",crc); debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_tx_save: crc=%x\n"),crc);
#endif #endif
debug(DEBUG_SHM,"shared_memory_scratchpad_region_tx_save: unlock\n"); debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_tx_save: unlock\n"));
sram_bulk_copy_into_buffer((uint32_t)SHARED_MEM_TX_LOC_STATE,scratchpad_region_tx, sram_bulk_copy_into_buffer((uint32_t)SHARED_MEM_TX_LOC_STATE,scratchpad_region_tx,
(uint32_t)SHARED_MEM_TX_LOC_SIZE); (uint32_t)SHARED_MEM_TX_LOC_SIZE);
scratchpad_locked_tx = 0; scratchpad_locked_tx = 0;
@ -92,10 +92,10 @@ void shared_memory_scratchpad_region_rx_save()
uint16_t crc; uint16_t crc;
crc = crc_check_bulk_memory((uint32_t)SHARED_MEM_RX_LOC_STATE, crc = crc_check_bulk_memory((uint32_t)SHARED_MEM_RX_LOC_STATE,
(uint32_t)(SHARED_MEM_RX_LOC_STATE + SHARED_MEM_RX_LOC_SIZE), 0x8000); (uint32_t)(SHARED_MEM_RX_LOC_STATE + SHARED_MEM_RX_LOC_SIZE), 0x8000);
debug(DEBUG_SHM,"shared_memory_scratchpad_region_tx_save: crc=%x\n",crc); debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_tx_save: crc=%x\n"),crc);
#endif #endif
debug(DEBUG_SHM,"shared_memory_scratchpad_region_rx_save: unlock\n"); debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_rx_save: unlock\n"));
sram_bulk_copy_into_buffer((uint32_t)SHARED_MEM_RX_LOC_STATE,scratchpad_region_rx, sram_bulk_copy_into_buffer((uint32_t)SHARED_MEM_RX_LOC_STATE,scratchpad_region_rx,
(uint32_t)SHARED_MEM_RX_LOC_SIZE); (uint32_t)SHARED_MEM_RX_LOC_SIZE);
scratchpad_locked_rx = 0; scratchpad_locked_rx = 0;
@ -111,7 +111,7 @@ void shared_memory_scratchpad_region_tx_restore()
if (scratchpad_locked_tx) if (scratchpad_locked_tx)
return; return;
debug(DEBUG_SHM,"shared_memory_scratchpad_region_tx_restore: lock\n"); debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_tx_restore: lock\n"));
sram_bulk_copy_from_buffer((uint32_t)SHARED_MEM_TX_LOC_STATE,scratchpad_region_tx, sram_bulk_copy_from_buffer((uint32_t)SHARED_MEM_TX_LOC_STATE,scratchpad_region_tx,
(uint32_t)SHARED_MEM_TX_LOC_SIZE); (uint32_t)SHARED_MEM_TX_LOC_SIZE);
scratchpad_locked_tx = 1; scratchpad_locked_tx = 1;
@ -124,7 +124,7 @@ void shared_memory_scratchpad_region_tx_restore()
uint16_t crc; uint16_t crc;
crc = crc_check_bulk_memory((uint32_t)SHARED_MEM_TX_LOC_STATE, crc = crc_check_bulk_memory((uint32_t)SHARED_MEM_TX_LOC_STATE,
(uint32_t)(SHARED_MEM_TX_LOC_STATE + SHARED_MEM_TX_LOC_SIZE), 0x8000); (uint32_t)(SHARED_MEM_TX_LOC_STATE + SHARED_MEM_TX_LOC_SIZE), 0x8000);
debug(DEBUG_SHM,"shared_memory_scratchpad_region_tx_restore: crc=%x\n",crc); debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_tx_restore: crc=%x\n"),crc);
#endif #endif
} }
@ -133,7 +133,7 @@ void shared_memory_scratchpad_region_rx_restore()
{ {
if (scratchpad_locked_rx) if (scratchpad_locked_rx)
return; return;
debug(DEBUG_SHM,"shared_memory_scratchpad_region_tx_save: lock\n"); debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_tx_save: lock\n"));
sram_bulk_copy_from_buffer((uint32_t)SHARED_MEM_RX_LOC_STATE,scratchpad_region_rx, sram_bulk_copy_from_buffer((uint32_t)SHARED_MEM_RX_LOC_STATE,scratchpad_region_rx,
(uint32_t)SHARED_MEM_RX_LOC_SIZE); (uint32_t)SHARED_MEM_RX_LOC_SIZE);
scratchpad_locked_rx = 1; scratchpad_locked_rx = 1;
@ -147,7 +147,7 @@ void shared_memory_scratchpad_region_rx_restore()
uint16_t crc; uint16_t crc;
crc = crc_check_bulk_memory((uint32_t)SHARED_MEM_RX_LOC_STATE, crc = crc_check_bulk_memory((uint32_t)SHARED_MEM_RX_LOC_STATE,
(uint32_t)(SHARED_MEM_RX_LOC_STATE + SHARED_MEM_RX_LOC_SIZE), 0x8000); (uint32_t)(SHARED_MEM_RX_LOC_STATE + SHARED_MEM_RX_LOC_SIZE), 0x8000);
debug(DEBUG_SHM,"shared_memory_scratchpad_region_rx_restore: crc=%x\n",crc); debug_P(DEBUG_SHM, PSTR("shared_memory_scratchpad_region_rx_restore: crc=%x\n"),crc);
#endif #endif
} }
@ -185,9 +185,9 @@ void shared_memory_write(uint8_t cmd, uint8_t value)
{ {
if (scratchpad_locked_tx) if (scratchpad_locked_tx)
debug(DEBUG_SHM,"shared_memory_write: locked_tx\n"); debug_P(DEBUG_SHM, PSTR("shared_memory_write: locked_tx\n"));
debug(DEBUG_SHM,"shared_memory_write: 0x%04x=0x%02x 0x%04x=0x%02x \n", debug_P(DEBUG_SHM, PSTR("shared_memory_write: 0x%04x=0x%02x 0x%04x=0x%02x \n"),
SHARED_MEM_TX_LOC_CMD, cmd, SHARED_MEM_TX_LOC_PAYLOAD, value); SHARED_MEM_TX_LOC_CMD, cmd, SHARED_MEM_TX_LOC_PAYLOAD, value);
sram_bulk_addr_save(); sram_bulk_addr_save();
@ -243,7 +243,7 @@ int shared_memory_read(uint8_t *cmd, uint8_t *len,uint8_t *buffer)
uint8_t state; uint8_t state;
if (scratchpad_locked_rx) if (scratchpad_locked_rx)
debug(DEBUG_SHM,"shared_memory_write: locked_tx\n"); debug_P(DEBUG_SHM, PSTR("shared_memory_write: locked_tx\n"));
state = sram_read(SHARED_MEM_RX_LOC_STATE); state = sram_read(SHARED_MEM_RX_LOC_STATE);
@ -254,7 +254,7 @@ int shared_memory_read(uint8_t *cmd, uint8_t *len,uint8_t *buffer)
*cmd = sram_read(SHARED_MEM_RX_LOC_CMD); *cmd = sram_read(SHARED_MEM_RX_LOC_CMD);
*len = sram_read(SHARED_MEM_RX_LOC_LEN); *len = sram_read(SHARED_MEM_RX_LOC_LEN);
debug(DEBUG_SHM,"shared_memory_read: 0x%04x=0x%02x 0x%04x=0x%02x \n", debug_P(DEBUG_SHM, PSTR("shared_memory_read: 0x%04x=0x%02x 0x%04x=0x%02x \n"),
SHARED_MEM_RX_LOC_CMD, *cmd, SHARED_MEM_RX_LOC_LEN, *len); SHARED_MEM_RX_LOC_CMD, *cmd, SHARED_MEM_RX_LOC_LEN, *len);
sram_bulk_copy_into_buffer(SHARED_MEM_RX_LOC_PAYLOAD,buffer, *len); sram_bulk_copy_into_buffer(SHARED_MEM_RX_LOC_PAYLOAD,buffer, *len);

View File

@ -94,19 +94,19 @@ void system_init(void)
void sreg_set(uint32_t addr) void sreg_set(uint32_t addr)
{ {
uint8_t i = 24; uint8_t i = 24;
debug(DEBUG_SREG,"sreg_set: addr=0x%08lx",addr); debug_P(DEBUG_SREG, PSTR("sreg_set: addr=0x%08lx"),addr);
while(i--) { while(i--) {
if ((addr & ( 1L << i))){ if ((addr & ( 1L << i))){
debug(DEBUG_SREG,"1"); debug_P(DEBUG_SREG, PSTR("1"));
AVR_ADDR_SER_PORT |= ( 1 << AVR_ADDR_SER_PIN); AVR_ADDR_SER_PORT |= ( 1 << AVR_ADDR_SER_PIN);
} else { } else {
AVR_ADDR_SER_PORT &= ~( 1 << AVR_ADDR_SER_PIN); AVR_ADDR_SER_PORT &= ~( 1 << AVR_ADDR_SER_PIN);
debug(DEBUG_SREG,"0"); debug_P(DEBUG_SREG, PSTR("0"));
} }
AVR_ADDR_SCK_PORT |= (1 << AVR_ADDR_SCK_PIN); AVR_ADDR_SCK_PORT |= (1 << AVR_ADDR_SCK_PIN);
AVR_ADDR_SCK_PORT &= ~(1 << AVR_ADDR_SCK_PIN); AVR_ADDR_SCK_PORT &= ~(1 << AVR_ADDR_SCK_PIN);
} }
debug(DEBUG_SREG,"\n"); debug_P(DEBUG_SREG, PSTR("\n"));
AVR_ADDR_LATCH_PORT |= (1 << AVR_ADDR_LATCH_PIN); AVR_ADDR_LATCH_PORT |= (1 << AVR_ADDR_LATCH_PIN);
AVR_ADDR_LATCH_PORT &= ~(1 << AVR_ADDR_LATCH_PIN); AVR_ADDR_LATCH_PORT &= ~(1 << AVR_ADDR_LATCH_PIN);
@ -127,7 +127,7 @@ inline void sram_bulk_addr_restore()
void sram_bulk_read_start(uint32_t addr) void sram_bulk_read_start(uint32_t addr)
{ {
debug(DEBUG_SRAM,"sram_bulk_read_start: addr=0x%08lx\n\r", addr); debug_P(DEBUG_SRAM, PSTR("sram_bulk_read_start: addr=0x%08lx\n\r"), addr);
addr_current = addr; addr_current = addr;
@ -173,7 +173,7 @@ inline uint8_t sram_bulk_read(void)
void sram_bulk_read_end(void) void sram_bulk_read_end(void)
{ {
debug(DEBUG_SRAM,"sram_bulk_read_end:\n"); debug_P(DEBUG_SRAM, PSTR("sram_bulk_read_end:\n"));
AVR_RD_PORT |= (1 << AVR_RD_PIN); AVR_RD_PORT |= (1 << AVR_RD_PIN);
AVR_CS_PORT |= (1 << AVR_CS_PIN); AVR_CS_PORT |= (1 << AVR_CS_PIN);
@ -183,7 +183,7 @@ void sram_bulk_read_end(void)
uint8_t sram_read(uint32_t addr) uint8_t sram_read(uint32_t addr)
{ {
uint8_t byte; uint8_t byte;
debug(DEBUG_SRAM_RAW,"sram_read: addr=0x%08lx\n\r", addr); debug_P(DEBUG_SRAM_RAW, PSTR("sram_read: addr=0x%08lx\n\r"), addr);
avr_data_in(); avr_data_in();
@ -215,7 +215,7 @@ uint8_t sram_read(uint32_t addr)
void sram_bulk_write_start(uint32_t addr) void sram_bulk_write_start(uint32_t addr)
{ {
debug(DEBUG_SRAM,"sram_bulk_write_start: addr=0x%08lx\n\r", addr); debug_P(DEBUG_SRAM, PSTR("sram_bulk_write_start: addr=0x%08lx\n\r"), addr);
avr_data_out(); avr_data_out();
@ -243,7 +243,7 @@ inline void sram_bulk_write( uint8_t data)
void sram_bulk_write_end(void) void sram_bulk_write_end(void)
{ {
debug(DEBUG_SRAM,"sram_bulk_write_end:"); debug_P(DEBUG_SRAM, PSTR("sram_bulk_write_end:"));
AVR_WR_PORT |= (1 << AVR_WR_PIN); AVR_WR_PORT |= (1 << AVR_WR_PIN);
AVR_CS_PORT |= (1 << AVR_CS_PIN); AVR_CS_PORT |= (1 << AVR_CS_PIN);
avr_data_in(); avr_data_in();
@ -252,7 +252,7 @@ void sram_bulk_write_end(void)
void sram_write(uint32_t addr, uint8_t data) void sram_write(uint32_t addr, uint8_t data)
{ {
debug(DEBUG_SRAM_RAW,"sram_write: addr=0x%08lx data=%x\n\r", addr, data); debug_P(DEBUG_SRAM_RAW, PSTR("sram_write: addr=0x%08lx data=%x\n\r"), addr, data);
avr_data_out(); avr_data_out();
@ -286,7 +286,7 @@ void sram_bulk_copy_from_buffer(uint32_t addr, uint8_t * src, uint32_t len)
uint32_t i; uint32_t i;
uint8_t *ptr = src; uint8_t *ptr = src;
debug(DEBUG_SRAM,"sram_bulk_copy_from_buffer: addr=0x%08lx src=0x%p len=%li\n\r", debug_P(DEBUG_SRAM, PSTR("sram_bulk_copy_from_buffer: addr=0x%08lx src=0x%p len=%li\n\r"),
addr, src, len); addr, src, len);
sram_bulk_write_start(addr); sram_bulk_write_start(addr);
for (i = addr; i < (addr + len); i++){ for (i = addr; i < (addr + len); i++){
@ -301,7 +301,7 @@ void sram_bulk_copy_into_buffer(uint32_t addr, uint8_t * dst, uint32_t len)
uint32_t i; uint32_t i;
uint8_t *ptr = dst; uint8_t *ptr = dst;
debug(DEBUG_SRAM,"sram_bulk_copy_into_buffer: addr=0x%08lx dst=0x%p len=%li\n\r", debug_P(DEBUG_SRAM, PSTR("sram_bulk_copy_into_buffer: addr=0x%08lx dst=0x%p len=%li\n\r"),
addr, dst, len); addr, dst, len);
sram_bulk_read_start(addr); sram_bulk_read_start(addr);
for (i = addr; i < (addr + len); i++) { for (i = addr; i < (addr + len); i++) {
@ -314,11 +314,11 @@ void sram_bulk_copy_into_buffer(uint32_t addr, uint8_t * dst, uint32_t len)
void sram_bulk_set(uint32_t addr, uint32_t len,uint8_t value){ void sram_bulk_set(uint32_t addr, uint32_t len,uint8_t value){
uint32_t i; uint32_t i;
debug(DEBUG_SRAM,"sram_bulk_set: addr=0x%08lx len=%li\n\r", addr,len); debug_P(DEBUG_SRAM, PSTR("sram_bulk_set: addr=0x%08lx len=%li\n\r"), addr,len);
sram_bulk_write_start(addr); sram_bulk_write_start(addr);
for (i = addr; i < (addr + len); i++) { for (i = addr; i < (addr + len); i++) {
if (0 == i % 0xfff) if (0 == i % 0xfff)
debug(DEBUG_SRAM,"sram_bulk_set: addr=0x%08lx\n\r", i); debug_P(DEBUG_SRAM, PSTR("sram_bulk_set: addr=0x%08lx\n\r"), i);
sram_bulk_write(value); sram_bulk_write(value);
sram_bulk_write_next(); sram_bulk_write_next();
} }

View File

@ -45,7 +45,7 @@ void test_read_write()
} }
addr = 0x000000; addr = 0x000000;
while (addr++ <= 0x0000ff) { while (addr++ <= 0x0000ff) {
info("read addr=0x%08lx %x\n", addr, sram_read(addr)); info_P(PSTR("read addr=0x%08lx %x\n"), addr, sram_read(addr));
} }
} }
@ -69,7 +69,7 @@ void test_bulk_read_write()
addr = 0x000000; addr = 0x000000;
sram_bulk_read_start(addr); sram_bulk_read_start(addr);
while (addr <= 0x8000) { while (addr <= 0x8000) {
info("addr=0x%08lx %x\n", addr, sram_bulk_read()); info_P(PSTR("addr=0x%08lx %x\n"), addr, sram_bulk_read());
sram_bulk_read_next(); sram_bulk_read_next();
addr++; addr++;
} }
@ -85,7 +85,7 @@ void test_non_zero_memory(uint32_t bottom_addr, uint32_t top_addr)
for (addr = bottom_addr; addr < top_addr; addr++) { for (addr = bottom_addr; addr < top_addr; addr++) {
c = sram_bulk_read(); c = sram_bulk_read();
if (c != 0xff) if (c != 0xff)
info("addr=0x%08lx c=0x%x\n", addr, c); info_P(PSTR("addr=0x%08lx c=0x%x\n"), addr, c);
sram_bulk_read_next(); sram_bulk_read_next();
} }
sram_bulk_read_end(); sram_bulk_read_end();
@ -95,12 +95,12 @@ void test_non_zero_memory(uint32_t bottom_addr, uint32_t top_addr)
void test_crc() void test_crc()
{ {
info("test_crc: clear\n"); info_P(PSTR("test_crc: clear\n"));
avr_bus_active(); avr_bus_active();
sram_bulk_set(0x000000, 0x10000, 0xff); sram_bulk_set(0x000000, 0x10000, 0xff);
info("test_crc: crc\n"); info_P(PSTR("test_crc: crc\n"));
crc_check_bulk_memory(0x000000, 0x10000, 0x8000); crc_check_bulk_memory(0x000000, 0x10000, 0x8000);
info("test_crc: check\n"); info_P(PSTR("test_crc: check\n"));
test_non_zero_memory(0x000000, 0x10000); test_non_zero_memory(0x000000, 0x10000);
} }

View File

@ -56,14 +56,14 @@ uint8_t usbFunctionWrite(uint8_t * data, uint8_t len)
uint8_t i; uint8_t i;
if (len > rx_remaining) { if (len > rx_remaining) {
info("ERROR:usbFunctionWrite more data than expected remain: %i len: %i\n", info_P(PSTR("ERROR:usbFunctionWrite more data than expected remain: %i len: %i\n"),
rx_remaining, len); rx_remaining, len);
len = rx_remaining; len = rx_remaining;
} }
if (req_state == REQ_STATUS_BULK_UPLOAD) { if (req_state == REQ_STATUS_BULK_UPLOAD) {
rx_remaining -= len; rx_remaining -= len;
debug(DEBUG_USB_TRANS,"usbFunctionWrite REQ_STATUS_BULK_UPLOAD addr: 0x%08lx len: %i rx_remaining=%i\n", debug_P(DEBUG_USB_TRANS, PSTR("usbFunctionWrite REQ_STATUS_BULK_UPLOAD addr: 0x%08lx len: %i rx_remaining=%i\n"),
req_addr, len, rx_remaining); req_addr, len, rx_remaining);
ptr = data; ptr = data;
i = len; i = len;
@ -81,7 +81,7 @@ uint8_t usbFunctionRead(uint8_t * data, uint8_t len)
if (len > tx_remaining) if (len > tx_remaining)
len = tx_remaining; len = tx_remaining;
tx_remaining -= len; tx_remaining -= len;
debug(DEBUG_USB_TRANS,"usbFunctionRead len=%i tx_remaining=%i \n", len, tx_remaining); debug_P(DEBUG_USB_TRANS, PSTR("usbFunctionRead len=%i tx_remaining=%i \n"), len, tx_remaining);
for (i = 0; i < len; i++) { for (i = 0; i < len; i++) {
*data = tx_buffer[len]; *data = tx_buffer[len];