📄 i2cbus.cpp
字号:
/* List : Depend of the conversion card plugged on the parallel data port */
/* Example : #define CNST_BITN_LPTP_WSCL 2 */
/******************************************************************************/
#define CNST_BITN_LPTP_WSCL 2
/*** CNST_BITN_LPTP_RSDA ******************************************************/
/* Purpose : Bit number of the SDA line on the read port */
/* Unit : Bit Number */
/* Range : [0-7] - LIMITED selection */
/* List : Depend of the conversion card plugged on the parallel dat port */
/* Example : #define CNST_BITN_LPTP_RSDA 4 */
/******************************************************************************/
#define CNST_BITN_LPTP_RSDA 4
/*** CNST_BITN_LPTP_RSCL ******************************************************/
/* Purpose : Bit number of the SCL line on the read port */
/* Unit : Bit Number */
/* Range : [0-7] - LIMITED selection */
/* List : Depend of the conversion card plugged on the parallel dat port */
/* Example : #define CNST_BITN_LPTP_RSCL 5 */
/******************************************************************************/
#define CNST_BITN_LPTP_RSCL 5
/*** CNST_ADDR_I2CM_DISP ******************************************************/
/* Purpose : I2C module address for the displayer */
/* Unit : None */
/* Range : Mem ADDR - FREE selection */
/* List : Depend on the displayer module configuration */
/* Example : #define CNST_ADDR_I2CM_DISP 0x070 */
/******************************************************************************/
#define CNST_ADDR_I2CM_DISP 0x070
/*** CNST_ADDR_I2CM_CLOCK *****************************************************/
/* Purpose : I2C module address for the Real-Time Clock */
/* Unit : None */
/* Range : Mem ADDR - FREE selection */
/* List : Depend on the RTC module configuration */
/* Example : #define CNST_ADDR_I2CM_CLOCK 0x0A2 */
/******************************************************************************/
#define CNST_ADDR_I2CM_CLOCK 0x0A2
/*/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\*/
/*\ DEFINITION DE 'CLASS' /*/
/*/ \*/
/*\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/*/
class FluxI2C
{
private: // Ne peut qu'etre utilise que dans FluxI2C
// Les 'Caracteristiques' d'un FluxI2C ///////////////////////////////
char FI2C_LPT_DATA;
int FI2C_LPT_PORT;
public: // Peut etre utilise en-dehors de FluxI2C (dans main par ex)
// Les 'Constructeurs/Destructeurs' //////////////////////////////////
FluxI2C();
FluxI2C(int AskedLptPort);
~FluxI2C();
// Les 'Methodes' ////////////////////////////////////////////////////
void InitI2C(int AskedLptPort);
void PowerOffI2C(void);
int TestBusI2C(void);
void SetBitI2C(int NbBit);
void ClearBitI2C(int NbBit);
int TestBitI2C(int NbBit);
void StartI2C(void);
void StopI2C(void);
int SAcknowledgeI2C(void);
void RAcknowledgeI2C(void);
void SendI2C(char Data2Send);
char ReceiveI2C(void);
int SendI2CFlux(char SendFlux[]);
int ReceiveI2CFlux(char ReceiveFlux[]);
char CharConvert(char Caract);
};
/*/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\*/
/*\ 'CONSTRUCTEURS/DESTRUCTEURS' /*/
/*/ \*/
/*\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/*/
/*--- START FUNCTION HEADER --------------------------------------------------*/
/* Name : FluxI2C */
/* Role : Default constructor, when no parameter is given */
/* Interface : None */
/* Pre-condition : None */
/* Constraints : None */
/* Behavior : */
/* DO */
/* [Configure the parallel port LPT 1] */
/* OD */
/*----------------------------------------------------------------------------*/
/* PROC FluxI2C */
/* ( */
/* ) */
/* DATA */
/* ATAD */
/* */
/* DO */
/* [Configure the parallel port LPT 1] = */
/* DO */
/* [Call the initialisation routine for the LPT1 port] */
/* OD */
/* OD */
/*--- END FUNCTION HEADER ----------------------------------------------------*/
FluxI2C::FluxI2C()
{
InitI2C(1); // Port LPT1 par defaut
}
/*--- START FUNCTION HEADER --------------------------------------------------*/
/* Name : FluxI2C */
/* Role : Constructor with parameter */
/* Interface : None */
/* Pre-condition : None */
/* Constraints : None */
/* Behavior : */
/* DO */
/* [Configure the selected parallel port] */
/* OD */
/*----------------------------------------------------------------------------*/
/* PROC FluxI2C */
/* ( */
/* ) */
/* DATA */
/* ATAD */
/* */
/* DO */
/* [Configure the selected parallel port] = */
/* DO */
/* [Call the initialisation routine with the selected port as parameter] */
/* OD */
/* OD */
/*--- END FUNCTION HEADER ----------------------------------------------------*/
FluxI2C::FluxI2C(int AskedLptPort)
{
InitI2C(AskedLptPort);
}
/*--- START FUNCTION HEADER --------------------------------------------------*/
/* Name : FluxI2C */
/* Role : Destructor automatically called at program exit */
/* Interface : None */
/* Pre-condition : None */
/* Constraints : None */
/* Behavior : */
/* DO */
/* [Restore the default/selected parallel port] */
/* OD */
/*----------------------------------------------------------------------------*/
/* PROC FluxI2C */
/* ( */
/* ) */
/* DATA */
/* ATAD */
/* */
/* DO */
/* [Restore the default/selected parallel port] = */
/* DO */
/* [Call the routine that will cut off the power of the conversion card] */
/* OD */
/* OD */
/*--- END FUNCTION HEADER ----------------------------------------------------*/
FluxI2C::~FluxI2C()
{
PowerOffI2C(); // A la fin, on COUPE tout...
}
/*/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\*/
/*\ 'METHODES' /*/
/*/ \*/
/*\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/\/*/
/*--- START FUNCTION HEADER --------------------------------------------------*/
/* Name : InitI2C */
/* Role : Switch on the card on and put it in STOP mode */
/* Interface : IN AskedLptPort */
/* 1 - LPT 1 */
/* 2 - LPT 2 */
/* Pre-condition : None */
/* Constraints : None */
/* Behavior : */
/* DO */
/* [Power ON and STOP condition] */
/* OD */
/*----------------------------------------------------------------------------*/
/* PROC InitI2C */
/* ( */
/* ) */
/* DATA */
/* ATAD */
/* */
/* DO */
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -