各位用过的说说怎么设置,我设置的没有反应。
SysCtlPeripheralEnable(SYSCTL_PERIPH_I2C1); SysCtlPeripheralReset(SYSCTL_PERIPH_I2C1); SysCtlPeripheralEnable(SYSCTL_PERIPH_GPIOJ); GPIOPinConfigure(GPIO_PJ0_I2C1SCL); GPIOPinConfigure(GPIO_PJ1_I2C1SDA); GPIOPinTypeI2C(GPIO_PORTJ_BASE, GPIO_PIN_0 | GPIO_PIN_1); i2c = (LM3SXXXX_STRUCT_I2C *)LM3SXXXX_BASE_I2C1_MASTER; //HWREG(I2C1_MASTER_BASE + I2C_O_MCR) |= 0x01; // Loopback mode I2CMasterInitExpClk(I2C1_MASTER_BASE, SysCtlClockGet(), false);// 100K I2CMasterSlaveAddrSet(I2C1_MASTER_BASE, 0x90, false ); I2CMasterEnable(I2C1_MASTER_BASE); // set for read TMP275 I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_SINGLE_SEND); I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_START); I2CMasterDataPut(I2C1_MASTER_BASE, 0x01); I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_CONT); I2CMasterDataPut(I2C1_MASTER_BASE, 0x60); I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_FINISH); I2CMasterDisable(I2C1_MASTER_BASE);
读的时候是:
I2CMasterEnable(I2C1_MASTER_BASE); I2CMasterSlaveAddrSet(I2C1_MASTER_BASE, 0x90, false); I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_SINGLE_SEND); I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_SEND_START); I2CMasterDataPut(I2C1_MASTER_BASE, 0x00); I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH); I2CMasterSlaveAddrSet(I2C1_MASTER_BASE, 0x91, false); I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_SINGLE_RECEIVE); I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_RECEIVE_START); TempDataBuf[0] = I2CMasterDataGet(I2C1_MASTER_BASE); I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_RECEIVE_CONT); TempDataBuf[1] = I2CMasterDataGet(I2C1_MASTER_BASE); I2CMasterControl(I2C1_MASTER_BASE, I2C_MASTER_CMD_BURST_RECEIVE_FINISH); I2CMasterDisable(I2C1_MASTER_BASE);
|