I2C IRQ handler implementation Part 7
In this article, let’s learn about the creation of some I2C application events. In the I2C event IRQ handling, we have used the macros for different events (Figure 1), which is not yet created. If you don’t define these macros, then the compiler will issue errors.
Go to the I2C header file and create I2C application event macros, as shown in Figure 2.
The events we are going to generate from the I2C driver is as follows:
- I2C_EV_TX_CMPLT
- I2C_EV_STOP
- I2C_EV_RX_CMPLT
Build the project to check whether there are any errors or not (Figure 3).
Look at the results of the compilation (Figure 4). There are a couple of problems. Now let’s solve them one by one.
- We have changed the prototype of the I2C_ClearADDRFlag(). The parameter of this function is changed to an I2C pointer variable. But we didn’t apply these changes to the function call of I2C_ClearADDRFlag() in the driver code. That’s why the compiler issues some errors, as shown in Figure 4. Now let’s go to the I2C driver and search for I2C_ClearADDRFlag (Figure 5). Here the parameter is no longer a base address; therefore, change it to a pointer to the handle, as shown in Figure 6.
- Implicit declaration of I2C_CloseReceiveData: Compiler will issue this error since we have not yet implemented I2C_CloseReceiveData() function.
- I2CHandle undeclared: The I2CHandle is not a variable; it is a pointer. Therefore, replace I2CHandle with pI2CHandle everywhere in your program (Figure 7).
Again, build the project. Now the code builds successfully. But we have 2 more functions to implement (Figure 8) that is I2C_CloseReceiveData and I2C_CloseSendData.