STM32 I2C Lecture 42 – Assignment: I2C interrupt APIs implementation

  • Post author:
  • Post category:Blog

 

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.

Figure 1. Code for I2C_MasterSendDataIT.

 

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.

Assignment: I2C interrupt APIs implementation
Figure 2. Comments for implementing I2C_MasterSendDataIT API.

 

After completing the I2C_MasterSendDataIT API implementation, copy the entire API, and paste it into the driver source file shown in Figure 3.

Assignment: I2C interrupt APIs implementation
Figure 3. I2C_driver.c file.

 

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.

Assignment: I2C interrupt APIs implementation
Figure 4. Code for I2C_MasterReceiveDataIT.

 

In the following article, let’s see I2C interrupt-based APIs Implementation. 

 

FastBit Embedded Brain Academy Courses

Click here: https://fastbitlab.com/course1

FastBitLab

The FastBit Embedded Brain Academy uses the power of internet to bring the online courses related to the field of embedded system programming, Real time operating system, Embedded Linux systems, etc at your finger tip with very low cost. Backed with strong experience of industry, we have produced lots of courses with the customer enrolment over 3000+ across 100+ countries.