Sold slow control/

Dependents:   sscm

Fork of S_SCTRL_SMlib by wimbeaumont Project

Revision:
8:fe1477cd1c14
Parent:
7:cb139102ec05
Child:
9:20f21cb7792e
--- a/S_SCTRL_SM1_hwfunct.cpp	Mon Sep 15 15:22:28 2014 +0000
+++ b/S_SCTRL_SM1_hwfunct.cpp	Tue Sep 16 19:36:21 2014 +0000
@@ -1,10 +1,17 @@
-/* hardware functions */
+/* hardware functions 
+ * ver 1.0  
+ * ver 1.1x   connectors signal working   
+ * ver 1.20   added serialnr read
+ 
+ 
+ */
+
 #include "mbed.h"
 #include "S_SCTRL_SM1_PinDef.h"
 #include "S_SCTRL_SM1_hwfunct.h"
 
 
-#define HW_LIB_SRC_VERSION "1.01"
+#define HW_LIB_SRC_VERSION "1.21"
 
 #define MAXLIBVERCHAR 100  // max char for lib version 
 
@@ -71,6 +78,11 @@
 hwlines->ain[0] = new AnalogIn(ADC1);
 hwlines->ain[1] = new AnalogIn(ADC2);
 
+hwlines->snr[0] = new DigitalIn(AD0);
+hwlines->snr[1] = new DigitalIn(AD1);
+hwlines->snr[2] = new DigitalIn(AD2);
+hwlines->snr[3] = new DigitalIn(AD3);
+hwlines->snr[4] = new DigitalIn(AD4);
 
 }
 
@@ -78,9 +90,9 @@
 
 // select intern or extern cal   0 = intern, 1 is extern 
 void setcalsource( int external, HWlines hwl) {
-    *(hwl.calext)=0;    *(hwl.calint[0])=0; *(hwl.calint[0])=0;  //disable all 
+    *(hwl.calext)=0;    *(hwl.calint[0])=0; *(hwl.calint[1])=0;  //disable all 
     if ( external==1 ) {*(hwl.calext)=1; }
-    else {*(hwl.calint[0])=1; *(hwl.calint[0])=1;  }
+    else {*(hwl.calint[0])=1; *(hwl.calint[1])=1;  }
 
     
 }
@@ -89,8 +101,8 @@
 void setdefault(HWlines hwl ) {
         for ( int i=0;i<2;i++){
             hwl.msio[i]->input();
-            *(hwl.direction[i])=LDIR_IN;
-            *(hwl.stio_mo[i])=RDIR_IN;
+            *(hwl.direction[i])=RDIR_IN;
+            *(hwl.stio_mo[i])=LDIR_IN;
         }
         setcalsource(0,hwl); //intern
 }
@@ -118,9 +130,17 @@
 
 
 char*   hwfunct_lib_version(){
-    sprintf(libversion,"hw lib versions  src : %s header:  %s ,date:%s %s \n\r",HW_LIB_SRC_VERSION,HW_LIB_HDR_VERSION ,  __DATE__,__TIME__);
+    sprintf(libversion,"hw lib versions  src : %s header:  %s pindef %s,date:%s %s \n\r",
+            HW_LIB_SRC_VERSION,HW_LIB_HDR_VERSION , PINDEF_VER, __DATE__,__TIME__);
     return libversion;
     
 }
 
-
+int get_serialnr(HWlines  *hwlines ){
+    int snr=0;
+    for( int bitnr=4 ; bitnr  >= 0  ;bitnr--){
+        snr=snr<<1;
+        snr|=hwlines->snr[bitnr]->read();
+    }
+    return snr;
+}