SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C1); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOG);
GPIOPinConfigure(GPIO_PG0_I2C1SCL);
GPIOPinConfigure(GPIO_PG1_I2C1SDA);
GPIOPinTypeI2C(GPIO_PORTG_BASE, GPIO_PIN_1);
GPIOPinTypeI2CSCL(GPIO_PORTG_BASE, GPIO_PIN_0);
I2CMasterEnable(I2C1_BASE);
IntEnable(I2C_INT_MASTER);
I2CMasterIntEnable(I2C1_BASE);
IntMasterEnable();
I2CMasterInitExpClk(I2C1_BASE, 40000000, false);
I2CMasterSlaveAddrSet(I2C1_BASE, SLAVE_ADDRESS,false);
I2CMasterDataPut(I2C1_BASE, WRITE_ADDRESS);
I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_START);
while(I2CMasterBusy(I2C1_BASE));
for(i = 0;i < DataNum;i++ )
{
I2CMasterDataPut(I2C1_BASE, DataTx[i]);
i == DataNum - 1 ?
I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH):
I2CMasterControl(I2C1_BASE, I2C_MASTER_CMD_BURST_SEND_CONT);
while(I2CMasterBusy(I2C1_BASE));//到这里卡死
}
怎么回事啊??一直主机忙状态。
此帖出自
小平头技术问答
一周热门 更多>