27.8.1.2.2 Workflow

  1. Retrieve the cause of the system reset to determine if the Watchdog module was the cause of the last reset.
    enum system_reset_cause reset_cause = system_get_reset_cause();
    
  2. Turn on or off the board LED based on whether the Watchdog reset the device.
    if (reset_cause == SYSTEM_RESET_CAUSE_WDT) {
        port_pin_set_output_level(LED_0_PIN, LED_0_INACTIVE);
    }
    else {
        port_pin_set_output_level(LED_0_PIN, LED_0_ACTIVE);
    }
    
  3. Enter an infinite loop to hold the main program logic.
    while (true) {
    
  4. Test to see if the board button is currently being pressed.
    if (port_pin_get_input_level(BUTTON_0_PIN) == false) {
    
  5. If the button is pressed, turn on the board LED and reset the Watchdog timer.
    port_pin_set_output_level(LED_0_PIN, LED_0_ACTIVE);
    
    wdt_reset_count();