STC15W408AS library 0.18.0
Loading...
Searching...
No Matches
frequency.h
Go to the documentation of this file.
1#ifndef STC15_FREQH
2#define STC15_FREQH
3
13#include <sys.h>
14#include <bits.h>
15
21#define CLK_DIV_MASK 0x07
22
31#define get_master_clock_frequency() (MAIN_Fosc)
32
40#define get_master_clock_frequency_high_part() (MAIN_FoscH)
41
49#define get_master_clock_frequency_low_part() (MAIN_FoscL)
50
60#define get_frequency_divider() (1 << get_frequency_divider_scale())
61
71#define get_frequency_divider_scale() (CLK_DIV & CLK_DIV_MASK)
72
85#define set_frequency_divider_scale(divider_scale) \
86do { \
87 CLK_DIV &= 0xf8; \
88 CLK_DIV |= (divider_scale & CLK_DIV_MASK); \
89} while(0)
90
91
113#define SYSclk (get_master_clock_frequency() >> get_frequency_divider_scale())
114
123#define enable_master_clock_output_div1() (CLK_DIV |= 0x40)
124
133#define enable_master_clock_output_div2() (CLK_DIV |= 0x80)
134
143#define enable_master_clock_output_div4() (CLK_DIV |= 0xC0)
144
154#define disable_master_clock_output() (CLK_DIV &= 0x3f)
155
170
178#define get_master_clock_output_pin() ((CLK_DIV & 0xC0) == 0 ? NONE : (CLK_DIV & 0x08) == 0 ? P5_4 : P1_6)
179
187#pragma save
188#pragma disable_warning 126
189#define set_master_clock_output_pin(pin) \
190do { \
191 if (pin == NONE) \
192 { \
193 disable_master_clock_output(); \
194 } \
195 else if (pin == P5_4) \
196 { \
197 bit_clr(CLK_DIV, SBIT3); \
198 } \
199 else if (pin == P1_6) \
200 { \
201 bit_set(CLK_DIV, SBIT3); \
202 } \
203} while(0)
204#pragma restore
205
206#endif
master_clock_output_pin_t
Master clock output pins enumeration.
Definition frequency.h:162
@ P1_6
output to pin 1.6
Definition frequency.h:168
@ P5_4
output to pin 5.4
Definition frequency.h:166
@ NONE
output disabled
Definition frequency.h:164