13 extern port_t ports[];
17 #define _P_VARS(_port) \
18 uint8_t flg __attribute__((unused)) = _port->flags; \
19 uint8_t adr = _port->adr; \
21 adr = 1<<(adr & 0x07);
23 #define _P_GET(_reg) (!!(*_reg & adr))
24 #define _P_SET(_reg,_val) do { \
32 #define PFLG_ALERT (1<<2) // alert when port changes externally
33 #define PFLG_ALT (1<<3) // switch H/Z and L/pull-up; default: H/L and Z/pull-up
34 #define PFLG_ALT2 (1<<4) // switch H/pullup and L/Z
35 #define PFLG_POLL (1<<5) // change has been reported
36 #define PFLG_CHANGED (1<<6) // pin change
37 #define PFLG_CURRENT (1<<7) // last-seen value. Hardcoded.
43 PO_OFF=0, PO_ON=1, PO_Z=2, PO_PULLUP=3
47 static inline port_in_t port_get_in(port_t *portp) {
53 static inline port_out_t port_get_out(port_t *portp) {
55 return _P_GET(port) | (!_P_GET(ddr)<<1) ;
59 static inline
void port_set_out(port_t *portp, port_out_t
state) {
61 _P_SET(port, state&1);
62 _P_SET(ddr,!(state&2));
63 portp->flags = (portp->flags&~PFLG_CURRENT) | (state<<7);
67 void port_check(port_t *pp);
70 void port_set(port_t *portp,
char val);
73 static inline
char port_changed(port_t *portp) {
74 return portp->flags & PFLG_CHANGED;
78 extern uint8_t port_changed_cache;
81 static inline char port_has_changed(port_t *portp) {
82 uint8_t flg = portp->flags;
83 if (flg & PFLG_CHANGED) {
92 static inline void port_pre_send (port_t *portp) {
93 (void)port_has_changed(portp);
96 static inline void port_post_send (port_t *portp) {
97 uint8_t flg = portp->flags;
99 if (flg & PFLG_CHANGED)
109 #endif // any inputs or outputs at all
uint8_t state
Definition: Sensors.cpp:526
return(x >> y)|(x<< (32-y))