OSDN Git Service

read buffer and programming buffer are separated
authornaruko <naruko@24ea1065-a21e-4ca1-99c9-f5125deb0858>
Sun, 29 Nov 2009 03:32:18 +0000 (03:32 +0000)
committernaruko <naruko@24ea1065-a21e-4ca1-99c9-f5125deb0858>
Sun, 29 Nov 2009 03:32:18 +0000 (03:32 +0000)
git-svn-id: svn+ssh://svn.osdn.net/svnroot/unagi@314 24ea1065-a21e-4ca1-99c9-f5125deb0858

kazzo/trunk/Makefile
kazzo/trunk/avr_main.c
kazzo/trunk/bus_access.c
kazzo/trunk/firmware.mak
kazzo/trunk/flashmemory.c
kazzo/trunk/kazzo_request.h [moved from kazzo/trunk/request.h with 57% similarity]
kazzo/trunk/usbconfig.h

index 0909efb..15122ed 100644 (file)
@@ -4,3 +4,6 @@ all:
 clean:
        make -f firmware.mak MCU=atmega164p TARGET=kazzo_mega164p clean
        make -f firmware.mak MCU=atmega16 TARGET=kazzo_mega16 clean
+
+p4p:
+       make -f firmware.mak MCU=atmega164p TARGET=kazzo_mega164p program
index a458523..371d0ce 100644 (file)
@@ -5,19 +5,21 @@
 #include "bus_access.h"
 #include "disk_access.h"
 #include "flashmemory.h"
-#include "request.h"
+#include "kazzo_request.h"
 
 //---- global variable ----
 static struct write_command{
        enum request request;
        uint16_t address, length, offset;
 }write_command;
