drv_acmp.h 2.3 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465
  1. /******************************************************************//**
  2. * @file drv_acmp.h
  3. * @brief ACMP (analog comparator) driver of RT-Thread RTOS for EFM32
  4. * COPYRIGHT (C) 2011, RT-Thread Development Team
  5. * @author onelife
  6. * @version 0.4 beta
  7. **********************************************************************
  8. * @section License
  9. * The license and distribution terms for this file may be found in the file LICENSE in this
  10. * distribution or at http://www.rt-thread.org/license/LICENSE
  11. **********************************************************************
  12. * @section Change Logs
  13. * Date Author Notes
  14. * 2011-02-23 onelife Initial creation for EFM32
  15. *********************************************************************/
  16. #ifndef __DRV_ACMP_H__
  17. #define __DRV_ACMP_H__
  18. /* Includes -------------------------------------------------------------------*/
  19. #include "hdl_interrupt.h"
  20. /* Exported types -------------------------------------------------------------*/
  21. struct efm32_acmp_device_t
  22. {
  23. ACMP_TypeDef *acmp_device;
  24. efm32_irq_hook_t hook;
  25. };
  26. struct efm32_acmp_output_t
  27. {
  28. rt_uint32_t location;
  29. rt_bool_t enable;
  30. rt_bool_t invert;
  31. };
  32. struct efm32_acmp_control_t
  33. {
  34. ACMP_Init_TypeDef *init;
  35. ACMP_Channel_TypeDef posInput;
  36. ACMP_Channel_TypeDef negInput;
  37. struct efm32_acmp_output_t *output;
  38. efm32_irq_hook_t hook;
  39. };
  40. /* Exported constants ---------------------------------------------------------*/
  41. /* Exported macro -------------------------------------------------------------*/
  42. /** Default config for ACMP init structure. */
  43. #define ACMP_INIT_DEFAULT \
  44. { \
  45. false, /* Full bias current*/ \
  46. true, /* Half bias current */ \
  47. 0, /* Biasprog current configuration */ \
  48. true, /* Enable interrupt for falling edge */ \
  49. true, /* Enable interrupt for rising edge */ \
  50. acmpWarmTime512, /* Warm-up time must be >10us */ \
  51. acmpHysteresisLevel0, /* Hysteresis configuration */ \
  52. 0, /* Inactive comparator output value */ \
  53. false, /* Disable low power mode */ \
  54. 0 /* Vdd reference scaling */ \
  55. }
  56. /* Exported functions --------------------------------------------------------- */
  57. void rt_hw_acmp_init(void);
  58. #endif /*__DRV_ACMP_H__ */