|
From: | Erik Walthinsen |
Subject: | Re: [avr-libc-dev] RFC: avr/bits.h |
Date: | Tue, 01 Mar 2005 12:39:02 -0800 |
User-agent: | Debian Thunderbird 1.0 (X11/20050116) |
E. Weddington wrote:
I was going under a false assumption about how they were defined.I personally do not support the macros as written by Erik Walthinsen (sorry, Erik).
This is specifically why I included both bit_set() and bit_set_mask(). They serve different purposes, and, being convenience macros, both are relevant.
As per docs, bit_set() takes a bit position, and bit_set_mask() takes any arbitrary value containing multiple bits:
bit_set(PORTB, 3); bit_set_mask(PORTB, BIT(3) | BIT(5) | BIT(7));IMO if the only macro set provided is a bit_set() that requires the bit position already converted with BIT(), then there really is no point in having the macros at all. The point in having a basic bit_set() routine in my opinion is to make it trivial to quickly and *obviously* flip a single bit in a register. If I'm flipping more than one, I probably wouldn't use bit_set_mask() anyway, personally.
[Prev in Thread] | Current Thread | [Next in Thread] |