X-Git-Url: https://git.libre-soc.org/?a=blobdiff_plain;f=src%2Fmain%2Fscala%2Fdevices%2Fgpio%2FGPIOPins.scala;h=da6ade3a3b008052aeb79cc4ecd2f33a787ec083;hb=39287b92159e7f7a25635dfe7cc5cb7dc01488bc;hp=11723c4d1a6a0b8a985694d2795521dc25b0367e;hpb=2139ab0d98a72072d3ab6116ab55b9e90b26cabe;p=sifive-blocks.git diff --git a/src/main/scala/devices/gpio/GPIOPins.scala b/src/main/scala/devices/gpio/GPIOPins.scala index 11723c4..da6ade3 100644 --- a/src/main/scala/devices/gpio/GPIOPins.scala +++ b/src/main/scala/devices/gpio/GPIOPins.scala @@ -9,18 +9,19 @@ import sifive.blocks.devices.pinctrl.{Pin} // even though it looks like something that more directly talks to // a pin. It also makes it possible to change the exact // type of pad this connects to. -class GPIOPins[T <: Pin] (pingen: ()=> T, c: GPIOParams) extends Bundle { - +class GPIOSignals[T <: Data](private val pingen: () => T, private val c: GPIOParams) extends Bundle { val pins = Vec(c.width, pingen()) +} + +class GPIOPins[T <: Pin](pingen: () => T, c: GPIOParams) extends GPIOSignals[T](pingen, c) - override def cloneType: this.type = - this.getClass.getConstructors.head.newInstance(pingen, c).asInstanceOf[this.type] +object GPIOPinsFromPort { - def fromGPIOPort(port: GPIOPortIO){ + def apply[T <: Pin](pins: GPIOSignals[T], port: GPIOPortIO){ // This will just match up the components of the Bundle that // exist in both. - (pins zip port.pins) foreach {case (pin, port) => + (pins.pins zip port.pins) foreach {case (pin, port) => pin <> port } }