STM32 I2C Lecture 30 – Assignment: I2C master receive data API implementation.

  • Post author:
  • Post category:Blog

 

Assignment: I2C master receive data API implementation

 

 


In this article, let’s implement the I2C master receive data. The parameters of this API are similar to the master TX API, or master send data API, as shown in Figure 1.

 

I2C master receive data API
Figure 1. Parameters of I2C_MasterReceiveData API.

 

Exercise:

In Figure 1, you can observe a couple of comments, according to which code is written for the master to receive the data from the slave. Here the comments describe what exactly you have to do.

For example, in the first case, write the code to call the corresponding API or function. Then, confirm the start generation’s completion, which is exactly similar to what you did to send data API.

There are two sections in I2C_MasterReceiveData API, as shown in Figure 2.

  1. Procedure to receive data when the length is equal to 1.
  2. Procedure to receive data when the length is greater than 1.

 

I2C master receive data API
Figure 2. Code to read data based on the length of the data to be received.

Look at Figure 2. There are several comments written inside each section, according to which you have to write the code.

 

In the following article, let’s implement the I2C master receive data API.

 

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.