Hi, Everyone
I need your help. I want to use I2C with FIFO on TM4C129x. but I do not understand FIFO Operation.
I try to loopback mode. How to store data to TX FIFO and How to get data from RX FIFO.
Tivaware has I2CFIFODataGet(). but it can get only single byte.
I do not understand this operation.
===================================
int main(void)
{ uint8_t ui8DataTx[8];
SysCtlClockFreqSet((SYSCTL_XTAL_25MHZ |SYSCTL_OSC_MAIN | SYSCTL_USE_PLL | SYSCTL_CFG_VCO_480), 120000000);
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C0);
SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOB);
GPIOPinConfigure(GPIO_PB2_I2C0SCL);
GPIOPinConfigure(GPIO_PB3_I2C0SDA);
GPIOPinTypeI2CSCL(GPIO_PORTB_BASE, GPIO_PIN_2);
GPIOPinTypeI2C(GPIO_PORTB_BASE, GPIO_PIN_3);
HWREG(I2C0_BASE + I2C_O_MCR) |= 0x01;
IntEnable(INT_I2C0);
I2CSlaveIntEnableEx(I2C0_BASE, I2C_SLAVE_INT_RX_FIFO_FULL);
I2CMasterInitExpClk(I2C0_BASE, SysCtlClockGet(), false);
I2CSlaveEnable(I2C0_BASE);
I2CSlaveInit(I2C0_BASE, SLAVE_ADDRESS);
I2CMasterSlaveAddrSet(I2C0_BASE, SLAVE_ADDRESS, false);
I2CSlaveIntEnable(I2C0_BASE);
//Tx FIFO Config
I2CTxFIFOConfigSet(I2C0_BASE, I2C_FIFO_CFG_TX_MASTER|I2C_FIFO_CFG_TX_TRIG_8); I2CRxFIFOConfigSet(I2C0_BASE, I2C_FIFO_CFG_RX_SLAVE|I2C_FIFO_CFG_RX_TRIG_8); I2CSlaveFIFOEnable(I2C0_BASE,I2C_SLAVE_RX_FIFO_ENABLE);
// // Enable interrupts to the processor. //
IntMasterEnable();
// // Initialize the data to send. //
ui8DataTx[0] = 0x11;
ui8DataTx[1] = 0x22;
ui8DataTx[2] = 0x33;
ui8DataTx[3] = 0x44;
ui8DataTx[4] = 0x55;
ui8DataTx[5] = 0x66;
ui8DataTx[6] = 0x77;
ui8DataTx[7] = 0x88;
I2CFIFODataPut(I2C0_BASE,ui8DataTx[0]);
I2CFIFODataPut(I2C0_BASE,ui8DataTx[1]);
I2CFIFODataPut(I2C0_BASE,ui8DataTx[2]);
I2CFIFODataPut(I2C0_BASE,ui8DataTx[3]);
I2CFIFODataPut(I2C0_BASE,ui8DataTx[4]);
I2CFIFODataPut(I2C0_BASE,ui8DataTx[5]);
I2CFIFODataPut(I2C0_BASE,ui8DataTx[6]);
I2CFIFODataPut(I2C0_BASE,ui8DataTx[7]);
I2CMasterControl(I2C0_BASE, I2C_MASTER_CMD_FIFO_BURST_SEND_START);
while( I2CMasterBusy(I2C0_BASE));
// // Loop forever. //
while(1) { } }
void I2C0SlaveIntHandler(void)
{
// // Clear the I2C0 interrupt flag. //
I2CSlaveIntClear(I2C0_BASE);
// // Read the data from the slave. // //
I2CFIFODataGetNonBlocking(I2C0_BASE,&g_ui8DataRx);
}
============================
Best Regards
Hiroyasu