comp.c 2.7 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798
  1. /**
  2. ******************************************************************************
  3. * File Name : COMP.c
  4. * Description : This file provides code for the configuration
  5. * of the COMP instances.
  6. ******************************************************************************
  7. * @attention
  8. *
  9. * <h2><center>&copy; Copyright (c) 2020 STMicroelectronics.
  10. * All rights reserved.</center></h2>
  11. *
  12. * This software component is licensed by ST under Ultimate Liberty license
  13. * SLA0044, the "License"; You may not use this file except in compliance with
  14. * the License. You may obtain a copy of the License at:
  15. * www.st.com/SLA0044
  16. *
  17. ******************************************************************************
  18. */
  19. /* Includes ------------------------------------------------------------------*/
  20. #include "comp.h"
  21. /* USER CODE BEGIN 0 */
  22. /* USER CODE END 0 */
  23. COMP_HandleTypeDef hcomp1;
  24. /* COMP1 init function */
  25. void MX_COMP1_Init(void)
  26. {
  27. hcomp1.Instance = COMP1;
  28. hcomp1.Init.InvertingInput = COMP_INPUT_MINUS_1_2VREFINT;
  29. hcomp1.Init.NonInvertingInput = COMP_INPUT_PLUS_IO1;
  30. hcomp1.Init.OutputPol = COMP_OUTPUTPOL_NONINVERTED;
  31. hcomp1.Init.Hysteresis = COMP_HYSTERESIS_NONE;
  32. hcomp1.Init.BlankingSrce = COMP_BLANKINGSRC_NONE;
  33. hcomp1.Init.Mode = COMP_POWERMODE_HIGHSPEED;
  34. hcomp1.Init.WindowMode = COMP_WINDOWMODE_DISABLE;
  35. hcomp1.Init.TriggerMode = COMP_TRIGGERMODE_NONE;
  36. if (HAL_COMP_Init(&hcomp1) != HAL_OK)
  37. {
  38. Error_Handler();
  39. }
  40. }
  41. void HAL_COMP_MspInit(COMP_HandleTypeDef* compHandle)
  42. {
  43. GPIO_InitTypeDef GPIO_InitStruct = {0};
  44. if(compHandle->Instance==COMP1)
  45. {
  46. /* USER CODE BEGIN COMP1_MspInit 0 */
  47. /* USER CODE END COMP1_MspInit 0 */
  48. __HAL_RCC_GPIOC_CLK_ENABLE();
  49. /**COMP1 GPIO Configuration
  50. PC5 ------> COMP1_INP
  51. */
  52. GPIO_InitStruct.Pin = RFID_RF_IN_Pin;
  53. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  54. GPIO_InitStruct.Pull = GPIO_NOPULL;
  55. HAL_GPIO_Init(RFID_RF_IN_GPIO_Port, &GPIO_InitStruct);
  56. /* USER CODE BEGIN COMP1_MspInit 1 */
  57. /* USER CODE END COMP1_MspInit 1 */
  58. }
  59. }
  60. void HAL_COMP_MspDeInit(COMP_HandleTypeDef* compHandle)
  61. {
  62. if(compHandle->Instance==COMP1)
  63. {
  64. /* USER CODE BEGIN COMP1_MspDeInit 0 */
  65. /* USER CODE END COMP1_MspDeInit 0 */
  66. /**COMP1 GPIO Configuration
  67. PC5 ------> COMP1_INP
  68. */
  69. HAL_GPIO_DeInit(RFID_RF_IN_GPIO_Port, RFID_RF_IN_Pin);
  70. /* USER CODE BEGIN COMP1_MspDeInit 1 */
  71. /* USER CODE END COMP1_MspDeInit 1 */
  72. }
  73. }
  74. /* USER CODE BEGIN 1 */
  75. /* USER CODE END 1 */
  76. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/