1818from ttboard .demoboard import DemoBoard , Pins
1919import ttboard .util .time as time
2020from ttboard .mode import RPMode
21+ import ttboard .util .shuttle_tests as shut_tests
2122
2223
2324import ttboard .logging as logging
2425log = logging .getLogger (__name__ )
2526
2627
2728def get_demoboard () -> DemoBoard :
28- return locals ()['demoboard' ]
29+ locvars = locals ()
30+ if 'demoboard' in locvars :
31+ return locvars ['demoboard' ]
32+
33+ return DemoBoard .get ()
2934
3035def get_context () -> dict :
31- return locals ()['context' ]
36+ locvars = locals ()
37+ if 'context' in locvars :
38+ return locvars ['context' ]
39+
40+ raise KeyError ('Cannot find context in localvars??' )
3241
3342def setup_somehow ():
3443 # any setup we might need done
3544 print ("nothing much to setup" )
45+ return True
3646
3747def firstboot_completed ():
3848 # called when all tests passed.
@@ -62,43 +72,12 @@ def test_bidirs(max_idx:int, delay_interval_ms:int=1):
6272 # a test, must return True to consider a pass
6373 tt = get_demoboard ()
6474 print (f'Testing bidirs up to { max_idx } on { tt } ' )
75+ err = shut_tests .factory_test_bidirs (tt , max_idx , delay_interval_ms )
6576
66- # select the project from the shuttle
67- update_delay_ms = delay_interval_ms
68- auto_clock_freq = 1e3
69- tt .shuttle .tt_um_test .enable ()
70- curMode = tt .mode
71- tt .mode = RPMode .ASIC_ON_BOARD # make sure we're controlling everything
72-
73- tt .in0 (0 ) # want this low
74- tt .clock_project_PWM (auto_clock_freq ) # clock it real good
75-
76- log .info ('First boot: starting bidirection pins tests' )
77- for bp in tt .bidirs :
78- bp .mode = Pins .OUT
79- bp (0 ) # start low
80-
81- errCount = 0
82- for i in range (max_idx ):
83- tt .bidir_byte = i
84- time .sleep_ms (update_delay_ms )
85- outbyte = tt .output_byte
86- if outbyte != i :
87- log .warn (f'MISMATCH between bidir val { i } and output { outbyte } ' )
88- errCount += 1
89-
90- # reset everything
91- for bp in tt .bidirs :
92- bp .mode = Pins .IN
93-
94- tt .clock_project_stop ()
95- tt .mode = curMode
96-
97- if errCount :
98- log .error (f'{ errCount } ERRORS encountered' )
77+ if err is not None :
78+ log .error (err )
9979 return False
10080
101- log .info ('Bi-directional pins acting pretty nicely as inputs!' )
10281 return True
10382
10483
@@ -107,39 +86,17 @@ def test_clocking(max_idx:int=30, delay_interval_ms:int=50):
10786 # a test, must return True to consider a pass
10887 tt = get_demoboard ()
10988 print (f'Testing manual clocking up to { max_idx } on { tt } ' )
110-
111-
112- # select the project from the shuttle
113- tt .shuttle .tt_um_test .enable ()
114- tt .mode = RPMode .ASIC_ON_BOARD # make sure we're controlling everything
115-
116-
117- tt .reset_project (True )
118- tt .input_byte = 1
119- tt .clock_project_stop ()
120- tt .reset_project (False )
121-
122- errCount = 0
123- for i in range (max_idx ):
124- tt .clock_project_once ()
125- time .sleep_ms (delay_interval_ms )
126- if tt .output_byte != i :
127- log .warn (f'MISMATCH between bidir val { i } and output { tt .output_byte } ' )
128- errCount += 1
129-
130-
131- if errCount :
132- log .error (f'{ errCount } ERRORS encountered' )
89+ err = shut_tests .factory_test_clocking (tt , max_idx , delay_interval_ms )
90+ if err is not None :
91+ log .error (err )
13392 return False
13493
135- log .info ('RP2040 clocking acting pretty nicely' )
13694 return True
13795
13896
13997
14098
14199
142-
143100def say_hello (delay_interval_ms :int = 100 , times :int = 1 ):
144101 # a test, must return True to consider a pass
145102 print (f'Saying hello' )
0 commit comments