Netcruzer Library API  V2.03
 All Data Structures Files Functions Variables Typedefs Enumerations Macros Groups Pages
nz_debounce.h
Go to the documentation of this file.
1 
105 #ifndef NZ_DEBOUNCE_H
106 #define NZ_DEBOUNCE_H
107 
108 #if defined(NZ_DEBOUNCE_ENABLED)
109 
110 //Check for gaps
111 #if defined(DEBOUNCE_GET_PORT8) && (!defined(DEBOUNCE_GET_PORT1)||!defined(DEBOUNCE_GET_PORT2)||!defined(DEBOUNCE_GET_PORT3)||!defined(DEBOUNCE_GET_PORT4)||!defined(DEBOUNCE_GET_PORT5)||!defined(DEBOUNCE_GET_PORT6)||!defined(DEBOUNCE_GET_PORT7))
112 #error "DEBOUNCE_GET_PORT8 is defined, but not DEBOUNCE_GET_PORT1 to DEBOUNCE_GET_PORT7! ALWAYS define DEBOUNCE_GET_PORTs from 1 and up, with NO gaps!"
113 #endif
114 #if defined(DEBOUNCE_GET_PORT7) && (!defined(DEBOUNCE_GET_PORT1)||!defined(DEBOUNCE_GET_PORT2)||!defined(DEBOUNCE_GET_PORT3)||!defined(DEBOUNCE_GET_PORT4)||!defined(DEBOUNCE_GET_PORT5)||!defined(DEBOUNCE_GET_PORT6))
115 #error "DEBOUNCE_GET_PORT7 is defined, but not DEBOUNCE_GET_PORT1 to DEBOUNCE_GET_PORT6! ALWAYS define DEBOUNCE_GET_PORTs from 1 and up, with NO gaps!"
116 #endif
117 #if defined(DEBOUNCE_GET_PORT6) && (!defined(DEBOUNCE_GET_PORT1)||!defined(DEBOUNCE_GET_PORT2)||!defined(DEBOUNCE_GET_PORT3)||!defined(DEBOUNCE_GET_PORT4)||!defined(DEBOUNCE_GET_PORT5))
118 #error "DEBOUNCE_GET_PORT6 is defined, but not DEBOUNCE_GET_PORT1 to DEBOUNCE_GET_PORT5! ALWAYS define DEBOUNCE_GET_PORTs from 1 and up, with NO gaps!"
119 #endif
120 #if defined(DEBOUNCE_GET_PORT5) && (!defined(DEBOUNCE_GET_PORT1)||!defined(DEBOUNCE_GET_PORT2)||!defined(DEBOUNCE_GET_PORT3)||!defined(DEBOUNCE_GET_PORT4))
121 #error "DEBOUNCE_GET_PORT5 is defined, but not DEBOUNCE_GET_PORT1 to DEBOUNCE_GET_PORT4! ALWAYS define DEBOUNCE_GET_PORTs from 1 and up, with NO gaps!"
122 #endif
123 #if defined(DEBOUNCE_GET_PORT4) && (!defined(DEBOUNCE_GET_PORT1)||!defined(DEBOUNCE_GET_PORT2)||!defined(DEBOUNCE_GET_PORT3))
124 #error "DEBOUNCE_GET_PORT4 is defined, but not DEBOUNCE_GET_PORT1 to DEBOUNCE_GET_PORT3! ALWAYS define DEBOUNCE_GET_PORTs from 1 and up, with NO gaps!"
125 #endif
126 #if defined(DEBOUNCE_GET_PORT3) && (!defined(DEBOUNCE_GET_PORT1)||!defined(DEBOUNCE_GET_PORT2))
127 #error "DEBOUNCE_GET_PORT3 is defined, but not DEBOUNCE_GET_PORT1 to DEBOUNCE_GET_PORT2! ALWAYS define DEBOUNCE_GET_PORTs from 1 and up, with NO gaps!"
128 #endif
129 #if defined(DEBOUNCE_GET_PORT2) && (!defined(DEBOUNCE_GET_PORT1))
130 #error "DEBOUNCE_GET_PORT2 is defined, but not DEBOUNCE_GET_PORT1! ALWAYS define DEBOUNCE_GET_PORTs from 1 and up, with NO gaps!"
131 #endif
132 
133 //Define how many deoubnce ports there are
134 #if defined(DEBOUNCE_GET_PORT8)
135 #define DEBOUNCE_PORTS 8
136 #elif defined(DEBOUNCE_GET_PORT7)
137 #define DEBOUNCE_PORTS 7
138 #elif defined(DEBOUNCE_GET_PORT6)
139 #define DEBOUNCE_PORTS 6
140 #elif defined(DEBOUNCE_GET_PORT5)
141 #define DEBOUNCE_PORTS 5
142 #elif defined(DEBOUNCE_GET_PORT4)
143 #define DEBOUNCE_PORTS 4
144 #elif defined(DEBOUNCE_GET_PORT3)
145 #define DEBOUNCE_PORTS 3
146 #elif defined(DEBOUNCE_GET_PORT2)
147 #define DEBOUNCE_PORTS 2
148 #elif defined(DEBOUNCE_GET_PORT1)
149 #define DEBOUNCE_PORTS 1
150 #else
151 #define DEBOUNCE_PORTS 0
152 #endif
153 
154 //#if (DEBOUNCE_PORTS > 0) && !defined(NZ_DEBOUNCE_ENABLED)
155 //#define NZ_DEBOUNCE_ENABLED
156 //#endif
157 
158 
159 // Defines //////////////////////////////////////
160 #define DEBOUNCE_SERVICE_TIME 20 //Debounce serice time in MS
161 
162 
163 // Variables ////////////////////////////////////
164 
168 void debounceInit();
169 
170 
174 void debounceService();
175 
182 BYTE debounceGetLatchedPorts();
183 
184 
194 BYTE debounceGetLatchedPort(BYTE port);
195 
196 #endif //#if defined(NZ_DEBOUNCE_ENABLED)
197 
198 #endif