Advertisement
Guest User

leds

a guest
Jun 20th, 2011
129
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
C 0.45 KB | None | 0 0
  1. #include "aduc812.h"
  2. #include "max.h"
  3.  
  4. static unsigned char old_led = 0;  
  5.  
  6.  
  7. void led( unsigned char n, unsigned char on )
  8. {
  9. unsigned char c;
  10. unsigned char mask = 1;
  11.  
  12.     if( n > 7 ) return;
  13.  
  14.     c = old_led;
  15.  
  16.     mask <<= n;
  17.  
  18.     if( on )
  19.         c |= mask;
  20.     else
  21.         c &= ~mask;        
  22.  
  23.     write_max( SV, c );    
  24.  
  25.     old_led = c;
  26. }
  27.  
  28.  
  29. void leds( unsigned char on )
  30. {
  31.     write_max( SV, on );    
  32.  
  33.     old_led = on;
  34. }
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement