Quantcast
Channel: Forum - Recent Threads
Viewing all articles
Browse latest Browse all 5781

RE: PinWrite from multiple threads

$
0
0

Here is the parametrized and optimized version with just plain assignments thanks to Karol's hint on POSR/PORR bits in PCNTR3 registers:

#define _CHK_PIN_0(p,b) ((R_IOPORT##p->PCNTR1 & (1<<((b)+16)))==0)
#define _CHK_PIN_1(p,b) ((R_IOPORT##p->PCNTR1 & (1<<((b)+16)))!=0)
#define _CLR_PIN(p,b)    {R_IOPORT##p->PCNTR3 = (1<<((b)+16));}
#define _SET_PIN(p,b)    {R_IOPORT##p->PCNTR3 = (1<<((b) ));}

#define _GreenLed_IsOn()   _CHK_PIN_0(6,0)// (P6.0==0)
#define _GreenLed_On()     _CLR_PIN(6,0)  // P6.0 = 0;
#define _GreenLed_Off()    _SET_PIN(6,0)  // P6.0 = 1;
#define _RedLed_IsOn()     _CHK_PIN_0(6,1)// (P6.1==0)
#define _RedLed_On()       _CLR_PIN(6,1)  // P6.1 = 0;
#define _RedLed_Off()      _SET_PIN(6,1)  // P6.1 = 1;
#define _OrangeLed_IsOn()  _CHK_PIN_0(6,2)// (P6.2==0)
#define _OrangeLed_On()    _CLR_PIN(6,2)  // P6.2 = 0;
#define _OrangeLed_Off()   _SET_PIN(6,2)  // P6.2 = 1;


Viewing all articles
Browse latest Browse all 5781

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>