SPImode
 
Syntax


extern char SPImode;

Description


 

SPImode will change the bit order and clock sense for all suceeding SPI commands or until SPImode is changed again.

Example

   case 42:   // check MicroMega FPU status
                   // clock on pin 15 and bi-directional data on 14, no CS used
    SPImode = 0; // FPU uses MSB first -- positive clock
    for (i=0; i<10; i++) shortMessage[i]= 0xFF;
    shortMessage [i] = 0;
    SPIOUT (-1,14,15,11,shortMessage);  // reset FPU
    WAIT (10);     
        
    shortMessage [0] = 0xF0;    // sync character
    SPIOUT (-1,14,15,1,shortMessage);  // sync FPU
    save_time = TIMER;
    while ((TIMER - save_time) < 15) ;     // wait 15 uSec
    SPIIN (-1,14,15, -1,-1,-1,-1, 1,shortResponse);  // get 1 byte status back
     
    if (shortResponse[0] != 0x5C) {
       printf("%x No FPU found\n",shortResponse[0]);      break;
    }
    printf("FPU found\n");

See also