Skip to content

Commit 95edf39

Browse files
committed
deprecated input_byte and co. ability to read back what we've written to bidirs
1 parent cce767b commit 95edf39

File tree

4 files changed

+17
-121
lines changed

4 files changed

+17
-121
lines changed

src/ttboard/boot/firstboot_operations.py

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -102,7 +102,7 @@ def say_hello(delay_interval_ms:int=200, times:int=1):
102102
tt.clock_project_PWM(1e3) # clock it real good
103103

104104
log.info('First boot: saying hello')
105-
tt.uio_oe[:] = [Pins.OUT] * 8 # set as outputs
105+
tt.uio_oe_pico[:] = [Pins.OUT] * 8 # set as outputs
106106

107107
short_delay_ms = int(delay_interval_ms/10)
108108
if short_delay_ms < 10:

src/ttboard/pins/pins.py

Lines changed: 1 addition & 114 deletions
Original file line numberDiff line numberDiff line change
@@ -155,7 +155,7 @@ def _init_ioports(self):
155155
port_defs = [
156156
('uo_out', platform.read_output_byte, platform.write_output_byte),
157157
('ui_in', platform.read_input_byte, platform.write_input_byte),
158-
('uio_in', None, platform.write_bidir_byte),
158+
('uio_in', platform.read_bidir_byte, platform.write_bidir_byte),
159159
('uio_out', platform.read_bidir_byte, None)
160160
]
161161
self._ports = dict()
@@ -197,119 +197,6 @@ def mode(self, setTo:int):
197197
beginFunc = startupMap[setTo]
198198
beginFunc()
199199

200-
def _setmode_on_pins(self, pinslist:list, modelist:list):
201-
max_idx = len(pinslist)
202-
if len(modelist) < max_idx:
203-
max_idx = len(modelist)
204-
205-
for i in range(max_idx):
206-
p = pinslist[i]
207-
p.mode = modelist[i]
208-
209-
def _getmode_for_pins(self, pinslist:list):
210-
return list(map(lambda x: x.mode, pinslist))
211-
212-
@property
213-
def outputs(self):
214-
return self.list_port('out')
215-
216-
@property
217-
def output_pins(self):
218-
return self.list_port('pin_out')
219-
220-
@property
221-
def output_byte(self):
222-
223-
if platform.IsRP2040:
224-
return platform.read_output_byte()
225-
return self._read_byte(self.outputs)
226-
227-
@output_byte.setter
228-
def output_byte(self, val:int):
229-
230-
if platform.IsRP2040:
231-
platform.write_output_byte(val)
232-
else:
233-
self._write_byte(self.outputs, val)
234-
235-
@property
236-
def output_mode(self):
237-
return self._getmode_for_pins(self.outputs)
238-
239-
@output_mode.setter
240-
def output_mode(self, pinmodes:list):
241-
self._setmode_on_pins(self.outputs, pinmodes)
242-
243-
244-
@property
245-
def inputs(self):
246-
return self.list_port('in')
247-
248-
@property
249-
def input_pins(self):
250-
return self.list_port('pin_in')
251-
252-
@property
253-
def input_byte(self):
254-
255-
if platform.IsRP2040:
256-
return platform.read_input_byte()
257-
258-
return self._read_byte(self.inputs)
259-
260-
261-
@input_byte.setter
262-
def input_byte(self, val:int):
263-
264-
if platform.IsRP2040:
265-
platform.write_input_byte(val)
266-
else:
267-
self._write_byte(self.inputs, val)
268-
269-
270-
271-
@property
272-
def input_mode(self):
273-
return self._getmode_for_pins(self.inputs)
274-
275-
@input_mode.setter
276-
def input_mode(self, pinmodes:list):
277-
self._setmode_on_pins(self.inputs, pinmodes)
278-
279-
280-
@property
281-
def bidirs(self):
282-
return self.list_port('uio')
283-
284-
@property
285-
def bidir_pins(self):
286-
return self.list_port('pin_uio')
287-
288-
@property
289-
def bidir_byte(self):
290-
291-
292-
if platform.IsRP2040:
293-
return platform.read_bidir_byte()
294-
295-
return self._read_byte(self.bidirs)
296-
297-
@bidir_byte.setter
298-
def bidir_byte(self, val:int):
299-
if platform.IsRP2040:
300-
platform.write_bidir_byte(val)
301-
else:
302-
self._write_byte(self.bidirs, val)
303-
304-
305-
@property
306-
def bidir_mode(self):
307-
return self._getmode_for_pins(self.bidirs)
308-
309-
@bidir_mode.setter
310-
def bidir_mode(self, pinmodes:list):
311-
self._setmode_on_pins(self.bidirs, pinmodes)
312-
313200
def begin_inputs_all(self):
314201

315202
log.debug(f'Begin inputs all with {gp.GPIOMap}')

src/ttboard/types/logic_array.py

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -241,6 +241,18 @@ def __eq__(
241241
return self == other
242242
else:
243243
return NotImplemented
244+
245+
def __gt__(self, other):
246+
return int(self) > int(other)
247+
248+
def __ge__(self, other):
249+
return int(self) >= int(other)
250+
251+
def __lt__(self, other):
252+
return int(self) < int(other)
253+
def __le__(self, other):
254+
return int(self) <= int(other)
255+
244256

245257
@property
246258
def is_resolvable(self) -> bool:

src/ttboard/util/platform.py

Lines changed: 3 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -135,14 +135,16 @@ def write_bidir_byte(val):
135135
# for bidir, all uio bits are in a line starting
136136
# at GPIO 21
137137
val = (val << 21)
138-
# xor with current GPIO values, and mask to keep only input bits
139138
val = (machine.mem32[0xd0000010] ^ val) & 0x1FE00000
140139
# val is now be all the bits that have CHANGED:
141140
# writing to 0xd000001c will flip any GPIO where a 1 is found,
142141
# only applies immediately to pins set as output
143142
machine.mem32[0xd000001c] = val
144143

145144

145+
@micropython.native
146+
def read_bidir_byte():
147+
return (machine.mem32[0xd0000004] & (0xff << 21)) >> 21
146148

147149
@micropython.native
148150
def read_bidir_outputenable():
@@ -156,11 +158,6 @@ def write_bidir_outputenable(val):
156158
val = (val << 21)
157159
machine.mem32[0xd0000020] = (machine.mem32[0xd0000020] & ((1 << 21) - 1)) | val
158160

159-
@micropython.native
160-
def read_bidir_byte():
161-
# just read the high and low nibbles from GPIO and combine into a byte
162-
return (machine.mem32[0xd0000004] & (0xff << 21)) >> 21
163-
164161
@micropython.native
165162
def write_output_byte(val):
166163
# low level machine stuff

0 commit comments

Comments
 (0)