From 7eb19e6024af7f05cf94c66fb843439a3509147e Mon Sep 17 00:00:00 2001 From: QuakeGod <quakegod@sina.com> Date: 星期一, 02 九月 2024 15:30:40 +0800 Subject: [PATCH] 2024-09-02 --- ComLib/Inc/MyQueue.h | 21 +++++++++++++-------- 1 files changed, 13 insertions(+), 8 deletions(-) diff --git a/ComLib/Inc/MyQueue.h b/ComLib/Inc/MyQueue.h index f070997..2b829b8 100644 --- a/ComLib/Inc/MyQueue.h +++ b/ComLib/Inc/MyQueue.h @@ -8,17 +8,22 @@ #ifndef __MYQUEUE_H__ #define __MYQUEUE_H__ +#pragma anon_unions typedef struct { unsigned char * buf1; - int Caps; - volatile int wp; //Write Pointor - volatile int rp; //Read Pointor + short Caps; + volatile short wp; //Write Pointor + volatile short rp; //Read Pointor // volatile int DataSize; - volatile int RecvBytes; - volatile int bFull; - volatile int bEmpty; - volatile int state; +// volatile short RecvBytes; + union{ + volatile unsigned char state; + struct{ + volatile unsigned char bFull:1; + volatile unsigned char bEmpty:1; + }; + }; }stMyQueue,* pMyQueue; @@ -30,7 +35,7 @@ } static __inline int GetDataLen(pMyQueue theQueue) { - int size=theQueue->wp -theQueue->rp; + int size=theQueue->wp - theQueue->rp; if (theQueue->bFull) { return theQueue->Caps; -- Gitblit v1.9.1