Small library for controll the TTL74HC595, who is a SerialIn-ParallelOut

Files at this revision

API Documentation at this revision

Comitter:
trombettamichele
Date:
Fri May 06 18:58:53 2011 +0000
Parent:
0:d78bcf13e9ed
Commit message:

Changed in this revision

ttl_74HC595.cpp Show annotated file Show diff for this revision Revisions of this file
ttl_74HC595.h Show annotated file Show diff for this revision Revisions of this file
--- a/ttl_74HC595.cpp	Wed Apr 27 16:21:05 2011 +0000
+++ b/ttl_74HC595.cpp	Fri May 06 18:58:53 2011 +0000
@@ -1,32 +1,32 @@
-#include "mbed.h"
-#include "ttl_74HC595.h"
-//  Small library for controll the TTL74HC595, who is a SerialIn-ParallelOut
-//  Created by Michele Trombetta
-//  Copyright 2010 5OFT. All rights reserved.
-
-ttl_74HC595::ttl_74HC595(PinName DS, PinName SH_CLK, PinName ST_CLK, PinName OE): _DS(DS), _SH_CLK(SH_CLK), _ST_CLK(ST_CLK), _OE(OE) {
-
-}
-
-void ttl_74HC595::send_data(unsigned char data) {
-    for (char i=0; i<8; i++) {
-        _SH_CLK = 0;
-        _DS = data & 0x01;
-        data >>= 1;
-        _SH_CLK = 1;
-    }
-}
-
-void ttl_74HC595::store_data() {
-    _ST_CLK = 1;
-    _ST_CLK = 0;
-}
-
-void ttl_74HC595::send(unsigned char data) {
-    send_data(data);
-    store_data();
-}
-
-void ttl_74HC595::setOE(bool enable) {
-    _OE = enable ? 0 : 1;
+#include "mbed.h"
+#include "ttl_74HC595.h"
+//  Small library for controll the TTL74HC595, who is a SerialIn-ParallelOut
+//  Created by Michele Trombetta
+//  Copyright 2010 5OFT. All rights reserved.
+
+ttl_74HC595::ttl_74HC595(PinName DS, PinName SH_CLK, PinName ST_CLK, PinName OE): _DS(DS), _SH_CLK(SH_CLK), _ST_CLK(ST_CLK), _OE(OE) {
+
+}
+
+void ttl_74HC595::send_data(unsigned char data) {
+    for (char i=0; i<8; i++) {
+        _SH_CLK = 0;
+        _DS = data & 0x01;
+        data >>= 1;
+        _SH_CLK = 1;
+    }
+}
+
+void ttl_74HC595::store_data() {
+    _ST_CLK = 1;
+    _ST_CLK = 0;
+}
+
+void ttl_74HC595::send(unsigned char data) {
+    send_data(data);
+    store_data();
+}
+
+void ttl_74HC595::setOE(bool enable) {
+    _OE = enable ? 0 : 1;
 }
\ No newline at end of file
--- a/ttl_74HC595.h	Wed Apr 27 16:21:05 2011 +0000
+++ b/ttl_74HC595.h	Fri May 06 18:58:53 2011 +0000
@@ -1,18 +1,18 @@
-#include "mbed.h"
-//  Small library for controll the TTL74HC595, who is a SerialIn-ParallelOut
-//  Created by Michele Trombetta
-//  Copyright 2010 5OFT. All rights reserved.
-
-class ttl_74HC595 {
-public:
-    ttl_74HC595(PinName DS, PinName SH_CLK, PinName ST_CLK, PinName OE);
-    void send_data(unsigned char data); //Send 1 byte to the IC
-    void store_data();  //Store the data into the internal latch
-    void send(unsigned char data);  //Rapid routine to send and store the data
-    void setOE(bool enable);    //Clear or set the OE pin
-private:
-    DigitalOut _DS;
-    DigitalOut _ST_CLK;
-    DigitalOut _SH_CLK;
-    DigitalOut _OE;
+#include "mbed.h"
+//  Small library for controll the TTL74HC595, who is a SerialIn-ParallelOut
+//  Created by Michele Trombetta
+//  Copyright 2010 5OFT. All rights reserved.
+
+class ttl_74HC595 {
+public:
+    ttl_74HC595(PinName DS, PinName SH_CLK, PinName ST_CLK, PinName OE);
+    void send_data(unsigned char data); //Send 1 byte to the IC
+    void store_data();  //Store the data into the internal latch
+    void send(unsigned char data);  //Rapid routine to send and store the data
+    void setOE(bool enable);    //Clear or set the OE pin
+private:
+    DigitalOut _DS;
+    DigitalOut _ST_CLK;
+    DigitalOut _SH_CLK;
+    DigitalOut _OE;
 };
\ No newline at end of file