forked from rszimm/sprinklers_pi
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathsysreset.cpp
More file actions
48 lines (39 loc) · 719 Bytes
/
sysreset.cpp
File metadata and controls
48 lines (39 loc) · 719 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
// sysreset.cpp
// System Reset wrapper
// Author: Richard Zimmerman
// Copyright (c) 2013 Richard Zimmerman
//
#include "sysreset.h"
#ifndef ARDUINO
/////////////////////////////
// Linux Code
//
#include <sys/reboot.h>
#include <stdlib.h>
void sysreset()
{
reboot(RB_AUTOBOOT);
exit(0);
}
#else
/////////////////////////////
// Arduino AVR Code
//
#include <avr/io.h>
#include <avr/wdt.h>
// Function Pototype
void wdt_init(void) __attribute__((naked)) __attribute__((section(".init3")));
// Function Implementation
void wdt_init(void)
{
MCUSR = 0;
wdt_disable();
return;
}
void sysreset()
{
//wdt_enable(WDTO_120MS);
//while(1) {};
asm volatile (" jmp 0");
}
#endif