Skip to content

Commit d6dd94b

Browse files
committed
spi: debug the interface to the SRAM
1 parent 01e672f commit d6dd94b

File tree

2 files changed

+24
-5
lines changed

2 files changed

+24
-5
lines changed

src/main/scala/spi/SerialSpiTest.scala

Lines changed: 23 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -100,6 +100,21 @@ class SerialSpiTest(id: Int, portName: String = "/dev/tty.usbserial-210292B40860
100100
v
101101
}
102102

103+
// The SRAM needs a delay after the command
104+
def readJedecIdWait() = {
105+
csLow()
106+
writeByte(0x9f)
107+
writeByte(0)
108+
writeByte(0)
109+
writeByte(0)
110+
val v = readByte()
111+
println("Manufacturer is 0x" + v.toHexString)
112+
println("Device type is 0x" + readByte().toHexString)
113+
println("Device id is 0x" + readByte().toHexString)
114+
csHigh()
115+
v
116+
}
117+
103118
def readStatusRegister() = {
104119
csLow()
105120
writeByte(0x05)
@@ -233,11 +248,11 @@ object SerialSpiTest extends App {
233248
val s = "Hello Wildcat!\n"
234249
val data = s.getBytes
235250
// spi.programFlash(1, 0, data)
236-
Thread.sleep(1000)
251+
// Thread.sleep(1000)
237252

238253
val buf = new Array[Byte](20)
239-
spi.readMemory(0, buf)
240-
println(new String(buf))
254+
// spi.readMemory(0, buf)
255+
// println(new String(buf))
241256
/*
242257
for (i <- 0 until 20) {
243258
print(spi.readMemory(i).toChar)
@@ -251,6 +266,10 @@ object SerialSpiTest extends App {
251266

252267
println("SRAM test")
253268
val sram = new SerialSpiTest(2) // SRAM
269+
sram.readJedecIdWait()
270+
sram.readMemory(0)
254271
sram.writeSram(0, 0x55)
255-
sram.readSram(0)
272+
sram.readMemory(0)
273+
sram.writeSram(0, 0xaa)
274+
sram.readMemory(0)
256275
}

src/test/scala/spi/FlashTest.scala

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -6,7 +6,7 @@ import chiseltest._
66
import org.scalatest.flatspec.AnyFlatSpec
77
import spi.SerialSpiTest.spi
88

9-
class FlashTest extends AnyFlatSpec with ChiselScalatestTester {
9+
class FlashTest(dontRun: String) extends AnyFlatSpec with ChiselScalatestTester {
1010
behavior of "FlashTest"
1111

1212
it should "test the flash" in {

0 commit comments

Comments
 (0)