各位大侠,我在学习I2C模块的编程,我对头文件中的一个定义的结构体弄不明白,关键是源程序中的MsgStatus变量包含的各种状态,我实在弄不明白这是什么意思,希望大家指导一下:
结构体为:
struct I2CMSG {
uint16 MsgStatus; // Word stating what state msg is in:
// I2C_MSGCMD_INACTIVE = do not send msg
// I2C_MSGCMD_BUSY = msg start has been sent,
// awaiting stop
// I2C_MSGCMD_SEND_WITHSTOP = command to send
// master trans msg complete with a stop bit
// I2C_MSGCMD_SEND_NOSTOP = command to send
// master trans msg without the stop bit
// I2C_MSGCMD_RESTART = command to send a restart
// as a master receiver with a stop bit
uint16 SlaveAddress; // I2C address of slave msg is intended for
uint16 NumOfBytes; // Num of valid bytes in (or to be put in MsgBuffer)
uint16 MemoryAddr; // RTC address of data associated with msg (low byte)
uint16 MsgBuffer[I2C_MAX_BUFFER_SIZE]; // Array holding msg data – max that
// MAX_BUFFER_SIZE can be is 16 due to
// the FIFO's
};
这些是MsgStatus指向的各种状态变量,到底是跟I2C模块是怎样的关系,我应该在哪查到这些变量,希望大家帮我指导一下:
// I2C Message Commands for I2CMSG struct
#define I2C_MSGSTAT_INACTIVE 0x0000
#define I2C_MSGSTAT_SEND_WITHSTOP 0x0010
#define I2C_MSGSTAT_WRITE_BUSY 0x0011
#define I2C_MSGSTAT_SEND_NOSTOP 0x0020
#define I2C_MSGSTAT_SEND_NOSTOP_BUSY 0x0021
#define I2C_MSGSTAT_RESTART 0x0022
#define I2C_MSGSTAT_READ_BUSY 0x0023
希望大家能帮我解决这个疑惑点,谢谢了!
囧:
这个是对应I2C寄存器的,看一下I2C的那个userguide就知道了
各位大侠,我在学习I2C模块的编程,我对头文件中的一个定义的结构体弄不明白,关键是源程序中的MsgStatus变量包含的各种状态,我实在弄不明白这是什么意思,希望大家指导一下:
结构体为:
struct I2CMSG {
uint16 MsgStatus; // Word stating what state msg is in:
// I2C_MSGCMD_INACTIVE = do not send msg
// I2C_MSGCMD_BUSY = msg start has been sent,
// awaiting stop
// I2C_MSGCMD_SEND_WITHSTOP = command to send
// master trans msg complete with a stop bit
// I2C_MSGCMD_SEND_NOSTOP = command to send
// master trans msg without the stop bit
// I2C_MSGCMD_RESTART = command to send a restart
// as a master receiver with a stop bit
uint16 SlaveAddress; // I2C address of slave msg is intended for
uint16 NumOfBytes; // Num of valid bytes in (or to be put in MsgBuffer)
uint16 MemoryAddr; // RTC address of data associated with msg (low byte)
uint16 MsgBuffer[I2C_MAX_BUFFER_SIZE]; // Array holding msg data – max that
// MAX_BUFFER_SIZE can be is 16 due to
// the FIFO's
};
这些是MsgStatus指向的各种状态变量,到底是跟I2C模块是怎样的关系,我应该在哪查到这些变量,希望大家帮我指导一下:
// I2C Message Commands for I2CMSG struct
#define I2C_MSGSTAT_INACTIVE 0x0000
#define I2C_MSGSTAT_SEND_WITHSTOP 0x0010
#define I2C_MSGSTAT_WRITE_BUSY 0x0011
#define I2C_MSGSTAT_SEND_NOSTOP 0x0020
#define I2C_MSGSTAT_SEND_NOSTOP_BUSY 0x0021
#define I2C_MSGSTAT_RESTART 0x0022
#define I2C_MSGSTAT_READ_BUSY 0x0023
希望大家能帮我解决这个疑惑点,谢谢了!
Jason Wu4:
I2CMSG是便于I2C模块操作时定义的结构体,数据传输过程中,定义该结构体变量,即可通过指针传递与I2C底层寄存器进行数据交互,底层寄存器建议参考Reference Guide。
各位大侠,我在学习I2C模块的编程,我对头文件中的一个定义的结构体弄不明白,关键是源程序中的MsgStatus变量包含的各种状态,我实在弄不明白这是什么意思,希望大家指导一下:
结构体为:
struct I2CMSG {
uint16 MsgStatus; // Word stating what state msg is in:
// I2C_MSGCMD_INACTIVE = do not send msg
// I2C_MSGCMD_BUSY = msg start has been sent,
// awaiting stop
// I2C_MSGCMD_SEND_WITHSTOP = command to send
// master trans msg complete with a stop bit
// I2C_MSGCMD_SEND_NOSTOP = command to send
// master trans msg without the stop bit
// I2C_MSGCMD_RESTART = command to send a restart
// as a master receiver with a stop bit
uint16 SlaveAddress; // I2C address of slave msg is intended for
uint16 NumOfBytes; // Num of valid bytes in (or to be put in MsgBuffer)
uint16 MemoryAddr; // RTC address of data associated with msg (low byte)
uint16 MsgBuffer[I2C_MAX_BUFFER_SIZE]; // Array holding msg data – max that
// MAX_BUFFER_SIZE can be is 16 due to
// the FIFO's
};
这些是MsgStatus指向的各种状态变量,到底是跟I2C模块是怎样的关系,我应该在哪查到这些变量,希望大家帮我指导一下:
// I2C Message Commands for I2CMSG struct
#define I2C_MSGSTAT_INACTIVE 0x0000
#define I2C_MSGSTAT_SEND_WITHSTOP 0x0010
#define I2C_MSGSTAT_WRITE_BUSY 0x0011
#define I2C_MSGSTAT_SEND_NOSTOP 0x0020
#define I2C_MSGSTAT_SEND_NOSTOP_BUSY 0x0021
#define I2C_MSGSTAT_RESTART 0x0022
#define I2C_MSGSTAT_READ_BUSY 0x0023
希望大家能帮我解决这个疑惑点,谢谢了!
user4244115:
回复 Jason Wu4:
您好,Reference Guide在哪里下载?
各位大侠,我在学习I2C模块的编程,我对头文件中的一个定义的结构体弄不明白,关键是源程序中的MsgStatus变量包含的各种状态,我实在弄不明白这是什么意思,希望大家指导一下:
结构体为:
struct I2CMSG {
uint16 MsgStatus; // Word stating what state msg is in:
// I2C_MSGCMD_INACTIVE = do not send msg
// I2C_MSGCMD_BUSY = msg start has been sent,
// awaiting stop
// I2C_MSGCMD_SEND_WITHSTOP = command to send
// master trans msg complete with a stop bit
// I2C_MSGCMD_SEND_NOSTOP = command to send
// master trans msg without the stop bit
// I2C_MSGCMD_RESTART = command to send a restart
// as a master receiver with a stop bit
uint16 SlaveAddress; // I2C address of slave msg is intended for
uint16 NumOfBytes; // Num of valid bytes in (or to be put in MsgBuffer)
uint16 MemoryAddr; // RTC address of data associated with msg (low byte)
uint16 MsgBuffer[I2C_MAX_BUFFER_SIZE]; // Array holding msg data – max that
// MAX_BUFFER_SIZE can be is 16 due to
// the FIFO's
};
这些是MsgStatus指向的各种状态变量,到底是跟I2C模块是怎样的关系,我应该在哪查到这些变量,希望大家帮我指导一下:
// I2C Message Commands for I2CMSG struct
#define I2C_MSGSTAT_INACTIVE 0x0000
#define I2C_MSGSTAT_SEND_WITHSTOP 0x0010
#define I2C_MSGSTAT_WRITE_BUSY 0x0011
#define I2C_MSGSTAT_SEND_NOSTOP 0x0020
#define I2C_MSGSTAT_SEND_NOSTOP_BUSY 0x0021
#define I2C_MSGSTAT_RESTART 0x0022
#define I2C_MSGSTAT_READ_BUSY 0x0023
希望大家能帮我解决这个疑惑点,谢谢了!
Jason Wu4:
回复 user4244115:
http://www.ti.com.cn/cn/lit/ug/sprug03b/sprug03b.pdf