ETHFW API Guide
Miscellaneous Utilities

Introduction

Functions

void appLogPrintf (const char *format,...)
 
static void EthFwUtils_assertLocal (bool condition, const char *str, const char *fileName, int32_t lineNum)
 
static void EthFwUtils_copyMacAddr (uint8_t *dst, const uint8_t *src)
 
static bool EthFwUtils_cmpMacAddr (const uint8_t *addr1, const uint8_t *addr2)
 
static bool EthFwUtils_isMcastAddr (const uint8_t *addr)
 

Macros

#define ETHFW_CFG_ASSERT_ENABLE   (1)
 Whether assertions are enabled or not. More...
 
#define ETHFW_MAC_ADDR_LEN   (6U)
 MAC address length. More...
 
#define ETHFW_UNUSED(x)   (x = x)
 Unused variable. More...
 
#define ETHFW_UTILS_ALIGN(x, y)   ((((x) + ((y) - 1)) / (y)) * (y))
 Align a value by performing a round-up operation. More...
 
#define ETHFW_UTILS_IS_ALIGNED(addr, alignSz)   (((uintptr_t)addr & ((alignSz) - 1U)) == 0U)
 Macro to determine if an address is aligned to a given size. More...
 
#define ETHFW_UTILS_ARRAY_COPY(dst, src)
 Macro to copy arrays. They must be of the same size. More...
 
#define EthFw_assert(cond, ...)
 Assertion. More...
 
#define EthFw_devAssert(cond, ...)
 Development-time assertion. More...
 
#define ETHFW_UTILS_COMPILETIME_ASSERT(cond)
 Compile-time assertion. More...
 

Macro Definition Documentation

◆ ETHFW_CFG_ASSERT_ENABLE

#define ETHFW_CFG_ASSERT_ENABLE   (1)

Whether assertions are enabled or not.

◆ ETHFW_MAC_ADDR_LEN

#define ETHFW_MAC_ADDR_LEN   (6U)

MAC address length.

◆ ETHFW_UNUSED

#define ETHFW_UNUSED (   x)    (x = x)

Unused variable.

◆ ETHFW_UTILS_ALIGN

#define ETHFW_UTILS_ALIGN (   x,
 
)    ((((x) + ((y) - 1)) / (y)) * (y))

Align a value by performing a round-up operation.

◆ ETHFW_UTILS_IS_ALIGNED

#define ETHFW_UTILS_IS_ALIGNED (   addr,
  alignSz 
)    (((uintptr_t)addr & ((alignSz) - 1U)) == 0U)

Macro to determine if an address is aligned to a given size.

◆ ETHFW_UTILS_ARRAY_COPY

#define ETHFW_UTILS_ARRAY_COPY (   dst,
  src 
)
Value:
do \
{ \
/* dst argument of macro should be array and not pointer.*/ \
ETHFW_UTILS_COMPILETIME_ASSERT(sizeof(dst) != sizeof(uintptr_t)); \
memcpy(dst, src, (ETHFW_ARRAYSIZE(dst) * sizeof(dst[0]))); \
} while (0)
#define ETHFW_ARRAYSIZE(x)
Macro to get the size of an array.
Definition: ethfw_types.h:128

Macro to copy arrays. They must be of the same size.

◆ EthFw_assert

#define EthFw_assert (   cond,
  ... 
)
Value:
do { \
ETHFWTRACE_ERR_IF(!(bool)(cond), ETHFW_EFAIL, __VA_ARGS__); \
EthFwUtils_assertLocal((bool)(cond), \
(const char *)# cond, \
(const char *)__FILE__, \
(int32_t)__LINE__); \
} while (0)
#define ETHFW_EFAIL
Generic failure error condition (typically caused by hardware).
Definition: ethfw_types.h:93

Assertion.

◆ EthFw_devAssert

#define EthFw_devAssert (   cond,
  ... 
)
Value:
do { \
ETHFWTRACE_ERR_IF(!(bool)(cond), ETHFW_EFAIL, __VA_ARGS__); \
EthFwUtils_assertLocal((bool)(cond), \
(const char *)# cond, \
(const char *)__FILE__, \
(int32_t)__LINE__); \
} while (0)
#define ETHFW_EFAIL
Generic failure error condition (typically caused by hardware).
Definition: ethfw_types.h:93

Development-time assertion.

◆ ETHFW_UTILS_COMPILETIME_ASSERT

#define ETHFW_UTILS_COMPILETIME_ASSERT (   cond)
Value:
do { \
typedef char ErrorCheck[((cond) == true) ? 1 : -1]; \
ErrorCheck a = {0}; \
a[0U] = a[0U]; \
} while (0)

Compile-time assertion.

Function Documentation

◆ appLogPrintf()

void appLogPrintf ( const char *  format,
  ... 
)

◆ EthFwUtils_assertLocal()

static void EthFwUtils_assertLocal ( bool  condition,
const char *  str,
const char *  fileName,
int32_t  lineNum 
)
inlinestatic

◆ EthFwUtils_copyMacAddr()

static void EthFwUtils_copyMacAddr ( uint8_t *  dst,
const uint8_t *  src 
)
inlinestatic

◆ EthFwUtils_cmpMacAddr()

static bool EthFwUtils_cmpMacAddr ( const uint8_t *  addr1,
const uint8_t *  addr2 
)
inlinestatic

◆ EthFwUtils_isMcastAddr()

static bool EthFwUtils_isMcastAddr ( const uint8_t *  addr)
inlinestatic