Skip to content

Commit

Permalink
Add some macros
Browse files Browse the repository at this point in the history
  • Loading branch information
christoph2 committed Jan 12, 2020
1 parent 074f0a4 commit f80a4cc
Show file tree
Hide file tree
Showing 2 changed files with 11 additions and 2 deletions.
12 changes: 10 additions & 2 deletions inc/xcp_macros.h
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
/*
* BlueParrot XCP
*
* (C) 2007-2019 by Christoph Schueler <github.com/Christoph2,
* (C) 2007-2020 by Christoph Schueler <github.com/Christoph2,
* cpu12.gems@googlemail.com>
*
* All Rights Reserved
Expand Down Expand Up @@ -60,13 +60,21 @@ extern "C"
#endif

#if !defined(XCP_LOWORD)
#define XCP_LOWORD(w) ((uint16_t)((w) & (uint16_t)0xffff)) /**< Get the low-word from a doubleword. */
#define XCP_LOWORD(w) ((uint16_t)((w) & (uint16_t)0xffff)) /**< Get the low-word from a double-word. */
#endif

#if !defined(XCP_HIWORD)
#define XCP_HIWORD(w) ((uint16_t)(((w) & (uint32_t)0xffff0000) >> 16)) /**< Get the high-word from a doubleword. */
#endif

#if !defined(XCP_MAKEWORD)
#define XCP_MAKEWORD(h, l) ((((uint16_t)((h) & ((uint8_t)0xff))) << (uint16_t)8) | ((uint16_t)((l) & ((uint8_t)0xff)))) /**< Make word from high and low bytes. */
#endif

#if !defined(XCP_MAKEDWORD)
#define XCP_MAKEDWORD(h, l) ((((uint32)((h) & ((uint16)0xffffu))) << (uint32)16) | ((uint32)((l) & ((uint16)0xffffu)))) /**< Make double-word from high and low words. */
#endif

#if !defined(XCP_MAX)
#define XCP_MAX(l, r) ((l) > (r) ? (l) : (r)) /**< Computes the maximum of \a l and \a r. */
#endif
Expand Down
1 change: 1 addition & 0 deletions inc/xcp_util.h
Original file line number Diff line number Diff line change
Expand Up @@ -43,6 +43,7 @@ bool XcpUtl_MemCmp(void const * dst, void const * src, uint32_t len);
void XcpUtl_Hexdump(uint8_t const * buf, uint16_t sz);
void XcpUtl_Itoa(uint32_t value, uint8_t base, uint8_t * buf);

#define XcpUtl_ZeroMem(dest, len) XcpUtl_MemSet((dest), '\0', (len))

#if XCP_ENABLE_EXTERN_C_GUARDS == XCP_ON
#if defined(__cplusplus)
Expand Down

0 comments on commit f80a4cc

Please sign in to comment.