STC15W408AS library
0.10.0
Loading...
Searching...
No Matches
include
counter2_mode0.h
Go to the documentation of this file.
1
#ifndef STC15_COUNTER2_MODE0H
2
#define STC15_COUNTER2_MODE0H
3
19
#include <assert.h>
20
#include <stdint.h>
21
#include <stdbool.h>
22
23
#include <
interrupt.h
>
24
#include <bits.h>
25
31
#define T2 P31
32
37
44
#define counter2_mode0_init() \
45
do { \
46
enable_mcu_interrupts(); \
47
enable_timer2_interrupt(); \
48
\
49
bit_clr(AUXR, CBIT4); \
50
bit_set(AUXR, SBIT3);
/* init Counter2 */
\
51
} while(0)
53
58
70
#define counter2_mode0_start(value) \
71
do { \
72
counter2_mode0_set_value(value); \
73
\
74
bit_set(AUXR, SBIT4); \
75
} while (0);
76
84
#define counter2_mode0_stop() \
85
do { \
86
bit_clr(AUXR, CBIT4); \
87
} while (0)
88
89
97
#define is_counter2_mode0_started() (test_if_bit_set(_AUXR, SBIT4))
99
104
112
#define counter2_mode0_get_value() ((((uint16_t) T2H) << 8) | T2L)
113
123
#define counter2_mode0_set_value(value) \
124
do { \
125
static_assert(value <= 0xffff, "value to large"); \
126
const uint16_t _val = (value); \
127
T2H = (uint8_t)(_val >> 8); \
128
T2L = (uint8_t)(_val & 0xff); \
129
} while(0)
131
136
144
#define counter2_mode0_enable_P30_output() (bit_set(INT_CLKO, SBIT2))
145
154
#define counter2_mode0_disable_P30_output() (bit_clr(INT_CLKO, CBIT2))
155
163
#define is_counter2_mode0_P30_output_enabled() (test_if_bit_set(INT_CLKO, SBIT2))
165
166
#endif
interrupt.h
Generated by
1.9.8