XilinxProcessorIPLib/drivers/qspipsu/examples/xqspipsu_generic_nand_flash_interrupt_example.c
s32 XQspiPsu_ParamPageCrc(u8 *ParamBuf, u32 StartOff, u32 Length)
{
        const u32 CrcInit = 0x4F4EU;
        const u32 Order = 16U;
        const u32 Polynom = 0x8005U;
        u32 i, j, c, Bit;
        u32 Crc = CrcInit;
        u32 DataIn;
        u32 DataByteCount = 0U;
        u32 CrcMask, CrcHighBit;

        CrcMask = ((u32)(((u32)1 << (Order - (u32)1)) -(u32)1) << (u32)1) | (u32)1;
        CrcHighBit = (u32)((u32)1 << (Order - (u32)1));
        /*
         * CRC covers the data bytes between byte 0 and byte 253
         * (ONFI 1.0, section 5.4.1.36)
         */
        for (i = StartOff; i < Length; i++) {
                DataIn = *(ParamBuf + i);
                c = (u32)DataIn;
                DataByteCount++;
                j = 0x80U;
                while (j != 0U) {
                        Bit = Crc & CrcHighBit;
                        Crc <<= 1U;
                        if ((c & j) != 0U) {
                                Bit ^= CrcHighBit;
                        }
                        if (Bit != 0U) {
                                Crc ^= Polynom;
                        }
                        j >>= 1U;
                }
                Crc &= CrcMask;
        }
        return Crc;
}
/*****************************************************************************/
/**
*
* This function calculates parameter page CRC.
*
* @param        Parambuf is a pointer to the ONFI parameter page buffer.
* @param        StartOff is the starting offset in buffer to calculate CRC.
* @param        Length is the number of bytes for which CRC is calculated.
*
* @return
*               CRC value.
* @note
*               None.
*
******************************************************************************/
This function calculates parameter page CRC.
This function calculates parameter page CRC .
s32 XQspiPsu_ParamPageCrc(u8 *ParamBuf, u32 StartOff, u32 Length)
{
        const u32 CrcInit = 0x4F4EU;
        const u32 Order = 16U;
        const u32 Polynom = 0x8005U;
        u32 i, j, c, Bit;
        u32 Crc = CrcInit;
        u32 DataIn;
        u32 DataByteCount = 0U;
        u32 CrcMask, CrcHighBit;
        CrcMask = ((u32)(((u32)1 << (Order - (u32)1)) -(u32)1) << (u32)1) | (u32)1;
        CrcHighBit = (u32)((u32)1 << (Order - (u32)1));
        for (i = StartOff; i < Length; i++) {
                DataIn = *(ParamBuf + i);
                c = (u32)DataIn;
                DataByteCount++;
                j = 0x80U;
                while (j != 0U) {
                        Bit = Crc & CrcHighBit;
                        Crc <<= 1U;
                        if ((c & j) != 0U) {
                                Bit ^= CrcHighBit;
                        }
                        if (Bit != 0U) {
                                Crc ^= Polynom;
                        }
                        j >>= 1U;
                }
                Crc &= CrcMask;
        }
        return Crc;
}
s32 XQspiPsu_ParamPageCrc ( u8 * ParamBuf , u32 StartOff , u32 Length ) { const u32 CrcInit = 0x4F4EU ; const u32 Order = 16U ; const u32 Polynom = 0x8005U ; u32 i , j , c , Bit ; u32 Crc = CrcInit ; u32 DataIn ; u32 DataByteCount = 0U ; u32 CrcMask , CrcHighBit ; CrcMask = ( ( u32 ) ( ( ( u32 ) 1 << ( Order - ( u32 ) 1 ) ) - ( u32 ) 1 ) << ( u32 ) 1 ) | ( u32 ) 1 ; CrcHighBit = ( u32 ) ( ( u32 ) 1 << ( Order - ( u32 ) 1 ) ) ; for ( i = StartOff ; i < Length ; i ++ ) { DataIn = * ( ParamBuf + i ) ; c = ( u32 ) DataIn ; DataByteCount ++ ; j = 0x80U ; while ( j != 0U ) { Bit = Crc & CrcHighBit ; Crc <<= 1U ; if ( ( c & j ) != 0U ) { Bit ^= CrcHighBit ; } if ( Bit != 0U ) { Crc ^= Polynom ; } j >>= 1U ; } Crc &= CrcMask ; } return Crc ; }
This function calculates parameter page CRC.
This function calculates parameter page CRC .
/*
         * CRC covers the data bytes between byte 0 and byte 253
         * (ONFI 1.0, section 5.4.1.36)
         */