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.
Revision 6:9ad19444c9ce, committed 2017-09-26
- Comitter:
- malcolmlear
- Date:
- Tue Sep 26 08:09:38 2017 +0000
- Parent:
- 5:7eea83fb1cb4
- Commit message:
- New Lab Board Test
Changed in this revision
| main.cpp | Show annotated file Show diff for this revision Revisions of this file |
--- a/main.cpp Fri Jan 27 08:54:23 2017 +0000
+++ b/main.cpp Tue Sep 26 08:09:38 2017 +0000
@@ -41,8 +41,8 @@
void SetLED(short LEDNo, short LEDState) {
LEDNo = ((LEDNo - 1) & 0x0007) + 1; // limit led number
+ LEDState = LEDState & 0x0003; // limit led state
LEDNo = (8 - LEDNo) * 2; // offset of led state in 'LEDbits'
- LEDState = LEDState & 0x0003; // limit led state
LEDState = LEDState << LEDNo;
short statemask = ((0x0003 << LEDNo) ^ 0xffff); // mask used to clear led state
LEDbits = ((LEDbits & statemask) | LEDState); // clear and set led state
@@ -52,9 +52,8 @@
short ReadLED(short LEDNo) {
LEDNo = ((LEDNo - 1) & 0x0007) + 1; // limit led number
LEDNo = (8 - LEDNo) * 2; // offset of led state in 'LEDbits'
- short LEDState = LEDbits;
- LEDState = LEDState >> LEDNo; // shift selected led state into ls 2 bits
- return (LEDState & 0x0003); // mask out and return led state
+ short LEDState = (LEDbits >> LEDNo) & 0x0003; // shift selected led state into ls 2 bits
+ return LEDState; // return led state
}
short ReadLEDs() {
@@ -71,7 +70,7 @@
SelInput(5); // select least significant 4 switches in[3:0]
short Switches = In0 + (In1 << 1) + (In2 << 2) + (In3 << 3);
SelInput(4); // select most significant 4 switches in[3:0]
- return (Switches + (In0 << 4)+ (In1 << 5) + (In2 << 6) + (In3 << 7));
+ return (Switches + (In0 << 4) + (In1 << 5) + (In2 << 6) + (In3 << 7));
}
short ReadSwitch(short SwitchNo) {
@@ -86,11 +85,11 @@
SelInput(0); // select Keypad top row
short Keys = (In0 << 15) + (In1 << 14) + (In2 << 13) + (In3 << 12);
SelInput(1); // select Keypad second row
- Keys = Keys + (In0 << 3) + (In1 << 6) + (In2 << 9) + (In3 << 11);
+ Keys += (In0 << 3) + (In1 << 6) + (In2 << 9) + (In3 << 11);
SelInput(2); // select Keypad third row
- Keys = Keys + (In0 << 2) + (In1 << 5) + (In2 << 8) + In3;
+ Keys += (In0 << 2) + (In1 << 5) + (In2 << 8) + In3;
SelInput(3); // select Keypad forth row
- Keys = Keys + (In0 << 1) + (In1 << 4) + (In2 << 7) + (In3 << 10);
+ Keys += (In0 << 1) + (In1 << 4) + (In2 << 7) + (In3 << 10);
return (Keys ^ 0xffff); // return inverted (Key press active high)
}