📄 comstruct.h
字号:
#define CPU_FREQ 3579500 //unit: Hz
#define INT24U unsigned short long //a special int type in MCC18
#define NULL_PTR (INT8U rom *) 0xffffff
#define MAX_DCALLNUM_LEN 12
/* defination of some constances */
//Serial port operation mode
#define S_NORMAL 0 //CPU com. with wireless module
#define S_DEBUG 1 //CPU com. with the DEBUG port
#define S_MONITOR 2 //CPU com. with wireless module and data on TX/RX lines sent to the DEBUG port
#define S_OFFLINE 3 //DEBUG port connect with wireless module directly
//the voice channel state
#define HANDSET 0
#define HANDFREE 1
//The modem work mode, command mode or data mode
#define MOD_COMMAND 0
#define MOD_DATA 1
//the coding method of SM
#define SM_ASCII 2
#define SM_UNICODE 4
//some timer ID
#define KEY_LED_ID 0x01
//MCNM status
#define MS_OK 0
#define MS_DATA_CORRUPTED 1
//system file ID
#define SYS_FILE_ID 0x00
//Voice channel state, handfree, handset or idle
#define VOX_IDLE 0
#define VOX_HANDFREE 1
#define VOX_HANDSET 2
//These constances is applied in the serial port receiving process. Bytes received is processed with INT2
//if the number of received bytes exceed the RXTHREHOLD of the COM port is idle for at least 20ms
#define RXTIMEOUTH 0xf7
#define RXTIMEOUTL 0x40 //about 20ms
//Timer2 used in keyscan, 20ms long
#define KSTIMEOUT 0x01
//#define KSTIMEOUTL 0x40
#define RXTHREHOLD 50
//when the value of a message is larger than this value, it's a direct message and the message itself is a
//message ID. if its value is smaller than this value, it's a pointer and point to a mem. block containing
//a message body
#define PTR_MAX 0x800000 //the maximum pointer value
//the DEBUG port frame type
#define FT_MCNM 0x04
#define FT_DEBUG 0xf0
//Main window (the middle 2 line of the screen) type
#define WND_IDLE 0
#define WND_CALL 1
#define WND_MENU 2
//port
#define PT_NONE 0x00
#define PT_HDLC 0x01
#define PT_SM 0x02
//the structure of undirect message head
typedef rom struct Msg_Head{
INT24U Msg_ID; //Identification of message
OS_EVENT * Origin; //Originator, actually it's the message queue of the originator
OS_MEM * pmemME; //MCB pointer of the message memory block
INT8U Attached; //If the message gets another memory block attached
INT16U LenOfAttach; //The length of information in the attached mem. block
INT8U rom * pMem; //Pointer of the attached mem. block
OS_MEM * pmemATT; //MCB pointer of the attached mem. block
INT8U LenOfBody; //The length of the message body following the message head
} MSG_HEAD;
//Here are some structure defination of messages
//this message is used by WICResp to report time value from module to SysTime
typedef rom struct Msg_TimeRpt{
MSG_HEAD Head;
INT8U Year;
INT8U Month;
INT8U Date;
INT24U Second;
} MSG_TIMERPT;
//This message is used by WICResp to report "WIND" and "WEND" value to WIC
typedef rom struct Msg_WindRpt{
MSG_HEAD Head;
INT16U Rpt;
} MSG_WINDRPT;
typedef rom struct Msg_KeyPress{
MSG_HEAD Head;
INT8U Key;
} MSG_KEYPRESS;
//
typedef rom struct Msg_LongDataTx{ //used to transmit very long data, no memblock attached, ptrData point
//to the data directly.
MSG_HEAD Head;
INT8U rom * ptrData;
INT16U Len;
} MSG_LONGDATATX;
typedef rom struct Msg_Protocol{ //the message defination for local connection
MSG_HEAD Head;
INT8U Port;
INT8U Type; //fill in the type, 0xff for default(when TxProtocol transmit data)
INT8U SubType;
INT8U SubNet;
}MSG_PROTOCOL;
typedef rom struct Msg_DirectCall{
MSG_HEAD Head;
INT8U Num[13]; //compressed BCD code
}MSG_DIRECTCALL;
typedef rom struct Msg_TonePlay{
MSG_HEAD Head;
INT8U Num[3]; //compressed BCD code
}MSG_TONEPLAY;
typedef rom struct Msg_PPP_Struct{
MSG_HEAD Msg_Head;
INT8U Address;
INT8U Control;
INT8U ProtocolH;
INT8U ProtocolL;
//
INT8U Code;
INT8U Id;
INT8U LengthHigh;
INT8U Length;
}MSG_PPP;
typedef rom struct Msg_Data_Conreq_Struct{
MSG_HEAD Msg_Head;
INT8U Num[MAX_DCALLNUM_LEN]; //ASCII
}MSG_DCONREQ;
typedef rom struct _MSG_UDP{
MSG_HEAD Msg_Head;
INT16U SourcePort;
INT16U LenOfPayload;
INT8U rom * pPayload;
}MSG_UDP;
/////////////////////////////////////
typedef rom struct Frame_Struct{
INT8U Len;
INT8U NT;
INT8U NR;
INT8U Type;
INT8U SubNet;
}FRAME_STRUCT;
typedef union _SWORD_VAL
{
INT24U Val;
struct
{
INT8U LSB;
INT8U MSB;
INT8U USB;
} bytes;
} SWORD_VAL;
typedef union _WORD_VAL
{
INT16U Val;
INT8U v[2];
} WORD_VAL;
#define LSB(a) ((a).v[0])
#define MSB(a) ((a).v[1])
typedef union _DWORD_VAL
{
INT32U Val;
INT8U v[4];
} DWORD_VAL;
#define LOWER_LSB(a) ((a).v[0])
#define LOWER_MSB(a) ((a).v[1])
#define UPPER_LSB(a) ((a).v[2])
#define UPPER_MSB(a) ((a).v[3])
typedef union _IP_ADDR
{
INT8U v[4];
INT32U Val;
} IP_ADDR;
//typedef rom struct _NODE_INFO
//{
// MAC_ADDR MACAddr;
// IP_ADDR IPAddr;
//} NODE_INFO;
//Here is a recommanded task structure. Where "XXXX" can be replaced by other words.
/*
void tskXXXX(void * data){
void rom * pMsg; //The pointer of message, it has to be a pointer point to the "rom: region
INT8U err; //Used to return the error value. It must be a variable in data region
for(;;){ //The main loop
pMsg = OSQPend(peventXXXX, 0, &err); //Wait for the messages
if(err == OS_NO_ERR){
if((INT24U)pMsg >= PTR_MAX){ //If is a direct message--just a value
switch ((INT24U)pMsg){
}
}
else{ //If it's a undirect message--a pointer
switch (((MSG_HEAD *)pMsg)->Msg_ID){
//Add message processing codes here. If some long data in message attachment has to be
//left to be processed later, you have to save the ((MSG_HEAD *)pMsg)->pMem and
//(MSG_HEAD *)pMsg)->pmemATT, codes like following shall be added
// (MSG_HEAD *)pMsg)->Attached = FALSE;
//so at the out point, the attached block will not be released
case MSG_XXXX:
break;
}
if(((MSG_HEAD *)pMsg)->Attached == TRUE){
OSMemPut(((MSG_HEAD *)pMsg)->pmemATT, ((MSG_HEAD *)pMsg)->pMem);
}
OSMemPut(((MSG_HEAD *)pMsg)->pmemME, pMsg);
}
}
}
}
*/
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -