From bb54174b78070536aa7a469ccd77df573682e616 Mon Sep 17 00:00:00 2001 From: Chris Rusin Date: Sun, 17 May 2026 21:26:37 +0200 Subject: [PATCH 1/2] Add Nano Every ATmega4809 support --- PSNee/MCU.h | 72 +++++++++++++++++++++++++++++++++++++++++++++++++ PSNee/PSNee.ino | 2 +- 2 files changed, 73 insertions(+), 1 deletion(-) diff --git a/PSNee/MCU.h b/PSNee/MCU.h index 96e85a4..8b94efd 100644 --- a/PSNee/MCU.h +++ b/PSNee/MCU.h @@ -449,6 +449,78 @@ #endif +#if defined(__AVR_ATmega4809__) || defined(__AVR_atmega4809__) +#define IS_4809_FAMILY + + #ifndef F_CPU + #define F_CPU 16000000UL + #endif + + #include + #include + #include + #include + #include + #include + + // --- Main Bus Interface (Arduino Nano Every / ATmega4809) --- + + // Define the main pins as inputs + #if defined(AVR_NANO_4809_328MODE) || defined(UNO_WIFI_REV2_328MODE) + #define PIN_DATA_INPUT VPORTE.DIR &= ~PIN3_bm // D8 -> PE3 + #define PIN_WFCK_INPUT VPORTB.DIR &= ~PIN0_bm // D9 -> PB0 + #define PIN_SQCK_INPUT VPORTF.DIR &= ~PIN4_bm // D6 -> PF4 + #define PIN_SUBQ_INPUT VPORTA.DIR &= ~PIN1_bm // D7 -> PA1 + + // Configure lines as outputs (for injection/override) + #define PIN_DATA_OUTPUT VPORTE.DIR |= PIN3_bm + #define PIN_WFCK_OUTPUT VPORTB.DIR |= PIN0_bm + + // Bus line state control (Set High / Clear Low) + #define PIN_DATA_SET VPORTE.OUT |= PIN3_bm + #define PIN_DATA_CLEAR VPORTE.OUT &= ~PIN3_bm + #define PIN_WFCK_CLEAR VPORTB.OUT &= ~PIN0_bm + + // Direct Register Reading (High-speed polling) + #define PIN_SQCK_READ (!!(VPORTF.IN & PIN4_bm)) + #define PIN_SUBQ_READ (!!(VPORTA.IN & PIN1_bm)) + #define PIN_WFCK_READ (!!(VPORTB.IN & PIN0_bm)) + + // --- Status Indication (LED) --- + #ifdef LED_RUN + #define PIN_LED_OUTPUT VPORTE.DIR |= PIN2_bm // D13 -> PE2 + #define PIN_LED_ON VPORTE.OUT |= PIN2_bm + #define PIN_LED_OFF VPORTE.OUT &= ~PIN2_bm + #endif + #else + #define PIN_DATA_INPUT PORTE.DIRCLR = PIN3_bm // D8 -> PE3 + #define PIN_WFCK_INPUT PORTB.DIRCLR = PIN0_bm // D9 -> PB0 + #define PIN_SQCK_INPUT PORTF.DIRCLR = PIN4_bm // D6 -> PF4 + #define PIN_SUBQ_INPUT PORTA.DIRCLR = PIN1_bm // D7 -> PA1 + + // Configure lines as outputs (for injection/override) + #define PIN_DATA_OUTPUT PORTE.DIRSET = PIN3_bm + #define PIN_WFCK_OUTPUT PORTB.DIRSET = PIN0_bm + + // Bus line state control (Set High / Clear Low) + #define PIN_DATA_SET PORTE.OUTSET = PIN3_bm + #define PIN_DATA_CLEAR PORTE.OUTCLR = PIN3_bm + #define PIN_WFCK_CLEAR PORTB.OUTCLR = PIN0_bm + + // Direct Register Reading (High-speed polling) + #define PIN_SQCK_READ (!!(PORTF.IN & PIN4_bm)) + #define PIN_SUBQ_READ (!!(PORTA.IN & PIN1_bm)) + #define PIN_WFCK_READ (!!(PORTB.IN & PIN0_bm)) + + // --- Status Indication (LED) --- + #ifdef LED_RUN + #define PIN_LED_OUTPUT PORTE.DIRSET = PIN2_bm // D13 -> PE2 + #define PIN_LED_ON PORTE.OUTSET = PIN2_bm + #define PIN_LED_OFF PORTE.OUTCLR = PIN2_bm + #endif + #endif +#endif + #if defined(__AVR_ATtiny85__) || defined(__AVR_ATtiny45__) || defined(__AVR_ATtiny25__) #define IS_ATTINY_FAMILY diff --git a/PSNee/PSNee.ino b/PSNee/PSNee.ino index 6db3deb..e1691c8 100644 --- a/PSNee/PSNee.ino +++ b/PSNee/PSNee.ino @@ -10,7 +10,7 @@ * SCPH model number // region code | region *--------------------------------------------------------------------------------------------------------------------*/ // #define SCPH_xxx1 // NTSC U/C | America. -// #define SCPH_xxx2 // PAL | Europ. +#define SCPH_xxx2 // PAL | Europ. // #define SCPH_xxx3 // NTSC J | Asia. // #define SCPH_xxxx // Universal From d80700a7ef1d501964ccc8549d15aa7f39f9daff Mon Sep 17 00:00:00 2001 From: Chris Rusin Date: Sun, 17 May 2026 21:45:00 +0200 Subject: [PATCH 2/2] Restore default console selection Keep the PR focused on Nano Every ATmega4809 board support by removing local sketch configuration from the branch. Co-authored-by: Cursor --- PSNee/PSNee.ino | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/PSNee/PSNee.ino b/PSNee/PSNee.ino index e1691c8..6db3deb 100644 --- a/PSNee/PSNee.ino +++ b/PSNee/PSNee.ino @@ -10,7 +10,7 @@ * SCPH model number // region code | region *--------------------------------------------------------------------------------------------------------------------*/ // #define SCPH_xxx1 // NTSC U/C | America. -#define SCPH_xxx2 // PAL | Europ. +// #define SCPH_xxx2 // PAL | Europ. // #define SCPH_xxx3 // NTSC J | Asia. // #define SCPH_xxxx // Universal