Created
February 27, 2015 02:09
-
-
Save kylehowells/46389fc58d21cb2f6f75 to your computer and use it in GitHub Desktop.
Get an uint16_t that was stored in an uint8_t* array.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| // uint8_t *buffer [1] & [2] contain the uint16_t bytes. | |
| uint16_t duration; | |
| uint8_t* p = (uint8_t*)(void*)&duration; | |
| *p = buffer[1]; // 2e | |
| *(p+1) = buffer[2]; // e5 | |
| //duration now contains 2ee5 | |
| printf("duration: %d", duration); |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment