Skip to content

Commit

Permalink
Added unsigned integer/long construct macros also because I "luve" sy…
Browse files Browse the repository at this point in the history
…mmetry.
  • Loading branch information
grodansparadis committed Dec 8, 2015
1 parent 6f8f354 commit c504853
Show file tree
Hide file tree
Showing 2 changed files with 16 additions and 3 deletions.
8 changes: 5 additions & 3 deletions common/vscp_firmware.c
Original file line number Diff line number Diff line change
Expand Up @@ -686,8 +686,8 @@ uint8_t vscp_readStdReg(uint8_t reg)
else if ( reg >= VSCP_REG_DEVICE_URL ) {

// * * * The device URL * * *
rv = vscp_getMDF_URL(reg - VSCP_REG_DEVICE_URL);
rv = vscp_getMDF_URL(reg - VSCP_REG_DEVICE_URL);

}

return rv;
Expand Down Expand Up @@ -1152,6 +1152,7 @@ void vscp_handleProtocolEvent(void)
#endif

case VSCP_TYPE_PROTOCOL_EXTENDED_PAGE_READ:

if ( vscp_nickname == vscp_imsg.data[0] ) {

uint16_t page_save, bytes = 0;
Expand Down Expand Up @@ -1211,7 +1212,7 @@ void vscp_handleProtocolEvent(void)

// send the event
vscp_sendEvent();

// increment byte by bytes_this_time and the event number by one
byte += bytes_this_time;

Expand Down Expand Up @@ -1286,6 +1287,7 @@ void vscp_handleProtocolEvent(void)
int8_t vscp_sendEvent(void)
{
int8_t rv;

if ( !(rv = sendVSCPFrame( vscp_omsg.vscp_class,
vscp_omsg.vscp_type,
vscp_nickname,
Expand Down
11 changes: 11 additions & 0 deletions common/vscp_firmware.h
Original file line number Diff line number Diff line change
Expand Up @@ -71,12 +71,23 @@ low end hardware device.
#define construct_signed16( msb, lsb ) ((int16_t)( (((uint16_t)msb)<<8) + \
(uint16_t)lsb) )

// This macro construct a unsigned integer from two unsigned chars in a safe way
#define construct_unsigned16( msb, lsb ) ((uint16_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);

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


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

0 comments on commit c504853

Please sign in to comment.