📄 variable_define.h
字号:
#define HEADER_SIZE 4 // 4 bytes header
#define PREAMBLE_LENGTH 10 // Number of bytes of preamble to send */
#define PREAMBLE_REQ 7 /* Number of bits required in addition to */
/* the initial 8 bits for the preamble to be */
/* accepted */
#define DATA_LENGTH 64
#ifdef CRC16
#define CRC_SIZE 2
#else
#define CRC_SIZE 1
#endif
// 这里TX_BUFFER_SIZE指的是实际要发送的字节长度,所以如果要
// 保证一次最多能发送64个有效数据的话,那么考虑帧头和同步码
// 的长度以及CRC校验码的长度后TX_BUFFER_SIZE的值就是它们四者
// 的总和了
#define TX_BUFFER_SIZE (DATA_LENGTH+HEADER_SIZE+PREAMBLE_LENGTH+CRC_SIZE) /* Size (in bytes) of transmit buffer */
// RX_BUFFER_SIZE指的是实际能接收的字节长度,如果我们要保证
// 一次最多能接受64个有效数据的话,那么考虑到数据后还有CRC校
// 验码,所以RX_BUFFER_SIZE的值就应该是64与CRC长度之和了
#define RX_BUFFER_SIZE (DATA_LENGTH+CRC_SIZE) /* Size (in bytes) of receive ring-buffer */
#define UI1 0x33 /* First byte of unique identifier */
#define UI2 0xCC /* Second byte of unique identifier */
#define FALSE 0
#define TRUE 1
#define ON TRUE
#define OFF FALSE
// Macros for turning on and off the LEDs
#define SET_RXLED(STATE) \
if (STATE) P2OUT &= ~BIT0; \
else P2OUT |= BIT0
#define SET_TXLED(STATE) \
if (STATE) P2OUT &= ~BIT7; \
else P2OUT |= BIT7
//定义键盘按键
#define BUTTON1 (P1IN & BIT0)
#define BUTTON2 (P1IN & BIT1)
#define BUTTON3 (P1IN & BIT2)
#define BUTTON4 (P1IN & BIT3)
// 模块单元地址
extern const unsigned char UnitAddress;
// 发送和接收的移位变量
unsigned char ShiftReg;
// Buffers for transmitted and received data
// These are put into different banks so that they can be as large as possible
// The TX buffer is filled up with data to be sent in the next data packet
// The RX buffer is a ring buffer in which received data is stored waiting to be
// sent to the UART
unsigned char TXBuffer[TX_BUFFER_SIZE];
unsigned char RXBuffer[RX_BUFFER_SIZE];
// Index pointers for use with buffers
unsigned char TXBufferIndex;
unsigned char RXBufferReadIndex;
unsigned char RXBufferWriteIndex;
// Counter variables
unsigned char PreambleEnd;
unsigned char PreambleNextbit;
unsigned char ByteCounter;
unsigned char BitCounter;
// Contains the total number of bytes to send in TX, including preamble and header
unsigned char BytesToSend;
// The number of bytes of data to receive in RX
unsigned char BytesToReceive;
// State variable stores the current state of the state machine
enum StateType {IDLE_STATE=0,RX_STATE=1,TX_STATE=2} State;
// This variable stores the state to switch to
// It is updated by the interrupt routine, while the main program
// does the actual state switch
volatile enum StateType NextState;
unsigned char LockAverage;
unsigned char UnlockAverage;
unsigned char RecOver;
⌨️ 快捷键说明
复制代码
Ctrl + C
搜索代码
Ctrl + F
全屏模式
F11
切换主题
Ctrl + Shift + D
显示快捷键
?
增大字号
Ctrl + =
减小字号
Ctrl + -