Make it possible to adjust the type of pad controls used,
[sifive-blocks.git] / src / main / scala / devices / i2c / I2CPins.scala
1 // See LICENSE for license details.
2 package sifive.blocks.devices.i2c
3
4 import Chisel._
5 import sifive.blocks.devices.pinctrl.{Pin, PinCtrl}
6 import sifive.blocks.util.ShiftRegisterInit
7
8
9 class I2CPins[T <: Pin](pingen: () => T) extends Bundle {
10
11 val scl: T = pingen()
12 val sda: T = pingen()
13
14 def fromI2CPort(i2c: I2CPort, syncStages: Int = 0) = {
15 scl.outputPin(i2c.scl.out, pue=true.B, ie = true.B)
16 scl.o.oe := i2c.scl.oe
17 i2c.scl.in := ShiftRegisterInit(scl.i.ival, syncStages, Bool(true))
18
19 sda.outputPin(i2c.sda.out, pue=true.B, ie = true.B)
20 sda.o.oe := i2c.sda.oe
21 i2c.sda.in := ShiftRegisterInit(sda.i.ival, syncStages, Bool(true))
22 }
23 }