STC15W408AS library 0.9.0
timer_to_ms_common.h
Go to the documentation of this file.
1#ifndef STC15_TIMER_TO_MS_COMMONH
2#define STC15_TIMER_TO_MS_COMMONH
3
13#include <stdint.h>
14#include <frequency.h>
15#include <timer_structs.h>
32#define timer_uint16_ticks_to_freq100(ticks, timer_clock_divider, frequency_divider_scale) ((100 * get_master_clock_frequency() / (timer_clock_divider * (1 + (uint32_t)ticks))) >> frequency_divider_scale)
33
55#define timer_frequency_to_ticks_unsafe(frequency, timer_clock_divider, frequency_divider_scale) (((get_master_clock_frequency() >> 1) / (frequency * timer_clock_divider)) >> frequency_divider_scale)
56
69#define timer_ticks_to_ms_usafe(ticks, timer_divider, frequency_divider_scale) (((1UL + (uint32_t)ticks) / ((get_master_clock_frequency_high_part() / timer_divider) >> frequency_divider_scale)))
70
85#define timer_ms_to_ticks_usafe(ms, timer_clock_divider) (ms * ((get_master_clock_frequency_high_part() + 26) >> get_frequency_divider_scale()) / timer_clock_divider)
86
87#endif