diff options
| author | tmk <nobody@nowhere> | 2013-02-16 04:05:58 +0900 |
|---|---|---|
| committer | tmk <nobody@nowhere> | 2013-02-16 04:08:31 +0900 |
| commit | e324fa29187dff7868d9d7fd378e0e46d77107a5 (patch) | |
| tree | a72966995df47eef01ced9873c14f972de8af069 /common/util.c | |
| parent | 0142b571c46c7db314063615c956cbc5ec9720f1 (diff) | |
| download | qmk_firmware-e324fa29187dff7868d9d7fd378e0e46d77107a5.tar.gz qmk_firmware-e324fa29187dff7868d9d7fd378e0e46d77107a5.zip | |
Rewrite layer action with layer_switch
Diffstat (limited to 'common/util.c')
| -rw-r--r-- | common/util.c | 11 |
1 files changed, 11 insertions, 0 deletions
diff --git a/common/util.c b/common/util.c index 9d8fb9321..ff1926d7d 100644 --- a/common/util.c +++ b/common/util.c | |||
| @@ -39,6 +39,7 @@ uint8_t bitpop16(uint16_t bits) | |||
| 39 | } | 39 | } |
| 40 | 40 | ||
| 41 | // most significant on-bit - return highest location of on-bit | 41 | // most significant on-bit - return highest location of on-bit |
| 42 | // NOTE: return 0 when bit0 is on or all bits are off | ||
| 42 | uint8_t biton(uint8_t bits) | 43 | uint8_t biton(uint8_t bits) |
| 43 | { | 44 | { |
| 44 | uint8_t n = 0; | 45 | uint8_t n = 0; |
| @@ -47,3 +48,13 @@ uint8_t biton(uint8_t bits) | |||
| 47 | if (bits >> 1) { bits >>= 1; n += 1;} | 48 | if (bits >> 1) { bits >>= 1; n += 1;} |
| 48 | return n; | 49 | return n; |
| 49 | } | 50 | } |
| 51 | |||
| 52 | uint8_t biton16(uint16_t bits) | ||
| 53 | { | ||
| 54 | uint8_t n = 0; | ||
| 55 | if (bits >> 8) { bits >>= 8; n += 8;} | ||
| 56 | if (bits >> 4) { bits >>= 4; n += 4;} | ||
| 57 | if (bits >> 2) { bits >>= 2; n += 2;} | ||
| 58 | if (bits >> 1) { bits >>= 1; n += 1;} | ||
| 59 | return n; | ||
| 60 | } | ||
