3 Replies Latest reply on Feb 13, 2019 8:31 PM by MuraliR_36

    I need Help I2C create sample code cybt343026

    JeRi_3276026

      Greetings.

      I have tried unsuccessfully to create a code to read an i2c slave in the kit cybt-343026-001

       

      Please, if someone can guide me towards a basic example.

      Thank you .

       

      I attach the code used.

       

      #include "wiced_hal_i2c.h"

      #include "wiced_bt_trace.h"

       

      #define I2C_SLAVE_ADDRESS (0x76)

      #define I2C_SLAVE_OPERATION_READ 0

      #define I2C_SLAVE_OPERATION_WRITE 1

       

      /* Sample code to test i2c driver */

       

       

      APPLICATION_START( )

      {

      void test_i2c_driver( void )

      {

      uint8_t data_array[] = "123456";

       

       

      /* Initializes the I2C driver and its private values. This initialization

      * sets the bus speed to 100KHz by default (I2CM_SPEED_100KHZ)*/

      wiced_hal_i2c_init( WICED_I2C_SDA_P35_SCL_P37 );

       

       

      /* current I2C bus speed */

      wiced_hal_i2c_get_speed( );

      wiced_hal_i2c_set_speed( I2CM_SPEED_100KHZ );

       

      /* Writes the given data to the I2C HW addressing a particular slave address */

      wiced_hal_i2c_write( data_array, sizeof( data_array ), I2C_SLAVE_ADDRESS);

       

       

      wiced_hal_i2c_read( data_array, sizeof( data_array ), I2C_SLAVE_ADDRESS);

      WICED_BT_TRACE( "Read bytes %s\n\r", data_array );

      }

      }