Ejemplo n.º 1
0
 def test_setClock(self):
     tester = BbTester()
     banger = bitbang.BitBanger(CLK_PIN, MISO_PIN, MOSI_PIN, ENABLE_PIN,
                                tester)
     banger.setClock()
     self.assertEqual([(ENABLE_PIN, tester.LOW), (ENABLE_PIN, tester.HIGH),
                       (CLK_PIN, tester.HIGH)], tester.pinActions)
Ejemplo n.º 2
0
 def test_clearMosi(self):
     tester = BbTester()
     banger = bitbang.BitBanger(CLK_PIN, MISO_PIN, MOSI_PIN, ENABLE_PIN,
                                tester)
     banger.clearMosi()
     self.assertEqual([(ENABLE_PIN, tester.LOW), (ENABLE_PIN, tester.HIGH),
                       (MOSI_PIN, tester.LOW)], tester.pinActions)
Ejemplo n.º 3
0
 def test_setup(self):
     tester = BbTester()
     banger = bitbang.BitBanger(CLK_PIN, MISO_PIN, MOSI_PIN, ENABLE_PIN,
                                tester)
     self.assertEqual(tester.BOARD, tester.mode)
     self.assertEqual(tester.OUT, tester.pinModes[CLK_PIN])
     self.assertEqual(tester.IN, tester.pinModes[MISO_PIN])
     self.assertEqual(tester.OUT, tester.pinModes[MOSI_PIN])
     self.assertEqual(tester.OUT, tester.pinModes[ENABLE_PIN])
Ejemplo n.º 4
0
 def test_waitForReadySignal(self):
     tester = BbTester()
     banger = bitbang.BitBanger(CLK_PIN, MISO_PIN, MOSI_PIN, ENABLE_PIN,
                                tester)
     tester.pinSettings[MISO_PIN] = [tester.LOW]
     with self.assertRaises(bitbang.SendByteTimeoutException):
         banger.sendByte(0x00)
     tester.pinSettings[MISO_PIN] = [tester.HIGH]
     banger.sendByte(0x00)
Ejemplo n.º 5
0
 def test_receiveByte(self):
     tester = BbTester()
     banger = bitbang.BitBanger(CLK_PIN, MISO_PIN, MOSI_PIN, ENABLE_PIN,
                                tester)
     tester.pinSettings[MISO_PIN] = [
         tester.LOW, tester.HIGH, tester.LOW, tester.HIGH, tester.LOW,
         tester.HIGH, tester.LOW, tester.HIGH
     ]
     result = banger.receiveByte()
     self.assertEqual(0x55, result)
Ejemplo n.º 6
0
 def test_sendByteLastBit(self):
     tester = BbTester()
     banger = bitbang.BitBanger(CLK_PIN, MISO_PIN, MOSI_PIN, ENABLE_PIN,
                                tester)
     banger.sendByte(0x01)
     c = CLK_PIN
     m = MOSI_PIN
     e = ENABLE_PIN
     h = tester.HIGH
     l = tester.LOW
     self.assertEqual([(e, l), (e, h), (c, l), (m, l), (c, h), (c, l),
                       (m, l), (c, h), (c, l), (m, l), (c, h), (c, l),
                       (m, l), (c, h), (c, l), (m, l), (c, h), (c, l),
                       (m, l), (c, h), (c, l), (m, l), (c, h), (c, l),
                       (m, h), (c, h), (c, l)], tester.pinActions)
Ejemplo n.º 7
0
 def __init__(self,
              addressBytes,
              clockPin,
              misoPin,
              mosiPin,
              enablePin,
              bitBanger=None):
     self.addressBytes = addressBytes
     if (bitBanger == None):
         bitBanger = bitbang.BitBanger(clockPin, misoPin, mosiPin,
                                       enablePin)
     self.bitBanger = bitBanger
     # wait a bit for the PIC to cycle up
     for x in range(1000000):
         pass
Ejemplo n.º 8
0
 def test_getMiso(self):
     tester = BbTester()
     banger = bitbang.BitBanger(CLK_PIN, MISO_PIN, MOSI_PIN, ENABLE_PIN,
                                tester)
     tester.pinSettings[MISO_PIN] = [tester.HIGH]
     self.assertEqual(tester.HIGH, banger.getMiso())