STC15W408AS library 0.9.0
power_management.h
Go to the documentation of this file.
1#ifndef POWER_MANAGEMENTH
2#define POWER_MANAGEMENTH
3
12#include <sys.h>
13#include <bits.h>
14#include <stdint.h>
15#include <stdbool.h>
16
22#define WIRC_H_ADDRESS 0xf8
23
29#define WIRC_L_ADDRESS 0xf9
30
43#define idle() (bit_set(PCON, SBIT0))
44
54#define power_down() \
55{ \
56 bit_set(PCON, SBIT1); \
57 __asm__("nop"); \
58 __asm__("nop"); \
59 __asm__("nop"); \
60}
61
73#define wakeup_timer_init(ticks) \
74{ \
75 WKTCH = (ticks >> 8) | 0x80; \
76 WKTCL = ticks & 0xff; \
77}
78
79static volatile __idata uint8_t * const wirc_h_ptr = (__idata uint8_t *) WIRC_H_ADDRESS;
80static volatile __idata uint8_t * const wirc_l_ptr = (__idata uint8_t *) WIRC_L_ADDRESS;
99#define wakeup_timer_internal_clk_freq() (((uint16_t)*wirc_h_ptr << 8) | *wirc_l_ptr)
100
101#endif
#define WIRC_L_ADDRESS
Wakeup timer internal clock frequency value low byte address.
Definition: power_management.h:29
#define WIRC_H_ADDRESS
Wakeup timer internal clock frequency value high byte address.
Definition: power_management.h:22