fix 1wire bugginess with addressing
This commit is contained in:
+10
-20
@@ -1,3 +1,4 @@
|
|||||||
|
#include <debug.h>
|
||||||
#include "payload_parser.h"
|
#include "payload_parser.h"
|
||||||
|
|
||||||
#define pp_check_capacity(pp, needed) \
|
#define pp_check_capacity(pp, needed) \
|
||||||
@@ -58,32 +59,21 @@ uint32_t pp_u32(PayloadParser *pp)
|
|||||||
|
|
||||||
uint64_t pp_u64(PayloadParser *pp)
|
uint64_t pp_u64(PayloadParser *pp)
|
||||||
{
|
{
|
||||||
pp_check_capacity(pp, 4);
|
pp_check_capacity(pp, 8);
|
||||||
if (!pp->ok) return 0;
|
if (!pp->ok) return 0;
|
||||||
|
|
||||||
uint64_t x = 0;
|
uint32_t x0, x1;
|
||||||
|
uint64_t x;
|
||||||
|
|
||||||
if (pp->bigendian) {
|
if (pp->bigendian) {
|
||||||
x |= (uint64_t) ((uint64_t) *pp->current++ << 56);
|
x1 = pp_u32(pp);
|
||||||
x |= (uint64_t) ((uint64_t) *pp->current++ << 48);
|
x0 = pp_u32(pp);
|
||||||
x |= (uint64_t) ((uint64_t) *pp->current++ << 40);
|
|
||||||
x |= (uint64_t) ((uint64_t) *pp->current++ << 32);
|
|
||||||
|
|
||||||
x |= (uint64_t) (*pp->current++ << 24);
|
|
||||||
x |= (uint64_t) (*pp->current++ << 16);
|
|
||||||
x |= (uint64_t) (*pp->current++ << 8);
|
|
||||||
x |= *pp->current++;
|
|
||||||
} else {
|
} else {
|
||||||
x |= *pp->current++;
|
x0 = pp_u32(pp);
|
||||||
x |= (uint64_t) (*pp->current++ << 8);
|
x1 = pp_u32(pp);
|
||||||
x |= (uint64_t) (*pp->current++ << 16);
|
|
||||||
x |= (uint64_t) (*pp->current++ << 24);
|
|
||||||
|
|
||||||
x |= (uint64_t) ((uint64_t) *pp->current++ << 32);
|
|
||||||
x |= (uint64_t) ((uint64_t) *pp->current++ << 40);
|
|
||||||
x |= (uint64_t) ((uint64_t) *pp->current++ << 48);
|
|
||||||
x |= (uint64_t) ((uint64_t) *pp->current++ << 56);
|
|
||||||
}
|
}
|
||||||
|
x = ((uint64_t)x1)<<32 | x0;
|
||||||
|
|
||||||
return x;
|
return x;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user