SHIFTIN
 
Syntax

void SHIFTIN  (int in_pin, int clk_pin, int mode, int cnt, int *wordList ,  int bitLengths) ;
Description


SHIFTIN has been kept as a compatable function with PBASIC.  It can be used for devices that are not covered by SPI, I2C or 1-Wire. Data is shifted in on in_pin, and a positive clock is sent on clk_pin for each bit.

While most other hardware functions use bytes, SHIFTIN is oriented for bit control.  The length of each variable defines the number of bits that will be shifted out (2 - 32).  For each word bitLengths bits will be shifted in.

SHIFTIN fills the integer array wordList cnt integers will be shifted in.

Data is shifted in at 600 Kbits/sec.


Example


    printf("FPU SHIFT test\n");     for (i= 0; i<10; i++) wordMessage[i]= 0xFF;
    wordMessage [i] = 0;
    SHIFTOUT (14,15,MSBFIRST,11,wordMessage, 8); // reset FPU
    WAIT (10);    wordMessage [0] = 0xF0;       // sync character
    SHIFTOUT (14,15,MSBFIRST,1,wordMessage, 8);  // sync FPU
    save_time = TIMER;
    while ((TIMER - save_time) < 15) ;    // wait 15 uSec
    
    SHIFTIN (14,15, MSBPRE,  1,wordMessage, 8);  // get 1 byte status back
    if (wordMessage[0] != 0x5C) {
      printf(%x "FPU found\nwordMessage[0]);
      break;
    }

See also