Commit f24c9944 authored by Ada Gottensträter's avatar Ada Gottensträter

Working PASM SPIRAM driver, significantly faster.

Also some minor optimization in PROPPLAY
parent e8eb6aa4
......@@ -134,7 +134,7 @@ OBJ
snd : "NS_sound_drv_052_22khz_16bit_stereo.spin" 'Sound driver
'eeprom : "NS_eeprom_drv_011.spin" 'EEPROM Driver
ram : "sdiram_seq.spin"
ram : "23lc1024.spin"
'///////////////////////////////////////////////////////////////////////
' EXPORT PUBLICS //////////////////////////////////////////////////////
......@@ -166,7 +166,7 @@ PUB start(arg_debug_data_ptr)
'Start eeprom driver
'eeprom.start(28,29,0)
ram.init(21,24,20,26)
ram.start(21,24,20,26)
return cogon := (cog := cognew(HDMF_main, @my_stack)) > 0
......@@ -270,7 +270,7 @@ PRI HDMF_main | i, HDMF_freq, HDMF_duration, HDMF_channel, HDMF_volume, HDMF_tim
'Pre-read the first byte (into y)
repeat while (LOCKSET(EEPROM_DRIVER_SEMAPHORE)==1)
ram.preparecog
'ram.preparecog
ram.Read(@y, song_ptr, 1)
'repeat while not eeprom.IsDone
......@@ -414,7 +414,6 @@ PUB EEPROM_Read(arg_buffer_address, arg_eeprom_address, arg_byte_count)
'' This is a pass-thru. The parameters are passed unchanged to the eeprom driver.
''
repeat while (LOCKSET(EEPROM_DRIVER_SEMAPHORE)==1)
ram.preparecog
ram.Read(arg_buffer_address, arg_eeprom_address-$8000, arg_byte_count)
PUB EEPROM_IsDone | done
......
{{
Super-naive SDI RAM Driver.
}}
CON
addr_mask = $00FFFFFF
write_cmd = $02<<24
read_cmd = $03<<24
VAR
byte DOpin, CLKpin, DIpin, CSpin
pub init(DO,CLK,DI,CS)
if DO <> DI+1
abort
DOpin := DO
CLKpin := CLK
DIpin := DI
CSpin := CS
prepare
dira[DOpin]~
dira[DIpin]~~
outa[CSpin]~
writeval($ffff,16) 'reset to SPI mode
outa[CSpin]~~
outa[CSpin]~
writeval(%00_00_11_11_11_00_11_11,16) 'set SDI (2-bit) mode (every bit is repeated twice since the ram is now in 1 bit mode)
outa[CSpin]~~
dira[DOpin]~~
outa[CSpin]~
writeval($0140,16) 'set sequential mode
end
pub write(buffer,address,length)
prepare
dira[DOpin]~~
dira[DIpin]~~
outa[CSpin]~
writeval((address&addr_mask)|write_cmd,32)
repeat length
writeval(byte[buffer++],8)
end
pub read(buffer,address,length)
prepare
dira[DOpin]~~
dira[DIpin]~~
outa[CSpin]~
writeval((address&addr_mask)|read_cmd,32)
dira[DOpin]~
dira[DIpin]~
readval(8) ' Dummy byte (only required in SDI and SQI)
repeat length
byte[buffer++] := readval(8)
end
pri readval(bits) | val
val~ ' clear input
bits >>= 1
repeat Bits
outa[CLKpin]~
'val := (val << 1) | ina[DOpin]
'val := (val << 1) | ina[DIpin]
val := (val << 2) | (ina[DOpin..DIpin])
outa[CLKpin]~~
return val
pri writeval(val,bits)
val <<= (32 - bits) ' pre-align
bits >>= 1
repeat bits
outa[CLKpin]~
'outa[DOpin] := (val <-= 1) & 1
'outa[DIpin] := (val <-= 1) & 1
outa[DOpin..DIpin] := ((val <-= 2)&%11)
outa[CLKpin]~~
pri prepare
outa[CLKpin]~~
dira[CLKpin]~~
outa[CSpin]~~
dira[CSpin]~~
pri end
outa[CSpin]~~
dira[DIpin]~
dira[DOpin]~
dira[CLKpin]~
dira[CSpin]~
\ No newline at end of file
......@@ -32,12 +32,14 @@ pub init(DO,CLK,DI,CS)
dira[CLKpin]~~
outa[CSpin]~~
dira[CSpin]~~
dira[DOpin]~
outa[DOpin]~~
dira[DOpin]~~
dira[DIpin]~~
outa[CSpin]~
writeval($ffff,16) 'reset to SPI mode
outa[CSpin]~~
dira[DOpin]~
outa[CSpin]~
writeval(%00_00_11_11_11_00_11_11,16) 'set SDI (2-bit) mode (every bit is repeated twice since the ram is now in 1 bit mode)
outa[CSpin]~~
......
......@@ -5,9 +5,9 @@
}}
CON
addr_mask = $00FFFFFF
write_cmd = $02<<24
read_cmd = $03<<24
'addr_mask = $00FFFFFF
write_cmd = $02
read_cmd = $03
seqmode_read = 1
seqmode_write = 2
......@@ -27,51 +27,71 @@ pub init(DO,CLK,DI,CS)
CSpin := CS
seqptr := -1
seqmode := 0
prepare
dira[DOpin]~
outa[CLKpin]~
dira[CLKpin]~~
outa[CSpin]~~
dira[CSpin]~~
dira[DOpin]~~
dira[DIpin]~~
outa[CSpin]~
writeval($ffff,16) 'reset to SPI mode
outa[CSpin]~~
dira[DOpin]~
outa[CSpin]~
writeval(%00_00_11_11_11_00_11_11,16) 'set SDI (2-bit) mode (every bit is repeated twice since the ram is now in 1 bit mode)
outa[CSpin]~~
dira[DOpin]~~
outa[CSpin]~
writeval($0140,16) 'set sequential mode
end
!outa[CSpin]
!outa[CSpin]
dira[DOpin]~
dira[DIpin]~
pub write(buffer,address,length)
if seqmode <> seqmode_write OR seqptr <> address
end
prepare
outa[CSpin]~~
outa[CSpin]~
dira[DOpin]~~
dira[DIpin]~~
outa[CSpin]~
writeval((address&addr_mask)|write_cmd,32)
writeval(((address<<8)|write_cmd)->8,32)
seqmode := seqmode_write
seqptr := address
dira[DOpin]~~
dira[DIpin]~~
repeat length
writeval(byte[buffer++],8)
dira[DOpin]~
dira[DIpin]~
seqptr += length
pub read(buffer,address,length)
if seqmode <> seqmode_read OR seqptr <> address
end
prepare
outa[CSpin]~~
dira[DOpin]~~
dira[DIpin]~~
outa[CSpin]~
writeval((address&addr_mask)|read_cmd,32)
writeval(((address<<8)|read_cmd)->8,32)
seqmode := seqmode_read
seqptr := address
skipbyte ' Dummy byte (only required in SDI and SQI)
seqptr += length
repeat length
byte[buffer++] := readval(8)
seqptr += length
pub skipbyte
PRI skipbyte
dira[DOpin]~
dira[DIpin]~
repeat 4
......@@ -82,25 +102,31 @@ pri readval(bits) | val
val~ ' clear input
bits >>= 1
repeat Bits
outa[CLKpin]~
'val := (val << 1) | ina[DOpin]
'val := (val << 1) | ina[DIpin]
val := (val << 2) | (ina[DOpin..DIpin])
outa[CLKpin]~~
outa[CLKpin]~
return val
pri writeval(val,bits)
val <<= (32 - bits) ' pre-align
bits >>= 1
repeat bits
outa[CLKpin]~
'outa[DOpin] := (val <-= 1) & 1
'outa[DIpin] := (val <-= 1) & 1
outa[DOpin..DIpin] := ((val <-= 2)&%11)
outa[CLKpin]~~
outa[CLKpin]~~
outa[CLKpin]~
pub preparecog
outa[CSpin]~
dira[CSpin]~~
outa[CLKpin]~
dira[CLKpin]~~
pri prepare
outa[CLKpin]~~
{pub prepare
outa[CLKpin]~
dira[CLKpin]~~
outa[CSpin]~~
dira[CSpin]~~
......@@ -110,4 +136,4 @@ pub end
dira[DOpin]~
dira[CLKpin]~
dira[CSpin]~
seqmode := 0
\ No newline at end of file
seqmode := 0}
\ No newline at end of file
......@@ -19,7 +19,12 @@ pub init(DO,CLK,DI,CS)
CSpin := CS
prepare
outa[CSpin]~
dira[DOpin]~~
outa[DOpin]~~
writeval($ff,8) 'reset to SPI mode
dira[DOpin]~
outa[DOpin]~
outa[CSpin]~~
outa[CSpin]~
writeval($0140,16) 'set sequential mode
......@@ -43,6 +48,15 @@ pub read(buffer,address,length)
byte[buffer++] := readval(8)
end
pub getmr
prepare
outa[CSpin]~
writeval($05,8)
result:=readval(8)
end
pri readval(bits) | val
val~ ' clear input
......
{{
Super-naive SDI RAM Driver.
}}
CON
addr_mask = $00FFFFFF
write_cmd = $02<<24
read_cmd = $03<<24
VAR
byte DOpin, CLKpin, DIpin, CSpin
pub init(DO,CLK,DI,CS)
DOpin := DO
CLKpin := CLK
DIpin := DI
CSpin := CS
prepare
dira[DOpin]~
dira[DIpin]~~
outa[CSpin]~
writeval($ffff,16) 'reset to SPI mode
outa[CSpin]~~
outa[CSpin]~
writeval(%00_00_11_11_11_00_11_11,16) 'set SDI (2-bit) mode (every bit is repeated twice since the ram is now in 1 bit mode)
outa[CSpin]~~
dira[DOpin]~~
outa[CSpin]~
writeval($0140,16) 'set sequential mode
end
pub write(buffer,address,length)
prepare
dira[DOpin]~~
dira[DIpin]~~
outa[CSpin]~
writeval((address&addr_mask)|write_cmd,32)
repeat length
writeval(byte[buffer++],8)
end
pub read(buffer,address,length)
prepare
dira[DOpin]~~
dira[DIpin]~~
outa[CSpin]~
writeval((address&addr_mask)|read_cmd,32)
dira[DOpin]~
dira[DIpin]~
readval(8) ' Dummy byte (only required in SDI and SQI)
repeat length
byte[buffer++] := readval(8)
end
pri readval(bits) | val
val~ ' clear input
bits >>= 1
repeat Bits
outa[CLKpin]~
'val := (val << 1) | ina[DOpin]
'val := (val << 1) | ina[DIpin]
val := (val << 2) | ((ina>>DIpin)&%11)
outa[CLKpin]~~
return val
pri writeval(val,bits)
val <<= (32 - bits) ' pre-align
bits >>= 1
repeat bits
outa[CLKpin]~
'outa[DOpin] := (val <-= 1) & 1
'outa[DIpin] := (val <-= 1) & 1
outa[DOpin..DIpin] := ((val <-= 2))
outa[CLKpin]~~
pri prepare
outa[CLKpin]~~
dira[CLKpin]~~
outa[CSpin]~~
dira[CSpin]~~
pri end
outa[CSpin]~~
dira[DIpin]~
dira[DOpin]~
dira[CLKpin]~
dira[CSpin]~
\ No newline at end of file
Help Keyboard controls: Arrow Keys -> Select file PgUp/PgDown-> Also select file Enter -> Play file or enter directory S -> Stop Space Bar -> Pause (SID dumps only) Tab -> Switch View (Files or Directories) R -> Rescan directory F1 -> This screen + and - -> Increase/Decrease SID IRQ Frequency PropPlay TV is free software (MIT) (C)2018 IRQsome Software (C)2014 Piotr Kardasz FAT Filesystem driver by Kwabena W. Agyeman SIDcog by Johannes Ahlebrand PRESS ANY KEY....
\ No newline at end of file
Help Keyboard controls: Arrow Keys -> Select file PgUp/PgDown-> Also select file Enter -> Play file or enter directory S -> Stop Space Bar -> Pause Tab -> Switch View (Files or Directories) R -> Rescan directory F1 -> This screen + and - -> Increase/Decrease SID IRQ Frequency PropPlay TV is free software (MIT) (C)2019 IRQsome Software (C)2014 Piotr Kardasz FAT Filesystem driver by Kwabena W. Agyeman SIDcog by Johannes Ahlebrand PM Synth by Andy Schenk PRESS ANY KEY....
\ No newline at end of file
Help Keyboard controls: Arrow Keys -> Select file PgUp/PgDown-> Also select file Enter -> Play file or enter directory S -> Stop Space Bar -> Pause (SID dumps only) Tab -> Switch View (Files or Directories) R -> Rescan directory F1 -> This screen + and - -> Increase/Decrease SID IRQ Frequency PropPlay TV is free software (MIT) (C)2018 IRQsome Software (C)2014 Piotr Kardasz FAT Filesystem driver by Kwabena W. Agyeman SIDcog by Johannes Ahlebrand PRESS ANY KEY....
\ No newline at end of file
Help Keyboard controls: Arrow Keys -> Select file PgUp/PgDown-> Also select file Enter -> Play file or enter directory S -> Stop Space Bar -> Pause Tab -> Switch View (Files or Directories) R -> Rescan directory F1 -> This screen + and - -> Increase/Decrease SID IRQ Frequency PropPlay TV is free software (MIT) (C)2019 IRQsome Software (C)2014 Piotr Kardasz FAT Filesystem driver by Kwabena W. Agyeman SIDcog by Johannes Ahlebrand PM Synth by Andy Schenk PRESS ANY KEY....
\ No newline at end of file
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment