Skip to content

Commit

Permalink
[spinel] fix little endian in lib (openthread#10522)
Browse files Browse the repository at this point in the history
  • Loading branch information
Irving-cl authored Jul 17, 2024
1 parent aba7aed commit 0897b50
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 6 deletions.
6 changes: 3 additions & 3 deletions src/lib/spinel/multi_frame_buffer.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -464,12 +464,12 @@ template <uint16_t kSize> class MultiFrameBuffer : public FrameWritePointer
public:
static uint16_t ReadUint16(const uint8_t *aBuffer)
{
return static_cast<uint16_t>((aBuffer[0] << 8) | aBuffer[1]);
return static_cast<uint16_t>((aBuffer[0]) | aBuffer[1] << 8);
}
static void WriteUint16(uint16_t aValue, uint8_t *aBuffer)
{
aBuffer[0] = (aValue >> 8) & 0xff;
aBuffer[1] = (aValue >> 0) & 0xff;
aBuffer[0] = (aValue >> 0) & 0xff;
aBuffer[1] = (aValue >> 8) & 0xff;
}
};

Expand Down
6 changes: 3 additions & 3 deletions src/lib/spinel/spi_frame.hpp
Original file line number Diff line number Diff line change
Expand Up @@ -238,12 +238,12 @@ class SpiFrame
public:
static uint16_t ReadUint16(const uint8_t *aBuffer)
{
return static_cast<uint16_t>((aBuffer[0] << 8) | aBuffer[1]);
return static_cast<uint16_t>((aBuffer[0]) | aBuffer[1] << 8);
}
static void WriteUint16(uint16_t aValue, uint8_t *aBuffer)
{
aBuffer[0] = (aValue >> 8) & 0xff;
aBuffer[1] = (aValue >> 0) & 0xff;
aBuffer[0] = (aValue >> 0) & 0xff;
aBuffer[1] = (aValue >> 8) & 0xff;
}
};

Expand Down

0 comments on commit 0897b50

Please sign in to comment.