STC15W408AS library 0.9.0
pin.h
Go to the documentation of this file.
1#ifndef STC15_PINH
2#define STC15_PINH
13#include <sys.h>
14#include <bits.h>
15#include <stdint.h>
16#include <stdbool.h>
17
31#define pin_quasi_bidiretional_init(port, port_pin) \
32{ \
33 bit_clr(port ## M1, ~(1 << port_pin)); \
34 bit_clr(port ## M0, ~(1 << port_pin)); \
35}
36
51#define pin_push_pull_init(port, port_pin) \
52{ \
53 bit_clr(port ## M1, ~(1 << port_pin)); \
54 bit_set(port ## M0, 1 << port_pin); \
55}
56
69#define pin_input_only_init(port, port_pin) \
70{ \
71 bit_set(port ## M1, 1 << port_pin); \
72 bit_clr(port ## M0, ~(1 << port_pin)); \
73}
74
88#define pin_open_drain_init(port, port_pin) \
89{ \
90 bit_set(port ## M1, 1 << port_pin); \
91 bit_set(port ## M0, 1 << port_pin); \
92}
93
101#define is_pin_mode_quasi_bidiretional(port, port_pin) ( ((port ## M1 & (1 << port_pin)) == 0) && ((port ## M0 & (1 << port_pin)) == 0 ) )
102
110#define is_pin_mode_push_pull(port, port_pin) ( ((port ## M1 & (1 << port_pin)) == 0) && ((port ## M0 & (1 << port_pin)) != 0) )
111
119#define is_pin_mode_input_only(port, port_pin) ( ((port ## M1 & (1 << port_pin)) != 0) && ((port ## M0 & (1 << port_pin)) == 0) )
120
128#define is_pin_mode_open_drain(port, port_pin) ( ((port ## M1 & (1 << port_pin)) != 0) && ((port ## M0 & (1 << port_pin)) != 0) )
129
137#define pin_port_quasi_bidiretional_init(port) \
138{ \
139 port ## M1 = 0x00; \
140 port ## M0 = 0x00; \
141}
142
150#define pin_port_pull_push_init(port) \
151{ \
152 port ## M1 = 0x00; \
153 port ## M0 = 0xff; \
154}
155
163#define pin_port_input_only_init(port) \
164{ \
165 port ## M1 = 0xff; \
166 port ## M0 = 0x00; \
167}
168
176#define pin_port_open_drain_init(port) \
177{ \
178 port ## M1 = 0xff; \
179 port ## M0 = 0xff; \
180}
181
182#endif