Skip to content

Commit

Permalink
AP_Math: fix LoadUint() to allow 32bit values
Browse files Browse the repository at this point in the history
  • Loading branch information
magicrub committed Oct 5, 2020
1 parent e4f8d47 commit 5e2450c
Show file tree
Hide file tree
Showing 2 changed files with 2 additions and 11 deletions.
8 changes: 1 addition & 7 deletions libraries/AP_Math/bitwise.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -19,17 +19,11 @@

#include "bitwise.h"

void loadUint(uint8_t *b, uint16_t v, uint8_t bitCount, bool MSBfirst)
void loadUint(uint8_t *b, uint32_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);
}
}
Expand Down
5 changes: 1 addition & 4 deletions libraries/AP_Math/bitwise.h
Original file line number Diff line number Diff line change
Expand Up @@ -19,11 +19,8 @@

#include <stdint.h>

void loadUint(uint8_t *b, uint16_t v, uint8_t bitCount, bool MSBfirst = true);
void loadUint(uint8_t *b, uint32_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);
Expand Down

0 comments on commit 5e2450c

Please sign in to comment.