Skip to content

Commit

Permalink
Added macros to construct signed integers from EEPROM content in a sa…
Browse files Browse the repository at this point in the history
…fe c standard way.
  • Loading branch information
grodansparadis committed Nov 25, 2015
1 parent 3bae432 commit 6f8f354
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions common/vscp_firmware.h
Original file line number Diff line number Diff line change
Expand Up @@ -65,6 +65,17 @@ low end hardware device.
#include <vscp_projdefs.h> // This file should be in your project folder
#include <inttypes.h>

// Macros

// This macro construct a signed integer from two unsigned chars in a safe way
#define construct_signed16( msb, lsb ) ((int16_t)( (((uint16_t)msb)<<8) + \
(uint16_t)lsb) )

// This macro construct a signed long from four unsigned chars in a safe way
#define construct_signed32( b0, b1, b2, b3 ) ((int32_t)( (((uint32_t)b0)<<24) + \
(((uint32_t)b0)<<16) + \
(((uint32_t)b0)<<8) + \
((uint32_t)b0);

// ******************************************************************************
// VSCP Constants
Expand Down

0 comments on commit 6f8f354

Please sign in to comment.