add shared memory module to put loader status

This commit is contained in:
David Voswinkel 2009-08-01 18:19:21 +02:00
parent 1539ff6111
commit 1b45c2f325
11 changed files with 239 additions and 73 deletions

View File

@ -16,6 +16,7 @@
# Author: Christian Starkjohann # Author: Christian Starkjohann
# ===================================================================================== # =====================================================================================
DEBUG = 1
TTY = /dev/tty.PL2303-00002126 TTY = /dev/tty.PL2303-00002126
DEVICE = atmega644 DEVICE = atmega644
F_CPU = 20000000 # in Hz F_CPU = 20000000 # in Hz
@ -23,16 +24,21 @@ TARGET = main
AVRDUDE = avrdude -c usbasp -p $(DEVICE) AVRDUDE = avrdude -c usbasp -p $(DEVICE)
SIZE = avr-size SIZE = avr-size
#LDFLAGS = -Wl,-u,vfprintf -lprintf_flt
#CFLAGS = -Iusbdrv -I. -DDEBUG_LEVEL=0
LDFLAGS = -Wl,-u,vfprintf
CFLAGS = -Iusbdrv -I. -DDEBUG_LEVEL=0 -DNO_DEBUG
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o usb_bulk.o uart.o fifo.o sram.o crc.o debug.o dump.o timer.o watchdog.o huffman-decode.o rle.c loader.o info.o
ifeq ($(DEBUG),1)
LDFLAGS = -Wl,-u,vfprintf -lprintf_flt
CFLAGS = -Iusbdrv -I. -DDEBUG_LEVEL=0
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o usb_bulk.o uart.o fifo.o sram.o crc.o debug.o dump.o timer.o watchdog.o huffman-decode.o rle.c loader.o info.o shared_memory.o
else
LDFLAGS = -Wl,-u
CFLAGS = -Iusbdrv -I. -DDEBUG_LEVEL=0 -DNO_DEBUG -DNO_INFO
OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o usb_bulk.o uart.o fifo.o sram.o crc.o debug.o dump.o timer.o watchdog.o rle.c loader.o info.o shared_memory.o
endif
COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE) COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE)
############################################################################## ##############################################################################
# Fuse values for particular devices # Fuse values for particular devices
############################################################################## ##############################################################################

View File

@ -27,6 +27,7 @@
#include "config.h" #include "config.h"
#include "sram.h" #include "sram.h"
#include "debug.h" #include "debug.h"
#include "info.h"
extern FILE uart_stdout; extern FILE uart_stdout;

View File

@ -23,6 +23,7 @@
#include <stdint.h> #include <stdint.h>
#include "debug.h" #include "debug.h"
#include "info.h"
#include "uart.h" #include "uart.h"
#include "sram.h" #include "sram.h"
@ -46,21 +47,21 @@ void dump_packet(uint32_t addr, uint32_t len, uint8_t * packet)
continue; continue;
} }
if (clear) { if (clear) {
printf("*\n"); info("*\n");
clear = 0; clear = 0;
} }
printf("%08lx:", addr + i); info("%08lx:", addr + i);
for (j = 0; j < 16; j++) { for (j = 0; j < 16; j++) {
printf(" %02x", packet[i + j]); info(" %02x", packet[i + j]);
} }
printf(" |"); info(" |");
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)
printf("%c", packet[i + j]); info("%c", packet[i + j]);
else else
printf("."); info(".");
} }
printf("|\n"); info("|\n");
} }
} }
@ -71,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)
printf("\n%08lx:", addr); info("\n%08lx:", addr);
byte = sram_bulk_read(); byte = sram_bulk_read();
sram_bulk_read_next(); sram_bulk_read_next();
printf(" %02x", byte); info(" %02x", byte);
} }
printf("\n"); info("\n");
sram_bulk_read_end(); sram_bulk_read_end();
} }

View File

