📄 i2c_timing_layer.h
字号:
/**@file i2c_timing_layer.h@author Zlatan Stanojevic*/#ifndef I2C_TIMING_LAYER_H#define I2C_TIMING_LAYER_H/**This structure represents one byte to be transmitted over the I2C interface.It contains the byte itself, which may be sent or received, as well as flags which determine the behaviour of the driver when transmitting the byte.@struct I2CByte*/typedef struct{ /** If this flag is set, the driver will stop transmission after this byte generating a stop condition. */ unsigned char last_byte : 1; /** This flag specified if the byte is to be read from (=1) or written to (=0) the bus. */ unsigned char read_byte : 1; /** In case of a non-acknowledgement the driver will try retransmitting the byte rather than giving up, if this flag is set. Usually this applies only for the first (address) byte. */ unsigned char retry : 1; /** @b Sending: @a ack specifies which value to expect for acknowledgement (low=0, high=1). If the byte has been acknowledged by the receiver according to ack, the driver sets the value of ack to 1 otherwise to 0. @b Receiving: @a ack selects whether th driver should acknowledge the received byte low (ack=0) or high (ack=1). Usually the last byte in a read operation is acknowledged high to announce the transmission end to the slave. */ unsigned char ack : 1; /** If set the driver generates a @a repeated @a start @a condition before transmitting this byte. */ unsigned char restart : 1; /** If set, an external function will be called by the driver. */ unsigned char callback : 1; /** @b Sending: Contains the byte to be sent. @b Receiving: Contains the byte that has been receivied if the transmission has been successful. */ unsigned char data;} I2CByte;typedef enum{ I2CSTAT_SUCCESS, I2CSTAT_FAILURE} I2CTimingStatus;/**Don't call any of the other I2C functions before initI2C, unpredictable results may occur otherwise. * @brief Performs necessary init routines. * @param pa_iSclPin specifies which programmable flag to use as I2C @b clock line * @param pa_iSdaPin specifies which programmable flag to use as I2C @b data line * @param pa_iTimer specifies number of system timer to use for timing. * @param pa_lFrequency speifies (in Hz) at which the emulated I2C interface should run.*/void I2CInitTiming( unsigned char pa_iSclPin, unsigned char pa_iSdaPin, int pa_iTimer, unsigned long pa_lFrequency );/**Warning: This routine blocks execution until the I2C line is free.@brief Starts transmitting given transmission list.@param pa_pMsg pointer to transmission list*/void I2CTransmit( I2CByte *pa_pMsg );extern void (*pTimingCallback)( I2CTimingStatus, I2CByte * );extern unsigned char busy_flag;#endif
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -