⭐ 欢迎来到虫虫下载站! | 📦 资源下载 📁 资源专辑 ℹ️ 关于我们
⭐ 虫虫下载站

📄 mbuspack.h

📁 coldfire5206芯片平台的升级程序
💻 H
字号:
#ifndef  MBUSPACK_H
   #define  MBUSPACK_H


#define TXDATA_LENGTH  (16)

// The length of three packet queue
#define CAT24C021_READ_PACKQUE_LEN   (10)
#define CAT24C021_WRITE_PACKQUE_LEN  (10)


// operation mode constant define.
enum OPMode{OPMODE_QUERY, OPMODE_INTERRUPT};

// Real time clock chip type
enum rtcType{RTC_NO, RTC_X1203, RTC_RS5C372A};

/**
 *  MBUS communication protocol information struct.
 */
typedef struct{
   // The number of byte being send first. this value must greater than 0
   UINT16 txLen1;

   // The number of byte being send second. 0 if no data to be transmitted
   // the second time, greater than 0 if there is some data to be transmitted
   // the second time, and a RESTART signal must be sent before the sequence
   // to be sent.
   UINT16 txLen2;

   // The number of byte to be received. 0 if no data to be received.
   UINT16 rxLen;

   // data to be transmitted. (including Slave address)
   UCHAR txData[TXDATA_LENGTH];

   // The address for saving received data.
   // Note: the saving routine will not check the range.
   UCHAR *rxData;

   // Repeat transfer for how many times if transfer failed 
   UINT16 repeatTimes;

}MBusPackType;


/**
 *  MBUS communication status information
 */
typedef struct{
   // the operation mode of mbus: OPMODE_QUERY or OPMODE_INTERRUPT
   UCHAR  mode;

   // has current packet been processed: finished(1), not yet(0)
   UCHAR  currPackFinished;

   // Error count for no acknowledge, this variable will be increased by
   // one every time MBUS module tramsnitted one byte but without acknowledge.
   UINT16 noAckError;

   // Count for transfer failure, increase by one every time one packet was not
   // transfered
   UINT16 transferFail;

   // Real Time Clock chip type: X1203, RS5C372 or no
   UCHAR  rtcChip;

   // The packet being transfered
   MBusPackType  currPack;
}MBusInfoType;


/**
 *  MBUS communication protocol information manage struct. just a queue.
 */
typedef struct{
   // write pointer.
   UINT16  getPtr;

   // read pointer.
   UINT16  putPtr;

   // the length of the queue
   UINT16  queueLen;

   // the packet queue.
   MBusPackType *packQue;

}MBusPackQueType;


// packet queue operation function: prototype declare
INT16  MBusPackQueGet(MBusPackQueType *theQue, MBusPackType** out);
INT16  MBusPackQuePut(MBusPackQueType *theQue, MBusPackType* in);


#endif

⌨️ 快捷键说明

复制代码 Ctrl + C
搜索代码 Ctrl + F
全屏模式 F11
切换主题 Ctrl + Shift + D
显示快捷键 ?
增大字号 Ctrl + =
减小字号 Ctrl + -