@ -18,12 +18,15 @@
*/ */
#include "huffman-decode.h"
#include <stdint.h> #include <stdint.h>
#include <stdio.h> #include <stdio.h>
#include <string.h> #include <string.h>
#include <stdlib.h> #include <stdlib.h>
#include "huffman-decode.h"
#include "info.h"
#include "debug.h"
#ifdef DEBUG #ifdef DEBUG
#undef DEBUG #undef DEBUG
#endif #endif
@ -100,11 +103,11 @@ static inline void set_last_to_eof(node_t* start){
#if DEBUG #if DEBUG
void print_tree(node_t* node){ void print_tree(node_t* node){
if(node->value==V_NODE){ if(node->value==V_NODE){
printf("\n%p --> node->left=%p node->right=%p",node,node->left, node->right); info("\n%p --> node->left=%p node->right=%p",node,node->left, node->right);
print_tree(node->left); print_tree(node->left);
print_tree(node->right); print_tree(node->right);
}else{ }else{
printf("\n%p => %i",node,node->value); info("\n%p => %i",node,node->value);
} }
} }
#endif #endif

View File

@ -35,6 +35,7 @@
#include "uart.h" #include "uart.h"
#include "sram.h" #include "sram.h"
#include "debug.h" #include "debug.h"
#include "info.h"
#include "dump.h" #include "dump.h"
#include "crc.h" #include "crc.h"
#include "usb_bulk.h" #include "usb_bulk.h"
@ -43,6 +44,7 @@
#include "huffman-decode.h" #include "huffman-decode.h"
#include "rle.h" #include "rle.h"
#include "loader.h" #include "loader.h"
#include "shared_memory.h"
extern const char _rom[] PROGMEM; extern const char _rom[] PROGMEM;
@ -89,6 +91,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
req_bank_size = (uint32_t)1 << rq->wValue.word; req_bank_size = (uint32_t)1 << rq->wValue.word;
sync_errors = 0; sync_errors = 0;
crc = 0; crc = 0;
shared_memory_put(SHARED_MEM_CMD_UPLOAD_START,0);
debug(DEBUG_USB,"USB_UPLOAD_INIT: bank_size=0x%08lx\n", req_bank_size); debug(DEBUG_USB,"USB_UPLOAD_INIT: bank_size=0x%08lx\n", req_bank_size);
/* /*
@ -121,6 +124,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
req_bank, req_addr); req_bank, req_addr);
req_bank++; req_bank++;
shared_memory_put(SHARED_MEM_CMD_UPLOAD_PROGESS,req_bank);
} }
ret_len = USB_MAX_TRANS; ret_len = USB_MAX_TRANS;
/* /*
@ -150,6 +154,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
debug(DEBUG_USB,"USB_BULK_UPLOAD_INIT: bank_size=0x%08lx bank_cnt=0x%x end_addr=0x%08lx\n", debug(DEBUG_USB,"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_put(SHARED_MEM_CMD_UPLOAD_START,0);
if (req_addr == 0x000000){ if (req_addr == 0x000000){
timer_start(); timer_start();
} }
@ -206,6 +211,7 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
req_bank, req_addr,timer_stop_int()); req_bank, req_addr,timer_stop_int());
#endif #endif
req_bank++; req_bank++;
shared_memory_put(SHARED_MEM_CMD_UPLOAD_PROGESS,req_bank);
timer_start(); timer_start();
} }
@ -221,7 +227,9 @@ usbMsgLen_t usbFunctionSetup(uchar data[8])
debug(DEBUG_USB,"USB_BULK_UPLOAD_END:\n"); debug(DEBUG_USB,"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_put(SHARED_MEM_CMD_UPLOAD_END,0);
ret_len = 0; ret_len = 0;
/* /*
* ------------------------------------------------------------------------- * -------------------------------------------------------------------------
*/ */
@ -298,7 +306,7 @@ void test_read_write(){
} }
addr = 0x000000; addr = 0x000000;
while (addr++ <= 0x0000ff){ while (addr++ <= 0x0000ff){
printf("read addr=0x%08lx %x\n",addr,sram_read(addr)); info("read addr=0x%08lx %x\n",addr,sram_read(addr));
} }
} }
@ -321,7 +329,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){
printf("addr=0x%08lx %x\n",addr,sram_bulk_read()); info("addr=0x%08lx %x\n",addr,sram_bulk_read());
sram_bulk_read_next(); sram_bulk_read_next();
addr++; addr++;
} }
@ -337,7 +345,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)
printf("addr=0x%08lx c=0x%x\n",addr,c); info("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();
@ -346,12 +354,12 @@ void test_non_zero_memory(uint32_t bottom_addr,uint32_t top_addr)
void test_crc(){ void test_crc(){
printf("test_crc: clear\n"); info("test_crc: clear\n");
avr_bus_active(); avr_bus_active();
sram_bulk_set(0x000000,0x10000,0xff); sram_bulk_set(0x000000,0x10000,0xff);
printf("test_crc: crc\n"); info("test_crc: crc\n");
crc_check_bulk_memory(0x000000,0x10000,0x8000); crc_check_bulk_memory(0x000000,0x10000,0x8000);
printf("test_crc: check\n"); info("test_crc: check\n");
test_non_zero_memory(0x000000,0x10000); test_non_zero_memory(0x000000,0x10000);
} }
@ -374,7 +382,7 @@ void decompress(PGM_VOID_P addr, uint16_t(*fp)(uint16_t)){
i++; i++;
c=huffman_dec_byte(&ctx); c=huffman_dec_byte(&ctx);
if (i%1024==0) if (i%1024==0)
printf("."); info(".");
if(c>0xff){ if(c>0xff){
return; return;
} }
@ -384,17 +392,17 @@ void decompress(PGM_VOID_P addr, uint16_t(*fp)(uint16_t)){
} }
void decompress_huffman(void){ void decompress_huffman(void){
printf("Decompress Rom %p to 0x000000\n",(void*)_rom); info("Decompress Rom %p to 0x000000\n",(void*)_rom);
sram_bulk_write_start(0x000000); sram_bulk_write_start(0x000000);
decompress(&_rom,read_byte_pgm); decompress(&_rom,read_byte_pgm);
sram_bulk_write_end(); sram_bulk_write_end();
printf("Done\n"); info("Done\n");
} }
void send_reset(){ void send_reset(){
printf("Reset Snes\n"); info("Reset Snes\n");
snes_reset_on(); snes_reset_on();
snes_reset_lo(); snes_reset_lo();
_delay_ms(2); _delay_ms(2);
@ -413,20 +421,20 @@ void send_irq(){
void set_rom_mode(){ void set_rom_mode(){
if (req_bank_size == 0x8000){ if (req_bank_size == 0x8000){
snes_lorom(); snes_lorom();
printf("Set Snes lowrom \n"); info("Set Snes lowrom \n");
} else { } else {
snes_hirom(); snes_hirom();
printf("Set Snes hirom \n"); info("Set Snes hirom \n");
} }
} }
void usb_connect(){ void usb_connect(){
uint8_t i = 0; uint8_t i = 0;
printf("USB init\n"); info("USB init\n");
usbDeviceDisconnect(); /* enforce re-enumeration, do this while */ usbDeviceDisconnect(); /* enforce re-enumeration, do this while */
cli(); cli();
printf("USB disconnect\n"); info("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();
@ -436,7 +444,7 @@ void usb_connect(){
} }
led_on(); led_on();
usbDeviceConnect(); usbDeviceConnect();
printf("USB connect\n"); info("USB connect\n");
} }
@ -444,28 +452,27 @@ void boot_startup_rom(){
uint8_t i = 0; uint8_t i = 0;
printf("Activate AVR bus\n"); info("Activate AVR bus\n");
avr_bus_active(); avr_bus_active();
printf("IRQ off\n"); info("IRQ off\n");
snes_irq_lo(); snes_irq_lo();
snes_irq_off(); snes_irq_off();
snes_lorom(); snes_lorom();
printf("Set Snes lowrom \n"); info("Set Snes lowrom \n");
/* /*
printf("Set Snes hirom\n"); info("Set Snes hirom\n");
snes_hirom(); snes_hirom();
printf("Disable snes WR\n"); info("Disable snes WR\n");
snes_wr_disable(); snes_wr_disable();
printf("IRQ off\n"); info("IRQ off\n");
snes_irq_lo(); snes_irq_lo();
snes_irq_off(); snes_irq_off();
*/ */
rle_decode(&_rom, ROM_SIZE, 0x000000); rle_decode(&_rom, ROM_SIZE, 0x000000);
dump_memory(0x10000 - 0x100, 0x10000); dump_memory(0x10000 - 0x100, 0x10000);
@ -473,23 +480,24 @@ void boot_startup_rom(){
snes_reset_off(); snes_reset_off();
snes_irq_lo(); snes_irq_lo();
snes_irq_off(); snes_irq_off();
printf("IRQ off\n"); info("IRQ off\n");
snes_hirom(); snes_hirom();
snes_wr_disable(); snes_wr_disable();
printf("Disable snes WR\n"); info("Disable snes WR\n");
snes_bus_active(); snes_bus_active();
printf("Activate Snes bus\n"); info("Activate Snes bus\n");
_delay_ms(100); _delay_ms(100);
printf("Reset Snes\n"); info("Reset Snes\n");
send_reset(); send_reset();
#if 0
i = 20; i = 20;
printf("Wait"); info("Wait");
while (--i){ while (--i){
_delay_ms(500); _delay_ms(500);
printf("."); info(".");
} }
printf("\n"); info("\n");
#endif
} }
int main(void) int main(void)
@ -500,7 +508,7 @@ int main(void)
uart_init(); uart_init();
stdout = &uart_stdout; stdout = &uart_stdout;
printf("Sytem start\n"); info("Sytem start\n");
system_init(); system_init();
#if 0 #if 0
@ -510,7 +518,7 @@ int main(void)
while(1); while(1);
#endif #endif
printf("Boot startup rom\n"); info("Boot startup rom\n");
boot_startup_rom(); boot_startup_rom();
usbInit(); usbInit();
@ -518,43 +526,45 @@ int main(void)
while (1){ while (1){
avr_bus_active(); avr_bus_active();
printf("Activate AVR bus\n"); info("Activate AVR bus\n");
printf("IRQ off\n"); info("IRQ off\n");
snes_irq_lo(); snes_irq_lo();
snes_irq_off(); snes_irq_off();
printf("Set Snes lowrom\n"); info("Set Snes lowrom\n");
snes_lorom(); snes_lorom();
printf("Disable snes WR\n"); info("Disable snes WR\n");
snes_wr_disable(); snes_wr_disable();
sei(); sei();
printf("USB poll\n"); info("USB poll\n");
while (req_state != REQ_STATUS_SNES){ while (req_state != REQ_STATUS_SNES){
usbPoll(); usbPoll();
} }
printf("USB poll done\n"); shared_memory_put(SHARED_MEM_CMD_TERMINATE,0);
info("USB poll done\n");
snes_reset_hi(); snes_reset_hi();
snes_reset_off(); snes_reset_off();
snes_irq_lo(); snes_irq_lo();
snes_irq_off(); snes_irq_off();
printf("IRQ off\n"); info("IRQ off\n");
set_rom_mode(); set_rom_mode();
snes_wr_disable(); snes_wr_disable();
printf("Disable snes WR\n"); info("Disable snes WR\n");
snes_bus_active(); snes_bus_active();
printf("Activate Snes bus\n"); info("Activate Snes bus\n");
_delay_ms(100); _delay_ms(100);
printf("Reset Snes\n"); info("Reset Snes\n");
send_reset(); send_reset();
printf("Poll\n"); info("Poll\n");
while (req_state != REQ_STATUS_AVR){ while (req_state != REQ_STATUS_AVR){
usbPoll(); usbPoll();
#ifdef DO_IRQ #ifdef DO_IRQ
i = 10; i = 10;
while (--i) { /* fake USB disconnect for > 250 ms */ while (--i) { /* fake USB disconnect for > 250 ms */
_delay_ms(100); _delay_ms(100);
} }
printf("Send IRQ %i\n",++irq_count); info("Send IRQ %i\n",++irq_count);
send_irq(); send_irq();
#endif #endif
@ -565,21 +575,21 @@ int main(void)
i = 5; i = 5;
while (--i) { while (--i) {
_delay_ms(500); _delay_ms(500);
printf("Wait to switch to snes mode %i\n", i); info("Wait to switch to snes mode %i\n", i);
} }
if (req_bank_size == 0x8000){ if (req_bank_size == 0x8000){
snes_lorom(); snes_lorom();
printf("Set Snes lowrom \n"); info("Set Snes lowrom \n");
} else { } else {
snes_hirom(); snes_hirom();
printf("Set Snes hirom \n"); info("Set Snes hirom \n");
} }
snes_wr_disable(); snes_wr_disable();
printf("Disable snes WR\n"); info("Disable snes WR\n");
snes_bus_active(); snes_bus_active();
printf("Activate Snes bus\n"); info("Activate Snes bus\n");
printf("Read 0x3000=%c\n",c); info("Read 0x3000=%c\n",c);
#endif #endif
} }
} }

View File

@ -28,6 +28,7 @@
#include "sram.h" #include "sram.h"
#include "debug.h" #include "debug.h"
#include "info.h"
#define RUNCHAR 0x90 #define RUNCHAR 0x90
@ -35,7 +36,7 @@ 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;
uint32_t out_len, out_len_left; uint32_t out_len, out_len_left;
printf("RLE decode len=%li addr=0x%08lx\n",in_len,out_addr); info("RLE decode len=%li addr=0x%08lx\n",in_len,out_addr);
last_byte = 0; last_byte = 0;
out_len_left = out_len; out_len_left = out_len;
@ -62,7 +63,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) {
printf("Orphaned RLE code at start\n"); info("Orphaned RLE code at start\n");
return 1; return 1;
} }
OUTBYTE(RUNCHAR); OUTBYTE(RUNCHAR);
@ -73,7 +74,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)
printf("."); info(".");
if (in_byte == RUNCHAR) { if (in_byte == RUNCHAR) {
INBYTE(in_repeat); INBYTE(in_repeat);
if ( in_repeat == 0 ) { if ( in_repeat == 0 ) {

View File

@ -0,0 +1,98 @@
/*
* =====================================================================================
*
* ________ .__ __ ________ ____ ________
* \_____ \ __ __|__| ____ | | __\______ \ _______ _/_ |/ _____/
* / / \ \| | \ |/ ___\| |/ / | | \_/ __ \ \/ /| / __ \
* / \_/. \ | / \ \___| < | ` \ ___/\ / | \ |__\ \
* \_____\ \_/____/|__|\___ >__|_ \/_______ /\___ >\_/ |___|\_____ /
* \__> \/ \/ \/ \/ \/
*
* www.optixx.org
*
*
* Version: 1.0
* Created: 07/21/2009 03:32:16 PM
* Author: david@optixx.org
*
* =====================================================================================
*/
#include <stdlib.h>
#include <stdint.h>
#include <util/delay.h>
#include "shared_memory.h"
#include "config.h"
#include "sram.h"
#include "debug.h"
#include "info.h"
uint8_t irq_addr_lo;
uint8_t irq_addr_hi;
uint8_t scratchpad_state;
uint8_t scratchpad_cmd;
uint8_t scratchpad_payload;
void shared_memory_scratchpad_save(){
scratchpad_state = sram_read(SHARED_MEM_LOC_STATE);
scratchpad_cmd = sram_read(SHARED_MEM_LOC_CMD);
scratchpad_payload = sram_read(SHARED_MEM_LOC_PAYLOAD);
}
void shared_memory_scratchpad_restore(){
sram_write(SHARED_MEM_LOC_STATE, scratchpad_state);
sram_write(SHARED_MEM_LOC_CMD, scratchpad_cmd);
sram_write(SHARED_MEM_LOC_PAYLOAD, scratchpad_payload);
}
void shared_memory_irq_hook(){
irq_addr_lo = sram_read(SHARED_IRQ_LOC_LO);
irq_addr_hi = sram_read(SHARED_IRQ_LOC_HI);
sram_write(SHARED_IRQ_HANDLER_LO, 0);
sram_write(SHARED_IRQ_HANDLER_HI, 0);
}
void shared_memory_irq_restore(){
sram_write(SHARED_IRQ_LOC_LO, irq_addr_lo);
sram_write(SHARED_IRQ_LOC_HI, irq_addr_hi);
}
void shared_memory_put(uint8_t cmd, uint8_t value){
info("Write shared memory %06lx=%02x %06lx=%02x \n",SHARED_MEM_LOC_CMD,cmd,SHARED_MEM_LOC_PAYLOAD,value);
shared_memory_scratchpad_save();
shared_memory_irq_hook();
sram_write(SHARED_MEM_LOC_STATE,1);
sram_write(SHARED_MEM_LOC_CMD,cmd);
sram_write(SHARED_MEM_LOC_PAYLOAD,value);
snes_irq_lo();
snes_irq_off();
snes_hirom();
snes_wr_disable();
snes_bus_active();
//snes_irq_on();
//snes_irq_lo();
//_delay_us(20);
//snes_irq_hi();
//snes_irq_off();
avr_bus_active();
snes_irq_off();
snes_irq_lo();
snes_lorom();
shared_memory_scratchpad_restore();
shared_memory_irq_restore();
}

View File

@ -0,0 +1,42 @@
/*
* =====================================================================================
*
* ________ .__ __ ________ ____ ________
* \_____ \ __ __|__| ____ | | __\______ \ _______ _/_ |/ _____/
* / / \ \| | \ |/ ___\| |/ / | | \_/ __ \ \/ /| / __ \
* / \_/. \ | / \ \___| < | ` \ ___/\ / | \ |__\ \
* \_____\ \_/____/|__|\___ >__|_ \/_______ /\___ >\_/ |___|\_____ /
* \__> \/ \/ \/ \/ \/
*
* www.optixx.org
*
*
* Version: 1.0
* Created: 07/21/2009 03:32:16 PM
* Author: david@optixx.org
*
* =====================================================================================
*/
#ifndef __SHARED_MEMORY_H__
#define __SHARED_MEMORY_H__
#define SHARED_MEM_CMD_UPLOAD_START 1
#define SHARED_MEM_CMD_UPLOAD_END 2
#define SHARED_MEM_CMD_UPLOAD_PROGESS 3
#define SHARED_MEM_CMD_TERMINATE 4
#define SHARED_MEM_LOC_STATE 0x000000
#define SHARED_MEM_LOC_CMD 0x000001
#define SHARED_MEM_LOC_PAYLOAD 0x000002
#define SHARED_IRQ_LOC_LO 0x00fffe
#define SHARED_IRQ_LOC_HI 0x00ffff
#define SHARED_IRQ_HANDLER_LO 0x12
#define SHARED_IRQ_HANDLER_HI 0x34
void shared_memory_put(uint8_t cmd, uint8_t value);
#endif

View File

@ -29,6 +29,7 @@
#include "sram.h" #include "sram.h"
#include "uart.h" #include "uart.h"
#include "debug.h" #include "debug.h"
#include "info.h"
void system_init(void) void system_init(void)
{ {

View File

@ -28,6 +28,7 @@
#include <avr/interrupt.h> /* for sei() */ #include <avr/interrupt.h> /* for sei() */
#include "debug.h" #include "debug.h"
#include "info.h"
#ifndef OCR1A #ifndef OCR1A
#define OCR1A OCR1 // 2313 support #define OCR1A OCR1 // 2313 support

View File

@ -34,6 +34,8 @@
#include "uart.h" #include "uart.h"
#include "sram.h" #include "sram.h"
#include "debug.h" #include "debug.h"
#include "info.h"
#include "crc.h" #include "crc.h"
#include "usb_bulk.h" #include "usb_bulk.h"
@ -54,7 +56,7 @@ uint8_t usbFunctionWrite(uint8_t * data, uint8_t len)
uint8_t i; uint8_t i;
if (len > rx_remaining) { if (len > rx_remaining) {
printf("ERROR:usbFunctionWrite more data than expected remain: %i len: %i\n", info("ERROR:usbFunctionWrite more data than expected remain: %i len: %i\n",
rx_remaining, len); rx_remaining, len);
len = rx_remaining; len = rx_remaining;
} }