This repository has been archived by the owner on Jun 16, 2024. It is now read-only.
-
Notifications
You must be signed in to change notification settings - Fork 0
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Showing
7 changed files
with
128 additions
and
30 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,7 @@ | ||
package ee.hrzn.chryse.platform.ecp5 | ||
|
||
object PullMode { | ||
val UP = "UP" | ||
val DOWN = "DOWN" | ||
val NONE = "NONE" | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
11 changes: 11 additions & 0 deletions
11
src/main/scala/ee/hrzn/chryse/platform/resource/Disconnected.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,11 @@ | ||
package ee.hrzn.chryse.platform.resource | ||
|
||
import ee.hrzn.chryse.platform.resource.Pin | ||
import ee.hrzn.chryse.platform.resource.PinPlatform | ||
|
||
import scala.language.implicitConversions | ||
|
||
object Disconnected { | ||
implicit def disconnected2Pin(disc: this.type): Pin = | ||
PinPlatform(this) | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
65 changes: 65 additions & 0 deletions
65
src/main/scala/ee/hrzn/chryse/platform/resource/SPIOLED.scala
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,65 @@ | ||
package ee.hrzn.chryse.platform.resource | ||
|
||
import chisel3._ | ||
import chisel3.experimental.Param | ||
|
||
class SPIOLED extends ResourceBase { | ||
val cs = ResourceData(Output(Bool()), invert = true) | ||
val clock = ResourceData(Output(Clock())) | ||
val copi = ResourceData(Output(Bool())) | ||
val cipo = ResourceData(Input(Bool())) | ||
val wp = ResourceData(Output(Bool()), invert = true) | ||
val hold = ResourceData(Output(Bool()), invert = true) | ||
|
||
def setName(name: String): Unit = { | ||
cs.setName(s"${name}_cs") | ||
clock.setName(s"${name}_clock") | ||
copi.setName(s"${name}_copi") | ||
cipo.setName(s"${name}_cipo") | ||
wp.setName(s"${name}_wp") | ||
hold.setName(s"${name}_hold") | ||
} | ||
|
||
def withAttributes(attribs: (String, Param)*): this.type = { | ||
cs.withAttributes(attribs: _*) | ||
clock.withAttributes(attribs: _*) | ||
copi.withAttributes(attribs: _*) | ||
cipo.withAttributes(attribs: _*) | ||
wp.withAttributes(attribs: _*) | ||
hold.withAttributes(attribs: _*) | ||
this | ||
} | ||
|
||
def setDefaultAttributes(defaultAttributes: Map[String, Param]): Unit = { | ||
cs.setDefaultAttributes(defaultAttributes) | ||
clock.setDefaultAttributes(defaultAttributes) | ||
copi.setDefaultAttributes(defaultAttributes) | ||
cipo.setDefaultAttributes(defaultAttributes) | ||
wp.setDefaultAttributes(defaultAttributes) | ||
hold.setDefaultAttributes(defaultAttributes) | ||
} | ||
|
||
def onPins( | ||
csN: Pin, | ||
clock: Pin, | ||
copi: Pin, | ||
cipo: Pin, | ||
wpN: Pin, | ||
holdN: Pin, | ||
): this.type = { | ||
this.cs.onPin(csN) | ||
this.clock.onPin(clock) | ||
this.copi.onPin(copi) | ||
this.cipo.onPin(cipo) | ||
this.wp.onPin(wpN) | ||
this.hold.onPin(holdN) | ||
this | ||
} | ||
|
||
def data: Seq[ResourceData[_ <: Data]] = | ||
Seq(cs, clock, copi, cipo, wp, hold) | ||
} | ||
|
||
object SPIOLED { | ||
def apply() = new SPIOLED | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters