#include "request.h"
//---- global variable ----
-static struct{
+static struct write_command{
enum request request;
uint16_t address, length, offset;
}write_command;
case REQUEST_PPU_FLASH_PROGRAM:{
static uint8_t *w = readbuffer;
if(write_command.offset == 0){
- w = readbuffer;
+ if(write_command.request == REQUEST_CPU_FLASH_PROGRAM){
+ w = readbuffer;
+ }else{
+ w = readbuffer + 0x100;
+ }
}
while(len != 0){
*w = *data;
if(write_command.request == REQUEST_CPU_FLASH_PROGRAM){
flash_cpu_program(write_command.address, write_command.length, readbuffer);
}else{
- flash_ppu_program(write_command.address, write_command.length, readbuffer);
+ flash_ppu_program(write_command.address, write_command.length, readbuffer + 0x100);
}
}
}return write_command.length == write_command.offset;
case REQUEST_DISK_WRITE:
disk_init(DISK_WRITE);
return 0;
+ case REQUEST_BOTH_FLASH_STATUS:
+ status[0] = flash_cpu_status();
+ status[1] = flash_ppu_status();
+ usbMsgPtr = status;
+ return 2;
case REQUEST_CPU_FLASH_STATUS:
status[0] = flash_cpu_status();
usbMsgPtr = status;
uint8_t toggle;
};
static struct flash_seqence seqence_cpu = {
- .status = IDLE, .reader = cpu_read, .writer = cpu_write_flash,
+ .status = IDLE, .reader = cpu_read_6502, .writer = cpu_write_flash,
.compare = cpu_compare
};
static struct flash_seqence seqence_ppu = {
erase_wait(s);
break;
case PROGRAM:
- program(s);
+ if((s->program_unit != 1) || (*(s->data) != 0xff)){
+ program(s);
+ }
s->status = TOGGLE_FIRST;
break;
case TOGGLE_FIRST:
REQUEST_CPU_WRITE_6502, REQUEST_CPU_WRITE_FLASH,
REQUEST_PPU_READ, REQUEST_PPU_WRITE,
REQUEST_DISK_STATUS_GET, REQUEST_DISK_READ, REQUEST_DISK_WRITE,
+ REQUEST_BOTH_FLASH_STATUS,
REQUEST_CPU_FLASH_STATUS, REQUEST_CPU_FLASH_CONFIG_SET,
REQUEST_CPU_FLASH_PROGRAM, REQUEST_CPU_FLASH_ERASE,
REQUEST_PPU_FLASH_STATUS, REQUEST_PPU_FLASH_CONFIG_SET,