diff options
| author | tmk <nobody@nowhere> | 2013-04-02 16:09:43 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2013-04-02 16:09:43 +0900 |
| commit | cc8e66754b1a5d0c11985cb0feb51ead49668744 (patch) | |
| tree | b2c7aa7bf5a2ed20650febc6b25fbbd3d773fe10 /common/util.c | |
| parent | 10f33a3e484e24065ed5eaab1c56c35156bace89 (diff) | |
| download | qmk_firmware-cc8e66754b1a5d0c11985cb0feb51ead49668744.tar.gz qmk_firmware-cc8e66754b1a5d0c11985cb0feb51ead49668744.zip | |
Refine ACT_LAYER and ACT_LAYER_TAP
- Remove ACT_LAYER_BITOP
Diffstat (limited to 'common/util.c')
| -rw-r--r-- | common/util.c | 19 |
1 files changed, 19 insertions, 0 deletions
diff --git a/common/util.c b/common/util.c index ff1926d7d..6d4d6bfda 100644 --- a/common/util.c +++ b/common/util.c | |||
| @@ -38,6 +38,14 @@ uint8_t bitpop16(uint16_t bits) | |||
| 38 | return c; | 38 | return c; |
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | uint8_t bitpop32(uint32_t bits) | ||
| 42 | { | ||
| 43 | uint8_t c; | ||
| 44 | for (c = 0; bits; c++) | ||
| 45 | bits &= bits - 1; | ||
| 46 | return c; | ||
| 47 | } | ||
| 48 | |||
| 41 | // most significant on-bit - return highest location of on-bit | 49 | // most significant on-bit - return highest location of on-bit |
| 42 | // NOTE: return 0 when bit0 is on or all bits are off | 50 | // NOTE: return 0 when bit0 is on or all bits are off |
| 43 | uint8_t biton(uint8_t bits) | 51 | uint8_t biton(uint8_t bits) |
| @@ -58,3 +66,14 @@ uint8_t biton16(uint16_t bits) | |||
| 58 | if (bits >> 1) { bits >>= 1; n += 1;} | 66 | if (bits >> 1) { bits >>= 1; n += 1;} |
| 59 | return n; | 67 | return n; |
| 60 | } | 68 | } |
| 69 | |||
| 70 | uint8_t biton32(uint32_t bits) | ||
| 71 | { | ||
| 72 | uint8_t n = 0; | ||
| 73 | if (bits >>16) { bits >>=16; n +=16;} | ||
| 74 | if (bits >> 8) { bits >>= 8; n += 8;} | ||
| 75 | if (bits >> 4) { bits >>= 4; n += 4;} | ||
| 76 | if (bits >> 2) { bits >>= 2; n += 2;} | ||
| 77 | if (bits >> 1) { bits >>= 1; n += 1;} | ||
| 78 | return n; | ||
| 79 | } | ||
