Hi Dialog.
I use DA14580 with SDK 5.0.3
I need to communicate by I2C communication with Accelerometer device LIS2DH12 (very similar to LIS3DH) .
I see that I2C driver from SDK for EEPROM uses poling section with GLOBAL INTERRUPT disabled in it.
Do you have I2C master driver example with intterupt work method?
Thanks a lot!
Device:
I have one more question:
Why does need to disable interrupt when we read data from I2C?
我的意思是这个函数:read_data_single I2C_e ()eprom.c driver:
static void read_data_single(uint8_t **p, uint32_t address, uint32_t size)
{
int j;
i2c_send_address(address);
for (j = 0; j < size; j++)
{
WAIT_WHILE_I2C_FIFO_IS_FULL(); // Wait if Tx FIFO is full
SEND_I2C_COMMAND(0x0100); // Set read access for times
}
// Critical section
GLOBAL_INT_DISABLE();
// Get the received data
for (j = 0; j < size; j++)
{
WAIT_FOR_RECEIVED_BYTE(); // Wait for received data
**p =(0xFF & GetWord16(I2C_DATA_CMD_REG)); // Get the received byte
(*p)++;
}
// End of critical section
GLOBAL_INT_RESTORE();
}
Hi Vadym,
No, currently there is no official relase of a driver on the I2C that works with interrupts.
On the following post i ve made some modifications on the I2C driver in order to work with interrupts so that more than 32 bytes to be transfered without start and stop signals, perhaps you will find it usefull.
https://support.dialog-semiconductor.com/i2c-data-transfer-size
Regarding the second post, there were some inconsistencies regarding this version of the driver, please check the new version of the read_data_single() in the new SDK. In the new version of the SDK the critical section has moved to the upper part of the function - the part where clock is applied to the i2c slave should be interrupt protected and not when reading the bytes from the FIFO. The reason for disabling the interrupts is in order to prevent an I2C termination between address and data in case of an interrupt.
Thanks MT_dialog