-static uint8_t readbuffer[READ_PACKET_SIZE];
 
 //---- function start ----
 uchar usbFunctionWrite(uchar *data, uchar len)
 {
+       static uint8_t cpu_buffer[FLASH_PACKET_SIZE];
+       static uint8_t ppu_buffer[FLASH_PACKET_SIZE];
        const uint16_t length = (uint16_t) len;
+       
        switch(write_command.request){
        case REQUEST_CPU_WRITE_6502:
                cpu_write_6502(write_command.address + write_command.offset, length, data);
@@ -30,12 +32,12 @@ uchar usbFunctionWrite(uchar *data, uchar len)
                break;
        case REQUEST_CPU_FLASH_PROGRAM:
        case REQUEST_PPU_FLASH_PROGRAM:{
-               static uint8_t *w = readbuffer;
+               static uint8_t *w = cpu_buffer; //this is static pointer! be careful.
                if(write_command.offset == 0){
                        if(write_command.request == REQUEST_CPU_FLASH_PROGRAM){
-                               w = readbuffer;
+                               w = cpu_buffer;
                        }else{
-                               w = readbuffer + 0x100;
+                               w = ppu_buffer;
                        }
                }
                while(len != 0){
@@ -47,9 +49,9 @@ uchar usbFunctionWrite(uchar *data, uchar len)
                }
                if(write_command.length == write_command.offset){
                        if(write_command.request == REQUEST_CPU_FLASH_PROGRAM){
-                               flash_cpu_program(write_command.address, write_command.length, readbuffer);
+                               flash_cpu_program(write_command.address, write_command.length, cpu_buffer);
                        }else{
-                               flash_ppu_program(write_command.address, write_command.length, readbuffer + 0x100);
+                               flash_ppu_program(write_command.address, write_command.length, ppu_buffer);
                        }
                }
                }return write_command.length == write_command.offset;
@@ -104,9 +106,10 @@ uchar usbFunctionWrite(uchar *data, uchar len)
 
 usbMsgLen_t usbFunctionSetup(uchar d[8])
 {
+       static uint8_t readbuffer[READ_PACKET_SIZE];
+       static uint8_t status[2];
        usbRequest_t *rq = (void *)d;
        uint8_t *data = readbuffer;
-       static uint8_t status[2];
 
        switch((enum request) rq->bRequest){
        case REQUEST_ECHO:
@@ -144,8 +147,8 @@ usbMsgLen_t usbFunctionSetup(uchar d[8])
                write_command.offset = 0;
                return USB_NO_MSG; //goto usbFunctionWrite
        case REQUEST_DISK_STATUS_GET:
-               usbMsgPtr = data;
-               return disk_status_get(data);
+               usbMsgPtr = status;
+               return disk_status_get(status);
        case REQUEST_DISK_READ: 
                disk_init(DISK_READ);
                return 0;
index 2134103..ba4575e 100644 (file)
@@ -384,11 +384,11 @@ void cpu_write_6502(uint16_t address, uint16_t length, const uint8_t *data)
 
 static inline void ppu_write_waveform(uint16_t address, uint8_t data)
 {
-       address_set(address);//PPU memory /CS open
+       address_set(address);//PPU charcter memory /CS open
        BUS_CONTROL_OUT = bit_get_negative(PPU_WR);
        DATABUS_OUT = data;
        BUS_CONTROL_OUT = BUS_CLOSE;
-       address_set(1 << 13); //PPU memory /CS close
+       address_set(1 << 13); ///CS close
 }
 void ppu_write(uint16_t address, uint16_t length, const uint8_t *data)
 {
index 6df0bf7..b1dde45 100644 (file)
@@ -1,5 +1,6 @@
 F_CPU = 16000000
-FORMAT = srec
+#FORMAT = srec
+FORMAT = ihex
 
 # Target file name (without extension).
 OBJDIR = ./$(TARGET)
@@ -130,10 +131,10 @@ LDFLAGS += $(PRINTF_LIB) $(SCANF_LIB) $(MATH_LIB)
 # Programming hardware
 # Type: avrdude -c ?
 # to get a full listing.
-AVRDUDE_PROGRAMMER = stk500v2
+AVRDUDE_PROGRAMMER = avrisp #stk500v2
 
 # com1 = serial port. Use lpt1 to connect to parallel port.
-AVRDUDE_PORT = com3 # programmer connected to serial device
+AVRDUDE_PORT = com4 # programmer connected to serial device
 
 AVRDUDE_WRITE_FLASH = -U flash:w:$(TARGET).hex
 #AVRDUDE_WRITE_EEPROM = -U eeprom:w:$(TARGET).eep
@@ -237,8 +238,8 @@ ALL_ASFLAGS = -mmcu=$(MCU) -I. -x assembler-with-cpp $(ASFLAGS)
 all: begin gccversion sizebefore build sizeafter end
 
 # Change the build target to build a HEX file or a library.
-build: elf hex eep lss sym sr
-#build: lib
+build: elf hex eep lss sym
+#build: lib sr
 
 
 elf: $(TARGET).elf
index 82d5fec..0e3ca21 100644 (file)
@@ -1,5 +1,4 @@
 #include <stdint.h>
-#include "request.h"
 #include "bus_access.h"
 
 //---- global variable ----
similarity index 57%
rename from kazzo/trunk/request.h
rename to kazzo/trunk/kazzo_request.h
index f9afc6e..32c054a 100644 (file)
@@ -1,5 +1,13 @@
-#ifndef __REQUEST_H_
-#define __REQUEST_H_
+#ifndef _KAZZO_REQUEST_H_
+#define _KAZZO_REQUEST_H_
+#define USB_CFG_VENDOR_ID       0xc0, 0x16
+#define USB_CFG_DEVICE_ID       0xdc, 0x05
+#define USB_CFG_DEVICE_VERSION  0x00, 0x01
+#define USB_CFG_VENDOR_NAME     'o', 'b', 'd', 'e', 'v', '.', 'a', 't'
+#define USB_CFG_VENDOR_NAME_LEN 8
+#define USB_CFG_DEVICE_NAME     'k', 'a', 'z', 'z', 'o'
+#define USB_CFG_DEVICE_NAME_LEN 5
+
 enum request{
        REQUEST_ECHO = 0,
        REQUEST_PHI2_INIT,
@@ -17,13 +25,7 @@ enum request{
        REQUEST_VRAM_CONNECTION
 };
 enum {
-       READ_PACKET_SIZE = 0x0200,
-       FLASH_PACKET_SIZE = READ_PACKET_SIZE / 2
+       READ_PACKET_SIZE = 0x0100,
+       FLASH_PACKET_SIZE = 0x0100
 };
-/*
-request argument
-bRequest       wValue  wLength
-xxx_READ       address length
-xxx_WRITExxxx  address length
-*/
 #endif
index d4f6522..13014fc 100644 (file)
 #define USB_USE_FAST_CRC                0
 
 /* -------------------------- Device Description --------------------------- */
-
-#define  USB_CFG_VENDOR_ID       0xc0, 0x16 /* = 0x16c0 = 5824 = voti.nl */
-/* USB vendor ID for the device, low byte first. If you have registered your
- * own Vendor ID, define it here. Otherwise you may use one of obdev's free
- * shared VID/PID pairs. Be sure to read USB-IDs-for-free.txt for rules!
- * *** IMPORTANT NOTE ***
- * This template uses obdev's shared VID/PID pair for Vendor Class devices
- * with libusb: 0x16c0/0x5dc.  Use this VID/PID pair ONLY if you understand
- * the implications!
- */
-#define  USB_CFG_DEVICE_ID       0xdc, 0x05 /* = 0x05dc = 1500 */
-/* 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
- * you may use one of obdev's free shared VID/PID pairs. See the file
- * USB-IDs-for-free.txt for details!
- * *** IMPORTANT NOTE ***
- * This template uses obdev's shared VID/PID pair for Vendor Class devices
- * with libusb: 0x16c0/0x5dc.  Use this VID/PID pair ONLY if you understand
- * the implications!
- */
-#define USB_CFG_DEVICE_VERSION  0x00, 0x01
-/* Version number of the device: Minor number first, then major number.
- */
-#define USB_CFG_VENDOR_NAME     'o', 'b', 'd', 'e', 'v', '.', 'a', 't'
-#define USB_CFG_VENDOR_NAME_LEN 8
-/* These two values define the vendor name returned by the USB device. The name
- * must be given as a list of characters under single quotes. The characters
- * are interpreted as Unicode (UTF-16) entities.
- * If you don't want a vendor name string, undefine these macros.
- * ALWAYS define a vendor name containing your Internet domain name if you use
- * obdev's free shared VID/PID pair. See the file USB-IDs-for-free.txt for
- * details.
- */
-#define USB_CFG_DEVICE_NAME     'k', 'a', 'z', 'z', 'o'
-#define USB_CFG_DEVICE_NAME_LEN 5
 /* Same as above for the device name. If you don't want a device name, undefine
  * the macros. See the file USB-IDs-for-free.txt before you assign a name if
  * you use a shared VID/PID.