I need Help I2C create sample code cybt343026

Tip / Sign in to post questions, reply, level up, and achieve exciting badges. Know more

cross mob
JeRi_3276026
Level 1
Level 1
First like given

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
Murali_R
Moderator
Moderator
Moderator
250 sign-ins 250 replies posted 100 solutions authored

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
Murali_R
Moderator
Moderator
Moderator
250 sign-ins 250 replies posted 100 solutions authored

Hi,

There seems to be a compilation error in the code.

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

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

0 Likes

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