Implementation of I2C master sending data API:Part 2
Creation of I2C related status flags definitions section to define flag macros:
Instead of writing I2C_TXE_FLAG, write the flag name followed by the flag, as shown in Figure 1. In this case, the flag name is TXE. Naming like this will be helpful because while coding, if we just type I2C_FLAG, then the eclipse will list all the options which are preceding with the word I2C_FLAG.
Let’s use a similar naming convention for the flag macros. Create the definitions for all the flags, as shown in Figure 2.
The master has to wait till the I2C_GetFlagStatus function returns 1. The while statement is used for this purpose, as shown in Figure 3.
Implement I2C_GetFlagStatus () in the I2C driver.c file, as shown in Figure 4.
FastBit Embedded Brain Academy Courses