anchor.diff:    10 bit I2C1-CR1 hbis!    \ ACK enable
   
     \ Wait for bus to initialize
  -  begin i2c-busy? 0= until
  +  i2c.timeout @ begin 1- dup 0= i2c-busy? 0= or until
   ;
   
   \ debugging
  
positive.code: : i2c-ADDR? ( -- b)  1  bit i2c-SR1-flag? ;     \ ADDR bit
  : i2c-MSL? ( -- b)   0  bit I2C1-SR2 hbit@ ;    \ MSL bit
  
  : i2c-SR1-wait ( u -- ) begin dup i2c-SR1-flag? until drop ; \ Waits until SR1 meets bit mask
  : i2c-SR1-!wait ( u -- ) begin dup i2c-SR1-flag? 0= until drop ;
  
  0  bit constant i2c-SR1-SB
  1  bit constant i2c-SR1-ADDR
  
negative.code: 7  bit constant i2c-SR1-TxE
  10 bit constant i2c-SR1-AF
  
   0 bit constant i2c-SR2-MSL
  
  \ Medium level actions, no or limited status checking
  
  : i2c-start ( -- ) \ set start bit and wait for start condition
    i2c-start! i2c-SR1-SB i2c-SR1-wait ;
  
  : i2c-stop  ( -- )  i2c-stop! i2c-SR2-MSL i2c-SR2-!wait ; \ stop and wait
  
  : i2c-probe ( c -- nak ) \ Sets address and waits for ACK or NAK
    i2c-start
  