Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
util.cpp@0:e0a44db7e925, 2010-12-23 (annotated)
- Committer:
- iamjay
- Date:
- Thu Dec 23 15:03:51 2010 +0000
- Revision:
- 0:e0a44db7e925
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| iamjay | 0:e0a44db7e925 | 1 | #include "mbed.h" |
| iamjay | 0:e0a44db7e925 | 2 | |
| iamjay | 0:e0a44db7e925 | 3 | #include "util.h" |
| iamjay | 0:e0a44db7e925 | 4 | |
| iamjay | 0:e0a44db7e925 | 5 | #include "main.h" |
| iamjay | 0:e0a44db7e925 | 6 | |
| iamjay | 0:e0a44db7e925 | 7 | unsigned char rev_byte(unsigned char c) |
| iamjay | 0:e0a44db7e925 | 8 | { |
| iamjay | 0:e0a44db7e925 | 9 | unsigned char r = 0, i; |
| iamjay | 0:e0a44db7e925 | 10 | |
| iamjay | 0:e0a44db7e925 | 11 | for (i = 1; i != 0; i = i<<1) { |
| iamjay | 0:e0a44db7e925 | 12 | r = r << 1; |
| iamjay | 0:e0a44db7e925 | 13 | if (c & i) |
| iamjay | 0:e0a44db7e925 | 14 | r |= 1; |
| iamjay | 0:e0a44db7e925 | 15 | } |
| iamjay | 0:e0a44db7e925 | 16 | |
| iamjay | 0:e0a44db7e925 | 17 | if (mode_config.numbits != 8) |
| iamjay | 0:e0a44db7e925 | 18 | r >>= (8 - mode_config.numbits); |
| iamjay | 0:e0a44db7e925 | 19 | |
| iamjay | 0:e0a44db7e925 | 20 | return r; |
| iamjay | 0:e0a44db7e925 | 21 | } |