1 Reply Latest reply on Feb 8, 2016 10:07 AM by rob.woolley

    [I2C] How to control start/stop I2C events ?


      Hello there,


      As mentioned in my other thread, I am working with an Adafruit 7-segment display. It is supported by the corresponding Arduino library, which I am adapting/rewriting in C since there is no C++ support yet in Rocket.


      The library makes use of the Arduino Wire library and in doing so, controls the START and STOP events on the I2C bus using constructs like {begin,end}Transmission :

      void Adafruit_LEDBackpack::writeDisplay(void) {
        Wire.write((uint8_t)0x00); // start at address $00
        for (uint8_t i=0; i<8; i++) {
        Wire.write(displaybuffer[i] & 0xFF); 
        Wire.write(displaybuffer[i] >> 8); 


      Following the Rocket doc, I have been using the corresponding i2c_polling_write API (sorry, I cannot find any publicly available Rocket API via an Intel search engine query, I can only find it on the Helix App Cloud but this requires a login). It took me some time (and a logic analyzer) to figure out that it sends the START and STOP events for each transaction, which is not what my hardware expects). I am thus now using a single buffer and a single API call to do the transfer, which appear to work fine :

      void bp_writeDisplay(void) {
        uint8_t buf[17] = {0};
        uint8_t idx = 1;
        buf[0] = 0x00;
        for (uint8_t i=0; i<=8; i++) {
          buf[idx] = displaybuffer[i] & 0xFF;
          buf[idx] = displaybuffer[i] >> 8;
        i2c_polling_write(i2c, buf, sizeof (buf), i2c_addr);

      This is however pretty tedious, as all content has to be transferred into a temporary buffer before the i2c API is called.


      Is there a way to work similarly to the Wire library APIs (API for start, simple send API, API for stop)?


      2016-02-01 edit: my approach definitely works since I now have the display working and the Adafruit demo code running on Rocket. I am still however interested in the answer since that would allow a quicker adaptation of Arduino libraries.