comp.c 2.9 KB

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