12.8.1.2.1 Code

Copy-paste the following code to your user application:
system_init();

config_port_pins();

system_peripheral_lock(SYSTEM_PERIPHERAL_ID(PORT),
        ~SYSTEM_PERIPHERAL_ID(PORT));

#if(SAML21)|| (SAML22) || (SAMC21) || defined(__DOXYGEN__)
    system_pac_enable_interrupt();
#endif
    system_interrupt_enable_global();

while (port_pin_get_input_level(BUTTON_0_PIN)) {
    /* Wait for button press */
}

system_interrupt_enter_critical_section();

system_peripheral_unlock(SYSTEM_PERIPHERAL_ID(PORT),
        ~SYSTEM_PERIPHERAL_ID(PORT));

port_pin_toggle_output_level(LED_0_PIN);

system_peripheral_lock(SYSTEM_PERIPHERAL_ID(PORT),
        ~SYSTEM_PERIPHERAL_ID(PORT));

system_interrupt_leave_critical_section();

while (1) {
    /* Do nothing */
}