This section describes the programming interface of the LPI2C Cortex Microcontroller Software Interface Standard (CMSIS) driver. And this driver defines generic peripheral driver interfaces for middleware making it reusable across a wide range of supported microcontroller devices. The API connects microcontroller peripherals with middleware that implements for example communication stacks, file systems, or graphic user interfaces. More information and usage methord see http://www.keil.com/pack/doc/cmsis/Driver/html/index.html.
The LPI2C CMSIS driver includes transactional APIs.
Transactional APIs are transaction target high-level APIs. The transactional APIs can be used to enable the peripheral quickly and also in the application if the code size and performance of transactional APIs satisfy the requirements. If the code size and performance are critical requirements, see the transactional API implementation and write custom code accessing the hardware registers.
void I2C_MasterSignalEvent_t(uint32_t event)
{
if (event == ARM_I2C_EVENT_TRANSFER_DONE)
{
g_MasterCompletionFlag = true;
}
}
Driver_I2C0.Initialize(I2C_MasterSignalEvent_t);
Driver_I2C0.PowerControl(ARM_POWER_FULL);
Driver_I2C0.Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_STANDARD);
Driver_I2C0.MasterTransmit(I2C_MASTER_SLAVE_ADDR, g_master_buff, I2C_DATA_LENGTH, false);
while (!g_MasterCompletionFlag)
{
}
g_MasterCompletionFlag = false;
void I2C_MasterSignalEvent_t(uint32_t event)
{
if (event == ARM_I2C_EVENT_TRANSFER_DONE)
{
g_MasterCompletionFlag = true;
}
}
EDMA_Init(EXAMPLE_LPI2C_DMA_BASEADDR, &edmaConfig);
Driver_I2C0.Initialize(I2C_MasterSignalEvent_t);
Driver_I2C0.PowerControl(ARM_POWER_FULL);
Driver_I2C0.Control(ARM_I2C_BUS_SPEED, ARM_I2C_BUS_SPEED_STANDARD);
Driver_I2C0.MasterReceive(I2C_MASTER_SLAVE_ADDR, g_master_buff, I2C_DATA_LENGTH, false);
while (!g_MasterCompletionFlag)
{
}
g_MasterCompletionFlag = false;
void I2C_SlaveSignalEvent_t(uint32_t event)
{
if (event == ARM_I2C_EVENT_TRANSFER_DONE)
{
g_SlaveCompletionFlag = true;
}
}
Driver_I2C1.Initialize(I2C_SlaveSignalEvent_t);
Driver_I2C1.PowerControl(ARM_POWER_FULL);
Driver_I2C1.Control(ARM_I2C_OWN_ADDRESS, I2C_MASTER_SLAVE_ADDR);
Driver_I2C1.SlaveReceive(g_slave_buff, I2C_DATA_LENGTH);
while (!g_SlaveCompletionFlag)
{
}
g_SlaveCompletionFlag = false;