MAVRK Embedded Software 0.91
Software Libraries for the MAVRK motherboard and related components

crc.h

Go to the documentation of this file.
00001 #ifndef _MSP430_CRC
00002 #define _MSP430_CRC
00003 /**************************************************************************************************************************************************
00004 *       crc.h               CRC definitions                                                                                                       *
00005 *                           TOOLS:    Built with IAR Kickstart V2/MS Visual C++ 6.0                                                               *
00006 *                                                                                                                                                 *
00007 *       Author:             Emil Lenchak                                                                                                          *
00008 *                                                                                                                                                 *
00009 *       Revision Date:      March 2004                                                                                                            *
00010 *                                                                                                                                                 *
00011 *       Revision Level:     1                                                                                                                     *
00012 ***************************************************************************************************************************************************
00013 *       Copyright © 2009-2012 Texas Instruments Incorporated - https://www.ti.com/                                                                 *
00014 ***************************************************************************************************************************************************
00015 *  Redistribution and use in source and binary forms, with or without modification, are permitted provided that the following conditions are met: *
00016 *                                                                                                                                                 *
00017 *    Redistributions of source code must retain the above copyright notice, this list of conditions and the following disclaimer.                 *
00018 *                                                                                                                                                 *
00019 *    Redistributions in binary form must reproduce the above copyright notice, this list of conditions and the following disclaimer in the        *
00020 *    documentation and/or other materials provided with the distribution.                                                                         *
00021 *                                                                                                                                                 *
00022 *    Neither the name of Texas Instruments Incorporated nor the names of its contributors may be used to endorse or promote products derived      *
00023 *    from this software without specific prior written permission.                                                                                *
00024 *                                                                                                                                                 *
00025 *  THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT          *
00026 *  LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT     *
00027 *  OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT         *
00028 *  LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY    *
00029 *  THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE      *
00030 *  OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.                                                                           *
00031 **************************************************************************************************************************************************/
00032 
00033 
00034 /************************
00035     CONSTANTS
00036 ************************/
00037 
00038 #ifdef __ICC430__  // for IAR Projects
00039 #define TBL_MEM const
00040 #else              // for CCS Projects
00041 #define TBL_MEM
00042 #endif 
00043 
00044 //#define CRC_DAT_PATH ".//..//..//dat//"
00045 //#define CRC_DAT_PATH "C:\\Program Files\\IAR Systems\\Embedded Workbench 3.2\\myProjects\\CRC\\dat\\"
00046 
00047 #define CRC_MSG_MAXSIZE        70
00048 #define CRC_TABLE_SIZE        256
00049 
00050 #define CRC_TEST_SEQ        "123456789"
00051 
00052 #define CRC16_CHECK         0xFEE8
00053 #define CRC16R_CHECK        0xBB3D
00054 #define CRC32_CHECK         0xFC891918
00055 #define CRC32R_CHECK        0xCBF43926
00056 /*
00057 // CRC-16: x16 + x15 + x2 + 1
00058 #define CRC16_POLY          0x8005
00059 #define CRC16_INIT_REM      0x0
00060 #define CRC16_FINAL_XOR     0x0
00061 */
00062 #define CRC16R_POLY         0xA001
00063 #define CRC16R_INIT_REM     0x0
00064 #define CRC16R_FINAL_XOR    0x0
00065 
00066 // CRC-CCITT: x16 + x12 + x5 + 1
00067 #define CRC16_POLY          0x1021
00068 #define CRC16_POLY_REF
00069 #define CRC16_INIT_REM      0x0
00070 #define CRC16_FINAL_XOR     0x0
00071 
00072 // CRC-32: x32 + ... + 1
00073 #define CRC32_POLY          0x04C11DB7
00074 #define CRC32_INIT_REM      0xFFFFFFFF
00075 #define CRC32_FINAL_XOR     0xFFFFFFFF
00076 
00077 #define CRC32R_POLY         0xEDB88320
00078 #define CRC32R_INIT_REM     0xFFFFFFFF
00079 #define CRC32R_FINAL_XOR    0xFFFFFFFF
00080 
00081 
00082 /**************************************************************************************************************************************************
00083 *               Prototypes                                                                                                                       
00084 **************************************************************************************************************************************************/
00085 #ifdef __cplusplus
00086 extern "C" {
00087 #endif
00088 
00089 unsigned short mvk_Make_Bitwise_Crc16 (unsigned short crc, unsigned short poly, 
00090                                        unsigned char *pmsg, unsigned int msg_size);
00091 unsigned short mvk_Make_Bitwise_Crc16_2 (unsigned short crc, unsigned short poly,
00092                                          unsigned char *pmsg, unsigned int msg_size);
00093 unsigned long mvk_Make_Bitwise_Crc32 (unsigned long crc, unsigned long poly, 
00094                                       unsigned char *pmsg, unsigned int msg_size);
00095 unsigned long mvk_Make_Bitwise_Crc32_2 (unsigned long crc, unsigned long poly, 
00096                                         unsigned char *pmsg, unsigned int msg_size);
00097 
00098 #ifdef __cplusplus
00099 }
00100 #endif
00101 
00102 
00103 
00104 #endif  // _MSP430_CRC
 All Data Structures Files Functions Variables Typedefs Enumerations Enumerator Defines