diff --git a/Code/C_Code/18.2.1_StopWatch/StopWatch.c b/Code/C_Code/18.2.1_StopWatch/StopWatch.c index 765e7de..05ae9f5 100644 --- a/Code/C_Code/18.2.1_StopWatch/StopWatch.c +++ b/Code/C_Code/18.2.1_StopWatch/StopWatch.c @@ -2,7 +2,7 @@ * Filename : StopWatch.c * Description : Control 4_Digit_7_Segment_Display by 74HC595 * Author : freenove -* modification: 2016/07/07 +* modification: 2018/07/16 **********************************************************************/ #include #include @@ -23,24 +23,48 @@ void selectDigit(int digit){ digitalWrite(digitPin[2],((digit&0x02) == 0x02) ? LOW : HIGH); digitalWrite(digitPin[3],((digit&0x01) == 0x01) ? LOW : HIGH); } -void outData(int8_t data){ //function used to output data for 74HC595输出数据函数 +void _shiftOut(int dPin,int cPin,int order,int val){ + int i; + for(i = 0; i < 8; i++){ + digitalWrite(cPin,LOW); + if(order == LSBFIRST){ + digitalWrite(dPin,((0x01&(val>>i)) == 0x01) ? HIGH : LOW); + delayMicroseconds(1); + } + else {//if(order == MSBFIRST){ + digitalWrite(dPin,((0x80&(val<