modified: host/source/inlprog.c
new file: host/source/erase.c new file: host/source/erase.h creating erase files called from main with e_flag modified: firmware/source/usb.c introducing switch statement with range of values of opcode type detection. modified: host/source/usb_operations.h turning off debug modified: shared/shared_errors.h renumbering some error codes thinking I'll have codes which can come from avr set to 128+
This commit is contained in:
parent
14eddd74ab
commit
94ea3fd474
|
|
@ -84,29 +84,28 @@ USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]) {
|
|||
|
||||
switch(spacket->bRequest) {
|
||||
case PINPORT:
|
||||
if((spacket->opcode > PP_OPCODE_ONLY_MIN)
|
||||
& (spacket->opcode < PP_OPCODE_ONLY_MAX)) {
|
||||
rv[0] = pinport_opcode_only( spacket->opcode );
|
||||
|
||||
} else if ((spacket->opcode > PP_OPCODE_8BOP_MIN)
|
||||
& (spacket->opcode < PP_OPCODE_8BOP_MAX)) {
|
||||
rv[0] = pinport_opcode_8b_operand( spacket->opcode, spacket->wIndexLSB );
|
||||
|
||||
} else if ((spacket->opcode > PP_OPCODE_16BOP_MIN)
|
||||
& (spacket->opcode < PP_OPCODE_16BOP_MAX)) {
|
||||
rv[0] = pinport_opcode_16b_operand( spacket->opcode,
|
||||
spacket->wIndexMSB, spacket->wIndexLSB );
|
||||
|
||||
} else if ((spacket->opcode > PP_OPCODE_24BOP_MIN)
|
||||
& (spacket->opcode < PP_OPCODE_24BOP_MAX)) {
|
||||
rv[0] = pinport_opcode_24b_operand( spacket->opcode,
|
||||
switch (spacket->opcode) {
|
||||
case PP_OPCODE_ONLY_MIN ... PP_OPCODE_ONLY_MAX:
|
||||
rv[0] = pinport_opcode_only( spacket->opcode );
|
||||
break;
|
||||
case PP_OPCODE_8BOP_MIN ... PP_OPCODE_8BOP_MAX:
|
||||
rv[0] = pinport_opcode_8b_operand(
|
||||
spacket->opcode, spacket->wIndexLSB );
|
||||
break;
|
||||
case PP_OPCODE_16BOP_MIN ... PP_OPCODE_16BOP_MAX:
|
||||
rv[0] = pinport_opcode_16b_operand(
|
||||
spacket->opcode, spacket->wIndexMSB, spacket->wIndexLSB );
|
||||
break;
|
||||
case PP_OPCODE_24BOP_MIN ... PP_OPCODE_24BOP_MAX:
|
||||
rv[0] = pinport_opcode_24b_operand( spacket->opcode,
|
||||
spacket->wValueMSB, spacket->wIndexMSB, spacket->wIndexLSB );
|
||||
|
||||
} else if ((spacket->opcode > PP_OPCODE_8BRV_MIN)
|
||||
& (spacket->opcode < PP_OPCODE_8BRV_MAX)) {
|
||||
rv[0] = pinport_opcode_8b_return( spacket->opcode, &rv[1]);
|
||||
//return error code plus opcode return value
|
||||
rlen ++;
|
||||
break;
|
||||
case PP_OPCODE_8BRV_MIN ... PP_OPCODE_8BRV_MAX:
|
||||
rv[0] = pinport_opcode_8b_return( spacket->opcode, &rv[1]);
|
||||
rlen ++;
|
||||
break;
|
||||
default: //pinport opcode min/max definition error
|
||||
rv[0] = ERR_BAD_PP_OP_MINMAX;
|
||||
}
|
||||
break; //end of PINPORT
|
||||
default:
|
||||
|
|
|
|||
|
|
@ -0,0 +1,57 @@
|
|||
#include "erase.h"
|
||||
|
||||
int erase_nes( USBtransfer *transfer )
|
||||
{
|
||||
|
||||
debug("erasing");
|
||||
|
||||
int xfr_cnt;
|
||||
uint8_t rbuf[2];
|
||||
rbuf[0] = 0;
|
||||
rbuf[1] = 0;
|
||||
int i;
|
||||
|
||||
transfer->endpoint = USB_IN;
|
||||
transfer->request = PINPORT;
|
||||
transfer->data = rbuf;
|
||||
|
||||
uint8_t c[20];
|
||||
uint8_t o[20];
|
||||
|
||||
c[0] = LED_ON;
|
||||
c[1] = ADDR_OP;
|
||||
c[2] = DATA_IP;
|
||||
c[3] = M2_OP;
|
||||
c[4] = ROMSEL_OP;
|
||||
c[5] = PRGRW_OP;
|
||||
c[6] = CSRD_OP;
|
||||
c[7] = CSWR_OP;
|
||||
c[8] = AHL_OP;
|
||||
c[9] = AXLOE_OP;
|
||||
c[10] = AXL_CLK;
|
||||
c[11] = ADDR_RD;
|
||||
c[12] = ADDR_LO;
|
||||
c[13] = ADDR_RD;
|
||||
c[14] = LED_OFF;
|
||||
c[15] = LED_OFF;
|
||||
c[16] = LED_OFF;
|
||||
c[17] = LED_OFF;
|
||||
c[18] = LED_OFF;
|
||||
c[19] = LED_OFF;
|
||||
|
||||
for ( i = 0; i < 20; i++) {
|
||||
transfer->wValueLSB = c[i];
|
||||
if (c[i] >= 0xc0) transfer->wLength = 2;
|
||||
else transfer->wLength = 1;
|
||||
xfr_cnt = usb_transfer( transfer );
|
||||
debug("xf: %d OP: %d/%x er: %d rv: %x",xfr_cnt, c[i], c[i], rbuf[0], rbuf[1]);
|
||||
rbuf[0] = 0xAA;
|
||||
rbuf[1] = 0;
|
||||
|
||||
//send command
|
||||
}
|
||||
|
||||
|
||||
return 0;
|
||||
|
||||
}
|
||||
|
|
@ -0,0 +1,29 @@
|
|||
#ifndef _erase_h
|
||||
#define _erase_h
|
||||
|
||||
#include <stdio.h>
|
||||
#include <string.h>
|
||||
#include <stdlib.h>
|
||||
#include <assert.h>
|
||||
#include <errno.h>
|
||||
#include <libusb.h>
|
||||
|
||||
//include prior to other file includes
|
||||
//that way DEBUG can be turned on/off for this file alone
|
||||
//uncomment to DEBUG this file alone
|
||||
#define DEBUG
|
||||
//"make debug" to get DEBUG msgs on entire program
|
||||
#include "dbg.h"
|
||||
|
||||
#include "usb_operations.h"
|
||||
#include "shared_errors.h"
|
||||
#include "shared_dictionaries.h"
|
||||
|
||||
//uncomment to DEBUG this file alone
|
||||
#define DEBUG
|
||||
//"make debug" to get DEBUG msgs on entire program
|
||||
#include "dbg.h"
|
||||
|
||||
int erase_nes( USBtransfer *transfer );
|
||||
|
||||
#endif
|
||||
|
|
@ -14,6 +14,7 @@
|
|||
|
||||
#include "usb_operations.h"
|
||||
#include "write_operations.h"
|
||||
#include "erase.h"
|
||||
#include "shared_dictionaries.h"
|
||||
|
||||
|
||||
|
|
@ -101,15 +102,17 @@ int main(int argc, char *argv[])
|
|||
uint8_t rbuf[8];
|
||||
|
||||
int i;
|
||||
printf("before return buffer: ");
|
||||
for (i = 0; i < 8; i++) {
|
||||
rbuf[i] = 7;
|
||||
printf("%x ", rbuf[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
if (e_flag) erase_nes( transfer );
|
||||
|
||||
//handle simple LED ON/OFF within main for now
|
||||
if (o_flag | f_flag) {
|
||||
printf("before return buffer: ");
|
||||
for (i = 0; i < 8; i++) {
|
||||
rbuf[i] = 7;
|
||||
printf("%x ", rbuf[i]);
|
||||
}
|
||||
printf("\n");
|
||||
transfer->endpoint = USB_IN;
|
||||
transfer->request = PINPORT;
|
||||
if (o_flag) transfer->wValueLSB = LED_ON;
|
||||
|
|
@ -119,14 +122,15 @@ int main(int argc, char *argv[])
|
|||
|
||||
//send command
|
||||
xfr_cnt = usb_transfer( transfer );
|
||||
|
||||
printf("total bytes xfrd: %d \n", xfr_cnt);
|
||||
printf("after buffer: ");
|
||||
for (i = 0; i < 8; i++) {
|
||||
printf("%x ", rbuf[i]);
|
||||
}
|
||||
printf("\n");
|
||||
}
|
||||
|
||||
printf("total bytes xfrd: %d \n", xfr_cnt);
|
||||
printf("after buffer: ");
|
||||
for (i = 0; i < 8; i++) {
|
||||
printf("%x ", rbuf[i]);
|
||||
}
|
||||
printf("\n");
|
||||
|
||||
|
||||
//if (o_flag) { //ON send REQ_LED_ON
|
||||
|
|
|
|||
|
|
@ -12,7 +12,7 @@
|
|||
#include "shared_dictionaries.h"
|
||||
|
||||
//uncomment to DEBUG this file alone
|
||||
#define DEBUG
|
||||
//#define DEBUG
|
||||
//"make debug" to get DEBUG msgs on entire program
|
||||
#include "dbg.h"
|
||||
|
||||
|
|
|
|||
|
|
@ -5,11 +5,14 @@
|
|||
|
||||
//greater than 128 are possible avr return codes
|
||||
#define ERR_UNKN_DICTIONARY 128
|
||||
#define ERR_BAD_PP_OP_MINMAX 129
|
||||
|
||||
#define ERR_UNKN_PP_OPCODE_ONLY 129
|
||||
|
||||
#define ERR_UNKN_PP_OPCODE_ONLY 139
|
||||
#define ERR_UNKN_PP_OPCODE_8BOP 130
|
||||
#define ERR_UNKN_PP_OPCODE_16BOP 131
|
||||
#define ERR_UNKN_PP_OPCODE_24BOP 132
|
||||
#define ERR_UNKN_PP_OPCODE_8BRV 133
|
||||
|
||||
|
||||
#endif
|
||||
|
|
|
|||
Loading…
Reference in New Issue