STC15W408AS library 0.9.0
delay.h
Go to the documentation of this file.
1#ifndef STC15_DELAYH
2#define STC15_DELAYH
3
12#include <stdint.h>
13#include <frequency.h>
14
20#define TICKS_DELAY_1ms ((uint16_t) (((get_master_clock_frequency() / 1000UL) - 30UL) / 18UL))
21
30#define delay_ms(ms) \
31{ \
32 { \
33 uint16_t ms_div = ms >> get_frequency_divider_scale(); \
34 do \
35 { \
36 uint16_t d = TICKS_DELAY_1ms; \
37 do \
38 { \
39 __asm NOP __endasm; \
40 __asm NOP __endasm; \
41 __asm NOP __endasm; \
42 } while (d--); \
43 } while (ms_div--); \
44 } \
45}
46
47#endif