|
|
UDI_MBGET, UDI_MBGET_2, UDI_MBGET_3, UDI_MBGET_4
Multi-byte extract helper macros
#include <udi.h>#define UDI_MBGET(N, structp, field) \ UDI_MBGET_##N (structp, field) #define UDI_MBGET_2(structp, field) \ ((structp)->field##0 | ((structp)->field##1<<8)) #define UDI_MBGET_3(structp, field) \ ((structp)->field##0 | ((structp)->field##1<<8) | \ ((structp)->field##2<<16)) #define UDI_MBGET_4(structp, field) \ ((structp)->field##0 | ((structp)->field##1<<8) | \ ((structp)->field##2<<16)|((structp)->field##3<<24))ARGUMENTS N is the number of bytes in the corresponding multi-byte quantity. N must be 2, 3, or 4.
structp is a pointer to a structure that contains N single-byte (and byte-aligned) members whose names are field0, field1, ... fieldn (n=N-1), which together represent an N-byte quantity in the structure.
field is the base name of a sequence of members in structp. The name of each member in the sequence is field followed by a decimal number in the range 0..N-1; this number represents the byte number in a multi-byte quantity, with byte 0 being the least significant byte. Each of these structure members must be of type udi_ubit8_t.
DESCRIPTION These macros are used to extract multi-byte quantities from a structure which has been constructed according to the byte-by-byte layout rules given in Section 22.2.1.1. The structure is pointed to by the structp argument, and the multi-byte quantities are represented by a sequence of fields in the structure whose names are based on the field argument.
As described above, the structp argument is a pointer to a structure that contains N single-byte (and byte-aligned) members whose names are field0, field1, ... fieldn (n=N-1), which together represent an N-byte quantity in the structure. field0 is the least significant byte; fieldn is the most significant.
UDI_MBGET extracts an N-byte unsigned quantity from the structure pointed to by structp. UDI_MBGET_2, UDI_MBGET_3, and UDI_MBGET_4, extract 2, 3, and 4-byte quantities, respectively.
These macros don't translate well into functional interfaces, so no corresponding functional interfaces are given.