STC15W408AS library
0.15.0
Loading...
Searching...
No Matches
include
counter0_mode2.h
Go to the documentation of this file.
1
#ifndef STC15_COUNTER0_MODE2H
2
#define STC15_COUNTER0_MODE2H
3
20
#include <stdint.h>
21
#include <assert.h>
22
23
#include <
interrupt.h
>
24
30
#define T0 P34
31
37
#define INT0 P32
38
43
63
#define counter0_mode2_init() \
64
do { \
65
enable_mcu_interrupts(); \
66
enable_timer0_interrupt(); \
67
\
68
TMOD &= 0xF0; \
69
TMOD |= 0x06; \
70
\
71
TF0 = 0; \
72
TR0 = 0; \
73
} while(0)
74
76
81
93
#define counter0_mode2_start(value) \
94
do { \
95
static_assert(value <= 0xff, "value is too large"); \
96
\
97
TH0 = (uint8_t) value; \
98
\
99
TF0 = 0; \
100
TR0 = 1; \
101
} while(0)
102
110
#define counter0_mode2_stop() \
111
do { \
112
TR0 = 0; \
113
} while (0)
114
122
#define is_counter0_mode2_started() (TR0 == 1 && (is_counter0_mode2_gate_opened() || INT0 == 1) )
123
125
130
138
#define counter0_mode2_get_value() (TL0)
139
149
#define counter0_mode2_set_value(value) \
150
do { \
151
static_assert(value <= 0xff, "value is too large"); \
152
TH0 = value; \
153
} while(0)
154
156
161
170
#define counter0_mode2_enable_P35_output() (bit_set(INT_CLKO, SBIT0))
171
180
#define counter0_mode2_disable_P35_output() (bit_clr(INT_CLKO, CBIT0))
181
189
#define is_counter0_mode2_P35_output_enabled() (test_if_bit_set(INT_CLKO, SBIT0))
190
200
#define counter0_mode2_open_gate() (bit_clr(TMOD, CBIT3))
201
209
#define counter0_mode2_close_gate() (bit_set(TMOD, SBIT3))
210
218
#define is_counter0_mode2_gate_opened() (test_if_bit_cleared(TMOD, SBIT3))
219
221
222
#endif
interrupt.h
Generated by
1.9.8