工具
Detailed Description
详细描述
This module contains some utility functions which can be used by the application. It includes some special functions for working with bitfields backed by a character array buffer.
这个模块包括应用中使用的一些功能函数。这些功能函数包括一些特殊的通过字符数组缓冲方式对位域进行处理的功能
| |
Functions | |
void | xMBUtilSetBits (UCHAR *ucByteBuf, USHORT usBitOffset, UCHAR ucNBits, UCHAR ucValues) |
UCHAR | xMBUtilGetBits (UCHAR *ucByteBuf, USHORT usBitOffset, UCHAR ucNBits) |
Function Documentation
函数文档
|
| Function to read bits in a byte buffer. 在字节缓冲中读取位 This function is used to extract up bit values from an array. Up to eight bit values can be extracted in one step. 这个函数从一个字节中来获取一个位的值。一步最多可以获取8个位的值。 Parameters: 参数
UCHAR ucBits[2] = {0, 0};
UCHAR ucResult;
// Extract the bits 3 - 10. ucResult = xMBUtilGetBits( ucBits, 3, 8 );
|
|
| Function to set bits in a byte buffer. 设置一个字节缓冲的位 This function allows the efficient use of an array to implement bitfields. The array used for storing the bits must always be a multiple of two bytes. Up to eight bits can be set or cleared in one operation. 这个函数可以实现有效处理位域的功能。存储位域的数值必须是两个字节。一次操作最多可处理8位。 Parameters:
ucBits[2] = {0, 0};
// Set bit 4 to 1 (read: set 1 bit starting at bit offset 4 to value 1) xMBUtilSetBits( ucBits, 4, 1, 1 );
// Set bit 7 to 1 and bit 8 to 0. xMBUtilSetBits( ucBits, 7, 2, 0x01 );
// Set bits 8 - 11 to 0x05 and bits 12 - 15 to 0x0A; xMBUtilSetBits( ucBits, 8, 8, 0x5A);
|