typeconverting - TinyOS: converting uint16_t and uint8_t into uint32_t -
i'm having following problem:
i have uint8_t  h_msb , uint16_t h_lsb , iwant combine them uint32_t
so here code:
void  parseheader(mypackage header,uint32_t* timestamp ){ (*timestamp) = (header->h_msb <<16)| header->h_lsb; }    but not seem work;
i tried h_msb = 10 , h_lsb= 10
i 10 timestamp.
the problem seems if shift beyon 7 bit information h_msb ist lost, how can since timestamp uint32_t ?
the problem h_msb uint8_t , shift operation performed within uint8_t type (or possibly within uint16_t, doesn't matter), 0. cast uint32_t before shifting:
(*timestamp) = (((uint32_t)header->h_msb) << 16) | header->h_lsb;      
Comments
Post a Comment