Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed
Diff: src/main.cpp
- Revision:
- 44:741ee27c8a34
- Parent:
- 43:291bbdba48f3
- Child:
- 45:bd8da8d90dbb
--- a/src/main.cpp Sat Mar 09 21:16:38 2019 +0000
+++ b/src/main.cpp Sat Mar 09 22:32:40 2019 +0000
@@ -53,12 +53,15 @@
bool running = FALSE;
bool testing = FALSE;
bool buck = TRUE;
-bool pcConnected = FALSE;
+bool pcConnected = FALSE; //New for 1U5
+bool master = FALSE; //New for 1U5
+
unsigned int max_rows = 2048;
unsigned int bCodeRow[13];
-unsigned int max_boards = 3;
+unsigned short max_boards = 3;
unsigned short row = 0;
-int row_test = 0;
+short row_test = 0;
+unsigned short slave_code = 0;
double CURRENT_48_OFFSET = 33940;
double CURRENT_24_OFFSET = 33580;
@@ -75,7 +78,15 @@
dofFlip = TRUE;
}
-int main() {
+
+
+int main() {
+
+ if(MS){ //New for 1U5
+ master = TRUE;
+ }else{
+ master = FALSE;
+ }
initOut();
@@ -86,6 +97,8 @@
initSerial();
+ initI2C();
+
initDRT(); // Display Refresh Timer
initADC();
@@ -130,20 +143,25 @@
buck = FALSE;
}
row_test = abs((int)(row-old_row));
- if(running){
+ if(running && master){ //New for 1U5
//The current sensors results are single-ended. Results below the midpoint are for buck mode, above is for boost mode.
- if(row_test>ROW_HYSTERESIS){
- old_row = row;
- if(row<=1023){
- updateControls(row);
- }
+ if(row_test>ROW_HYSTERESIS){
+ old_row = row;
+ if(row<=1023){
+ slave_code = updateMasterControls(row); //New for 1U5
+ sendSlaveCommands(slave_code); //New for 1U5
+ }
}
+ else if(running && !master){ //New for 1U5
+ slave_code = getMasterCommands(); //New for 1U5
+ updateSlaveControls(slave_code); //New for 1U5
+ }
}else if(!testing){
row_test = abs((int)(my12-old_row));
if(row_test>ROW_HYSTERESIS){
old_row = my12;
if(row<=1023){
- updateControls(my12);
+ updateMasterControls(my12);
}
}
}