/******************************** 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; }