Mistake on this page?
Report an issue in GitHub or email us
checksumutils.h
Go to the documentation of this file.
1 /**
2  ******************************************************************************
3  * @file checksumutils.h
4  * @author MCD Application Team
5  * @brief Header for checksumutils.c module
6  ******************************************************************************
7  * @attention
8  *
9  * Copyright (c) 2021 STMicroelectronics.
10  * All rights reserved.
11  *
12  * This software is licensed under terms that can be found in the LICENSE file
13  * in the root directory of this software component.
14  * If no LICENSE file comes with this software, it is provided AS-IS.
15  *
16  ******************************************************************************
17  */
18 
19 /* Define to prevent recursive inclusion -------------------------------------*/
20 #ifndef CHECKSUM_UTILS_H
21 #define CHECKSUM_UTILS_H
22 
23 #ifdef __cplusplus
24 extern "C" {
25 #endif
26 
27 /* Includes ------------------------------------------------------------------*/
28 /*cstat -MISRAC2012-* */
29 #include <stddef.h>
30 #include <stdint.h>
31 /*cstat +MISRAC2012-* */
32 
33 
34 /* NOTE: MUST ENABLE STM32L HARDWARE CRC periph before use this API
35 #define USE_STM32L_CRC
36  */
37 
38 #ifdef USE_STM32L_CRC
39 /*cstat -MISRAC2012-* */
40 #include "stm32l4xx_hal.h"
41 /*cstat +MISRAC2012-* */
42 #endif /* USE_STM32L_CRC */
43 
44 
45 /********************* CRC8 MXOS Check **************************************
46  ******************CRC-8 XMODEM x8+x5+x4+1******************************
47  ****************************************************************************/
48 
49 typedef struct
50 {
51  uint8_t crc;
52 } CRC8_Context;
53 
54 /**
55  * @brief initialize the CRC8 Context
56  *
57  * @param inContext holds CRC8 result
58  *
59  * @retval none
60  */
61 void CRC8_Init(CRC8_Context *inContext);
62 
63 
64 /**
65  * @brief Calculate the CRC8 result
66  *
67  * @param inContext holds CRC8 result during calculation process
68  * @param inSrc input data
69  * @param inLen length of input data
70  *
71  * @retval none
72  */
73 void CRC8_Update(CRC8_Context *inContext, const uint8_t *inSrc, size_t inLen);
74 
75 
76 /**
77  * @brief output CRC8 result
78  *
79  * @param inContext holds CRC8 result
80  * @param outResutl holds CRC8 final result
81  *
82  * @retval none
83  */
84 void CRC8_Final(CRC8_Context *inContext, uint8_t *outResult);
85 
86 
87 /********************* CRC16 MXOS Check **************************************
88  ******************CRC-16/XMODEM x16+x12+x5+1******************************
89  ******************************************************************************/
90 
91 #ifdef USE_STM32L_CRC
92 
93 int8_t HW_CRC16_Init(CRC_HandleTypeDef *CrcHandle);
94 int8_t HW_CRC16_Update(CRC_HandleTypeDef *CrcHandle, uint8_t *input_data, uint32_t input_len, uint16_t *crc16_out);
95 
96 #else
97 
98 typedef struct
99 {
100  uint16_t crc;
101 } CRC16_Context;
102 
103 /**
104  * @brief initialize the CRC16 Context
105  *
106  * @param inContext holds CRC16 result
107  *
108  * @retval none
109  */
110 void CRC16_Init(CRC16_Context *inContext);
111 
112 
113 /**
114  * @brief Calculate the CRC16 result
115  *
116  * @param inContext holds CRC16 result during calculation process
117  * @param inSrc input data
118  * @param inLen length of input data
119  *
120  * @retval none
121  */
122 void CRC16_Update(CRC16_Context *inContext, const uint8_t *inSrc, size_t inLen);
123 
124 
125 /**
126  * @brief output CRC16 result
127  *
128  * @param inContext holds CRC16 result
129  * @param outResutl holds CRC16 final result
130  *
131  * @retval none
132  */
133 void CRC16_Final(CRC16_Context *inContext, uint16_t *outResult);
134 
135 #endif /* USE_STM32L_CRC */
136 
137 
138 #ifdef __cplusplus
139 }
140 #endif
141 
142 #endif /* CHECKSUM_UTILS_H */
void CRC8_Final(CRC8_Context *inContext, uint8_t *outResult)
output CRC8 result
void CRC16_Update(CRC16_Context *inContext, const uint8_t *inSrc, size_t inLen)
Calculate the CRC16 result.
void CRC16_Init(CRC16_Context *inContext)
initialize the CRC16 Context
void CRC16_Final(CRC16_Context *inContext, uint16_t *outResult)
output CRC16 result
void CRC8_Update(CRC8_Context *inContext, const uint8_t *inSrc, size_t inLen)
Calculate the CRC8 result.
void CRC8_Init(CRC8_Context *inContext)
initialize the CRC8 Context
Important Information for this Arm website

This site uses cookies to store information on your computer. By continuing to use our site, you consent to our cookies. If you are not happy with the use of these cookies, please review our Cookie Policy to learn how they can be disabled. By disabling cookies, some features of the site will not work.