Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Diff: shitreg.cpp
- Revision:
- 0:b9fbca7b029d
diff -r 000000000000 -r b9fbca7b029d shitreg.cpp
--- /dev/null Thu Jan 01 00:00:00 1970 +0000
+++ b/shitreg.cpp Sat Dec 03 07:17:34 2016 +0000
@@ -0,0 +1,69 @@
+#include "mbed.h"
+//#include <bitset>
+#include "arduino.h"
+
+//using namespace mbed::mbed;
+
+//DigitalOut lat(P8_11);
+//DigitalOut dat(P8_13);
+//DigitalOut clk(P4_4);
+Serial pc(USBTX, USBRX); // tx, rx
+DigitalOut pins[1][3] = {{P8_11,P8_13,P4_4}};
+DigitalIn ser(P2_14);
+DigitalOut clk_inh(P4_5);
+DigitalOut clk_2(P4_7);
+DigitalOut SH_LD(P4_6);
+
+int delay_time;
+int i;
+uint8_t init;
+uint8_t data_read;
+void shift(uint8_t data, int delay_time,int row_no){
+ DigitalOut lat = pins[row_no][0];
+ DigitalOut dat = pins[row_no][1];
+ DigitalOut clk = pins[row_no][2];
+ clk = 0;
+ dat = 0;
+ lat = 0;
+ SH_LD = 1;
+ clk_inh = 1;
+ clk_2 = 1;
+ data_read = 0x00;
+ init = 0x80;
+
+ for(i=0;i<8;i++){
+ dat = data & (init>>i);
+ clk = 1;
+ clk = 0;
+ }
+ lat = 1;
+ lat = 0;
+
+}
+
+uint8_t shift_par(int clk_time, int load_time){
+ SH_LD = 0;
+ wait_us(load_time);
+ SH_LD = 1;
+ wait_us(load_time);
+ data_read = (data_read<<1)|ser;
+ clk_inh = 0;
+
+ for(i=0;i<8;i++)
+ {
+ data_read = (data_read<<1)|ser;
+ clk_2 = 0;
+ clk_2 = 1;
+
+ }
+
+ return data_read;
+
+ }
+
+int main() {
+
+ shift(0x4F, 0, 0);
+ wait_ms(500);
+ pc.printf("%c", shift_par(0,0));
+}
\ No newline at end of file