diff --git a/sw/spi.s b/sw/spi.s index b5ff81d..f4c0e7a 100644 --- a/sw/spi.s +++ b/sw/spi.s @@ -7,6 +7,10 @@ .code +SPI_SCLK = $01 +SPI_SSn = $02 +SPI_MOSI = $04 + ; Write a single byte to the SPI device ; @in A The byte to write @@ -19,16 +23,18 @@ _spi_write_byte: tax @loop: bit tmp1 ; Check if high bit set beq @1 - lda #$04 ; Bit not set. + lda #SPI_MOSI ; Bit not set. bra @1 @1: lda #$00 ; Bit set sta BB_SPI_BASE ; Write data - adc #$01 + adc #SPI_SCLK sta BB_SPI_BASE ; Write clock txa lsr ; Select next bit tax bne @loop ; Stop when mask is 0 + lda #SPI_SSn ; Raise Slave Select + sta BB_SPI_BASE ply ; Restore regs plx rts ; Return