diff --git a/avr/usbload/Makefile b/avr/usbload/Makefile index e2d0589..afdccf2 100644 --- a/avr/usbload/Makefile +++ b/avr/usbload/Makefile @@ -4,12 +4,11 @@ DEVICE = atmega644 F_CPU = 20000000 # in Hz FUSE_L = 0xb7 FUSE_H = 0xd9 -AVRDUDE = sudo avrdude -c usbasp -p $(DEVICE) -P $(TTY) +AVRDUDE = avrdude -c usbasp -p $(DEVICE) CFLAGS = -Iusbdrv -I. -DDEBUG_LEVEL=0 #-std=gnu99 OBJECTS = usbdrv/usbdrv.o usbdrv/usbdrvasm.o usbdrv/oddebug.o main.o uart.o fifo.o sram.o crc.o debug.o - COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE) ############################################################################## @@ -38,24 +37,6 @@ COMPILE = avr-gcc -Wall -Os -DF_CPU=$(F_CPU) $(CFLAGS) -mmcu=$(DEVICE) # | +------------------ WDTON (WDT not always on) -################################## ATMega8 ################################## -# ATMega8 FUSE_L (Fuse low byte): -# 0x9f = 1 0 0 1 1 1 1 1 -# ^ ^ \ / \--+--/ -# | | | +------- CKSEL 3..0 (external >8M crystal) -# | | +--------------- SUT 1..0 (crystal osc, BOD enabled) -# | +------------------ BODEN (BrownOut Detector enabled) -# +-------------------- BODLEVEL (2.7V) -# ATMega8 FUSE_H (Fuse high byte): -# 0xc9 = 1 1 0 0 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000) -# ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0 -# | | | | | +-------- BOOTSZ1 -# | | | | + --------- EESAVE (don't preserve EEPROM over chip erase) -# | | | +-------------- CKOPT (full output swing) -# | | +---------------- SPIEN (allow serial programming) -# | +------------------ WDTON (WDT not always on) -# +-------------------- RSTDISBL (reset pin is enabled) -# # symbolic targets: help: diff --git a/avr/usbload/commandline/snesuploader b/avr/usbload/commandline/snesuploader index 37c1d58..d43d4cf 100755 Binary files a/avr/usbload/commandline/snesuploader and b/avr/usbload/commandline/snesuploader differ diff --git a/avr/usbload/main.c b/avr/usbload/main.c index 4601aa6..15e7eec 100644 --- a/avr/usbload/main.c +++ b/avr/usbload/main.c @@ -179,23 +179,82 @@ uint8_t usbFunctionRead(uint8_t * data, uint8_t len) int main(void) { uint8_t i; - //wdt_enable(WDTO_1S); + uint32_t addr; + + wdt_enable(WDTO_8S); uart_init(); stdout = &uart_stdout; - sram_init(); - printf("SRAM Init\n"); - spi_init(); - printf("SPI Init\n"); + + system_init(); + + printf("Sytem Init\n"); + avr_bus_active(); + + + DDRB|= (1 << PB1); + PORTB|= (1 << PB1); + while(1) + wdt_reset(); + +#if 0 + avr_bus_active(); + printf("set sreg 0xff55aa\n"); + sreg_set(0xff55aa); + counter_load(); + sram_write(0xff55aa,0x55); + while(1) + wdt_reset(); + addr = 0x3fffff; + sreg_set(0x00000); + counter_load(); + wdt_reset(); + + while(addr--){ + counter_up(); + } + printf("done\n"); + + while(1){ + wdt_reset(); + i = 10; + while(i--) + _delay_ms(100); + //printf("counter up\n"); + + } +#endif + avr_bus_active(); +#if 1 + addr = 0x00; + i = 0; + while (addr++ <= 0xff){ + sram_write(addr,i++); + } +#endif + addr = 0x00; + while (addr++ <= 0xff){ + printf("read addr=0x%08lx %x\n",addr,sram_read(addr)); + } + while(1); + usbInit(); printf("USB Init\n"); usbDeviceDisconnect(); /* enforce re-enumeration, do this while * interrupts are disabled! */ + cli(); printf("USB disconnect\n"); i = 10; while (--i) { /* fake USB disconnect for > 250 ms */ wdt_reset(); - _delay_ms(1); + led_on(); + _delay_ms(35); + led_off(); + _delay_ms(65); + } + led_on(); + + usbDeviceConnect(); printf("USB connect\n"); sei(); diff --git a/avr/usbload/sram.c b/avr/usbload/sram.c index 0c15e8e..d916ee9 100644 --- a/avr/usbload/sram.c +++ b/avr/usbload/sram.c @@ -1,67 +1,110 @@ #include #include #include +#include +#include /* for _delay_ms() */ + #include "sram.h" #include "uart.h" #include "debug.h" -void spi_init(void) -{ - /* - * Set MOSI and SCK output, all others input - */ - SPI_DIR |= ((1 << S_MOSI) | (1 << S_SCK) | (1 << S_LATCH)); - SPI_DIR &= ~(1 << S_MISO); - SPI_PORT |= (1 << S_MISO); - /* - * Enable SPI, Master - */ - SPCR = ((1 << SPE) | (1 << MSTR)); -} -void spi_master_transmit(unsigned char cData) +void system_init(void) { - /* - * Start transmission - */ - SPDR = cData; + /*-------------------------------------------------*/ + + DDRA = 0x00; + PORTA = 0x00; + + /*-------------------------------------------------*/ + + DDRC |= ( (1 << AVR_ADDR_LATCH_PIN) + | (1 << AVR_ADDR_SCK_PIN) + | (1 << AVR_ADDR_SER_PIN) + | (1 << AVR_ADDR_LOAD_PIN) + | (1 << AVR_ADDR_DOWN_PIN) + | (1 << AVR_ADDR_UP_PIN)); + + DDRC &= ~ (1 << SNES_WR_PIN); + + PORTC &= ~((1 << AVR_ADDR_LATCH_PIN) + | (1 << AVR_ADDR_SCK_PIN)); + + + PORTC |= ( (1 << AVR_ADDR_DOWN_PIN) + | (1 << AVR_ADDR_UP_PIN) + | (1 << AVR_ADDR_LOAD_PIN) + | (1 << SNES_WR_PIN)); + /*-------------------------------------------------*/ + + DDRB |= ( (1 << AVR_RD_PIN) + | (1 << AVR_WR_PIN) + | (1 << AVR_CS_PIN) + | (1 << SNES_IRQ_PIN)); + + PORTB |= ( (1 << AVR_RD_PIN) + | (1 << AVR_WR_PIN) + | (1 << AVR_CS_PIN) + | (1 << SNES_IRQ_PIN)); + /*-------------------------------------------------*/ + + + DDRD |= ( (1 << AVR_SNES_SW_PIN) + | (1 << HI_LOROM_SW_PIN) + | (1 << SNES_WR_EN_PIN)); - /* - * Wait for transmission complete - */ - while (!(SPSR & (1 << SPIF))); + PORTD |= (1 << HI_LOROM_SW_PIN); + + PORTD &= ~((1 << AVR_SNES_SW_PIN) + | (1 << SNES_WR_EN_PIN)); + /*-------------------------------------------------*/ + + +} + + +void sreg_set(uint32_t addr) +{ + uint8_t i = 24; + printf("sreg addr=0x%08lx ",addr); + while(i--) { + if ((addr & ( 1L << i))){ + printf("1"); + AVR_ADDR_SER_PORT |= ( 1 << AVR_ADDR_SER_PIN); + } else { + AVR_ADDR_SER_PORT &= ~( 1 << AVR_ADDR_SER_PIN); + printf("0"); + + } + AVR_ADDR_SCK_PORT |= (1 << AVR_ADDR_SCK_PIN); + AVR_ADDR_SCK_PORT &= ~(1 << AVR_ADDR_SCK_PIN); + } + printf("\n"); + AVR_ADDR_LATCH_PORT |= (1 << AVR_ADDR_LATCH_PIN); + AVR_ADDR_LATCH_PORT &= ~(1 << AVR_ADDR_LATCH_PIN); + + counter_load(); + } -void sram_set_addr(uint32_t addr) -{ - spi_master_transmit((uint8_t) (addr >> 16)); - spi_master_transmit((uint8_t) (addr >> 8)); - spi_master_transmit((uint8_t) (addr >> 0)); - - LATCH_PORT |= (1 << S_LATCH); - LATCH_PORT &= ~(1 << S_LATCH); -} uint8_t sram_read(uint32_t addr) { uint8_t byte; - - RAM_DIR = 0x00; - RAM_PORT = 0xff; - - CTRL_PORT |= (1 << R_RD); - CTRL_PORT |= (1 << R_WR); - - spi_master_transmit((uint8_t) (addr >> 16)); - spi_master_transmit((uint8_t) (addr >> 8)); - spi_master_transmit((uint8_t) (addr >> 0)); - - LATCH_PORT |= (1 << S_LATCH); - LATCH_PORT &= ~(1 << S_LATCH); - CTRL_PORT &= ~(1 << R_RD); - + + avr_data_in(); + + AVR_WR_PORT |= (1 << AVR_WR_PIN); + AVR_RD_PORT |= (1 << AVR_RD_PIN); + AVR_CS_PORT &= ~(1 << AVR_CS_PIN); + _delay_ms(1); + + sreg_set(addr); + + AVR_RD_PORT &= ~(1 << AVR_RD_PIN); + asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); @@ -70,65 +113,39 @@ uint8_t sram_read(uint32_t addr) asm volatile ("nop"); asm volatile ("nop"); asm volatile ("nop"); - - byte = RAM_REG; - CTRL_PORT |= (1 << R_RD); - RAM_DIR = 0x00; - RAM_PORT = 0x00; + + byte = AVR_DATA_PIN; +#if 0 + printf("read %x\n",byte); + while(1) + wdt_reset(); +#endif + AVR_RD_PORT |= (1 << AVR_RD_PIN); + + AVR_CS_PORT |= (1 << AVR_CS_PIN); + + avr_data_in(); return byte; + } void sram_write(uint32_t addr, uint8_t data) { - RAM_DIR = 0xff; - - CTRL_PORT |= (1 << R_RD); - CTRL_PORT |= (1 << R_WR); - - spi_master_transmit((uint8_t) (addr >> 16)); - spi_master_transmit((uint8_t) (addr >> 8)); - spi_master_transmit((uint8_t) (addr >> 0)); - - LATCH_PORT |= (1 << S_LATCH); - LATCH_PORT &= ~(1 << S_LATCH); - - - CTRL_PORT &= ~(1 << R_WR); - - RAM_PORT = data; - CTRL_PORT |= (1 << R_WR); - - RAM_DIR = 0x00; - RAM_PORT = 0x00; -} - -void sram_init(void) -{ - - RAM_DIR = 0x00; - RAM_PORT = 0x00; - - CTRL_DIR |= ((1 << R_WR) | (1 << R_RD)); - CTRL_PORT |= (1 << R_RD); - CTRL_PORT |= (1 << R_WR); - - LED_PORT |= (1 << D_LED0); -} - -void sram_snes_mode01(void) -{ - CTRL_PORT |= (1 << R_WR); - CTRL_PORT &= ~(1 << R_RD); -} - -void sram_snes_mode02(void) -{ - CTRL_DIR |= (1 << R_WR); - CTRL_PORT |= (1 << R_WR); - // CTRL_PORT &= ~(1< -//SREG defines -#define S_MOSI PB5 -#define S_MISO PB6 -#define S_SCK PB7 -#define S_LATCH PB4 - -//DEBUG defines -#define D_LED0 PD6 - -//SRAM defines -#define R_WR PB1 -#define R_RD PB0 - -#define RAM_PORT PORTA -#define RAM_DIR DDRA -#define RAM_REG PINA - -#define CTRL_PORT PORTB -#define CTRL_DIR DDRB -#define LATCH_PORT PORTB -#define LATCH_DIR DDRB - -#define SPI_PORT PORTB -#define SPI_DIR DDRB - -#define LED_PORT PORTD -#define LED_DIR DDRD - #define ROMSIZE 4 #define BLOCKS (ROMSIZE << 8) #define MEMSIZE 0x80000 -void spi_init(void); -void spi_master_transmit(unsigned char cData); -void sram_set_addr(uint32_t addr); +#define LED_PORT PORTC +#define LED_DIR DDRC +#define LED_PIN PC7 + +#define led_on() ((LED_PORT &=~ (1 << LED_PIN)),\ + (LED_DIR &=~ (1 << LED_PIN))) +#define led_off() ((LED_PORT &=~ (1 << LED_PIN)),\ + (LED_DIR |= (1 << LED_PIN))) +/* Port C*/ +#define AVR_ADDR_PORT PORTC +#define AVR_ADDR_DIR DDRC +#define AVR_ADDR_LATCH_PORT PORTC +#define AVR_ADDR_LATCH_DIR DDRC +#define AVR_ADDR_LATCH_PIN PC6 + +#define AVR_ADDR_SCK_PORT PORTC +#define AVR_ADDR_SCK_DIR DDRC +#define AVR_ADDR_SCK_PIN PC5 + +#define AVR_ADDR_SER_PORT PORTC +#define AVR_ADDR_SER_DIR DDRC +#define AVR_ADDR_SER_PIN PC4 + +#define AVR_ADDR_LOAD_PORT PORTC +#define AVR_ADDR_LOAD_DIR DDRC +#define AVR_ADDR_LOAD_PIN PC2 + +#define counter_load() ((AVR_ADDR_LOAD_PORT &= ~(1 << AVR_ADDR_LOAD_PIN)),\ + (AVR_ADDR_LOAD_PORT |= (1 << AVR_ADDR_LOAD_PIN))) + +#define AVR_ADDR_DOWN_PORT PORTC +#define AVR_ADDR_DOWN_DIR DDRC +#define AVR_ADDR_DOWN_PIN PC1 + +#define counter_down() ((AVR_ADDR_DOWN_PORT &= ~(1 << AVR_ADDR_DOWN_PIN)),\ + (AVR_ADDR_DOWN_PORT |= (1 << AVR_ADDR_DOWN_PIN))) + +#define AVR_ADDR_UP_PORT PORTC +#define AVR_ADDR_UP_DIR DDRC +#define AVR_ADDR_UP_PIN PC0 + +#define counter_up() ((AVR_ADDR_UP_PORT &= ~(1 << AVR_ADDR_UP_PIN)),\ + (AVR_ADDR_UP_PORT |= (1 << AVR_ADDR_UP_PIN))) + +#define SNES_WR_PORT PORTC +#define SNES_WR_DIR DDRC +#define SNES_WR_PIN PC3 + +/* Port B*/ +#define AVR_PORT PORTB +#define AVR_DIR DDRB +#define AVR_RD_PORT PORTB +#define AVR_RD_DIR DDRB +#define AVR_RD_PIN PB2 + +#define AVR_WR_PORT PORTB +#define AVR_WR_DIR DDRB +#define AVR_WR_PIN PB1 + +#define AVR_CS_PORT PORTB +#define AVR_CS_DIR DDRB +#define AVR_CS_PIN PB0 + +#define SNES_IRQ_PORT PORTB +#define SNES_IRQ_DIR DDRB +#define SNES_IRQ_PIN PB3 + +#define snes_irq_off() (SNES_IRQ_PORT |= (1 << SNES_IRQ_PIN)) +#define snes_irq_on() (SNES_IRQ_PORT &= ~(1 << SNES_IRQ_PIN)) + + +/* Port A*/ +#define AVR_DATA_PORT PORTA +#define AVR_DATA_DIR DDRA +#define AVR_DATA_PIN PINA + +#define avr_data_in() ((AVR_DATA_DIR = 0x00),\ + (AVR_DATA_PORT = 0x00)) + +#define avr_data_out() (AVR_DATA_DIR = 0xff) + +/* Port D*/ + +#define AVR_SNES_PORT PORTD +#define AVR_SNES_DIR DDRD +#define AVR_SNES_SW_PORT PORTD +#define AVR_SNES_SW_DIR DDRD +#define AVR_SNES_SW_PIN PD5 + +#define avr_bus_active() ((AVR_SNES_SW_PORT &= ~(1 << AVR_SNES_SW_PIN)),\ + (HI_LOROM_SW_PORT |= (1 << HI_LOROM_SW_PIN))) + +#define snes_bus_active() (AVR_SNES_SW_PORT |= (1 << AVR_SNES_SW_PIN)) + +#define HI_LOROM_SW_PORT PORTD +#define HI_LOROM_SW_DIR DDRD +#define HI_LOROM_SW_PIN PD6 + +#define snes_hirom() (HI_LOROM_SW_PORT &= ~(1 << HI_LOROM_SW_PIN)) +#define snes_lorom() (HI_LOROM_SW_PORT |= (1 << HI_LOROM_SW_PIN)) + + +#define SNES_WR_EN_PORT PORTD +#define SNES_WR_EN_DIR DDRD +#define SNES_WR_EN_PIN PD7 + +#define snes_wr_disable() (SNES_WR_EN_PORT &= ~(1 << SNES_WR_EN_PIN)) +#define snes_wr_enable() (SNES_WR_EN_PORT |= (1 << SNES_WR_EN_PIN)) + + + + + + + +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_init(void); -void sram_snes_mode01(void); -void sram_snes_mode02(void); void sram_clear(uint32_t addr, uint32_t len); void sram_copy(uint32_t addr,uint8_t *src, uint32_t len); void sram_read_buffer(uint32_t addr,uint8_t *dst, uint32_t len); diff --git a/avr/usbload/usbconfig.h b/avr/usbload/usbconfig.h index 9235795..0284c4a 100644 --- a/avr/usbload/usbconfig.h +++ b/avr/usbload/usbconfig.h @@ -56,13 +56,13 @@ section at the end of this file). /* ----------------------- Optional Hardware Config ------------------------ */ -#define USB_CFG_PULLUP_IOPORTNAME D +//#define USB_CFG_PULLUP_IOPORTNAME D /* If you connect the 1.5k pullup resistor from D- to a port pin instead of * V+, you can connect and disconnect the device from firmware by calling * the macros usbDeviceConnect() and usbDeviceDisconnect() (see usbdrv.h). * This constant defines the port on which the pullup resistor is connected. */ -#define USB_CFG_PULLUP_BIT 6 +//#define USB_CFG_PULLUP_BIT 6 /* This constant defines the bit number in USB_CFG_PULLUP_IOPORT (defined * above) where the 1.5k pullup resistor is connected. See description * above for details. @@ -206,7 +206,7 @@ section at the end of this file). * own Vendor ID, define it here. Otherwise you use one of obdev's free shared * VID/PID pairs. Be sure to read USBID-License.txt for rules! */ -#define USB_CFG_DEVICE_ID 0xdc, 0x05 +#define USB_CFG_DEVICE_ID 0xdd, 0x05 /* This is the ID of the product, low byte first. It is interpreted in the * scope of the vendor ID. If you have registered your own VID with usb.org * or if you have licensed a PID from somebody else, define it here. Otherwise diff --git a/poc/poc_at644/Makefile b/poc/poc_at644/Makefile index 3ef6916..00169cd 100644 --- a/poc/poc_at644/Makefile +++ b/poc/poc_at644/Makefile @@ -42,7 +42,7 @@ MCU = atmega644 # Main Oscillator Frequency # This is only used to define F_OSC in all assembler and c-sources. -F_OSC = 8000000 +F_OSC = 20000000 # Output format. (can be srec, ihex, binary) FORMAT = ihex @@ -177,11 +177,90 @@ LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB) # # Type: avrdude -c ? # to get a full listing. +############################################################################## +# Fuse values for particular devices +############################################################################## +# If your device is not listed here, go to +# http://palmavr.sourceforge.net/cgi-bin/fc.cgi +# and choose options for external crystal clock and no clock divider # -AVRDUDE_PROGRAMMER = stk500v2 +################################## ATMega8 ################################## +# ATMega8 FUSE_L (Fuse low byte): +# 0x9f = 1 0 0 1 1 1 1 1 +# ^ ^ \ / \--+--/ +# | | | +------- CKSEL 3..0 (external >8M crystal) +# | | +--------------- SUT 1..0 (crystal osc, BOD enabled) +# | +------------------ BODEN (BrownOut Detector enabled) +# +-------------------- BODLEVEL (2.7V) +# ATMega8 FUSE_H (Fuse high byte): +# 0xc9 = 1 1 0 0 1 0 0 1 <-- BOOTRST (boot reset vector at 0x0000) +# ^ ^ ^ ^ ^ ^ ^------ BOOTSZ0 +# | | | | | +-------- BOOTSZ1 +# | | | | + --------- EESAVE (don't preserve EEPROM over chip erase) +# | | | +-------------- CKOPT (full output swing) +# | | +---------------- SPIEN (allow serial programming) +# | +------------------ WDTON (WDT not always on) +# +-------------------- RSTDISBL (reset pin is enabled) +# +############################## ATMega48/88/168 ############################## +# ATMega*8 FUSE_L (Fuse low byte): +# 0xdf = 1 1 0 1 1 1 1 1 +# ^ ^ \ / \--+--/ +# | | | +------- CKSEL 3..0 (external >8M crystal) +# | | +--------------- SUT 1..0 (crystal osc, BOD enabled) +# | +------------------ CKOUT (if 0: Clock output enabled) +# +-------------------- CKDIV8 (if 0: divide by 8) +# ATMega*8 FUSE_H (Fuse high byte): +# 0xde = 1 1 0 1 1 1 1 0 +# ^ ^ ^ ^ ^ \-+-/ +# | | | | | +------ BODLEVEL 0..2 (110 = 1.8 V) +# | | | | + --------- EESAVE (preserve EEPROM over chip erase) +# | | | +-------------- WDTON (if 0: watchdog always on) +# | | +---------------- SPIEN (allow serial programming) +# | +------------------ DWEN (debug wire enable) +# +-------------------- RSTDISBL (reset pin is enabled) +# +############################## ATTiny25/45/85 ############################### +# ATMega*5 FUSE_L (Fuse low byte): +# 0xef = 1 1 1 0 1 1 1 1 +# ^ ^ \+/ \--+--/ +# | | | +------- CKSEL 3..0 (clock selection -> crystal @ 12 MHz) +# | | +--------------- SUT 1..0 (BOD enabled, fast rising power) +# | +------------------ CKOUT (clock output on CKOUT pin -> disabled) +# +-------------------- CKDIV8 (divide clock by 8 -> don't divide) +# ATMega*5 FUSE_H (Fuse high byte): +# 0xdd = 1 1 0 1 1 1 0 1 +# ^ ^ ^ ^ ^ \-+-/ +# | | | | | +------ BODLEVEL 2..0 (brownout trigger level -> 2.7V) +# | | | | +---------- EESAVE (preserve EEPROM on Chip Erase -> not preserved) +# | | | +-------------- WDTON (watchdog timer always on -> disable) +# | | +---------------- SPIEN (enable serial programming -> enabled) +# | +------------------ DWEN (debug wire enable) +# +-------------------- RSTDISBL (disable external reset -> enabled) +# +################################ ATTiny2313 ################################# +# ATTiny2313 FUSE_L (Fuse low byte): +# 0xef = 1 1 1 0 1 1 1 1 +# ^ ^ \+/ \--+--/ +# | | | +------- CKSEL 3..0 (clock selection -> crystal @ 12 MHz) +# | | +--------------- SUT 1..0 (BOD enabled, fast rising power) +# | +------------------ CKOUT (clock output on CKOUT pin -> disabled) +# +-------------------- CKDIV8 (divide clock by 8 -> don't divide) +# ATTiny2313 FUSE_H (Fuse high byte): +# 0xdb = 1 1 0 1 1 0 1 1 +# ^ ^ ^ ^ \-+-/ ^ +# | | | | | +---- RSTDISBL (disable external reset -> enabled) +# | | | | +-------- BODLEVEL 2..0 (brownout trigger level -> 2.7V) +# | | | +-------------- WDTON (watchdog timer always on -> disable) +# | | +---------------- SPIEN (enable serial programming -> enabled) +# | +------------------ EESAVE (preserve EEPROM on Chip Erase -> not preserved) +# +-------------------- DWEN (debug wire enable) + +# +AVRDUDE_PROGRAMMER = usbasp # com1 = serial port. Use lpt1 to connect to parallel port. -AVRDUDE_PORT = /dev/ttyUSB0 # programmer connected to serial device +AVRDUDE_PORT = # programmer connected to serial device AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep @@ -201,7 +280,7 @@ AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex # to submit bug reports. #AVRDUDE_VERBOSE = -v -v -AVRDUDE_FLAGS = -p $(MCU) -P $(AVRDUDE_PORT) -c $(AVRDUDE_PROGRAMMER) +AVRDUDE_FLAGS = -p $(MCU) -c $(AVRDUDE_PROGRAMMER) AVRDUDE_FLAGS += $(AVRDUDE_NO_VERIFY) AVRDUDE_FLAGS += $(AVRDUDE_VERBOSE) AVRDUDE_FLAGS += $(AVRDUDE_ERASE_COUNTER) diff --git a/poc/poc_at644/main.c b/poc/poc_at644/main.c index 9556bec..e7c278e 100644 --- a/poc/poc_at644/main.c +++ b/poc/poc_at644/main.c @@ -102,7 +102,8 @@ void SRAM_Write(uint32_t addr, uint8_t data) int main(void) { - + DDRB|= (1 << PB1); + PORTB|= (1 << PB1); while(1); return(0); } diff --git a/poc/poc_at644/mmc.c b/poc/poc_at644/mmc.c deleted file mode 100644 index 28cb62c..0000000 --- a/poc/poc_at644/mmc.c +++ /dev/null @@ -1,298 +0,0 @@ -/*####################################################################################### -Connect AVR to MMC/SD - -Copyright (C) 2004 Ulrich Radig - -Bei Fragen und Verbesserungen wendet euch per EMail an - -mail@ulrichradig.de - -oder im Forum meiner Web Page : www.ulrichradig.de - -Dieses Programm ist freie Software. Sie können es unter den Bedingungen der -GNU General Public License, wie von der Free Software Foundation veröffentlicht, -weitergeben und/oder modifizieren, entweder gemäß Version 2 der Lizenz oder -(nach Ihrer Option) jeder späteren Version. - -Die Veröffentlichung dieses Programms erfolgt in der Hoffnung, -daß es Ihnen von Nutzen sein wird, aber OHNE IRGENDEINE GARANTIE, -sogar ohne die implizite Garantie der MARKTREIFE oder der VERWENDBARKEIT -FÜR EINEN BESTIMMTEN ZWECK. Details finden Sie in der GNU General Public License. - -Sie sollten eine Kopie der GNU General Public License zusammen mit diesem -Programm erhalten haben. -Falls nicht, schreiben Sie an die Free Software Foundation, -Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307, USA. -#######################################################################################*/ - -#include "mmc.h" -#include - -//############################################################################ -//Routine zur Initialisierung der MMC/SD-Karte (SPI-MODE) -unsigned char mmc_init () -//############################################################################ -{ - unsigned int Timeout = 0,i; - - //Konfiguration des Ports an der die MMC/SD-Karte angeschlossen wurde - DDRC |= ( (1< 20) - { - MMC_Disable(); - return(1); //Abbruch bei Commando1 (Return Code1) - } - } - - //Sendet Commando CMD1 an MMC/SD-Karte - Timeout = 0; - - CMD[0] = 0x41;//Commando 1 - CMD[5] = 0xFF; - - while( mmc_write_command (CMD) !=0) - { - if (Timeout++ > 800) - { - MMC_Disable(); - return(9); //Abbruch bei Commando2 (Return Code2) - } - } - return(0); -} - -//############################################################################ -//Sendet ein Commando an die MMC/SD-Karte -unsigned char mmc_write_command (unsigned char *cmd) -//############################################################################ -{ - unsigned char tmp = 0xff; - unsigned int Timeout = 0; - - - //sendet 6 Byte Commando - for (unsigned char a = 0;a<0x06;a++) //sendet 6 Byte Commando zur MMC/SD-Karte - { - mmc_write_byte(*cmd++); - } - - //Wartet auf ein gültige Antwort von der MMC/SD-Karte - while (tmp == 0xff) - { - tmp = mmc_read_byte(); - - if (Timeout++ > 50) - { - break; //Abbruch da die MMC/SD-Karte nicht Antwortet - } - } - return(tmp); -} - -//############################################################################ -//Routine zum Empfangen eines Bytes von der MMC-Karte -unsigned char mmc_read_byte (void) -//############################################################################ -{ - uint8_t Byte=0,j; - - for(j=0; j<8; j++){ - Byte = (Byte<<1); - - PORTC |= (1<>24 ); - cmd[2] = ((addr & 0x00FF0000) >>16 ); - cmd[3] = ((addr & 0x0000FF00) >>8 ); - - //Sendet Commando cmd24 an MMC/SD-Karte (Write 1 Block/512 Bytes) - tmp = mmc_write_command (cmd); - if (tmp != 0) - { - return(tmp); - } - - //Wartet einen Moment und sendet einen Clock an die MMC/SD-Karte - for (unsigned char a=0;a<100;a++) - { - mmc_read_byte(); - } - - //Sendet Start Byte an MMC/SD-Karte - mmc_write_byte(0xFE); - - //Schreiben des Bolcks (512Bytes) auf MMC/SD-Karte - for (unsigned int a=0;a<512;a++) - { - mmc_write_byte(*Buffer++); - } - - //CRC-Byte schreiben - mmc_write_byte(0xFF); //Schreibt Dummy CRC - mmc_write_byte(0xFF); //CRC Code wird nicht benutzt - - //Fehler beim schreiben? (Data Response XXX00101 = OK) - if((mmc_read_byte()&0x1F) != 0x05) return(1); - - //Wartet auf MMC/SD-Karte Bussy - while (mmc_read_byte() != 0xff){}; - - -return(0); -} - -//############################################################################ -//Routine zum lesen des CID Registers von der MMC/SD-Karte (16Bytes) -void mmc_read_block(unsigned char *cmd,unsigned char *Buffer,unsigned int Bytes) -//############################################################################ -{ - //Sendet Commando cmd an MMC/SD-Karte - if (mmc_write_command (cmd) != 0) - { - return; - } - - //Wartet auf Start Byte von der MMC/SD-Karte (FEh/Start Byte) - - while (mmc_read_byte() != 0xfe){}; - - //Lesen des Bolcks (normal 512Bytes) von MMC/SD-Karte - for (unsigned int a=0;a>24 ); - cmd[2] = ((addr & 0x00FF0000) >>16 ); - cmd[3] = ((addr & 0x0000FF00) >>8 ); - - mmc_read_block(cmd,Buffer,512); - - return(0); -} - -//############################################################################ -//Routine zum lesen des CID Registers von der MMC/SD-Karte (16Bytes) -unsigned char mmc_read_cid (unsigned char *Buffer) -//############################################################################ -{ - //Commando zum lesen des CID Registers - unsigned char cmd[] = {0x4A,0x00,0x00,0x00,0x00,0xFF}; - - mmc_read_block(cmd,Buffer,16); - - return(0); -} - -//############################################################################ -//Routine zum lesen des CSD Registers von der MMC/SD-Karte (16Bytes) -unsigned char mmc_read_csd (unsigned char *Buffer) -//############################################################################ -{ - //Commando zum lesen des CSD Registers - unsigned char cmd[] = {0x49,0x00,0x00,0x00,0x00,0xFF}; - - mmc_read_block(cmd,Buffer,16); - return(0); -} diff --git a/poc/poc_at644/mmc.h b/poc/poc_at644/mmc.h deleted file mode 100644 index 2a251a0..0000000 --- a/poc/poc_at644/mmc.h +++ /dev/null @@ -1,57 +0,0 @@ -/*####################################################################################### -Connect ARM to MMC/SD - -Copyright (C) 2004 Ulrich Radig -#######################################################################################*/ - -#ifndef _MMC_H_ - #define _MMC_H_ - -#include - -//#define SPI_Mode 1 //1 = Hardware SPI | 0 = Software SPI -#define SPI_Mode 0 - -#define MMC_Write PORTC //Port an der die MMC/SD-Karte angeschlossen ist also des SPI -#define MMC_Read PINC -#define MMC_Direction_REG DDRC - -#if defined (__AVR_ATmega8__) -#define MMC_CS PC0 -#define MMC_DO PC1 -#define MMC_DI PC2 -#define MMC_CLK PC3 - #define SPI_SS 4 //Nicht Benutz muß aber definiert werden -#endif - - -//Prototypes -extern unsigned char mmc_read_byte(void); - -extern void mmc_write_byte(unsigned char); - -extern void mmc_read_block(unsigned char *,unsigned char *,unsigned in); - -extern unsigned char mmc_init(void); - -extern unsigned char mmc_read_sector (unsigned long,unsigned char *); - -extern unsigned char mmc_write_sector (unsigned long,unsigned char *); - -extern unsigned char mmc_write_command (unsigned char *); - -extern unsigned char mmc_read_csd (unsigned char *); - -extern unsigned char mmc_read_cid (unsigned char *); - -//set MMC_Chip_Select to high (MMC/SD-Karte Inaktiv) -#define MMC_Disable() MMC_Write|= (1< currentDocument - tools/bsnes/cart/cart.hpp + avr/usbload/commandline/snesuploader.c documents @@ -21,6 +21,216 @@ 271 metaData + avr/usbload/Makefile + + caret + + column + 29 + line + 4 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + avr/usbload/commandline/opendevice.c + + caret + + column + 3 + line + 27 + + firstVisibleColumn + 0 + firstVisibleLine + 234 + + avr/usbload/commandline/opendevice.h + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 26 + + avr/usbload/commandline/snesuploader.c + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 198 + + avr/usbload/crc.c + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + avr/usbload/debug.c + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + avr/usbload/debug.h + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + avr/usbload/fifo.c + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + avr/usbload/fifo.h + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + avr/usbload/main.c + + caret + + column + 17 + line + 59 + + firstVisibleColumn + 0 + firstVisibleLine + 161 + + avr/usbload/sram.c + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 121 + + avr/usbload/sram.h + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + avr/usbload/uart.c + + caret + + column + 25 + line + 59 + + firstVisibleColumn + 0 + firstVisibleLine + 26 + + avr/usbload/uart.h + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + avr/usbload/usbconfig.h + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 207 + poc/avr_sdcard/fat.h caret @@ -49,6 +259,48 @@ firstVisibleLine 0 + scripts/b.py + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 0 + + scripts/rom.py + + caret + + column + 0 + line + 228 + + firstVisibleColumn + 0 + firstVisibleLine + 189 + + scripts/rom_analyse.sql + + caret + + column + 0 + line + 0 + + firstVisibleColumn + 0 + firstVisibleLine + 2 + snes/banktest/LoadGraphics.asm caret @@ -322,6 +574,24 @@ tools/bsnes/memory/smemory/mapper/chip.cpp tools/bsnes/cart/cart.cpp tools/bsnes/cart/cart.hpp + scripts/rom_analyse.sql + scripts/b.py + scripts/rom.py + avr/usbload/crc.c + avr/usbload/sram.c + avr/usbload/sram.h + avr/usbload/fifo.h + avr/usbload/fifo.c + avr/usbload/Makefile + avr/usbload/debug.h + avr/usbload/debug.c + avr/usbload/uart.c + avr/usbload/main.c + avr/usbload/usbconfig.h + avr/usbload/commandline/opendevice.c + avr/usbload/commandline/opendevice.h + avr/usbload/commandline/snesuploader.c + avr/usbload/uart.h showFileHierarchyDrawer @@ -334,10 +604,55 @@ isExpanded subItems - + + avr + + isExpanded + + subItems + + usbload + + isExpanded + + subItems + + commandline + + isExpanded + + subItems + + + + + + + poc + + isExpanded + + subItems + + + scripts + + isExpanded + + subItems + + + snes + + isExpanded + + subItems + + + windowFrame - {{96, 60}, {936, 818}} + {{0, 60}, {936, 818}}