瀏覽代碼

Experimental shiftOutWithDelay

pull/1/head
Philip Howard 12 年之前
父節點
當前提交
d677719d0e
共有 2 個檔案被更改,包括 34 行新增0 行删除
  1. +33
    -0
      wiringPi/wiringShift.c
  2. +1
    -0
      wiringPi/wiringShift.h

+ 33
- 0
wiringPi/wiringShift.c 查看文件

@@ -82,3 +82,36 @@ void shiftOut (uint8_t dPin, uint8_t cPin, uint8_t order, uint8_t val)
digitalWrite (cPin, LOW) ;
}
}


/*
* shiftOut:
* Shift data out to a clocked source
*********************************************************************************
*/

void shiftOutWithDelay (uint8_t dPin, uint8_t cPin, uint8_t order, uint8_t val, uint8_t delay)
{
int8_t i;

if (order == MSBFIRST)
for (i = 7 ; i >= 0 ; --i)
{
digitalWrite (dPin, val & (1 << i)) ;
delayMicroseconds (delay) ;
digitalWrite (cPin, HIGH) ;
delayMicroseconds (delay) ;
digitalWrite (cPin, LOW) ;
delayMicroseconds (delay) ;
}
else
for (i = 0 ; i < 8 ; ++i)
{
digitalWrite (dPin, val & (1 << i)) ;
delayMicroseconds (delay) ;
digitalWrite (cPin, HIGH) ;
delayMicroseconds (delay) ;
digitalWrite (cPin, LOW) ;
delayMicroseconds (delay) ;
}
}

+ 1
- 0
wiringPi/wiringShift.h 查看文件

@@ -35,6 +35,7 @@ extern "C" {

extern uint8_t shiftIn (uint8_t dPin, uint8_t cPin, uint8_t order) ;
extern void shiftOut (uint8_t dPin, uint8_t cPin, uint8_t order, uint8_t val) ;
extern void shiftOutWithDelay (uint8_t dPin, uint8_t cPin, uint8_t order, uint8_t val, uint8_t delay) ;

#ifdef __cplusplus
}


Loading…
取消
儲存