STC15W408AS library
0.12.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
59
#define counter0_mode2_init() \
60
do { \
61
enable_mcu_interrupts(); \
62
enable_timer0_interrupt(); \
63
\
64
TMOD &= 0xF0; \
65
TMOD |= 0x06; \
66
\
67
TF0 = 0; \
68
TR0 = 0; \
69
} while(0)
70
72
77
89
#define counter0_mode2_start(value) \
90
do { \
91
static_assert(value <= 0xff, "value is too large"); \
92
\
93
TH0 = (uint8_t) value; \
94
\
95
TF0 = 0; \
96
TR0 = 1; \
97
} while(0)
98
106
#define counter0_mode2_stop() \
107
do { \
108
TR0 = 0; \
109
} while (0)
110
118
#define is_counter0_mode2_started() (TR0 == 1 && (is_counter0_mode2_gate_opened() || INT0 == 1) )
119
121
126
134
#define counter0_mode2_get_value() (TL0)
135
145
#define counter0_mode2_set_value(value) \
146
do { \
147
static_assert(value <= 0xff, "value is too large"); \
148
TH0 = value; \
149
} while(0)
150
152
157
166
#define counter0_mode2_enable_P35_output() (bit_set(INT_CLKO, SBIT0))
167
176
#define counter0_mode2_disable_P35_output() (bit_clr(INT_CLKO, CBIT0))
177
185
#define is_counter0_mode2_P35_output_enabled() (test_if_bit_set(INT_CLKO, SBIT0))
186
196
#define counter0_mode2_open_gate() (bit_clr(TMOD, CBIT3))
197
205
#define counter0_mode2_close_gate() (bit_set(TMOD, SBIT3))
206
214
#define is_counter0_mode2_gate_opened() (test_if_bit_cleared(TMOD, SBIT3))
215
217
218
#endif
interrupt.h
Generated by
1.9.8