Habe leider gerade keine SPI Komponente zur Hand und habe mich eigentlich noch nie mit SPI beschäftigt. Sieht aber recht einfach aus.
In der Function SPI würde ich aber die Bytes nicht festnageln und besser define ref at verwenden.
Code:
FUNCTION spi(spiodata as byte)                'R/W auf SPI
   DEFINE spicount as byte
   DEFINE spiidata as byte
   DEFINE spiibit ref spiidata at bit[8]
   DEFINE spiobit ref spiodata at bit[8]                    'letztes Bit aus spiodata
   FOR spicount = 0 to 8
      nop(200)
      SLCK=0             'Abfallende Flanke des Clocks
      nop(100)
      SDO = spiobit                                 'SDO Bit Setzen
      spiodata = spiodata shl 1                   'Daten vorbereiten   
      nop(200)
      spiidata = spiidata shl 1                   'Daten vorbereiten
      SLCK=1             'Steigende Flanke des Clocks
      nop(100)
      spiibit = SDI                               'Daten Einlesen
   NEXT
   RETURN spiidata   
END SUB