?? rs232.h
字號:
#ifndef _RS232_H_
#define _RS232_H_
#ifndef _INC_PMSG
#define _INC_PMSG
#ifdef __cplusplus
extern "C" {
#endif
#define SERIAL_BUF_AND 0x7f
#define SERIAL_BUF_LEN 0x80
// Maximum length of data field in a packet is 248 bytes, which yields in 254 total packet length.
#define P_MAX_DATA_LENGTH 2048
//#define P_MAX_PACKET_LENGTH 2054
// Elementary Units of the Protocol
#define P_NUL 0x00 // Initialization Byte
#define P_ENQ 0x05 // Action Complete Notification
#define P_ACK 0x06 // Positive Achnowledgement
#define P_DC1 0x11 // Unable to Execute Command
#define P_NAK 0x15 // Negative Acknowledgement, also Camera Signature
#define P_END 0xff // Termination Byte
// Packet - Variable length sequence of bytes. Known packet types are in the following:
#define P_DATA_UNFINISHED 0x02 // Data packet that is not last in sequence
#define P_DATA 0x03 // Data packet that is last in sequence
#define P_CMD 0x1b // Command packet
/*
Packet structure as the following:
Offset Length Meaning
0 1 Packet type
1 1 Packet subtype/sequence
2 2 Length of data
4 variable Data
-2 2 Checksum
*/
// Packet subtype
// Command packet has subtype 0x43 or 0x53. Only the first command packet in a session has subtype 0x53.
#define P_CMD_FIRST 0x53
#define P_CMD_NORMAL 0x43
// Data packets that are sent in responce to a single command are numbered starting from zero.
// If all requested data fits in one packet, it has type 0x03(P_DATA) and sequence 0.
/*
Command is a sequance of bytes sent in the data field of a command packet.
Command format and codes are as follows:
Offset Length Description
0 1 Command code
1 1 Register number or subcode
2 variable Optional argument
*/
// Five command codes are known: Argument Description
#define P_CMD_SET_REG 0 // int32 Set value of integer register
#define P_CMD_GET_REG 1 // none Read value of integer register
#define P_CMD_ACTION 2 // vdata Take action unrelated to registers
#define P_CMD_SET_VDATA 3 // vdata Set value of vdata register
#define P_CMD_GET_VDATA 4 // none Read value of vdata register
// The following registers are known: Type R/W Description
// The following registers are known: Type
#define P_CMD_CUR_IMG_TYPE 1 // int32
#define P_CMD_NAND_CS 2 // int32
#define P_CMD_BOOT_STAGE 3 // int32
#define P_CMD_FRAME_LEN 4 // int32
#define P_CMD_CUR_IMG_LENGTH 5 // int32
// For command 2 (P_CMD_ACTION), the second byte is action code not register number. The following action codes are known:
// Code Argument Description
#define P_ACTION_WRITE_IMG 0 // single zero byte
#define P_ACTION_UPDATE_TOC 1 // single zero byte
#define P_ACTION_OPEN_DATA_PIPE 2 // single zero byte
#define P_ACTION_CLOSE_DATA_PIPE 3 // single zero byte
void DoRS232(void);
void Rs232Init(void);
void Rs232Handshake(void);
unsigned char Rs232GetChar(void);
void Rs232PutChar(char c);
void Rs232GetChars(void);
#ifdef __cplusplus
}
#endif
#endif
#endif//#ifndef _RS232_H_
?? 快捷鍵說明
復制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號
Ctrl + =
減小字號
Ctrl + -