-
Notifications
You must be signed in to change notification settings - Fork 1
Expand file tree
/
Copy pathseaking2.ino
More file actions
103 lines (70 loc) · 2.43 KB
/
seaking2.ino
File metadata and controls
103 lines (70 loc) · 2.43 KB
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
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
#include "cubesat.h"
#include <map>
#include <list>
#include <bitset>
#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7)
#include "mbed.h"
#else
#define Wire2 Wire
#include <axp20x.h>
#include <boards.h>
#endif
//////////////////////// DONT WRITE TO SERIAL PORT BEFORE ITS DECLARED ----- NO WRITING TO CONSOLE IN CONSTRUCTORS OF SYSTEMS THAT ARE BELOW ----------------------////////////////////////////////////////////////
////////////////////////REACTIONWHEEL #include <mbed.h> IS CAUSE OF SPI ISSUES ---- Never include that! ////////////////////////////////
#define WATCHDOGWAIT 32760 //This is the Max the Portenta can do
#define IAM "ADR1"
#define SAT IAM
CSatellite sat;
void setup() { }
void mysetup() {
sat.name(IAM);
sat.setIAM(sat.name());
Serial.begin(1000000);
long tt=getTime();
while (!Serial){
if(getTime()>tt+10000)
break;
}
Wire.begin(); //NEED to turn I2C ON Otherwise CRASH
Wire1.begin();
Wire2.begin();
#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7)
//Super IMPORTANT Initialize SPIs so not floating!!!!
//////////// WARNING DOESNT WORK WITH PIN ALIASES NO IDEA WHY
digitalWrite(PC_13,HIGH);
digitalWrite(PI_4,HIGH);
digitalWrite(PJ_8,HIGH);
//mbed_reset_reboot_count();
//mbed::Watchdog::get_instance().start(WATCHDOGWAIT);
#else
initBoard();
// esp_task_wdt_init(WDT_TIMEOUT, true); // panic so ESP32 restarts
// esp_task_wdt_add(NULL); //add current thread to WDT watch
//Serial.println(ESP.getFreeHeap());
Wire.begin(21,22);
#endif
while (!Serial&&(getTime()<10000)) ;
writeconsoleln("Starting...");
delay(1000);
Wire.setClock(400000);
Wire1.setClock(400000);
Wire2.setClock(400000);
delay(1000);
sat.setup();
}
//Check to make sure time isnt getting too big and overflows (~50days), reset
void loop() {
CMsg msg;
delay(1000);
mysetup();
msg.set(_COMMENT,"This is Major Tom to Ground Control");
msg.setTIMESTAMP();
sat.addTransmitList(msg);
while(1){
sat.loop();
// count++;
#if defined(ARDUINO_PORTENTA_H7_M4) || defined(ARDUINO_PORTENTA_H7_M7)
// if(count%WATCHDOG_LOOP_COUNT==0) mbed::Watchdog::get_instance().kick();
#endif
}
}