Code: Select all
@asm_pio( set_init=rp2.PIO.OUT_LOW )
def prog():
if_( x )
set( pins, 1 )
else_()
set( pins, 0 )
endif_()
Code: Select all
def if_( self, cond ):
if self.pass_ == 0:
self.ifs[-1]["if"] = (cond, self.num_instr)
else:
cond = self.ifs[-1]["if"][0]
instr= self.ifs[-1]["if"][1]
if( self.ifs[-1]["elif"] ):
instr = self.ifs[-1]["elif"][1]
elif( self.ifs[-1]["else"] ):
instr = self.ifs[-1]["else"][1]
elif( self.ifs[-1]["end_if"] ):
instr = self.ifs[-1]["end_if"][1]
self.word( 0x0000 | cond << 5 | instr )
def elif_( self, cond ):
...
def else_( self ):
...
def endif_( self ):
...
_pio_funcs:
# if condition constants
"_x": 1,
"_not_x_dec": 2,
"_y": 3,
"_not_y_dec": 4,
"_x_eq_y": 5,
"_not_pin": 6,
"_osre": 7,
# functions
...
"if_": None,
"elif_": None,
"else_": None,
"endif_": None,