Implementation of I2C master sending data API:Part 5
Testing I2C MasterSendData() API:
Before testing the code, build the code to check whether we encounter any error or not.
- Save the file.
- Right-click on the project and select the build project option to build the project.
- There are a couple of errors, as shown in Figure 1.
The problem is with the I2C driver.h, there are no include guards. The include guards prevent the inclusion of multiple definitions during the preprocessor stage of the compilation. It prevents the multiple inclusion of the header file contents. Whenever you create a header file, the include guards will be added automatically by the eclipse. But for I2C, there are no include guards. If you face the same problem, then add the no include guards in the I2C driver.h file, as shown in Figure 2. At the end of the program, add #endif.
- Compile once again. There is another error called redefinition of dummyRead. Remove the redefinition shown in Figure 3.
- Then compile once again, now the code is compiled successfully (Figure 4).
FastBit Embedded Brain Academy Courses