1 /****************************************************************************** 2 * 3 * Copyright (C) 2018 ST Microelectronics S.A. 4 * 5 * Licensed under the Apache License, Version 2.0 (the "License"); 6 * you may not use this file except in compliance with the License. 7 * You may obtain a copy of the License at: 8 * 9 * http://www.apache.org/licenses/LICENSE-2.0 10 * 11 * Unless required by applicable law or agreed to in writing, software 12 * distributed under the License is distributed on an "AS IS" BASIS, 13 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. 14 * See the License for the specific language governing permissions and 15 * limitations under the License. 16 * 17 * 18 ******************************************************************************/ 19 #ifndef ISO13239CRC_H_ 20 #define ISO13239CRC_H_ 21 22 //************************************ Defines ********************************* 23 #define CRC_PRESET 0xFFFF 24 #define CRC_POLYNOMIAL 0x8408 25 26 #include <stdint.h> 27 28 //************************************ Structs ********************************* 29 30 //************************************ Functions ******************************* 31 32 /** 33 * Computes the 16-bit CRC of the specified function. 34 * 35 * @param data The data to compute the CRC over. 36 * @param len The length of the data. 37 * 38 * @return The CRC of the data. -1 if something went wrong. 39 */ 40 uint16_t computeCrc(uint8_t *data, int len); 41 42 #endif /* ISO13239CRC_H_ */ 43