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
#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);
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){
}
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;
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:
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;
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)
{
F_CPU = 16000000
-FORMAT = srec
+#FORMAT = srec
+FORMAT = ihex
# Target file name (without extension).
OBJDIR = ./$(TARGET)
# 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
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
#include <stdint.h>
-#include "request.h"
#include "bus_access.h"
//---- global variable ----
-#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,
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
#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.