Files
@ a2c96432427b
Branch filter:
Location: therm-ng/drivers/STM32F3xx_HAL_Driver/Src/stm32f3xx_hal_crc_ex.c - annotation
a2c96432427b
8.9 KiB
text/plain
Use tim17 to gen pwmout; oc doesn't work so using isr
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 236 237 | f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d f94ab6abb81d | /**
******************************************************************************
* @file stm32f3xx_hal_crc_ex.c
* @author MCD Application Team
* @version V1.2.0
* @date 13-November-2015
* @brief Extended CRC HAL module driver.
* This file provides firmware functions to manage the extended
* functionalities of the CRC peripheral.
*
@verbatim
================================================================================
##### How to use this driver #####
================================================================================
[..]
(+) Set user-defined generating polynomial thru HAL_CRCEx_Polynomial_Set()
(+) Configure Input or Output data inversion
@endverbatim
******************************************************************************
* @attention
*
* <h2><center>© COPYRIGHT(c) 2015 STMicroelectronics</center></h2>
*
* Redistribution and use in source and binary forms, with or without modification,
* are permitted provided that the following conditions are met:
* 1. Redistributions of source code must retain the above copyright notice,
* this list of conditions and the following disclaimer.
* 2. Redistributions in binary form must reproduce the above copyright notice,
* this list of conditions and the following disclaimer in the documentation
* and/or other materials provided with the distribution.
* 3. Neither the name of STMicroelectronics nor the names of its contributors
* may be used to endorse or promote products derived from this software
* without specific prior written permission.
*
* THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
* AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE
* DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE LIABLE
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER
* CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY,
* OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE
* OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
******************************************************************************
*/
/* Includes ------------------------------------------------------------------*/
#include "stm32f3xx_hal.h"
/** @addtogroup STM32F3xx_HAL_Driver
* @{
*/
/** @defgroup CRCEx CRCEx
* @brief CRC Extended HAL module driver
* @{
*/
#ifdef HAL_CRC_MODULE_ENABLED
/* Private typedef -----------------------------------------------------------*/
/* Private define ------------------------------------------------------------*/
/* Private macro -------------------------------------------------------------*/
/* Private variables ---------------------------------------------------------*/
/* Private function prototypes -----------------------------------------------*/
/* Exported functions --------------------------------------------------------*/
/** @defgroup CRCEx_Exported_Functions CRC Extended Exported Functions
* @{
*/
/** @defgroup CRCEx_Exported_Functions_Group1 CRC Extended Initialization and de-initialization functions
* @brief CRC Extended Initialization and Configuration functions.
*
@verbatim
===============================================================================
##### Extended configuration functions #####
===============================================================================
[..] This section provides functions allowing to:
(+) Configure the generating polynomial
(+) Configure the input data inversion
(+) Configure the output data inversion
@endverbatim
* @{
*/
/**
* @brief Initialize the CRC polynomial if different from default one.
* @param hcrc: CRC handle
* @param Pol: CRC generating polynomial (7, 8, 16 or 32-bit long).
* This parameter is written in normal representation, e.g.
* @arg for a polynomial of degree 7, X^7 + X^6 + X^5 + X^2 + 1 is written 0x65
* @arg for a polynomial of degree 16, X^16 + X^12 + X^5 + 1 is written 0x1021
* @param PolyLength: CRC polynomial length.
* This parameter can be one of the following values:
* @arg CRC_POLYLENGTH_7B: 7-bit long CRC (generating polynomial of degree 7)
* @arg CRC_POLYLENGTH_8B: 8-bit long CRC (generating polynomial of degree 8)
* @arg CRC_POLYLENGTH_16B: 16-bit long CRC (generating polynomial of degree 16)
* @arg CRC_POLYLENGTH_32B: 32-bit long CRC (generating polynomial of degree 32)
* @retval HAL status
*/
HAL_StatusTypeDef HAL_CRCEx_Polynomial_Set(CRC_HandleTypeDef *hcrc, uint32_t Pol, uint32_t PolyLength)
{
uint32_t msb = 31; /* polynomial degree is 32 at most, so msb is initialized to max value */
/* Check the parameters */
assert_param(IS_CRC_POL_LENGTH(PolyLength));
/* check polynomial definition vs polynomial size:
* polynomial length must be aligned with polynomial
* definition. HAL_ERROR is reported if Pol degree is
* larger than that indicated by PolyLength.
* Look for MSB position: msb will contain the degree of
* the second to the largest polynomial member. E.g., for
* X^7 + X^6 + X^5 + X^2 + 1, msb = 6. */
while (((Pol & (1U << msb)) == 0) && (msb-- > 0)){}
switch (PolyLength)
{
case CRC_POLYLENGTH_7B:
if (msb >= HAL_CRC_LENGTH_7B)
{
return HAL_ERROR;
}
break;
case CRC_POLYLENGTH_8B:
if (msb >= HAL_CRC_LENGTH_8B)
{
return HAL_ERROR;
}
break;
case CRC_POLYLENGTH_16B:
if (msb >= HAL_CRC_LENGTH_16B)
{
return HAL_ERROR;
}
break;
case CRC_POLYLENGTH_32B:
/* no polynomial definition vs. polynomial length issue possible */
break;
default:
break;
}
/* set generating polynomial */
WRITE_REG(hcrc->Instance->POL, Pol);
/* set generating polynomial size */
MODIFY_REG(hcrc->Instance->CR, CRC_CR_POLYSIZE, PolyLength);
/* Return function status */
return HAL_OK;
}
/**
* @brief Set the Reverse Input data mode.
* @param hcrc: CRC handle
* @param InputReverseMode: Input Data inversion mode.
* This parameter can be one of the following values:
* @arg CRC_INPUTDATA_NOINVERSION: no change in bit order (default value)
* @arg CRC_INPUTDATA_INVERSION_BYTE: Byte-wise bit reversal
* @arg CRC_INPUTDATA_INVERSION_HALFWORD: HalfWord-wise bit reversal
* @arg CRC_INPUTDATA_INVERSION_WORD: Word-wise bit reversal
* @retval HAL status
*/
HAL_StatusTypeDef HAL_CRCEx_Input_Data_Reverse(CRC_HandleTypeDef *hcrc, uint32_t InputReverseMode)
{
/* Check the parameters */
assert_param(IS_CRC_INPUTDATA_INVERSION_MODE(InputReverseMode));
/* Change CRC peripheral state */
hcrc->State = HAL_CRC_STATE_BUSY;
/* set input data inversion mode */
MODIFY_REG(hcrc->Instance->CR, CRC_CR_REV_IN, InputReverseMode);
/* Change CRC peripheral state */
hcrc->State = HAL_CRC_STATE_READY;
/* Return function status */
return HAL_OK;
}
/**
* @brief Set the Reverse Output data mode.
* @param hcrc: CRC handle
* @param OutputReverseMode: Output Data inversion mode.
* This parameter can be one of the following values:
* @arg CRC_OUTPUTDATA_INVERSION_DISABLE: no CRC inversion (default value)
* @arg CRC_OUTPUTDATA_INVERSION_ENABLE: bit-level inversion (e.g. for a 8-bit CRC: 0xB5 becomes 0xAD)
* @retval HAL status
*/
HAL_StatusTypeDef HAL_CRCEx_Output_Data_Reverse(CRC_HandleTypeDef *hcrc, uint32_t OutputReverseMode)
{
/* Check the parameters */
assert_param(IS_CRC_OUTPUTDATA_INVERSION_MODE(OutputReverseMode));
/* Change CRC peripheral state */
hcrc->State = HAL_CRC_STATE_BUSY;
/* set output data inversion mode */
MODIFY_REG(hcrc->Instance->CR, CRC_CR_REV_OUT, OutputReverseMode);
/* Change CRC peripheral state */
hcrc->State = HAL_CRC_STATE_READY;
/* Return function status */
return HAL_OK;
}
/**
* @}
*/
/**
* @}
*/
#endif /* HAL_CRC_MODULE_ENABLED */
/**
* @}
*/
/**
* @}
*/
/************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/
|