|
| 1 | +from .JlcPart import JlcPart |
| 2 | +from ..abstract_parts import * |
| 3 | + |
| 4 | + |
| 5 | +class Lsm6dsv16x_Device(InternalSubcircuit, FootprintBlock, JlcPart): |
| 6 | + def __init__(self) -> None: |
| 7 | + super().__init__() |
| 8 | + self.vdd = self.Port(VoltageSink( |
| 9 | + voltage_limits=(1.71, 3.6) * Volt, |
| 10 | + current_draw=(2.6 * uAmp, 0.65 * mAmp) # Values for low-power and high-performance modes |
| 11 | + )) |
| 12 | + self.vddio = self.Port(VoltageSink( |
| 13 | + voltage_limits=(1.08, 3.6) * Volt # Extended range |
| 14 | + )) |
| 15 | + self.gnd = self.Port(Ground()) |
| 16 | + |
| 17 | + dio_model = DigitalBidir.from_supply( |
| 18 | + self.gnd, self.vddio, |
| 19 | + voltage_limit_abs=(-0.3 * Volt, self.vddio.voltage_limits.upper() + 0.3), |
| 20 | + # datasheet states abs volt to be [0.3, VDD_IO+0.3], likely a typo |
| 21 | + current_limits=(-4, 4) * mAmp, |
| 22 | + input_threshold_factor=(0.3, 0.7) |
| 23 | + ) |
| 24 | + self.i2c = self.Port(I2cTarget(dio_model)) |
| 25 | + |
| 26 | + dout_model = DigitalSource.low_from_supply(self.gnd) |
| 27 | + self.int1 = self.Port(dout_model, optional=True) |
| 28 | + self.int2 = self.Port(dout_model, optional=True) |
| 29 | + |
| 30 | + self.qvar1 = self.Port(Passive(), optional=True) |
| 31 | + self.qvar2 = self.Port(Passive(), optional=True) |
| 32 | + |
| 33 | + def contents(self) -> None: |
| 34 | + self.footprint( |
| 35 | + 'U', 'Package_LGA:Bosch_LGA-14_3x2.5mm_P0.5mm', |
| 36 | + { |
| 37 | + '1': self.gnd, # sa0 |
| 38 | + '2': self.qvar1, # not used in mode 1 |
| 39 | + '3': self.qvar2, # not used in mode 1 |
| 40 | + '4': self.int1, |
| 41 | + '5': self.vddio, |
| 42 | + '6': self.gnd, |
| 43 | + '7': self.gnd, |
| 44 | + '8': self.vdd, |
| 45 | + '9': self.int2, |
| 46 | + # '10': self.nc, # leave unconnected |
| 47 | + # '11': self.nc, # leave unconnected |
| 48 | + '12': self.vddio, # cs pin |
| 49 | + '13': self.i2c.scl, |
| 50 | + '14': self.i2c.sda, |
| 51 | + }, |
| 52 | + mfr='STMicroelectronics', part='LSM6DSV16X', |
| 53 | + datasheet='https://www.st.com/resource/en/datasheet/lsm6dsv16x.pdf' |
| 54 | + ) |
| 55 | + self.assign(self.lcsc_part, 'C5267406') |
| 56 | + self.assign(self.actual_basic_part, False) |
| 57 | + |
| 58 | + |
| 59 | +class Lsm6dsv16x(Accelerometer, Gyroscope, DefaultExportBlock): |
| 60 | + """Integrated High-edn smartphone 3d accelerometer (ranging over +/- 2/4/8/16 g) and 3d gyroscope |
| 61 | + (ranging over +/- 125/250/500/1000/2000 dps). Onboard sensor fusion for quaternion calculation. |
| 62 | + Supports external qvar for tap detections, etc.""" |
| 63 | + |
| 64 | + def __init__(self): |
| 65 | + super().__init__() |
| 66 | + self.ic = self.Block(Lsm6dsv16x_Device()) |
| 67 | + self.gnd = self.Export(self.ic.gnd, [Common]) |
| 68 | + self.pwr = self.Export(self.ic.vdd, [Power]) |
| 69 | + self.pwr_io = self.Export(self.ic.vddio, default=self.pwr, doc="IO supply voltage") |
| 70 | + |
| 71 | + self.i2c = self.Export(self.ic.i2c) |
| 72 | + self.int1 = self.Export(self.ic.int1, optional=True, |
| 73 | + doc="Programmable interrupt. This can be configured as push-pull / open-drain.") |
| 74 | + self.int2 = self.Export(self.ic.int2, optional=True, |
| 75 | + doc="Programmable interrupt. This can be configured as push-pull / open-drain.") |
| 76 | + |
| 77 | + self.qvar1 = self.Export(self.ic.qvar1, optional=True, doc="qvar input pin 1") |
| 78 | + self.qvar2 = self.Export(self.ic.qvar2, optional=True, doc="qvar input pin 2") |
| 79 | + |
| 80 | + def contents(self): |
| 81 | + super().contents() |
| 82 | + self.vdd_cap = self.Block(DecouplingCapacitor(100 * nFarad(tol=0.2))).connected(self.gnd, self.ic.vdd) |
| 83 | + self.vddio_cap = self.Block(DecouplingCapacitor(100 * nFarad(tol=0.2))).connected(self.gnd, self.ic.vddio) |
0 commit comments