Browse Source

Revert "AP_Math: fix LoadUint() to allow 32bit values"

This reverts commit 5e2450c4ea.
zr-v5.1
Tom Pittenger 4 years ago committed by Andrew Tridgell
parent
commit
ee8f50e6a5
  1. 8
      libraries/AP_Math/bitwise.cpp
  2. 5
      libraries/AP_Math/bitwise.h

8
libraries/AP_Math/bitwise.cpp

@ -19,11 +19,17 @@ @@ -19,11 +19,17 @@
#include "bitwise.h"
void loadUint(uint8_t *b, uint32_t v, uint8_t bitCount, bool MSBfirst)
void loadUint(uint8_t *b, uint16_t v, uint8_t bitCount, bool MSBfirst)
{
const uint8_t last = bitCount/8;
// count = 32
// last = 4
// MSBfirst = 1;
for (uint8_t i=0; i<last; i++) {
const uint8_t idx = MSBfirst ? last-1-i : i;
// idx = 4-1-0
b[i] = v >> (8*idx);
}
}

5
libraries/AP_Math/bitwise.h

@ -19,8 +19,11 @@ @@ -19,8 +19,11 @@
#include <stdint.h>
void loadUint(uint8_t *b, uint32_t v, uint8_t bitCount, bool MSBfirst = true);
void loadUint(uint8_t *b, uint16_t v, uint8_t bitCount, bool MSBfirst = true);
//void loadU16(uint8_t *b, uint16_t v, bool MSBfirst = true) { loadUx(b, v, 16, MSBfirst); }
//void loadU24(uint8_t *b, uint32_t v, bool MSBfirst = true) { loadUx(b, v, 24, MSBfirst); }
//void loadU32(uint8_t *b, uint32_t v, bool MSBfirst = true) { loadUx(b, v, 32, MSBfirst); }
uint16_t fetchU16(const uint8_t *v, bool MSBfirst = true);
uint32_t fetchU24(const uint8_t *v, bool MSBfirst = true);
uint32_t fetchU32(const uint8_t *v, bool MSBfirst = true);

Loading…
Cancel
Save