fork of what I have been writing

Dependencies:   Crypto

Files at this revision

API Documentation at this revision

Comitter:
kubitz
Date:
Fri Feb 28 17:40:23 2020 +0000
Parent:
0:19fd8c1944fb
Child:
2:60ec222456b6
Commit message:
added crypto thread

Changed in this revision

ES_CW2_Starter_STARFISH/main.cpp Show annotated file Show diff for this revision Revisions of this file
--- a/ES_CW2_Starter_STARFISH/main.cpp	Fri Feb 28 17:36:48 2020 +0000
+++ b/ES_CW2_Starter_STARFISH/main.cpp	Fri Feb 28 17:40:23 2020 +0000
@@ -2,8 +2,12 @@
 #include "SHA256.h"
 
 Timer timer_nonce;
-Mail<string, 16> mail_box;
 
+typedef struct {
+  uint32_t counter; /* A counter value               */
+} mail_t;
+
+Mail<mail_t, 16> mail_box;
 
 uint8_t sequence[] = {0x45,0x6D,0x62,0x65,0x64,0x64,0x65,0x64,
 0x20,0x53,0x79,0x73,0x74,0x65,0x6D,0x73,
@@ -13,6 +17,7 @@
 0x74,0x68,0x69,0x6E,0x67,0x73,0x21,0x20,
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00,
 0x00,0x00,0x00,0x00,0x00,0x00,0x00,0x00};
+
 uint64_t* key = (uint64_t*)&sequence[48];
 uint64_t* nonce = (uint64_t*)&sequence[56];
 uint32_t successful_nonce = 0;
@@ -20,6 +25,8 @@
 
 uint8_t hash[32];
 uint32_t previous_time;
+
+
 //Photointerrupter input pins
 #define I1pin D3
 #define I2pin D6
@@ -138,11 +145,15 @@
     intStateOld = intState;
 }
 
-void print_mails(){
-    
-    
-    
-    }
+void print_crypto_thread() {
+    while (true) {
+        osEvent evt = mail_box.get();
+        if (evt.status == osEventMail) {
+            mail_t *mail = (mail_t*)evt.value.p;
+            printf("Number of cycles: %u\n\r", mail->counter);
+            mail_box.free(mail);
+        }
+}
     
 //Main
 int main() {