Rev 1524 | Rev 1910 | Go to most recent revision | Show entire file | Regard whitespace | Details | Blame | Last modification | View Log | SVN | RSS feed
| Rev 1524 | Rev 1826 | ||
|---|---|---|---|
| Line 7... | Line 7... | ||
| 7 | #define HIGH_NOCH 3 |
7 | #define HIGH_NOCH 3 |
| 8 | #define LOW_NOCH 4 |
8 | #define LOW_NOCH 4 |
| 9 | 9 | ||
| 10 | #define IO_HIGH 1 |
10 | #define IO_HIGH 1 |
| 11 | #define IO_LOW 0 |
11 | #define IO_LOW 0 |
| - | 12 | ||
| - | 13 | #ifndef sns_input_SEND_PERIODIC |
|
| - | 14 | #define sns_input_SEND_PERIODIC 0 |
|
| - | 15 | #endif |
|
| 12 | 16 | ||
| 13 | /* |
17 | /* |
| 14 | 18 | ||
| 15 | Callback function that is called from pin-change driver on AVR IO |
19 | Callback function that is called from pin-change driver on AVR IO |
| 16 | id gives which pin that changed, status is the new state of the changed pin |
20 | id gives which pin that changed, status is the new state of the changed pin |
| Line 23... | Line 27... | ||
| 23 | if (id == sns_input_PCINT_CH0) { |
27 | if (id == sns_input_PCINT_CH0) { |
| 24 | if (IO_LOW != status) { |
28 | if (IO_LOW != status) { |
| 25 | pinStatus[0] = HIGH; |
29 | pinStatus[0] = HIGH; |
| 26 | } else { |
30 | } else { |
| 27 | pinStatus[0] = LOW; |
31 | pinStatus[0] = LOW; |
| 28 | } |
32 | } |
| 29 | } |
33 | } |
| 30 | #endif |
34 | #endif |
| 31 | #endif |
35 | #endif |
| 32 | #ifdef sns_input_CH1 |
36 | #ifdef sns_input_CH1 |
| 33 | #if sns_input_CH1PCA95xxIO==0 |
37 | #if sns_input_CH1PCA95xxIO==0 |
| 34 | if (id == sns_input_PCINT_CH1) { |
38 | if (id == sns_input_PCINT_CH1) { |
| 35 | if (IO_LOW != status) { |
39 | if (IO_LOW != status) { |
| 36 | pinStatus[1] = HIGH; |
40 | pinStatus[1] = HIGH; |
| 37 | } else { |
41 | } else { |
| 38 | pinStatus[1] = LOW; |
42 | pinStatus[1] = LOW; |
| 39 | } |
43 | } |
| 40 | } |
44 | } |
| 41 | #endif |
45 | #endif |
| 42 | #endif |
46 | #endif |
| 43 | #ifdef sns_input_CH2 |
47 | #ifdef sns_input_CH2 |
| 44 | #if sns_input_CH2PCA95xxIO==0 |
48 | #if sns_input_CH2PCA95xxIO==0 |
| 45 | if (id == sns_input_PCINT_CH2) { |
49 | if (id == sns_input_PCINT_CH2) { |
| 46 | if (IO_LOW != status) { |
50 | if (IO_LOW != status) { |
| 47 | pinStatus[2] = HIGH; |
51 | pinStatus[2] = HIGH; |
| 48 | } else { |
52 | } else { |
| 49 | pinStatus[2] = LOW; |
53 | pinStatus[2] = LOW; |
| 50 | } |
54 | } |
| 51 | } |
55 | } |
| 52 | #endif |
56 | #endif |
| 53 | #endif |
57 | #endif |
| 54 | #ifdef sns_input_CH3 |
58 | #ifdef sns_input_CH3 |
| 55 | #if sns_input_CH3PCA95xxIO==0 |
59 | #if sns_input_CH3PCA95xxIO==0 |
| 56 | if (id == sns_input_PCINT_CH3) { |
60 | if (id == sns_input_PCINT_CH3) { |
| 57 | if (IO_LOW != status) { |
61 | if (IO_LOW != status) { |
| 58 | pinStatus[3] = HIGH; |
62 | pinStatus[3] = HIGH; |
| 59 | } else { |
63 | } else { |
| 60 | pinStatus[3] = LOW; |
64 | pinStatus[3] = LOW; |
| 61 | } |
65 | } |
| 62 | } |
66 | } |
| 63 | #endif |
67 | #endif |
| 64 | #endif |
68 | #endif |
| 65 | #ifdef sns_input_CH4 |
69 | #ifdef sns_input_CH4 |
| 66 | #if sns_input_CH4PCA95xxIO==0 |
70 | #if sns_input_CH4PCA95xxIO==0 |
| 67 | if (id == sns_input_PCINT_CH4) { |
71 | if (id == sns_input_PCINT_CH4) { |
| 68 | if (IO_LOW != status) { |
72 | if (IO_LOW != status) { |
| 69 | pinStatus[4] = HIGH; |
73 | pinStatus[4] = HIGH; |
| Line 158... | Line 162... | ||
| 158 | #if sns_input_CH4PCA95xxIO==1 |
162 | #if sns_input_CH4PCA95xxIO==1 |
| 159 | if (pinStatus[4] == LOW_NOCH && ((status>>sns_input_CH4)&0x1) == IO_HIGH) { |
163 | if (pinStatus[4] == LOW_NOCH && ((status>>sns_input_CH4)&0x1) == IO_HIGH) { |
| 160 | pinStatus[4] = HIGH; |
164 | pinStatus[4] = HIGH; |
| 161 | } else if (pinStatus[4] == HIGH_NOCH && ((status>>sns_input_CH4)&0x1) == IO_LOW) { |
165 | } else if (pinStatus[4] == HIGH_NOCH && ((status>>sns_input_CH4)&0x1) == IO_LOW) { |
| 162 | pinStatus[4] = LOW; |
166 | pinStatus[4] = LOW; |
| 163 | } |
167 | } |
| 164 | #endif |
168 | #endif |
| 165 | #endif |
169 | #endif |
| 166 | 170 | ||
| 167 | #ifdef sns_input_CH5 |
171 | #ifdef sns_input_CH5 |
| 168 | #if sns_input_CH5PCA95xxIO==1 |
172 | #if sns_input_CH5PCA95xxIO==1 |
| 169 | if (pinStatus[5] == LOW_NOCH && ((status>>sns_input_CH5)&0x1) == IO_HIGH) { |
173 | if (pinStatus[5] == LOW_NOCH && ((status>>sns_input_CH5)&0x1) == IO_HIGH) { |
| 170 | pinStatus[5] = HIGH; |
174 | pinStatus[5] = HIGH; |
| 171 | } else if (pinStatus[5] == HIGH_NOCH && ((status>>sns_input_CH5)&0x1) == IO_LOW) { |
175 | } else if (pinStatus[5] == HIGH_NOCH && ((status>>sns_input_CH5)&0x1) == IO_LOW) { |
| 172 | pinStatus[5] = LOW; |
176 | pinStatus[5] = LOW; |
| 173 | } |
177 | } |
| 174 | #endif |
178 | #endif |
| 175 | #endif |
179 | #endif |
| 176 | #ifdef sns_input_CH6 |
180 | #ifdef sns_input_CH6 |
| 177 | #if sns_input_CH0PCA95xxIO==1 |
181 | #if sns_input_CH0PCA95xxIO==1 |
| 178 | if (pinStatus[6] == LOW_NOCH && ((status>>sns_input_CH6)&0x1) == IO_HIGH) { |
182 | if (pinStatus[6] == LOW_NOCH && ((status>>sns_input_CH6)&0x1) == IO_HIGH) { |
| 179 | pinStatus[6] = HIGH; |
183 | pinStatus[6] = HIGH; |
| 180 | } else if (pinStatus[6] == HIGH_NOCH && ((status>>sns_input_CH6)&0x1) == IO_LOW) { |
184 | } else if (pinStatus[6] == HIGH_NOCH && ((status>>sns_input_CH6)&0x1) == IO_LOW) { |
| Line 186... | Line 190... | ||
| 186 | #if sns_input_CH7PCA95xxIO==1 |
190 | #if sns_input_CH7PCA95xxIO==1 |
| 187 | if (pinStatus[7] == LOW_NOCH && ((status>>sns_input_CH7)&0x1) == IO_HIGH) { |
191 | if (pinStatus[7] == LOW_NOCH && ((status>>sns_input_CH7)&0x1) == IO_HIGH) { |
| 188 | pinStatus[7] = HIGH; |
192 | pinStatus[7] = HIGH; |
| 189 | } else if (pinStatus[7] == HIGH_NOCH && ((status>>sns_input_CH7)&0x1) == IO_LOW) { |
193 | } else if (pinStatus[7] == HIGH_NOCH && ((status>>sns_input_CH7)&0x1) == IO_LOW) { |
| 190 | pinStatus[7] = LOW; |
194 | pinStatus[7] = LOW; |
| 191 | } |
195 | } |
| 192 | #endif |
196 | #endif |
| 193 | #endif |
197 | #endif |
| 194 | 198 | ||
| 195 | } |
199 | } |
| 196 | #endif |
200 | #endif |
| 197 | 201 | ||
| 198 | 202 | ||
| 199 | #if sns_input_ENABLE_PCA95xx==1 |
- | |
| 200 | /* |
203 | /* |
| 201 | 204 | ||
| 202 | Function that initiates status variables for |
205 | Function that initiates status variables for pins |
| 203 | called at statup |
206 | called at statup |
| 204 | 207 | ||
| 205 | */ |
208 | */ |
| 206 | void |
209 | void sns_input_setPinStatus(void) |
| 207 | { |
210 | { |
| - | 211 | #if sns_input_ENABLE_PCA95xx==1 |
|
| 208 | uint16_t status = Pca95xx_GetInputs(); |
212 | uint16_t status = Pca95xx_GetInputs(); |
| - | 213 | #endif |
|
| 209 | #ifdef sns_input_CH0 |
214 | #ifdef sns_input_CH0 |
| 210 | #if sns_input_CH0PCA95xxIO==1 |
215 | #if sns_input_CH0PCA95xxIO==1 |
| 211 | if (((status>>sns_input_CH0)&0x1) != IO_LOW) { |
216 | if (((status>>sns_input_CH0)&0x1) != IO_LOW) { |
| - | 217 | pinStatus[0] = HIGH_NOCH; |
|
| - | 218 | } else { |
|
| - | 219 | pinStatus[0] = LOW_NOCH; |
|
| - | 220 | } |
|
| - | 221 | #else |
|
| - | 222 | if (gpio_get_state(sns_input_CH0)) { |
|
| 212 | pinStatus[0] = HIGH_NOCH; |
223 | pinStatus[0] = HIGH_NOCH; |
| 213 | } else { |
224 | } else { |
| 214 | pinStatus[0] = LOW_NOCH; |
225 | pinStatus[0] = LOW_NOCH; |
| 215 | } |
226 | } |
| 216 | #endif |
227 | #endif |
| 217 | #endif |
228 | #endif |
| 218 | #ifdef sns_input_CH1 |
229 | #ifdef sns_input_CH1 |
| 219 | #if sns_input_CH1PCA95xxIO==1 |
230 | #if sns_input_CH1PCA95xxIO==1 |
| 220 | if (((status>>sns_input_CH1)&0x1) != IO_LOW) { |
231 | if (((status>>sns_input_CH1)&0x1) != IO_LOW) { |
| - | 232 | pinStatus[1] = HIGH_NOCH; |
|
| - | 233 | } else { |
|
| - | 234 | pinStatus[1] = LOW_NOCH; |
|
| - | 235 | } |
|
| - | 236 | #else |
|
| - | 237 | if (gpio_get_state(sns_input_CH1)) { |
|
| 221 | pinStatus[1] = HIGH_NOCH; |
238 | pinStatus[1] = HIGH_NOCH; |
| 222 | } else { |
239 | } else { |
| 223 | pinStatus[1] = LOW_NOCH; |
240 | pinStatus[1] = LOW_NOCH; |
| 224 | } |
241 | } |
| 225 | #endif |
242 | #endif |
| 226 | #endif |
243 | #endif |
| 227 | #ifdef sns_input_CH2 |
244 | #ifdef sns_input_CH2 |
| 228 | #if sns_input_CH2PCA95xxIO==1 |
245 | #if sns_input_CH2PCA95xxIO==1 |
| 229 | if (((status>>sns_input_CH2)&0x1) != IO_LOW) { |
246 | if (((status>>sns_input_CH2)&0x1) != IO_LOW) { |
| - | 247 | pinStatus[2] = HIGH_NOCH; |
|
| - | 248 | } else { |
|
| - | 249 | pinStatus[2] = LOW_NOCH; |
|
| - | 250 | } |
|
| - | 251 | #else |
|
| - | 252 | if (gpio_get_state(sns_input_CH2)) { |
|
| 230 | pinStatus[2] = HIGH_NOCH; |
253 | pinStatus[2] = HIGH_NOCH; |
| 231 | } else { |
254 | } else { |
| 232 | pinStatus[2] = LOW_NOCH; |
255 | pinStatus[2] = LOW_NOCH; |
| 233 | } |
256 | } |
| 234 | #endif |
257 | #endif |
| 235 | #endif |
258 | #endif |
| 236 | #ifdef sns_input_CH3 |
259 | #ifdef sns_input_CH3 |
| 237 | #if sns_input_CH3PCA95xxIO==1 |
260 | #if sns_input_CH3PCA95xxIO==1 |
| 238 | if (((status>>sns_input_CH3)&0x1) != IO_LOW) { |
261 | if (((status>>sns_input_CH3)&0x1) != IO_LOW) { |
| - | 262 | pinStatus[3] = HIGH_NOCH; |
|
| - | 263 | } else { |
|
| - | 264 | pinStatus[3] = LOW_NOCH; |
|
| - | 265 | } |
|
| - | 266 | #else |
|
| - | 267 | if (gpio_get_state(sns_input_CH3)) { |
|
| 239 | pinStatus[3] = HIGH_NOCH; |
268 | pinStatus[3] = HIGH_NOCH; |
| 240 | } else { |
269 | } else { |
| 241 | pinStatus[3] = LOW_NOCH; |
270 | pinStatus[3] = LOW_NOCH; |
| 242 | } |
271 | } |
| 243 | #endif |
272 | #endif |
| Line 246... | Line 275... | ||
| 246 | #if sns_input_CH4PCA95xxIO==1 |
275 | #if sns_input_CH4PCA95xxIO==1 |
| 247 | if (((status>>sns_input_CH4)&0x1) != IO_LOW) { |
276 | if (((status>>sns_input_CH4)&0x1) != IO_LOW) { |
| 248 | pinStatus[4] = HIGH_NOCH; |
277 | pinStatus[4] = HIGH_NOCH; |
| 249 | } else { |
278 | } else { |
| 250 | pinStatus[4] = LOW_NOCH; |
279 | pinStatus[4] = LOW_NOCH; |
| 251 | } |
280 | } |
| - | 281 | #else |
|
| - | 282 | if (gpio_get_state(sns_input_CH4)) { |
|
| - | 283 | pinStatus[4] = HIGH_NOCH; |
|
| - | 284 | } else { |
|
| - | 285 | pinStatus[4] = LOW_NOCH; |
|
| - | 286 | } |
|
| 252 | #endif |
287 | #endif |
| 253 | #endif |
288 | #endif |
| 254 | #ifdef sns_input_CH5 |
289 | #ifdef sns_input_CH5 |
| 255 | #if sns_input_CH5PCA95xxIO==1 |
290 | #if sns_input_CH5PCA95xxIO==1 |
| 256 | if (((status>>sns_input_CH5)&0x1) != IO_LOW) { |
291 | if (((status>>sns_input_CH5)&0x1) != IO_LOW) { |
| 257 | pinStatus[5] = HIGH_NOCH; |
292 | pinStatus[5] = HIGH_NOCH; |
| 258 | } else { |
293 | } else { |
| 259 | pinStatus[5] = LOW_NOCH; |
294 | pinStatus[5] = LOW_NOCH; |
| 260 | } |
295 | } |
| - | 296 | #else |
|
| - | 297 | if (gpio_get_state(sns_input_CH5)) { |
|
| - | 298 | pinStatus[5] = HIGH_NOCH; |
|
| - | 299 | } else { |
|
| - | 300 | pinStatus[5] = LOW_NOCH; |
|
| - | 301 | } |
|
| 261 | #endif |
302 | #endif |
| 262 | #endif |
303 | #endif |
| 263 | #ifdef sns_input_CH6 |
304 | #ifdef sns_input_CH6 |
| 264 | #if sns_input_CH6PCA95xxIO==1 |
305 | #if sns_input_CH6PCA95xxIO==1 |
| 265 | if (((status>>sns_input_CH6)&0x1) != IO_LOW) { |
306 | if (((status>>sns_input_CH6)&0x1) != IO_LOW) { |
| - | 307 | pinStatus[6] = HIGH_NOCH; |
|
| - | 308 | } else { |
|
| - | 309 | pinStatus[6] = LOW_NOCH; |
|
| - | 310 | } |
|
| - | 311 | #else |
|
| - | 312 | if (gpio_get_state(sns_input_CH6)) { |
|
| 266 | pinStatus[6] = HIGH_NOCH; |
313 | pinStatus[6] = HIGH_NOCH; |
| 267 | } else { |
314 | } else { |
| 268 | pinStatus[6] = LOW_NOCH; |
315 | pinStatus[6] = LOW_NOCH; |
| 269 | } |
316 | } |
| 270 | #endif |
317 | #endif |
| 271 | #endif |
318 | #endif |
| 272 | #ifdef sns_input_CH7 |
319 | #ifdef sns_input_CH7 |
| 273 | #if sns_input_CH7PCA95xxIO==1 |
320 | #if sns_input_CH7PCA95xxIO==1 |
| 274 | if (((status>>sns_input_CH7)&0x1) != IO_LOW) { |
321 | if (((status>>sns_input_CH7)&0x1) != IO_LOW) { |
| - | 322 | pinStatus[7] = HIGH_NOCH; |
|
| - | 323 | } else { |
|
| - | 324 | pinStatus[7] = LOW_NOCH; |
|
| - | 325 | } |
|
| - | 326 | #else |
|
| - | 327 | if (gpio_get_state(sns_input_CH7)) { |
|
| 275 | pinStatus[7] = HIGH_NOCH; |
328 | pinStatus[7] = HIGH_NOCH; |
| 276 | } else { |
329 | } else { |
| 277 | pinStatus[7] = LOW_NOCH; |
330 | pinStatus[7] = LOW_NOCH; |
| 278 | } |
331 | } |
| 279 | #endif |
332 | #endif |
| 280 | #endif |
333 | #endif |
| 281 | } |
334 | } |
| 282 | #endif |
- | |
| 283 | 335 | ||
| 284 | void sns_input_Init(void) |
336 | void sns_input_Init(void) |
| 285 | { |
337 | { |
| 286 | pinStatus[0] = NOCHANGE; |
- | |
| 287 | pinStatus[1] = NOCHANGE; |
- | |
| 288 | pinStatus[2] = NOCHANGE; |
- | |
| 289 | pinStatus[3] = NOCHANGE; |
- | |
| 290 | pinStatus[4] = NOCHANGE; |
- | |
| 291 | pinStatus[5] = NOCHANGE; |
- | |
| 292 | pinStatus[6] = NOCHANGE; |
- | |
| 293 | pinStatus[7] = NOCHANGE; |
- | |
| 294 | uint8_t index = 0; |
- | |
| 295 | - | ||
| 296 | #if sns_input_ENABLE_PCA95xx==1 |
338 | #if sns_input_ENABLE_PCA95xx==1 |
| 297 | Pca95xx_SetCallback(sns_input_PCA95XX_CALLBACK_INDEX, &sns_input_PCA95xx_callback); |
339 | Pca95xx_SetCallback(sns_input_PCA95XX_CALLBACK_INDEX, &sns_input_PCA95xx_callback); |
| 298 | Pca95xx_Init(0); |
340 | Pca95xx_Init(0); |
| 299 | #endif |
341 | #endif |
| 300 | 342 | ||
| Line 305... | Line 347... | ||
| 305 | #else |
347 | #else |
| 306 | gpio_clr_pullup(sns_input_CH0); |
348 | gpio_clr_pullup(sns_input_CH0); |
| 307 | #endif |
349 | #endif |
| 308 | gpio_set_in(sns_input_CH0); |
350 | gpio_set_in(sns_input_CH0); |
| 309 | Pcint_SetCallbackPin(sns_input_PCINT_CH0, sns_input_CH0, &sns_input_pcint_callback); |
351 | Pcint_SetCallbackPin(sns_input_PCINT_CH0, sns_input_CH0, &sns_input_pcint_callback); |
| 310 | #else |
352 | #else |
| 311 | Pca95xx_set_in(sns_input_CH0); |
353 | Pca95xx_set_in(sns_input_CH0); |
| 312 | #endif |
354 | #endif |
| 313 | index++; |
- | |
| 314 | #endif |
355 | #endif |
| 315 | #ifdef sns_input_CH1 |
356 | #ifdef sns_input_CH1 |
| 316 | #if sns_input_CH1PCA95xxIO==0 |
357 | #if sns_input_CH1PCA95xxIO==0 |
| 317 | #if (sns_input_CH1_pullup == 1) |
358 | #if (sns_input_CH1_pullup == 1) |
| 318 | gpio_set_pullup(sns_input_CH1); |
359 | gpio_set_pullup(sns_input_CH1); |
| Line 322... | Line 363... | ||
| 322 | gpio_set_in(sns_input_CH1); |
363 | gpio_set_in(sns_input_CH1); |
| 323 | Pcint_SetCallbackPin(sns_input_PCINT_CH1, sns_input_CH1, &sns_input_pcint_callback); |
364 | Pcint_SetCallbackPin(sns_input_PCINT_CH1, sns_input_CH1, &sns_input_pcint_callback); |
| 324 | #else |
365 | #else |
| 325 | Pca95xx_set_in(sns_input_CH1); |
366 | Pca95xx_set_in(sns_input_CH1); |
| 326 | #endif |
367 | #endif |
| 327 | index++; |
- | |
| 328 | #endif |
368 | #endif |
| 329 | #ifdef sns_input_CH2 |
369 | #ifdef sns_input_CH2 |
| 330 | #if sns_input_CH2PCA95xxIO==0 |
370 | #if sns_input_CH2PCA95xxIO==0 |
| 331 | #if (sns_input_CH2_pullup == 1) |
371 | #if (sns_input_CH2_pullup == 1) |
| 332 | gpio_set_pullup(sns_input_CH2); |
372 | gpio_set_pullup(sns_input_CH2); |
| 333 | #else |
373 | #else |
| 334 | gpio_clr_pullup(sns_input_CH2); |
374 | gpio_clr_pullup(sns_input_CH2); |
| 335 | #endif |
375 | #endif |
| 336 | gpio_set_in(sns_input_CH2); |
376 | gpio_set_in(sns_input_CH2); |
| 337 | Pcint_SetCallbackPin(sns_input_PCINT_CH2, sns_input_CH2, &sns_input_pcint_callback); |
377 | Pcint_SetCallbackPin(sns_input_PCINT_CH2, sns_input_CH2, &sns_input_pcint_callback); |
| 338 | #else |
378 | #else |
| 339 | Pca95xx_set_in(sns_input_CH2); |
379 | Pca95xx_set_in(sns_input_CH2); |
| 340 | #endif |
380 | #endif |
| 341 | index++; |
- | |
| 342 | #endif |
381 | #endif |
| 343 | #ifdef sns_input_CH3 |
382 | #ifdef sns_input_CH3 |
| 344 | #if sns_input_CH3PCA95xxIO==0 |
383 | #if sns_input_CH3PCA95xxIO==0 |
| 345 | #if (sns_input_CH3_pullup == 1) |
384 | #if (sns_input_CH3_pullup == 1) |
| 346 | gpio_set_pullup(sns_input_CH3); |
385 | gpio_set_pullup(sns_input_CH3); |
| 347 | #else |
386 | #else |
| 348 | gpio_clr_pullup(sns_input_CH3); |
387 | gpio_clr_pullup(sns_input_CH3); |
| 349 | #endif |
388 | #endif |
| 350 | gpio_set_in(sns_input_CH3); |
389 | gpio_set_in(sns_input_CH3); |
| 351 | Pcint_SetCallbackPin(sns_input_PCINT_CH3, sns_input_CH3, &sns_input_pcint_callback); |
390 | Pcint_SetCallbackPin(sns_input_PCINT_CH3, sns_input_CH3, &sns_input_pcint_callback); |
| 352 | #else |
391 | #else |
| 353 | Pca95xx_set_in(sns_input_CH3); |
392 | Pca95xx_set_in(sns_input_CH3); |
| 354 | #endif |
393 | #endif |
| 355 | index++; |
- | |
| 356 | #endif |
394 | #endif |
| 357 | #ifdef sns_input_CH4 |
395 | #ifdef sns_input_CH4 |
| 358 | #if sns_input_CH4PCA95xxIO==0 |
396 | #if sns_input_CH4PCA95xxIO==0 |
| 359 | #if (sns_input_CH4_pullup == 1) |
397 | #if (sns_input_CH4_pullup == 1) |
| 360 | gpio_set_pullup(sns_input_CH4); |
398 | gpio_set_pullup(sns_input_CH4); |
| 361 | #else |
399 | #else |
| 362 | gpio_clr_pullup(sns_input_CH4); |
400 | gpio_clr_pullup(sns_input_CH4); |
| 363 | #endif |
401 | #endif |
| 364 | gpio_set_in(sns_input_CH4); |
402 | gpio_set_in(sns_input_CH4); |
| 365 | Pcint_SetCallbackPin(sns_input_PCINT_CH4, sns_input_CH4, &sns_input_pcint_callback); |
403 | Pcint_SetCallbackPin(sns_input_PCINT_CH4, sns_input_CH4, &sns_input_pcint_callback); |
| 366 | #else |
404 | #else |
| 367 | Pca95xx_set_in(sns_input_CH4); |
405 | Pca95xx_set_in(sns_input_CH4); |
| 368 | #endif |
406 | #endif |
| 369 | index++; |
- | |
| 370 | #endif |
407 | #endif |
| 371 | #ifdef sns_input_CH5 |
408 | #ifdef sns_input_CH5 |
| 372 | #if sns_input_CH5PCA95xxIO==0 |
409 | #if sns_input_CH5PCA95xxIO==0 |
| 373 | #if (sns_input_CH5_pullup == 1) |
410 | #if (sns_input_CH5_pullup == 1) |
| 374 | gpio_set_pullup(sns_input_CH5); |
411 | gpio_set_pullup(sns_input_CH5); |
| 375 | #else |
412 | #else |
| 376 | gpio_clr_pullup(sns_input_CH5); |
413 | gpio_clr_pullup(sns_input_CH5); |
| 377 | #endif |
414 | #endif |
| 378 | gpio_set_in(sns_input_CH5); |
415 | gpio_set_in(sns_input_CH5); |
| 379 | Pcint_SetCallbackPin(sns_input_PCINT_CH5, sns_input_CH5, &sns_input_pcint_callback); |
416 | Pcint_SetCallbackPin(sns_input_PCINT_CH5, sns_input_CH5, &sns_input_pcint_callback); |
| 380 | #else |
417 | #else |
| 381 | Pca95xx_set_in(sns_input_CH5); |
418 | Pca95xx_set_in(sns_input_CH5); |
| 382 | #endif |
419 | #endif |
| 383 | index++; |
- | |
| 384 | #endif |
420 | #endif |
| 385 | #ifdef sns_input_CH6 |
421 | #ifdef sns_input_CH6 |
| 386 | #if sns_input_CH6PCA95xxIO==0 |
422 | #if sns_input_CH6PCA95xxIO==0 |
| 387 | #if (sns_input_CH6_pullup == 1) |
423 | #if (sns_input_CH6_pullup == 1) |
| 388 | gpio_set_pullup(sns_input_CH6); |
424 | gpio_set_pullup(sns_input_CH6); |
| 389 | #else |
425 | #else |
| 390 | gpio_clr_pullup(sns_input_CH6); |
426 | gpio_clr_pullup(sns_input_CH6); |
| 391 | #endif |
427 | #endif |
| 392 | gpio_set_in(sns_input_CH6); |
428 | gpio_set_in(sns_input_CH6); |
| 393 | Pcint_SetCallbackPin(sns_input_PCINT_CH6, sns_input_CH6, &sns_input_pcint_callback); |
429 | Pcint_SetCallbackPin(sns_input_PCINT_CH6, sns_input_CH6, &sns_input_pcint_callback); |
| 394 | #else |
430 | #else |
| 395 | Pca95xx_set_in(sns_input_CH6); |
431 | Pca95xx_set_in(sns_input_CH6); |
| 396 | #endif |
432 | #endif |
| 397 | index++; |
- | |
| 398 | #endif |
433 | #endif |
| 399 | #ifdef sns_input_CH7 |
434 | #ifdef sns_input_CH7 |
| 400 | #if sns_input_CH7PCA95xxIO==0 |
435 | #if sns_input_CH7PCA95xxIO==0 |
| 401 | #if (sns_input_CH7_pullup == 1) |
436 | #if (sns_input_CH7_pullup == 1) |
| 402 | gpio_set_pullup(sns_input_CH7); |
437 | gpio_set_pullup(sns_input_CH7); |
| 403 | #else |
438 | #else |
| 404 | gpio_clr_pullup(sns_input_CH7); |
439 | gpio_clr_pullup(sns_input_CH7); |
| 405 | #endif |
440 | #endif |
| 406 | gpio_set_in(sns_input_CH7); |
441 | gpio_set_in(sns_input_CH7); |
| 407 | Pcint_SetCallbackPin(sns_input_PCINT_CH7, sns_input_CH7, &sns_input_pcint_callback); |
442 | Pcint_SetCallbackPin(sns_input_PCINT_CH7, sns_input_CH7, &sns_input_pcint_callback); |
| 408 | #else |
443 | #else |
| 409 | Pca95xx_set_in(sns_input_CH7); |
444 | Pca95xx_set_in(sns_input_CH7); |
| 410 | #endif |
445 | #endif |
| 411 | index++; |
- | |
| 412 | #endif |
446 | #endif |
| 413 | 447 | ||
| 414 | #if sns_input_ENABLE_PCA95xx==1 |
- | |
| - | 448 | ||
| 415 |
|
449 | sns_input_setPinStatus(); |
| 416 | #endif |
- | |
| 417 | 450 | ||
| 418 | Timer_SetTimeout(sns_input_DEBOUNCE_TIMER, sns_input_DEBOUNCE_TIME_MS, TimerTypeFreeRunning, 0); |
451 | Timer_SetTimeout(sns_input_DEBOUNCE_TIMER, sns_input_DEBOUNCE_TIME_MS, TimerTypeFreeRunning, 0); |
| - | 452 | Timer_SetTimeout(sns_input_SEND_PERIODIC_TIMER, sns_input_SEND_PERIOD_MS, TimerTypeFreeRunning, 0); |
|
| 419 | } |
453 | } |
| 420 | 454 | ||
| - | 455 | #if sns_input_SEND_PERIODIC==1 |
|
| - | 456 | uint8_t ChannelToSend = 0; |
|
| - | 457 | #endif |
|
| 421 | void sns_input_Process(void) |
458 | void sns_input_Process(void) |
| 422 | { |
459 | { |
| 423 | if (Timer_Expired(sns_input_DEBOUNCE_TIMER)) |
460 | if (Timer_Expired(sns_input_DEBOUNCE_TIMER)) |
| 424 | { |
461 | { |
| 425 | uint8_t index = 0; |
462 | uint8_t index = 0; |
| Line 430... | Line 467... | ||
| 430 | StdCan_Set_direction(txMsg.Header, DIRECTIONFLAG_FROM_OWNER); |
467 | StdCan_Set_direction(txMsg.Header, DIRECTIONFLAG_FROM_OWNER); |
| 431 | txMsg.Header.ModuleType = CAN_MODULE_TYPE_SNS_INPUT; |
468 | txMsg.Header.ModuleType = CAN_MODULE_TYPE_SNS_INPUT; |
| 432 | txMsg.Header.ModuleId = sns_input_ID; |
469 | txMsg.Header.ModuleId = sns_input_ID; |
| 433 | txMsg.Header.Command = CAN_MODULE_CMD_PHYSICAL_PINSTATUS; |
470 | txMsg.Header.Command = CAN_MODULE_CMD_PHYSICAL_PINSTATUS; |
| 434 | txMsg.Length = 2; |
471 | txMsg.Length = 2; |
| 435 | txMsg.Data[0] = index; |
472 | txMsg.Data[0] = index; |
| 436 | if (pinStatus[index] == HIGH) { |
473 | if (pinStatus[index] == HIGH) { |
| - | 474 | txMsg.Data[1] = CAN_MODULE_ENUM_PHYSICAL_PINSTATUS_STATUS_HIGH; |
|
| - | 475 | pinStatus[index] = HIGH_NOCH; |
|
| - | 476 | } else { |
|
| - | 477 | txMsg.Data[1] = CAN_MODULE_ENUM_PHYSICAL_PINSTATUS_STATUS_LOW; |
|
| - | 478 | pinStatus[index] = LOW_NOCH; |
|
| - | 479 | } |
|
| - | 480 | StdCan_Put(&txMsg); |
|
| - | 481 | } |
|
| - | 482 | } |
|
| - | 483 | } |
|
| - | 484 | ||
| - | 485 | #if sns_input_SEND_PERIODIC==1 |
|
| - | 486 | if (Timer_Expired(sns_input_SEND_PERIODIC_TIMER)) |
|
| - | 487 | { |
|
| - | 488 | StdCan_Msg_t txMsg; |
|
| - | 489 | StdCan_Set_class(txMsg.Header, CAN_MODULE_CLASS_SNS); |
|
| - | 490 | StdCan_Set_direction(txMsg.Header, DIRECTIONFLAG_FROM_OWNER); |
|
| - | 491 | txMsg.Header.ModuleType = CAN_MODULE_TYPE_SNS_INPUT; |
|
| - | 492 | txMsg.Header.ModuleId = sns_input_ID; |
|
| - | 493 | txMsg.Header.Command = CAN_MODULE_CMD_PHYSICAL_PINSTATUS; |
|
| - | 494 | txMsg.Length = 2; |
|
| - | 495 | txMsg.Data[0] = ChannelToSend; |
|
| - | 496 | #ifdef sns_input_CH0 |
|
| - | 497 | if (ChannelToSend==0) |
|
| - | 498 | { |
|
| - | 499 | if (pinStatus[ChannelToSend] == HIGH || pinStatus[ChannelToSend] == HIGH_NOCH) { |
|
| - | 500 | txMsg.Data[1] = CAN_MODULE_ENUM_PHYSICAL_PINSTATUS_STATUS_HIGH; |
|
| - | 501 | } else if (pinStatus[ChannelToSend] == LOW || pinStatus[ChannelToSend] == LOW_NOCH) { |
|
| - | 502 | txMsg.Data[1] = CAN_MODULE_ENUM_PHYSICAL_PINSTATUS_STATUS_LOW; |
|
| - | 503 | } |
|
| - | 504 | ||
| - | 505 | StdCan_Put(&txMsg); |
|
| - | 506 | } |
|
| - | 507 | #endif |
|
| - | 508 | #ifdef sns_input_CH1 |
|
| - | 509 | if (ChannelToSend==1) |
|
| - | 510 | { |
|
| - | 511 | if (pinStatus[ChannelToSend] == HIGH || pinStatus[ChannelToSend] == HIGH_NOCH) { |
|
| - | 512 | txMsg.Data[1] = CAN_MODULE_ENUM_PHYSICAL_PINSTATUS_STATUS_HIGH; |
|
| - | 513 | } else if (pinStatus[ChannelToSend] == LOW || pinStatus[ChannelToSend] == LOW_NOCH) { |
|
| - | 514 | txMsg.Data[1] = CAN_MODULE_ENUM_PHYSICAL_PINSTATUS_STATUS_LOW; |
|
| - | 515 | } |
|
| - | 516 | ||
| - | 517 | StdCan_Put(&txMsg); |
|
| - | 518 | } |
|
| - | 519 | #endif |
|
| - | 520 | #ifdef sns_input_CH2 |
|
| - | 521 | if (ChannelToSend==2) |
|
| - | 522 | { |
|
| - | 523 | if (pinStatus[ChannelToSend] == HIGH || pinStatus[ChannelToSend] == HIGH_NOCH) { |
|
| - | 524 | txMsg.Data[1] = CAN_MODULE_ENUM_PHYSICAL_PINSTATUS_STATUS_HIGH; |
|
| - | 525 | } else if (pinStatus[ChannelToSend] == LOW || pinStatus[ChannelToSend] == LOW_NOCH) { |
|
| - | 526 | txMsg.Data[1] = CAN_MODULE_ENUM_PHYSICAL_PINSTATUS_STATUS_LOW; |
|
| - | 527 | } |
|
| - | 528 | ||
| - | 529 | StdCan_Put(&txMsg); |
|
| - | 530 | } |
|
| - | 531 | #endif |
|
| - | 532 | #ifdef sns_input_CH3 |
|
| - | 533 | if (ChannelToSend==3) |
|
| - | 534 | { |
|
| - | 535 | if (pinStatus[ChannelToSend] == HIGH || pinStatus[ChannelToSend] == HIGH_NOCH) { |
|
| - | 536 | txMsg.Data[1] = CAN_MODULE_ENUM_PHYSICAL_PINSTATUS_STATUS_HIGH; |
|
| - | 537 | } else if (pinStatus[ChannelToSend] == LOW || pinStatus[ChannelToSend] == LOW_NOCH) { |
|
| - | 538 | txMsg.Data[1] = CAN_MODULE_ENUM_PHYSICAL_PINSTATUS_STATUS_LOW; |
|
| - | 539 | } |
|
| - | 540 | ||
| - | 541 | StdCan_Put(&txMsg); |
|
| - | 542 | } |
|
| - | 543 | #endif |
|
| - | 544 | #ifdef sns_input_CH4 |
|
| - | 545 | if (ChannelToSend==4) |
|
| - | 546 | { |
|
| - | 547 | if (pinStatus[ChannelToSend] == HIGH || pinStatus[ChannelToSend] == HIGH_NOCH) { |
|
| - | 548 | txMsg.Data[1] = CAN_MODULE_ENUM_PHYSICAL_PINSTATUS_STATUS_HIGH; |
|
| - | 549 | } else if (pinStatus[ChannelToSend] == LOW || pinStatus[ChannelToSend] == LOW_NOCH) { |
|
| - | 550 | txMsg.Data[1] = CAN_MODULE_ENUM_PHYSICAL_PINSTATUS_STATUS_LOW; |
|
| - | 551 | } |
|
| - | 552 | ||
| - | 553 | StdCan_Put(&txMsg); |
|
| - | 554 | } |
|
| - | 555 | #endif |
|
| - | 556 | #ifdef sns_input_CH5 |
|
| - | 557 | if (ChannelToSend==5) |
|
| - | 558 | { |
|
| - | 559 | if (pinStatus[ChannelToSend] == HIGH || pinStatus[ChannelToSend] == HIGH_NOCH) { |
|
| - | 560 | txMsg.Data[1] = CAN_MODULE_ENUM_PHYSICAL_PINSTATUS_STATUS_HIGH; |
|
| - | 561 | } else if (pinStatus[ChannelToSend] == LOW || pinStatus[ChannelToSend] == LOW_NOCH) { |
|
| - | 562 | txMsg.Data[1] = CAN_MODULE_ENUM_PHYSICAL_PINSTATUS_STATUS_LOW; |
|
| - | 563 | } |
|
| - | 564 | ||
| - | 565 | StdCan_Put(&txMsg); |
|
| - | 566 | } |
|
| - | 567 | #endif |
|
| - | 568 | #ifdef sns_input_CH6 |
|
| - | 569 | if (ChannelToSend==6) |
|
| - | 570 | { |
|
| - | 571 | if (pinStatus[ChannelToSend] == HIGH || pinStatus[ChannelToSend] == HIGH_NOCH) { |
|
| - | 572 | txMsg.Data[1] = CAN_MODULE_ENUM_PHYSICAL_PINSTATUS_STATUS_HIGH; |
|
| - | 573 | } else if (pinStatus[ChannelToSend] == LOW || pinStatus[ChannelToSend] == LOW_NOCH) { |
|
| - | 574 | txMsg.Data[1] = CAN_MODULE_ENUM_PHYSICAL_PINSTATUS_STATUS_LOW; |
|
| - | 575 | } |
|
| - | 576 | ||
| - | 577 | StdCan_Put(&txMsg); |
|
| - | 578 | } |
|
| - | 579 | #endif |
|
| - | 580 | #ifdef sns_input_CH7 |
|
| - | 581 | if (ChannelToSend==7) |
|
| - | 582 | { |
|
| - | 583 | if (pinStatus[ChannelToSend] == HIGH || pinStatus[ChannelToSend] == HIGH_NOCH) { |
|
| 437 | txMsg.Data[1] = CAN_MODULE_ENUM_PHYSICAL_PINSTATUS_STATUS_HIGH; |
584 | txMsg.Data[1] = CAN_MODULE_ENUM_PHYSICAL_PINSTATUS_STATUS_HIGH; |
| 438 |
|
585 | } else if (pinStatus[ChannelToSend] == LOW || pinStatus[ChannelToSend] == LOW_NOCH) { |
| 439 | } else { |
- | |
| 440 | txMsg.Data[1] = CAN_MODULE_ENUM_PHYSICAL_PINSTATUS_STATUS_LOW; |
586 | txMsg.Data[1] = CAN_MODULE_ENUM_PHYSICAL_PINSTATUS_STATUS_LOW; |
| - | 587 | } |
|
| - | 588 | ||
| 441 |
|
589 | StdCan_Put(&txMsg); |
| 442 | } |
590 | } |
| - | 591 | #endif |
|
| - | 592 | ||
| 443 |
|
593 | if (ChannelToSend++ >=8) |
| 444 |
|
594 | { |
| - | 595 | ChannelToSend=0; |
|
| 445 | } |
596 | } |
| 446 | } |
597 | } |
| - | 598 | #endif |
|
| 447 | } |
599 | } |
| 448 | 600 | ||
| 449 | void sns_input_HandleMessage(StdCan_Msg_t *rxMsg) |
601 | void sns_input_HandleMessage(StdCan_Msg_t *rxMsg) |
| 450 | { |
602 | { |
| 451 | 603 | ||