Interrupts on ATMEGA4809 boards (Arduino Uno Wifi Rev2, Arduino Nano Every)

I'm using the Arduino Uno Wifi Rev2 for a project and I'm trying to get the value from an analog input during an interrupt.

I've followed the datasheet here http://ww1.microchip.com/downloads/en/DeviceDoc/ATmega4808-4809-Data-Sheet-DS40002173A.pdf, particularly pages 395 to 422.

I think I'm on the right track but I'm not sure how to know what ADC and channel is connected to what pins on the Arduino. I also do not know how to format the interrupt function...

currently I get an error:
Arduino: 1.8.10 (Linux), Board: "Arduino Uno WiFi Rev2, ATMEGA328"

In file included from /home/ryacu/.arduino15/packages/arduino/hardware/megaavr/1.8.5/cores/arduino/Arduino.h:27:0,
from sketch/ADC.ino.cpp:1:
ADC:39:5: error: expected ')' before '' token
ISR(ADC0.INTFLAGS_vect) {
^
ADC:39:5: error: expected ')' before '
' token
ADC:39:5: error: expected ')' before '' token
ISR(ADC0.INTFLAGS_vect) {
^
ADC:39:5: error: expected ')' before '
' token
exit status 1
expected ')' before '*' token

This report would have more information with
"Show verbose output during compilation"
option enabled in File -> Preferences.

My sketch is below:

unsigned int val;

void setup() {
  // ADC Setup
  ADC0.CTRLA    &= B01111111; // Run in Standby: Off
  ADC0.CTRLA    &= B11111011; // Resolution Selection: Full 10-bit resolution
  ADC0.CTRLA    |= B00000010; // Free-Running: On
  ADC0.CTRLA    |= B00000001; // ADC Enable: On
  
  ADC0.CTRLB    &= B11111000; // Sample Accumulation Number Select: 0
  
  ADC0.CTRLC    |= B01000000; // Sample Capacitance Selection: Reduced size of sampling capacitance
  ADC0.CTRLC    &= B11011111;
  ADC0.CTRLC    |= B00010000; // Reference Selection: VDD
  ADC0.CTRLC    |= B00000111; // Prescaler: DIV256
  
  ADC0.CTRLD    &= B00011111; // Initialization Delay: DLY0
  ADC0.CTRLD    &= B11101111; // Automatic Sampling Delay Variation: ASVOFF
  
  ADC0.MUXPOS   &= B11100000; // ADC input pin 0
  
  ADC0.COMMAND  |= B00000001; // Start Conversion: On
  
  ADC0.EVCTRL   &= B11111110; // Start Event Input: Off
  
  ADC0.INTCTRL  &= B11111101; // Window Comparator Interrupt Enable: Off
  ADC0.INTCTRL  |= B00000001; // Result Ready Interrupt Enable: On
  
  // Serial Setup
  Serial.begin(9600);
}

void loop() {
  // Print Most Recent Reading Every Second
  delay(1000);
  Serial.println(val);
}

ISR(ADC0.INTFLAGS_vect) {
  // Interrupt Setup
  ADC0.INTFLAGS |= B00000001; // Clear Flag
  val = ADC0.RES & 0x03FF;
}

I'd appreciate any help with knowing what ADC is connected to the pins as well as how to format the interrupt function correctly.

Thanks

Okay... by looking at this file: ArduinoCore-megaavr/pins_arduino.h at master · arduino/ArduinoCore-megaavr · GitHub I am able to see that pins A0, A1, A2, A3, A4, and A5 in Arduino correspond to pins PD0, PD1, PD2, PD3, PD4, and PD5.

Then by looking at the datasheet again http://ww1.microchip.com/downloads/en/DeviceDoc/ATmega4808-4809-Data-Sheet-DS40002173A.pdf on page 18 I am able to see that pins PD0, PD1, PD2, PD3, PD4, and PD5 correspond to channels 0, 1, 2, 3, 4, and 5 of ADC0

That's taken care of, and frankly what I expected.

Still not sure on the formatting of the interrupt function

 ISR(ADC0.INTFLAGS_vect)

Still not sure on the formatting of the interrupt function

You have to match the name of the vectored function in the avr/xxxx.h file. In the case of the 4809 and the ADC, you'd have (up to) two:

ISR(ADC0_RESRDY_vect) { /* my code / }
ISR(ADC0_WCOMP_vect) { /
my code */ }

ISR(ADC0_RESRDY_vect) is exactly what I needed. Thank you