We have light!! P1 I2C driver questions and PASM
I've been working on my own P1 I2C driver based on JonnyMac's I2C demos for P2. I'm attempting to drive14 segment LEDs using a HT16K33 in an adafruit feather. And finally tonight, we have light! lol
In P2, JonnyMac called a method which included PASM code (see below). Is there a way to do something equivalent in P1 where I can call different PASM subroutines? Based on the command or data I'm writing with the HT16K33, I need flexibility to write a different number of bytes.
Can I have multiple DAT structures with a different ORG followed by a number? I've only ever seen P1 code with 1 DAT PASM code. I've attached my P1 driver.
JonnyMac's driver for I2C write in P2
pub write(i2cbyte) : ackbit | scl, sda, tix, bits '' Write byte to I2C bus '' -- leaves SCL low longmove(@scl, @sclpin, 3) ' copy pins & timing org shl i2cbyte, #24 ' align i2cbyte. to i2cbyte. .wr_byte mov bits, #8 ' output 8 bits, msbfirst .wb0 shl i2cbyte, #1 wc ' msb --> c drvc sda ' c -- sda waitx tix ' let sda settle drvh scl ' scl high testp scl wc ' check for clock stretch if_nc jmp #$-2 waitx tix waitx tix drvl scl ' scl low waitx tix djnz bits, #.wb0 .get_ack drvh sda ' pull-up sda waitx tix drvh scl ' scl high testp scl wc ' check for clock stretch if_nc jmp #$-2 waitx tix testp sda wc ' sample sda (ack bit) muxc ackbit, #1 ' update return value waitx tix drvl scl ' scl low waitx tix waitx tix end
HT16K33 has different length for a COMMAND and READ/WRITE.