• Just copying the code together I'd say it should look like this:

    //replace D0
    const CS_PIN = D0;
    const CLK_PIN = D0;
    const MOSI_PIN = D0;
    var isActive = false;
    var d=1;
    var toPrint = "Got: ";
    
    //CS_PIN
    setWatch(function() {
      isActive = true;
      d=1; //cleanup at start
    },CS_PIN,{edge:"rising", repeat: true});
    
    setWatch(function() {
      isActive = false;
      console.log(toPrint);
      toPrint = "Got: ";
      if (d!==1) {
        console.log("Bit error");
      }
    },CS_PIN,{edge:"falling", repeat: true});
    
    //CLK_PIN
    setWatch(function(e) {
      if (isActive) {
        d=(d<<1)|e.data;
        if (d>255) {
          toPrint = toPrint + (d&255);
          d=1; //cleanup after 8 bits
        }
      }
    },CLK_PIN,{edge:"rising", data:MOSI_PIN, repeat: true});
    
About

Avatar for maze1980 @maze1980 started