#include <avr/io.h>
#include <util/delay.h>

#define PA1_SET_MASK 0x02 // LED 1 to 2
#define PA2_SET_MASK 0x04 // LED 3 to 6
#define PA3_SET_MASK 0x08 // LED 7 to 8
#define PA6_SET_MASK 0x40 // Green LED
#define PA7_SET_MASK 0x80 // Red LED

int main(void)
{
    VPORTA.DIR = 0x0;

    // Configure PA1 as output (Pin 4 on ATTINY202-SSN)
    VPORTA.DIR |= PA1_SET_MASK;

    // Configure PA2 as output (Pin 5 on ATTINY202-SSN)
    VPORTA.DIR |= PA2_SET_MASK;

    // Configure PA3 as output (Pin 7 on ATTINY202-SSN)
    VPORTA.DIR |= PA3_SET_MASK;

    // Configure PA6 as output (Pin 2 on ATTINY202-SSN)
    VPORTA.DIR |= PA6_SET_MASK;

    // Configure PA7 as output (Pin 3 on ATTINY202-SSN)
    VPORTA.DIR |= PA7_SET_MASK;

    VPORTA.OUT ^= !PA1_SET_MASK; // LED 1 to 2
    VPORTA.OUT ^= !PA2_SET_MASK; // LED 3 to 6
    VPORTA.OUT ^= !PA3_SET_MASK; // LED 7 to 8

    while (1)
    {
        VPORTA.OUT ^= PA6_SET_MASK; // toggle green LED
        VPORTA.OUT ^= PA7_SET_MASK; // toggle red LED

        VPORTA.OUT ^= PA2_SET_MASK; // toggle inner four LED

        _delay_ms(500);
    }
}
