Differences

This shows you the differences between two versions of the page.

Link to this comparison view

Both sides previous revisionPrevious revision
en:examples:define [2009/03/05 10:36] raivo.sellen:examples:define [2010/02/04 12:34] (current) – removed mikk.leini
Line 1: Line 1:
-====== Useful definitions ====== 
  
- 
-===== bit manipulations ===== 
- 
-<code c> 
- 
- 
-#define BIT(x) (1 << (x)) // Bit index to bit mask 
-#define SET(x) |=  BIT(x) // Bit setting 
-#define CLR(x) &= ~BIT(x) // Bit clearing 
-#define INV(x) ^=  BIT(x) // Bit inversion 
- 
-// Setting or clearing specified bit in specified byte 
-#define SETTO(value, bit, to) value = ((to) ? value | BIT(bit) : value & ~BIT(bit))  
- 
-// Checking whether the specified bit is set in specified byte 
-#define ISSET(value, bit) ((value) & (BIT(bit))) 
- 
-// avrlibc deprecated macros 
-#define sbi(sfr, bit) (_SFR_BYTE(sfr) |=  _BV(bit)) // Set bit in byte 
-#define cbi(sfr, bit) (_SFR_BYTE(sfr) &= ~_BV(bit)) // Clear bit in byte 
- 
-#define MAX(a, b) ((a) > (b)) ? (a):(b) 
-</code> 
- 
-Digi i/o board (Studyboard) 
- 
-<code c> 
-#define LED1 PORTC, 3 
-#define LED2 PORTC, 4 
-#define LED3 PORTC, 5 
- 
-#define S1 PORTC, 0 
-#define S2 PORTC, 1 
-#define S3 PORTC, 2 
-</code> 
en/examples/define.1236249417.txt.gz · Last modified: 2020/07/20 09:00 (external edit)
CC Attribution-Share Alike 4.0 International
www.chimeric.de Valid CSS Driven by DokuWiki do yourself a favour and use a real browser - get firefox!! Recent changes RSS feed Valid XHTML 1.0