initial commit, reads dev id

Files at this revision

API Documentation at this revision

Comitter:
phonemacro
Date:
Sat Aug 11 10:25:54 2018 +0000
Parent:
1:7ae9b934ee55
Child:
3:ad8f1059a0c5
Commit message:
Add challenge 1

Changed in this revision

MAX8614X.cpp Show annotated file Show diff for this revision Revisions of this file
MAX8614X.h Show annotated file Show diff for this revision Revisions of this file
--- a/MAX8614X.cpp	Sat Aug 11 00:37:58 2018 +0000
+++ b/MAX8614X.cpp	Sat Aug 11 10:25:54 2018 +0000
@@ -101,10 +101,18 @@
     printf("Status reg: %X %X \n\r", status.val[0], status.val[1]);
 
     if (status.sha_done) {
+        shaComplete = true;
         printf("sha interrupt\n\r");
     }
 }
-
+bool MAX8614X::isShaComplete(void)
+{
+    return shaComplete;
+}
+void MAX8614X::clearShaComplete(void)
+{
+    shaComplete = false;
+}
 MAX8614X::~MAX8614X(void) 
 {
   //empty block
--- a/MAX8614X.h	Sat Aug 11 00:37:58 2018 +0000
+++ b/MAX8614X.h	Sat Aug 11 10:25:54 2018 +0000
@@ -184,6 +184,15 @@
     static const uint8_t MAX8614X_INT1_EN_DIE_TEMP_MASK = (0x1 << 2);
     static const uint8_t MAX8614X_INT1_EN_VDD_OOR_MASK  = (0x1 << 1);
 
+    /*SHA256 Control*/
+    static const uint8_t MAX8614X_IE_SHA_DONE_EN          = (0x01 << 0);
+    static const uint8_t MAX8614X_SHACMD_SHA_START        = (0x01 << 0);
+    static const uint8_t MAX8614X_SHACMD_SHA_EN           = (0x01 << 1);
+    static const uint8_t MAX8614X_MEMCNTRL_BANK0_MASK     = (0);
+    static const uint8_t MAX8614X_MEMCNTRL_BANK1_MASK     = (1);
+    static const uint8_t MAX8614X_MEMCNTRL_WR_DIS_MASK    = (0x01 << 0);
+    static const uint8_t MAX8614X_MEMCNTRL_WR_EN_MASK     = (0x01 << 1);
+    
     /* PUBLIC TYPE DEFINITIONS */
     typedef struct RegisterMap {
         uint8_t addr;
@@ -222,6 +231,8 @@
 
     int writeBlock(const RegisterMap reg_block[], unsigned int size);
     void irq_handler(void);
+    bool isShaComplete(void);
+    void clearShaComplete(void);
         /* PUBLIC VARIABLES */
     InterruptIn m_ir;
         
@@ -230,6 +241,7 @@
     /* PRIVATE VARIABLES */
     SPI &m_spiBus;
     DigitalOut &m_cs;
+    bool shaComplete;
 
     /* PRIVATE FUNCTION DECLARATIONS */
 };