Assignment: I2C interrupt APIs implementation
In this article, let’s implement the MasterSendDataIT API.
Assignment:
Implement the MasterSendDataIT API. For that, first, download the file shown in Figure 1, whose link is attached in the resource section, and the file name is I2C_MasterSendDataIT.c.
The I2C_MasterSendDataIT.c contains partial code, and the assignment for you is to complete the code.
There are a couple of question marks in some places of Figure 1 that you have to remove with the appropriate code. The code should be implemented according to a couple of comments mentioned.
For example, look at Figure 2. According to the comments, first, you need to implement the code to generate the start condition, then implement the code to enable the ITBUFFEN control bit, and so on.
After completing the I2C_MasterSendDataIT API implementation, copy the entire API, and paste it into the driver source file shown in Figure 3.
Steps for writing code:
- First, save all the parameters of I2C_MasterSendDataIT API into the placeholder variables of the handle structure.
- Enable a couple of interrupts, control bits.
- Exit
The ISR takes care of the data transmission, which we will implement later.
For receiving data, there is one more file called I2C_MasterReceiveDataIT.c (Figure 4). Download it and implement the code according to the comments mentioned.
The steps for writing code are similar to the I2C_MasterSendDataIT API.
In the following article, let’s see I2C interrupt-based APIs Implementation.
FastBit Embedded Brain Academy Courses
Click here: https://fastbitlab.com/course1