comp.c 2.8 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103
  1. /**
  2. ******************************************************************************
  3. * @file comp.c
  4. * @brief 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.InputMinus = COMP_INPUT_MINUS_1_4VREFINT;
  29. hcomp1.Init.InputPlus = COMP_INPUT_PLUS_IO1;
  30. hcomp1.Init.OutputPol = COMP_OUTPUTPOL_NONINVERTED;
  31. hcomp1.Init.Hysteresis = COMP_HYSTERESIS_HIGH;
  32. hcomp1.Init.BlankingSrce = COMP_BLANKINGSRC_NONE;
  33. hcomp1.Init.Mode = COMP_POWERMODE_MEDIUMSPEED;
  34. hcomp1.Init.WindowMode = COMP_WINDOWMODE_DISABLE;
  35. hcomp1.Init.TriggerMode = COMP_TRIGGERMODE_IT_RISING_FALLING;
  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. /* COMP1 interrupt Init */
  57. HAL_NVIC_SetPriority(COMP_IRQn, 5, 0);
  58. HAL_NVIC_EnableIRQ(COMP_IRQn);
  59. /* USER CODE BEGIN COMP1_MspInit 1 */
  60. /* USER CODE END COMP1_MspInit 1 */
  61. }
  62. }
  63. void HAL_COMP_MspDeInit(COMP_HandleTypeDef* compHandle)
  64. {
  65. if(compHandle->Instance==COMP1)
  66. {
  67. /* USER CODE BEGIN COMP1_MspDeInit 0 */
  68. /* USER CODE END COMP1_MspDeInit 0 */
  69. /**COMP1 GPIO Configuration
  70. PC5 ------> COMP1_INP
  71. */
  72. HAL_GPIO_DeInit(RFID_RF_IN_GPIO_Port, RFID_RF_IN_Pin);
  73. /* COMP1 interrupt Deinit */
  74. HAL_NVIC_DisableIRQ(COMP_IRQn);
  75. /* USER CODE BEGIN COMP1_MspDeInit 1 */
  76. /* USER CODE END COMP1_MspDeInit 1 */
  77. }
  78. }
  79. /* USER CODE BEGIN 1 */
  80. /* USER CODE END 1 */
  81. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/