From b43b3c07568583883dd5601ee50d914bc6700ad4 Mon Sep 17 00:00:00 2001 From: paul eeepc Date: Tue, 22 Nov 2016 20:27:52 -0600 Subject: [PATCH] modified: Makefile -modified to caluclate ROM/RAM usage of atmega164a new file: source/io.h new file: source/logic.h -created files modified: source/io.c modified: source/main.c -created io_pullup going to make separate io inits based on cartridge inserted -modifing for io.h modified: source/pinport.h -File mostly complete with all possible pin manipulations --- firmware/Makefile | 3 +- firmware/source/io.c | 43 ++++---- firmware/source/io.h | 9 ++ firmware/source/logic.h | 6 ++ firmware/source/main.c | 15 ++- firmware/source/pinport.h | 216 ++++++++++++++++++++++---------------- 6 files changed, 176 insertions(+), 116 deletions(-) create mode 100644 firmware/source/io.h create mode 100644 firmware/source/logic.h diff --git a/firmware/Makefile b/firmware/Makefile index fec210c..aeb086c 100644 --- a/firmware/Makefile +++ b/firmware/Makefile @@ -61,7 +61,8 @@ main.elf: shared $(OBJECTS) main.hex: main.elf rm -f main.hex main.eep.hex avr-objcopy -j .text -j .data -O ihex main.elf main.hex - avr-size main.hex + avr-size -C --mcu=${DEVICE} main.elf +# avr-size main.hex # debugging targets: diff --git a/firmware/source/io.c b/firmware/source/io.c index 665a1e9..45526d3 100644 --- a/firmware/source/io.c +++ b/firmware/source/io.c @@ -1,30 +1,35 @@ +#include "io.h" -#include -#include "pinport.h" -//Goal is to silience everything -//Clear busses and pull up when able -void io_init() +//pullup as many cart pins as possible +//goal to be safe state for all hardware +void io_pullup() { - //pull up data bus - DATA_IP(); - DATA_HI(); - //pull up addr[7:0] bus ADDR_IP(); ADDR_HI(); - //EXP0 input no pullup - //SNES /RESET pin disables SRAM on first few pcb versions - //NES PRG-ROM /OE on old INL-ROM v1 boards w/pulldown - //NED PRG-ROM /WE on INL-ROM v3 boards w/pullup - //NES CPLD JTAG TDO non-5v tolerant - EXP0_IP(); - EXP0_LO(); + //pull up data bus + DATA_IP(); + DATA_HI(); - //IRQ pullup NES boards will drive this pin - IRQ_IP(); - IRQ_HI(); + //pull up control port + CTL_IP(); + CTL_HI(); + + //pull up aux port + AUX_IP(); + AUX_HI(); + //Aux port EXP /OE control + //pull up on EXP FF should disable FF ouput + + //EXP0 input no pullup + //Lots of possibilities, ~safe bet it will have it's own pull-up/down if needed. + //SNES /RESET pin disables SRAM on first few pcb versions + //NES PRG-ROM /OE (with pulldown) on old INL-ROM v1 boards w/pulldown + //NED PRG-ROM /WE (with pullup) on INL-ROM v3 boards w/pullup + //NES CPLD JTAG TDO non-5v tolerant + EXP0_FLT(); //LED LAST displaying complete.. } diff --git a/firmware/source/io.h b/firmware/source/io.h new file mode 100644 index 0000000..8bffa3c --- /dev/null +++ b/firmware/source/io.h @@ -0,0 +1,9 @@ +#ifndef _io_h +#define _io_h + +#include +#include "pinport.h" + +void io_pullup(); + +#endif diff --git a/firmware/source/logic.h b/firmware/source/logic.h new file mode 100644 index 0000000..efc3a02 --- /dev/null +++ b/firmware/source/logic.h @@ -0,0 +1,6 @@ + +#define LO 0x00 +#define HI 0xFF + +#define TRUE 0x00 +//FALSE is ANYTHING but TRUE, the value signifies the error number diff --git a/firmware/source/main.c b/firmware/source/main.c index 490c65f..42f56e5 100644 --- a/firmware/source/main.c +++ b/firmware/source/main.c @@ -4,8 +4,8 @@ #include #include "usbdrv.h" -#include "macro.h" -#include "usb_commands.h" +#include "io.h" +#include "shared_usb_commands.h" //USB_PUBLIC usbMsgLen_t usbFunctionSetup(uchar data[8]); @@ -124,13 +124,13 @@ int main() usbDeviceConnect(); - //intialize i/o to default state - io_init(); + //intialize i/o to pullup state + io_pullup(); //configure LED PORT/DDR - //SETUP_LED(); - //Always startup with LED ON - //LED_ON(); + LED_OP(); + //boot with LED on to differentiate bettwen BL/RUN + LED_ON(); //enable interrupts sei(); @@ -150,4 +150,3 @@ int main() return 0; } - diff --git a/firmware/source/pinport.h b/firmware/source/pinport.h index 9110cee..0af787e 100644 --- a/firmware/source/pinport.h +++ b/firmware/source/pinport.h @@ -1,12 +1,21 @@ #include +#include "logic.h" //This file contains pinout translations from AVR names to "kazzo" names //this file also works to make all kazzo versions compatible and "alike" +//There are defines for kazzo version, turns out unique early versions +//can be differentiated by solder mask color. +//Final version is default and doesn't need any defines +//#define PURPLE_KAZZO +//#define GREEN_KAZZO //======================================================= //History of PCB revsisions produced by InfiniteNesLives //======================================================= // +// uncomment define if buiding for either of the first two versions +//#define PURPLE_KAZZO + // First printed circuit board version // only handful made (less than 10?) // Purple solder mask @@ -31,6 +40,9 @@ // and jumper closed.. // Believe I closed this jumper on units I shipped // prob should have left it open.. +// Suggested fix: leave open and ground EXP9 +// -prevents issue with LED when FC cart inserted +// -minor draw back no access to EXP9 // ALOG - EXP6 - DIGI jumper // another noob jumper decision... // ALOG is the MCU AREF pin which should be tied to VCC @@ -64,6 +76,9 @@ // -Same as version above as far as I know. // // +// uncomment define if buiding for this versions +//#define GREEN_KAZZO +// // Third printed circuit board version // only handful made (about ten?) used primarily as SNES prototype // Green solder mask @@ -84,8 +99,8 @@ // instead it's controlled by A20 (EXPFF Q4) // prevents putting INL SNES boards in program mode unless A20 is also low // pretty much makes flashing SNES boards a royal PITA/impossible -// would have to free /RESET and wire to EXP0/PD0 to flash INL SNES board. -// +// Suggested fix is to have PD0 (EXP0) control SNES /RESET +// would have to free /RESET and wire to EXP0/PD0 to permit flashing/reading INL SNES board. // // // Fourth printed circuit board version @@ -127,6 +142,7 @@ // Orange solder mask // Labeled "Retro programmer/dumper v1.4" "Kazzo 1.x" // Dated OCT 2016 +// Addition of fancy INL logo for first time // * Includes NES, Famicom, & SNES connector // * SNES connector improvement to correct pitch issue with prev ver. // * Addition of PCT resettable fuse on incoming power. @@ -137,10 +153,6 @@ // -None from previous version // -#define LO 0x00 -#define HI 0xFF -//#define TRUE 0x00 -//FALSE is ANYTHING but TRUE, the value signifies the error number //============================ @@ -153,8 +165,8 @@ //DDR-PORT MACROS #define ADDR_IP() ADDR_DDR = LO #define ADDR_OP() ADDR_DDR = HI -#define ADDR_HI() ADDR_OUT = HI #define ADDR_LO() ADDR_OUT = LO +#define ADDR_HI() ADDR_OUT = HI //============================ @@ -167,8 +179,8 @@ //DDR-PORT MACROS #define DATA_IP() DATA_DDR = LO #define DATA_OP() DATA_DDR = HI -#define DATA_HI() DATA_OUT = HI #define DATA_LO() DATA_OUT = LO +#define DATA_HI() DATA_OUT = HI //============================ @@ -181,61 +193,94 @@ //DDR-PORT MACROS #define CTL_IP() CTL_DDR = LO // No CTL_OP() macro as some of these are inputs or bidir, best to individually assert as output -#define CTL_HI() CTL_OUT = HI #define CTL_LO() CTL_OUT = LO -//OLD CODE //AHL, AXL, are always output and high, unless individually asserted. -// #define CTL_IP() CTL_DDR = 0b10001000// &= ((1<GND, RUN->float -#define p_XOE PD7 //EXP/ADDRHI FF /OE pin on purple and green boards +#ifdef PURPLE_KAZZO +#define pg_XOE PD7 //EXP/ADDRHI FF /OE pin on purple and green boards +#endif +#ifdef GREEN_KAZZO +#define pg_XOE PD7 //EXP/ADDRHI FF /OE pin on purple and green boards +#endif +#ifndef pg_XOE //FINAL_DESIGN #define AXLOE PD7 //EXP/ADDRHI FF CLK & /OE pin on final board versions +#endif //PIN MACROS -// //EXP0 to only be pulled high because XO boards don't level shift EXP0 -// //EXP0_LO(); replace with EXP0_LO(); EXP0_OP(); -// //EXP0_HI(); replace with EXP0_IP(); EXP0_HI(); -// #define EXP0_IP() AUX_DDR &= ~(1< high -//#define LATCH_AXL() CTL_OUT &= ~(1< high - - - -// #define PRG_RD_PCE_HI() CTL_OUT |= (1<enable o/p +#define EXPFF_FLT() AUX_OUT |= (1<disable o/p +//Caution AXL_CLK() relies on EXPFF_OP() to be called beforehand +// Think of it like you must enable the output before you can clock it. +// Floating EXPFF also happens to clock it. Think of it like it looses it's value if disabled. +#define AXL_CLK() EXPFF_FLT(); EXPFF_OP(); //same name and convention as purple +#else //purple and green versions +#define XOE_IP() AUX_DDR &= ~(1<enable o/p +#define EXPFF_FLT() AUX_OUT |= (1<disable o/p +#endif