Important changes to repositories hosted on mbed.com
Mbed hosted mercurial repositories are deprecated and are due to be permanently deleted in July 2026.
To keep a copy of this software download the repository Zip archive or clone locally using Mercurial.
It is also possible to export all your personal repositories from the account settings page.
Dependencies: mbed CANBuffer Watchdog MODSERIAL mbed-rtos xbeeRelay IAP
Fork of SystemManagement by
PollSwitch/PollSwitch.cpp@29:f148490b5f65, 2014-11-08 (annotated)
- Committer:
- pspatel321
- Date:
- Sat Nov 08 17:15:14 2014 +0000
- Revision:
- 29:f148490b5f65
- Parent:
- 17:c9ce210f6654
Parth edits branch
Who changed what in which revision?
| User | Revision | Line number | New contents of line |
|---|---|---|---|
| martydd3 | 7:5f6e31faa08e | 1 | #include "PollSwitch.h" |
| martydd3 | 7:5f6e31faa08e | 2 | |
| pspatel321 | 17:c9ce210f6654 | 3 | LPCDigitalIn sw[]={ LPCDigitalIn(p1_0, PullDown), |
| pspatel321 | 17:c9ce210f6654 | 4 | LPCDigitalIn(p1_1, PullDown), |
| pspatel321 | 17:c9ce210f6654 | 5 | LPCDigitalIn(p1_4, PullDown), |
| pspatel321 | 17:c9ce210f6654 | 6 | LPCDigitalIn(p1_8, PullDown), |
| pspatel321 | 17:c9ce210f6654 | 7 | LPCDigitalIn(p1_9, PullDown), |
| pspatel321 | 17:c9ce210f6654 | 8 | LPCDigitalIn(p1_10, PullDown), |
| pspatel321 | 17:c9ce210f6654 | 9 | LPCDigitalIn(p1_14, PullDown), |
| pspatel321 | 17:c9ce210f6654 | 10 | LPCDigitalIn(p1_15, PullDown), |
| pspatel321 | 17:c9ce210f6654 | 11 | LPCDigitalIn(p1_16, PullDown), |
| pspatel321 | 17:c9ce210f6654 | 12 | LPCDigitalIn(p1_17, PullDown), |
| pspatel321 | 17:c9ce210f6654 | 13 | LPCDigitalIn(p1_27, PullDown), |
| pspatel321 | 17:c9ce210f6654 | 14 | LPCDigitalIn(p1_28, PullDown) |
| pspatel321 | 17:c9ce210f6654 | 15 | }; |
| martydd3 | 7:5f6e31faa08e | 16 | |
| pspatel321 | 17:c9ce210f6654 | 17 | PollSwitch::PollSwitch(){ |
| pspatel321 | 17:c9ce210f6654 | 18 | switchState = 0; |
| martydd3 | 7:5f6e31faa08e | 19 | } |
| martydd3 | 7:5f6e31faa08e | 20 | |
| pspatel321 | 17:c9ce210f6654 | 21 | uint16_t PollSwitch::poll(){ |
| martydd3 | 7:5f6e31faa08e | 22 | int i = 0; |
| martydd3 | 7:5f6e31faa08e | 23 | |
| martydd3 | 7:5f6e31faa08e | 24 | // if a low signal is detected, previous switch is broken |
| pspatel321 | 17:c9ce210f6654 | 25 | for(i = 1; i < sizeof(sw)/sizeof(sw[0]); i++){ |
| pspatel321 | 17:c9ce210f6654 | 26 | if(!sw[i].read()) |
| martydd3 | 7:5f6e31faa08e | 27 | break; |
| martydd3 | 7:5f6e31faa08e | 28 | } |
| martydd3 | 7:5f6e31faa08e | 29 | |
| martydd3 | 7:5f6e31faa08e | 30 | // bit on: switch may be broken |
| pspatel321 | 29:f148490b5f65 | 31 | if (i < sizeof(sw)/sizeof(sw[0])) { |
| pspatel321 | 29:f148490b5f65 | 32 | switchState = (1 << i); |
| pspatel321 | 29:f148490b5f65 | 33 | return (1 << i); |
| pspatel321 | 29:f148490b5f65 | 34 | } else return 0; |
| martydd3 | 7:5f6e31faa08e | 35 | } |
