Error_t TI_I2C_WriteRead(unsigned char sla,
int num_write_bytes,
unsigned char write_data[],
int num_read_bytes,
unsigned char read_buffer[] )
{
return I2CMRead(&tfa_sI2CInst, sla,
write_data,
num_write_bytes,
read_buffer,
num_read_bytes,
NULL,
NULL);
}
{
// Configure the system frequency.
//
/*ROM_SysCtlClockSet*/SysCtlClockSet(SYSCTL_SYSDIV_5 | SYSCTL_USE_PLL | SYSCTL_XTAL_16MHZ |
SYSCTL_OSC_MAIN);
//
// Initialize the UART.
//
ConfigureUART();
//
// Clear the terminal and print the welcome message.
// The I2C3 peripheral must be enabled before use.
//
/*ROM_SysCtlPeripheralEnable*/SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C3);
/*ROM_SysCtlPeripheralEnable*/SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOD);
//
// Configure the pin muxing for I2C3 functions on port D0 and D1.
// This step is not necessary if your part does not support pin muxing.
//
/*ROM_GPIOPinConfigure*/GPIOPinConfigure(GPIO_PD0_I2C3SCL);
/*ROM_GPIOPinConfigure*/GPIOPinConfigure(GPIO_PD1_I2C3SDA);
//
// Select the I2C function for these pins. This function will also
// configure the GPIO pins pins for I2C operation, setting them to
// open-drain operation with weak pull-ups. Consult the data sheet
// to see which functions are allocated per pin.
//
GPIOPinTypeI2CSCL(GPIO_PORTD_BASE, GPIO_PIN_0);
/*ROM_GPIOPinTypeI2C*/GPIOPinTypeI2C(GPIO_PORTD_BASE, GPIO_PIN_1);
HWREG(GPIO_PORTD_BASE + GPIO_O_PUR) = 0x3;
//
//Initial the GPIO for LED
//
/*ROM_SysCtlPeripheralEnable*/SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOF);
/*ROM_GPIOPinTypeGPIOOutput*/GPIOPinTypeGPIOOutput(GPIO_PORTF_BASE, GPIO_PIN_1);
/*ROM_GPIOPinWrite*/GPIOPinWrite(GPIO_PORTF_BASE, GPIO_PIN_1, 0x00);
//
/*ROM_IntMasterEnable*/IntMasterEnable();
//
// Initialize I2C3 peripheral.
//
I2CMInit(&tfa_sI2CInst, I2C3_BASE, INT_I2C3, 0xff, 0xff,
/*ROM_SysCtlClockGet*/SysCtlClockGet());
I2CMasterInitExpClk(I2C3_BASE, SysCtlClockGet(),true/*true*/);//400KBps
Then calling my function
TI_I2C_WriteRead() like
TI_I2C_WriteRead(slave_address,
sizeof(write_data), write_data, sizeof(read_buffer), read_buffer);
}
However saw read from I2C is not rerturning correct value , is this function useful ? if no, any other possible function to read/write buffer from/To I2C ?
Any idea please ?
Maw,