From 83009b11b4d250edbc98d89540e8e732c2817236 Mon Sep 17 00:00:00 2001 From: "matthias@rpi" Date: Mon, 30 Oct 2023 22:14:33 +0100 Subject: [PATCH] add read --- system/spi.s65 | 47 ++++++++++++++++++++++++++++++++++++++++------- 1 file changed, 40 insertions(+), 7 deletions(-) diff --git a/system/spi.s65 b/system/spi.s65 index 0af61ce..28e6207 100644 --- a/system/spi.s65 +++ b/system/spi.s65 @@ -5,19 +5,19 @@ ; @depends IO-W65C22N ;******************************************************************************** - .include "system/system.h65" +.include "system/system.h65" .ifndef INCLUDE_SPI INCLUDE_SPI = 1 - .segment "CODE" - .struct SPI_Pins + + .struct SPI_P_Pins ; VIA addresses DDR_a .word ; address of the data direction register R_a .word ; address of the register ; pin mask - SLK_p .byte ; Serial Clock + SCLK_p .byte ; Serial Clock POCI_p .byte ; Peripheral Out / Controller In PICO_p .byte ; Peripheral In / Controller Out CSB_p .byte ; Chip Select @@ -25,14 +25,47 @@ INCLUDE_SPI = 1 CPOL .byte ; Clock Polarity CPHA .byte ; Clock Phase .endstruct + +;******************************************************************************** +; @function Initialize the IO Adapter for SPI +; @param ARG0-1 Address of the SPI_Pins struct +;******************************************************************************** +.proc spi_p_init + ; todo USE MASKS + ; set Shift register to shift in under external clock on CB1 + lda #%00001100 + sta SPI_IO + IO_ACR + + ; enable SR interrupts + lda #%10000100 + sta SPI_IO + IO_IER + rts +.endproc + +.proc spi_p_read + ; print received byte + lda SPI_IO + IO_SR + jsr _lcd_char + rts +.endproc + +;******************************************************************************** +; @function Read bytes +; @param X Number of bytes to send +; @param ARG0-1 Address of the SPI_Pins struct +; @param ARG2-3 Address of the first byte +;******************************************************************************** +.proc recv_data +.endproc ;******************************************************************************** ; @function Send bytes ; @param X Number of bytes to send -; @param ARG0-1 Address of the first byte -; @param ARG2-3 Address of the SPI_Pins struct +; @param ARG0-1 Address of the SPI_Pins struct +; @param ARG2-3 Address of the first byte ;******************************************************************************** -send_data: +.proc send_data +.endproc