diff options
author | tmk <nobody@nowhere> | 2012-11-24 16:34:59 +0900 |
---|---|---|
committer | tmk <nobody@nowhere> | 2012-11-24 16:34:59 +0900 |
commit | 94b4fba6e6afa6d7d68051a1ceb6987bb6002ccd (patch) | |
tree | bd9f35b876d13bca20c7655fbbb93f4733aea0dd /common/util.c | |
parent | 83f0e800e53a6d91a814d19f94bc5401a6322971 (diff) | |
download | qmk_firmware-94b4fba6e6afa6d7d68051a1ceb6987bb6002ccd.tar.gz qmk_firmware-94b4fba6e6afa6d7d68051a1ceb6987bb6002ccd.zip |
Add bitpop16() in util.c.
Diffstat (limited to 'common/util.c')
-rw-r--r-- | common/util.c | 10 |
1 files changed, 9 insertions, 1 deletions
diff --git a/common/util.c b/common/util.c index 644301fe89..9d8fb93219 100644 --- a/common/util.c +++ b/common/util.c @@ -22,7 +22,7 @@ uint8_t bitpop(uint8_t bits) { uint8_t c; for (c = 0; bits; c++) - bits &= bits -1; + bits &= bits - 1; return c; /* const uint8_t bit_count[] = { 0, 1, 1, 2, 1, 2, 2, 3, 1, 2, 2, 3, 2, 3, 3, 4 }; @@ -30,6 +30,14 @@ uint8_t bitpop(uint8_t bits) */ } +uint8_t bitpop16(uint16_t bits) +{ + uint8_t c; + for (c = 0; bits; c++) + bits &= bits - 1; + return c; +} + // most significant on-bit - return highest location of on-bit uint8_t biton(uint8_t bits) { |