Interface Programming Information and Examples
CYW920706WCDEVAL Hardware User Guide Doc. No.: 002-16535 Rev. **
40
*/
uint8_t test_spiffy1_slave_send_receive_byte( void )
{
uint8_t byteReceived;
/* Rx one byte of data */
wiced_hal_pspi_rx_data( 1, &byteReceived );
/* Send back byteRe 1 */
byteR+;
/* Tx one byte of data */
wiced_hal_pspi_tx_data( 1, &byteReceived );
}
10.4 BSC Programming Example
The following example shows how to initialize the BSC as a master, and how to write, read, and use the combination write-
then-read transactions.
#include "wiced_hal_i2c.h"
#define I2C_SLAVE_ADDRESS (0x1A) /* Use driver slave address 0x1A =
* (7'b0001101 << 1) | 1'bR|W */
#define I2C_SLAVE_OPERATION_READ 0 /* Read operation to the lower level
* driver is 0 */
#define I2C_SLAVE_OPERATION_WRITE 1 /* Write operation to the lower
* level driver is 1 */
/* Sample code to test i2c driver */
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( );
/* current I2C bus speed */
wiced_hal_i2c_get_speed( );
/* Sets the I2C bus speed
*(I2CM_SPEED_100KHZ/ I2CM_SPEED_400KHZ/ I2CM_SPEED_800KHZ/ I2CM_SPEED_1000KHZ)*/
wiced_hal_i2c_set_speed( I2CM_SPEED_400KHZ );
/* 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);
/* Reads data into given buffer from the I2C HW addressing
* a particular slave address */
wiced_hal_i2c_read( data_array, sizeof( data_array ), I2C_SLAVE_ADDRESS);
WICED_BT_TRACE( "Read bytes %s\n\r", data_array );
}