i2c 通信用のラッパー ファイルをいくつか生成しています。これらは C で書かれています。
ヘッダー ファイルは次のようになります。
#ifndef IMX6QI2C_WRAPPER_H_
#define IMX6QI2C_WRAPPER_H_
#include <linux/i2c-dev.h> //contains definitions for:
struct i2c_msg
struct i2c_rdwr_ioctl_data
//fn declarations
#endif /* IMX6QI2C_WRAPPER_H_ */
ソース ファイルには次が含まれます。
#include "imx6qi2c_wrapper.h"
#include <stdio.h> //printf()
#include <unistd.h> //for close()
#include <string.h> //for MANY implicit decl. & -Wformat errs
#include <sys/types.h> //open()
#include <sys/stat.h> //open()
#include <fcntl.h> //open(),O_RDWR
#include <sys/ioctl.h> //ioctl()
#include <errno.h> //errno,strerror()
#define I2CMSGS_TOTAL_WR 1
#define I2CMSGS_TOTAL_RD 2
#define I2C_M_WR 0x00 //missing from i2c_msg flags
int imxSend_i2cMsg(const int i2c_fd,
struct i2c_msg *i2cMsgArray,
const unsigned int arraySize){
//do stuff
}
int imxSend_i2cByte(const int i2c_fd,
const unsigned char i2cAddress,
const unsigned char devRegister,
const unsigned char value){
struct i2c_msg i2cmsg[2];
//do stuff
ret=imxSend_i2cMsg(i2c_fd,&i2cmsg,I2CMSGS_TOTAL_WR);
//do more stuff
}
現在、コンパイラは「imxSend_i2cMsg()」の定義で問題ありませんstruct i2c_msg *i2cMsgArray
。
struct i2c_msg i2cmsg[2]
しかし、関数「imxSend_i2cByte()」のローカル変数の宣言に問題があります。
エラーは次のとおりです:「配列型には不完全な要素型があります」。
そして、私は不思議に思っています。
#include ディレクティブに関連している可能性がありますか? 私の例でi2c-dev.h
は、「struct i2c_msg」の定義が含まれており、#include されてi2c_wrapper.h
おり、後者がi2c_wrapper.c
ファイルに含まれています。私の理解では、これはソースファイルが実際に「struct i2c_msg」を「見る」ことができることを意味します。いいえ?
stackoverflow で何度もこの質問を見てきましたが、答えはまだ明らかではありません。誰かが私を正しい方向に向けることができますか?
ご協力ありがとうございました。