github.com/tinygo-org/tinygo@v0.31.3-0.20240404173401-90b0bf646c27/src/machine/watchdog.go (about)

     1  //go:build nrf52840 || nrf52833 || rp2040 || atsamd51 || atsame5x || stm32
     2  
     3  package machine
     4  
     5  // WatchdogConfig holds configuration for the watchdog timer.
     6  type WatchdogConfig struct {
     7  	// The timeout (in milliseconds) before the watchdog fires.
     8  	//
     9  	// If the requested timeout exceeds `MaxTimeout` it will be rounded
    10  	// down.
    11  	TimeoutMillis uint32
    12  }
    13  
    14  // watchdog must be implemented by any platform supporting watchdog functionality
    15  type watchdog interface {
    16  	// Configure the watchdog.
    17  	//
    18  	// This method should not be called after the watchdog is started and on
    19  	// some platforms attempting to reconfigure after starting the watchdog
    20  	// is explicitly forbidden / will not work.
    21  	Configure(config WatchdogConfig) error
    22  
    23  	// Starts the watchdog.
    24  	Start() error
    25  
    26  	// Update the watchdog, indicating that the app is healthy.
    27  	Update()
    28  }
    29  
    30  // Ensure required public symbols var exists and meets interface spec
    31  var _ = watchdog(Watchdog)
    32  
    33  // Ensure required public constants exist
    34  const _ = WatchdogMaxTimeout