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.
ShiftReg.cpp
00001 #include "mbed.h" 00002 #include "ShiftReg.h" 00003 00004 #define MY_DEBUG 0 00005 00006 ShiftReg::ShiftReg 00007 (PinName data 00008 ,PinName store 00009 ,PinName clock 00010 ): _ds(data), _st(store), _sh(clock) 00011 { 00012 } 00013 00014 00015 void ShiftReg::ShiftByte 00016 (int8_t data 00017 ,BitOrd ord 00018 ) 00019 { 00020 uint8_t mask; 00021 00022 if (ord == MSBFirst) mask = 0x80; 00023 else mask = 0x01; 00024 00025 for (int i = 0; i < 8; i++) 00026 { 00027 if (data & mask) _ds = 1; 00028 else _ds = 0; 00029 00030 #if MY_DEBUG > 0 00031 printf("%d ", _ds.read()); 00032 #endif /* MY_DEBUG */ 00033 00034 if (ord == MSBFirst) mask = mask >> 1; 00035 else mask = mask << 1; 00036 00037 _sh = 0; 00038 _sh = 1; 00039 } 00040 00041 #if MY_DEBUG > 0 00042 printf("\n"); 00043 #endif /* MY_DEBUG */ 00044 00045 } 00046 00047 void 00048 ShiftReg::ShiftBit 00049 (int8_t data 00050 ) 00051 { 00052 _ds = data; 00053 _sh = 0; 00054 _sh = 1; 00055 } 00056 00057 void 00058 ShiftReg::Latch 00059 ( 00060 ) 00061 { 00062 _st = 1; 00063 _st = 0; 00064 }
Generated on Tue Jul 12 2022 21:38:09 by
1.7.2