comp.c 3.1 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113
  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) 2021 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. /* USER CODE BEGIN COMP1_Init 0 */
  28. /* USER CODE END COMP1_Init 0 */
  29. /* USER CODE BEGIN COMP1_Init 1 */
  30. /* USER CODE END COMP1_Init 1 */
  31. hcomp1.Instance = COMP1;
  32. hcomp1.Init.InputMinus = COMP_INPUT_MINUS_1_4VREFINT;
  33. hcomp1.Init.InputPlus = COMP_INPUT_PLUS_IO1;
  34. hcomp1.Init.OutputPol = COMP_OUTPUTPOL_NONINVERTED;
  35. hcomp1.Init.Hysteresis = COMP_HYSTERESIS_HIGH;
  36. hcomp1.Init.BlankingSrce = COMP_BLANKINGSRC_NONE;
  37. hcomp1.Init.Mode = COMP_POWERMODE_MEDIUMSPEED;
  38. hcomp1.Init.WindowMode = COMP_WINDOWMODE_DISABLE;
  39. hcomp1.Init.TriggerMode = COMP_TRIGGERMODE_IT_RISING_FALLING;
  40. if (HAL_COMP_Init(&hcomp1) != HAL_OK)
  41. {
  42. Error_Handler();
  43. }
  44. /* USER CODE BEGIN COMP1_Init 2 */
  45. /* USER CODE END COMP1_Init 2 */
  46. }
  47. void HAL_COMP_MspInit(COMP_HandleTypeDef* compHandle)
  48. {
  49. GPIO_InitTypeDef GPIO_InitStruct = {0};
  50. if(compHandle->Instance==COMP1)
  51. {
  52. /* USER CODE BEGIN COMP1_MspInit 0 */
  53. /* USER CODE END COMP1_MspInit 0 */
  54. __HAL_RCC_GPIOC_CLK_ENABLE();
  55. /**COMP1 GPIO Configuration
  56. PC5 ------> COMP1_INP
  57. */
  58. GPIO_InitStruct.Pin = RFID_RF_IN_Pin;
  59. GPIO_InitStruct.Mode = GPIO_MODE_ANALOG;
  60. GPIO_InitStruct.Pull = GPIO_NOPULL;
  61. HAL_GPIO_Init(RFID_RF_IN_GPIO_Port, &GPIO_InitStruct);
  62. /* COMP1 interrupt Init */
  63. HAL_NVIC_SetPriority(COMP_IRQn, 5, 0);
  64. HAL_NVIC_EnableIRQ(COMP_IRQn);
  65. /* USER CODE BEGIN COMP1_MspInit 1 */
  66. /* USER CODE END COMP1_MspInit 1 */
  67. }
  68. }
  69. void HAL_COMP_MspDeInit(COMP_HandleTypeDef* compHandle)
  70. {
  71. if(compHandle->Instance==COMP1)
  72. {
  73. /* USER CODE BEGIN COMP1_MspDeInit 0 */
  74. /* USER CODE END COMP1_MspDeInit 0 */
  75. /**COMP1 GPIO Configuration
  76. PC5 ------> COMP1_INP
  77. */
  78. HAL_GPIO_DeInit(RFID_RF_IN_GPIO_Port, RFID_RF_IN_Pin);
  79. /* COMP1 interrupt Deinit */
  80. HAL_NVIC_DisableIRQ(COMP_IRQn);
  81. /* USER CODE BEGIN COMP1_MspDeInit 1 */
  82. /* USER CODE END COMP1_MspDeInit 1 */
  83. }
  84. }
  85. /* USER CODE BEGIN 1 */
  86. /* USER CODE END 1 */
  87. /************************ (C) COPYRIGHT STMicroelectronics *****END OF FILE****/