frame

I2C Clock Stretching

Hi

I'm trying to implement a driver for the Adafruit BDO055 9DOF Absolute Orientation sensor board to work with a viperised Photon.

The BDO055 sensor requires Clock Stretching to work with I2C correctly. 

I can see from the original Particle Photon documentation that Clock Stretching was part of the I2C functionality (Wire.stretchClock(stretch) 

Is this functionality available within the Zerynth Photon Python VM implementation? 
Tagged:

Comments

  • LorenzoRLorenzoR Member, Moderator
    Hi andolph,

    Zerynth I2C implementation should allow by default Clock Stretching in Master mode, but since we have not tried it, are you experiencing unexpected behaviours?
    Lorenzo Rizzello
    Zerynth Support Team

  • Hi Lorenzo

    In the original photon (non python) setup, Clock Stretching has to be specifically switched 'on' using the Wire.stretchClock(stretch) instruction.

    Is it correct that Clock Stretching is 'on' by default in the Zerynth Photon?

    If not, I can't see anyway, within the Zerynth photon software implementation, of switching Clock Stretching 'on'.

    Could you suggest how this could be achieved?
  • LorenzoRLorenzoR Member, Moderator
    Hi andolph,
    from Wire.stretchClock() implementation
    void I2C_StretchClockCmd(I2C_TypeDef* I2Cx, FunctionalState NewState)
    {
    /* Check the parameters */
    assert_param(IS_I2C_ALL_PERIPH(I2Cx));
    assert_param(IS_FUNCTIONAL_STATE(NewState));
    if (NewState == DISABLE)
    {
    /* Enable the selected I2C Clock stretching */
    I2Cx->CR1 |= I2C_CR1_NOSTRETCH;
    }
    else
    {
    /* Disable the selected I2C Clock stretching */
    I2Cx->CR1 &= (uint16_t)~((uint16_t)I2C_CR1_NOSTRETCH);
    }
    }
    we see how they only clear the NOSTRETCH bit in the I2C control register when stretching is needed.
    As concerns Zerynth I2C, that bit is left to 0, so you do not have to enable it manually :)

    Let us know if something does not work anyway ;)
    Lorenzo Rizzello
    Zerynth Support Team

Sign In or Register to comment.

ZERYNTH Community

@ 2016 Zerynth.com, all rights reserved.