cancel
Showing results for 
Search instead for 
Did you mean: 

Studio Bluetooth

JeRi_3276026
New Contributor II

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 );

}

}

0 Likes
1 Solution
MuraliR_36
Moderator
Moderator

Hi,

There seems to be a compilation error in the code.

Add the header file "sparcommon.h" and your code should work fine.

View solution in original post

3 Replies
MuraliR_36
Moderator
Moderator

Hi,

There seems to be a compilation error in the code.

Add the header file "sparcommon.h" and your code should work fine.

View solution in original post

JeRi_3276026
New Contributor II

Sorry, import Spartcommon.h in my code, it dosent works

0 Likes
MuraliR_36
Moderator
Moderator

Could you please upload the screenshot of the error that you are facing along with the application files(.c and .h) so that we can debug the issue.

0 Likes