SapFlow Probe
A low-cost HRM probe for measuring a tree's water consumption
debug.h
Go to the documentation of this file.
1 #pragma once
2 
3 #include <string.h> // for strncpy
4 #include <Arduino.h>
5 #include "pinout.h"
6 
15 public:
17  void init(int period);
19  void set(int l, const char * str);
21  void print(void);
23  void write(void);
25  bool read(void);
27  void pause(void);
29  void resume(void);
30 private:
31  char buffer[100];
32  int line2;
33  int period; // timeout period in ms
34 };
35 
40 class WatchdogSAMD {
41 public:
42  WatchdogSAMD():
43  _initialized(false)
44  {}
45 
51  int enable(int PeriodMS);
53  void reset();
55  uint8_t resetCause();
57  void disable();
58 private:
59  void _initialize_wdt();
60  bool _initialized;
61 };
62 
65 
72 #define MARK() halt_location.set(__LINE__,__PRETTY_FUNCTION__)
FunctionMarker::set
void set(int l, const char *str)
Record the current line number and function name. Also feeds the watchdog.
Definition: debug.cpp:18
FunctionMarker
Used for debugging.
Definition: debug.h:14
FunctionMarker::init
void init(int period)
Initialize the watchdog at the period given.
Definition: debug.cpp:26
WatchdogSAMD::resetCause
uint8_t resetCause()
Find out the cause of the last reset - see datasheet for bitmask.
FunctionMarker::print
void print(void)
Prints the most recently recorded value.
Definition: debug.cpp:42
WatchdogSAMD::reset
void reset()
Reset or 'kick' the watchdog timer to prevent a reset of the device.
WatchdogSAMD::enable
int enable(int PeriodMS)
Enable the watchdog timer to reset the machine if it hangs.
FunctionMarker::resume
void resume(void)
Re-enable the watchdog. You should do this right after waking from sleep.
Definition: debug.cpp:37
FunctionMarker::pause
void pause(void)
Pause the watchdog. You'll want to do this before sleeping.
Definition: debug.cpp:33
WatchdogSAMD::disable
void disable()
Completely disable the watchdog timer.
halt_location
static class FunctionMarker halt_location
Singleton of our debug class.
Definition: debug.h:64
pinout.h
FunctionMarker::read
bool read(void)
Read the recorded value from flash.
Definition: debug.cpp:58
FunctionMarker::write
void write(void)
Actually write the recorded value to flash.
Definition: debug.cpp:49
WatchdogSAMD
Watchdog for SAMD21.
Definition: debug.h:40