- introduced enterCritical, exitCritial

git-svn-id: http://moon:8086/svn/projects/HendiControl@36 fda53097-d464-4ada-af97-ba876c37ca34
This commit is contained in:
2019-03-02 14:28:06 +00:00
parent a94413670a
commit c092db8909
5 changed files with 89 additions and 41 deletions
+20
View File
@@ -10,6 +10,7 @@
#define FIFO_H_
#include <stdlib.h>
#include <avr/interrupt.h>
typedef struct _sFifo
{
@@ -28,4 +29,23 @@ int fifo_push(Fifo *pObj, void *pItem);
int fifo_pop(Fifo *pObj, void *pItem);
int fifo_isEmpty(Fifo *pObj);
static volatile size_t criticalCount = 0;
static inline void enterCritical()
{
cli();
criticalCount++;
}
static inline void exitCritial()
{
if (criticalCount)
{
criticalCount--;
if (!criticalCount)
{
sei();
}
}
}
#endif /* FIFO_H_ */