STC15W408AS library 0.18.0
Loading...
Searching...
No Matches
comparator.h
Go to the documentation of this file.
1#ifndef STC15_COMPARATORH
2#define STC15_COMPARATORH
3
4#include <sys.h>
5#include <interrupt.h>
6
22#define CMP_ENABLE_BIT_POS 7
26#define CMP_ENABLE_BIT_MASK bit_mask(CMP_ENABLE_BIT_POS)
30#define CMP_ENABLE_BIT (CMP_ENABLE_BIT_MASK)
31
33#define CMPCR1_DEFAULT_VALUE 0x00
35#define CMPCR2_DEFAULT_VALUE 0x09
36
42#define comparator_init_async() \
43do { \
44 CMPCR1 = CMPCR1_DEFAULT_VALUE; \
45 CMPCR2 = CMPCR2_DEFAULT_VALUE; \
46 \
47 enable_mcu_interrupts(); \
48 enable_comparator_interrupt(ANY_EDGE); \
49} while(0)
50
58#define comparator_start() (bit_set(CMPCR1, CMP_ENABLE_BIT))
59
67#define comparator_stop() (bit_clr(CMPCR1, CMP_ENABLE_BIT))
68
69#endif