Repository navigation
Expand file tree
/
Copy pathverify_imu_i2cm.py
More file actions
51 lines (51 loc) · 3.65 KB
/
Copy pathverify_imu_i2cm.py
File metadata and controls
51 lines (51 loc) · 3.65 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
"""Exercise timed I2CM/MAG transactions, faults, reset and observer capacity."""
import verify_imu_auxiliary as auxiliary
harness=auxiliary.harness
EXTRA='''
from Antmicro.Renode.Peripherals.Miscellaneous import BlackwallImuI2cMaster,BlackwallExecutionObserver
def put(q,reg,data,enabled=True):return q.TryWriteIreg(reg,Array[Byte](data),enabled)
def get(q,reg):return list(q.ReadIreg(reg,1))
def setup(q,reg,data=None):
check('profile',put(q,0xa20f,[0x1e]))
if data is None:check('read-address',put(q,0xa20e,[reg]))
else:check('write-reg',put(q,0xa233,[reg]) and put(q,0xa234,[data]))
check('command',put(q,0xa206,[0x91 if data is None else 0x82]))
old=get(q,0xa216)[0]
check('go',put(q,0xa216,[(old&0xf6)|1]))
q=BlackwallImuI2cMaster(m,'a045000000',100,True,0)
check('master-invalid-address',not put(q,0xa250,[0]) and q.Starts==0)
check('master-go-without-request',get(q,0xa216)==[0xa0] and not put(q,0xa216,[0xa1]))
setup(q,0x7f,0xca)
check('master-busy',q.Pending and get(q,0xa218)==[1] and not q.TakeDoneInterrupt())
check('master-no-config-while-busy',not put(q,0xa20f,[0x1e]))
advance(99);check('master-not-early',q.Pending and not q.Unlocked)
advance(2);check('master-completion',not q.Pending and q.Unlocked and q.Completions==1 and get(q,0xa218)==[2])
check('master-done-latched-once',q.TakeDoneInterrupt() and not q.TakeDoneInterrupt())
setup(q,0x7c);advance(101);check('master-read-sequencer',q.TakeDoneInterrupt() and get(q,0xa21b)==[0])
check('master-read-consumed',q.ReadIreg(0xa21b,1) is None)
setup(q,0x7c,0x80);advance(101);check('master-soft-reset',q.TakeDoneInterrupt() and q.SoftResets==1 and q.Sequencer==0)
setup(q,0x7f,0);advance(101);check('master-lock',q.TakeDoneInterrupt() and not q.Unlocked)
setup(q,4,3);advance(101);check('master-mrm-mode',q.TakeDoneInterrupt() and q.Mode==3)
setup(q,5);advance(101);check('master-mode-status',q.TakeDoneInterrupt() and get(q,0xa21b)==[3])
setup(q,4,0);advance(101);check('master-standby',q.TakeDoneInterrupt() and q.Mode==0)
setup(q,1);advance(101);check('master-id',q.TakeDoneInterrupt() and get(q,0xa21b)==[0x45] and q.IdentityReads==1)
q.Reset();check('master-reset',q.Starts==q.Completions==0 and q.Control==0xa0 and q.Mode==0 and not q.Pending)
setup(q,0x7f,0xca);advance(50);q.Reset();advance(100);check('master-reset-cancels',q.Starts==0 and not q.Unlocked and not q.Pending)
missing=BlackwallImuI2cMaster(m,'a045000000',100,False,0)
setup(missing,0x7f,0xca);advance(101);check('master-missing-completion',missing.Pending and missing.Completions==0 and not missing.TakeDoneInterrupt())
fault=BlackwallImuI2cMaster(m,'a045000000',100,True,4)
setup(fault,0x7f,0xca);advance(101);check('master-fault-no-commit',fault.TakeDoneInterrupt() and get(fault,0xa218)==[6] and not fault.Unlocked)
bad=BlackwallImuI2cMaster(m,'a044000000',100,True,0)
setup(bad,1);advance(101);check('master-wrong-id-preserved',bad.TakeDoneInterrupt() and get(bad,0xa21b)==[0x44])
stream=BlackwallImuI2cMaster(m,'a045000000',100,True,0)
setup(stream,1);advance(101);stream.TakeDoneInterrupt();get(stream,0xa21b)
check('stream-read-profile-start',put(stream,0xa20e,[6]))
check('stream-profile-continuation',stream.TryWriteContinuation(0xa20f,Array[Byte]([0x1e]),True))
check('stream-command',put(stream,0xa206,[0x91]))
get(stream,0xa216);check('stream-go-preserves-address',put(stream,0xa216,[0xa1]))
advance(101);check('stream-read-status',stream.TakeDoneInterrupt() and get(stream,0xa21b)==[0])
observer=BlackwallExecutionObserver(None,16384)
check('extended-observer-capacity',observer.Capacity==16384)
'''
harness.DRIVER=harness.DRIVER.replace("Console.WriteLine('BLACKWALL_IMU_UNIT ",EXTRA+"Console.WriteLine('BLACKWALL_IMU_UNIT ")
if __name__=='__main__':harness.main()