바이트의 비트 수를 해석하는 함수

1805 단어 bit
/******************************** Function Description ************************************
*Function Name:    ParseBytes
*Function Desp:     bit ;
*Arguments    : 3 
*            uint32_t uiData: ;
*            uint8_t ucBitTotal: bit ;
*            uint8_t pucRes[]: 
*Return Value : uint8_t :bit 1 ;
*Author       : Qingsong.Cao
*Create Date  : 2013-01-22
*Modify       : None
********************************************************************************************/
uint8_t ParseBytes(uint32_t uiData, uint8_t ucBitTotal, uint8_t pucRes[])
{
    uint8_t i = 0;
    uint8_t j = 0;
    uint8_t ucTmp = 0;

    for (i=0; i<ucBitTotal; i++)
    {
        ucTmp = (uiData >> i) & 0x01;
        if (0x01 == ucTmp)
        {
            pucRes[j] = i;
            j++;
        }
    }

    return j;
}

좋은 웹페이지 즐겨찾기