- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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 );
}
}
Solved! Go to Solution.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
There seems to be a compilation error in the code.
Add the header file "sparcommon.h" and your code should work fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Hi,
There seems to be a compilation error in the code.
Add the header file "sparcommon.h" and your code should work fine.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
Sorry, import Spartcommon.h in my code, it dosent works
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
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.