vvv

Dependents:   Enrico_newproject_copy

Files at this revision

API Documentation at this revision

Comitter:
billycorgan123
Date:
Wed Mar 07 21:11:16 2018 +0000
Commit message:
nuova update 7 marzo 2018;

Changed in this revision

CD74HC165E.cpp Show annotated file Show diff for this revision Revisions of this file
CD74HC165E.h Show annotated file Show diff for this revision Revisions of this file
diff -r 000000000000 -r 5ec20ee3f455 CD74HC165E.cpp
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CD74HC165E.cpp	Wed Mar 07 21:11:16 2018 +0000
@@ -0,0 +1,42 @@
+#include "CD74HC165E.h"
+
+#define HIGH 1
+#define LOW  0
+
+int WaitingTime=1;
+//CD74HC165E
+//PL pin 1
+//CP pin 2
+//CE pin 15
+//Q7 pin 9
+
+
+
+CD74HC165E::CD74HC165E (PinName PL, PinName CP, PinName Q7) : _PL(PL), _CP(CP), _Q7(Q7)
+{
+_PL = LOW;
+_CP = LOW;
+//_Q7 no perchè è una uscita e non ingresso
+}
+
+bool* CD74HC165E::Read()    {
+//achieving data D0-D7
+_CP = LOW;
+wait_us(WaitingTime); 
+_PL = LOW; 
+wait_us(WaitingTime*5);   // 5 microseconds to be sure to achieve all data D0-D7
+_PL = HIGH; 
+
+//store data in array
+static bool myDataIn[8] = {1,0,1,0,1,0,1,0}; 
+wait_us(WaitingTime);  
+for (int i=7; i>=0; i--) {
+    _CP = LOW;
+    wait_us(WaitingTime);
+    myDataIn[i] = _Q7;      
+    _CP = HIGH;
+    wait_us(WaitingTime);      
+    }
+    
+return myDataIn;
+}
\ No newline at end of file
diff -r 000000000000 -r 5ec20ee3f455 CD74HC165E.h
--- /dev/null	Thu Jan 01 00:00:00 1970 +0000
+++ b/CD74HC165E.h	Wed Mar 07 21:11:16 2018 +0000
@@ -0,0 +1,21 @@
+#ifndef CD74HC165E_H
+#define CD74HC165E_H
+#include "mbed.h"
+
+class CD74HC165E
+{
+ 
+public: 
+        CD74HC165E (PinName PL, PinName CP, PinName Q7);
+        //PL pin 1  of CD74HC165E   loading
+        //CP pin 2  of CD74HC165E   clock 
+        //CE pin 15 of CD74HC165E   clock enable, active low, connected to GND
+        //Q7 pin 9  of CD74HC165E   serial out
+        bool* Read();
+
+private:      
+        DigitalOut _PL, _CP;
+        DigitalIn _Q7;
+};
+
+#endif
\ No newline at end of file